xxxxxxxxxx
28
function setup() {
createCanvas(400, 400);
noStroke();
}
function draw() {
background(220);
colorMode(HSB);
for(let i = 0; i < 100 * 100; i ++){
fill(50, i % 100, i / 100);
rect(i % 100 * 4, int(i/100) * 4, 4, 4);
}
colorMode(HSB);
fill(50, 50, 50);
rect (20, 80, 100, 40);
colorMode(RGB);
fill(1)
text("hsb(50, 50, 50)", 22, 90);
let colorTemp = get(mouseX, mouseY);
let h = hue(colorTemp);
let s = saturation(colorTemp);
let b = brightness(colorTemp);
fill(colorTemp);
rect (20, 120, 100, 40);
fill(2, 200, 80);
text("h " +int(h) +"\ns " +int(s) + "\nb " + +int(b), mouseX, mouseY + 40);
}