xxxxxxxxxx
34
let numRectangles = 3;
function setup() {
createCanvas(400, 400);
noStroke();
noLoop();
}
function draw() {
background(200, 0, 200);
let rectSpacing = width / numRectangles;
for (let i = 0; i < numRectangles; i = i + 1) {
let fillColor = map(i, 0, numRectangles - 1, 0, 220);
let rectHeight = map(i, 0, numRectangles - 1, rectSpacing, height);
fill(fillColor);
rect(0, 0, rectSpacing, rectHeight);
translate(rectSpacing, 0);
}
// fill(0);
// rect(0, 0, 400/3, 400/3);
// translate(400/3, 0);
// fill(110);
// rect(0, 0, 400/3, 2*400/3);
// translate(400/3, 0);
// fill(220);
// rect(0, 0, 400/3, 400);
// strokeWeight(20);
// stroke(255, 0, 0);
// point(0, 0);
}