AnimationInstance

Struct AnimationInstance 

Source
pub struct AnimationInstance {
    pub id: AnimationId,
    pub tween: Tween<f32>,
    pub state: AnimationState,
    pub loop_count: u32,
    pub current_loop: u32,
    pub alternate: bool,
    /* private fields */
}
Expand description

An animation instance that can be managed by an Animator.

Fields§

§id: AnimationId

Unique ID

§tween: Tween<f32>

Tween for the animation

§state: AnimationState

Current state

§loop_count: u32

Loop count (0 = infinite, 1 = once, N = N times)

§current_loop: u32

Current loop iteration

§alternate: bool

Whether to reverse on alternate loops (ping-pong)

Implementations§

Source§

impl AnimationInstance

Source

pub fn new(id: AnimationId, from: f32, to: f32, duration_ms: u32) -> Self

Create a new animation instance.

Source

pub const fn with_easing(self, easing: EasingFunction) -> Self

Set easing function.

Source

pub const fn with_loop_count(self, count: u32) -> Self

Set loop count (0 = infinite).

Source

pub const fn with_alternate(self, alternate: bool) -> Self

Enable ping-pong alternating.

Source

pub fn start(&mut self)

Start the animation.

Source

pub fn pause(&mut self)

Pause the animation.

Source

pub fn resume(&mut self)

Resume the animation.

Source

pub fn stop(&mut self)

Stop the animation.

Source

pub fn value(&self) -> f32

Get the current value.

Source

pub fn advance(&mut self, delta_ms: u32)

Advance the animation by delta milliseconds.

Trait Implementations§

Source§

impl Debug for AnimationInstance

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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