pub struct Keyframes<T: Animatable> { /* private fields */ }Expand description
An animation composed of time-positioned Keyframe values.
§Examples
use aura_anim_core::{Animation, keyframes::Keyframes, timing::Duration};
let mut animation = Keyframes::new(0.0_f32)
.push(100.0, 1.0)
.push(200.0, 0.0);
animation.tick(Duration::from_millis(100.0));
assert_eq!(*animation.value(), 1.0);
animation.tick(Duration::from_millis(100.0));
assert_eq!(*animation.value(), 0.0);Implementations§
Source§impl<T: Animatable> Keyframes<T>
impl<T: Animatable> Keyframes<T>
Sourcepub fn new(initial: T) -> Self
pub fn new(initial: T) -> Self
Creates a running keyframe animation with an initial frame at zero.
Sourcepub fn push(self, time_ms: f64, value: T) -> Self
pub fn push(self, time_ms: f64, value: T) -> Self
Adds a keyframe with linear easing after the preceding frame.
Sourcepub fn push_eased(self, time_ms: f64, value: T, easing: Easing) -> Self
pub fn push_eased(self, time_ms: f64, value: T, easing: Easing) -> Self
Adds a keyframe with the provided easing.
Sourcepub fn push_frame(self, frame: Keyframe<T>) -> Self
pub fn push_frame(self, frame: Keyframe<T>) -> Self
Adds or replaces a keyframe at the frame’s time.
Sourcepub fn with_delay(self, delay: Delay) -> Self
pub fn with_delay(self, delay: Delay) -> Self
Sets the delay before playback begins.
Sourcepub fn with_iterations(self, iterations: impl Into<IterationCount>) -> Self
pub fn with_iterations(self, iterations: impl Into<IterationCount>) -> Self
Sets the number of playback iterations.
Sourcepub fn with_direction(self, direction: Direction) -> Self
pub fn with_direction(self, direction: Direction) -> Self
Sets the playback direction.
Trait Implementations§
Source§impl<T: Animatable> Animation<T> for Keyframes<T>
impl<T: Animatable> Animation<T> for Keyframes<T>
Source§fn state(&self) -> AnimationState
fn state(&self) -> AnimationState
Returns the animation’s lifecycle state.
Source§fn duration(&self) -> Option<Duration>
fn duration(&self) -> Option<Duration>
Returns the total duration when it is finite and known.
Source§fn advance(&mut self, delta: Duration) -> Duration
fn advance(&mut self, delta: Duration) -> Duration
Advances the animation and returns any unconsumed duration.
Auto Trait Implementations§
impl<T> Freeze for Keyframes<T>where
T: Freeze,
impl<T> RefUnwindSafe for Keyframes<T>where
T: RefUnwindSafe,
impl<T> Send for Keyframes<T>where
T: Send,
impl<T> Sync for Keyframes<T>where
T: Sync,
impl<T> Unpin for Keyframes<T>where
T: Unpin,
impl<T> UnsafeUnpin for Keyframes<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Keyframes<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