Scatter a handful of points on a canvas, and two of the most useful structures in generative art fall directly out of their arrangement: a Voronoi diagram, which carves the whole plane into cells, one per point, where every pixel in a cell is closer to that point than to any other; and a Delaunay triangulation, which connects the same points into triangles chosen so that no other point ends up inside any triangle’s circumcircle. The two aren’t just thematically related. They’re mathematical duals: compute one and you can derive the other directly, which is exactly why most libraries compute them together rather than separately.
Why these two keep showing up together
A Voronoi diagram answers “which point owns this region of space.” A Delaunay triangulation answers “which points are each other’s natural neighbors.” Visually, a Voronoi cell’s edges are perpendicular to the Delaunay edges connecting the two points that cell is split between, which is the geometric fact underlying the duality. In practice, this means an organic cracked-glass or cell-membrane texture (Voronoi) and a smooth, non-overlapping triangular mesh over a scattered point set (Delaunay) are two visual styles generated from the exact same underlying computation, just read differently.
The core algorithm idea
Both structures are usually built with some version of Fortune’s algorithm (for Voronoi, sweeping a line across the plane and tracking a growing set of parabolic arcs) or an incremental Delaunay construction (adding points one at a time and locally re-triangulating around each new one). You don’t need to implement either from scratch to use them well; nearly every creative-coding environment has a library that computes both from a point set in a handful of lines.
In p5.js, the d3-delaunay library (yes, originally built for D3.js, but it works standalone) takes an array of [x, y] points and returns both a delaunay object and a voronoi object from one call:
import { Delaunay } from "d3-delaunay";
let points = [[100, 100], [300, 150], [200, 300], [400, 250]];
let delaunay = Delaunay.from(points);
let voronoi = delaunay.voronoi([0, 0, width, height]);
function draw() {
background(255);
for (let i = 0; i < points.length; i++) {
let cell = voronoi.cellPolygon(i);
beginShape();
for (let pt of cell) vertex(pt[0], pt[1]);
endShape(CLOSE);
}
}
In Python, scipy.spatial ships both Voronoi and Delaunay as ready-made classes built on the same underlying Qhull library, so the same point array produces both structures without pulling in a separate dependency.
In Processing (Java), there’s no built-in equivalent, but the mesh or a ported d3-delaunay-style library covers the same ground; several creative coders have also hand-ported Fortune’s algorithm directly into Processing sketches, which is a reasonable weekend project if you want to actually understand the sweep-line mechanics rather than just call a library.
Where this shows up in practice
Voronoi cells, slightly relaxed with Lloyd’s algorithm (repeatedly moving each point to its cell’s centroid and recomputing), produce the evenly-spaced, organic cell patterns behind a lot of procedural texture work, stippling, and simulated biological growth. Delaunay triangulation, meanwhile, is the standard first step in turning a scattered point cloud into a usable surface mesh, which is why it shows up constantly in terrain generation and low-poly art styles, not just in pure 2D graphic work.