用python写个皮卡丘
时间: 2023-11-19 15:06:08 浏览: 111
用python画一只可爱的皮卡丘实例
很高兴听到您对Python编程的兴趣。您可以使用Python中的Turtle模块来绘制皮卡丘。以下是一个示例代码:
```python
import turtle
# 设置窗口大小
turtle.setup(800, 600)
# 窗口标题
turtle.title("皮卡丘")
# 设置画笔
pen = turtle.Turtle()
pen.pensize(3)
# 画圆
def draw_circle(pos_x, pos_y, radius, color):
pen.penup()
pen.goto(pos_x, pos_y)
pen.pendown()
pen.color("black", color)
pen.begin_fill()
pen.circle(radius)
pen.end_fill()
# 画半圆
def draw_semicircle(pos_x, pos_y, radius, extent, color):
pen.penup()
pen.goto(pos_x, pos_y)
pen.pendown()
pen.color("black", color)
pen.begin_fill()
pen.circle(radius, extent)
pen.end_fill()
# 绘制皮卡丘
draw_circle(0, 0, 200, "#FDD835") # 绘制黄色圆形部分
draw_circle(-60, 80, 35, "white") # 绘制左眼白色部分
draw_circle(60, 80, 35, "white") # 绘制右眼白色部分
draw_circle(-50, 100, 15, "black") # 绘制左眼黑色部分
draw_circle(50, 100, 15, "black") # 绘制右眼黑色部分
draw_semicircle(0, 20, 80, 180, "#BF360C") # 绘制嘴巴部分
draw_semicircle(0, 75, 100, 180, "#FDD835") # 绘制腮红部分
pen.hideturtle() # 隐藏画笔
turtle.done()
```
希望这可以为您提供帮助!
阅读全文