LinearGradientBrush.LinearColors(1) = Color.FromArgb(255, 0, 128) not working

C

C

arrowBrush.LinearColors(0) = Color.FromArgb(0, 255, 128)
arrowBrush.LinearColors(1) = Color.FromArgb(255, 0, 128)

What am I doing wrong?

The whole code, by the way is as follows. This is still very
preliminary.

Sub drawArrow(ByVal g As Graphics, ByVal hv As Short, ByVal
arrowLength As Short, ByVal arrowThick As Short, ByVal arrowWidth As
Short)

Dim arrowPoints(6) As Point
Dim rect As Rectangle = New Rectangle(10, 10, 1, 1)

If hv = 1 Then
rect.Height = arrowWidth
rect.Width = arrowLength
Else
rect.Height = arrowLength
rect.Width = arrowWidth
End If

Dim arrowBrush As System.Drawing.Drawing2D.LinearGradientBrush
= New System.Drawing.Drawing2D.LinearGradientBrush(rect, Color.White,
Color.Black, System.Drawing.Drawing2D.LinearGradientMode.Horizontal)

arrowBrush.LinearColors(0) = Color.FromArgb(0, 255, 128)
arrowBrush.LinearColors(1) = Color.FromArgb(255, 0, 128)
' arrowBrush.LinearColors = (Color.Blue, Color.Red)
arrowBrush.LinearColors = New Color() {Color.FromArgb(0, 255,
128), _
Color.FromArgb(255, 0, 128)}

arrowPoints(0) = New Point(10, 20) ' this should come from
arrowL, arrowW, etc.
arrowPoints(1) = New Point(50, 20)
arrowPoints(2) = New Point(50, 10)
arrowPoints(3) = New Point(70, 30)
arrowPoints(4) = New Point(50, 50)
arrowPoints(5) = New Point(50, 40)
arrowPoints(6) = New Point(10, 40)

g.FillPolygon(arrowBrush, arrowPoints)
Me.Invalidate()

End Sub
 
C

C

Looks like I have not asked clearly. The two lines
arrowBrush.LinearColors(0) = Color.FromArgb(0, 255, 128)
arrowBrush.LinearColors(1) = Color.FromArgb(255, 0, 128)
are not changing the two extreme colours of the brush.

But
arrowBrush.LinearColors = New Color() {Color.FromArgb(0, 255,
128), Color.FromArgb(255, 0, 128)}
works fine.

What is wrong with the first approach?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top