xxxxxxxxxx
61
let angle = 0;
let cellsize;
function setup() {
createCanvas(windowWidth, windowHeight);
noFill();
strokeWeight(2);
}
function draw() {
background(255);
cellSize = min(width / 10, height / 10);
for (let y = cellSize; y < height - cellSize; y += cellSize) {
for (let x = cellSize; x < width - cellSize; x += cellSize) {
push();
translate(x + cellSize / 2, y + cellSize / 2);
rotateAmount = random(-angle, angle);
rotate(rotateAmount);
square(-cellSize / 2, -cellSize / 2, cellSize);
pop();
}
angle += 0.05;
}
noLoop();
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
angle = 0;
}
//my attempt
// let cellsize;
// // let seed = 2;
// function setup() {
// createCanvas(windowWidth, windowHeight);
// // rectMode(CENTER);
// noFill();
// strokeWeight(2);
// }
// function windowResized() {
// resizeCanvas(windowWidth, windowHeight);
// }
// function draw() {
// background(255);
// // randomSeed(seed);
// cellSize = min(width / 10, height / 10);
// for (let x = width/10; x < width * 0.85; x += cellSize) {
// for (let y = height/12; y < height * 0.95; y += cellSize) {
// square(x, y, cellSize);
// }
// }
// }