Skip to main content

SpringScalar

Trait SpringScalar 

Source
pub trait SpringScalar: Lerp + Clone {
    const DIMENSIONS: usize;

    // Required methods
    fn dimension(&self, index: usize) -> f32;
    fn from_dimensions(dimensions: [f32; 4]) -> Self;
}
Expand description

Values springs can animate: fixed-dimension float vectors (at most SPRING_MAX_DIMENSIONS), mirroring Compose’s AnimationVector1D..4D.

The spring integrates each dimension independently in value space — velocity is expressed in value units per second — so retargeting an animation mid-flight keeps the physical velocity (no hitch), and gestures can hand their release velocity to Animatable::animate_to_with_velocity.

Required Associated Constants§

Source

const DIMENSIONS: usize

Number of animated dimensions (1..=4).

Required Methods§

Source

fn dimension(&self, index: usize) -> f32

Reads dimension index (index < Self::DIMENSIONS).

Source

fn from_dimensions(dimensions: [f32; 4]) -> Self

Rebuilds a value from per-dimension floats (indices beyond Self::DIMENSIONS are ignored).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SpringScalar for Color

Colors spring as four independent channels, mirroring how Compose animates Color as an AnimationVector4D. Channels are clamped back into [0, 1] when the vector is rebuilt, so overshooting springs still produce valid colors (Compose’s gamut coercion).

Source§

const DIMENSIONS: usize = 4

Source§

fn dimension(&self, index: usize) -> f32

Source§

fn from_dimensions(dimensions: [f32; 4]) -> Self

Source§

impl SpringScalar for f32

Source§

const DIMENSIONS: usize = 1

Source§

fn dimension(&self, _index: usize) -> f32

Source§

fn from_dimensions(dimensions: [f32; 4]) -> Self

Source§

impl SpringScalar for f64

Source§

const DIMENSIONS: usize = 1

Source§

fn dimension(&self, _index: usize) -> f32

Source§

fn from_dimensions(dimensions: [f32; 4]) -> Self

Implementors§