pub struct Keyframes<Value> { /* private fields */ }Expand description
A nonempty track starting at zero, with absolute destinations and relative holds.
Exact timestamps return stored values. Intervals use the arriving point’s easing, while holds clone their value without invoking interpolation. Sampling is stateless and uses integer ticks for interval selection before f64 progress.
This is the canonical crate::Keyframes type.
use motion_core::prelude::*;
use motion_core::{
DisplayList, RasterLimits, ResourceStore, ValidatedDisplayList, MAX_PATH_VERBS,
MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
let track = Keyframes::new(0.0_f64)
.to(1.seconds(), 10.0, Easing::QuadraticIn)
.hold(500.milliseconds())
.to(2.5.seconds(), 20.0, Easing::Linear);
assert_eq!(track.sample(500.milliseconds().after_origin()), 2.5);
assert_eq!(track.sample(1250.milliseconds().after_origin()), 10.0);
assert_eq!(track.sample(2.seconds().after_origin()), 15.0);
assert_eq!(track.duration(), 2.5.seconds());Implementations§
Source§impl<Value> Keyframes<Value>
impl<Value> Keyframes<Value>
Sourcepub fn new(value: Value) -> Self
pub fn new(value: Value) -> Self
Starts with a value at zero. Without further points the finite duration is zero and every sample returns this value.
Sourcepub fn to(self, at: Duration, value: Value, easing: Easing) -> Self
pub fn to(self, at: Duration, value: Value, easing: Easing) -> Self
Appends a destination at an absolute local time, not an added duration. The easing controls the segment arriving at this value.
§Panics
Panics unless at is strictly later than the previous point, including
any appended hold. Equal and descending times are not sorted or converted
into instantaneous jumps.
Source§impl<Value: Clone> Keyframes<Value>
impl<Value: Clone> Keyframes<Value>
Sourcepub fn hold(self, duration: Duration) -> Self
pub fn hold(self, duration: Duration) -> Self
Holds the last value for an additional duration, without interpolation. Zero is a no-op, leaving the last timestamp unchanged.
§Panics
Panics on signed tick overflow; see Self::try_hold.
Sourcepub fn try_hold(self, duration: Duration) -> Result<Self, ValidationError>
pub fn try_hold(self, duration: Duration) -> Result<Self, ValidationError>
Holds like Self::hold, reporting tick overflow.
Trait Implementations§
Source§impl<Value: Interpolate + Send + Sync> FiniteAnimation<Value> for Keyframes<Value>
impl<Value: Interpolate + Send + Sync> FiniteAnimation<Value> for Keyframes<Value>
Source§fn delay(self, offset: Duration) -> Delay<Self>where
Self: Sized,
fn delay(self, offset: Duration) -> Delay<Self>where
Self: Sized,
Source§fn try_delay(self, offset: Duration) -> Result<Delay<Self>, ValidationError>where
Self: Sized,
fn try_delay(self, offset: Duration) -> Result<Delay<Self>, ValidationError>where
Self: Sized,
Self::delay, reporting duration overflow.Source§fn speed(self, factor: f64) -> Speed<Self>where
Self: Sized,
fn speed(self, factor: f64) -> Speed<Self>where
Self: Sized,
Source§fn try_speed(self, factor: f64) -> Result<Speed<Self>, ValidationError>where
Self: Sized,
fn try_speed(self, factor: f64) -> Result<Speed<Self>, ValidationError>where
Self: Sized,
Self::speed, reporting an invalid factor or
unrepresentable duration.Source§fn then<Next: FiniteAnimation<Value>>(self, next: Next) -> Then<Self, Next>where
Self: Sized,
fn then<Next: FiniteAnimation<Value>>(self, next: Next) -> Then<Self, Next>where
Self: Sized,
Source§fn repeat(self, count: u32) -> Repeat<Self>where
Self: Sized,
fn repeat(self, count: u32) -> Repeat<Self>where
Self: Sized,
count times. Intermediate boundaries restart;
the final boundary holds the target. Zero repeats hold the initial value.
Duration overflow panics at construction.