terrain_forge/noise/
mod.rs1mod perlin;
4mod value;
5mod fbm;
6mod modifiers;
7mod simplex;
8mod worley;
9mod ridged;
10
11pub use perlin::Perlin;
12pub use value::Value;
13pub use fbm::Fbm;
14pub use modifiers::*;
15pub use simplex::Simplex;
16pub use worley::Worley;
17pub use ridged::Ridged;
18
19pub trait NoiseSource {
21 fn sample(&self, x: f64, y: f64) -> f64;
23}
24
25pub trait NoiseExt: NoiseSource + Sized {
27 fn scale(self, factor: f64) -> Scale<Self> {
29 Scale { source: self, factor }
30 }
31
32 fn offset(self, amount: f64) -> Offset<Self> {
34 Offset { source: self, amount }
35 }
36
37 fn clamp(self, min: f64, max: f64) -> Clamp<Self> {
39 Clamp { source: self, min, max }
40 }
41
42 fn abs(self) -> Abs<Self> {
44 Abs { source: self }
45 }
46
47 fn fbm(self, octaves: u32, lacunarity: f64, persistence: f64) -> Fbm<Self> {
49 Fbm::new(self, octaves, lacunarity, persistence)
50 }
51}
52
53impl<T: NoiseSource> NoiseExt for T {}