plushie/animation/spring
Renderer-side physics-based spring descriptor.
Springs animate using a damped harmonic oscillator simulation. Unlike timed transitions, springs have no fixed duration: they settle naturally based on stiffness, damping, and mass. This makes them ideal for interactive animations where the target changes frequently (drag, scroll, hover) because interruption preserves velocity for smooth redirection.
Usage
import plushie/animation/spring
// Custom parameters
spring.new(to: 1.05, stiffness: 200.0, damping: 20.0)
// Named presets
spring.gentle(1.0)
spring.bouncy(1.05) |> spring.from(0.0)
Types
Values
pub fn bouncy(to: Float) -> Spring
Bouncy preset: quick with visible overshoot. (stiffness: 300, damping: 10)
pub fn encode(s: Spring) -> node.PropValue
Encode a spring to its wire-format PropValue.
Only non-default fields are included to keep messages compact.
pub fn gentle(to: Float) -> Spring
Gentle preset: slow, smooth, no overshoot. (stiffness: 120, damping: 14)
pub fn molasses(to: Float) -> Spring
Molasses preset: slow, heavy, deliberate. (stiffness: 60, damping: 12)
pub fn new(
to to: Float,
stiffness stiffness: Float,
damping damping: Float,
) -> Spring
Create a new spring with explicit stiffness and damping.
pub fn snappy(to: Float) -> Spring
Snappy preset: quick, minimal overshoot. (stiffness: 200, damping: 20)
pub fn stiff(to: Float) -> Spring
Stiff preset: very quick, crisp stop. (stiffness: 400, damping: 30)