Commit 939ad123 by BellCodeEditor

save project

parent 0378ed03
Showing with 17 additions and 11 deletions
......@@ -9,19 +9,25 @@ pen.down() # wheat小麦
pen.seth(90)
# 移动到起点
def tree(n):
if n >= 50:
if n >= 0:
if n <=12:
color_list = ['snow','lightcoral']
color=random.choice(color_list)
pen.color(color)
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()
pen.right(30*angle)
length = 1.5*random.random()
tree(n-10*length)
pen.left(60*angle)
tree(n-10*length)
pen.right(30*angle)
pen.up()
pen.backward(n) # 后退
pen.down()
if c==1:
pen.color("snow")
else:
pen.color("lightcoral")
tree(100)
tree(60)
turtle.done()
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