Commit 4f41873c by BellCodeEditor

save project

parent 576b5884
Showing with 61 additions and 0 deletions
import turtle
import random
def tree(n):
if n >= 0:
angle = random.randint(15,30)
lenth = random.randint(5,10)
pencolor = ['snow','lightcoral']
tree_lenth = n - lenth
if tree_lenth < 5:
pen.color(random.choices(pencolor))
pen.pensize(3)
else:
pen.pensize(n/10)
pen.color('sienna')
pen.fd(n)
pen.right(angle)
tree(tree_lenth)
pen.left(2*angle)
tree(tree_lenth)
pen.right(angle)
pen.up()
pen.bk(n)
pen.down()
pen = turtle.Turtle()
pen.color('sienna')
pen.speed(0)
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
# 移动到起点
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.down()
# pen.forward(100)
# pen.left(30)
# pen.forward(50)
# pen.up()
# pen.backward(50)
# pen.down()
# pen.right(60)
# pen.fd(50)
# pen.up()
# pen.backward(50)
# pen.down()
# pen.left(30)
# pen.up()
# pen.backward(100)
# pen.down()
tree(70)
turtle.done()
\ 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