fillpolygin in gdi

biggie_mac

New member
Joined
Nov 17, 2008
Messages
1
Programming Experience
Beginner
Hi everybody, I'm a rookie in gdi, I've made graphics only in java and I'm a bit stuck on something.
I'm trying to fill a polygon with a gradient color.
Googling the problem I've noticed everybody create the points array using

VB.NET:
New Pointf(){p1,p2,p3...}
I don't have/know the points because I read them from a file. So I would need to add them in a for.

I tried
VB.NET:
Dim p as New Pointf()

for....
p.add(New point(x,y),new System.drawing.size(5,5))
end for
but it doesn't work. I get an error when I call fillpolygon:

Overload resolution failed because no accessible 'FillPolygon' can be called with these arguments:
'Public Sub FillPolygon(brush As System.Drawing.Brush, points() As System.Drawing.PointF)': Value of type 'System.Drawing.PointF' cannot be converted to '1-dimensional array of System.Drawing.PointF


also, is there a way to create a gradient brush? I also haven't found any examples on google

10x a lot in advance
 
If you know the number of points from start use an array and For-Next, else fill a collection like the List(Of Point) and use the ToArray method when passing the parameter.
VB.NET:
Dim l As New List(Of Point)
l.Add(Point.Empty)
g.FillPolygon(Brushes.Black, l.ToArray)

You will find Bobs Beginners Guide to GDI+ andFAQ enlightening, it has one about the LinearGradienBrush too.
 
Back
Top