Beispiel #1
0
 public ColorHsl(ColorHsl hsl)
 {
     this._alpha = hsl._alpha;
     this._h     = hsl._h;
     this._s     = hsl._s;
     this._l     = hsl._l;
 }
Beispiel #2
0
        public void Conversion_Must_Not_Change_Original_Color()
        {
            string[] colors = new string[] { "#FFFF4040", "#FF78D2C8" };

            foreach (string colorString in colors)
            {
                Color    color    = ColorUtils.ColorFromString(colorString);
                ColorHsl hslColor = color.ToHsl();
                Color    color2   = hslColor.ToColor();

                Assert.AreEqual(color, color2);
            }
        }
Beispiel #3
0
        public ColorRgb(ColorHsl hsl)
        {
            if (double.IsNaN(hsl.H) || hsl.S == 0)            //HSL values = From 0 to 1
            {
                this._alpha = hsl.Alpha;
                this._r     = hsl.L;             //RGB results = From 0 to 255
                this._g     = hsl.L;
                this._b     = hsl.L;
                return;
            }

            double       m2       = (hsl.L < 0.5) ? hsl.L * (1.0 + hsl.S) : (hsl.L + hsl.S) - (hsl.S * hsl.L);
            double       m1       = (2.0 * hsl.L) - m2;
            const double onethird = (1.0 / 3.0);

            this._alpha = hsl.Alpha;
            this._r     = 1.0 * hue_2_rgb(m1, m2, hsl.H + onethird);
            this._g     = 1.0 * hue_2_rgb(m1, m2, hsl.H);
            this._b     = 1.0 * hue_2_rgb(m1, m2, hsl.H - onethird);
        }
 private bool _equals(ColorHsl other)
 {
     return(this.H == other.H && this.S == other.S && this.L == other.L);
 }