Spring

class Spring(stiffness: Float = 120.0f, damping: Float = 0.55f, initial: Float = 0.0f)

A value that chases a target and overshoots a little before settling.

This is the difference between a drawing that answers the music and one that reads as a meter. Setting a size straight from a beat makes it snap, because the number snaps. Pushing a spring with the beat instead gives the growth a beginning, a peak and a recovery, which is what a physical object does and what an eye expects.

Beats should call kick, never write value. A kick adds speed, so two hits close together add up instead of the second one cancelling the first.

Constructors

Link copied to clipboard
constructor(stiffness: Float = 120.0f, damping: Float = 0.55f, initial: Float = 0.0f)

Properties

Link copied to clipboard

How long after a kick this spring reaches its peak, in seconds.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun advance(deltaSeconds: Float)

Moves the spring on by one frame.

Link copied to clipboard
fun kick(amount: Float)

Adds speed. This is how a beat pushes something rather than placing it.

Link copied to clipboard
fun reset(to: Float = 0.0f)