Skip to main content

Animatable

Trait Animatable 

Source
pub trait Animatable {
    type Output;

    // Required method
    fn evaluate(&self, t: f32) -> Self::Output;

    // Provided methods
    fn curved(self, curve: Curve) -> Curved<Self>
       where Self: Sized { ... }
    fn animate<'a>(
        &'a self,
        controller: &'a AnimationController,
    ) -> Animation<'a, Self>
       where Self: Sized { ... }
}
Expand description

The rest of the animation layer: tweens chained and curved, the scroll simulations and their constants. A value that can be shaped by a [0,1] progress value — the abstraction tweens and curves share. It is the bridge between the explicit side (an AnimationController producing a [0,1] frame by frame) and a typed value: tween.animate(&controller).value() reads the current colour, size or point at any instant, without the view knowing the controller as anything other than that value.

Required Associated Types§

Source

type Output

The type of value produced (colour, size, number).

Required Methods§

Source

fn evaluate(&self, t: f32) -> Self::Output

The value at progress t ∈ [0,1].

Provided Methods§

Source

fn curved(self, curve: Curve) -> Curved<Self>
where Self: Sized,

Chains a Curve before evaluation: t is shaped by the curve first, so a single linear progress value can drive a value with non-linear timing.

Source

fn animate<'a>( &'a self, controller: &'a AnimationController, ) -> Animation<'a, Self>
where Self: Sized,

Binds this animation to an AnimationController’s progress, producing an Animation whose value() follows the controller’s current value. The controller’s value is normalised by its own bounds, so a non-unit controller still drives a full [0,1].

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<A> Animatable for Curved<A>
where A: Animatable,

Source§

impl<T> Animatable for Tween<T>
where T: Lerp,

Source§

impl<T> Animatable for TweenSequence<T>