From fa8118bb781d2311e77e2bc86fafe55f5f328e49 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 2 May 2025 16:12:54 +0200 Subject: [PATCH] tweak visuals --- src/app.rs | 2 +- src/rules.rs | 11 +++++++---- src/simulation.rs | 9 ++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/app.rs b/src/app.rs index 1b5ee67..78a0474 100644 --- a/src/app.rs +++ b/src/app.rs @@ -45,7 +45,7 @@ impl App { connection, sim: Simulation::new(), terminated: false, - target_duration: FRAME_PACING, + target_duration: FRAME_PACING * 4, pixels: Bitmap::max_sized(), luma: BrightnessGrid::new(TILE_WIDTH, TILE_HEIGHT), } diff --git a/src/rules.rs b/src/rules.rs index b7432d7..40b984f 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -12,8 +12,11 @@ pub struct Rules type Kernel3x3 = [[bool; 3]; 3]; -pub const MOORE_NEIGHBORHOOD: Kernel3x3 = - [[true, true, true], [true, false, true], [true, true, true]]; +pub const MOORE_NEIGHBORHOOD: Kernel3x3 = [ + [true, true, true], + [true, false, true], + [true, true, true] +]; pub const NEUMANN_NEIGHBORHOOD: Kernel3x3 = [ [false, true, false], @@ -83,8 +86,8 @@ pub fn generate_u8b3() -> Rules { &[], ); - let add = rng.gen_range(5..40); - let sub = rng.gen_range(5..40); + let add = rng.gen_range(1..15); + let sub = rng.gen_range(1..15); println_info(format!("generated u8b3: Birth {birth:?} Survival {survive:?}, kernel: {kernel:?}, alive_thresh: {alive_threshold}, delta: {add}/{sub}")); diff --git a/src/simulation.rs b/src/simulation.rs index a3a8e51..03e03d2 100644 --- a/src/simulation.rs +++ b/src/simulation.rs @@ -75,10 +75,8 @@ impl Simulation { self.left_pixels.step(); self.right_pixels.step(); - if self.iteration % Wrapping(10) == Wrapping(0) { - self.left_luma.step(); - self.right_luma.step(); - } + self.left_luma.step(); + self.right_luma.step(); self.iteration += Wrapping(1u8); @@ -121,7 +119,8 @@ impl Simulation { }; for y in 0..luma.height() { let set = left_or_right.get(x, y) as f32 / u8::MAX as f32 * u8::from(Brightness::MAX) as f32; - let set = Brightness::try_from(set as u8).unwrap(); + let set = (set as u8).max(1); + let set = Brightness::try_from(set).unwrap(); luma.set(x, y, set); } }