SHARE
TWEET

CSH2012 LAB12 tree.py

calcpage May 24th, 2013 188 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. #tree.py    MrG    2013.0521
  3. import random
  4. import turtle
  5.  
  6. def tree(branchLen,t,s):
  7.     if branchLen > 0:
  8.         t.pensize(s)
  9.         if branchLen==8:
  10.              t.color("darkgreen")
  11.         else:
  12.              t.color("brown")
  13.         t.forward(branchLen)
  14.         t.right(20)
  15.         tree(branchLen-8,t,s-1)
  16.         t.left(40)
  17.         tree(branchLen-8,t,s-1)
  18.         t.right(20)
  19.         t.backward(branchLen)
  20.         t.color("brown")
  21.  
  22. t = turtle.Turtle()
  23. t.left(90)
  24. t.up()
  25. t.backward(100)
  26. t.down()
  27. t.speed(100)
  28. tree(80,t,10)
  29. turtle.mainloop()
RAW Paste Data
Top