Home > Language Reference > Classes > Display

Polygon Method

Draws a polygon.

Syntax

Public Sub Polygon(ByRef iVertices() As Integer, Optional ByVal iCount As Integer = -1, Optional ByVal eMode As HbRectangle = hbRectFillSolid+hbRectBorderSolid)

ParameterDescription
iVerticesArray containing horizontal and vertical coordinates of each vertice in the polygon.
iCountNumber of sides in the polygon.
eModeDrawing options.

Remarks

The Polygon method draws a polygon whose vertices are contained in the iVertices array. The iCount parameter indicates the number of edges in the polygon.

The iVertice parameter should be an array of two dimensions, the first specifying the horizontal coordinates of each point and second specifying the vertical coordinates of each point. The following example shows how to draw a polygon whose vertices are specified by the user clicking on the handheld device screen.

Private iVertices(0 To 1, 0 To 50) as Integer
Private iCount as Integer

Private Sub Form_PenDown(ByVal x As Integer, ByVal y As Integer)
  If iCount<=50 Then
    iVertices(0,iCount)=x
    iVertices(1,iCount)=y
    iCount=iCount+1
    
    PutPixel x, y, hbColorBlack
    Flush
  End If
End Sub

Private Sub Button1_Click()
  BackColor = hbColorBlue
  ForeColor = hbColorBlack
  Polygon iVertices, iCount,hbRectBorderSolid+hbRectFillSolid
  iCount = 0
End Sub

For performance and memory usage reasons, the number of vertices is limited to 100. However, you can experience an out of memory error even with smaller polygons, if running on old devices which do not have much heap.

The eMode parameter specifies the drawing options, and should be a combination of the following group of constants:

To indicate the fill color, specify one of the following constants:

ConstantValueDescription
hbRectFillNone&H0000No fill.
hbRectFillSolid&H0001The drawing is filled with the current background color, previously specified by the BackColor property.
hbRectFillPattern&H0002The drawing is filled with the current pattern, previously specified by the Pattern property.

To indicate the border type, specify one of the following constants:

ConstantValueDescription
hbRectBorderNone&H0000No border.
hbRectBorderSolid&H0010The border is drawn with the foreground color, previously specified by the ForeColor property.

Before drawing the polygon, the graphics instruction buffer is emptied by an implicit call to the Flush method.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A