使用python 画一张小猫图片
时间: 2023-12-25 17:26:05 浏览: 92
好的,这里是一个使用 Python 的 turtle 模块绘制小猫图片的示例代码:
```python
import turtle
# 设置画笔
turtle.speed(10)
turtle.pensize(3)
turtle.penup()
turtle.goto(-150, 100)
turtle.pendown()
# 绘制头部
turtle.fillcolor('#FFB6C1')
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 绘制左耳朵
turtle.penup()
turtle.goto(-120, 180)
turtle.pendown()
turtle.fillcolor('#FFB6C1')
turtle.begin_fill()
turtle.right(45)
turtle.circle(30, 180)
turtle.left(90)
turtle.circle(30, 180)
turtle.end_fill()
# 绘制右耳朵
turtle.penup()
turtle.goto(-20, 180)
turtle.pendown()
turtle.fillcolor('#FFB6C1')
turtle.begin_fill()
turtle.right(180)
turtle.circle(30, 180)
turtle.right(90)
turtle.circle(30, 180)
turtle.end_fill()
# 绘制左眼
turtle.penup()
turtle.goto(-90, 80)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
turtle.fillcolor('black')
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
# 绘制右眼
turtle.penup()
turtle.goto(-30, 80)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
turtle.fillcolor('black')
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
# 绘制鼻子
turtle.penup()
turtle.goto(-60, 30)
turtle.pendown()
turtle.fillcolor('pink')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制口红
turtle.penup()
turtle.goto(-80, 10)
turtle.pendown()
turtle.pencolor('red')
turtle.circle(10, 180)
# 绘制左胡须
turtle.penup()
turtle.goto(-60, 0)
turtle.pendown()
turtle.pensize(2)
turtle.pencolor('#A52A2A')
turtle.right(20)
turtle.forward(40)
turtle.penup()
turtle.goto(-60, 0)
turtle.pendown()
turtle.left(40)
turtle.forward(40)
# 绘制右胡须
turtle.penup()
turtle.goto(-60, -10)
turtle.pendown()
turtle.right(20)
turtle.forward(40)
turtle.penup()
turtle.goto(-60, -10)
turtle.pendown()
turtle.left(40)
turtle.forward(40)
# 完成绘制
turtle.done()
```
运行代码后,将会弹出一个窗口显示绘制的小猫图片。你也可以根据自己的需求调整绘制的参数和颜色等属性。
阅读全文