From d1f515b17d0dd4439aa237d9bbe2eea8464dff7f Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 27 Mar 2025 14:35:54 -0400 Subject: [PATCH] cleanup Buf struct --- src/buffer.rs | 12 ++++++++---- src/grid.rs | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) 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, }