Diffusion-Limited Aggregation
First appeared 1981 · Thomas Witten, Leonard Sander — Diffusion-limited aggregation — Witten & Sander (1981). · timeline ↗
inventor-coined Name · coined by Thomas Witten, Leonard Sander (1981) — Descriptive name coined by its inventors: Witten & Sander titled their 1981 work "diffusion-limited aggregation".
In one line A growth process in which randomly walking particles stick on contact with a growing cluster, producing fractal, branching dendritic patterns (like frost, coral, or mineral deposits).
The code
The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.
dla/index.html
const SEED = Math.floor(Math.random()*1e9);
// Diffusion-Limited Aggregation on a square lattice. A single seed sits at
// the centre; random walkers spawn on a circle just outside the cluster and
// stick the moment they touch it. The build accumulates frame by frame, so
// the canvas is never cleared after setup.
const G = 200; // lattice resolution
const MAX = 8000; // particles before stopping
let occ; // occupancy grid (0 = empty)
let s, cell, cx, cy;
let R = 3; // current cluster radius, in cells
let attached = 1;
function idx(x, y) { return y * G + x; }
function setup() {
randomSeed(SEED);
s = Math.min(windowWidth, windowHeight);
createCanvas(s, s);
background(8, 8, 12);
pixelDensity(1);
noStroke();
colorMode(HSB, 360, 100, 100);
cell = s / G;
cx = G >> 1;
cy = G >> 1;
occ = new Uint8Array(G * G);
occ[idx(cx, cy)] = 1; // central seed
}
function draw() {
const WALKERS = 300;
for (let n = 0; n < WALKERS && attached < MAX; n++) {
const spawnR = Math.min(G * 0.49, R + 5);
const a = random(TWO_PI);
let x = Math.round(cx + spawnR * Math.cos(a));
let y = Math.round(cy + spawnR * Math.sin(a));
const killR = spawnR + 8;
const killR2 = killR * killR;
for (let step = 0; step < 4000; step++) {
const d = Math.floor(random(4));
if (d === 0) x++; else if (d === 1) x--; else if (d === 2) y++; else y--;
if (x < 1 || y < 1 || x >= G - 1 || y >= G - 1) break; // off lattice
const dx = x - cx, dy = y - cy;
if (dx * dx + dy * dy > killR2) break; // wandered off
if (occ[idx(x + 1, y)] || occ[idx(x - 1, y)] ||
occ[idx(x, y + 1)] || occ[idx(x, y - 1)]) {
occ[idx(x, y)] = 1;
attached++;
const r = Math.sqrt(dx * dx + dy * dy);
if (r + 2 > R) R = r + 2;
// hue ramps with distance from the seed: warm core → cool tips
const t = Math.min(1, r / (G * 0.5));
fill((30 + t * 260) % 360, 70, 100);
rect(x * cell, y * cell, cell + 0.6, cell + 0.6);
break;
}
}
}
if (attached >= MAX) noLoop();
}How it works
Start with one or more seed particles fixed as the cluster. Then repeat: 1. Release a particle from far away (often the edge of the domain or a circle around the cluster). 2. Let it random-walk (Brownian motion) step by step. 3. When it moves adjacent to (touches) any cluster particle, freeze it there — it becomes part of the cluster. 4. If it wanders too far, discard it and release a new one. Because tips of the cluster are reached first by incoming walkers, they shield the interior, so growth concentrates at extremities — yielding the characteristic self-similar, fractal dendrites (fractal dimension ≈ 1.71 in 2D).
Parameters
particleCount: number — Number of walkers released to aggregate onto the cluster.stepSize: number — Distance a walker moves per random-walk step.stickiness: number — Probability a walker sticks on contact with the existing cluster.seedCount: number — Number of fixed seed points the cluster grows from.
Lineage
Frequently combined with
- Particle System · 2 works
- Bezier / Catmull-Rom Splines · 1 work
- Geometric / Hexagonal Tiling · 1 work
- Flow Field / Vector Field · 1 work
Works using this algorithm (3)
Last updated 2026-07-16