Skip to content

No.196 · Backgrounds

Dot Swarm

720 dots that sweep from one outline to the next — circle, star, Oman, heart, a V — scatter from the pointer and burst on a press.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Night

Build a Canvas 2D swarm of exactly 720 dots that morphs between outlines: a circle, a five-point star, the outline of Oman (from about 20 longitude/latitude points), a heart (the classic parametric curve) and a V. Every outline is resampled by arc length into three nested contours (scale 1, 0.72 and 0.44 with 360, 230 and 130 points — 720 in all), each centred on its centroid and sorted by angle around it, so the swarm reads as layered rings of distinct dots. Changing shape only changes each dot's home — dot i moves to point i of the new outline in the same layer — and because every layer is in angle order the swarm sweeps round into the new shape instead of crossing through itself. Homes are scaled to 36% of the smaller side. Physics per frame: the pointer pushes dots away within 18% of the smaller side with strength (1 − d/reach)²; then v = (v + (home − p)·0.05)·0.84 pulls each dot home on a damped spring. A press sends a shockwave from the press point — v += away·(1 − d/200)·30 within 200px — and moves to the next shape; with nobody touching it the shape also advances every 7 seconds. A moving dot is drawn as an ellipse stretched along its velocity (radius × s by radius ÷ √s, s = 1 + speed·0.18, capped at 4), so fast dots streak. All dots are filled in one path. On first view the dots arrive from a ring outside the frame. A mono caption names the shape (polite live region) next to a "Next shape" button. Selected variant — Night (night): Apply the night theme. Where the brief above gives no colour values for it, choose a restrained night palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Move through the swarm to part it; press to send a shockwave and move to the next shape, or use the Next shape button. Motion: Spring 0.05 with damping 0.84; shockwave 30 within 200px; shapes advance every 7s when idle; dots streak along their velocity. Accessibility: The canvas is role="img" with the current shape named; changes are announced politely and the Next shape button works from the keyboard. Reduced motion jumps straight to each outline with no physics. Responsive behavior: Scales the outline to the container and re-homes the dots on resize; dot size grows with the frame. Touch: Drag a finger through the dots to part them; tap for the shockwave and the next shape. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Move through the swarm to part it; press to send a shockwave and move to the next shape, or use the Next shape button.
Motion
Spring 0.05 with damping 0.84; shockwave 30 within 200px; shapes advance every 7s when idle; dots streak along their velocity.
Accessibility
The canvas is role="img" with the current shape named; changes are announced politely and the Next shape button works from the keyboard. Reduced motion jumps straight to each outline with no physics.
Responsive
Scales the outline to the container and re-homes the dots on resize; dot size grows with the frame.
On touch
Drag a finger through the dots to part them; tap for the shockwave and the next shape.