Last active
August 29, 2015 14:19
-
-
Save adusak/df72f78daf355f493491 to your computer and use it in GitHub Desktop.
Triangle fractal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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