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
impl Keyframe
Sourcepub fn new<S: Into<State>>(target: S, start: u64, end: u64) -> Keyframe
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);
Sourcepub fn get_duration(&self) -> u64
pub fn get_duration(&self) -> u64
Returns the duration of the keyframe.
Sourcepub fn get_target(&self) -> State
pub fn get_target(&self) -> State
Returns the target state for the keyframe.
Sourcepub fn get_transition(&self) -> Easing
pub fn get_transition(&self) -> Easing
Returns the easing function used in the keyframe.
Sourcepub fn set_transition(self, transition: Easing) -> Self
pub fn set_transition(self, transition: Easing) -> Self
Sets a new easing function for the keyframe.