Ejemplo n.º 1
0
        /// <summary>
        /// Steps the color.
        /// </summary>
        /// <param name="clr">The color.</param>
        /// <param name="alpha">The alpha.</param>
        /// <returns>Color.</returns>
        public static Color StepColor(Color clr, int alpha)
        {
            if (alpha == 100)
            {
                return(clr);
            }

            byte  a  = clr.A;
            byte  r  = clr.R;
            byte  g  = clr.G;
            byte  b  = clr.B;
            float bg = 0;

            int _alpha = Math.Min(alpha, 200);

            _alpha = Math.Max(alpha, 0);
            double ialpha = ((double)(_alpha - 100.0)) / 100.0;

            if (ialpha > 100)
            {
                // blend with white
                bg     = 255.0F;
                ialpha = 1.0F - ialpha;  // 0 = transparent fg; 1 = opaque fg
            }
            else
            {
                // blend with black
                bg     = 0.0F;
                ialpha = 1.0F + ialpha;  // 0 = transparent fg; 1 = opaque fg
            }

            r = (byte)(ZeroitLBColorManager.BlendColour(r, bg, ialpha));
            g = (byte)(ZeroitLBColorManager.BlendColour(g, bg, ialpha));
            b = (byte)(ZeroitLBColorManager.BlendColour(b, bg, ialpha));

            return(Color.FromArgb(a, r, g, b));
        }