turtle画一幅简笔画
时间: 2023-09-03 20:08:44 浏览: 108
好的,让我们画一幅简单的海底世界:
```python
import turtle
# 创建画布和画笔
my_turtle = turtle.Turtle()
my_screen = turtle.Screen()
# 画海底世界
my_turtle.color("blue") # 设置画笔颜色为蓝色
my_screen.bgcolor("lightblue") # 设置背景颜色为浅蓝色
my_turtle.pensize(5) # 设置画笔粗细为5
# 画海底
my_turtle.penup()
my_turtle.goto(-400, -200)
my_turtle.pendown()
my_turtle.begin_fill()
my_turtle.goto(400, -200)
my_turtle.goto(400, 0)
my_turtle.goto(-400, 0)
my_turtle.goto(-400, -200)
my_turtle.end_fill()
# 画太阳
my_turtle.penup()
my_turtle.goto(-300, 200)
my_turtle.pendown()
my_turtle.color("yellow") # 设置画笔颜色为黄色
my_turtle.begin_fill()
my_turtle.circle(50)
my_turtle.end_fill()
# 画海底草
my_turtle.color("green") # 设置画笔颜色为绿色
for i in range(10):
my_turtle.penup()
x = -300 + i * 80
y = -200
my_turtle.goto(x, y)
my_turtle.pendown()
my_turtle.circle(20)
# 画海星
my_turtle.color("orange") # 设置画笔颜色为橙色
my_turtle.penup()
my_turtle.goto(-150, -50)
my_turtle.pendown()
my_turtle.begin_fill()
for i in range(5):
my_turtle.forward(50)
my_turtle.right(144)
my_turtle.end_fill()
# 画海螺
my_turtle.color("brown") # 设置画笔颜色为棕色
my_turtle.penup()
my_turtle.goto(100, -100)
my_turtle.pendown()
my_turtle.begin_fill()
my_turtle.circle(30)
my_turtle.end_fill()
my_turtle.color("white") # 设置画笔颜色为白色
my_turtle.penup()
my_turtle.goto(100, -75)
my_turtle.pendown()
my_turtle.begin_fill()
my_turtle.circle(15)
my_turtle.end_fill()
# 完成画图
my_screen.mainloop()
```
这幅简笔画包括海底、太阳、海底草、海星和海螺,运行上述代码可以看到它的样子。
阅读全文