Skip to main content

AnimatedValue

Struct AnimatedValue 

Source
pub struct AnimatedValue<T: Interpolate + Clone> { /* private fields */ }
Expand description

Animated value that transitions smoothly.

Supports two modes:

  • Tween (when spec.spring is None): interpolates between start and target over a fixed duration using an easing curve.
  • Spring (when spec.spring is Some): numerically integrates a physical spring ODE (x'' = -k·(x - target) - d·x') with emergent duration. When the target changes mid-animation, the current value and velocity carry forward seamlessly.

Implementations§

Source§

impl AnimatedValue<f32>

Source

pub fn update_decay(&mut self, friction: f32, stop_threshold: f32) -> bool

Tick the decay animation. Returns true if still animating.

Source§

impl<T: Interpolate + Clone> AnimatedValue<T>

Source

pub fn new(initial: T, spec: AnimationSpec) -> Self

Source

pub fn set_spec(&mut self, spec: AnimationSpec)

Source

pub fn set_keyframes(&mut self, keyframes: KeyframesSpec<T>)

Set a keyframes spec for multi-stage animation. When set, set_target is ignored and the value is driven by the keyframe sequence.

Source

pub fn set_target(&mut self, target: T)

Source

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

Snap immediately to a value without animating.

Source

pub fn update(&mut self) -> bool

Source

pub fn get(&self) -> &T

Source

pub fn is_animating(&self) -> bool

Source

pub fn has_keyframes(&self) -> bool

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for AnimatedValue<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> 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, 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.