Commit ab4df7ef by BellCodeEditor

save project

parent 63e606be
Showing with 10 additions and 67 deletions
import turtle
import random
from turtle import *
from time import sleep
#画樱花的躯干
def tree(branchLen,t):#branchlen树脂长度,T表示turtle对象
sleep(0.0005)
if branchLen >3 :
if 8 <=branchLen <=12:
if random.randint(0,2)==0:
t.color("snow") #白
else:
t.color("lightcoral")#淡三湖色
t.pensize(branchLen/3)
elif branchLen<8:
if random.randint(0.001)==0:
t.color("snow")
else:
t.color("lightcoral")
t.pensize(branchLen/2)
else:
t.color("sienna")#樍色
t.pensize(branchLen/10)
t.forward(branchLen)
a=1.5*random.random()
t.right(20*b)
b=1.5*random.random()
tree(branchLen-10*a,t)
t.left(40*a)
tree(branchLen-10*a,t)
t.right(20*b)
t.up()
t.backwark(branchLen)
t.down()
def petal(m,t):
for i in range(m):
a=200-400*random.random()
b=10-20*random.random()
t.up()
t.forward(a)
t.left(90)
t.forward(b)
t.down()
t.color("lightcoral")
t.circle(1)
t.up()
t.backward(a)
t.right(90)
t.forward(b)
def main():
t=turtle.Turtle()
w=turtle.Screen()
t.hideturtle()
getscreen().tracer(5,0)
w.screensize(bg='wheat')
t.left(90)
t.up()
t.backward(150)
t.down()
t.color("sienna")
tree(60,t)
petal(200,t)
w.exitonclick()
main()
t.done()
a=['华雄']
c=['颜良','文丑']
a.extend(c)
print(a)
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