So I’m experimenting with color pickers for my projects and so far I managed to make RGB sliders and an HSB color picker (pretty happy with this one). Im pleased with both of these but another thing I want to do is a color picker with only one 2D slider. So I tried making somehing like this (I know this doesn’t have brown and gray but I have kind of a plan for those) : https://www.colortools.net/color_spectrum.html. With this code:
void setup() {
surface.setSize(460, 140);
surface.setLocation(displayWidth - 465, displayHeight - 145);
surface.setAlwaysOnTop(true);
fullScreen();
colorMode(HSB,360,100,100);
}
void draw() {
background(255,0,100);
//main frame
noFill();
stroke(0);
rect(0, 0, width - 1, height - 1);
//exit button
noFill();
rect(400, 20, 40, 20);
fill(0,100,100);
if (mouseX > 400 && mouseY > 20 && mouseX < 440 && mouseY < 40) {
rect(400, 20, 40, 20);
stroke(0,0,100);
} else stroke(0,0,0);
line(415, 25, 425, 35);
line(415, 35, 425, 25);
//this is the code that draws the spectrum
for (int h = 20; h < 380; h++) {
for (int s = 20; s < 120; s++) {
for (int b = 20; b < 120; b++) {
color c = color(h - 20,s - 20,b - 20);
set(h,s,c);
}
}
}
}
void mouseReleased() {
if (mouseX > 400 && mouseY > 20 && mouseX < 440 && mouseY < 40) exit();
}
This looks pretty good but it doesn’t have black. And I couldn’t quite figure that out. Will appreciate any help!