用 Python 绘制一只小白兔
时间: 2023-11-05 22:58:05 浏览: 43
好的,以下是用 Python 绘制一只小白兔的代码:
```python
import turtle
# 移动到起始位置
turtle.penup()
turtle.goto(-50, 50)
turtle.pendown()
# 绘制身体
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 绘制左耳朵
turtle.fillcolor("pink")
turtle.penup()
turtle.goto(-75, 120)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(60)
turtle.circle(-30, 120)
turtle.setheading(180)
turtle.forward(35)
turtle.setheading(120)
turtle.circle(30, 120)
turtle.setheading(60)
turtle.forward(35)
turtle.end_fill()
# 绘制右耳朵
turtle.fillcolor("pink")
turtle.penup()
turtle.goto(25, 120)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(120)
turtle.circle(-30, 120)
turtle.setheading(0)
turtle.forward(35)
turtle.setheading(240)
turtle.circle(30, 120)
turtle.setheading(120)
turtle.forward(35)
turtle.end_fill()
# 绘制左眼睛
turtle.fillcolor("black")
turtle.penup()
turtle.goto(-25, 80)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制右眼睛
turtle.fillcolor("black")
turtle.penup()
turtle.goto(25, 80)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制左前脚
turtle.fillcolor("white")
turtle.penup()
turtle.goto(-60, -20)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(280)
turtle.circle(30, 120)
turtle.setheading(0)
turtle.forward(30)
turtle.setheading(200)
turtle.circle(-30, 120)
turtle.setheading(280)
turtle.forward(30)
turtle.end_fill()
# 绘制右前脚
turtle.fillcolor("white")
turtle.penup()
turtle.goto(10, -20)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(260)
turtle.circle(-30, 120)
turtle.setheading(180)
turtle.forward(30)
turtle.setheading(80)
turtle.circle(30, 120)
turtle.setheading(260)
turtle.forward(30)
turtle.end_fill()
# 绘制左后脚
turtle.fillcolor("white")
turtle.penup()
turtle.goto(-50, -70)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(260)
turtle.circle(30, 120)
turtle.setheading(0)
turtle.forward(30)
turtle.setheading(200)
turtle.circle(-30, 120)
turtle.setheading(260)
turtle.forward(30)
turtle.end_fill()
# 绘制右后脚
turtle.fillcolor("white")
turtle.penup()
turtle.goto(0, -70)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(280)
turtle.circle(-30, 120)
turtle.setheading(180)
turtle.forward(30)
turtle.setheading(80)
turtle.circle(30, 120)
turtle.setheading(280)
turtle.forward(30)
turtle.end_fill()
# 隐藏海龟
turtle.hideturtle()
# 显示绘图窗口
turtle.mainloop()
```
相关推荐
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)