Struct cgl_rs::noise::NoiseParams

source ·
#[repr(C)]
pub struct NoiseParams { pub type_id: i32, pub fractal_type: i32, pub octaves: i32, pub frequency: NoiseDataType, pub lacunarity: NoiseDataType, pub gain: NoiseDataType, pub weighted_strength: NoiseDataType, pub ping_pong_strength: NoiseDataType, }

Fields§

§type_id: i32§fractal_type: i32§octaves: i32§frequency: NoiseDataType§lacunarity: NoiseDataType§gain: NoiseDataType§weighted_strength: NoiseDataType§ping_pong_strength: NoiseDataType

Implementations§

source§

impl NoiseParams

source

pub fn new() -> Self

Creates a new NoiseParams instance with default values.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
cgl_rs::noise::shutdown();
source

pub fn set_type(&mut self, noise_type: NoiseType)

Sets the type of noise to generate.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
params.set_type(cgl_rs::noise::NoiseType::Perlin);
cgl_rs::noise::shutdown();
source

pub fn set_fractal_type(&mut self, fractal_type: FractalType)

Sets the type of fractal to use when generating noise.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
params.set_fractal_type(cgl_rs::noise::FractalType::FBM);
cgl_rs::noise::shutdown();
source

pub fn set_octaves(&mut self, octaves: i32)

Sets the number of octaves to use when generating noise.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
params.set_octaves(4);
cgl_rs::noise::shutdown();
source

pub fn set_frequency(&mut self, frequency: NoiseDataType)

Sets the frequency of the noise.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
params.set_frequency(0.01);
cgl_rs::noise::shutdown();
source

pub fn set_lacunarity(&mut self, lacunarity: NoiseDataType)

Sets the lacunarity of the noise.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
params.set_lacunarity(2.0);
cgl_rs::noise::shutdown();
source

pub fn set_gain(&mut self, gain: NoiseDataType)

Sets the gain of the noise.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
params.set_gain(0.5);
cgl_rs::noise::shutdown();
source

pub fn set_weighted_strength(&mut self, weighted_strength: NoiseDataType)

Sets the weighted strength of the noise.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
params.set_weighted_strength(0.5);
cgl_rs::noise::shutdown();
source

pub fn set_ping_pong_strength(&mut self, ping_pong_strength: NoiseDataType)

Sets the ping pong strength of the noise.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
params.set_ping_pong_strength(0.5);
cgl_rs::noise::shutdown();
source

pub fn get_type(&self) -> NoiseType

Gets the type of noise being generated.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
let noise_type = params.get_type();
cgl_rs::noise::shutdown();
source

pub fn get_fractal_type(&self) -> FractalType

Gets the type of fractal being used to generate noise.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
let fractal_type = params.get_fractal_type();
cgl_rs::noise::shutdown();
source

pub fn get_octaves(&self) -> i32

Gets the number of octaves being used to generate noise.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
let octaves = params.get_octaves();
cgl_rs::noise::shutdown();
source

pub fn get_frequency(&self) -> NoiseDataType

Gets the frequency of the noise.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
let frequency = params.get_frequency();
cgl_rs::noise::shutdown();
source

pub fn get_lacunarity(&self) -> NoiseDataType

Gets the lacunarity of the noise.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
let lacunarity = params.get_lacunarity();
cgl_rs::noise::shutdown();
source

pub fn get_gain(&self) -> NoiseDataType

Gets the gain of the noise.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
let gain = params.get_gain();
cgl_rs::noise::shutdown();
source

pub fn get_weighted_strength(&self) -> NoiseDataType

Gets the weighted strength of the noise.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
let weighted_strength = params.get_weighted_strength();
cgl_rs::noise::shutdown();
source

pub fn get_ping_pong_strength(&self) -> NoiseDataType

Gets the ping pong strength of the noise.

Example
cgl_rs::noise::init();
let params = cgl_rs::noise::NoiseParams::new();
let ping_pong_strength = params.get_ping_pong_strength();
cgl_rs::noise::shutdown();
source

pub fn get_noise( &self, x: NoiseDataType, y: NoiseDataType, z: NoiseDataType ) -> NoiseDataType

Generates noise using the current parameters.

Example
cgl_rs::noise::init();
let mut params = cgl_rs::noise::NoiseParams::new();
let noise = params.get_noise(0.0, 0.0, 0.0);
cgl_rs::noise::shutdown();
See also
  • cgl_rs::noise::get

Trait Implementations§

source§

impl Clone for NoiseParams

source§

fn clone(&self) -> NoiseParams

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for NoiseParams

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for NoiseParams

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.