python画皮卡丘的代码
时间: 2023-11-12 19:57:59 浏览: 140
以下是Python画皮卡丘的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor('#FEE12B')
# 画圆函数
def draw_circle(x, y, r, color):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.fillcolor(color)
turtle.begin_fill()
turtle.circle(r)
turtle.end_fill()
# 画矩形函数
def draw_rectangle(x, y, w, h, color):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.fillcolor(color)
turtle.begin_fill()
for i in range(2):
turtle.forward(w)
turtle.right(90)
turtle.forward(h)
turtle.right(90)
turtle.end_fill()
# 画皮卡丘的脸
draw_circle(0, 100, 200, '#FED55D')
# 画皮卡丘的耳朵
draw_circle(-120, 220, 60, '#FED55D')
draw_circle(120, 220, 60, '#FED55D')
# 画皮卡丘的眼睛
draw_circle(-70, 140, 30, '#FFFFFF')
draw_circle(70, 140, 30, '#FFFFFF')
draw_circle(-70, 140, 15, '#000000')
draw_circle(70, 140, 15, '#000000')
# 画皮卡丘的腮红
draw_circle(-120, 60, 40, '#FC4A5C')
draw_circle(120, 60, 40, '#FC4A5C')
# 画皮卡丘的嘴巴
turtle.penup()
turtle.goto(-100, 20)
turtle.pendown()
turtle.pensize(10)
turtle.right(90)
turtle.circle(100, 180)
# 画皮卡丘的鼻子
draw_circle(0, 60, 30, '#000000')
# 画皮卡丘的眉毛
turtle.penup()
turtle.goto(-100, 180)
turtle.pendown()
turtle.pensize(20)
turtle.right(45)
turtle.forward(60)
turtle.penup()
turtle.goto(100, 180)
turtle.pendown()
turtle.right(90)
turtle.forward(60)
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
阅读全文