next #1
|
@ -45,7 +45,7 @@ impl App {
|
||||||
connection,
|
connection,
|
||||||
sim: Simulation::new(),
|
sim: Simulation::new(),
|
||||||
terminated: false,
|
terminated: false,
|
||||||
target_duration: FRAME_PACING,
|
target_duration: FRAME_PACING * 4,
|
||||||
pixels: Bitmap::max_sized(),
|
pixels: Bitmap::max_sized(),
|
||||||
luma: BrightnessGrid::new(TILE_WIDTH, TILE_HEIGHT),
|
luma: BrightnessGrid::new(TILE_WIDTH, TILE_HEIGHT),
|
||||||
}
|
}
|
||||||
|
|
11
src/rules.rs
11
src/rules.rs
|
@ -12,8 +12,11 @@ pub struct Rules<T: Value>
|
||||||
|
|
||||||
type Kernel3x3 = [[bool; 3]; 3];
|
type Kernel3x3 = [[bool; 3]; 3];
|
||||||
|
|
||||||
pub const MOORE_NEIGHBORHOOD: Kernel3x3 =
|
pub const MOORE_NEIGHBORHOOD: Kernel3x3 = [
|
||||||
[[true, true, true], [true, false, true], [true, true, true]];
|
[true, true, true],
|
||||||
|
[true, false, true],
|
||||||
|
[true, true, true]
|
||||||
|
];
|
||||||
|
|
||||||
pub const NEUMANN_NEIGHBORHOOD: Kernel3x3 = [
|
pub const NEUMANN_NEIGHBORHOOD: Kernel3x3 = [
|
||||||
[false, true, false],
|
[false, true, false],
|
||||||
|
@ -83,8 +86,8 @@ pub fn generate_u8b3() -> Rules<u8> {
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
|
|
||||||
let add = rng.gen_range(5..40);
|
let add = rng.gen_range(1..15);
|
||||||
let sub = rng.gen_range(5..40);
|
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}"));
|
println_info(format!("generated u8b3: Birth {birth:?} Survival {survive:?}, kernel: {kernel:?}, alive_thresh: {alive_threshold}, delta: {add}/{sub}"));
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,8 @@ impl Simulation {
|
||||||
self.left_pixels.step();
|
self.left_pixels.step();
|
||||||
self.right_pixels.step();
|
self.right_pixels.step();
|
||||||
|
|
||||||
if self.iteration % Wrapping(10) == Wrapping(0) {
|
self.left_luma.step();
|
||||||
self.left_luma.step();
|
self.right_luma.step();
|
||||||
self.right_luma.step();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.iteration += Wrapping(1u8);
|
self.iteration += Wrapping(1u8);
|
||||||
|
|
||||||
|
@ -121,7 +119,8 @@ impl Simulation {
|
||||||
};
|
};
|
||||||
for y in 0..luma.height() {
|
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 = 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);
|
luma.set(x, y, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue