Commit 5c190c37 by BellCodeEditor

auto save

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