import os
import random

from drawMethods import drawCircle
from palettes import randomNamedPalette
from util import getTurtleAndScreen
# Divided Colored Circles
# CAC, 2024

cellSize=100
numCols=16
numRows=8
width=cellSize*numCols
height = cellSize*numRows

name,palette = randomNamedPalette()
sides = random.randint(3,9)

filename = os.path.basename(__file__)[0:-3]
turtle, screen = getTurtleAndScreen("Divided Circles ("+name+") "+str(sides)+" sides",width,height,filename,moveWorld=True)

bgcolor = random.choice(palette)
screen.bgcolor(bgcolor)
if random.randint(0,1):
    palette.remove(bgcolor)

wedgeAngle=360/sides
percent = .9
radius = percent * cellSize / 2

for row in range (0,numRows):
    for col in range(0,numCols):
        x = col * cellSize + cellSize / 2
        y = row * cellSize + cellSize / 2
        for i in range(0,sides):
            turtle.color(random.choice(palette))
            drawCircle(turtle, x, y, radius,start=i*wedgeAngle,extent=wedgeAngle)

screen.mainloop()