Skip to main content

SpringCurve

Struct SpringCurve 

Source
#[repr(C)]
pub struct SpringCurve { pub stiffness: f32, pub damping: f32, pub mass: f32, }
Expand description

Mass-spring-damper parameters for AnimationInterpolationFunction::Spring.

Lives here rather than in azul-core because it is part of a #[repr(C)] CSS enum that crosses the C ABI; azul-core re-exports it so the animation engine can keep talking about Spring without reaching across layers.

Fields§

§stiffness: f32

Pull toward the target. Higher = faster, more eager.

§damping: f32

Resistance. Higher = less overshoot; at critical damping, none.

§mass: f32

Inertia. Higher = more sluggish, more overshoot for a given stiffness.

Implementations§

Source§

impl SpringCurve

Source

pub const SMOOTH: Self

No overshoot, quick settle. The safe default for UI motion.

Source

pub const GENTLE: Self

Soft and slow; for large surfaces where snappiness reads as jarring.

Source

pub const SNAPPY: Self

Fast with a slight overshoot; for small controls that should feel crisp.

Source

pub const MAX_STEP_SECS: f32 = 0.05

Longest step handed to the integrator, in seconds (~3 frames at 60 Hz).

Source

pub const EPSILON_VALUE: f32 = 0.06

Distance below which a spring counts as arrived (~a sixteenth of a device px).

Source

pub const EPSILON_VELOCITY: f32 = 0.06

Speed below which a spring counts as stopped, in units/second.

Source

pub fn damping_ratio(&self) -> f32

The damping ratio: < 1 under-damped (overshoots), 1 critical, > 1 over-damped.

Source

pub fn step( &self, value: f32, target: f32, velocity: f32, dt: f32, ) -> (f32, f32)

One integration step. Returns the new (value, velocity).

dt is clamped: a stalled frame (tab restored, breakpoint hit) must not hand the integrator a huge step and fling the value off to infinity.

Source

pub fn is_settled(&self, value: f32, target: f32, velocity: f32) -> bool

Whether the spring has effectively arrived.

Both conditions are required: near the target AND barely moving. Position alone would settle at the peak of an overshoot, mid-flight.

Trait Implementations§

Source§

impl Clone for SpringCurve

Source§

fn clone(&self) -> SpringCurve

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 Copy for SpringCurve

Source§

impl Debug for SpringCurve

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SpringCurve

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SpringCurve

Source§

fn eq(&self, other: &SpringCurve) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SpringCurve

Auto Trait Implementations§

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.