Pebbles

Original demo by Vincent Hardy, published October 4, 2009.

Open Pebbles in the gallery

Pebbles is a compact demonstration of two methods on the SVG path element: getTotalLength and getPointAtLength. Together they let a script walk along any outline and ask where it is at each step.

The document holds two hidden paths, the outlines of the words SVG and Wow. The script samples 250 points along each one and places a small circle at every point on the first, with a little random offset and a shared radial gradient that makes it look like a polished stone. After play is pressed, the pebbles appear in random order and begin to shimmer. A click on the background blends each pebble from its point on the first word to its point on the second.

The original code runs almost unchanged. One real bug needed fixing: the pebble radius was computed before its inputs were set, which produced invalid values that current browsers report as errors. We also added keyboard control, a short hint, and scaling so the demo fits small windows and the gallery frame.

This note was newly written for the reconstruction. Read the original post in the Internet Archive.

Topics: Animation, Interactive