Struct Keyframe

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

Intermediate step in an animation sequence

Implementations§

Source§

impl<T> Keyframe<T>

Source

pub fn new<F: Float>( value: T, time: F, function: impl EasingFunction + 'static + Send + Sync, ) -> Self

Creates a new keyframe from the specified values. If the time value is negative the keyframe will start at 0.0.

§Arguments
  • value - The value that this keyframe will be tweened to/from
  • time - The start time in seconds of this keyframe
  • function - The easing function to use from the start of this keyframe to the start of the next keyframe
Source

pub fn new_dynamic<F: Float>( value: T, time: F, function: Box<dyn EasingFunction + Send + Sync + 'static>, ) -> Self

Same as new, but allows you to supply an easing function which size is not known at compile time.

§Arguments
  • value - The value that this keyframe will be tweened to/from
  • time - The start time in seconds of this keyframe
  • function - The easing function to use from the start of this keyframe to the start of the next keyframe
Source

pub fn value(&self) -> T
where T: Clone,

The value of this keyframe

Source

pub fn time(&self) -> f64

The time in seconds at which this keyframe starts in a sequence

Source

pub fn function(&self) -> &dyn EasingFunction

The easing function that will be used when tweening to another keyframe

Source

pub fn tween_to(&self, next: &Keyframe<T>, time: impl Float) -> T
where T: CanTween + Clone,

Returns the value between this keyframe and the next keyframe at the specified time

§Note

The following applies if:

  • The requested time is before the start time of this keyframe: the value of this keyframe is returned
  • The requested time is after the start time of next keyframe: the value of the next keyframe is returned
  • The start time of the next keyframe is before the start time of this keyframe: the value of the next keyframe is returned

Trait Implementations§

Source§

impl<T: Clone> Clone for Keyframe<T>

Source§

fn clone(&self) -> Keyframe<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: Debug> Debug for Keyframe<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T: Display> Display for Keyframe<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<V, T: Float> From<(V, T)> for Keyframe<V>

Source§

fn from(tuple: (V, T)) -> Self

Creates a new keyframe from a tuple of (value, time). EaseInOut will be used as the easing function. If the time value is negative the keyframe will start at 0.0.

Source§

impl<V, T: Float> From<(V, T, Box<dyn EasingFunction + Sync + Send>)> for Keyframe<V>

Source§

fn from(tuple: (V, T, Box<dyn EasingFunction + Send + Sync + 'static>)) -> Self

Creates a new keyframe from a tuple of (value, time, function). If the time value is negative the keyframe will start at 0.0.

Source§

impl<V, T: Float, F: EasingFunction + 'static + Send + Sync> From<(V, T, F)> for Keyframe<V>

Source§

fn from(tuple: (V, T, F)) -> Self

Creates a new keyframe from a tuple of (value, time, function). If the time value is negative the keyframe will start at 0.0.

Auto Trait Implementations§

§

impl<T> Freeze for Keyframe<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Keyframe<T>

§

impl<T> Send for Keyframe<T>
where T: Send,

§

impl<T> Sync for Keyframe<T>
where T: Sync,

§

impl<T> Unpin for Keyframe<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Keyframe<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.