ВэйДлин,
да и ваш код вполне рабочий с поправкой
function RGBtoHSB(RGB_r, RGB_g, RGB_b){
var Min, Max, D, H;
Max = (RGB_r > RGB_g) ? ((RGB_r > RGB_b) ? RGB_r : RGB_b) : ((RGB_g > RGB_b) ? RGB_g : RGB_b);
Min = (RGB_r < RGB_g) ? ((RGB_r < RGB_b) ? RGB_r : RGB_b) : ((RGB_g < RGB_b) ? RGB_g : RGB_b);
if(Min == Max) {
HSB_h = 0;
HSB_s = 0;
HSB_b = Max / 255;
} else {
if(RGB_r == Min) {
D = RGB_g - RGB_b;
H = 3;
} else {
if(RGB_g == Min) {
D = RGB_b - RGB_r;
H = 5;
} else {
D = RGB_r - RGB_g;
H = 1;
}
}
HSB_h = (H - (D / (Max - Min))) / 6;
HSB_s = (Max - Min) / Max;
HSB_b = Max / 255;
}
HSB_h = HSB_h * 360;
if(HSB_h == 360) {
HSB_h = 0;
}
//HSB_h *= 100;
HSB_s *= 100;
HSB_b *= 100;
alert(Math.round(HSB_h) + ' - ' + Math.round(HSB_s) + ' - ' +Math.round( HSB_b));
}
RGBtoHSB(127, 212, 255);