Struct AnimationSequence

Source
pub struct AnimationSequence<T> { /* private fields */ }
Expand description

A collection of keyframes that can be played back in sequence

Implementations§

Source§

impl<T> AnimationSequence<T>

Source

pub fn new() -> Self

Creates a new empty animation sequence

Source

pub fn insert( &mut self, keyframe: Keyframe<T>, ) -> Result<(), AnimationSequenceError>

Inserts a new keyframe into the animation sequence

Source

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.

Source

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

Source

pub fn clear(&mut self)

Removes all keyframes from this sequence

Source

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.

Source

pub fn has_keyframe_at(&self, timestamp: f64) -> bool

If this sequence has a keyframe at the exact timestamp

Source

pub fn keyframes(&self) -> usize

The number of keyframes in this sequence

Source

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
Source

pub fn now_strict(&self) -> Option<T>
where T: CanTween + Clone,

The current value of this sequence, only based on the existing sequence entries.

Source

pub fn now(&self) -> T
where T: CanTween + Clone + Default,

The current value of this sequence, use the default if necessary.

Source

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.

Source

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.

Source

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.

Source

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()
Source

pub fn duration(&self) -> f64

The length in seconds of this sequence

Source

pub fn time(&self) -> f64

The current progression of this sequence in seconds

Source

pub fn progress(&self) -> f64

The current progression of this sequence as a percentage

Source

pub fn finished(&self) -> bool

If this sequence has finished and is at the end. It can be reset with advance_to(0.0).

Source

pub fn reverse(&mut self)

Reverses the order of all keyframes in this sequence

Source§

impl<T: Float + CanTween + Clone> AnimationSequence<T>

Source

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§

Source§

impl<T: Clone> Clone for AnimationSequence<T>

Source§

fn clone(&self) -> AnimationSequence<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Default> Default for AnimationSequence<T>

Source§

fn default() -> AnimationSequence<T>

Returns the “default value” for a type. Read more
Source§

impl<T> From<Vec<Keyframe<T>>> for AnimationSequence<T>

Source§

fn from(vec: Vec<Keyframe<T>>) -> Self

Creates a new animation sequence from a vector of keyframes

Source§

impl<T, I: Into<Keyframe<T>>> FromIterator<I> for AnimationSequence<T>

Source§

fn from_iter<I2: IntoIterator<Item = I>>(iter: I2) -> Self

Creates a new animation sequence from an iterator

Source§

impl<'a, T> IntoIterator for &'a AnimationSequence<T>

Source§

type Item = &'a Keyframe<T>

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Keyframe<T>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for AnimationSequence<T>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.