diff --git a/src/buffer.rs b/src/buffer.rs index f44f953..09308e0 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -1,13 +1,17 @@ #[derive(Debug, Clone)] pub struct Buf { - pub width: usize, - pub height: usize, + width: usize, + height: usize, pub buf: Vec, } impl Buf { - pub const fn new(width: usize, height: usize, buf: Vec) -> Self { - Buf { width, height, buf } + pub fn new(width: usize, height: usize) -> Self { + Buf { + width, + height, + buf: vec![0.0; height * width], + } } // Truncate x and y and return a corresponding index into the data slice. diff --git a/src/grid.rs b/src/grid.rs index 24bc0ff..3ac5443 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -71,7 +71,7 @@ impl Grid { height, data, config: PopulationConfig::new(rng), - buf: Buf::new(width, height, vec![0.0; width * height]), + buf: Buf::new(width, height), blur: Blur::new(width), agents, }