terrain_forge/noise/
mod.rs1mod fbm;
4mod modifiers;
5mod perlin;
6mod ridged;
7mod simplex;
8mod value;
9mod worley;
10
11pub use fbm::Fbm;
12pub use modifiers::*;
13pub use perlin::Perlin;
14pub use ridged::Ridged;
15pub use simplex::Simplex;
16pub use value::Value;
17pub use worley::Worley;
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 {
30 source: self,
31 factor,
32 }
33 }
34
35 fn offset(self, amount: f64) -> Offset<Self> {
37 Offset {
38 source: self,
39 amount,
40 }
41 }
42
43 fn clamp(self, min: f64, max: f64) -> Clamp<Self> {
45 Clamp {
46 source: self,
47 min,
48 max,
49 }
50 }
51
52 fn abs(self) -> Abs<Self> {
54 Abs { source: self }
55 }
56
57 fn fbm(self, octaves: u32, lacunarity: f64, persistence: f64) -> Fbm<Self> {
59 Fbm::new(self, octaves, lacunarity, persistence)
60 }
61}
62
63impl<T: NoiseSource> NoiseExt for T {}