turtle 绘制笑脸表情符号

turtle 绘制笑脸表情符号,如图所示

要求:

1. 脸蛋半径100,颜色黄色

2. 左右眼睛半径15,坐标依次(-40,120), (40,120)

3. 左右眼球半径5,颜色黑色,坐标依次(-40, 125), (40, 125)

4. 嘴巴半径40,颜色黑色,坐标(-40, 85)

5. 鼻子半径8,颜色黑色,坐标(0, 75)

6. 舌头半径10,颜色红色,坐标(-10, 45)

7. 绘制结束后隐藏小海龟 

参考代码

import turtle

def eye(col, rad):
    turtle.pendown()
    turtle.fillcolor(col)
    turtle.begin_fill()
    turtle.circle(rad)
    turtle.end_fill()
    turtle.penup()

# 画脸
turtle.fillcolor('yellow')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
turtle.penup()

# 左眼
turtle.goto(-40, 120)
eye('white', 15)
turtle.goto(-40, 125)
eye('black', 5)

# 右眼
turtle.goto(40, 120)
eye('white', 15)
turtle.goto(40, 125)
eye('black', 5)

# 鼻子
turtle.goto(0, 75)
eye('black', 8)

# 嘴巴
turtle.goto(-40, 85)
turtle.pendown()
turtle.right(90)
turtle.circle(40, 180)
turtle.penup()

# 舌头
turtle.goto(-10, 45)
turtle.pendown()
turtle.right(180)
turtle.fillcolor('red')
turtle.begin_fill()
turtle.circle(10, 180)
turtle.end_fill()


turtle.hideturtle()

 

posted @ 2024-07-18 17:01  子墨老师  阅读(1)  评论(0编辑  收藏  举报