用turtle画一条鱼
时间: 2023-07-27 13:07:32 浏览: 57
下面是使用Turtle绘制一条鱼的示例代码:
```python
import turtle
t = turtle.Pen()
t.pensize(5)
t.speed(2)
t.color("blue")
# 绘制鱼的身体
t.begin_fill()
t.penup()
t.goto(-100, 0)
t.pendown()
t.setheading(45)
t.circle(70, 180)
t.setheading(-45)
t.circle(-70, 180)
t.end_fill()
# 绘制鱼的眼睛
t.penup()
t.goto(-60, 50)
t.pendown()
t.color("black")
t.begin_fill()
t.circle(10)
t.end_fill()
# 绘制鱼的尾巴
t.penup()
t.goto(20, 0)
t.pendown()
t.color("blue")
t.begin_fill()
t.setheading(0)
t.circle(-30, 120)
t.setheading(180)
t.circle(30, 120)
t.end_fill()
# 绘制鱼的鳍
t.penup()
t.goto(-100, 30)
t.pendown()
t.color("blue")
t.begin_fill()
t.setheading(-30)
t.circle(50, 60)
t.setheading(180)
t.circle(-50, 60)
t.end_fill()
# 隐藏画笔
t.hideturtle()
turtle.done()
```
该代码使用Turtle绘制了一条蓝色的鱼,包括身体、眼睛、尾巴和鳍。你可以尝试修改代码,绘制其他颜色或形状的鱼。
相关推荐
![](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)