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, ResourcePool, 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()), 2.5);
assert_eq!(track.sample(1250.milliseconds()), 10.0);
assert_eq!(track.sample(2.seconds()), 15.0);
assert_eq!(track.duration(), Some(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: Time, value: Value, easing: Easing) -> Self
pub fn to(self, at: Time, 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, or for invalid easing parameters. Equal, negative
and descending times are not sorted or converted into instantaneous jumps.
Trait Implementations§
Source§impl<Value: Interpolate + Send + Sync> Animation<Value> for Keyframes<Value>
impl<Value: Interpolate + Send + Sync> Animation<Value> for Keyframes<Value>
Source§fn sample(&self, time: Time) -> Value
fn sample(&self, time: Time) -> Value
Source§fn duration(&self) -> Option<Duration>
fn duration(&self) -> Option<Duration>
None for an unbounded signal.Source§fn map<Output, Function>(self, function: Function) -> Map<Self, Function, Value>
fn map<Output, Function>(self, function: Function) -> Map<Self, Function, Value>
Source§fn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
fn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
Source§fn delay(self, offset: Duration) -> Delay<Self>where
Self: Sized,
fn delay(self, offset: Duration) -> Delay<Self>where
Self: Sized,
Source§fn speed(self, factor: f64) -> Speed<Self>where
Self: Sized,
fn speed(self, factor: f64) -> Speed<Self>where
Self: Sized,
Source§fn then<Next: Animation<Value>>(self, next: Next) -> Then<Self, Next>where
Self: Sized,
fn then<Next: Animation<Value>>(self, next: Next) -> Then<Self, Next>where
Self: Sized,
Source§fn reverse(self) -> Reverse<Self>where
Self: Sized,
fn reverse(self) -> Reverse<Self>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.
Infinite sources or duration overflow panic at construction.