pub struct Tween<Value> { /* private fields */ }Expand description
A finite endpoint-to-endpoint interpolation with double-precision progress.
use motion_core::prelude::*;
use motion_core::{
DisplayList, RasterLimits, ResourcePool, ValidatedDisplayList, MAX_PATH_VERBS,
MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
let movement = Tween::new(Point::ORIGIN, Point::new(100.0, 40.0), 2.seconds());
assert_eq!(movement.sample(1.seconds()), Point::new(50.0, 20.0));
assert_eq!(movement.sample((-1).seconds()), Point::ORIGIN);Implementations§
Source§impl<Value> Tween<Value>
impl<Value> Tween<Value>
Sourcepub fn new(from: Value, to: Value, duration: Duration) -> Self
pub fn new(from: Value, to: Value, duration: Duration) -> Self
Creates a linear tween. A negative duration panics at construction.
A zero duration holds from before zero and to at/after zero.
Sourcepub fn try_new(
from: Value,
to: Value,
duration: Duration,
) -> Result<Self, ValidationError>
pub fn try_new( from: Value, to: Value, duration: Duration, ) -> Result<Self, ValidationError>
Creates a tween from dynamic input without panicking for negative duration.
Sourcepub fn easing(self, easing: Easing) -> Self
pub fn easing(self, easing: Easing) -> Self
Selects a f64 curve. Invalid curve parameters panic during construction.
Sourcepub fn try_easing(self, easing: Easing) -> Result<Self, ValidationError>
pub fn try_easing(self, easing: Easing) -> Result<Self, ValidationError>
Selects a curve after recoverable validation of its built-in parameters.
Trait Implementations§
Source§impl<Value: Interpolate + Send + Sync> Animation<Value> for Tween<Value>
impl<Value: Interpolate + Send + Sync> Animation<Value> for Tween<Value>
Source§fn sample(&self, time: Time) -> Value
fn sample(&self, time: Time) -> Value
Samples without advancing a clock or changing playback state.
Source§fn duration(&self) -> Option<Duration>
fn duration(&self) -> Option<Duration>
Returns the finite duration, or
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>
Transforms values without changing timing.
Source§fn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
fn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
Samples in parallel; the duration is infinite if either input is infinite.
Source§fn delay(self, offset: Duration) -> Delay<Self>where
Self: Sized,
fn delay(self, offset: Duration) -> Delay<Self>where
Self: Sized,
Delays a finite animation, holding its initial value before the offset.
Infinite signals shift their signed time instead. Negative offsets and
finite duration overflow panic at construction.
Source§fn speed(self, factor: f64) -> Speed<Self>where
Self: Sized,
fn speed(self, factor: f64) -> Speed<Self>where
Self: Sized,
Changes playback speed by a finite, strictly positive factor.
Durations round to the nearest tick; a collapsed finite animation becomes
instantaneous. Invalid factors and unrepresentable durations panic.
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,
Runs two finite animations in sequence. The second owns their shared
boundary. Infinite sources or duration overflow panic at construction.
Source§fn reverse(self) -> Reverse<Self>where
Self: Sized,
fn reverse(self) -> Reverse<Self>where
Self: Sized,
Reverses a finite animation. Infinite sources panic at construction.
Source§fn repeat(self, count: u32) -> Repeat<Self>where
Self: Sized,
fn repeat(self, count: u32) -> Repeat<Self>where
Self: Sized,
Plays a finite animation
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.Auto Trait Implementations§
impl<Value> !RefUnwindSafe for Tween<Value>
impl<Value> !UnwindSafe for Tween<Value>
impl<Value> Forget for Tween<Value>
impl<Value> Freeze for Tween<Value>where
Value: Freeze,
impl<Value> Send for Tween<Value>where
Value: Send,
impl<Value> Sync for Tween<Value>where
Value: Sync,
impl<Value> Unpin for Tween<Value>where
Value: Unpin,
impl<Value> UnsafeUnpin for Tween<Value>where
Value: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more