Skip to main content
100%

Sierpinski Triangle

✓ Published2🌍 Public
CCurran Kelleher
Last edited Nov 7, 2023
Created on Oct 6, 2021
Forked from Tree Fractal

This interactive Sierpinski triangle fractal renders recursively to a canvas, with its recursion depth controlled by the mouse’s horizontal position. The visualization shows how a geometric fractal pattern changes complexity as the mouse moves from left (shallow depth) to right (deeper recursion). The code uses the Canvas API’s `clearRect`, `beginPath`, and `fill` methods to draw triangles, and scales the canvas dimensions by `window.devicePixelRatio` for high-resolution displays. The fractal is generated from a fixed initial triangle with depth up to 10 based on mouse X position.

AI-generated description

Interactive tree fractal with Canvas.

Move the mouse to change the branching!

Draws from HTML5 Examples.

Extended to use high resolution Canvas for high pixel density displays.

MIT Licensed

Similar vizzes