Data & layoutFoam treemap
A treemap made of soap foam, where every bubble’s area is exactly its share.
What it costs a frame
- GPU
- 4.73 ms
- CPU, median
- 0.33 ms
- CPU, 95th pct
- 0.65 ms
- Draw calls
- 0
- Weight
- Heavy
Measured 14 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 4.63–4.75, CPU 0.29–0.38 ms). What ran: Plays the ten years on a loop, so the solver re-packs every frame (twelve bubbles and the panel as a rigid box, 240 grid rows, 4 iterations a frame) and the foam is redrawn with its films flowing; GPU time from its own timestamp queries. Phones: tiers are being measured next.
| Machine | GPU ms | CPU ms | CPU p95 |
|---|---|---|---|
| RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool | 4.73 | 0.33 | 0.65 |
| apple · Apple A19 Proin a browser tab · 16 November 2026 | 10.5 | 0.72 | 1.20 |
| Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026 | 12.8 | 0.49 | 0.96 |
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.
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
- Market shares, budgets or portfolios as one shape whose parts are exactly their sizes
- A treemap that keeps each item in its place over time, so change reads as growth, not as a shuffle
- What-ifs you do with your hands: grow a share, merge two, take one out, and see the rest yield
- A page where text and panels are part of the picture and the data packs round them
- A striking, calm hero or dashboard backdrop that is still a true chart
Pitfalls, in brief
- Keep each thing in one slot.
- A slot that goes from nothing to a share is born: the solver blows a tiny bubble at its home and lets it grow.
- Areas are exact on the grid, not to the pixel: the 240-row grid puts each bubble within about 0.1 point of its share, and a bubble smaller than a few grid cells cannot be held exactly.
- Homes inside a rigid box are pushed out past the nearest box edge with room beyond it.
- The true pole is packed into one 32-bit atomic: 14 bits of distance over 18 of sample index.
9 more in brief
- The read-back is a frame or two behind.
- Solver iterations are even: the state ping-pongs between two buffers and the draw reads the first.
- A foam takes a while to stop: after the areas are right, the sites creep toward their centroids and homes for several seconds (Lloyd relaxation is slow at the end).
- A canvas that has given out a webgpu context cannot give a 2d one.
- A device lost later (a driver reset, a laptop waking) stops the engine: step() returns false from then on.
- A cancelled pointer (pointercancel: the browser took the gesture) is not a drop: the demo forgets the press instead of merging or moving the bubble.
- The Canvas 2D tier keeps under about 3 ms a frame at 1072 × 576 by doing less, not by doing it faster: a 40-row grid and one solver iteration, the solve and the draw on alternate frames, the picture at a fifth of the size (the browser scales the canvas up), its own field that looks only at the three nearest cells, and tiles that no wall crosses filled from their corners.
- The films are the cost, not the solver: every pixel of the box works out the foam’s field over every cell three times (twice more for the dome’s slope), stirs the film with a dozen noise lookups and sums twelve wavelengths.
- The foam is a picture: keep its numbers in the DOM too (a ranked list or a table), with the changes said once in a live region.
Where it comes from
From HaTac. Fully custom code.
Aurenhammer, Power diagrams: properties, algorithms and applications (SIAM J. Computing, 1987): The cells are a power diagram (a weighted Voronoi diagram), whose weights set the areas.
Nocaj & Brandes, Computing Voronoi treemaps: faster, simpler, and resolution-independent (EuroVis 2012): Area-exact weighted Voronoi treemaps by adjusting weights and moving sites to centroids; here done on a GPU grid with a Newton step on each weight.
Lloyd, Least squares quantization in PCM (1982): Sites relaxing toward their cells’ centroids.
Plateau’s laws and the Young–Laplace equation: Three films meeting at 120° in concave liquid borders, and walls bent by the pressure difference of bubbles of different size.
Chris Wyman, Peter-Pike Sloan & Peter Shirley, Simple Analytic Approximations to the CIE XYZ Color Matching Functions (2013): Through the thin-film entry’s functions (film.ts).
Mark Jarzynski & Marc Olano, Hash Functions for GPU Rendering (2020): PCG3D behind the films’ flow noise and the pop’s droplets.


