pub struct Tween { /* private fields */ }Expand description
Smooth scalar tween between 0.0 and 1.0 (or any pair of values the
caller interprets). Drives animations such as the scroll-bar hover
expansion and toggle-switch on/off slide.
Implementations§
Source§impl Tween
impl Tween
Sourcepub const fn new(initial: f64, duration_secs: f64) -> Self
pub const fn new(initial: f64, duration_secs: f64) -> Self
New tween that starts at initial with the same value as its target
(no animation in flight).
Sourcepub fn set_target(&mut self, new_target: f64)
pub fn set_target(&mut self, new_target: f64)
Update the target. If it differs from the current target, re-anchors the animation at the current interpolated value so reversals are smooth.
Sourcepub fn tick(&mut self) -> f64
pub fn tick(&mut self) -> f64
Advance the animation based on elapsed wall time and return the new
interpolated value. Ease-out cubic. While in flight this also calls
request_tick so the host keeps painting frames until completion.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tween
impl RefUnwindSafe for Tween
impl Send for Tween
impl Sync for Tween
impl Unpin for Tween
impl UnsafeUnpin for Tween
impl UnwindSafe for Tween
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