Skip to main content

Animated

Struct Animated 

Source
pub struct Animated<T> { /* private fields */ }
Expand description

A value on its way to a target. It holds no clock: every call takes the time.

Redirecting is continuous. A spring restarts from the current position and velocity, which is the exact solution for a moved anchor. Tweens are additive: the new one eases in the target’s change while earlier ones finish easing out theirs, and the sum has no corner, even when a hover flickers.

Implementations§

Source§

impl<T: Animatable> Animated<T>

Source

pub fn new(value: T) -> Self

A value at rest.

Source

pub fn target(&self) -> T

Where the value is heading.

Source

pub fn set_target(&mut self, target: T, transition: Transition, now: f64)

Sends the value to target starting at time now (seconds). Asking for the current target again does nothing, so calling this on every build is fine.

Source

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

The value at time now.

Source

pub fn velocity(&self, now: f64) -> [f32; 4]

Rate of change per second of each component at time now.

Source

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

Forgets what has finished by time now. Returns true while still moving.

Source

pub fn is_moving(&self) -> bool

True while the value has not reached its target as of the last Self::step.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Animated<T>

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: Debug> 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> Freeze for Animated<T>
where T: Freeze,

§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.