Last active
August 29, 2015 14:19
-
-
Save adusak/912bdcda6d0b9196dc72 to your computer and use it in GitHub Desktop.
Square 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 tan, radians, sqrt | |
| from python.common.Turtle import Turtle | |
| def squares(depth=50, angle=86, size=500): | |
| t = Turtle() | |
| length = size | |
| for i in range(depth): | |
| for _ in range(4): | |
| t.forward(length) | |
| t.right(90) | |
| movebit = length * tan(radians(angle)) / (1 + tan(radians(angle))) | |
| length = sqrt((length - movebit) ** 2 + movebit ** 2) | |
| t.forward(movebit) | |
| t.right(angle) | |
| t.export("squares") | |
| squares(angle=70, size=900) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment