Skip to main content
Public

Share visualization

Loading preview…

Fork of Sierpinski Triangle

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Fork of Sierpinski Triangle

0
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.

Comments

Sign in to join the discussion.

MIT Licensed