xxxxxxxxxx
39
function setup(){
createCanvas(425, 800);
}
//credits to GOLAN LEVIN for the structure of the code
function draw() {
background(240);
strokeWeight(1.5);
noFill();
noLoop();
var offsetx = 50;
var offsety = 50;
var spacing = 30;
for (var row = 0; row < 22; row ++){
for (var col = 0; col < 12; col ++){
var px = offsetx + col*spacing;
var py = offsety + row*spacing;
var rotationRandomness = map(row, 0, 22, 0, 0.3*PI);
var randAngle = rotationRandomness * (random(-1,1));
if(row > 14){
var rdx = row^2 * random(-2,2);
var rdy = row^2 * random(-2,2);
}
var rdx = (row^3)/2 * random(-1,1);
var rdy = (row^3)/2 * random(-1,1);
push();
translate(rdx,rdy);
translate(px, py);
rotate(randAngle);
rect(-spacing/2, -spacing/2, spacing, spacing);
pop();
}
}
}