有pythonturtle模块绘制一条鲫鱼
时间: 2023-10-20 16:14:25 浏览: 97
好的,以下是绘制一条鲫鱼的Python代码:
```python
import turtle
# 设置画布大小和背景色
turtle.setup(800, 600)
turtle.bgcolor("#87CEEB")
# 设置画笔颜色和粗细
turtle.pensize(3)
turtle.pencolor("#FFA500")
# 绘制鱼身
turtle.fillcolor("#FFA500")
turtle.begin_fill()
turtle.goto(-100, 0)
turtle.goto(0, 100)
turtle.goto(200, 0)
turtle.goto(0, -100)
turtle.goto(-100, 0)
turtle.end_fill()
# 绘制鱼尾
turtle.fillcolor("#FFD700")
turtle.begin_fill()
turtle.goto(200, 0)
turtle.goto(250, 50)
turtle.goto(250, -50)
turtle.goto(200, 0)
turtle.end_fill()
# 绘制鱼眼
turtle.penup()
turtle.goto(-30, 30)
turtle.pendown()
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-20, 40)
turtle.pendown()
turtle.fillcolor("#000000")
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
turtle.done()
```
运行上述代码后,即可在画布上看到一条漂亮的鲫鱼。你可以根据需要修改代码中的颜色、位置和大小等参数,绘制出不同的鱼图案。
阅读全文