public static Colour FromHsl(Hue hue, Saturation saturation, Lightness lighness) { byte r; byte b; byte g; if (saturation == 0) { r = g = b = (byte)(lighness * 255); } else { double v1, v2; double hueTemp = hue / 360; double saturationTemp = saturation / 100; double lighnessTemp = lighness / 100; v2 = (lighnessTemp < 0.5) ? (lighnessTemp * (1 + saturationTemp)) : (lighnessTemp + saturationTemp - (lighnessTemp * saturationTemp)); v1 = 2 * lighnessTemp - v2; r = (byte)(255 * HueToRGB(v1, v2, hueTemp + (1.0f / 3))); g = (byte)(255 * HueToRGB(v1, v2, hueTemp)); b = (byte)(255 * HueToRGB(v1, v2, hueTemp - (1.0f / 3))); } return(new Colour(Intensity.FromScalar(r), Intensity.FromScalar(g), Intensity.FromScalar(b))); }
public static Colour FromRgb(Intensity red, Intensity green, Intensity blue) { return(new Colour(red, green, blue)); }
private Colour(Intensity red, Intensity green, Intensity blue) { this.red = red; this.green = green; this.blue = blue; }