I am having trouble with filled polygons. When these filled polygons are written out in a .bmp format, I find that the fill is overlapping the boundary polygon. I will show a brief example of what I have so you can tell me (hopefully) where I've screwed up.
Code:Private Sub pbox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pbox2.Click Dim myGraphics As Graphics Dim myPoints() As Point Dim myFillPoints() As Point Form1_MouseClick(sender, e) Dim PtFill1 As Point = New Point(insPoint.X + 1, insPoint.Y + 1) Dim PtFill2 As Point = New Point(insPoint.X + 20, insPoint.Y + 1) Dim PtFill3 As Point = New Point(insPoint.X + 20, insPoint.Y + 21) Dim PtFill4 As Point = New Point(insPoint.X + 60, insPoint.Y + 21) Dim PtFill5 As Point = New Point(insPoint.X + 60, insPoint.Y + 40) Dim PtFill6 As Point = New Point(insPoint.X + 40, insPoint.Y + 40) Dim PtFill7 As Point = New Point(insPoint.X + 40, insPoint.Y + 60) Dim PtFill8 As Point = New Point(insPoint.X + 21, insPoint.Y + 60) Dim PtFill9 As Point = New Point(insPoint.X + 21, insPoint.Y + 40) Dim PtFill10 As Point = New Point(insPoint.X + 1, insPoint.Y + 40) Dim pt1 As Point = insPoint Dim pt2 As Point = New Point(insPoint.X + 20, insPoint.Y) Dim pt3 As Point = New Point(insPoint.X + 20, insPoint.Y + 20) Dim pt4 As Point = New Point(insPoint.X + 60, insPoint.Y + 20) Dim pt5 As Point = New Point(insPoint.X + 60, insPoint.Y + 40) Dim pt6 As Point = New Point(insPoint.X + 40, insPoint.Y + 40) Dim pt7 As Point = New Point(insPoint.X + 40, insPoint.Y + 60) Dim pt8 As Point = New Point(insPoint.X + 20, insPoint.Y + 60) Dim pt9 As Point = New Point(insPoint.X + 20, insPoint.Y + 40) Dim pt10 As Point = New Point(insPoint.X, insPoint.Y + 40) myGraphics = Graphics.FromHwnd(hwnd:=ActiveForm().Handle) ReDim myPoints(9) ReDim myFillPoints(9) myPoints(0) = pt1 myPoints(1) = pt2 myPoints(2) = pt3 myPoints(3) = pt4 myPoints(4) = pt5 myPoints(5) = pt6 myPoints(6) = pt7 myPoints(7) = pt8 myPoints(8) = pt9 myPoints(9) = pt10 myFillPoints(0) = PtFill1 myFillPoints(1) = PtFill2 myFillPoints(2) = PtFill3 myFillPoints(3) = PtFill4 myFillPoints(4) = PtFill5 myFillPoints(5) = PtFill6 myFillPoints(6) = PtFill7 myFillPoints(7) = PtFill8 myFillPoints(8) = PtFill9 myFillPoints(9) = PtFill10 For Each pts As Point In myPoints If pts.X < 50 Or pts.X > 170 Or pts.Y < 140 Or pts.Y > 340 Then MsgBox("Shape falls outside of range." & vbCrLf & "Select a different insertion point.", MsgBoxStyle.OkOnly, "WARNING") Exit Sub Else Continue For End If Next myGraphics.DrawPolygon(pen:=Pens.Black, points:=myPoints) myGraphics.FillPolygon(Brushes.Indigo, myFillPoints) End Sub


Reply With Quote
