Voronoi Diagram

also: Dirichlet tessellation, Thiessen polygons

First appeared 1908 · Georgy Voronoy — Georgy Voronoy (1908); related Dirichlet tessellation, 1850. · timeline ↗

third-party / eponym Name — An eponym conferred by later mathematicians, not by Voronoy himself — a textbook Stigler's-law case: Dirichlet studied the same tessellation earlier (1850, hence "Dirichlet tessellation"), and the structures recur under many names. The "Voronoi" eponym honours Georgy Voronoy's 1908 treatment. Coiner and date of the name itself not established here (to be confirmed).

In one line A partition of the plane from a set of seed points (sites): every location is assigned to its nearest site, carving the plane into one convex cell per site. Used for cellular patterns and organic tilings.

Voronoi Diagram · Open in new tab ↗ · Motion begins only when you press Run.

The code

The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.

voronoi/index.html
const SEED = Math.floor(Math.random()*1e9);

function setup() {
  randomSeed(SEED);
  const s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  noStroke();

  // Brute-force per-pixel Voronoi for clarity (O(N·W·H)).
  // Use a small canvas + scale up to keep it fast.
  const W = 240;
  const cnv = createGraphics(W, W);
  cnv.pixelDensity(1);

  const N = 28;
  const sites = Array.from({ length: N }, () => ({
    x: random(W), y: random(W),
    c: [random(40, 230), random(40, 230), random(40, 230)],
  }));

  cnv.loadPixels();
  for (let y = 0; y < W; y++) {
    for (let x = 0; x < W; x++) {
      let best = 0, bestD = Infinity;
      for (let i = 0; i < N; i++) {
        const dx = x - sites[i].x;
        const dy = y - sites[i].y;
        const d = dx*dx + dy*dy;
        if (d < bestD) { bestD = d; best = i; }
      }
      const idx = 4 * (y * W + x);
      const c = sites[best].c;
      cnv.pixels[idx]   = c[0];
      cnv.pixels[idx+1] = c[1];
      cnv.pixels[idx+2] = c[2];
      cnv.pixels[idx+3] = 255;
    }
  }
  cnv.updatePixels();

  noSmooth();
  image(cnv, 0, 0, width, height);

  // Overlay site markers.
  fill(0); noStroke();
  const r = width / W;
  for (const p of sites) circle(p.x * r, p.y * r, width * 0.008);
}

Open the demo source ↗

How it works

Given a set of sites, the Voronoi cell of a site is the set of all points closer to it than to any other site; cell boundaries lie exactly halfway (perpendicular bisectors) between neighbouring sites, meeting at vertices equidistant from three or more sites. Ways to compute it: 1. Brute force: for each pixel, find the nearest site (simple, slow). 2. Fortune's sweepline algorithm: O(n log n) construction of the exact diagram. 3. As the dual of a Delaunay triangulation: connect circumcentres of adjacent Delaunay triangles. Weighting the distance metric (power/multiplicative) yields additively/ multiplicatively weighted variants.

Parameters

Lineage

Related
Delaunay Triangulation, Poisson Disk Sampling, Circle Packing, Polygon Mosaic

Frequently combined with

Works using this algorithm (9)

Autology
steganon
Cytographia
golan-levin
Ego Death
electralina
Gen 3
dca
Human Unreadable
operator
Lacunae
james-dalessandro
Low Tide
artem-verkhovskiy-x-andy-shaw
Material Violence
jeres
Metropolis
mpkoz

Last updated 2026-07-16