Skip to content

Instantly share code, notes, and snippets.

@adusak
Last active August 29, 2015 14:19
Show Gist options
  • Save adusak/df72f78daf355f493491 to your computer and use it in GitHub Desktop.
Save adusak/df72f78daf355f493491 to your computer and use it in GitHub Desktop.
Triangle fractal
from math import sin, radians
from python.common.Turtle import Turtle
def triangles(depth=20, size=200):
t = Turtle()
step = (size * sin(radians(30))) / depth
print(step)
for i in range(depth):
length = size - (i * (step / sin(radians(30))))
for _ in range(3):
t.forward(length)
t.right(360 / 3)
t.penup()
t.right(30)
t.forward(step)
t.left(30)
t.pendown()
t.export("triangles")
triangles(30, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment