Commit 2698d3ed by BellCodeEditor

save project

parent f14cd11c
Showing with 21 additions and 9 deletions
import turtle
import random
pen = turtle.Turtle()
pen.color('sienna')
pen.speed("fastest")
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
......@@ -9,25 +11,35 @@ w.bgcolor('wheat') # wheat小麦
# 移动到起点
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.backward(200) # 后退
pen.down()
def tree(n):
if n>=50:
if n>=0:
if n<=12:
pen.pensize(n/2)
pen.pencolor(random.choice(["snow","lightcoral","pink"]))
else:
pen.color('sienna')
pen.pensize(n/10)
angle=random.randint(0,30)
length=random.randint(1,10)
pen.forward(n)
pen.right(30)
tree(n-10)
pen.left(60)
tree(n-10)
pen.right(30)
pen.right(angle)
tree(n-length)
pen.left(angle*2)
tree(n-length)
pen.right(angle)
pen.up()
pen.backward(n)
pen.down()
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