Skip to main content

Ease

Struct Ease 

Source
pub struct Ease {
    pub x1: f32,
    pub y1: f32,
    pub x2: f32,
    pub y2: f32,
}
Expand description

The one easing curve every surface moves on, as CSS’s cubic-bezier(x1, y1, x2, y2) with the endpoints pinned at (0, 0) and (1, 1).

Both y control points must stay inside 0.0..=1.0. That is what keeps the curve monotone — an envelope that overshoots and comes back would make a panel’s alpha rise past its target and fall again. Both x control points must stay inside 0.0..=1.0 too, which is what makes x(t) invertible.

Fields§

§x1: f32

First control point, time axis.

§y1: f32

First control point, progress axis.

§x2: f32

Second control point, time axis.

§y2: f32

Second control point, progress axis.

Implementations§

Source§

impl Ease

Source

pub fn at(self, t: f32) -> f32

Progress at normalised time t: 0.0 at t <= 0, 1.0 at t >= 1, and the curve’s height in between.

Solves x(s) = t by bisection on the curve parameter s — a fixed 40 halvings in f64, which puts s well inside an f32 step of the root and allocates nothing.

Monotone in t to the last bit, by construction. The height is read at the bisection’s lower bound, which never decreases as t grows (every comparison t passes, a larger t passes too), and it is computed in f64 and rounded once — an f32 evaluation of the height wobbles by an ulp near the top of a flat ease-out, which is a panel’s alpha stepping back down on its last frames.

Source

pub fn css(self) -> String

The CSS spelling, cubic-bezier(x1, y1, x2, y2).

Trait Implementations§

Source§

impl Clone for Ease

Source§

fn clone(&self) -> Ease

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 Debug for Ease

Source§

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

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

impl PartialEq for Ease

Source§

fn eq(&self, other: &Ease) -> 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 Copy for Ease

Source§

impl StructuralPartialEq for Ease

Auto Trait Implementations§

§

impl Freeze for Ease

§

impl RefUnwindSafe for Ease

§

impl Send for Ease

§

impl Sync for Ease

§

impl Unpin for Ease

§

impl UnsafeUnpin for Ease

§

impl UnwindSafe for Ease

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<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> 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, 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.
§

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

§

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

§

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

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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