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 position and optionally a seed parameter.
With a seed parameter it can be used for fractals:
use noise_functions::{ NoiseFn, Sample2, OpenSimplex2s };
let warped = NoiseFn(|pos: [f32; 2], seed: i32| {
let warp_x = OpenSimplex2s.seed(seed + 100).sample2(pos);
let warp_y = OpenSimplex2s.seed(seed + 200).sample2(pos);
let warped = [pos[0] + warp_x, pos[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.
sourcepub const fn fbm_weighted(
self,
octaves: u32,
gain: f32,
lacunarity: f32,
weighted_strength: f32
) -> FbmWeighted<Self>
pub const fn fbm_weighted( self, octaves: u32, gain: f32, lacunarity: f32, weighted_strength: f32 ) -> FbmWeighted<Self>
This function is const
if the feature nightly-const-fn-float
is enabled.
sourcepub const fn ridged(
self,
octaves: u32,
gain: f32,
lacunarity: f32
) -> Ridged<Self>
pub const fn ridged( self, octaves: u32, gain: f32, lacunarity: f32 ) -> Ridged<Self>
This function is const
if the feature nightly-const-fn-float
is enabled.
sourcepub const fn ridged_weighted(
self,
octaves: u32,
gain: f32,
lacunarity: f32,
weighted_strength: f32
) -> RidgedWeighted<Self>
pub const fn ridged_weighted( self, octaves: u32, gain: f32, lacunarity: f32, weighted_strength: f32 ) -> RidgedWeighted<Self>
This function is const
if the feature nightly-const-fn-float
is enabled.
sourcepub const fn ping_pong(
self,
octaves: u32,
gain: f32,
lacunarity: f32,
strength: f32
) -> PingPong<Self>
pub const fn ping_pong( self, octaves: u32, gain: f32, lacunarity: f32, strength: f32 ) -> PingPong<Self>
This function is const
if the feature nightly-const-fn-float
is enabled.
sourcepub const fn ping_pong_weighted(
self,
octaves: u32,
gain: f32,
lacunarity: f32,
strength: f32,
weighted_strength: f32
) -> PingPongWeighted<Self>
pub const fn ping_pong_weighted( self, octaves: u32, gain: f32, lacunarity: f32, strength: f32, weighted_strength: f32 ) -> PingPongWeighted<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