zng::var::animation::easing

Type Alias EasingStep

Source
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

Source

pub fn clamp_range(self) -> Factor

Clamp factor to [0.0..=1.0] range.

Source

pub fn max(self, other: impl Into<Factor>) -> Factor

Returns the maximum of two factors.

Source

pub fn min(self, other: impl Into<Factor>) -> Factor

Returns the minimum of two factors.

Source

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.

Source

pub fn abs(self) -> Factor

Computes the absolute value of self.

Source

pub fn flip(self) -> Factor

Flip factor, around 0.5,

Returns 1.0 - self.

Source

pub fn pct(self) -> FactorPercent

Factor as percentage.

Trait Implementations

Source§

impl Add for Factor

Source§

type Output = Factor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Factor) -> <Factor as Add>::Output

Performs the + operation. Read more
Source§

impl AddAssign for Factor

Source§

fn add_assign(&mut self, rhs: Factor)

Performs the += operation. Read more
Source§

impl Clone for Factor

Source§

fn clone(&self) -> Factor

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 Factor

Source§

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

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

impl<'de> Deserialize<'de> for Factor

Source§

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 Display for Factor

Source§

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

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

impl Div for Factor

Source§

type Output = Factor

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Factor) -> <Factor as Div>::Output

Performs the / operation. Read more
Source§

impl DivAssign for Factor

Source§

fn div_assign(&mut self, rhs: Factor)

Performs the /= operation. Read more
Source§

impl From<FactorPercent> for Factor

Source§

fn from(value: FactorPercent) -> Factor

Converts to this type from the input type.
Source§

impl From<Progress> for Factor

Source§

fn from(status: Progress) -> Factor

Converts to this type from the input type.
Source§

impl From<bool> for Factor

Source§

fn from(value: bool) -> Factor

Converts to this type from the input type.
Source§

impl From<f32> for Factor

Source§

fn from(value: f32) -> Factor

Converts to this type from the input type.
Source§

impl Hash for Factor

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoVar<Align> for Factor

Source§

type Var = LocalVar<Align>

Variable type that will wrap the T value. Read more
Source§

fn into_var(self) -> <Factor as IntoVar<Align>>::Var

Converts the source value into a var.
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<CornerRadius> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<CornerRadius>>::Var

All corners same relative length.

Source§

type Var = LocalVar<CornerRadius>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<EasingTime> for Factor

Source§

type Var = LocalVar<EasingTime>

Variable type that will wrap the T value. Read more
Source§

fn into_var(self) -> <Factor as IntoVar<EasingTime>>::Var

Converts the source value into a var.
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<Factor2d> for Factor

Source§

type Var = LocalVar<Factor2d>

Variable type that will wrap the T value. Read more
Source§

fn into_var(self) -> <Factor as IntoVar<Factor2d>>::Var

Converts the source value into a var.
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<FactorPercent> for Factor

Source§

type Var = LocalVar<FactorPercent>

Variable type that will wrap the T value. Read more
Source§

fn into_var(self) -> <Factor as IntoVar<FactorPercent>>::Var

Converts the source value into a var.
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<FactorSideOffsets> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<FactorSideOffsets>>::Var

All sides equal.

Source§

type Var = LocalVar<FactorSideOffsets>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<FontStretch> for Factor

Source§

type Var = LocalVar<FontStretch>

Variable type that will wrap the T value. Read more
Source§

fn into_var(self) -> <Factor as IntoVar<FontStretch>>::Var

Converts the source value into a var.
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<GradientRadius> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<GradientRadius>>::Var

Conversion to Length::Factor and to radius.

Source§

type Var = LocalVar<GradientRadius>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<GradientStop> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<GradientStop>>::Var

Conversion to Length::Factor color hint.

Source§

type Var = LocalVar<GradientStop>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<GridSpacing> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<GridSpacing>>::Var

Column and row equal relative length.

Source§

type Var = LocalVar<GridSpacing>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<Length> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<Length>>::Var

Conversion to Length::Factor

Source§

type Var = LocalVar<Length>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<Point> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<Point>>::Var

Splat relative length.

Source§

type Var = LocalVar<Point>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<Progress> for Factor

Source§

type Var = LocalVar<Progress>

Variable type that will wrap the T value. Read more
Source§

fn into_var(self) -> <Factor as IntoVar<Progress>>::Var

Converts the source value into a var.
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<SideOffsets> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<SideOffsets>>::Var

All sides equal relative length.

Source§

type Var = LocalVar<SideOffsets>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<Size> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<Size>>::Var

Splat relative length.

Source§

type Var = LocalVar<Size>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl IntoVar<Vector> for Factor

Source§

fn into_var(self) -> <Factor as IntoVar<Vector>>::Var

Conversion to Length::Factor then to vector.

Source§

type Var = LocalVar<Vector>

Variable type that will wrap the T value. Read more
Source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
Source§

impl Mul for Factor

Source§

type Output = Factor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Factor) -> <Factor as Mul>::Output

Performs the * operation. Read more
Source§

impl MulAssign for Factor

Source§

fn mul_assign(&mut self, rhs: Factor)

Performs the *= operation. Read more
Source§

impl Neg for Factor

Source§

type Output = Factor

The resulting type after applying the - operator.
Source§

fn neg(self) -> <Factor as Neg>::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for Factor

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Factor

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 SelectorValue for Factor

Source§

fn to_selector( value: Box<dyn VarBoxed<Factor>>, min: Factor, max: Factor, ) -> Selector

Make the selector.
Source§

impl Serialize for Factor

Source§

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 Sub for Factor

Source§

type Output = Factor

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Factor) -> <Factor as Sub>::Output

Performs the - operation. Read more
Source§

impl SubAssign for Factor

Source§

fn sub_assign(&mut self, rhs: Factor)

Performs the -= operation. Read more
Source§

impl Transitionable for Factor

Source§

fn lerp(self, to: &Factor, step: Factor) -> Factor

Sample the linear interpolation from self -> to by step.
Source§

impl Zeroable for Factor

§

fn zeroed() -> Self

Source§

impl Copy for Factor

Source§

impl IntoValue<Align> for Factor

Source§

impl IntoValue<CornerRadius> for Factor

Source§

impl IntoValue<EasingTime> for Factor

Source§

impl IntoValue<Factor2d> for Factor

Source§

impl IntoValue<FactorPercent> for Factor

Source§

impl IntoValue<FactorSideOffsets> for Factor

Source§

impl IntoValue<FontStretch> for Factor

Source§

impl IntoValue<GradientRadius> for Factor

Source§

impl IntoValue<GradientStop> for Factor

Source§

impl IntoValue<GridSpacing> for Factor

Source§

impl IntoValue<Length> for Factor

Source§

impl IntoValue<Point> for Factor

Source§

impl IntoValue<Progress> for Factor

Source§

impl IntoValue<SideOffsets> for Factor

Source§

impl IntoValue<Size> for Factor

Source§

impl IntoValue<Vector> for Factor

Source§

impl Pod for Factor