I am using Visual Studio 2005 with Visual Basic.
I am trying to create a vertical color-gradient rectangle. I want the
rectangle to go from red on top to blue on the bottom.
This is the routine I am using:
'''''''''''''''''''''''''''''''''''
RectHeight = 50
Dim RCT As New Rectangle(10, 10, 40, RectHeight)
Dim LGB As New LinearGradientBrush(RCT, Color.Red, Color.Blue,
LinearGradientMode.Vertical)
Dim NewReg = New Region(RCT)
gr.FillRegion(LGB, NewReg)
'''''''''''''''''''''''''''''''''''
If I use the above value (RectHeight = 50) for the height of the
rectangle it looks correct. If I instead use:
RectHeight = 51
Then the rectangle gets goofed. The very top line will have the
"bottom" color but the rest of the rectangle looks correct. If the
height of the rectangle is evenly divisible by 2, then it will look
correct. If the height is an odd value then the rectangle will display
the wrong color at the top line every time.
Anyone else experience this? Something stupid I am doing in the code?