Creating a very rough sketch of a generative rothko – three or two rectangles of random size within a range on a muted background – and I’ve come to the conclusion I don’t understand how fill()
and/or random()
works.
However, what happens is that all the rectangles are the same randomized color. Was I mistaken in thinking that writing fill()
next to each rect()
would have generated a different color? Can anyone point me in the direction of how to get each of these rectangles to be differently colored or maybe another resource on how fill actually works?
Thank you!
let rectX = 30;
let width = 430;
let r;
let g;
let b;
function setup() {
r = random(255);
g = random(255);
b = random(255);
createCanvas(500, 500);
background(0);
fill(r, g, b);
rect(rectX, 20, width, random(80, 100));
fill(r, g, b);
rect(rectX, 200, width, random(25, 250));
fill(r, g, b);
rect(rectX, 400, width, random(55, 80));
}