Fill Polygon

I am creating a polygon-like drawing. I am drawing an octogon. 7 sides have a pen color of red. The other has black. How can I fill the polygon or open-space with blue or green or even black?
[191 byte] By [codefund.com] at [2007-12-16]
# 1
You have an array of points you use to create the octagon, right? Take that array of points and pass it to the Graphics.FillPolygon method, passing in the appropriate brush to use, as well.
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
But, how can I take the array of points and split up the color of the pen? What if I wanted every other line to be a different color? Can you show me a sample in VB? Here is what I have:Dim myPoints() As Point = {New Point(10,30), New Point(100,10), New Point(150,75), New Point(100,150), New Point(10,130)}
myGraphics.DrawPolygon(Pens.Blue, myPoints)
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
I don't know of a "tricky" way to do it, but here's code that just worked for me:

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim myPoints() As Point = {New Point(10, 30), New Point(100, 10), New Point(150, 75), New Point(100, 150), New Point(10, 130)}
e.Graphics.DrawPolygon(Pens.Blue, myPoints)

Dim i As Integer
Dim myPen As Pen
For i = 0 To myPoints.Length - 2
If (i Mod 2) = 0 Then
myPen = Pens.Red
Else
myPen = Pens.Blue
End If
e.Graphics.DrawLine(myPen, myPoints(i), myPoints(i + 1))
e.Graphics.FillPolygon(Brushes.Green, myPoints)
Next
End Sub

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
A few questions on this. When I do this, my graphics is not crisp. I get lines off of the edge of the image. Also, I would like to fill only half of the image. When I do FillPolygon, I can change the myPoints to be the adjusted points correct?
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5
Nevermind, I got this to work now.
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6
Glad you got it working. There are lots of tricks you can use to get exactly what you want. Did you resize pieces of the drawing to make it look better?
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...