I am not used to the syntax yet. How would I make the rect
in to a double array? In the programming language I used, you could put shapes into a double array, like so:
box[i][j] = Shapes.AddRectangle(GraphicsWindow.Width/10, GraphicsWindow.Height/10)
Here's my HTML/JavaScript code:
var cnv = document.getElementById("canvas");
var ctx = cnv.getContext('2d');
var width = cnv.width;
var height = cnv.height;
var size = 10;
var box[][] = new rect[width / size][height / size];
function drawGrid() {
var i = null;
var j = null;
for (i = 1; i <= width / size; i++) {
for (j = 1; j <= height / size; j++) {
box[i][j] = ctx.rect((i - 1) * size, (j - 1) * size, size, size);
ctx.fillStyle = 'red';
ctx.fill();
}
}
return;
}
drawGrid();
<html>
<head>
<body>
<canvas id="canvas" width="250" height="250" style="border: 1px solid black;">
</canvas>
</body>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
</html>