Question

I have drawn vertical Rectangle but i want to fill it from bottom to top. here is the code i used

System.Drawing.Drawing2D.LinearGradientBrush linGrBrush = 
    new System.Drawing.Drawing2D.LinearGradientBrush(
           new Point(0, 12),
           new Point(0,2),
           Color.FromArgb(0, 0, 0, 0),
           Color.FromArgb(255, 190, 0, 0));

Pen pen = new Pen(linGrBrush);

e.Graphics.FillRectangle(linGrBrush,groupBox2.Width -50,10, 25,  x);

using (Pen Pen1 = new Pen(Color.BurlyWood, 4))
{
   e.Graphics.DrawRectangle(Pen1, groupBox2.Width -50,10, 25, 200);
}

x is color fill offset which fill is used to fill rectangle after every 2 seconds.

Was it helpful?

Solution

I think that you should adjust the starting and the ending points of the gradient:

System.Drawing.Drawing2D.LinearGradientBrush linGrBrush = 
         new System.Drawing.Drawing2D.LinearGradientBrush(
               new Point(0, 1),
               new Point(0,0),
               Color.FromArgb(0, 0, 0, 0),
               Color.FromArgb(255, 190, 0, 0));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top