Sierpinski Triangle
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 descriptionInteractive 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.