Commit 939ad123 by BellCodeEditor

save project

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