Struct keyframe::AnimationSequence
source · [−]pub struct AnimationSequence<T> { /* private fields */ }
Expand description
A collection of keyframes that can be played back in sequence
Implementations
sourceimpl<T> AnimationSequence<T>
impl<T> AnimationSequence<T>
sourcepub fn insert(
&mut self,
keyframe: Keyframe<T>
) -> Result<(), AnimationSequenceError>
pub fn insert(
&mut self,
keyframe: Keyframe<T>
) -> Result<(), AnimationSequenceError>
Inserts a new keyframe into the animation sequence
sourcepub fn insert_many(
&mut self,
keyframes: impl IntoIterator<Item = impl Into<Keyframe<T>>>
) -> Result<(), AnimationSequenceError>
pub fn insert_many(
&mut self,
keyframes: impl IntoIterator<Item = impl Into<Keyframe<T>>>
) -> Result<(), AnimationSequenceError>
Inserts several keyframes from an iterator all at once. This is faster because sorting only needs to be done after all the keyframes have been inserted.
sourcepub fn remove(&mut self, timestamp: f64) -> bool
pub fn remove(&mut self, timestamp: f64) -> bool
Removes the keyframe from the sequence at the specified time. Returns true if a keyframe was actually removed
sourcepub fn retain<F: FnMut(f64) -> bool>(&mut self, f: F) -> bool
pub fn retain<F: FnMut(f64) -> bool>(&mut self, f: F) -> bool
Retains only the keyframes specified by the predicate. Works the same as Vec::retain
.
Returns true only if a keyframe was actually removed.
sourcepub fn has_keyframe_at(&self, timestamp: f64) -> bool
pub fn has_keyframe_at(&self, timestamp: f64) -> bool
If this sequence has a keyframe at the exact timestamp
sourcepub fn pair(&self) -> (Option<&Keyframe<T>>, Option<&Keyframe<T>>)
pub fn pair(&self) -> (Option<&Keyframe<T>>, Option<&Keyframe<T>>)
The current pair of keyframes that are being animated (current, next)
Note
The following applies if:
- There are no keyframes in this sequence: (
None
,None
) is returned - The sequence has not reached the first keyframe: (
None
, current) is returned - There is only one keyframe in this sequence and the sequence has reached it: (current,
None
) is returned - The sequence has finished: (current,
None
) is returned
sourcepub fn now_strict(&self) -> Option<T> where
T: CanTween + Clone,
pub fn now_strict(&self) -> Option<T> where
T: CanTween + Clone,
The current value of this sequence, only based on the existing sequence entries.
sourcepub fn now(&self) -> T where
T: CanTween + Clone + Default,
pub fn now(&self) -> T where
T: CanTween + Clone + Default,
The current value of this sequence, use the default if necessary.
sourcepub fn advance_by(&mut self, duration: f64) -> f64
pub fn advance_by(&mut self, duration: f64) -> f64
Advances this sequence by the duration specified.
Returns the remaining time (i.e. the amount that the specified duration went outside the bounds of the total duration of this sequence) after the operation has completed.
A value over 0 indicates the sequence is at the finish point. A value under 0 indicates this sequence is at the start point.
sourcepub fn advance_and_maybe_reverse(&mut self, duration: f64) -> bool
pub fn advance_and_maybe_reverse(&mut self, duration: f64) -> bool
Advances this sequence by the duration specified.
If the duration causes the sequence to go out of bounds it will reverse and return true
.
sourcepub fn advance_and_maybe_wrap(&mut self, duration: f64) -> bool
pub fn advance_and_maybe_wrap(&mut self, duration: f64) -> bool
Advances this sequence by the duration specified.
If the duration causes the sequence to go out of bounds it will wrap around and return true
.
sourcepub fn advance_to(&mut self, timestamp: f64) -> f64
pub fn advance_to(&mut self, timestamp: f64) -> f64
Advances this sequence to the exact timestamp.
Returns the remaining time (i.e. the amount that the specified timestamp went outside the bounds of the total duration of this sequence) after the operation has completed.
A value over 0 indicates the sequence is at the finish point. A value under 0 indicates this sequence is at the start point.
Note
The following applies if:
- The timestamp is negative: the sequence is set to
0.0
- The timestamp is after the duration of the sequence: the sequence is set to
duration()
sourceimpl<T: Float + CanTween + Clone> AnimationSequence<T>
impl<T: Float + CanTween + Clone> AnimationSequence<T>
sourcepub fn to_easing_function(self) -> Keyframes
pub fn to_easing_function(self) -> Keyframes
Consumes this sequence and creates a normalized easing function which controls the 2D curve according to the keyframes in this sequence
Note
This function is only implemented for one-dimensional float types, since each value corresponds to a Y position
Trait Implementations
sourceimpl<T: Default> Default for AnimationSequence<T>
impl<T: Default> Default for AnimationSequence<T>
sourcefn default() -> AnimationSequence<T>
fn default() -> AnimationSequence<T>
Returns the “default value” for a type. Read more
sourceimpl<T, I: Into<Keyframe<T>>> FromIterator<I> for AnimationSequence<T>
impl<T, I: Into<Keyframe<T>>> FromIterator<I> for AnimationSequence<T>
sourcefn from_iter<I2: IntoIterator<Item = I>>(iter: I2) -> Self
fn from_iter<I2: IntoIterator<Item = I>>(iter: I2) -> Self
Creates a new animation sequence from an iterator
sourceimpl<'a, T> IntoIterator for &'a AnimationSequence<T>
impl<'a, T> IntoIterator for &'a AnimationSequence<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for AnimationSequence<T>
impl<T> Send for AnimationSequence<T> where
T: Send,
impl<T> Sync for AnimationSequence<T> where
T: Sync,
impl<T> Unpin for AnimationSequence<T> where
T: Unpin,
impl<T> !UnwindSafe for AnimationSequence<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more