1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
use noise_fns::NoiseFn;

/// Noise function that inverts the output value from the source function.
pub struct Invert<'a, T: 'a> {
    /// Outputs a value.
    pub source: &'a NoiseFn<T>,
}

impl<'a, T> Invert<'a, T> {
    pub fn new(source: &'a NoiseFn<T>) -> Self {
        Invert { source }
    }
}

impl<'a, T> NoiseFn<T> for Invert<'a, T> {
    fn get(&self, point: T) -> f64 {
        -self.source.get(point)
    }
}