我想制作一个在绘制时逐渐改变颜色的图案,像这样:
#by the way this is in a loop
turtle.fd(100)
turtle.rt(30)
turtle.fd(50)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.rt(3)
#something here to change the color a little bit
没有颜色,这仍然是一个很酷的图案,但是我想知道如何使颜色从例如红色逐渐变为黄色变为绿色和蓝色,然后最终变为红色。
答案 0 :(得分:3)
import turtle
color = ['red','yellow','green','blue']
for i in range(100):
#by the way this is in a loop
turtle.color(color[i%4])
turtle.fd(100)
turtle.rt(30)
turtle.fd(50)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.rt(3)
#something here to change the color a little bit
这是一个不错的选择