xxxxxxxxxx
51
let bgColor;
function setup() {
createCanvas(600, 400);
bgColor = color(random(255), random(255), random(255));
}
function mouseClicked() {
// Change the background color to a new random color on each mouse click
bgColor = color(random(255), random(255), random(255));
save('windows.jpg');
}
function draw() {
background(bgColor); // Use the current background color
for (var x = 25; x < width; x += 100) {
var c = map(x, 0, width, 0, 255);
var b = map(x, 0, width, 255, 0);
// Outline
stroke('black');
fill('white');
rect(x - 5, 45, 60, 135);
rect(x - 5, 220, 60, 135);
// Gradient
fill(c);
rect(x, 50, 50, 125);
fill(b);
rect(x, 225, 50, 125);
// Window panes
fill('white');
rect(x + 22.5, 50, 4, 125);
rect(x + 22.5, 225, 4, 125);
rect(x, 60, 50, 4);
rect(x, 237, 50, 4);
// Blue details
noStroke();
fill('rgb(35,35,134)');
rect(x - 10, 35, 70, 10);
rect(x - 10, 180, 70, 10);
rect(x, 185, 50, 10);
rect(x - 10, 210, 70, 10);
rect(x - 10, 355, 70, 10);
rect(x, 360, 50, 10);
}
}