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
use noise_fns::NoiseFn; /// Noise function that outputs a constant value. /// /// This function takes a input, value, and returns that input for all points, /// producing a constant-valued field. /// /// This function is not very useful by itself, but can be used as a source /// function for other noise functions. #[derive(Clone, Copy, Debug)] pub struct Constant { /// Constant value. pub value: f64, } impl Constant { pub fn new(value: f64) -> Self { Self { value } } } impl<T: Copy> NoiseFn<T> for Constant { fn get(&self, _point: T) -> f64 { self.value } }