~/projects/pixel-fireworks.md
Pixel fireworks
A pixel-art fireworks maker that lives on this site. Pick colours, a shape and a size, then click the sky.
Choose a few colours, a shape (peony, ring, heart, star, willow, palm, crossette, saturn, spiral or strobe) and a size, then click anywhere in the night sky. A rocket climbs to where you clicked and bursts there. Hold the mouse down to keep firing, or press “auto show” and let it run. The show is paced like a real display: quiet stretches of single big shells, builds that speed up, fans of matching shells across the sky and rapid barrages, ending on a finale and a short dark pause before it starts again.
How it works
- Pixels on a grid. Every star is drawn into a small buffer at a third of the screen’s resolution and scaled up with hard edges. Stars start white-hot, settle into their colour and fade out in quarter steps, like pixel-art shading.
- Glow as its own layer. Two shrunken copies of the fireworks sit under the crisp pixels, blurred by different amounts, so each pixel gets a soft halo without losing its edges. Every layer is blended with
screen, so where colours overlap they get brighter. - Shapes that hold together. All the stars in one burst share the same drag and gravity, so a heart or a star grows and falls as one piece and keeps its outline.
- A dithered sky. The gradient and skyline use ordered dithering, and the stars twinkle in three steps.
- Optional sound. Every firework is heard in stages, all made with Web Audio: a mortar thump and rising hiss as it lifts, the boom, then a tail that depends on the shape (a willow sizzles, a palm whooshes, a strobe buzzes, a crossette bursts a second time as its stars split, glitter crackles). A compressor and a little ducking keep a busy finale from getting harsh. Off by default.