Commit 67c4fc3d by BellCodeEditor

save project

parent bae41ef6
Showing with 42 additions and 0 deletions
import turtle
import random
def tree(n):
if n >= 0:
pen.pensize(n/10)
pen.forward(n)
a=random.randint(0,30)
e=random.randint(1,15)
pen.right(a)
tree(n-e)
pen.left(2*a)
tree(n-e)
pen.right(a)
pen.up()
pen.backward(n)
pen.down()
pen = turtle.Turtle()
pen.speed(0)
pen.color('sienna')
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
# 移动到起点
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.down()
tree(60)
# pen.down()
# pen.forward(100)
# pen.right(30)
# pen.forward(50)
# pen.right(180)
# pen.backward(-50)
# pen.left(60)
# pen.forward(-50)
# pen.up()
# pen.forward(50)
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