Skip to main content

Animator

Struct Animator 

Source
pub struct Animator { /* private fields */ }
Expand description

Tracks a set of keyed transitions and advances them frame by frame.

Each animation is identified by a caller-chosen u64 key; starting a new animation with an existing key replaces it (so a re-triggered hover doesn’t stack). Animator::advance adds dt seconds to every active animation and drops the finished ones.

Implementations§

Source§

impl Animator

Source

pub fn new() -> Self

Create an empty animator.

Source

pub fn active_count(&self) -> usize

Number of currently-active animations.

Source

pub fn is_animating(&self) -> bool

Returns true if any animation is in flight.

Source

pub fn start(&mut self, key: u64, start: f32, end: f32, transition: Transition)

Start (or restart) the animation under key, interpolating start → end over transition. Any existing animation with the same key is replaced and its elapsed time reset.

Source

pub fn value(&self, key: u64) -> Option<f32>

The current value of the animation under key, or None if no such animation is active.

Source

pub fn advance(&mut self, dt: f32) -> usize

Advance every active animation by dt seconds, removing any that have finished. Returns the number still active afterwards.

Source

pub fn cancel(&mut self, key: u64) -> bool

Cancel the animation under key. Returns true if one was removed.

Trait Implementations§

Source§

impl Debug for Animator

Source§

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

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

impl Default for Animator

Source§

fn default() -> Animator

Returns the “default value” for a type. 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.