Struct NoiseFn

Source
pub struct NoiseFn<F, const WITH_SEED: bool>(pub F);
Expand description

Wraps a function to make it implement Sample.

The function is expected to take one parameter for the point and optionally a seed parameter.

Tuple Fields§

§0: F

Trait Implementations§

Source§

impl<F, const WITH_SEED: bool> Noise for NoiseFn<F, WITH_SEED>

Source§

fn sample2<Point>(&self, point: Point) -> f32
where Self: Sized + Sample<2>, Point: Into<[f32; 2]>,

Samples the noise in 2D.
Source§

fn sample3<Point>(&self, point: Point) -> f32
where Self: Sized + Sample<3>, Point: Into<[f32; 3]>,

Samples the noise in 3D.
Source§

fn sample4<Point>(&self, point: Point) -> f32
where Self: Sized + Sample<4>, Point: Into<[f32; 4]>,

Samples the noise in 3D.
Source§

fn sample2a<Point>(&self, point: Point) -> f32
where Self: Sized + Sample<2, f32x2>, Point: Into<f32x2>,

Available on crate feature nightly-simd only.
Samples the noise in 2D.
Source§

fn sample3a<Point>(&self, point: Point) -> f32
where Self: Sized + Sample<3, f32x4>, Point: Into<f32x4>,

Available on crate feature nightly-simd only.
Samples the noise in 3D.
Source§

fn sample4a<Point>(&self, point: Point) -> f32
where Self: Sized + Sample<4, f32x4>, Point: Into<f32x4>,

Available on crate feature nightly-simd only.
Samples the noise in 4D.
Source§

fn seed(self, seed: i32) -> Seeded<Self>
where Self: Sized,

Overwrites the seed to be sampled with. Read more
Source§

fn add_seed(self, value: i32) -> AddSeed<Self>
where Self: Sized,

Adds value to the seed.
Source§

fn mul_seed(self, value: i32) -> MulSeed<Self>
where Self: Sized,

Multiplies the seed by value.
Source§

fn frequency<F>(self, frequency: F) -> Frequency<Self, F::Noise>
where Self: Sized, F: ValueOrNoise,

Modifies a noise with a frequency multiplier. Read more
Source§

fn fbm(self, octaves: u32, gain: f32, lacunarity: f32) -> Fbm<Self>
where Self: Sized,

Creates a fractal from this noise with the provided octaves, gain and lacunarity. Read more
Source§

fn ridged(self) -> Ridged<Self>
where Self: Sized,

Modifies a noise to create a peak at 0. Read more
Source§

fn triangle_wave<F>(self, frequency: F) -> TriangleWave<Self, F::Noise>
where Self: Sized, F: ValueOrNoise,

Applies a triangle wave to the output of a noise function. Read more
Source§

fn tileable(self, width: f32, height: f32) -> Tileable<Self>
where Self: Sized,

Creates a tileable 2D noise from a 4D noise. Read more
Source§

fn translate_x<X>(self, x: X) -> TranslateX<Self, X::Noise>
where Self: Sized, X: ValueOrNoise,

Translates the point before it is used to sample self.
Source§

fn translate_xy<X, Y>(self, x: X, y: Y) -> TranslateXy<Self, X::Noise, Y::Noise>
where Self: Sized, X: ValueOrNoise, Y: ValueOrNoise,

Translates the point before it is used to sample self.
Source§

fn translate_xyz<X, Y, Z>( self, x: X, y: Y, z: Z, ) -> TranslateXyz<Self, X::Noise, Y::Noise, Z::Noise>
where Self: Sized, X: ValueOrNoise, Y: ValueOrNoise, Z: ValueOrNoise,

Translates the point before it is used to sample self.
Source§

fn translate_xyzw<X, Y, Z, W>( self, x: X, y: Y, z: Z, w: W, ) -> TranslateXyzw<Self, X::Noise, Y::Noise, Z::Noise, W::Noise>

Translates the point before it is used to sample self.
Source§

fn add<Rhs>(self, rhs: Rhs) -> Add<Self, Rhs::Noise>
where Self: Sized, Rhs: ValueOrNoise,

Adds the output values.
Source§

fn sub<Rhs>(self, rhs: Rhs) -> Sub<Self, Rhs::Noise>
where Self: Sized, Rhs: ValueOrNoise,

Subtracts one output value from the other.
Source§

fn mul<Rhs>(self, rhs: Rhs) -> Mul<Self, Rhs::Noise>
where Self: Sized, Rhs: ValueOrNoise,

Multiplies the output values.
Source§

fn div<Rhs>(self, rhs: Rhs) -> Div<Self, Rhs::Noise>
where Self: Sized, Rhs: ValueOrNoise,

Divides one output value by the other.
Source§

fn rem<Rhs>(self, rhs: Rhs) -> Rem<Self, Rhs::Noise>
where Self: Sized, Rhs: ValueOrNoise,

Calculates the remainder from dividing one output value by the other.
Source§

fn min<Rhs>(self, rhs: Rhs) -> Min<Self, Rhs::Noise>
where Self: Sized, Rhs: ValueOrNoise,

Computes the minimum of the two output values.
Source§

fn max<Rhs>(self, rhs: Rhs) -> Max<Self, Rhs::Noise>
where Self: Sized, Rhs: ValueOrNoise,

Computes the maximum of the two output values.
Source§

fn clamp<Min, Max>( self, min: Min, max: Max, ) -> Clamp<Self, Min::Noise, Max::Noise>
where Self: Sized, Min: ValueOrNoise, Max: ValueOrNoise,

Returns max if value is greater than max and min if value is less than min. Otherwise this will return value. Read more
Source§

fn lerp<B, T>(self, b: B, t: T) -> Lerp<Self, B::Noise, T::Noise>
where Self: Sized, B: ValueOrNoise, T: ValueOrNoise,

Linearly interpolates between self and b.
Source§

fn pow<Rhs>(self, rhs: Rhs) -> Pow<Self, Rhs::Noise>
where Self: Sized, Rhs: ValueOrNoise,

Raises the output value to a power.
Source§

fn neg(self) -> Neg<Self>
where Self: Sized,

Performs negation on the output value.
Source§

fn abs(self) -> Abs<Self>
where Self: Sized,

Computes the absolute value of the output value.
Source§

fn sqrt(self) -> Sqrt<Self>
where Self: Sized,

Returns the square root of a number. Read more
Source§

fn floor(self) -> Floor<Self>
where Self: Sized,

Computes the largest integer less than or equal to the output value.
Source§

fn ceil(self) -> Ceil<Self>
where Self: Sized,

Computes the smallest integer greater than or equal to self.
Source§

fn round(self) -> Round<Self>
where Self: Sized,

Computes the nearest integer to the output value. If a value is half-way between two integers, round away from 0.0.
Source§

fn sin(self) -> Sin<Self>
where Self: Sized,

Computes the sine of the output value (in radians).
Source§

fn cos(self) -> Cos<Self>
where Self: Sized,

Computes the cosine of the output value (in radians).
Source§

fn tan(self) -> Tan<Self>
where Self: Sized,

Computes the tangent of the output value (in radians).
Source§

fn map<F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: Fn(f32) -> f32,

Maps the output value.
Source§

fn by_ref(&self) -> &Self
where Self: Sized,

Returns the Noise by reference. Read more
Source§

impl<const DIM: usize, Point, F> Sample<DIM, Point> for NoiseFn<F, false>
where F: Fn(Point) -> f32,

Source§

fn sample_with_seed(&self, point: Point, _seed: i32) -> f32

Source§

impl<const DIM: usize, Point, F> Sample<DIM, Point> for NoiseFn<F, true>
where F: Fn(Point, i32) -> f32,

Source§

fn sample_with_seed(&self, point: Point, seed: i32) -> f32

Auto Trait Implementations§

§

impl<F, const WITH_SEED: bool> Freeze for NoiseFn<F, WITH_SEED>
where F: Freeze,

§

impl<F, const WITH_SEED: bool> RefUnwindSafe for NoiseFn<F, WITH_SEED>
where F: RefUnwindSafe,

§

impl<F, const WITH_SEED: bool> Send for NoiseFn<F, WITH_SEED>
where F: Send,

§

impl<F, const WITH_SEED: bool> Sync for NoiseFn<F, WITH_SEED>
where F: Sync,

§

impl<F, const WITH_SEED: bool> Unpin for NoiseFn<F, WITH_SEED>
where F: Unpin,

§

impl<F, const WITH_SEED: bool> UnwindSafe for NoiseFn<F, WITH_SEED>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<N> ValueOrNoise for N
where N: Noise,