Feature Library

Sand-pour charts

2.10 GPU · 0.23 CPU ms
A still of the Sand-pour charts demo
Still
The live demo starts when it’s in view.Drag a glass sideways to tip it · arrows choose, Shift + arrow tips, Space taps · Months or Quarters · Table

Charts made of falling sand: page elements become glasses that fill with real grains to each value, the brim at the plan and the surplus heaped over it, in…

What it costs a frame

2.10 ms
0.23 ms
GPU
2.10 ms
CPU, median
0.23 ms
CPU, 95th pct
0.35 ms
Draw calls
0
Weight
Heavy

Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 1.73–2.19, CPU 0.23–0.28 ms). What ran: Twelve glasses and the hourglass on a 2 px grid (about 540 × 290 cells at 1920 × 1080 with the dock). Measured while busy: every 2.5 s a glass is tipped in turn and every fourth time all pour again, so most frames step the automaton (16 to 18 Margolus steps with count and decide) and draw; at rest a frame costs nothing. Timed with its own timestamp queries. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool2.100.230.35
apple · Apple A19 Proin a browser tab · 16 November 20263.550.180.30
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20262.290.410.72

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

How steadily it runs on Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258V · in a browser tab

Typical frame ?
16.65 ms
1% low ?
51 fps
Varies by ?
±0.50 ms
All metricsIntel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258V · in a browser tab
p50p95p9916.05 ms19.60 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
16.65 ms
p95 ?
17.40 ms
p99 ?
17.91 ms
Slowest ?
23.23 ms
Mean ?
16.71 ms
Standard deviation ?
0.50 ms
1% low ?
51 fps
0.1% low ?
43 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 0.7 / 1.3 ms

Input

No input during this run. A browser-tab run plays none.

Memory

JavaScript heap ?
89.4 → 85.7 MB
Growth ?
-3.63 MB

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
NothingNo other packages

What it’s for

  1. A showpiece bar chart against a plan or target
  2. Stacked parts of a value as layers of sand
  3. Progress to a goal as an hourglass
  4. A dashboard figure people can play with
  5. Surplus and shortfall made physical
  6. Falling sand in any container shape over a page

Pitfalls, in brief

  1. A grain is a cell: the sand counts exactly, but a glass holds only as many grains as it has cells inside. glassGeometry counts them as the GPU rasterises them; size values against that capacity (grainsFor), never against the element’s pixels.
  2. Random rain doesn’t lie level: the automaton only flattens slopes steeper than 45°, so random bumps grow into slopes it never removes.
  3. A band one cell thick (a drain along a floor) can fall between cell centres and hold no cells at all, depending on where the box lands; then that glass never empties.
  4. Grains don’t follow a glass that moves: when an element moves or the canvas is resized, everything is emptied and poured again (at once, out of sight, after the first layout).
  5. A value over the capacity heaps above the brim, at most a cone as tall as half the glass is wide; the rest spills down the outside.
10 more in brief
  1. Lean a glass only into the gap beside it (leanLimit, 80% of the way to its neighbour).
  2. Without carrying the sand, a leaned glass slides under its own heap and spills on the wrong side.
  3. Rest only on what the GPU says, and only after two quiet reports taken after the last change: the readback is copied only when the last one has been mapped, so it is a frame or two late.
  4. An hourglass’s upper bulb never fills to its nominal grains: the heap under its spout blocks it first.
  5. Shelves go in the shape list before the glasses, and a shelf’s sink never replaces a wall: otherwise the sink row under a glass’s floor drains it.
  6. Changing the colour layers of a glass that is already full empties it and pours again: colours are given out by the order grains leave the spout, so only more of the top layer can simply be poured on.
  7. Several frames sent before one submit share the last uniform written (writeBuffer is ordered by submits): a settle sends its sixteen short frames as sixteen submits.
  8. A WebGPU device can be lost (a driver reset, a sleeping laptop, another tab’s crash).
  9. Reduced motion: pours, refills and a glass righting itself settle at full speed without being drawn, and the finished picture is shown.
  10. The canvas covers the elements and takes no pointer (pointer-events: none): input goes to the elements under it, so the glasses stay real, focusable, labelled page elements.
15 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

Tommaso Toffoli & Norman Margolus, Cellular Automata Machines (MIT Press, 1987): The Margolus neighbourhood: 2 × 2 blocks on offsets that alternate each step, so every rule is local, conserving and free of races on the GPU.

Mark Jarzynski & Marc Olano, Hash Functions for GPU Rendering (2020): The PCG hash behind every grain’s random choices, its shade and its glint.

Alan W. Paeth, A Fast Algorithm for General Raster Rotation (Graphics Interface, 1986): The idea behind the carry: a shear moves whole rows by whole cells, so it permutes them and loses nothing.

WAI-ARIA Authoring Practices Guide (W3C): The listbox pattern for the glasses (one Tab stop, arrows choose) and the radio group for the data switch.

falling sandcellular automatonmargolusgranularchartsbar chartstackedplan vs actualhourglassprogressdom + gpudrag to tipcomputeraw webgpuwgslatomicsrests when stilltimestamp queriesreduced motionno dependencies

Near it in the frame