com.williamcallahan.tui4j.compat.harmonica.
How it works
ASpring computes new position and velocity values each frame from the current state and a target equilibrium. Call update() once per frame and write the resulting position to your view:
target at a rate determined by three parameters: FPS, frequency, and damping.
Creating a spring
Spring.newSpring(double deltaTime, double angularFrequency, double dampingRatio)
Advancing the simulation
Callupdate(pos, vel, equilibriumPos) once per animation frame:
double[] array: [newPosition, newVelocity]. Store both values and feed them back into the next update() call.
Complete example: animated ellipse following the mouse
The cell-buffer example uses two independent springs — one for the X axis and one for the Y axis — to smoothly chase the mouse cursor:Animating a progress bar
Use a single spring to animate a bar toward a target width:Tuning the parameters
Projectile motion
Projectile simulates ballistic motion under acceleration. It is useful for effects like particles or bouncing elements:
Mouse input
Combine mouse tracking with spring animation
External commands
Launch editors and shells from your TUI