| 66 | turtle.pendown() |
| 67 | |
| 68 | def drawTree(x, y, direction, seed): |
| 69 | global LEFT_ANGLE, RIGHT_ANGLE, LEFT_DECREASE, RIGHT_DECREASE |
| 70 | |
| 71 | # Go to the starting point: |
| 72 | turtle.penup() |
| 73 | turtle.goto(x, y) |
| 74 | turtle.setheading(direction) |
| 75 | turtle.pendown() |
| 76 | |
| 77 | # Try changing these values and looking at the results: |
| 78 | random.seed(seed) |
| 79 | LEFT_ANGLE = random.randint(10, 30) |
| 80 | RIGHT_ANGLE = random.randint(10, 30) |
| 81 | LEFT_DECREASE = random.randint( 6, 15) |
| 82 | RIGHT_DECREASE = random.randint( 6, 15) |
| 83 | START_SIZE = random.randint(80, 120) |
| 84 | |
| 85 | # Draw the tree: |
| 86 | drawBranch(x, y, direction, START_SIZE) |
| 87 | turtle.update() # Finish drawing the screen. |
| 88 | |
| 89 | |
| 90 | try: |