public static Color HslToRgb(HslColor hsl)
 {
     // Translated from JavaScript, part of coati
     double h = (double)hsl.H / 256;
     double s = (double)hsl.S / 255;
     double l = (double)hsl.L / 255;
     double q;
     if (l < 0.5)
         q = l * (1 + s);
     else
         q = l + s - l * s;
     double p = 2 * l - q;
     double[] t = new double[] { h + 1.0 / 3, h, h - 1.0 / 3 };
     byte[] rgb = new byte[3];
     for (int i = 0; i < 3; i++)
     {
         if (t[i] < 0) t[i]++;
         if (t[i] > 1) t[i]--;
         if (t[i] < 1.0 / 6)
             rgb[i] = (byte)Math.Round((p + ((q - p) * 6 * t[i])) * 255);
         else if (t[i] < 1.0 / 2)
             rgb[i] = (byte)Math.Round(q * 255);
         else if (t[i] < 2.0 / 3)
             rgb[i] = (byte)Math.Round((p + ((q - p) * 6 * (2.0 / 3 - t[i]))) * 255);
         else
             rgb[i] = (byte)Math.Round(p * 255);
     }
     return Color.FromArgb(rgb[0], rgb[1], rgb[2]);
 }
        public bool Equals(HslColor c)
        {
            if ((object)c == null)
            {
                return false;
            }

            return (H == c.H) && (S == c.S) && (L == c.L);
        }