color2hue function
returns a color saturation
Implementation
num color2hue(num colorValue, num shading, num tint) {
if (tint < 0) tint += 1;
if (tint > 1) tint -= 1;
if (tint < 1 / 6) {
return colorValue + (shading - colorValue) * 6 * tint;
}
if (tint < 1 / 2) {
return shading;
}
if (tint < 2 / 3) {
return colorValue + (shading - colorValue) * (2 / 3 - tint) * 6;
}
return colorValue;
}