海龟绘图,皮卡丘代码
时间: 2023-12-20 17:30:24 浏览: 80
以下是绘制皮卡丘头部的海龟绘图代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("#FFFACD")
# 定义画脸的函数
def face(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.setheading(40)
turtle.circle(-150, 69)
turtle.fillcolor("#FBD624")
turtle.begin_fill()
turtle.setheading(120)
turtle.circle(-150, 69)
turtle.end_fill()
# 定义画眼睛的函数
def eye(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(x, y+5)
turtle.pendown()
turtle.fillcolor("#000000")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
# 定义画嘴巴的函数
def mouth(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.setheading(-80)
turtle.circle(80, 40)
turtle.circle(80, 80)
turtle.setheading(0)
turtle.circle(80, 40)
# 画皮卡丘头部
face(-100, 100)
# 画左眼
eye(-50, 170)
# 画右眼
eye(70, 170)
# 画嘴巴
mouth(-20, 30)
# 隐藏海龟
turtle.hideturtle()
# 点击关闭窗口
turtle.done()
```
阅读全文