帮我用python编写一个画出皮卡丘的程序
时间: 2023-05-21 10:05:03 浏览: 102
好的,以下是一份用 Python 语言编写的画皮卡丘程序,希望对您有所帮助:
```python
import turtle
# 画出一个黑色圆形
def circle(color):
turtle.fillcolor(color)
turtle.begin_fill()
turtle.circle(60)
turtle.end_fill()
# 画出一个黑色椭圆形
def ellipse():
turtle.fillcolor('black')
turtle.begin_fill()
for i in range(2):
turtle.circle(80, 45)
turtle.circle(40, 45)
turtle.end_fill()
# 画出一个电气表盘状的东西
def semicircle(x, y, r, color):
turtle.penup()
turtle.goto(x, y-r)
turtle.pendown()
turtle.fillcolor(color)
turtle.begin_fill()
turtle.circle(r, 180)
turtle.end_fill()
# 画出一个红色五角星
def star():
turtle.penup()
turtle.goto(-25, 80)
turtle.pendown()
turtle.fillcolor('red')
turtle.begin_fill()
for i in range(5):
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
# 头
def head():
circle('yellow')
# 左耳
turtle.penup()
turtle.goto(-130, 105)
turtle.pendown()
circle('black')
# 右耳
turtle.penup()
turtle.goto(70, 105)
turtle.pendown()
circle('black')
# 面部特征
semicircle(-45, 0, 30, 'white') # 左眼白色部分
semicircle(45, 0, 30, 'white') # 右眼白色部分
semicircle(-37, 0, 12, 'black') # 左眼黑色部分
semicircle(37, 0, 12, 'black') # 右眼黑色部分
semicircle(-37, 10, 5, 'white') # 左眼珠
semicircle(37, 10, 5, 'white') # 右眼珠
semicircle(0, -25, 45, 'red') # 嘴
# 腮
turtle.penup()
turtle.goto(-95, -35)
turtle.pendown()
circle('red')
turtle.penup()
turtle.goto(95, -35)
turtle.pendown()
circle('red')
# 身体
def body():
circle('yellow')
# 腹部
turtle.penup()
turtle.goto(0, -110)
turtle.pendown()
ellipse()
# 尾巴
turtle.penup()
turtle.goto(120, -50)
turtle.pendown()
semicircle(0, 0, 30, 'yellow')
turtle.penup()
turtle.goto(105, -50)
turtle.pendown()
semicircle(0, 0, 15, 'black')
turtle.penup()
turtle.goto(90, -50)
turtle.pendown()
semicircle(0, 0, 15, 'yellow')
turtle.penup()
turtle.goto(75, -50)
turtle.pendown()
semicircle(0, 0, 15, 'black')
# 整体
def pikachu():
head()
body()
star()
turtle.speed(0)
pikachu()
turtle.done()
```
希望这个程序能够帮到您!
阅读全文