Skip to main content

Easing

Enum Easing 

Source
pub enum Easing {
Show 27 variants Linear, InQuad, OutQuad, InOutQuad, InCubic, OutCubic, InOutCubic, InSine, OutSine, InOutSine, InQuart, OutQuart, InOutQuart, InQuint, OutQuint, InOutQuint, InExpo, OutExpo, InOutExpo, InCirc, OutCirc, InOutCirc, InBack, OutBack, InOutBack, Bezier(f32, f32, f32, f32), Spline(&'static [[f32; 6]]),
}
Expand description

How an animation moves from its start to its end: what fraction of the way it has gone at each fraction of its time.

Variants§

§

Linear

The same speed all the way.

§

InQuad

Starts slow.

§

OutQuad

Ends slow.

§

InOutQuad

Starts and ends slow.

§

InCubic

Starts slower.

§

OutCubic

Ends slower. The default: it settles gently, as most interface motion should.

§

InOutCubic

Starts and ends slower.

§

InSine

Starts slow, along a quarter sine wave.

§

OutSine

Ends slow, along a quarter sine wave.

§

InOutSine

Starts and ends slow, along half a sine wave.

§

InQuart

Starts slower than a cubic.

§

OutQuart

Ends slower than a cubic.

§

InOutQuart

Starts and ends slower than a cubic.

§

InQuint

Starts slower still.

§

OutQuint

Ends slower still.

§

InOutQuint

Starts and ends slower still.

§

InExpo

Barely moves, then rushes in: each tenth of the time doubles it.

§

OutExpo

Rushes out, then barely moves.

§

InOutExpo

Barely moves at both ends.

§

InCirc

Starts slow along a quarter circle.

§

OutCirc

Ends slow along a quarter circle.

§

InOutCirc

Starts and ends slow along quarter circles.

§

InBack

Pulls back about 10% behind the start, then goes.

§

OutBack

Runs about 10% past the end, then settles back.

§

InOutBack

Pulls back at the start and runs past the end.

§

Bezier(f32, f32, f32, f32)

A cubic Bézier from (0, 0) to (1, 1) through the control points (x1, y1) and (x2, y2), as CSS’s cubic-bezier. The x values are kept within 0 to 1.

§

Spline(&'static [[f32; 6]])

Cubic Bézier segments joined end to end, as Qt’s Easing.BezierSpline. Each is [c1x, c1y, c2x, c2y, end_x, end_y]: two control points and an end, starting from the previous end, the first from (0, 0). The last must end at (1, 1), and the ends’ x values must never go back. A spline that breaks either rule, is empty, or holds a number that isn’t finite moves linearly instead. A control point’s x is kept within its segment.

Material 3’s emphasized curve:

use crabshell_ui::{Easing, Transition};

const EMPHASIZED: Easing = Easing::Spline(&[
    [0.05, 0.0, 0.133333, 0.06, 0.166666, 0.4],
    [0.208333, 0.82, 0.25, 1.0, 1.0, 1.0],
]);
const ENTER: Transition = Transition::new(500).easing(EMPHASIZED);

Implementations§

Source§

impl Easing

Source

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

How far along the animation is, from 0 to 1 (Back, a Bézier or a spline may overshoot either end), when t of its time has passed. t is kept within 0 to 1.

Trait Implementations§

Source§

impl Clone for Easing

Source§

fn clone(&self) -> Self

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 Easing

Source§

impl Debug for Easing

Source§

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

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

impl Default for Easing

Source§

fn default() -> Self

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

impl PartialEq for Easing

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Easing

Auto Trait Implementations§

§

impl Forget for Easing

§

impl Freeze for Easing

§

impl Move for Easing

§

impl RefUnwindSafe for Easing

§

impl Send for Easing

§

impl Sync for Easing

§

impl Unpin for Easing

§

impl UnsafeUnpin for Easing

§

impl UnwindSafe for Easing

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more