xxxxxxxxxx
46
//MQ Assignment 8: Windows. lossely Based on the windows of my building. Credit:https://images1.apartments.com/i2/-T1_Wi-j1TeBNNsYpzP7bN3C_kQunsuRf6TJk2NETi4/111/249-259-w-144th-st-new-york-ny-building-photo.jpg
function setup() {
createCanvas(400, 400);
background(220);
drawBuilding();
}
function drawBuilding() {
let cols = 3; // windows in row
let rows = 3; // Number windows in column
let windowWidth = 60;
let windowHeight = 80;
let spacingX = 100;
let spacingY = 100;
let startX = 50;
let startY = 50;
for (let i = 0; i < cols; i++) {
for (let j = 0; j < rows; j++) {
let x = startX + i * spacingX;
let y = startY + j * spacingY;
drawWindow(x, y, windowWidth, windowHeight);
}
}
}
function drawWindow(x, y, w, h) {
// frame
fill("brown");
rect(x, y, w, h);
// panes
fill("black");
rect(x + 5, y + 5, w / 2 - 10, h - 10);
rect(x + w / 2 + 5, y + 5, w / 2 - 10, h - 10);
// top/bottom accents
fill("white");
rect(x, y - 5, w, 5); // Top
rect(x, y + h, w, 5); // Bottom
}
function mousePressed() {
save("MQ Apt Windows.png");
}