1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use super::{NoiseDomain, perm_table::PermTable, helpers::{EmptyConfig, SeedOnlyNoise}};
use sized_matrix::Vector;
#[derive(Copy, Clone)]
pub struct WhiteNoise {
perm_table: PermTable,
}
impl WhiteNoise {
pub fn new() -> EmptyConfig<Self> {
EmptyConfig::new()
}
}
impl SeedOnlyNoise for WhiteNoise {
type Seed = u64;
type Value = u8;
fn seed(seed: u64) -> Self {
Self {
perm_table: PermTable::new(seed)
}
}
}
impl<const N: usize> NoiseDomain<Vector<u8, N>> for WhiteNoise {
fn noise(&self, pos: Vector<u8, N>) -> u8 {
let mut acc: u8 = 0;
for i in 0..N {
acc = self.perm_table.0[acc.wrapping_add(pos[i]) as usize];
}
acc
}
}