this.rgbToHsl=function(rgb)
{
var r = rgb.red;
var g = rgb.green;
var b = rgb.blue;
r = r/255, g = g/255, b = b/255;
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
if(max == min){
h = s = 0; // achromatic
}else{
var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
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 "H"+Math.round(h*360)+" S"+Math.round(s*100)+" L"+Math.round(l*100);
}
this.rgbToHsv=function(rgb)
{
var r = rgb.red;
var g = rgb.green;
var b = rgb.blue;
r = r/255, g = g/255, b = b/255;
var max = Math.max(r, g, b);
var 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; // achromatic
}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 "H"+Math.round(h*360)+" S"+Math.round(s*100)+" B"+Math.round(v*100);
}