ВэйДлин,
с инета
function rgb2hsv(d, e, f) {
var h, b;
d /= 255;
e /= 255;
var g = f / 255,
a, k, c = Math.max(d, e, g);
b = c - Math.min(d, e, g);
0 == b ? a = k = 0 : (k = b / c, f = (c - d) / 6 / b + .5, h = (c - e) / 6 / b + .5, b = (c - g) / 6 / b + .5, d === c ? a = b - h : e === c ? a = 1 / 3 + f - b : g === c && (a = 2 / 3 + h - f), 0 > a ? a += 1 : 1 < a && --a);
return [Math.round(360 * a), Math.round(100 * k), Math.round(100 * c)]
};
alert( rgb2hsv(127, 212, 255) );