Skip to content

Instantly share code, notes, and snippets.

@cmaggard
Created July 24, 2010 01:58
Show Gist options
  • Save cmaggard/488308 to your computer and use it in GitHub Desktop.
Save cmaggard/488308 to your computer and use it in GitHub Desktop.
import math
import turtle
class MyTurtle(object):
def __init__(self):
self.turtle = turtle.Turtle()
self.complex = 1
self.screen = (self.turtle.window_width(), self.turtle.window_height())
self.size = 3*self.screen[1]/8
def draw(self, complex = 1, len = None):
if len is None:
len = self.size
for x in xrange(3):
self.line(complex, len)
self.turtle.left(120)
def line(self, complexity, len):
if complexity == 1:
self.turtle.fd(len)
self.turtle.left(120)
else:
self.line(complexity - 1, len/3)
self.turtle.right(60)
self.line(complexity - 1, len/3)
self.turtle.left(120)
self.line(complexity - 1, len/3)
self.turtle.right(60)
self.line(complexity - 1, len/3)
def reset(self):
self.turtle.clear()
if __name__ == "__main__":
turt = MyTurtle()
turt.draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment