programmingscoobydoo
12/22/2004 9:47:00 AM
Hi,
I'm not doing this for any particular reason, but was just playing
with specialising windows controls. It's driven me mad...
I wanted to create a control, derived from System.Windows.Forms.Panel
(though, i started with System.Windows.Forms.UserControl) that fills
itself with a gradient.
I made it rotate in response to a timer etc. - The drawing code is in
the onPaint override.
I seemed to work ok, until the angle is 180degrees. In stead of being
a smooth white to black transition, it starts with a 1 pixel wide,
black, vertical column of pixels.
///this recreates the problem:
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint (e);
Rectangle r = new Rectangle(ClientRectangle.X, ClientRectangle.Y,
ClientRectangle.Width, ClientRectangle.Height);
LinearGradientBrush b = new LinearGradientBrush(r,Color.Black,
Color.White, 180, false);
e.Graphics.FillRectangle(b,r);
}
If I replace the brush declaration - (swapping colours and setting
the angle to 0) - no such line appears. Everything looks well:
LinearGradientBrush b = new LinearGradientBrush(r,Color.White,
Color.Black, 0, false);
The Size of the panel is 100,100.
What have I missed? Why do I get the line?
Dave.