∞ forever components

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 motionpointermobile-ready

Open on the canvas to copy the code → Free account · 3 copies a day · membership goes unlimited

Live demo — the real component, running in a sandbox. One self-contained HTML file, zero dependencies. Open it on the canvas →
1

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)
  • demo-v1 preview lifecycle: initialize demoEnabled from window.__foreverPreview and stop attract work on the window forever:interactive event; retain manual feedback, settling, cleanup and explicit sessions

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
  • State remains local to each mounted instance; format/theme remount preserves takeover, not component values.

boidsflockingparticlescanvassimulationpointerswarm

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. Initial automatic launches stop after first input; canvas clicks…
  • Confetti CannonOchre festival-paper palette: broad confetti rectangles fire from bottom corners, tumble and flip. First input stops automatic launches; a manual 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; initial figure-eight attract motion stops after first input; manual chain…
  • 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.