28 October 2018, 14:22

sierpinski triangle

The Sierpinski Triangle is rather beautiful. I thought might be interesting to try and create it in code. Luckily I was able to find many others who had attempted the same thing. I did a little reading on what was involved and the steps are pretty straight forward:

  1. Start with an equilateral triangle and locate the midpoints of each of the sides of the triangle.
  2. Connect each of the midpoints with a line segment, and remove the triangle you just created.
  3. You now have three equilateral triangles within the original equilateral triangle. Repeat steps 1 and 2 for each of these triangles. This process can be continued indefinitely or until you choose to stop.

Here's my attempt:

See the Pen Sierpinski Triangle by Adam Harpur (@harps116) on CodePen.

← Starting ~ 2019
Gravitational Attraction →