∞ forever components

Particles & Physics

Sandfall Hourglass

Amber sand grains fall through a cellular-automaton hourglass cavity, piling realistically at the base; initial automatic flips stop after first input; canvas click reverses gravity and lets grains settle.

canvasheavy complexitymoderate motionclickmobile-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

Timers, loading screens, meditative ambient displays, or any context needing a satisfying physics loop with no user friction.

When not to

Contexts requiring legible overlaid text or light backgrounds — background and palette are hardcoded dark amber. Low-end devices may struggle with the per-frame grid scan.

Working with an AI agent

Every component ships agent-ready metadata. An example instruction for this one:

Change the sand palette to cool blues by replacing PAL with ['#0d1b2a','#1a3a5c','#1e5f8a','#2980b9','#5dade2','#aed6f1'] and set background to #0a0f14. 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

  • sand color palette (PAL array)
  • grain size divisor (S/110)
  • hourglass neck width (COLS*0.05)
  • hourglass bulge width (COLS*0.40)
  • simulation tick rate (acc>=33)
  • auto-flip drain threshold (drained<2)
  • theme tokens (:root dark defaults + [data-theme=light] overrides)

Keep intact

  • pre-baked bg canvas (bakeBg) — critical for per-frame perf
  • visibilitychange pause/resume
  • prefers-reduced-motion static fallback (900 step fast-forward)
  • IIFE wrapper
  • 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

  • Per-frame full grid scan is O(COLS*ROWS) — heavy on large viewports with small cell sizes
  • Hourglass shape is purely rectangular mask math — cannot produce curved glass silhouette
  • pointermove kick only adds extra simulation steps, not a true pointer interaction
  • State remains local to each mounted instance; format/theme remount preserves takeover, not component values.

sandcellular-automatonphysicshourglassparticlescanvasgenerative

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.