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
impl Normal
Sourcepub const fn new(value: f32) -> Self
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 theNormalwith
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
Sourcepub fn try_from(value: f32) -> Result<Self, NormalOutOfRange>
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].
Sourcepub const fn set(&mut self, value: f32)
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 theNormalwith
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
Sourcepub fn try_set(&mut self, value: f32) -> Result<(), NormalOutOfRange>
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].
Sourcepub fn as_f32_inv(&self) -> f32
pub fn as_f32_inv(&self) -> f32
Returns the inverse value (1.0 - value) of the Normal as an f32