Vinnie Garcia

Customizable particle pulse ⚛

How it worksBack to the demo

Lines that turn into a circuit-like pattern

Turn off Auto Pulse and click or tap. A pulse starts at the center of the canvas, regardless of where you clicked. Turn off Random Direction Changes too and the pattern becomes straight lines in eight directions.

Turn the random changes back on and each particle can veer 45 degrees left or right. The old line stays behind as it moves, so many paths together look like branching circuitry. Nothing electrical is being simulated, and crossings don't act as junctions.

Particles/Pulse adds more particles, not more launch angles. The eight directions repeat, so some particles initially share a path. Random turns pull them apart later.

Pulse interval (ms) changes how often automatic pulses launch. It doesn't change travel speed. Color Range sets the central hue for new pulses, with a small random variation; particles already moving keep their color. Trail Fade chooses between gradually darkening old lines and clearing them on the next frame.

The trail does much of the work

Every particle moves five pixels per animation frame and draws a line from its old position to its new one. With random changes enabled, it has a five-percent chance per update of making a turn. Speed stays the same through the turn.

With trails on, a translucent black layer goes over the canvas each frame. Old marks get darker while new ones stay bright. Particles that leave the canvas are recycled for later pulses.

There are no child particles splitting off, and no collisions. The apparent branches come from overlapping trails. Both travel and turning depend on animation frames rather than a fixed physical clock. With the operating system's reduced-motion preference enabled, the normal continuous loop doesn't run, so the page may look still.

For particles that do bounce off each other, see the 3D collision experiment. The drawing here uses the paths and transparency described in the Canvas API tutorial.