nativeview-physics
Zero-dependency, zero-allocation closed-form physics and timing-curve primitives shared across nativeview-layout, nativeview-motion, nativeview-ui, and pluggable scroll/animation engines.
Primitives
- Springs (
SpringSpec,SpringState): Unconditionally stablef64closed-form damped harmonic oscillator covering under-damped, critically-damped, and over-damped regimes with velocity-preserving mid-flight retargeting. - Exponential Decay (
DecaySpec,DecayState): Closed-form inertial deceleration, exact boundary hit-time intersection, projected resting distance, and inverse launch velocity for snap targeting. - Rubber-Band Resistance (
RubberBandSpec): Apple-style asymptotic drag resistance with exact forward and inverse transforms. - Smooth Wheel (
SmoothWheelSpec): Closed-form exponential smoothing for discrete wheel detents. - Velocity Tracking (
VelocityTracker,VelocityTrackerConfig):Copy, zero-heap EMA gesture velocity estimator with pause reset and clamping. - Easing Curves (
CubicBezier,StepPosition,EasingCurve): Bracketed Newton-Raphson / bisection CSScubic-bezier,steps(), and spring step-response curves.
Example
use ;
let spec = snappy;
let mut spring = new;
for _ in 0..300
assert_eq!;
let decay = apple;
let dist = decay.projected_distance;
let v0 = decay.initial_velocity_for_distance;
assert!;
let rb = APPLE;
let vis = rb.forward;
assert!;
let = apple.step;
assert!;
let mut tracker = new;
tracker.record_dt;
assert!;
assert!;
assert_eq!;
Verification