python turtle 海龟绘图–送你一朵小红花
效果展示:
代码:
import turtle as t
t.pensize(4)
t.speed(10)
#送你一朵小红花
#花叶
#左侧叶子
t.fillcolor("green")
t.begin_fill()
t.setheading(90)
t.circle(70,120)
t.left(60)
t.circle(70,120)
t.left(120)
t.fd(80)
t.end_fill()
t.penup()
#右侧叶子
t.setpos(0,0) #把画笔提回原来的原点位置
t.pendown()
t.fillcolor("green")
t.begin_fill()
t.setheading(90)
t.circle(-70, 120)
t.right(60)
t.circle(-70, 120)
t.right(120)
t.fd(80)
t.end_fill()
#花茎
t.penup()
t.setpos(0, 0)
t.setheading(90) #掉转海龟的方向
t.pendown()
t.fd(160)
#花朵
t.penup()
t.goto(0, 265)
t.pendown()
t.fillcolor("red")
t.begin_fill()
for i in range(5):
t.circle(35,216)
t.right(144)
t.end_fill()
#花蕊
t.penup()
t.goto(10,215)
t.pendown()
t.fillcolor("yellow")
t.begin_fill()
t.circle(30)
t.end_fill()
t.exitonclick()