noises_and_patterns/
pattern.rs1use crate::prelude::*;
2
3pub mod bricks;
4
5pub trait Pattern {
6
7 fn new() -> Self;
8
9 fn pattern_2d(&self, p: (FP, FP)) -> (FP, FP);
11
12 fn set_property(&mut self, name: &str, value: FP);
14
15 #[inline(always)]
17 fn hash21(&self, p: FP2) -> FP {
18 let mut p3 = glm::fract(&FP3::new(p.x * 0.1031, p.y * 0.1031, p.x * 0.1031));
19
20 let dot = glm::dot(&p3, &(FP3::new(p3.y + 33.333, p3.z + 33.333, p3.x + 33.333)));
21
22 p3.x += dot; p3.y += dot; p3.z += dot;
23 ((p3.x + p3.y) * p3.z).fract()
24 }
25}