pub struct Timeline { /* private fields */ }Expand description
A timeline that schedules multiple animations at specific offsets.
Implements Animation where value() returns overall progress (0.0–1.0).
Implementations§
Source§impl Timeline
impl Timeline
Sourcepub fn add(self, offset: Duration, animation: impl Animation + 'static) -> Self
pub fn add(self, offset: Duration, animation: impl Animation + 'static) -> Self
Add an animation event at an absolute offset (builder pattern).
Sourcepub fn add_labeled(
self,
label: &str,
offset: Duration,
animation: impl Animation + 'static,
) -> Self
pub fn add_labeled( self, label: &str, offset: Duration, animation: impl Animation + 'static, ) -> Self
Add a labeled animation event at an absolute offset (builder pattern).
Sourcepub fn then(self, animation: impl Animation + 'static) -> Self
pub fn then(self, animation: impl Animation + 'static) -> Self
Add an event relative to the last event’s offset (builder pattern).
If no events exist, the offset is 0.
Sourcepub fn set_duration(self, d: Duration) -> Self
pub fn set_duration(self, d: Duration) -> Self
Set the total duration explicitly (builder pattern).
If not called, duration is inferred as max(event.offset).
A zero duration is clamped to 1ns.
Sourcepub fn set_loop_count(self, count: LoopCount) -> Self
pub fn set_loop_count(self, count: LoopCount) -> Self
Set the loop count (builder pattern).
Source§impl Timeline
impl Timeline
Sourcepub fn seek(&mut self, time: Duration)
pub fn seek(&mut self, time: Duration)
Seek to an absolute time position.
Clamps to [0, total_duration]. Resets all animations and re-ticks them up to the seek point so their state is consistent.
Sourcepub fn seek_label(&mut self, label: &str) -> bool
pub fn seek_label(&mut self, label: &str) -> bool
Seek to a labeled event’s offset.
Returns true if the label was found, false otherwise (no-op).
Sourcepub fn state(&self) -> PlaybackState
pub fn state(&self) -> PlaybackState
Current playback state.
Sourcepub fn current_time(&self) -> Duration
pub fn current_time(&self) -> Duration
Current time position.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Number of events in the timeline.
Sourcepub fn event_value(&self, label: &str) -> Option<f32>
pub fn event_value(&self, label: &str) -> Option<f32>
Get the animation value for a specific labeled event.
Returns None if the label doesn’t exist.
Sourcepub fn event_value_at(&self, index: usize) -> Option<f32>
pub fn event_value_at(&self, index: usize) -> Option<f32>
Get the animation value for an event by index.
Returns None if index is out of bounds.