Public Class Polygon
  'members...
  Public FILLCOLOUR As Color
  Public NPOINTS As Integer
  Public PARITYMODE As Integer
  Public POINTS() As Element
  Public TYPE As String
  Public APEX As Integer   '(Indicates which of the points is the apex)

  'methods...
  Sub DRAW(ByVal g As Graphics, ByVal listofpoints As PointsList)
    Dim pen1 As New Pen(Color.Black)
    Dim brush1 As New SolidBrush(LineColours(0))
    Dim nodes(NPOINTS - 1) As PointF
    For i As Integer = 0 To NPOINTS - 1
      nodes(i) = listofpoints.GetPoint(POINTS(i).Point)
    Next
    g.FillPolygon(New SolidBrush(FILLCOLOUR), nodes)
    Dim h, j As Integer
    Dim m, n As Single
    Dim r As Integer
    For i As Integer = 0 To NPOINTS - 1
      h = (i + NPOINTS - 1) Mod NPOINTS
      j = (i + 1) Mod NPOINTS
      m = 180 * PointsList.arctan(nodes(i), nodes(h)) / Math.PI
      n = 180 * PointsList.arctan(nodes(i), nodes(j)) / Math.PI
      r = POINTS(i).Radius
      If Form1.CheckBox50.Checked And r > 99 Then
        g.FillPie(brush1, nodes(i).X - 10, nodes(i).Y - 10, 20, 20, n, (m - n + 360) Mod 360)
      End If
      r = r Mod 100
      pen1.Color = LineColours(POINTS(i).Colour)
      If POINTS(i).Colour = 1 And Form1.CheckBox51.Checked And r > 0 Then
        pen1.Width = 2
        g.DrawArc(pen1, nodes(i).X - r, nodes(i).Y - r, 2 * r, 2 * r, n, (m - n + 360) Mod 360)
      End If
      If POINTS(i).Colour = 2 And Form1.CheckBox52.Checked And r > 0 Then
        pen1.Width = 10
        g.DrawArc(pen1, nodes(i).X - r, nodes(i).Y - r, 2 * r, 2 * r, n, (m - n + 360) Mod 360)
      End If
    Next
    g.DrawPolygon(Pens.Black, nodes)
  End Sub

  Function equalls(ByVal q As Polygon) As Boolean
    For i As Integer = 0 To NPOINTS - 1
      If POINTS(i).Point <> q.POINTS(i).Point Then Return False
    Next
    Return True
  End Function

End Class
