import math
import os
import random

from drawMethods import drawForwardSlash, drawBackwardSlash
from util import getTurtleAndScreen
# Slashes
# CAC, 2024

aspectRatio = 1.5
height = 1000
width = height*aspectRatio
numRows=20
numCols= round(numRows*aspectRatio)
cellSize = height/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)

d = math.sqrt(2 * cellSize * cellSize)
turtle.pensize(5)

for row in range (0,numRows):
    for col in range(0,numCols):
        x = col * cellSize
        y= row * cellSize

        # Random color
        colorNumber = random.randint(0,7)
        turtle.color(colors[colorNumber])

        if random.randint(0,1):
            # Better: Use a method.
            drawForwardSlash(turtle, x, y, cellSize)

            #draw lower left to upper right
            # First technique
            # turtle.penup()
            # turtle.goto(x,y)
            # turtle.setheading(45)
            # turtle.pendown()
            # turtle.forward(d)

            # Second technique
            # turtle.penup()
            # turtle.goto(x,y)
            # turtle.pendown()
            # turtle.goto(x+cellSize,y+cellSize)

        else:
            drawBackwardSlash(turtle, x, y, cellSize)

            # draw upper left to lower right
            # turtle.penup()
            # turtle.goto(x,y+cellSize)
            # turtle.setheading(-45)
            # turtle.pendown()
            # turtle.forward(d)

            # turtle.penup()
            # turtle.goto(x,y+cellSize)
            # turtle.pendown()
            # turtle.goto(x+cellSize,y)

screen.mainloop()