pub struct Timeline {
pub name: String,
pub fps: f32,
/* private fields */
}Expand description
Multi-track animation timeline.
Fields§
§name: StringHuman-readable name for this timeline.
fps: f32Frames per second (used by frame_count).
Implementations§
Source§impl Timeline
impl Timeline
Sourcepub fn with_fps(name: impl Into<String>, fps: f32) -> Self
pub fn with_fps(name: impl Into<String>, fps: f32) -> Self
Create a new timeline with an explicit fps value.
Sourcepub fn remove_track(&mut self, name: &str) -> bool
pub fn remove_track(&mut self, name: &str) -> bool
Remove the track named name. Returns true if a track was removed.
Sourcepub fn get_track(&self, name: &str) -> Option<&AnimTrack>
pub fn get_track(&self, name: &str) -> Option<&AnimTrack>
Get an immutable reference to the named track.
Sourcepub fn get_track_mut(&mut self, name: &str) -> Option<&mut AnimTrack>
pub fn get_track_mut(&mut self, name: &str) -> Option<&mut AnimTrack>
Get a mutable reference to the named track.
Sourcepub fn track_names(&self) -> Vec<&str>
pub fn track_names(&self) -> Vec<&str>
Sorted list of all track names.
Sourcepub fn track_count(&self) -> usize
pub fn track_count(&self) -> usize
Number of tracks in this timeline.
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Number of frames: ceil(duration * fps).
Sourcepub fn evaluate(&self, time: f32) -> HashMap<String, f32>
pub fn evaluate(&self, time: f32) -> HashMap<String, f32>
Evaluate all tracks at time, returning a map of track name to value.
Sourcepub fn bake(&self, sample_fps: f32) -> Vec<HashMap<String, f32>>
pub fn bake(&self, sample_fps: f32) -> Vec<HashMap<String, f32>>
Sample the timeline at uniform intervals of 1.0 / sample_fps from t = 0
to the timeline duration, returning a Vec of name→value snapshots.
Sourcepub fn set_key(&mut self, track_name: &str, time: f32, value: f32)
pub fn set_key(&mut self, track_name: &str, time: f32, value: f32)
Add a keyframe to the named track, creating it (with Linear interp) if absent.
Sourcepub fn time_offset(&mut self, dt: f32)
pub fn time_offset(&mut self, dt: f32)
Shift all keyframes in every track by dt seconds.
Sourcepub fn time_scale(&mut self, factor: f32)
pub fn time_scale(&mut self, factor: f32)
Scale all keyframe times by factor (speed up or slow down the timeline).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Timeline
impl RefUnwindSafe for Timeline
impl Send for Timeline
impl Sync for Timeline
impl Unpin for Timeline
impl UnsafeUnpin for Timeline
impl UnwindSafe for Timeline
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more