import turtle as tt
import random
def tree(branch, t):
if branch > 3:
if 8 <= branch <= 12:
if random.randint(0, 2) == 0:
t.color('snow') # 白
else:
t.color('lightcoral') # 淡珊瑚色
t.pensize(branch / 3)
elif branch < 8:
if random.randint(0, 1) == 0:
t.color('snow')
else:
t.color('lightcoral') # 淡珊瑚色
t.pensize(branch / 2)
else:
t.color('sienna') # 赭(zhě)色
t.pensize(branch / 10) # 6
t.forward(branch)
a = 1.5 * random.random()
t.right(20 * a)
b = 1.5 * random.random()
tree(branch - 10 * b, t)
t.left(40 * a)
tree(branch - 10 * b, t)
t.right(20 * a)
t.up()
t.backward(branch)
t.down()
def petal(m, tr):
for i in range(m):
a = 200 - 400 * random.random()
b = 10 - 20 * random.random()
tr.up()
tr.forward(b)
tr.left(90)
tr.forward(a)
tr.down()
tr.color('lightcoral') # 淡珊瑚色
tr.circle(1)
tr.up()
tr.backward(a)
tr.right(90)
tr.backward(b)
te = tt.Turtle()
w = tt.Screen()
te.hideturtle() # 隐藏画笔
te.getscreen().tracer(5, 0)
w.screensize(bg='wheat') # wheat小麦
te.left(90)
te.up()
te.backward(150)
te.down()
te.color('sienna')
tree(60, te)
petal(200, te)
te.goto(20, -80)
te.write("庆年最美", font=("Microsoft YaHei", 10, "normal"))
w.exitonclick()
import turtle
turtle.setup(width=0.6, height=0.6)
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)
printer = turtle.Turtle()
printer.hideturtle()
printer.penup()
printer.goto(60, -120)
printer.write("So beautiful rose! the same as you \n\n", align="right", font=("楷体", 16, "bold"))
printer.write(" ——from 俊雄", align="center", font=("楷体", 12, "normal"))
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(10, 180)
turtle.circle(25, 110)
turtle.left(50)
turtle.circle(60, 45)
turtle.circle(20, 170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30, 110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90, 70)
turtle.circle(30, 150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80, 90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150, 80)
turtle.left(50)
turtle.circle(150, 90)
turtle.end_fill()
turtle.left(150)
turtle.circle(-90, 70)
turtle.left(20)
turtle.circle(75, 105)
turtle.setheading(60)
turtle.circle(80, 98)
turtle.circle(-90, 40)
turtle.left(180)
turtle.circle(90, 40)
turtle.circle(-80, 98)
turtle.setheading(-83)
turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(-80, 90)
turtle.right(90)
turtle.circle(-80, 90)
turtle.end_fill()
turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)
turtle.right(90)
turtle.right(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(80, 90)
turtle.left(90)
turtle.circle(80, 90)
turtle.end_fill()
turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200, 60)
turtle.done()
import turtle
turtle.speed('fastest')
turtle.pensize(1)
for y in range(200):
turtle.forward(3*y)
turtle.left(20)
turtle.right(175)
手机扫一扫
移动阅读更方便
你可能感兴趣的文章