SHARE
TWEET

CSH2012 LAB12 koch.py

calcpage Jun 1st, 2013 176 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. #koch.py     MrG     2013.0530
  3. import turtle
  4.  
  5. def flake(t, length, depth):
  6.     if depth==1:
  7.         t.fd(length)
  8.     else:
  9.         length/=3
  10.         flake(t,length,depth-1)
  11.         t.left(60)
  12.         flake(t,length,depth-1)
  13.         t.right(120)
  14.         flake(t,length,depth-1)
  15.         t.left(60)
  16.         flake(t,length,depth-1)
  17.  
  18. alex=turtle.Turtle()
  19. alex.pencolor('green')
  20. alex.pensize(2)
  21. alex.speed(0)
  22.  
  23. alex.pu()
  24. alex.backward(150)
  25. alex.left(90)
  26. alex.forward(250)
  27. alex.right(90)
  28. alex.pd()
  29.  
  30. level=5
  31. for i in range(6):
  32.     flake(alex,300,level)
  33.     alex.right(60)
  34.  
  35. turtle.mainloop()
RAW Paste Data
Top