ball bounce — live canvas animation example

motion & easing8-
trig, angles & vectors8+
collision detection11+
numbers in motion7+
geometry & shapes8+
generative showpieces13+
handy helpers7+
low = thuds · high = springy

Gravity, bounce, and a little friction.

Every ball runs the same one-line physics step: add gravity to its vertical speed, move, and on each wall/floor hit reflect the speed and keep a fraction of it — that fraction is restitution (bounciness). Drag the slider: near 1 the balls barely tire; lower and they die out fast.

Rainbow balls keep streaming in, staggered, so there's always one in the air. They're drawn from a fixed object pool — once the pit is full we never make a new one; instead the ball that's rested longest is plucked off the floor and dropped again. The streaks are motion trails — we fade the previous frame instead of erasing it, so movement leaves a comet.