xxxxxxxxxx
27
/*
Create a function called grid that would work with three parameters: a numX and a numY parameter that would create numX amount of shapes
(say rectangles) on the x-axis and numY amount of shapes on the y-axis and a size parameter that would set the size of the shapes.
*/
function setup() {
createCanvas(500, 500);
}
function draw() {
background(255);
// note that the size parameter cannot exceed the value of numX or numY
grid(30, 40, 10);
}
function grid(numX, numY, size) {
for (var i = 0; i < numX; i++) {
for (var j = 0; j < numY; j++) {
rect(numX * i, numY * j, size, size);
}
}
}