Created
September 29, 2013 16:53
-
-
Save NYKevin/6754239 to your computer and use it in GitHub Desktop.
Branching spiral
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
#!/usr/bin/python3 | |
import turtle | |
import math | |
MIN_LENGTH = 2 | |
#FACTOR = (3/2) + math.sqrt(5)/2 | |
FACTOR = 2 | |
def fractal(length): | |
if length < MIN_LENGTH: | |
return | |
turtle.forward(length) | |
turtle.right(90) | |
turtle.forward(length) | |
turtle.right(90) | |
fractal(length/FACTOR) | |
turtle.right(90) | |
turtle.forward(length/2) | |
turtle.right(90) | |
fractal(length/FACTOR) | |
turtle.left(90) | |
turtle.forward(length/2) | |
turtle.left(90) | |
turtle.forward(length/2) | |
turtle.right(90) | |
fractal(length/FACTOR) | |
turtle.left(90) | |
turtle.forward(length/2) | |
turtle.left(180) | |
if __name__ == '__main__': | |
turtle.speed(10) | |
turtle.left(90) | |
fractal(100) | |
while True: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment