Skip to content

Instantly share code, notes, and snippets.

@NYKevin
Created September 29, 2013 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NYKevin/6754239 to your computer and use it in GitHub Desktop.
Save NYKevin/6754239 to your computer and use it in GitHub Desktop.
Branching spiral
#!/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