Commit 9c39835c by BellCodeEditor

save project

parent 19214870
Showing with 15 additions and 7 deletions
import turtle
import random
pen = turtle.Turtle()
pen.color('sienna')
# 画布大小
w = turtle.Screen()
w.bgcolor('green' ) # wheat小麦
w.bgcolor('blue') # wheat小麦
# 移动到起点
pen.left(90)
......@@ -14,15 +15,22 @@ pen.down()
pen.speed(100)
def tree(n):
if n >=50:
if n >=0:
if n <12:
pen.pensize(n/3)
colors=['snow','orange']
pen.pencolor(random.choice(colors))
else:
pen.pensize(n/10)
pen.color('sienna')
length=random.randint(1,15)
rangle=random.randint(0,30)
pen.forward(n)
pen.right(30)
pen.right(rangle)
tree(n-10)
pen.left(60)
pen.left(2*rangle)
tree(n-10)
pen.right(30)
pen.right(rangle)
pen.up()
pen.backward(n)
pen.down()
......
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