xxxxxxxxxx
26
function setup() {
createCanvas(400, 400);
frameRate(1);
}
function draw() {
background(0);
fill(colorFromPalette());
ellipse(100, 200, 100);
fill(colorFromPalette());
ellipse(200, 200, 100);
fill(colorFromPalette());
ellipse(300, 200, 100);
}
function colorFromPalette() {
let r = random();
if (r < 0.33) { // three choices with equal odds
return 'Coral';
} else if (r < 0.66) {
return 'SpringGreen';
} else { // implicit: 0.66 <= r
return 'Yellow';
}
}