Постепенно меняющая окрас черепаха (питон)

Я хочу сделать узор, который постепенно меняет цвет по мере рисования, примерно так:

#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

Без цвета это все еще довольно крутой узор, но я хочу знать, как заставить цвет постепенно меняться, скажем, от красного к желтому, к зеленому и синему, а затем обратно к красному.


person RhinoRunner    schedule 15.10.2020    source источник


Ответы (1)


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

Это хороший вариант

person Divyessh    schedule 15.10.2020