使用python的turtle库绘制一个阿狸
时间: 2023-06-20 11:04:18 浏览: 122
好的,下面是绘制阿狸的代码:
```python
import turtle
# 设置画笔属性
turtle.pensize(5)
turtle.speed(5)
turtle.color("black", "yellow")
# 绘制头部
turtle.begin_fill()
turtle.circle(150)
turtle.end_fill()
# 绘制左耳朵
turtle.penup()
turtle.goto(-70, 200)
turtle.pendown()
turtle.begin_fill()
turtle.right(30)
turtle.circle(60, 260)
turtle.left(70)
turtle.circle(30, 180)
turtle.right(70)
turtle.circle(60, 260)
turtle.end_fill()
# 绘制右耳朵
turtle.penup()
turtle.goto(70, 200)
turtle.pendown()
turtle.begin_fill()
turtle.left(30)
turtle.circle(-60, 260)
turtle.right(70)
turtle.circle(-30, 180)
turtle.left(70)
turtle.circle(-60, 260)
turtle.end_fill()
# 绘制眼睛
turtle.penup()
turtle.goto(-50, 50)
turtle.pendown()
turtle.begin_fill()
turtle.color("black", "white")
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 绘制眼珠
turtle.penup()
turtle.goto(-40, 60)
turtle.pendown()
turtle.begin_fill()
turtle.color("black", "black")
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 60)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制鼻子
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.begin_fill()
turtle.color("black", "black")
turtle.circle(20)
turtle.end_fill()
# 绘制嘴巴
turtle.penup()
turtle.goto(-80, -80)
turtle.pendown()
turtle.right(30)
turtle.circle(80, 150)
turtle.done()
```
运行上述代码后,即可绘制出一个阿狸的图案。如下图所示:
![阿狸](https://cdn.luogu.com.cn/upload/image_hosting/ed4rk4jg.png)
阅读全文