Commit e0ba0595 by BellCodeEditor

auto save

parent a4b5b421
Showing with 24 additions and 15 deletions
......@@ -2,20 +2,30 @@ import turtle
import random
pen = turtle.Turtle()
pen.color('sienna')
pen.color('sienna') #赭色
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
pen.speed(0)
#写字
pen.penup()
pen.goto(-400,100)
pen.write('宝\n\n\n\n\n\n出',font=('宋体',20,'normal'))
pen.goto(0,0)
# 移动到起点
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.down()
pen.speed(0)
def tree(n): # 画树枝
if n>=0:
if n<= 12 :
#画一个二叉树(二,分型树)
def tree(n):
if n >= 0:
if n <= 12:
color_list = ['snow','lightcoral']
color = random.choice(color_list)
pen.color(color)
......@@ -23,18 +33,16 @@ def tree(n): # 画树枝
else:
pen.color('sienna')
pen.pensize(n/10)
pen.pensize(n/10)
pen.forward(n)
angle = random.randint(0,30)
length = random.randint(1,15)
pen.forward(n) #前进
angle = random.randint(0,30)#随机生成角度
len = random.randint(1,15) #随机生成树枝的长度
pen.right(angle)
tree(n-length)
tree(n-len)
pen.left(2*angle)
tree(n-length)
tree(n-len)
pen.right(angle)
pen.up()
pen.penup() #抬笔
pen.backward(n)
pen.down()
tree(60)
pen.pendown() #落笔
tree(80)
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