用Python里面的turle 画个皮卡丘
时间: 2024-01-21 13:16:53 浏览: 109
好的,以下是Python代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor('#FED047')
# 画皮卡丘的脸
turtle.penup()
turtle.goto(-200, 100)
turtle.pendown()
turtle.begin_fill()
turtle.color('#FED047')
turtle.circle(120)
turtle.end_fill()
# 画皮卡丘的眼睛
turtle.penup()
turtle.goto(-80, 240)
turtle.pendown()
turtle.begin_fill()
turtle.color('white')
turtle.circle(40)
turtle.end_fill()
turtle.penup()
turtle.goto(-80, 260)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 240)
turtle.pendown()
turtle.begin_fill()
turtle.color('white')
turtle.circle(40)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 260)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(20)
turtle.end_fill()
# 画皮卡丘的嘴巴
turtle.penup()
turtle.goto(-100, 40)
turtle.pendown()
turtle.pensize(5)
turtle.color('black')
turtle.right(45)
turtle.circle(60, 90)
turtle.right(180)
turtle.circle(-60, 90)
# 画皮卡丘的鼻子
turtle.penup()
turtle.goto(-15, 130)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(20)
turtle.end_fill()
# 画皮卡丘的腮红
turtle.penup()
turtle.goto(-180, 80)
turtle.pendown()
turtle.begin_fill()
turtle.color('#FC4A62')
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 80)
turtle.pendown()
turtle.begin_fill()
turtle.color('#FC4A62')
turtle.circle(30)
turtle.end_fill()
# 画皮卡丘的耳朵
turtle.penup()
turtle.goto(-220, 200)
turtle.pendown()
turtle.begin_fill()
turtle.color('#FED047')
turtle.right(50)
turtle.circle(-90, 100)
turtle.right(180)
turtle.circle(90, 100)
turtle.end_fill()
turtle.penup()
turtle.goto(120, 200)
turtle.pendown()
turtle.begin_fill()
turtle.color('#FED047')
turtle.right(50)
turtle.circle(-90, 100)
turtle.right(180)
turtle.circle(90, 100)
turtle.end_fill()
# 画皮卡丘的身体
turtle.penup()
turtle.goto(-200, -120)
turtle.pendown()
turtle.begin_fill()
turtle.color('#FED047')
turtle.circle(120, 180)
turtle.right(90)
turtle.forward(240)
turtle.right(90)
turtle.circle(120, 180)
turtle.end_fill()
# 完成
turtle.done()
```
运行这段代码,就可以看到一个可爱的皮卡丘了!
阅读全文