pub struct Animated<T: Animatable> { /* private fields */ }Expand description
A value that moves toward its target along a Curve. Time is in seconds on the caller’s
clock (f64), the same clock for every call.
A retarget samples position and velocity at now and starts the new motion from there, so
a value interrupted mid-flight never jumps or loses its speed. Once settled, the value is
exactly its target.
Implementations§
Source§impl<T: Animatable> Animated<T>
impl<T: Animatable> Animated<T>
Sourcepub fn set_pixels_per_point(&mut self, pixels_per_point: f32)
pub fn set_pixels_per_point(&mut self, pixels_per_point: f32)
Settle thresholds for a display with pixels_per_point (from the next motion on).
Sourcepub fn curve(&self) -> Curve
pub fn curve(&self) -> Curve
The curve of the current motion (Curve::Instant at rest or after a jump).
Sourcepub fn set(&mut self, value: T)
pub fn set(&mut self, value: T)
Jump to value and stop: for direct manipulation, where the value follows the user’s hand.
Sourcepub fn animate_to(
&mut self,
target: T,
curve: Curve,
now: f64,
prefs: &MotionPrefs,
) -> bool
pub fn animate_to( &mut self, target: T, curve: Curve, now: f64, prefs: &MotionPrefs, ) -> bool
Move toward target along curve, from wherever the value is at now and with its
current velocity. Under prefs.reduced the class’s reduced curve is used instead
(Class::reduce). Returns false and does nothing when target is the current target
(so calling this every frame with the same target is free).
Sourcepub fn release(
&mut self,
velocity: T,
target: T,
curve: Curve,
now: f64,
prefs: &MotionPrefs,
)
pub fn release( &mut self, velocity: T, target: T, curve: Curve, now: f64, prefs: &MotionPrefs, )
Let go with velocity (per lane, units per second) and move toward target along
curve, from wherever the value is at now: the end of a drag or fling. Always restarts.
Sourcepub fn velocity(&self, now: f64) -> T
pub fn velocity(&self, now: f64) -> T
The velocity at now, per lane in units per second (0 once settled). For a type whose
lanes are not linear in the value (a colour), read it through Animated::velocity_lanes.
Sourcepub fn sample_lanes(&self, now: f64) -> Lanes
pub fn sample_lanes(&self, now: f64) -> Lanes
The lanes of the value at now.
Sourcepub fn velocity_lanes(&self, now: f64) -> Lanes
pub fn velocity_lanes(&self, now: f64) -> Lanes
The velocity lanes at now (all 0 once settled; 0 for a lane an effect class holds at
its start or target).
Sourcepub fn settle_at(&self) -> f64
pub fn settle_at(&self) -> f64
When the value is settled for good (f64::NEG_INFINITY at rest). A caller requests
frames only while now < settle_at().
Sourcepub fn is_settled(&self, now: f64) -> bool
pub fn is_settled(&self, now: f64) -> bool
Whether the value is settled at now (it then is exactly its target).