[−][src]Struct keyframe::AnimationSequence
A collection of keyframes that can be played back in sequence
Methods
impl<T: CanTween + Copy> AnimationSequence<T> where
Keyframe<T>: Default,
[src]
Keyframe<T>: Default,
pub fn new() -> Self
[src]
Creates a new empty animation sequence
pub fn insert(
&mut self,
keyframe: Keyframe<T>
) -> Result<(), AnimationSequenceError>
[src]
&mut self,
keyframe: Keyframe<T>
) -> Result<(), AnimationSequenceError>
Inserts a new keyframe into the animation sequence
pub fn insert_many(
&mut self,
keyframes: impl IntoIterator<Item = impl Into<Keyframe<T>>>
) -> Result<(), AnimationSequenceError>
[src]
&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.
pub fn remove(&mut self, timestamp: f64) -> bool
[src]
Removes the keyframe from the sequence at the specified time. Returns true if a keyframe was actually removed
pub fn clear(&mut self)
[src]
Removes all keyframes from this sequence
pub fn retain<F: FnMut(f64) -> bool>(&mut self, f: F) -> bool
[src]
Retains only the keyframes specified by the predicate. Works the same as Vec::retain
.
Returns true only if a keyframe was actually removed.
pub fn has_keyframe_at(&self, timestamp: f64) -> bool
[src]
If this sequence has a keyframe at the exact timestamp
pub fn keyframes(&self) -> usize
[src]
The number of keyframes in this sequence
pub fn pair(&self) -> (Option<&Keyframe<T>>, Option<&Keyframe<T>>)
[src]
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
pub fn now(&self) -> T
[src]
The current value of this sequence
pub fn advance_by(&mut self, duration: f64) -> f64
[src]
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.
pub fn advance_and_maybe_reverse(&mut self, duration: f64) -> bool
[src]
Advances this sequence by the duration specified.
If the duration causes the sequence to go out of bounds it will reverse and return true
.
pub fn advance_and_maybe_wrap(&mut self, duration: f64) -> bool
[src]
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
.
pub fn advance_to(&mut self, timestamp: f64) -> f64
[src]
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()
pub fn duration(&self) -> f64
[src]
The length in seconds of this sequence
pub fn time(&self) -> f64
[src]
The current progression of this sequence in seconds
pub fn progress(&self) -> f64
[src]
The current progression of this sequence as a percentage
pub fn finished(&self) -> bool
[src]
If this sequence has finished and is at the end.
It can be reset with advance_to(0.0)
.
pub fn reverse(&mut self)
[src]
Reverses the order of all keyframes in this sequence
impl<T: Float + CanTween + Copy> AnimationSequence<T> where
Keyframe<T>: Default,
[src]
Keyframe<T>: Default,
pub fn to_easing_function(self) -> Keyframes
[src]
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
impl<T: CanTween + Copy> Default for AnimationSequence<T> where
Keyframe<T>: Default,
[src]
Keyframe<T>: Default,
impl<T: CanTween + Copy> From<Vec<Keyframe<T>>> for AnimationSequence<T> where
Keyframe<T>: Default,
[src]
Keyframe<T>: Default,
fn from(vec: Vec<Keyframe<T>>) -> Self
[src]
Creates a new animation sequence from a vector of keyframes
impl<T: CanTween + Copy, I: Into<Keyframe<T>>> FromIterator<I> for AnimationSequence<T> where
Keyframe<T>: Default,
[src]
Keyframe<T>: Default,
fn from_iter<I2: IntoIterator<Item = I>>(iter: I2) -> Self
[src]
Creates a new animation sequence from an iterator
impl<'a, T: CanTween + Copy> IntoIterator for &'a AnimationSequence<T> where
Keyframe<T>: Default,
[src]
Keyframe<T>: Default,
Auto Trait Implementations
impl<T> !RefUnwindSafe for AnimationSequence<T>
impl<T> Send for AnimationSequence<T> where
T: Send,
T: Send,
impl<T> Sync for AnimationSequence<T> where
T: Sync,
T: Sync,
impl<T> Unpin for AnimationSequence<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for AnimationSequence<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,