pub struct Keyframe<T: Tweenable> { /* private fields */ }Expand description
Implementations§
Source§impl<T: Tweenable> Keyframe<T>
impl<T: Tweenable> Keyframe<T>
Sourcepub fn new(time: f32, value: T) -> Self
pub fn new(time: f32, value: T) -> Self
Create a new keyframe at the given time with the given value.
Sourcepub fn with_easing(self, easing: Easing) -> Self
pub fn with_easing(self, easing: Easing) -> Self
Create a keyframe with easing.
Sourcepub fn set_easing(&mut self, easing: Option<Easing>)
pub fn set_easing(&mut self, easing: Option<Easing>)
Set the easing function.
Sourcepub fn has_easing(&self) -> bool
pub fn has_easing(&self) -> bool
Check if this keyframe has custom easing.
Sourcepub fn tween_to(&self, next: &Keyframe<T>, time: f32) -> T
pub fn tween_to(&self, next: &Keyframe<T>, time: f32) -> T
Interpolate from this keyframe to the next at the given time.
Uses the easing function from next (since easing controls
interpolation TO a keyframe).
§Behavior
- If
time <= self.time: returnsself.value - If
time >= next.time: returnsnext.value - If
next.time <= self.time: returnsnext.value(invalid order) - Otherwise: interpolates using
next.easing(or linear if None)
§Examples
use eazy_keyframes::Keyframe;
use eazy_core::Easing;
let kf1 = Keyframe::new(0.0, 0.0_f32);
let kf2 = Keyframe::new(1.0, 100.0_f32).with_easing(Easing::OutBounce);
let value = kf1.tween_to(&kf2, 0.5);Trait Implementations§
Source§impl<T: Tweenable> From<(f32, T)> for Keyframe<T>
Create keyframe from (time, value) tuple with linear easing.
impl<T: Tweenable> From<(f32, T)> for Keyframe<T>
Create keyframe from (time, value) tuple with linear easing.
Source§impl<T: Tweenable> From<(f32, T, Easing)> for Keyframe<T>
Create keyframe from (time, value, easing) tuple.
impl<T: Tweenable> From<(f32, T, Easing)> for Keyframe<T>
Create keyframe from (time, value, easing) tuple.
Source§impl<T: Tweenable> FromIterator<Keyframe<T>> for KeyframeTrack<T>
impl<T: Tweenable> FromIterator<Keyframe<T>> for KeyframeTrack<T>
Auto Trait Implementations§
impl<T> Freeze for Keyframe<T>where
T: Freeze,
impl<T> RefUnwindSafe for Keyframe<T>where
T: RefUnwindSafe,
impl<T> Send for Keyframe<T>
impl<T> Sync for Keyframe<T>
impl<T> Unpin for Keyframe<T>where
T: Unpin,
impl<T> UnwindSafe for Keyframe<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