pub type EasingStep = Factor;
Expand description
Easing function output.
Usually in the [0..=1] range, but can overshoot. An easing function converts a EasingTime
into this factor.
§Examples
use zng_unit::*;
use zng_var::animation::easing::{EasingStep, EasingTime};
/// Cubic animation curve.
fn cubic(time: EasingTime) -> EasingStep {
let f = time.fct();
f * f * f
}
Note that all the common easing functions are implemented in easing
.
Aliased Type§
struct EasingStep(pub f32);
Fields§
§0: f32
Implementations
Source§impl Factor
impl Factor
Sourcepub fn clamp_range(self) -> Factor
pub fn clamp_range(self) -> Factor
Clamp factor to [0.0..=1.0]
range.
Sourcepub fn clamp(self, min: impl Into<Factor>, max: impl Into<Factor>) -> Factor
pub fn clamp(self, min: impl Into<Factor>, max: impl Into<Factor>) -> Factor
Returns self
if min <= self <= max
, returns min
if self < min
or returns max
if self > max
.
Sourcepub fn pct(self) -> FactorPercent
pub fn pct(self) -> FactorPercent
Factor as percentage.
Trait Implementations
Source§impl AddAssign for Factor
impl AddAssign for Factor
Source§fn add_assign(&mut self, rhs: Factor)
fn add_assign(&mut self, rhs: Factor)
Performs the
+=
operation. Read moreSource§impl<'de> Deserialize<'de> for Factor
impl<'de> Deserialize<'de> for Factor
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Factor, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Factor, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl DivAssign for Factor
impl DivAssign for Factor
Source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moreSource§impl From<FactorPercent> for Factor
impl From<FactorPercent> for Factor
Source§fn from(value: FactorPercent) -> Factor
fn from(value: FactorPercent) -> Factor
Converts to this type from the input type.
Source§impl IntoVar<EasingTime> for Factor
impl IntoVar<EasingTime> for Factor
Source§impl IntoVar<FactorPercent> for Factor
impl IntoVar<FactorPercent> for Factor
Source§impl MulAssign for Factor
impl MulAssign for Factor
Source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moreSource§impl PartialOrd for Factor
impl PartialOrd for Factor
Source§impl Serialize for Factor
impl Serialize for Factor
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl SubAssign for Factor
impl SubAssign for Factor
Source§fn sub_assign(&mut self, rhs: Factor)
fn sub_assign(&mut self, rhs: Factor)
Performs the
-=
operation. Read moreSource§impl Transitionable for Factor
impl Transitionable for Factor
Source§fn lerp(self, to: &Self, step: EasingStep) -> Self
fn lerp(self, to: &Self, step: EasingStep) -> Self
Sample the linear interpolation from
self
-> to
by step
.