Struct noise_functions::NoiseFn
source · pub struct NoiseFn<F>(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.
With a seed parameter it can be used for fractals:
use noise_functions::{ NoiseFn, Sample2, OpenSimplex2s };
let warped = NoiseFn(|point: [f32; 2], seed: i32| {
let warp_x = OpenSimplex2s.seed(seed + 100).sample2(point);
let warp_y = OpenSimplex2s.seed(seed + 200).sample2(point);
let warped = [point[0] + warp_x, point[1] + warp_y];
OpenSimplex2s.sample2(warped)
});
let warped_fbm = warped.fbm(3, 0.5, 2.0);
let value = warped_fbm.sample2([1.0, 2.0]);
Tuple Fields§
§0: F
Implementations§
source§impl<F> NoiseFn<F>
impl<F> NoiseFn<F>
pub const fn seed(self, seed: i32) -> Seeded<Self>
pub const fn frequency(self, frequency: f32) -> Frequency<Self>
sourcepub const fn fbm(self, octaves: u32, gain: f32, lacunarity: f32) -> Fbm<Self>
pub const fn fbm(self, octaves: u32, gain: f32, lacunarity: f32) -> Fbm<Self>
This function is const
if the feature nightly-const-fn-float
is enabled.
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for NoiseFn<F>where
F: Freeze,
impl<F> RefUnwindSafe for NoiseFn<F>where
F: RefUnwindSafe,
impl<F> Send for NoiseFn<F>where
F: Send,
impl<F> Sync for NoiseFn<F>where
F: Sync,
impl<F> Unpin for NoiseFn<F>where
F: Unpin,
impl<F> UnwindSafe for NoiseFn<F>where
F: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more