Particles & Physics
Sandfall Hourglass
Amber sand grains fall through a cellular-automaton hourglass cavity, piling realistically at the base; auto-flips when drained, click reverses gravity.
canvasheavy complexitymoderate motionclick
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
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)
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
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.