pub struct Tween<T: Interpolate> { /* private fields */ }Expand description
Time-based interpolation from one value to another.
The tween stores its current value and can be retargeted while active. Time is supplied by the caller, which lets each host drive rendering from its own loop.
Implementations§
Source§impl<T: Interpolate> Tween<T>
impl<T: Interpolate> Tween<T>
Sourcepub fn new(initial: T) -> Result<Self, TweenError>
pub fn new(initial: T) -> Result<Self, TweenError>
Creates an inactive tween whose current value and target are initial.
Sourcepub fn to(
self,
target: T,
duration: Duration,
easing: Easing,
) -> Result<Self, TweenError>
pub fn to( self, target: T, duration: Duration, easing: Easing, ) -> Result<Self, TweenError>
Retargets the tween and returns it for builder-style setup.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns true while the tween is still moving toward its target.
Sourcepub fn set_target(
&mut self,
target: T,
duration: Duration,
easing: Easing,
) -> Result<(), TweenError>
pub fn set_target( &mut self, target: T, duration: Duration, easing: Easing, ) -> Result<(), TweenError>
Starts moving from the current value toward target.
A zero duration snaps immediately to the target.
Sourcepub fn snap(&mut self, value: T) -> Result<(), TweenError>
pub fn snap(&mut self, value: T) -> Result<(), TweenError>
Replaces the current value and target without animation.
Sourcepub fn update(&mut self, dt: Duration) -> Result<T, TweenError>
pub fn update(&mut self, dt: Duration) -> Result<T, TweenError>
Advances the tween by dt and returns the new current value.
Large dt values are allowed and clamp the tween to its target.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Tween<T>where
T: Freeze,
impl<T> RefUnwindSafe for Tween<T>where
T: RefUnwindSafe,
impl<T> Send for Tween<T>where
T: Send,
impl<T> Sync for Tween<T>where
T: Sync,
impl<T> Unpin for Tween<T>where
T: Unpin,
impl<T> UnsafeUnpin for Tween<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Tween<T>where
T: UnwindSafe,
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