Components/Spring

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
spring · dart_tui
Spring demo

Spring

PropertyTypeDescription
fpsintFrame rate the spring is driven at.
frequencydoubleAngular frequency — higher is snappier.
dampingdouble< 1 overshoots, 1 is critical, > 1 is over-damped.
update(pos, vel, target)(double, double)Advance one frame; returns the new (position, velocity).

Related