Cycling in array loop
From
Richard Medina@21:1/5 to
All on Sat Oct 29 12:19:59 2022
I want to print circle colors using the turtle package.
Something like this
First circles row
yellow, red, cyan, blue
Second circles row
red, cyan, blue, purple
Third circles row
cyan, blue, purple, yellow
Fourth circles row
purple, yellow red, cyan
See code. Any help is more than welcome
import turtle
wn = turtle. Screen() #creates window to draw
wn.setup(700,700) # change size of window
wn.bgcolor("black")
ted = turtle. Turtle() #creates a turtle to draw with
turtle. Up()
turtle. Speed(0)
fill = ["purple","yellow","red","cyan","blue"]
for j in range(4):
for i in range(4):
turtle.pensize(3)
# turtle. Color(fill[i])
if j==3:
turtle. Color(fill[i])
else:
turtle. Color(fill[2*i+1-i])
turtle.up()
turtle.goto(-300 + 160*i,-300 + 160*j)
turtle. Down()
turtle. Circle(80)
turtle.up()
turtle.goto(-300 + 160*i,-300 + 160*j)
#if j=3:
# ted.fillcolor(fill[i])
#else:
# ted.fillcolor(fill[2*i+1-i])
wn.exitonclick() # wait for a user click on the canvas
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)