Trait libnoise::Generator2D

source ·
pub trait Generator2D: Generator<2> {
    // Provided methods
    fn rotate(self, rotation: [f64; 1]) -> Rotate<2, 1, Self> { ... }
    fn displace_x<GA>(
        self,
        displacement_generator: GA
    ) -> Displace<2, 0, Self, GA>
       where GA: Generator<2> { ... }
    fn displace_y<GA>(
        self,
        displacement_generator: GA
    ) -> Displace<2, 1, Self, GA>
       where GA: Generator<2> { ... }
}
Expand description

A trait representing the specialization of Generator<D> for 2-dimensional input spaces.

Anything implementing this trait must also implement Generator<2>. This trait exists for two reasons: The first is to provide functions that either only make sense for specific dimensionalities, or are either too difficult or inefficient to implement in a dimension-agnostic manner. The second is to bypass certain limitations of constant generics.

Provided Methods§

source

fn rotate(self, rotation: [f64; 1]) -> Rotate<2, 1, Self>

Create a generator which rotates input points before passing them to the underlying generator.

Takes an angle in radians for each unique pair of axes in the input space and crates a generator which rotates each input point for the provided angle on the plane spanned by each axis pair, before passing it to the underlying generator. The specific plane of rotation for each angle is as follows:

plane of rotationcorresponding angle
xy-planerotation[0]
Examples

Basic usage:

let point = [0.2, 0.5];

let generator = Source::simplex(42)     // build a generator
    .rotate([0.4]);                     // apply the adapter

let value = generator.sample(point);    // sample the generator
source

fn displace_x<GA>(self, displacement_generator: GA) -> Displace<2, 0, Self, GA>
where GA: Generator<2>,

Create a generator providing the results of the underlying generator after displacing the x-coordinate by the result of the provided generator.

Creates a generator which is exactly the same as the underlying generator, except the x-coordinate of the input point is first displaced by the result of displacement_generator for that point.

Examples

Basic usage:

let mut point = [0.2, 0.5];

let generator = Source::simplex(42)     // build a generator
    .displace_x(Source::simplex(43));   // apply the adapter

let value = generator.sample(point);    // sample the generator

point[0] += Source::simplex(43).sample(point);
assert_eq!(value, Source::simplex(42).sample(point))
source

fn displace_y<GA>(self, displacement_generator: GA) -> Displace<2, 1, Self, GA>
where GA: Generator<2>,

Create a generator providing the results of the underlying generator after displacing the y-coordinate by the result of the provided generator.

Creates a generator which is exactly the same as the underlying generator, except the y-coordinate of the input point is first displaced by the result of displacement_generator for that point.

Examples

Basic usage:

let mut point = [0.2, 0.5];

let generator = Source::simplex(42)     // build a generator
    .displace_y(Source::simplex(43));   // apply the adapter

let value = generator.sample(point);    // sample the generator

point[1] += Source::simplex(43).sample(point);
assert_eq!(value, Source::simplex(42).sample(point))

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Generator2D for Checkerboard<2>

source§

impl Generator2D for Constant<2>

source§

impl Generator2D for ImprovedPerlin<2>

source§

impl Generator2D for Perlin<2>

source§

impl Generator2D for Simplex<2>

source§

impl Generator2D for Value<2>

source§

impl Generator2D for Worley<2>

source§

impl<G: Generator<2>> Generator2D for Abs<2, G>

source§

impl<G: Generator<2>> Generator2D for Add<2, G>

source§

impl<G: Generator<2>> Generator2D for Billow<2, G>

source§

impl<G: Generator<2>> Generator2D for Clamp<2, G>

source§

impl<G: Generator<2>> Generator2D for Exp<2, G>

source§

impl<G: Generator<2>> Generator2D for Fbm<2, G>

source§

impl<G: Generator<2>> Generator2D for Mul<2, G>

source§

impl<G: Generator<2>> Generator2D for Neg<2, G>

source§

impl<G: Generator<2>> Generator2D for Pow<2, G, f64>

source§

impl<G: Generator<2>> Generator2D for Pow<2, G, i32>

source§

impl<G: Generator<2>> Generator2D for RidgedMulti<2, G>

source§

impl<G: Generator<2>> Generator2D for Rotate<2, 1, G>

source§

impl<G: Generator<2>> Generator2D for Scale<2, G>

source§

impl<G: Generator<2>> Generator2D for Translate<2, G>

source§

impl<G: Generator<2>, L: Fn(f64) -> f64 + Copy> Generator2D for Lambda<2, G, L>

source§

impl<GA: Generator<2>, GB: Generator<2>> Generator2D for Max<2, GA, GB>

source§

impl<GA: Generator<2>, GB: Generator<2>> Generator2D for Min<2, GA, GB>

source§

impl<GA: Generator<2>, GB: Generator<2>> Generator2D for Power<2, GA, GB>

source§

impl<GA: Generator<2>, GB: Generator<2>> Generator2D for Product<2, GA, GB>

source§

impl<GA: Generator<2>, GB: Generator<2>> Generator2D for Sum<2, GA, GB>

source§

impl<GA: Generator<2>, GB: Generator<2>, GC: Generator<2>> Generator2D for Blend<2, GA, GB, GC>

source§

impl<GA: Generator<2>, GB: Generator<2>, GC: Generator<2>> Generator2D for Select<2, GA, GB, GC>

source§

impl<N: Fn([f64; 2]) -> f64> Generator2D for Custom<2, N>

source§

impl<const A: usize, G: Generator<2>, GA: Generator<2>> Generator2D for Displace<2, A, G, GA>