Skip to content
Math Background Studioby GordonKit
Open Studio

Voronoi

Poisson-sampled points split the plane into Voronoi cells, evened out by Lloyd relaxation.

Open Voronoi in Studio

Voronoi background example

Scatter some points and give each one the territory that is closer to it than to any other point. The territories are Voronoi cells, and together they tile the plane like cracked mud, giraffe skin or a dragonfly wing.

How the maths works

sᵢ
Each seed claims the area closer to it than to any other seed. The centroid of the highlighted cell (open circle) is where its seed moves next; repeating this evens the cells out.
Formula
Voronoi cell
cell(sᵢ) = { p : |p − sᵢ| ≤ |p − sⱼ|, ∀ j }
Lloyd relaxation
sᵢ ← centroid(cell(sᵢ))

The border between two neighboring cells is the perpendicular bisector of the two points, so every cell is a convex polygon. The studio computes the cells from a Delaunay triangulation, their mathematical dual.

The points are placed with Poisson-disk sampling: no two may be closer than a set radius, which gives an even spread without looking like a grid.

Lloyd relaxation then moves each point to the centroid of its cell and recomputes the diagram. After a few rounds the cells become more uniform and hexagon-like, approaching a centroidal Voronoi tessellation.

Parameters

Cell density
About how many cells a 16:9 canvas holds. Cells keep their size on other ratios; only their number changes.
12 to 1500
Relaxation
Rounds of Lloyd relaxation. 0 keeps the raw sample; each round makes the cells more even.
0 to 5
Line width
Width of the cell outlines, relative to the short side of the canvas.
0.0005 to 0.02
Fill
Solid fills the cells, Outline draws only their borders, and Solid + outline does both.
Solid · Outline · Solid + outline
Cell shrink
Shrinks each cell toward its centroid, opening gaps that show the background like grout between tiles.
0 to 0.8
Colouring
Random colours each cell independently, By distance runs the palette outward from the centre, Cycle steps through the palette in sampling order.
Random · By distance · Cycle

Examples

Each example opens in the studio with these settings.

Using it as a background

A little cell shrink with a light background gives a stained-glass or mosaic look; outlines only give a clean technical pattern.

By distance puts one end of the palette in the centre, a natural spotlight for a title.