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:
  1. Private Sub CreatePolygon(ByRef Color As Color, ByRef LocationBounds As Rectangle, Optional ByRef NumberOfPoints As Int32 = 10)
  2.         Dim R As New Random
  3.         Dim PolygonPointsList As New List(Of Point)
  4.         Dim PolygonArray() As Point
  5.         Dim G1 As Graphics = Me.CreateGraphics
  6.         Dim Sb As New SolidBrush(Color)
  7.         For i As Int32 = 1 To NumberOfPoints Step 1
  8.             Dim NewPt As New Point(CInt(R.Next(LocationBounds.X, LocationBounds.X + LocationBounds.Width)), _
  9.                                    CInt(R.Next(LocationBounds.Y, LocationBounds.Y + LocationBounds.Height)))
  10.             PolygonPointsList.Add(NewPt)
  11.         Next
  12.         PolygonArray = PolygonPointsList.ToArray
  13.         Me.Refresh()
  14.         G1.FillPolygon(Sb, PolygonArray)
  15.     End Sub