Struct Keyframe

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

Represents a keyframe in an animation sequence.

A Keyframe specifies a target value to be applied to the Output of the Track to which this keyframe belongs. The Output’s state will be smoothly transitioned from its current state to the target value during the animation. This transition occurs between the start timestamp and the end timestamp.

During this period, a smooth transition is applied using an Easing function, which controls how the value changes from the current state to the target state.

§Example

If a Keyframe is set with a target value of 100, a start time of 0 ms, and an end time of 1000 ms, the Output’s value will gradually move towards value 100 (whatever it means to it: let it be the brightness of a LED, or the position of a Servo), over 1000 milliseconds, following the defined easing function.

use hermes_five::animations::{Easing, Keyframe};
let keyframe = Keyframe::new(100, 0, 1000).set_transition(Easing::SineInOut);

Implementations§

Source§

impl Keyframe

Source

pub fn new<S: Into<State>>(target: S, start: u64, end: u64) -> Keyframe

Creates a new Keyframe with the specified target value, start, and end times.
_default Easing::linear function is used.

§Arguments
  • target - The target state value.
  • start - The start time of the keyframe in milliseconds.
  • end - The end time of the keyframe in milliseconds.
§Panic

Panics if timestamps order are wrong: end < start.

§Example
use hermes_five::animations::Keyframe;
let keyframe = Keyframe::new(100, 0, 1000);
Source

pub fn get_duration(&self) -> u64

Returns the duration of the keyframe.

Source

pub fn get_target(&self) -> State

Returns the target state for the keyframe.

Source

pub fn get_start(&self) -> u64

Returns the start time of the keyframe.

Source

pub fn get_end(&self) -> u64

Returns the end time of the keyframe.

Source

pub fn get_transition(&self) -> Easing

Returns the easing function used in the keyframe.

Source

pub fn set_transition(self, transition: Easing) -> Self

Sets a new easing function for the keyframe.

Trait Implementations§

Source§

impl Clone for Keyframe

Source§

fn clone(&self) -> Keyframe

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 Debug for Keyframe

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.