pub struct Tweened<T: Lerp + 'static> { /* private fields */ }Expand description
A value that animates toward whatever it is told to become.
Reads are reactive, so a canvas that reads a Tweened re-records every frame of its
transition and not otherwise. Retargeting mid-flight starts the new transition from the value
on screen, which keeps the motion continuous: a slider dragged back and forth bends the path
instead of snapping it.
ⓘ
let height = Tweened::new(0.0);
button("Grow").action(move || height.animate_to(120.0, AnimSpec::spring(0.4, 0.8)));
canvas(move |d, _| d.fill(Shape::Rect(Rect::new(0.0, 0.0, 40.0, height.get())), BLUE));Implementations§
Source§impl<T: Lerp + 'static> Tweened<T>
impl<T: Lerp + 'static> Tweened<T>
Sourcepub fn on(clock: FrameClock, initial: T) -> Self
pub fn on(clock: FrameClock, initial: T) -> Self
A value at initial, animating on clock.
Sourcepub fn get_untracked(&self) -> T
pub fn get_untracked(&self) -> T
The value on screen now, without subscribing.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Whether a transition is in flight.
Sourcepub fn animate_to(&self, target: T, spec: AnimSpec)
pub fn animate_to(&self, target: T, spec: AnimSpec)
Animate from the value on screen to target under spec.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Tweened<T>
impl<T> !Send for Tweened<T>
impl<T> !Sync for Tweened<T>
impl<T> !UnwindSafe for Tweened<T>
impl<T> Freeze for Tweened<T>
impl<T> Unpin for Tweened<T>
impl<T> UnsafeUnpin for Tweened<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more