228

Penrose Subdivision

Infinite 5-fold aperiodic Penrose tiling generated through recursive deflation of Robinson golden triangles using phi = (1+sqrt(5))/2.

Playground
60 FPS Canvas 2D
Click + Drag to interact with field
</>

Full Executable Algorithm Code

// 016 - Penrose Subdivision (geometry)
// 1:1 Original algorithm engine source
function createPenroseSubdivision() {
  const GOLDEN_RATIO = (1 + Math.sqrt(5)) / 2;
  function drawTriangle(ctx, x1, y1, x2, y2, x3, y3, depth, type, time) {
    if (depth <= 0) {
      ctx.beginPath();
      ctx.moveTo(x1, y1);
      ctx.lineTo(x2, y2);
      ctx.lineTo(x3, y3);
      ctx.closePath();
      const hue = (type === 0 ? 190 : 280) + depth * 20 + time * 15;
      ctx.fillStyle = hsla(hue, 80, 50, 0.4);
      ctx.fill();
      ctx.strokeStyle = hsla(hue, 90, 70, 0.8);
      ctx.lineWidth = 0.9;
      ctx.stroke();
      return;
    }
    if (type === 0) {
      const p4x = x1 + (x2 - x1) / GOLDEN_RATIO;
      const p4y = y1 + (y2 - y1) / GOLDEN_RATIO;
      drawTriangle(ctx, x3, y3, p4x, p4y, x1, y1, depth - 1, 0, time);
      drawTriangle(ctx, p4x, p4y, x3, y3, x2, y2, depth - 1, 1, time);
    } else {
      const p4x = x2 + (x3 - x2) / GOLDEN_RATIO;
      const p4y = y2 + (y3 - y2) / GOLDEN_RATIO;
      const p5x = x2 + (x1 - x2) / GOLDEN_RATIO;
      const p5y = y2 + (y1 - y2) / GOLDEN_RATIO;
      drawTriangle(ctx, p4x, p4y, p5x, p5y, x2, y2, depth - 1, 1, time);
      drawTriangle(ctx, p5x, p5y, p4x, p4y, x1, y1, depth - 1, 0, time);
      drawTriangle(ctx, x3, y3, p4x, p4y, x1, y1, depth - 1, 1, time);
    }
  }
  return {
    setup() {
    },
    render(context, timeState, params) {
      const { ctx, width, height } = context;
      const t = timeState.time * Number(params.speed || 0.4);
      const depth = Math.min(5, Number(params.subdivisionDepth || 4));
      const radius = Math.min(width, height) * 0.44;
      ctx.fillStyle = "#08090d";
      ctx.fillRect(0, 0, width, height);
      const cx = width * 0.5;
      const cy = height * 0.5;
      const folds = 10;
      for (let i = 0; i < folds; i++) {
        const a1 = i / folds * Math.PI * 2 + t * 0.1;
        const a2 = (i + 1) / folds * Math.PI * 2 + t * 0.1;
        const x1 = cx + Math.cos(a1) * radius;
        const y1 = cy + Math.sin(a1) * radius;
        const x2 = cx + Math.cos(a2) * radius;
        const y2 = cy + Math.sin(a2) * radius;
        drawTriangle(ctx, cx, cy, x1, y1, x2, y2, depth, i % 2, t);
      }
    }
  };
}

// Default parameters from content metadata
const defaultParams = [
  {
    "key": "subdivisionDepth",
    "label": "Recursion Depth",
    "type": "range",
    "min": 2,
    "max": 5,
    "step": 1,
    "defaultValue": 4,
    "description": "Fractal deflation resolution"
  },
  {
    "key": "speed",
    "label": "Rotation Drift",
    "type": "range",
    "min": 0.1,
    "max": 1.5,
    "step": 0.05,
    "defaultValue": 0.4,
    "description": "Aperiodic rotation speed"
  }
];

if (!window.__art_instances) window.__art_instances = {};
if (!window.__art_instances['penrose-subdivision']) {
  const inst = typeof createPenroseSubdivision === 'function' ? createPenroseSubdivision() : null;
  if (inst && inst.setup) {
    inst.setup({ ctx, width, height, dpr: 1, aspectRatio: width / height }, defaultParams);
  }
  window.__art_instances['penrose-subdivision'] = inst;
}

const instance = window.__art_instances['penrose-subdivision'];
if (instance && instance.render) {
  instance.render(
    { ctx, width, height, dpr: 1, aspectRatio: width / height },
    { time, deltaTime: dt, frameCount: Math.floor(time * 60), fps: 60 },
    defaultParams
  );
}
Edit in Interactive Playground Zero Dependencies • Standalone Canvas 2D
ƒ

Mathematical Formulation

high
Analytical Equation
ϕ=1+52,p4=p1+p2p1ϕ\phi = \frac{1+\sqrt{5}}{2}, \quad \mathbf{p}_{4} = \mathbf{p}_1 + \frac{\mathbf{p}_2 - \mathbf{p}_1}{\phi}
Click to expand
Compact Formula
p4 = p1 + (p2 - p1) / φ, subdivide(RobinsonTriangle(depth - 1))

Mathematical Tags

#penrose #aperiodic #golden-ratio #fractal #tiling #geometry
Author: Math Art Core Target: 60 FPS

Export & Embed: Penrose Subdivision

4K PNG Snapshot

High-resolution single frame render

WebM Video (5s Loop)

60 FPS browser-captured stream

Standalone JS Script

Complete executable Canvas 2D algorithm

HTML Iframe Embed

<iframe src="https://art.fazleyrabbi.xyz/embed/penrose-subdivision" width="500" height="500" frameborder="0" loading="lazy"></iframe>
ESC
↑↓ Navigate Select
110 Mathematical Artworks
Made by Fazley Rabbi

Support the Project

Keep mathematical creative coding alive & open source

Or via Direct Payoneer ($0 Fee)
Payoneer Customer ID: $0 Fee Direct
24076084

💡 Payoneer app: Go to Pay → Pay to recipient → Enter ID 24076084.

Thank you for supporting generative mathematical animations! ✨