xxxxxxxxxx
35
function setup() {
createCanvas(800, 600);
noLoop(); // Prevent continuous drawing
}
function draw() {
background(255); // White background
let startY = height / 2 - (5 * 100) / 2; // Calculate starting Y position to center the stack
for (let i = 0; i < 4; i++) {
// Set a slight random rotation angle
let angle = random(-PI / 20, PI / 20); // Slight rotation between -9 and 9 degrees
// Set transparency
fill(0, 200); // Black with transparency
noStroke();
// Save the current state
push();
// Translate to the center of the canvas
translate(width / 2, startY + i * 70 + 75); // Center X and adjust Y for each rectangle
// Rotate by the random angle
rotate(angle);
// Draw the rectangle
rectMode(CENTER);
rect(0, 0, 300, 70);
// Restore the original state
pop();
}
}