I made this sketch to help me visualise the RGB relation with more intuitive HSB. It is a work in progress i intent to add animation and some more features. Actually this began as an study for making loops in a rgb lamp made with Arduino. Yep yet another rgb lamp... :-) Any way I think it is cool and seeing the rgb slider move as you change saturation or hue is cool and helped me to visualise all this. So to the question.
I made a "focus" test. If mouse is in RGB half of the screen RGB sliders are set to accept input from user and HSB to follow, if mouse is closer to HSB half of the screen, the opposite. I'm using Processing rgbMode()/hsbMode() and red()/hue()... to read values of color in diffrents modes and passing this to sliders.
Depending on values, when the focus change from RGB to HSB to RGB... there is a little change in values, some roundin issue probably. The best way to spot this is fiddle with the sliders and than move the mouse passing the centre of the screen while keeping an eye in RGB percents values (the are more precise with decimals). Some times it changes more than one time... This is not really a flaw to the sketch, but can I improve this? How are made calculation to convert from RGB to HSB? I have normalised all values and I'm working with (RGB,1.0) and (HSB,1.0) to try to avoid this, but... no luck.
The code is below, there is an online version (processingjs) here. As the sketch uses a non system font it may be easier...
/// program displays color values in both rgb and hsb
/// you can input in any one adn the other will update
//int _id = -1; // can i make it a class var? no no
float R = 0.5; /// actually those first values are not being used
float G = 0.5; /// but are here to not leave them unitialized
float B = 0.5;
float hu = 0.5;
float sa = 0.5;
float br = 0.5;
color back; ////some drawing colors
color filler = color ( R, G, B);
PGraphics hueImg, satImg, brImg; // imgs for sliders lable