xxxxxxxxxx
33
/*
----- Coding Tutorial by Patt Vira -----
Name: 2D Grid w Nested Loop
Video Tutorial: https://youtu.be/UKxB2j4h7Ag?si=I8EgydcHmb1S6VRt
Connect with Patt: @pattvira
https://www.pattvira.com/
----------------------------------------
*/
let columns = 4; let rows = 4;
let colSize; let rowSize;
function setup() {
createCanvas(400, 400);
colSize = width/columns;
rowSize = height/rows;
}
function draw() {
background(220);
for (let i=0; i<columns; i++){
for (let j=0; j<rows; j++){
// ellipse(colSize/2 + i*colSize, rowSize/2 + j*rowSize, colSize, rowSize);
rect(i*colSize, j*rowSize, colSize, rowSize);
}
}
}