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§
Sourceconst DIMENSIONS: usize
const DIMENSIONS: usize
Number of animated dimensions (1..=4).
Required Methods§
Sourcefn from_dimensions(dimensions: [f32; 4]) -> Self
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).
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).