python画猫咪代码
时间: 2023-11-12 17:57:59 浏览: 506
以下是一个简单的 Python 代码,可以画出一只可爱的猫咪:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(600, 600)
turtle.bgcolor("#F0EFEF")
# 画猫脸
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F5B041")
turtle.circle(150)
turtle.end_fill()
# 画猫耳朵
turtle.penup()
turtle.goto(-70, 70)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F7DC6F")
for i in range(3):
turtle.forward(140)
turtle.right(120)
turtle.end_fill()
# 右耳朵
turtle.penup()
turtle.goto(70, 70)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F7DC6F")
for i in range(3):
turtle.forward(140)
turtle.left(120)
turtle.end_fill()
# 画猫眼睛
turtle.penup()
turtle.goto(-50, 20)
turtle.pendown()
turtle.begin_fill()
turtle.color("#FFFFFF")
turtle.circle(30)
turtle.end_fill()
# 右眼
turtle.penup()
turtle.goto(50, 20)
turtle.pendown()
turtle.begin_fill()
turtle.color("#FFFFFF")
turtle.circle(30)
turtle.end_fill()
# 左眼珠
turtle.penup()
turtle.goto(-40, 30)
turtle.pendown()
turtle.begin_fill()
turtle.color("#000000")
turtle.circle(15)
turtle.end_fill()
# 右眼珠
turtle.penup()
turtle.goto(40, 30)
turtle.pendown()
turtle.begin_fill()
turtle.color("#000000")
turtle.circle(15)
turtle.end_fill()
# 画猫鼻子
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F7DC6F")
turtle.circle(20)
turtle.end_fill()
# 画猫嘴巴
turtle.penup()
turtle.goto(-50, -50)
turtle.pendown()
turtle.right(90)
turtle.circle(50, 180)
# 画猫胡须
turtle.penup()
turtle.goto(-30, -10)
turtle.pendown()
turtle.right(20)
turtle.forward(60)
# 右胡须
turtle.penup()
turtle.goto(30, -10)
turtle.pendown()
turtle.left(40)
turtle.forward(60)
# 猫咪完成
turtle.done()
```
阅读全文