xxxxxxxxxx
43
let width = 500
let height = 500
let margin = 50
let numRows = 4
let numCols = 4
let squareLength = (width -2 * margin) / numCols
let maxShift = squareLength / 2
function setup() {
createCanvas(400, 400);
frameRate(1);
}
function draw() {
fill('white');
stroke('blue');
for (let row = 0; row < numRows; row += 1) {
for (let num = 0; num < 10; num++) {
drawRow(row);
}
}
}
function drawRow(row) {
for (let column = 0; column < numCols; column += 1) {
let x = margin + column*squareLength + random(maxShift);
let y = margin + row*squareLength + random(maxShift);
if (random(20) < 10) {
maxShift = maxShift;
} else {
maxShift = maxShift * -1;
}
textSize(72);
text("&", x, y);
//rect(x,y, squareLength, squareLength);
}
}