pub struct KeyframeTrack<T>where
T: Animatable,{
pub looping: Loop,
/* private fields */
}Expand description
A sorted collection of keyframes that evaluates a value over time.
Empty tracks are valid. They evaluate to None instead of requiring
T: Default or panicking.
§Example
use animato_core::{Easing, Update};
use animato_tween::KeyframeTrack;
let mut track = KeyframeTrack::new()
.push_eased(0.0, 0.0_f32, Easing::EaseOutCubic)
.push(1.0, 100.0);
track.update(0.5);
assert!(track.value().unwrap() > 50.0);Fields§
§looping: LoopLooping behavior for this track.
Implementations§
Source§impl<T> KeyframeTrack<T>where
T: Animatable,
impl<T> KeyframeTrack<T>where
T: Animatable,
Sourcepub fn new() -> KeyframeTrack<T>
pub fn new() -> KeyframeTrack<T>
Create an empty keyframe track.
Sourcepub fn push(self, time: f32, value: T) -> KeyframeTrack<T>
pub fn push(self, time: f32, value: T) -> KeyframeTrack<T>
Insert a linear keyframe and keep the track sorted by time.
If another frame already exists at the same time, it is replaced.
Sourcepub fn push_eased(self, time: f32, value: T, easing: Easing) -> KeyframeTrack<T>
pub fn push_eased(self, time: f32, value: T, easing: Easing) -> KeyframeTrack<T>
Insert a keyframe with an explicit segment easing.
If another frame already exists at the same time, it is replaced.
Sourcepub fn looping(self, mode: Loop) -> KeyframeTrack<T>
pub fn looping(self, mode: Loop) -> KeyframeTrack<T>
Set the looping behavior.
Sourcepub fn value_at(&self, secs: f32) -> Option<T>
pub fn value_at(&self, secs: f32) -> Option<T>
Evaluate the track at an absolute time in seconds.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
true when the track has finished all finite playback.
Trait Implementations§
Source§impl<T> Clone for KeyframeTrack<T>where
T: Clone + Animatable,
impl<T> Clone for KeyframeTrack<T>where
T: Clone + Animatable,
Source§fn clone(&self) -> KeyframeTrack<T>
fn clone(&self) -> KeyframeTrack<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for KeyframeTrack<T>where
T: Debug + Animatable,
impl<T> Debug for KeyframeTrack<T>where
T: Debug + Animatable,
Source§impl<T> Default for KeyframeTrack<T>where
T: Animatable,
impl<T> Default for KeyframeTrack<T>where
T: Animatable,
Source§fn default() -> KeyframeTrack<T>
fn default() -> KeyframeTrack<T>
Returns the “default value” for a type. Read more
Source§impl<T> Playable for KeyframeTrack<T>where
T: Animatable,
impl<T> Playable for KeyframeTrack<T>where
T: Animatable,
Source§fn is_complete(&self) -> bool
fn is_complete(&self) -> bool
true when the animation has reached its terminal state.Source§fn as_any(&self) -> &(dyn Any + 'static)
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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Return a type-erased mutable reference for downcasting.
Auto Trait Implementations§
impl<T> Freeze for KeyframeTrack<T>
impl<T> RefUnwindSafe for KeyframeTrack<T>where
T: RefUnwindSafe,
impl<T> Send for KeyframeTrack<T>where
T: Send,
impl<T> Sync for KeyframeTrack<T>where
T: Sync,
impl<T> Unpin for KeyframeTrack<T>where
T: Unpin,
impl<T> UnsafeUnpin for KeyframeTrack<T>
impl<T> UnwindSafe for KeyframeTrack<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more