python用turtle画简单的海底
时间: 2023-06-30 19:20:30 浏览: 140
好的,以下是一个简单的海底绘制代码示例:
```python
import turtle
# 设置海底背景颜色
turtle.bgcolor("#3B9C9C")
# 画海底沙滩
turtle.penup()
turtle.goto(-350, -250)
turtle.pendown()
turtle.begin_fill()
turtle.color("#F5DEB3")
turtle.forward(700)
turtle.right(90)
turtle.forward(150)
turtle.right(90)
turtle.forward(700)
turtle.right(90)
turtle.forward(150)
turtle.end_fill()
# 画海底草丛
turtle.penup()
turtle.goto(-200, -200)
turtle.pendown()
turtle.color("#2E8B57")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.goto(-100, -200)
turtle.pendown()
turtle.begin_fill()
turtle.circle(70)
turtle.end_fill()
turtle.penup()
turtle.goto(50, -200)
turtle.pendown()
turtle.begin_fill()
turtle.circle(40)
turtle.end_fill()
# 画海底石头
turtle.penup()
turtle.goto(-150, -150)
turtle.pendown()
turtle.color("#A9A9A9")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(100, -100)
turtle.pendown()
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 隐藏海龟
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
运行上述代码,即可绘制出一个简单的海底场景。你可以按照自己的需求,对代码进行修改和扩展。
阅读全文