Commit 1577e636 by BellCodeEditor

save project

parent fa0d584b
Showing with 21 additions and 13 deletions
import turtle
import random
pen = turtle.Turtle()
pen.color('sienna')
# pen.speed(1)
pen.speed(0)
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
def tree(n):
if n>=50:
w.bgcolor('wheat') # wheat小麦🌾
def tree(n):#定义画树🌳
if n>=0:
pencolor = ['snow','lightcoral']
jiaodu = random.randint(15,30)
lenth = random.randint(5,10)
if n-lenth <5:
pen.color(random.choice(pencolor))
pen.pensize(5)
else:
pen.pensize(n/10)
pen.color('sienna')
pen.forward(n)
pen.right(30)
tree(n-50)
pen.left(60)
tree(n-50)
pen.right(30)
pen.right(jiaodu)
tree(n-lenth)
pen.left(2*jiaodu)
tree(n-lenth)
pen.right(jiaodu)
pen.up()
pen.backward(n)
pen.down()
......@@ -28,7 +36,7 @@ pen.backward(150)
pen.down()
tree(100)
tree(80)
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