python用turtle库绘制皮卡丘
时间: 2023-07-12 14:36:54 浏览: 145
好的,以下是使用turtle库绘制皮卡丘的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor('#FFE4C4')
# 定义画笔颜色和大小
turtle.pensize(3)
turtle.color('black')
# 绘制皮卡丘的耳朵
def ear(x, y):
turtle.pu()
turtle.goto(x, y)
turtle.pd()
turtle.begin_fill()
turtle.color('#FEEA3B')
turtle.circle(80, 80)
turtle.goto(x, y)
turtle.seth(180)
turtle.circle(-80, 80)
turtle.end_fill()
# 绘制皮卡丘的脸
def face():
turtle.pu()
turtle.goto(0, -150)
turtle.pd()
turtle.begin_fill()
turtle.color('#FEEA3B')
turtle.circle(200)
turtle.end_fill()
# 绘制皮卡丘的眼睛
def eye(x, y):
turtle.pu()
turtle.goto(x, y)
turtle.pd()
turtle.begin_fill()
turtle.color('white')
turtle.circle(50)
turtle.end_fill()
turtle.pu()
turtle.color('black')
turtle.goto(x, y - 10)
turtle.pd()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制皮卡丘的嘴巴
def mouth():
turtle.pu()
turtle.goto(0, -50)
turtle.pd()
turtle.color('black')
turtle.seth(-60)
turtle.circle(80, 120)
# 绘制皮卡丘的红脸颊
def cheek(x, y):
turtle.pu()
turtle.goto(x, y)
turtle.pd()
turtle.begin_fill()
turtle.color('#FC4D50')
turtle.circle(30)
turtle.end_fill()
# 绘制皮卡丘的左耳和右耳
ear(-100, 150)
ear(100, 150)
# 绘制皮卡丘的脸
face()
# 绘制皮卡丘的眼睛
eye(-50, 150)
eye(50, 150)
# 绘制皮卡丘的嘴巴
mouth()
# 绘制皮卡丘的红脸颊
cheek(-120, 20)
cheek(120, 20)
# 隐藏画笔
turtle.hideturtle()
# 显示绘制结果
turtle.done()
```
运行以上代码可以绘制出一只可爱的皮卡丘。希望能够帮助到你!
阅读全文
相关推荐


















