Skip to content
Snippets Groups Projects
Commit babe06d6 authored by Finn Bear's avatar Finn Bear
Browse files

Improve automata slide.

parent 4f8e64fc
No related branches found
No related tags found
No related merge requests found
......@@ -156,25 +156,37 @@ impl Slide for Automata {
} => {
// Iterate grid ~5 times a second.
if self.governor.ready(ui.ctx().input().time, 0.2) {
if *iterations == 10 {
// Automatically begin expansion.
*expanding = true;
} else if *iterations == 20 {
// Draw a vertical line on the left to create a cool pattern.
for y in 4..self.life.size_cells - 4 {
self.life.set_fill(2, y, Color32::BLACK);
// Schedule some special events at some interation counts.
match *iterations {
10 => {
// Automatically begin expansion.
*expanding = true;
}
} else if *iterations == 30 {
// Draw another set of lines to create a cool pattern.
for x in 4..self.life.size_cells - 4 {
// Solid line at the bottom.
self.life
.set_fill(x, self.life.size_cells - 2, Color32::BLACK);
// Line with gaps at the top.
if x % 6 != 0 {
self.life.set_fill(x, 2, Color32::BLACK);
20 => {
for y in 4..self.life.size_cells - 4 {
// Line on the left.
self.life.set_fill(2, y, Color32::BLACK);
// Line with gaps on the right.
if y < self.life.size_cells - 11 && y % 8 != 0 {
self.life
.set_fill(self.life.size_cells - 2, y, Color32::BLACK);
}
}
}
30 => {
// Draw another set of lines to create a cool pattern.
for x in 4..self.life.size_cells - 4 {
// Solid line at the bottom.
self.life
.set_fill(x, self.life.size_cells - 2, Color32::BLACK);
// Line with gaps at the top.
if x % 6 != 0 {
self.life.set_fill(x, 2, Color32::BLACK);
}
}
}
_ => {}
}
// Boolean to int cast yields 1 if true, 0 otherwise.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment