Fractal / Recursive Subdivision

First appeared 1975 · Benoit Mandelbrot — Benoit Mandelbrot coined "fractal" (1975); "The Fractal Geometry of Nature", 1982. · timeline ↗

community / folk Name — Descriptive: "fractal" was coined by Benoit Mandelbrot (1975); "fractal recursion" is a descriptive label for recursive self-similar generation, not a coined algorithm name.

In one line A general technique that generates self-similar structure by applying a rule to a shape and then to its parts, repeatedly — Koch curves, the Sierpiński gasket, recursive rectangle splits (Mondrian-like), and branching trees.

Fractal / Recursive Subdivision · 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.

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

// Recursive subdivision: each square is probabilistically split into 4
// quadrants; leaves are filled with a depth-tinted colour. A self-similar
// Mondrian-meets-quadtree fractal.
function setup() {
  randomSeed(SEED);
  const s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  colorMode(HSB, 360, 100, 100);
  background(0, 0, 8);
  const baseHue = random(360);

  subdivide(0, 0, s, 0);

  function subdivide(x, y, size, depth) {
    const pSplit = Math.max(0, 0.92 - depth * 0.14);
    if (size > s * 0.02 && depth < 8 && random() < pSplit) {
      const h = size / 2;
      subdivide(x, y, h, depth + 1);
      subdivide(x + h, y, h, depth + 1);
      subdivide(x, y + h, h, depth + 1);
      subdivide(x + h, y + h, h, depth + 1);
    } else {
      const h = (baseHue + depth * 34) % 360;
      fill(h, 60, 30 + depth * 9);
      stroke(0, 0, 8);
      strokeWeight(s * 0.0015);
      const g = size * 0.04;
      rect(x + g, y + g, size - 2*g, size - 2*g, size * 0.06);
    }
  }
}

Open the demo source ↗

How it works

Define a base case and a recursive step that replaces a shape with smaller copies/parts of itself, then call it on each part: 1. If the recursion depth (or smallest size) limit is reached, draw the shape and return. 2. Otherwise transform the shape into N sub-parts (e.g. split a segment into the 4 pieces of the Koch curve; split a rectangle into 2–4 sub-rectangles; spawn child branches at an angle) and recurse into each. Because the same rule runs at every scale, detail appears at all magnifications (self-similarity). The branching factor, scale ratio and any randomness in the split control the look — from rigid Sierpiński triangles to organic trees.

Parameters

Lineage

Precedents
Benoit Mandelbrot
Related
L-System, Strange Attractor

Frequently combined with

Works using this algorithm (25)

a heart and a soul
roman-janajev
Corners
rafael-rozendaal
Cryptoblots
daim-aggott-honsch
Cyber Cities
pxlq
Divisions
michael-connolly
Dynamic Slices
pxlq
Exhibition: 3291
cryptobauhaus
Fabergé Fractals
tom-beddard
Flora NT
petar-milojevic
FOCUS
matto
Fractal
herbert-w-franke
Imposter Syndrome
ippsketch
Machine Comics
roni-block
Patchwork Saguaros
jake-rockland
Pieces of Me
r4v3n
Sheets
rudxane
SL/CE
stranger-in-the-q
Space Debris [m'aider]
whalestreet-x-pxlq
Space Debris [ravaged]
whalestreet-x-pxlq
Space Debris [warning]
whalestreet-x-pxlq
Thereidoscope
daim-aggott-honsch
Variant Plan
jeff-davis
Vol Libre
loren-carpenter
Window
jan-robert-leegte
Zabriskie Point
ken-musgrave

References

Last updated 2026-07-16