xxxxxxxxxx
79
let colRed, colBlue, colBlack, colYellow;
let randColChoice;
let maxIterations;
let blockScale;
function setup() {
//Variable declarations:
createCanvas(windowWidth, windowHeight, WEBGL);
background('#fff9cc');
angleMode(DEGREES);
rotate(45);
maxIterations = 70;
blockScale = 4;
colRed = createVector(252, 61, 61);
colBlue = createVector(9, 11, 227);
colBlack = createVector(15, 21, 28);
colYellow = createVector(255, 217, 0);
/////////////////////
//Code stars here///
////////////////////
drawBauhaus(maxIterations);
}
function drawBauhaus(DrawMax) {
let i = 0;
let rectX = 0;
let rectY = 0;
let rectW = 0;
let rectH = 0;
let drawMax = DrawMax;
background('#fff9cc');
while (i < drawMax) {
noStroke();
randColChoice = round(random(0, 3));
if (randColChoice == 0) { //Red
fill(colRed.x, colRed.y, colRed.z);
} else if (randColChoice == 1) { //Blue
fill(colBlue.x, colBlue.y, colBlue.z);
} else if (randColChoice == 2) {
fill(colBlack.x, colBlack.y, colBlack.z);
} else {
fill(colYellow.x, colYellow.y, colYellow.z);
}
i++;
rectW = random(5, windowWidth / blockScale);
rectH = random(5, windowHeight / blockScale);
rectX = random(-windowWidth / 2, windowWidth / 2);
rectY = random(-windowWidth / 2, windowWidth / 2);
rect(rectX, rectY, rectW, rectH);
}
}
function mousePressed() {
drawBauhaus(maxIterations);
console.log('Drawing new artwork!');
}