import os
import random
from util import getTurtleAndScreen
# Random Colored Squares
# CAC, 2024
# For this one I determine the size of the screen by first realizing I want
# to break it up into an 8x8 grid of a given size square cell.
cellSize=100
numCols=12
numRows=8
width=cellSize*numCols
height = cellSize*numRows
colors = ["red","yellow",(0,255,0),"#FFFFFF",'#0000BB',(127,127,127),"turquoise","#E8205A"]
filename = os.path.basename(__file__)[0:-3]
turtle, screen = getTurtleAndScreen("Smaller Squares",width,height,filename,moveWorld=True)
# Make the background gray. Notice that we do not see any gray
# because the checkerboard covers the whole screen.
screen.bgcolor("gold")
percent = random.uniform(.5, .9)
for row in range (0,numRows):
for col in range(0,numCols):
x = col * cellSize + (1-percent)*cellSize/2
y= row * cellSize + (1-percent)*cellSize/2
# Move to the lower left corner of the cell.
turtle.penup()
turtle.goto(x,y)
#Random color
colorNumber = random.randint(0,7)
turtle.color(colors[colorNumber])
# Draw a square, filled in.
turtle.pendown()
turtle.begin_fill()
turtle.setheading(0)
for i in range(0,4):
turtle.forward(cellSize*percent)
turtle.left(90)
turtle.end_fill()
screen.mainloop()