Commit 995e1507 by BellCodeEditor

save project

parent 316004e3
Showing with 25 additions and 12 deletions
import turtle
import random
t = turtle.Turtle()
t.color('sienna')
t.hideturtle()
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
......@@ -13,17 +14,29 @@ t.backward(150) # 后退
t.down()
def tree(n):
if n>=50:
t.pensize(100)
t.speed(-1)
if n>= 0:
if n<=12:
t.speed(100)
color_list = ['snow','lightcoral']
color = random.choice(color_list)
t.color(color)
t.pensize(n / 3)
else:
t.color('sienna')
t.pensize(n / 10)
t.forward(n)
t.right(30)
tree(n-50)
t.left(60)
tree(n-50)
t.right(30)
angle = random.random()
t.right(30*angle)
length = 1.5*random.random()
tree(n-10*length)
t.left(60*angle)
tree(n-10*length)
t.right(30*angle)
t.up()
t.backward(n)
t.down()
tree(100)
turtle.done()
\ No newline at end of file
tree(60)
turtle.done()
for i in range (5):
tree()
lt(72)
\ 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