MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / drawTree

Function drawTree

src/gamesbyexample/fractalnonuniformtree.py:68–87  ·  view source on GitHub ↗
(x, y, direction, seed)

Source from the content-addressed store, hash-verified

66 turtle.pendown()
67
68def 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
90try:

Callers 1

mainFunction · 0.85

Calls 1

drawBranchFunction · 0.70

Tested by

no test coverage detected