Hello!
Today I would like to learn how to create a polygon without any intersecting lines. How can this be done?
Thanks.
This is something I just wrote to create any random polygon.
vb Code:
Private Sub CreatePolygon(ByRef Color As Color, ByRef LocationBounds As Rectangle, Optional ByRef NumberOfPoints As Int32 = 10) Dim R As New Random Dim PolygonPointsList As New List(Of Point) Dim PolygonArray() As Point Dim G1 As Graphics = Me.CreateGraphics Dim Sb As New SolidBrush(Color) For i As Int32 = 1 To NumberOfPoints Step 1 Dim NewPt As New Point(CInt(R.Next(LocationBounds.X, LocationBounds.X + LocationBounds.Width)), _ CInt(R.Next(LocationBounds.Y, LocationBounds.Y + LocationBounds.Height))) PolygonPointsList.Add(NewPt) Next PolygonArray = PolygonPointsList.ToArray Me.Refresh() G1.FillPolygon(Sb, PolygonArray) End Sub


Reply With Quote
