Substrate

別名: crack propagation、perpendicular line growth

初出 2003 · Jared Tarbell — Popularized by Jared Tarbell's "Substrate" (2003), an open-source Processing sketch published at complexification.net. · 年表 ↗

発明者による命名 名称 · 命名 Jared Tarbell (2003) — 作者が自身の 2003 年作品を「Substrate」と命名し、技法名がその作品名を継いだ。

ひとことで 平面上を進む線が、自分自身に対して垂直な新しい線を生み出していくエージェント的な成長手法。各線は他の線に衝突するまで進んで停止し、結晶や亀裂、都市地図のような密な網目を生み出す。

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

コード

上のデモの実際のスケッチ(サンドボックスで再現可能)。これで全部です。

substrate/index.html
// A re-implementation after Jared Tarbell's Substrate crack-propagation (2003) —
// not the original Processing work. Lines ("cracks") advance until they hit
// another and stop; a stopped crack seeds a new one perpendicular to an existing
// line. Constants are a plausible reconstruction.
const SEED = Math.floor(Math.random() * 1e9);
const EMPTY = -1;
let W, H, grid, cracks, made, MAX;

function seedCrack() {
  for (let t = 0; t < 2000; t++) {
    const px = Math.floor(Math.random() * W), py = Math.floor(Math.random() * H);
    if (grid[py * W + px] !== EMPTY) {
      let a = grid[py * W + px] + (Math.random() < 0.5 ? 90 : -90) + (Math.random() - 0.5) * 4;
      cracks.push({ x: px + 0.61, y: py + 0.61, a: (a * Math.PI) / 180 });
      return;
    }
  }
  cracks.push({ x: Math.random() * W, y: Math.random() * H, a: Math.random() * Math.PI * 2 });
}

function setup() {
  randomSeed(SEED);
  const s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  background('#f4f1ea');
  W = width; H = height;
  grid = new Int16Array(W * H).fill(EMPTY);
  MAX = Math.floor((W + H) * 0.9);
  cracks = []; made = 0;
  for (let i = 0; i < 3; i++) {                       // initial seeds
    const x = Math.floor(Math.random() * W), y = Math.floor(Math.random() * H);
    grid[y * W + x] = Math.floor(Math.random() * 360);
    cracks.push({ x, y, a: (grid[y * W + x] * Math.PI) / 180 });
    made++;
  }
  stroke(20, 55);
  strokeWeight(1);
}

function draw() {
  for (let step = 0; step < 180; step++) {
    for (let i = cracks.length - 1; i >= 0; i--) {
      const c = cracks[i];
      const nx = c.x + Math.cos(c.a), ny = c.y + Math.sin(c.a);
      const gx = Math.floor(nx), gy = Math.floor(ny);
      if (gx < 0 || gy < 0 || gx >= W || gy >= H) {
        cracks.splice(i, 1); if (made < MAX) { seedCrack(); made++; } continue;
      }
      const gi = gy * W + gx;
      if (grid[gi] === EMPTY) {
        grid[gi] = ((Math.round((c.a * 180) / Math.PI)) % 360 + 360) % 360;
        point(nx, ny);
        c.x = nx; c.y = ny;
      } else {                                          // collision → stop, spawn perpendicular
        cracks.splice(i, 1); if (made < MAX) { seedCrack(); made++; }
      }
    }
  }
  if (cracks.length === 0) noLoop();
}

デモのソースを開く ↗

仕組み

位置と向きを持つ「亀裂(線)」の集合を管理し、各ステップで線を一歩進めて描画、他の線や画面端に衝突したら停止、既存線上の点から垂直(±90°)方向に新しい線を生成する、を繰り返す。垂直分岐の規則が直交的な破断パターンを生む。

パラメータ

系譜

先行例
Jared Tarbell
関連
Diffusion-Limited Aggregation、Physarum (Slime-Mould Agents)、Reaction-Diffusion

このアルゴリズムを使う作品 (1)

Substrate
jared-tarbell

最終更新 2026-07-16