Skip to main content

Animatable

Trait Animatable 

Source
pub trait Animatable<T> {
    // Required method
    fn transform(&self, app: &App, t: f64) -> T;

    // Provided methods
    fn evaluate(&self, app: &App, animation: AnyAnimation<f64>) -> T
       where Self: Sized { ... }
    fn animate(
        self,
        app: &mut App,
        parent: Retained<AnyAnimation<f64>>,
    ) -> Retained<AnyAnimation<T>>
       where Self: Sized + Clone + 'static,
             T: 'static { ... }
    fn chain<P>(self, parent: P) -> ChainedEvaluation<P, Self>
       where Self: Sized + Clone,
             P: Animatable<f64> + Clone { ... }
}
Expand description

An object that can produce a value of type T given an Animation<double> as input.

Typically, the values of the input animation are nominally in the range 0.0 to 1.0. In principle, however, any value could be provided.

The main implementor of Animatable is Tween.

Required Methods§

Source

fn transform(&self, app: &App, t: f64) -> T

Returns the value of the object at point t.

The value of t is nominally a fraction in the range 0.0 to 1.0, though in practice it may extend outside this range.

Provided Methods§

Source

fn evaluate(&self, app: &App, animation: AnyAnimation<f64>) -> T
where Self: Sized,

The current value of this object for the given animation.

This function is implemented by deferring to transform. Implementors that want to provide custom behavior should override transform, not evaluate.

Source

fn animate( self, app: &mut App, parent: Retained<AnyAnimation<f64>>, ) -> Retained<AnyAnimation<T>>
where Self: Sized + Clone + 'static, T: 'static,

Returns a new animation that is driven by the given animation but that takes on values determined by this object. The new animation keeps parent; whoever keeps the result keeps both.

Source

fn chain<P>(self, parent: P) -> ChainedEvaluation<P, Self>
where Self: Sized + Clone, P: Animatable<f64> + Clone,

Returns a new Animatable whose value is determined by first evaluating the given parent and then evaluating this object at the result.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Animatable<Alignment> for AlignmentTween

Source§

fn transform(&self, _app: &App, t: f64) -> Alignment

Source§

impl Animatable<Option<AlignmentGeometry>> for AlignmentGeometryTween

Source§

impl Animatable<Option<Color>> for Retained<Handle<ColorTween>>

Source§

fn transform(&self, app: &App, t: f64) -> Option<Color>

Source§

impl Animatable<Option<FractionalOffset>> for FractionalOffsetTween

Source§

fn transform(&self, _app: &App, t: f64) -> Option<FractionalOffset>

Source§

impl Animatable<Option<Rect>> for Retained<Handle<RectTween>>

Source§

fn transform(&self, app: &App, t: f64) -> Option<Rect>

Source§

impl Animatable<Option<Size>> for Retained<Handle<SizeTween>>

Source§

fn transform(&self, app: &App, t: f64) -> Option<Size>

Source§

impl Animatable<f64> for Retained<Handle<CurveTween>>

Source§

fn transform(&self, app: &App, t: f64) -> f64

Source§

impl Animatable<i64> for Retained<Handle<IntTween>>

Source§

fn transform(&self, app: &App, t: f64) -> i64

Source§

impl Animatable<i64> for Retained<Handle<StepTween>>

Source§

fn transform(&self, app: &App, t: f64) -> i64

Source§

impl<T> Animatable<T> for Retained<Handle<ConstantTween<T>>>
where T: Clone + 'static,

Source§

fn transform(&self, app: &App, _t: f64) -> T

Source§

impl<T> Animatable<T> for Retained<Handle<ReverseTween<T>>>
where T: TweenLerp + 'static,

Source§

fn transform(&self, app: &App, t: f64) -> T

Source§

impl<T> Animatable<T> for Retained<Handle<Tween<T>>>
where T: TweenLerp + 'static,

Source§

fn transform(&self, app: &App, t: f64) -> T

Implementors§