/sierpinski-triangles

Uses recursion to draw fractal Sierpinski triangles on HTML5 canvas

Primary LanguageJavaScript

Sierpinski

The project is to recursively draw Sierpinski triangles on HTML5 canvas.

I created this mini-site to practice Javascript. Skills practiced were Javascript, JQuery and HTML5 canvas and recursion.

The site uses a JQuery slider to get the desired complexity level for the Sierpinski Triangle, from 1 (just one equilateral triangle) to nine levels deep. A recursive function then draws the fractal pattern. The base case is a single equilateral triangle, and the function calls itself to draw more triangles within these triangles.

The Sierpinski Triangle is displayed using HTML5 canvas.

The site is mobile-friendly, using JQuery to resize the triangle and other elements so that the screen, however big, is filled with one centered Sierpinski triangle.