Commit c37b52fe by BellCodeEditor

save project

parent 0409473a
Showing with 19 additions and 7 deletions
import turtle
import random
def tree(n):
if n >= 50:
if n >= 0:
if n <= 12:
color_list = ["snow", "lightcoral"]
color = random.choice(color_list)
pen.color(color)
pen.pensize(n/3)
else:
pen.color("sienna")
pen.pensize(n/10)
pen.forward(n)
pen.right(30)
tree(n-10)
pen.left(60)
tree(n-10)
pen.right(30)
angle = random.randint(0, 30)
length = random.randint(1, 15)
pen.right(angle)
tree(n-length)
pen.left(2*angle)
tree(n-length)
pen.right(angle)
pen.up()
pen.backward(n)
pen.down()
......@@ -24,7 +35,7 @@ pen.up()
pen.backward(150) # 后退
pen.down()
tree(100)
tree(60)
turtle.done()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment