pub struct AnimationController { /* private fields */ }Expand description
The animation vocabulary: the shell-fed frame clock (FrameTime)
plus the pure easing/interpolation/spring math a widget or app advances it
through, flat-re-exported from frust-core::anim. Time enters from the
shell during paint (PaintCtx::frame_time); nothing here reads a clock.
A 0.0..=1.0 value driven by a duration + Curve or a Spring fling.
Plain data + math (see the module contract): a widget advances it during
paint and re-requests a frame while advance returns true.
forward/reverse/animate_to settle as Completed/Dismissed; repeat
never completes; a fling settles at 1.0 (non-negative velocity) or 0.0.
§Overshoot (spring-driven only)
A fling is not clamped in flight: an under-damped SpringDesc (M3’s spatial
presets use damping_ratio: 0.9) overshoots on purpose, then lands exactly on
the target. Use value_clamped for a bounded read.
Implementations§
Source§impl AnimationController
impl AnimationController
Sourcepub fn new(duration: Duration) -> AnimationController
pub fn new(duration: Duration) -> AnimationController
Create an idle controller at 0.0 with the given default duration and Curve::Linear.
Sourcepub fn with_curve(self, curve: Curve) -> AnimationController
pub fn with_curve(self, curve: Curve) -> AnimationController
Set the easing curve applied to duration-driven motion (builder-style).
Sourcepub fn value(&self) -> f64
pub fn value(&self) -> f64
The current value: within 0.0..=1.0 for duration motion, but a spring
fling may transiently leave that range (see the type docs’
Overshoot section); see value_clamped.
Sourcepub fn value_clamped(&self) -> f64
pub fn value_clamped(&self) -> f64
value clamped to 0.0..=1.0; differs from it only while a
fling overshoots.
Sourcepub fn status(&self) -> AnimationStatus
pub fn status(&self) -> AnimationStatus
The current lifecycle status.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Whether a motion is in progress (the next advance makes progress).
Sourcepub fn animate_to(&mut self, target: f64)
pub fn animate_to(&mut self, target: f64)
Animate from the current value to target (clamped to 0.0..=1.0) over
the controller’s duration.
Sourcepub fn repeat(&mut self)
pub fn repeat(&mut self)
Loop 0.0→1.0 (eased) indefinitely with a period of the controller’s
duration. advance always returns true for a repeat.
Sourcepub fn fling(&mut self, velocity: f64, spring: SpringDesc)
pub fn fling(&mut self, velocity: f64, spring: SpringDesc)
Start a spring fling from the current value with initial velocity (value
units per second), settling at 1.0 for a non-negative velocity, else 0.0.
The value is not clamped in flight (see the type docs’ Overshoot section).
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Halt any in-progress motion, leaving the value where it is and the status
AnimationStatus::Idle.
Sourcepub fn advance(&mut self, now: FrameTime) -> bool
pub fn advance(&mut self, now: FrameTime) -> bool
Advance to frame time now, returning whether it is still animating (the
caller must then request another frame).
The delta uses FrameTime::saturating_sub, so a repeated or out-of-order
timestamp yields a zero delta, never a panic or NaN. The first advance
after starting a motion only seeds the clock.
Trait Implementations§
Source§impl Clone for AnimationController
impl Clone for AnimationController
Source§fn clone(&self) -> AnimationController
fn clone(&self) -> AnimationController
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for AnimationController
Auto Trait Implementations§
impl Freeze for AnimationController
impl RefUnwindSafe for AnimationController
impl Send for AnimationController
impl Sync for AnimationController
impl Unpin for AnimationController
impl UnsafeUnpin for AnimationController
impl UnwindSafe for AnimationController
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.