예제 #1
0
        public static void DrawRectangleShadow(this Graphics g, Rectangle rect, Color shadowColor, int shadowDepth, int shadowMaxAlpha, int shadowMinAlpha, Padding shadowDirection)
        {
            for (int i = 0; i < shadowDepth; i++)
            {
                int currentAlpha = (int)MathHelpers.Lerp(shadowMaxAlpha, shadowMinAlpha, (float)i / (shadowDepth - 1));

                using (Pen pen = new Pen(Color.FromArgb(currentAlpha, shadowColor)))
                {
                    Rectangle shadowRect = new Rectangle(rect.X + -shadowDirection.Left * i, rect.Y + -shadowDirection.Top * i,
                                                         rect.Width + (shadowDirection.Left + shadowDirection.Right) * i, rect.Height + (shadowDirection.Top + shadowDirection.Bottom) * i);

                    g.DrawRectangleProper(pen, shadowRect);
                }
            }
        }
예제 #2
0
 public static Color Lerp(Color from, Color to, float amount)
 {
     return(Color.FromArgb((int)MathHelpers.Lerp(from.R, to.R, amount), (int)MathHelpers.Lerp(from.G, to.G, amount), (int)MathHelpers.Lerp(from.B, to.B, amount)));
 }