public static Color colorFromHSV(float hue, float saturation, float lumValue)
{
//select colour sector (from degrees to 6 facets)
int hSector = ((int)Math.Floor(hue / 60)) % 6;
//select minor degree component within sector
float hMinor = hue / 60f - (float)Math.Floor(hue / 60);
//map HSV components to RGB
float v = lumValue;
float p = lumValue * (1f - saturation);
float q = lumValue * (1f - saturation * hMinor);
float t = lumValue * (1f - saturation * (1f - hMinor));
//transpose RGB components based on hue sector
if (hSector == 0)
return new Color(v, t, p, 1f);
else if (hSector == 1)
return new Color(q, v, p, 1f);
else if (hSector == 2)
return new Color(p, v, t, 1f);
else if (hSector == 3)
return new Color(p, q, v, 1f);
else if (hSector == 4)
return new Color(t, p, v, 1f);
else
return new Color(v, p, q, 1f);
}