Particles & Physics
Boids Flocking
Up to 60 lime-green triangular boids flock using alignment, cohesion, and separation rules; they flee the cursor on a dark canvas with motion-trail fade.
canvasheavy complexitymoderate motionpointer
Open on the canvas to copy the code → Free account · 3 copies a day · membership goes unlimited
Worth keeping?
Votes steer what gets built next — sign in to cast one, free to read
When to use it
Ambient hero backgrounds, generative art demos, or any dark-theme context needing organic crowd motion.
When not to
Light backgrounds (hardcoded dark fill). Low-end mobile — O(n²) neighbor loop scales poorly above ~60 boids.
Working with an AI agent
Every component ships agent-ready metadata. An example instruction for this one:
Change boid color to electric blue (set h to 200 and adjust hsl saturation), increase max speed from maxS=2.6 to 3.5, and raise boid count cap from 60 to 100. Theme: dark tokens live in :root, the light variant in :root[data-theme="light"]; ?theme=light or a {type:'forever:theme'} postMessage switches at runtime.
Safe to edit
- boid count cap (Math.min(60, ...))
- max speed (maxS=2.6)
- hue range (h: 90+Math.random()*60)
- flee radius from pointer (pd<90)
- trail fade opacity (rgba alpha 0.28)
- neighbor radius (R=34)
- theme tokens (:root dark defaults + [data-theme=light] overrides)
Keep intact
- DPR-aware canvas sizing
- visibilitychange pause/play
- prefers-reduced-motion guard (single static frame)
- toroidal wrap-around boundary
- theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)
Known limitations
- O(n²) neighbor search — scales poorly above ~80 boids on low-end devices
- No reduced-motion fallback beyond a single static step (boids still drawn but don't animate)
- Light re-theme via the [data-theme=light] token block; catalog bg/accent describe the dark default
More Particles & Physics components
- Gravity Dot RainMulticolored dots fall under gravity with motion trails, bounce off the floor, and scatter away from the cursor on a dark navy canvas.
- Firework BurstColorful glowing sparks burst radially, fall under gravity, and fade against a dark sky. Auto-launches bursts; click anywhere to add more.
- Confetti CannonColored rectangles fire from bottom corners in auto-cycling bursts, tumbling with gravity and flip animation. Click anywhere to trigger a cursor burst.
- Bouncing Balls7–14 glossy pastel balls bounce off walls and collide with elastic physics; cursor repels balls within a 70px radius.
- Spring ChainA 16-node spring chain whips and follows the cursor in a lime-to-gold gradient; drifts in a figure-eight pattern when idle.
- Cloth Wave GridAn 11x11 wireframe grid ripples like cloth via sine/cosine waves in cyan-to-violet hues; mesh nodes bulge away from the cursor on hover.