Tizen2.3的RGBA颜色到HSV的转换代码
一个例子说明如何RGB颜色转换为使用Tizen2.3 HSV颜色。var rgbToHsv = function(rgb) {
var r = rgb;
var g = rgb;
var b = rgb;
r /= 255, g /= 255, b /= 255;
var max = Math.max(r, g, b),
min = Math.min(r, g, b);
var h, s, v = max;
var d = max - min;
s = max === 0 ? 0 : d / max;
if (max == min) {
h = 0;
} else {
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
}
h /= 6;
}
return ;
};
rgbToHsv();
页:
[1]