Skip to main content

Curves

Enum Curves 

Source
pub enum Curves {}
Expand description

A collection of common animation curves.

See also:

  • Curve, the interface implemented by the curves available from the Curves class.

§Why these are functions

Dart’s are static const fields, which the language canonicalizes: every mention of Curves.easeIn is the same object, which is what makes Flutter’s widget.curve != oldWidget.curve checks answer “unchanged”. Rust has no const canonicalization, so each accessor hands out a clone of one process-local Rc and Rc::ptr_eq reproduces that comparison.

Implementations§

Source§

impl Curves

Source

pub fn linear() -> Rc<dyn Curve>

A linear animation curve.

This is the identity map over the unit interval: its Curve::transform method returns its input unmodified. This is useful as a default curve for cases where a Curve is required but no actual curve is desired.

Source

pub fn decelerate() -> Rc<dyn Curve>

A curve where the rate of change starts out quickly and then decelerates; an upside-down f(t) = t² parabola.

This is equivalent to the Android DecelerateInterpolator class with a unit factor (the default factor).

Source

pub fn fast_linear_to_slow_ease_in() -> Rc<dyn Curve>

A curve that is very steep and linear at the beginning, but quickly flattens out and very slowly eases in.

By default is the curve used to animate pages on iOS back to their original position if a swipe gesture is ended midway through a swipe.

Source

pub fn fast_ease_in_to_slow_ease_out() -> Rc<dyn Curve>

A curve that starts slowly, speeds up very quickly, and then ends slowly.

This curve is used by default to animate page transitions used by CupertinoPageRoute.

It has been derived from plots of native iOS 16.3 animation frames on iPhone 14 Pro Max. Specifically, transition animation positions were measured every frame and plotted against time. Then, a cubic curve was strictly fit to the measured data points.

Source

pub fn ease() -> Rc<dyn Curve>

A cubic animation curve that speeds up quickly and ends slowly.

This is the same as the CSS easing function ease.

Source

pub fn ease_in() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly.

This is the same as the CSS easing function ease-in.

Source

pub fn ease_in_to_linear() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends linearly.

The symmetric animation to Curves::linear_to_ease_out.

Source

pub fn ease_in_sine() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly. This is similar to Curves::ease_in, but with sinusoidal easing for a slightly less abrupt beginning and end. Nonetheless, the result is quite gentle and is hard to distinguish from Curves::linear at a glance.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_quad() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly. Based on a quadratic equation where f(t) = t², this is effectively the inverse of Curves::decelerate.

Compared to Curves::ease_in_sine, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_cubic() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly. This curve is based on a cubic equation where f(t) = t³. The result is a safe sweet spot when choosing a curve for widgets animating off the viewport.

Compared to Curves::ease_in_quad, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_quart() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly. This curve is based on a quartic equation where f(t) = t⁴.

Animations using this curve or steeper curves will benefit from a longer duration to avoid motion feeling unnatural.

Compared to Curves::ease_in_cubic, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_quint() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly. This curve is based on a quintic equation where f(t) = t⁵.

Compared to Curves::ease_in_quart, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_expo() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly. This curve is based on an exponential equation where f(t) = 2¹⁰⁽ᵗ⁻¹⁾.

Using this curve can give your animations extra flare, but a longer duration may need to be used to compensate for the steepness of the curve.

Compared to Curves::ease_in_quint, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_circ() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly. This curve is effectively the bottom-right quarter of a circle.

Like Curves::ease_in_expo, this curve is fairly dramatic and will reduce the clarity of an animation if not given a longer duration.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_back() -> Rc<dyn Curve>

A cubic animation curve that starts slowly and ends quickly. This curve is similar to Curves.elasticIn in that it overshoots its bounds before reaching its end. Instead of repeated swinging motions before ascending, though, this curve overshoots once, then continues to ascend.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_out() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly.

This is the same as the CSS easing function ease-out.

Source

pub fn linear_to_ease_out() -> Rc<dyn Curve>

A cubic animation curve that starts linearly and ends slowly.

A symmetric animation to Curves::ease_in_to_linear.

Source

pub fn ease_out_sine() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly. This is similar to Curves::ease_out, but with sinusoidal easing for a slightly less abrupt beginning and end. Nonetheless, the result is quite gentle and is hard to distinguish from Curves::linear at a glance.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_out_quad() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly. This is effectively the same as Curves::decelerate, only simulated using a cubic bezier function.

Compared to Curves::ease_out_sine, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_out_cubic() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly. This curve is a flipped version of Curves::ease_in_cubic.

The result is a safe sweet spot when choosing a curve for animating a widget’s position entering or already inside the viewport.

Compared to Curves::ease_out_quad, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_out_quart() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly. This curve is a flipped version of Curves::ease_in_quart.

Animations using this curve or steeper curves will benefit from a longer duration to avoid motion feeling unnatural.

Compared to Curves::ease_out_cubic, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_out_quint() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly. This curve is a flipped version of Curves::ease_in_quint.

Compared to Curves::ease_out_quart, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_out_expo() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly. This curve is a flipped version of Curves::ease_in_expo. Using this curve can give your animations extra flare, but a longer duration may need to be used to compensate for the steepness of the curve.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_out_circ() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly. This curve is effectively the top-left quarter of a circle.

Like Curves::ease_out_expo, this curve is fairly dramatic and will reduce the clarity of an animation if not given a longer duration.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_out_back() -> Rc<dyn Curve>

A cubic animation curve that starts quickly and ends slowly. This curve is similar to Curves.elasticOut in that it overshoots its bounds before reaching its end. Instead of repeated swinging motions after ascending, though, this curve only overshoots once.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_out() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly.

This is the same as the CSS easing function ease-in-out.

Source

pub fn ease_in_out_sine() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly. This is similar to Curves::ease_in_out, but with sinusoidal easing for a slightly less abrupt beginning and end.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_out_quad() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly. This curve can be imagined as Curves::ease_in_quad as the first half, and Curves::ease_out_quad as the second.

Compared to Curves::ease_in_out_sine, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_out_cubic() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly. This curve can be imagined as Curves::ease_in_cubic as the first half, and Curves::ease_out_cubic as the second.

The result is a safe sweet spot when choosing a curve for a widget whose initial and final positions are both within the viewport.

Compared to Curves::ease_in_out_quad, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_out_cubic_emphasized() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up shortly thereafter, and then ends slowly. This curve can be imagined as a steeper version of Curves::ease_in_out_cubic.

The result is a more emphasized eased curve when choosing a curve for a widget whose initial and final positions are both within the viewport.

Compared to Curves::ease_in_out_cubic, this curve is slightly steeper.

Source

pub fn ease_in_out_quart() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly. This curve can be imagined as Curves::ease_in_quart as the first half, and Curves::ease_out_quart as the second.

Animations using this curve or steeper curves will benefit from a longer duration to avoid motion feeling unnatural.

Compared to Curves::ease_in_out_cubic, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_out_quint() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly. This curve can be imagined as Curves::ease_in_quint as the first half, and Curves::ease_out_quint as the second.

Compared to Curves::ease_in_out_quart, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_out_expo() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly.

Since this curve is arrived at with an exponential function, the midpoint is exceptionally steep. Extra consideration should be taken when designing an animation using this.

Compared to Curves::ease_in_out_quint, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_out_circ() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly. This curve can be imagined as Curves::ease_in_circ as the first half, and Curves::ease_out_circ as the second.

Like Curves::ease_in_out_expo, this curve is fairly dramatic and will reduce the clarity of an animation if not given a longer duration.

Compared to Curves::ease_in_out_expo, this curve is slightly steeper.

Derived from Robert Penner’s easing functions.

Source

pub fn ease_in_out_back() -> Rc<dyn Curve>

A cubic animation curve that starts slowly, speeds up, and then ends slowly. This curve can be imagined as Curves::ease_in_back as the first half, and Curves::ease_out_back as the second.

Since two curves are used as a basis for this curve, the resulting animation will overshoot its bounds twice before reaching its end - first by exceeding its lower bound, then exceeding its upper bound and finally descending to its final position.

Derived from Robert Penner’s easing functions.

Source

pub fn fast_out_slow_in() -> Rc<dyn Curve>

A curve that starts quickly and eases into its final position.

Over the course of the animation, the object spends more time near its final destination. As a result, the user isn’t left waiting for the animation to finish, and the negative effects of motion are minimized.

See also:

  • Easing.legacy, the name for this curve in the Material specification.
Source

pub fn slow_middle() -> Rc<dyn Curve>

A cubic animation curve that starts quickly, slows down, and then ends quickly.

Source

pub fn bounce_in() -> Rc<dyn Curve>

An oscillating curve that grows in magnitude.

Source

pub fn bounce_out() -> Rc<dyn Curve>

An oscillating curve that first grows and then shrink in magnitude.

Source

pub fn bounce_in_out() -> Rc<dyn Curve>

An oscillating curve that first grows and then shrink in magnitude.

Source

pub fn elastic_in() -> Rc<dyn Curve>

An oscillating curve that grows in magnitude while overshooting its bounds.

Source

pub fn elastic_out() -> Rc<dyn Curve>

An oscillating curve that shrinks in magnitude while overshooting its bounds.

Source

pub fn elastic_in_out() -> Rc<dyn Curve>

An oscillating curve that grows and then shrinks in magnitude while overshooting its bounds.

Auto Trait Implementations§

§

impl Forget for Curves

§

impl Freeze for Curves

§

impl Move for Curves

§

impl RefUnwindSafe for Curves

§

impl Send for Curves

§

impl Sync for Curves

§

impl Unpin for Curves

§

impl UnsafeUnpin for Curves

§

impl UnwindSafe for Curves

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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