CPolygon:Count


The Count method returns the number of points in the CPolygon object.

Syntax

nCount = CPolygon:Count()

where

    nCount is the number of elements in the CPolygon. On failure, 0 is returned.

  

This method returns the number of members (or values) in the CPolygon. This is not the same thing as the maximum index in the array. For example, if the CPolygon has 2 members, one at index 1 and the other at index 10000, then Count = 2.

Example

Suppose a CPolygon is created from 2 tables, each having 6 elements. The following script returns the number of points in the polygon:

x = {4,5,6,7,10,16}

-- table of x values

y = {1,2,-3,-12,18,5}

-- table of y values

A = CPolygon:new( x, y )

-- create a CPolygon

Printf("N = %d", A:Count() )

-- result: N = 6

Related Topics

CPolygon class