Skip to main content

Animated

Struct Animated 

Source
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>

Source

pub fn new(value: T, class: Class) -> Self

A value at rest at value.

Source

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).

Source

pub fn class(&self) -> Class

The value’s class.

Source

pub fn target(&self) -> T

Where the value comes to rest.

Source

pub fn curve(&self) -> Curve

The curve of the current motion (Curve::Instant at rest or after a jump).

Source

pub fn set(&mut self, value: T)

Jump to value and stop: for direct manipulation, where the value follows the user’s hand.

Source

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).

Source

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.

Source

pub fn sample(&self, now: f64) -> T

The value at now.

Source

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.

Source

pub fn sample_lanes(&self, now: f64) -> Lanes

The lanes of the value at now.

Source

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).

Source

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().

Source

pub fn is_settled(&self, now: f64) -> bool

Whether the value is settled at now (it then is exactly its target).

Trait Implementations§

Source§

impl<T: Animatable> Clone for Animated<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Animatable> Copy for Animated<T>

Source§

impl<T: Animatable> Debug for Animated<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Forget for Animated<T>

§

impl<T> Freeze for Animated<T>
where T: Freeze,

§

impl<T> Move for Animated<T>

§

impl<T> RefUnwindSafe for Animated<T>
where T: RefUnwindSafe,

§

impl<T> Send for Animated<T>
where T: Send,

§

impl<T> Sync for Animated<T>
where T: Sync,

§

impl<T> Unpin for Animated<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Animated<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Animated<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.