gfn() = Grid(
    6,
    7,
    (x,y)->string(rand(1:9)),
    line_color="red",
    title=Label("Title", color="#666", size=32),
    title_right=Label("Title Right", color="green", size=32),
    header=Label("Header", color="orange", size=32),
    header_right=Label("Header Right")
)
gfn()

g2fn() = Grid(
    6,
    7,
    (x,y)->Cell(
        string(rand(1:9)), 
        tl="a", 
        tr="b", 
        bl="c", 
        br="c"
    ),
    line_color="green",
    title=Label("Title2", color="#666", size=32),
    title_right=Label("Title Right2", color="green", size=32),
    header=Label("Header2", color="orange", size=32),
    header_right=Label("Header Right2")
)
g2fn()




# Chess pieces
# https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces
# By Cburnett - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=1499803

rows = [
    [17:32],
    [14:32],
    [13:32],
    [12:32],
    [12:32],
    [12:32],
    [12:32],
    [13:32],
    [14:32],
    [15:30],
    [15:27],
    [15:26],
    [15:24],
    [15:23],
    [14:23],
    [13:23],
    [12:23],
    [11:23],
    [10:23],
    [9:23],
    [8:23],
    [7:23],
    [6:23],
    [5:23],
    [4:23],
    [3:23],
    [2:23],
    [1:23],
    [1:23],
    [1:23],
]

function getgridmat(rows)
    m = falses(30, 32)
    for (row, ranges) in enumerate(rows)
        for range in ranges
            m[row, range] .= true
        end
    end
    m
end

mat = getgridmat(rows)



# 30x32
function gettrackfn(mat)
    function racetrack(row,col)
        if !mat[row,col]
            return nothing
        end
        bg_color = nothing
        if row == size(mat, 1)
            bg_color = "#E79280"
        elseif col == size(mat, 2)
            bg_color = "#92BD8E"
        end
        Cell(
            nothing,
            line_thickness=1,
            bg_color=bg_color
        )
    end
end

g4fn() = Grid(
    size(mat, 1),
    size(mat, 2),
    gettrackfn(mat),
    line_thickness=0,
    title_right=Label("Finish Line", color="#333", size=48),
    header=Label("Starting Line", color="#333", size=48),
    margin_bottom=60,
    margin_left=20,
    margin_right=20,
)
g4fn()


t1fn() = Table(
    3,
    1,
    (x,y)->gfn(),
    margin_top=0,
    margin_bottom=0,
    margin_left=50,
    margin_right=50,
)
t1 = t1fn()

t2fn() = Table(
    1,
    3,
    (x,y)->y == 2 ? t1fn() : TableCell(gfn(), valign=:top),
)
t2 = t2fn()
