Skip to main content

Normal

Struct Normal 

Source
pub struct Normal(/* private fields */);
Expand description

An f32 value that is guaranteed to be constrained to the range of

0.0 >= value <= 1.0

§Example

use iced_audio::Normal;

let mut normal = Normal::new(-1.0);
assert_eq!(normal.as_f32(), 0.0);

normal.set(3.0);
assert_eq!(normal.as_f32(), 1.0);

normal.set(0.5);
assert_eq!(normal.as_f32(), 0.5);

Implementations§

Source§

impl Normal

Source

pub const MIN: Self

A Normal with the value 0.0.

Source

pub const CENTER: Self

A Normal with the value 0.5.

Source

pub const MAX: Self

A Normal with the value 1.0.

Source

pub const fn new(value: f32) -> Self

Creates a new Normal, clamping the provided value to the valid range of [0.0..=1.0].

§Arguments
  • value - the value to initialize the Normal with

if value < 0.0, then normal.value is set to 0.0

else if value > 1.0, then normal.value is set to 1.0

else normal.value is set to value

Source

pub fn try_from(value: f32) -> Result<Self, NormalOutOfRange>

Tries to create a Normal from the given value, erroring if the value is out of the range [0.0..=1.0].

Source

pub const fn set(&mut self, value: f32)

Sets a value for the Normal, clamping it to the valid range of [0.0..=1.0].

§Arguments
  • value - the value to set the Normal with

if value < 0.0, then normal.value is set to 0.0

else if value > 1.0, then normal.value is set to 1.0

else normal.value is set to value

Source

pub fn try_set(&mut self, value: f32) -> Result<(), NormalOutOfRange>

Tries to set a value for the Normal, erroring if the value is out of the range [0.0..=1.0].

Source

pub fn as_f32(&self) -> f32

Returns the value of the Normal as an f32

Source

pub fn as_f32_inv(&self) -> f32

Returns the inverse value (1.0 - value) of the Normal as an f32

Source

pub fn scale(&self, scalar: f32) -> f32

Returns the value of the Normal times the scalar

Source

pub fn scale_inv(&self, scalar: f32) -> f32

Returns the inverse value (1.0 - value) of the Normal times the scalar

Trait Implementations§

Source§

impl Clone for Normal

Source§

fn clone(&self) -> Normal

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Normal

Source§

impl Debug for Normal

Source§

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

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

impl Default for Normal

Source§

fn default() -> Normal

Returns the “default value” for a type. Read more
Source§

impl Display for Normal

Source§

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

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

impl From<Normal> for f32

Source§

fn from(normal: Normal) -> f32

Converts to this type from the input type.
Source§

impl From<Normal> for f64

Source§

fn from(normal: Normal) -> f64

Converts to this type from the input type.
Source§

impl From<Normal> for NormalParam

Source§

fn from(normal: Normal) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Normal

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Normal

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Normal

Source§

fn eq(&self, other: &Normal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Normal

Source§

fn partial_cmp(&self, other: &Normal) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Normal

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.