python画图皮卡丘
时间: 2023-06-23 16:49:06 浏览: 84
好的,以下是使用Python绘制皮卡丘的代码:
```python
import turtle
# 初始化
t = turtle.Turtle()
t.speed(10)
turtle.bgcolor("#FED9B7")
# 绘制身体
t.penup()
t.goto(-50, -50)
t.pendown()
t.begin_fill()
t.fillcolor("#FED9B7")
t.circle(100)
t.end_fill()
# 绘制左耳
t.penup()
t.goto(-80, 90)
t.pendown()
t.begin_fill()
t.fillcolor("#000000")
t.circle(30)
t.end_fill()
# 绘制右耳
t.penup()
t.goto(50, 90)
t.pendown()
t.begin_fill()
t.fillcolor("#000000")
t.circle(30)
t.end_fill()
# 绘制左眼
t.penup()
t.goto(-40, 40)
t.pendown()
t.begin_fill()
t.fillcolor("#FFFFFF")
t.circle(20)
t.end_fill()
t.penup()
t.goto(-35, 50)
t.pendown()
t.begin_fill()
t.fillcolor("#000000")
t.circle(7)
t.end_fill()
# 绘制右眼
t.penup()
t.goto(20, 40)
t.pendown()
t.begin_fill()
t.fillcolor("#FFFFFF")
t.circle(20)
t.end_fill()
t.penup()
t.goto(25, 50)
t.pendown()
t.begin_fill()
t.fillcolor("#000000")
t.circle(7)
t.end_fill()
# 绘制嘴巴
t.penup()
t.goto(-30, -20)
t.pendown()
t.pensize(5)
t.right(30)
t.circle(50, 60)
t.penup()
t.goto(10, -20)
t.pendown()
t.left(60)
t.circle(-50, 60)
# 绘制红色脸颊
t.penup()
t.goto(-70, -70)
t.pendown()
t.right(30)
t.begin_fill()
t.fillcolor("#FF0000")
t.circle(30, 120)
t.end_fill()
t.penup()
t.goto(40, -70)
t.pendown()
t.left(60)
t.begin_fill()
t.fillcolor("#FF0000")
t.circle(-30, 120)
t.end_fill()
# 隐藏画笔
t.hideturtle()
# 显示绘制结果
turtle.done()
```
运行代码后,将会绘制出一张皮卡丘的图像。效果如下所示:

阅读全文
相关推荐













