Spring
A damped-harmonic-oscillator for smooth, eased motion of any scalar — a progress value, a scroll offset, a cursor position. Pure math with no terminal I/O; drive it one frame per TickMsg. damping < 1 overshoots, 1 is critical, > 1 never overshoots.
Install the package
Every component ships in the single dart_tui package.
$dart pub add dart_tui

final spring = Spring(fps: 60, frequency: 6, damping: 1);
var (pos, vel) = (0.0, 0.0);
const target = 1.0;
// each TickMsg, ease toward the target:
(pos, vel) = spring.update(pos, vel, target);Spring
| Property | Type | Description |
|---|---|---|
| fps | int | Frame rate the spring is driven at. |
| frequency | double | Angular frequency — higher is snappier. |
| damping | double | < 1 overshoots, 1 is critical, > 1 is over-damped. |
| update(pos, vel, target) | (double, double) | Advance one frame; returns the new (position, velocity). |