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)
| Parameter | Description |
| iVertices | Array containing horizontal and vertical coordinates of each vertice in the polygon. |
| iCount | Number of sides in the polygon. |
| eMode | Drawing 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 SubFor 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:
| Constant | Value | Description |
| hbRectFillNone | &H0000 | No fill. |
| hbRectFillSolid | &H0001 | The drawing is filled with the current background color, previously specified by the BackColor property. |
| hbRectFillPattern | &H0002 | The drawing is filled with the current pattern, previously specified by the Pattern property. |
To indicate the border type, specify one of the following constants:
| Constant | Value | Description |
| hbRectBorderNone | &H0000 | No border. |
| hbRectBorderSolid | &H0010 | The 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
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |