逐渐改变颜色(python)

我想制作一个在绘制时逐渐改变颜色的图案,如下所示:


#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

没有颜色,这仍然是一个很酷的图案,但我想知道如何使颜色逐渐从红色变为黄色,再到绿色和蓝色,然后最终变回红色。


慕慕森
浏览 59回答 1
1回答

梵蒂冈之花

import turtlecolor = ['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这是一个不错的选择
打开App,查看更多内容
随时随地看视频慕课网APP