Skip to main content

Timeline

Struct Timeline 

Source
pub struct Timeline {
    pub looping: Loop,
    pub time_scale: f32,
    /* private fields */
}
Expand description

Composes multiple animations on one shared clock.

Entries are stored by label, absolute start time, and cached duration. Normal one-shot playback advances children incrementally. Seeking and timeline-level loops resynchronize children through Playable::seek_to.

Fields§

§looping: Loop

Timeline-level looping behavior.

§time_scale: f32

Timeline time scale. 1.0 = normal speed, 2.0 = double speed.

Implementations§

Source§

impl Timeline

Source

pub fn new() -> Timeline

Create an empty timeline.

Source

pub fn add<A>( self, label: impl Into<String>, animation: A, at: At<'_>, ) -> Timeline
where A: Playable + Send + 'static,

Add an animation at the requested position.

Missing At::Label references fall back to At::End behavior.

Source

pub fn looping(self, mode: Loop) -> Timeline

Set timeline-level looping behavior.

Source

pub fn time_scale(self, scale: f32) -> Timeline

Set the timeline time scale.

Negative values are clamped to 0.0.

Source

pub fn set_time_scale(&mut self, scale: f32)

Change the timeline time scale at runtime.

1.0 is normal speed, 2.0 is double speed, and 0.0 freezes time.

Source

pub fn on_entry_complete( self, label: impl Into<String>, f: impl FnMut() + Send + 'static, ) -> Timeline

Register a callback fired when the labeled entry completes during update.

This is available with the std feature. Seeking and resetting do not fire callbacks.

Source

pub fn on_complete(self, f: impl FnMut() + Send + 'static) -> Timeline

Register a callback fired once when finite timeline playback completes during update.

This is available with the std feature. Seeking to the end does not fire this callback.

Source

pub fn play(&mut self)

Begin playback.

Source

pub fn pause(&mut self)

Pause playback.

Source

pub fn resume(&mut self)

Resume playback after a pause.

Source

pub fn reset(&mut self)

Reset the timeline and all children to the beginning.

Source

pub fn seek(&mut self, progress: f32)

Seek by normalized progress through the timeline.

Source

pub fn seek_abs(&mut self, secs: f32)

Seek to an absolute time in seconds.

Source

pub fn duration(&self) -> f32

Base duration in seconds, equal to the last finishing entry.

Source

pub fn progress(&self) -> f32

Current normalized progress through finite playback.

Source

pub fn is_complete(&self) -> bool

true when the timeline has finished all finite playback.

Source

pub fn state(&self) -> TimelineState

Current timeline state.

Source

pub fn elapsed(&self) -> f32

Current total elapsed timeline time in seconds.

Source

pub fn entry_count(&self) -> usize

Number of entries in the timeline.

Source

pub fn get<T>(&self, label: &str) -> Option<&T>
where T: Playable + 'static,

Find a child animation by label and concrete type.

Source

pub fn get_mut<T>(&mut self, label: &str) -> Option<&mut T>
where T: Playable + 'static,

Find a mutable child animation by label and concrete type.

Trait Implementations§

Source§

impl Debug for Timeline

Source§

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

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

impl Default for Timeline

Source§

fn default() -> Timeline

Returns the “default value” for a type. Read more
Source§

impl Playable for Timeline

Source§

fn duration(&self) -> f32

Total finite duration in seconds.
Source§

fn reset(&mut self)

Reset the animation to its initial state.
Source§

fn seek_to(&mut self, progress: f32)

Seek to normalized progress through the animation.
Source§

fn is_complete(&self) -> bool

true when the animation has reached its terminal state.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Return a type-erased shared reference for downcasting.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Return a type-erased mutable reference for downcasting.
Source§

impl Update for Timeline

Source§

fn update(&mut self, dt: f32) -> bool

Advance the animation by dt seconds. 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.