帮我用python画一个猫头
时间: 2023-07-20 08:33:56 浏览: 214
好的,以下是一个用 Python 绘制猫头的示例代码:
```python
import turtle
# 定义画笔
pen = turtle.Turtle()
pen.speed(0)
pen.pensize(3)
# 绘制圆形头部
pen.fillcolor("#ffc0cb")
pen.begin_fill()
pen.circle(100)
pen.end_fill()
# 绘制两个三角耳朵
pen.fillcolor("#ffc0cb")
pen.begin_fill()
pen.setheading(50)
pen.circle(40, 100)
pen.setheading(0)
pen.forward(30)
pen.setheading(130)
pen.circle(-40, 100)
pen.setheading(180)
pen.forward(30)
pen.end_fill()
# 绘制两个眼睛及瞳孔
pen.penup()
pen.goto(-40, 120)
pen.fillcolor("white")
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.pendown()
pen.fillcolor("black")
pen.begin_fill()
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(40, 120)
pen.pendown()
pen.fillcolor("white")
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(60, 120)
pen.fillcolor("black")
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 绘制鼻子
pen.penup()
pen.goto(0, 80)
pen.pendown()
pen.fillcolor("black")
pen.begin_fill()
pen.circle(15)
pen.end_fill()
# 绘制嘴巴
pen.penup()
pen.goto(-40, 50)
pen.pendown()
pen.setheading(-20)
pen.circle(30, 120)
pen.penup()
pen.goto(-40, 50)
pen.pendown()
pen.setheading(-160)
pen.circle(30, -120)
# 隐藏画笔
pen.hideturtle()
turtle.done()
```
运行以上代码,即可绘制出一个猫头图案。
阅读全文