Commit a74e4af4 by BellCodeEditor

save project

parent a075876f
Showing with 30 additions and 4 deletions
import turtle
import turtle as p
import random
p.speed(0)
def tree(n):
if n>=0:
if n<=12:
color_l=['snow','lightcoral']
color=random.choice(color_l)
p.color(color)
p.pensize(n/3)
else:
p.pensize(n/10)
p.color('sienna')
jiao=random.randint(0,30)
cang=random.randint(1,15)
p.fd(n)
p.rt(jiao)
tree(n-cang)
p.lt(jiao*2)
tree(n-cang)
p.rt(jiao)
p.up()
p.bk(n)
p.down()
pen = turtle.Turtle()
pen = p
pen.color('sienna')
# 画布大小
w = turtle.Screen()
w = p
w.bgcolor('wheat') # wheat小麦
# 移动到起点
......@@ -12,4 +37,5 @@ pen.up()
pen.backward(150) # 后退
pen.down()
turtle.done()
tree(60)
p.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