代码如下:
from turtle import *
speed(0) # 最快的画笔速度
# 画圆脸
setup(600, 600, 0, 0)
penup()
fd(-200)
pendown()
color('yellow', 'yellow')
begin_fill()
seth(-90)
circle(200)
end_fill()
# 画嘴巴
penup()
seth(0)
fd(10)
pendown()
pensize(3) # 调整画笔大小
color('red')
seth(-90)
circle(190, 180)
# 画眼睛
penup()
fd(100)
seth(180)
fd(573)
for i in range(2): # 给画两只眼睛制造相同代码,才可以使用for循环,绘制两只眼睛
penup()
seth(0)
fd(200)
pendown()
pensize(2)
seth(20)
color('black', 'white')
begin_fill()
circle(-230, 40)
circle(-10, 180)
circle(210, 40)
circle(-10, 180)
end_fill()
color('black', 'black')
begin_fill()
circle(-10)
end_fill()
# #画左眉毛
penup()
home()
fd(-160)
seth(90)
fd(120)
pendown()
color('black')
begin_fill()
seth(53)
circle(-200, 15)
seth(10)
circle(-50, 50)
seth(120)
circle(42, 150)
end_fill()
# #画右眉毛
penup()
home()
fd(160)
seth(90)
fd(120)
pendown()
color('black')
begin_fill()
seth(127)
circle(200, 15)
seth(170)
circle(50, 50)
seth(60)
circle(-42, 150)
end_fill()
# 笔回到中心点
penup()
home()
# 不关闭画布页面
done()
打印结果如下:
其中,第10行代码控制圆脸的颜色:
color('yellow', 'yellow')
若改为:
color('green', 'green')
则打印结果为: