cleanup Buf struct

This commit is contained in:
Simon Gardling 2025-03-27 14:35:54 -04:00
parent 75fab93907
commit d1f515b17d
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 9 additions and 5 deletions

View File

@ -1,13 +1,17 @@
#[derive(Debug, Clone)]
pub struct Buf {
pub width: usize,
pub height: usize,
width: usize,
height: usize,
pub buf: Vec<f32>,
}
impl Buf {
pub const fn new(width: usize, height: usize, buf: Vec<f32>) -> 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.

View File

@ -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,
}