To create an oscillation animation using HTML5 Canvas, we can use the equation for a simple harmonic oscillator to set the shape's position for each frame:
x(t) = amplitude * sin(t * 2PI / period) + x0
Code Editor
Modified on April 9th, 2013
by Eric Rowell