System.Windows.Forms.MathHelper.ColorLerp C# (CSharp) Method

ColorLerp() public static method

public static ColorLerp ( ColorF from, Color to, float speed ) : ColorF
from System.Drawing.ColorF
to Color
speed float
return System.Drawing.ColorF
        public static ColorF ColorLerp(ColorF from, Color to, float speed)
        {
            if (from == to) return from;
            var r = FloatLerp(from.R, to.R, speed);
            var g = FloatLerp(from.G, to.G, speed);
            var b = FloatLerp(from.B, to.B, speed);
            var a = FloatLerp(from.A, to.A, speed);
            return ColorF.FromArgb(a, r, g, b);
        }

Usage Example

Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (uwfHovered || scrollDraging)
            {
                scrollDestinationColor = ScrollHoverColor;
            }
            else
            {
                scrollDestinationColor = ScrollColor;
            }
            MathHelper.ColorLerp(scrollDestinationColor, 4, ref scrollCurrentColorA, ref scrollCurrentColorR, ref scrollCurrentColorG, ref scrollCurrentColorB);
            scrollCurrentColor = Color.FromArgb((int)scrollCurrentColorA, (int)scrollCurrentColorR, (int)scrollCurrentColorR, (int)scrollCurrentColorB);

            if (scrollOrientation == ScrollOrientation.HorizontalScroll)
            {
                int backX = subtractButton.Location.X + subtractButton.Width;
                e.Graphics.uwfFillRectangle(BackColor, backX, 0, addButton.Location.X - backX, Height);
            }
            else
            {
                int backY = subtractButton.Location.Y + subtractButton.Height;
                e.Graphics.uwfFillRectangle(BackColor, 0, backY, Width, addButton.Location.Y - backY);
            }
            e.Graphics.uwfFillRectangle(scrollCurrentColor, scrollRect.X, scrollRect.Y, scrollRect.Width, scrollRect.Height);
        }
All Usage Examples Of System.Windows.Forms.MathHelper::ColorLerp