Cranpose Animation
A physics-based animation library designed for the Cranpose composition model.
When to Use
Use this crate to create smooth, interruptible animations. Unlike traditional timeline-based animation systems, Cranpose animations are driven by state changes. When a target value changes, the animation system automatically calculates the transition from the current value to the new target, maintaining velocity and continuity.
Key Concepts
Animatable<T, V>: A low-level value holder that tracks the current value and velocity. It is the primitive used to build higher-level animation APIs.AnimationSpec: Defines the behavior of an animation. Common types include:Spring: Physical simulation based on stiffness and damping ratio.Tween: Duration-based interpolation with an easing curve.
animate*AsState: Composable functions that subscribe to a target value and return aStateobject representing the current animated value.animateFloatAsStateandanimateColorAsStateare joined byanimateDpAsState,animateOffsetAsState,animateSizeAsStateandanimateRectAsState, all built over the genericanimateValueAsStateand theSpringScalarvector-converter core -- any type that decomposes into a fixed-size float vector (seeSpringScalar/Lerp) gets a specialization for free.Transition<S>: A finite, state-driven animation obtained fromupdateTransition. Multiple child animations (transition.animateFloat { },.animateDp { },.animateColor { }, or the generic.animateValue { }) each derive their own target from the same state and run in lockstep;transition.is_running()istrueuntil every child has settled.
Example: Interruptible Spring Animation
use *;
Example: Infinite Transition
use ;
use *;
Example: Finite, State-Driven Transition
use ;
use Color;