Skip to main content

webizen_runtime/
diffusion.rs

1#[derive(Debug, Clone, Copy)]
2pub struct DiffusionConfig {
3    pub width: u32,
4    pub height: u32,
5    pub diffusion_rate: f32,
6}
7
8impl DiffusionConfig {
9    /// `cell` count.
10    pub fn cell_count(&self) -> usize {
11        self.width as usize * self.height as usize
12    }
13
14    /// `raw-byte` length.
15    pub fn raw_byte_len(&self) -> u64 {
16        (self.cell_count() * std::mem::size_of::<f32>()) as u64
17    }
18}
19
20#[derive(Debug, Clone, Copy)]
21pub struct DiffusionField {
22    pub dimensions: (u32, u32),
23    pub epoch: u64,
24}
25
26impl DiffusionField {
27    /// Creates a new instance.
28    pub fn new(dimensions: (u32, u32)) -> Self {
29        Self {
30            dimensions,
31            epoch: 0,
32        }
33    }
34}