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 { ...@@ -156,25 +156,37 @@ impl Slide for Automata {
} => { } => {
// Iterate grid ~5 times a second. // Iterate grid ~5 times a second.
if self.governor.ready(ui.ctx().input().time, 0.2) { if self.governor.ready(ui.ctx().input().time, 0.2) {
if *iterations == 10 { // Schedule some special events at some interation counts.
// Automatically begin expansion. match *iterations {
*expanding = true; 10 => {
} else if *iterations == 20 { // Automatically begin expansion.
// Draw a vertical line on the left to create a cool pattern. *expanding = true;
for y in 4..self.life.size_cells - 4 {
self.life.set_fill(2, y, Color32::BLACK);
} }
} else if *iterations == 30 { 20 => {
// Draw another set of lines to create a cool pattern. for y in 4..self.life.size_cells - 4 {
for x in 4..self.life.size_cells - 4 { // Line on the left.
// Solid line at the bottom. self.life.set_fill(2, y, Color32::BLACK);
self.life
.set_fill(x, self.life.size_cells - 2, Color32::BLACK); // Line with gaps on the right.
// Line with gaps at the top. if y < self.life.size_cells - 11 && y % 8 != 0 {
if x % 6 != 0 { self.life
self.life.set_fill(x, 2, Color32::BLACK); .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. // 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