Skip to main content
100%

Fractals in D3 and Canvas: Sierpinski Gasket

✓ Published0🌍 Public
TThanaporn-sk
Last edited Mar 31, 2017
Created on Mar 31, 2017

This example visualizes the construction of a Sierpinski gasket, a fractal pattern, by iteratively layering scaled-down copies of a canvas. Each iteration creates a new canvas, scales its context by half, and draws three copies of the previous canvas into the corners, replacing the old one every second. The animation runs for 14 total iterations using D3 v4 to select elements and append canvases, while the drawing and scaling operations rely on the Canvas API’s `scale` and `drawImage` methods. The original canvas is filled green using `fillRect`, and each new canvas labels its iteration number with `fillText`.

AI-generated description

forked from <a href='http://bl.ocks.org/beemyfriend/'>beemyfriend</a>'s block: <a href='http://bl.ocks.org/beemyfriend/8bafcd8151a050b8028e76eb61acfc13'>Fractals in D3 and Canvas: Sierpinski Gasket</a>

mit Licensed

Similar vizzes