有人曾经这样做过吗?同时使用多种颜色。
我有一列颜色:
colors = ["#880000",\
"#884400",\
"#888800",\
"#008800",\
"#008888",\
"#000088",\
"#440088",\
"#880088"]
我的目标是将颜色列表传递给海龟,让它在一个转向的行中绘制一个彩色圆。
我的函数如下:
def drawImage(colorList, radius):
for color in colorList:
turtle.color(color)
turtle.penup()
turtle.setpos(0, -radius)
xpos=turtle.xcor()
ypos=turtle.ycor()
turtle.begin_fill()
turtle.pendown()
turtle.home()
turtle.setpos(xpos,ypos)
turtle.circle(radius)
turtle.end_fill()
turtle.color('black')
turtle.width(2)
turtle.circle(radius)
return
上述函数的问题在于它仅使用一种颜色进行绘制,而不是使用列表中不同颜色的小弧。有人能帮我解决这个问题或指出我做错了什么吗?
该函数被调用如下:
drawImage(colors,200)
,这将绘制一个半径为200的彩色圆形。