好的,我们可以使用 Python 的 turtle 模块来绘制喷泉图案。
下面是一个简单的例子:
import turtle
def draw_spray():
for i inrange(20):
turtle.forward(50)
turtle.backward(50)
turtle.right(18)
turtle.speed('fastest')
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.pensize(5)
turtle.pencolor('blue')
draw_spray()
turtle.done()
运行这段代码后,将会弹出一个窗口,在其中显示一个蓝色的喷泉图案。
其中,draw_spray
函数定义了绘制喷泉图案的步骤,包括前进、后退和转向。然后在主程序中,我们使用了 turtle 模块的一些方法来设置画笔的属性(如颜色和粗细),并调用 draw_spray
函数来绘制喷泉图案。