Skip to main content
100%

Fork of Sierpinski Triangle

✓ Published0🌍 Public
Ppkdvalis
Last edited Nov 28, 2023
Created on Nov 28, 2023

This interactive fractal displays a Sierpinski triangle that divides into recursively smaller subtriangles on an HTML5 Canvas. The branching depth changes dynamically based on mouse position, ranging from zero to ten subdivisions. The code uses the Canvas API’s `getContext` and `fill` methods, with `devicePixelRatio` to ensure sharp rendering on high-resolution displays. Moving the mouse horizontally triggers a `mousemove` event, recalculating depth and redrawing the triangle with `clearRect` and recursive function calls.

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