xxxxxxxxxx
33
function range(start, stop, step=1) {
let rng = [];
if (stop===undefined) [start, stop] = [0, start];
for (let i=start; step>0 ? i<stop : i>stop; i+=step) rng.push(i);
return rng;
}
function flipped(cell){
return {row:cell.col, col:cell.row}
}
function grid(i, numColumns){
return {row:Math.floor(i/numColumns), col:i%numColumns}
}
function setup() {
createCanvas(600, 400);
background(0)
noStroke()
fill(255)
translate(20, 20)
let colSpacing = 25
let rowSpacing = 25
for (const i of range(40)){
let cell = grid(i, 10)
let x = colSpacing * cell.col
let y = rowSpacing * cell.row
circle(x, y, 15)
}
}