예제 #1
0
        public static RGB HslToRgb(HSL hsl)
        {
            double modifiedH, modifiedS, modifiedL, r = 1, g = 1, b = 1, q, p;

            modifiedH = hsl.H / 360.0;
            modifiedS = hsl.S / 100.0;
            modifiedL = hsl.L / 100.0;

            q = (modifiedL < 0.5) ? modifiedL * (1 + modifiedS) : modifiedL + modifiedS - modifiedL * modifiedS;
            p = 2 * modifiedL - q;

            if (modifiedS != 0)
            {
                r = GetHue(p, q, modifiedH + 1.0 / 3);
                g = GetHue(p, q, modifiedH);
                b = GetHue(p, q, modifiedH - 1.0 / 3);
            }

            return(new RGB((byte)Math.Round(r * 255), (byte)Math.Round(g * 255), (byte)Math.Round(b * 255)));
        }
예제 #2
0
 public static XYZ HslToXyz(HSL hsl)
 {
     return(RgbToXyz(HslToRgb(hsl)));
 }
예제 #3
0
 public static CMYK HslToCmyk(HSL hsl)
 {
     return(RgbToCmyk(HslToRgb(hsl)));
 }
예제 #4
0
 public static HEX HslToHex(HSL hsl)
 {
     return(RgbToHex(HslToRgb(hsl)));
 }