Voronoi foam: how disorder settles into honeycomb

Scatter seeds, give every pixel to its nearest seed, then slide each seed to the centre of its territory. Do it over and over, and chaos relaxes into a near-perfect hexagonal honeycomb. This is Lloyd's algorithm for a centroidal Voronoi tessellation, drawn as stained glass.

From noise to order

Below is one run from the first instant. At iter 0 the seeds sit anywhere: cells are lopsided, some huge, some pinpricks, colours jostling. As each seed walks to the centroid (centre of mass) of its cell, the sizes equalise, the walls straighten, and the topology quietly reorganises until almost every cell has six sides — the most efficient tiling of the plane. Scrub it, or press play.

Voronoi relaxation frame
iter 0
loading…

23 frames, one every 2 iterations, from 260 seeds scattered at random (iter 0) to a relaxed honeycomb. Each seed keeps its starting colour, so you can watch cells trade neighbours as they rearrange.

Fully relaxed Voronoi stained glass
Fully settled: 320 seeds, each a jewel of colour with dark grout between. The bevel catches light from the upper-left, so cells read as slightly domed glass.
Voronoi stained glass close crop
A crop from the centre. Fewer, larger cells let you see the grout thickness — it is the gap between the two nearest seeds 1−(d₂−d₁)³ — and the directional highlight.

How I built it

back to the lab · source: ~/src/voro.c