import os
import random
from util import getTurtleAndScreen
# Random Colored Polygons
# CAC, 2024
cellSize=50
numCols=18
numRows=12
width=cellSize*numCols
height = cellSize*numRows
sides = random.randrange(3,12)
colors = ["red","yellow",(0,255,0),"#FFFFFF",'#0000BB',(127,127,127),"turquoise","#E8205A"]
filename = os.path.basename(__file__)[0:-3]
turtle, screen = getTurtleAndScreen("Polygons: "+str(sides),width,height,filename,moveWorld=True)
screen.bgcolor("tan")
percent = random.uniform(.5, .9)
for row in range (0,numRows):
for col in range(0,numCols):
# Move to the lower left corner of the cell.
turtle.penup()
newCellSize = percent*cellSize
x = col * cellSize + cellSize/2
y= row * cellSize + (1-percent)*cellSize/2
turtle.goto(x,y)
# Random color
colorNumber = random.randint(0,7)
turtle.color(colors[colorNumber])
turtle.pendown()
turtle.begin_fill()
turtle.setheading(0)
turtle.circle(newCellSize/2,steps=sides)
turtle.end_fill()
screen.mainloop()