CPolygon:Add
The Add function adds point data to the CPolygon. The new data are appended to the existing points in the polygon.
bSuccess = CPolygon:Add( x, y ) bSuccess = CPolygon:Add( array ) bSuccess = CPolygon:Add( arrayX, arrayY ) bSuccess = CPolygon:Add( CPoint ) bSuccess = CPolygon:Add( CPolygonOld ) where |
x, y are two numbers that are added as a new point.
array is a Lua array with elements [1] and [2] which are appended as a new point of the current CPolygon.
CPoint is a CPoint object that is added as a new point.
CPolygonOld is an existing CPolygon object whose points are appended to those in the current CPolygon.
bSuccess is the returned success code. On success it is true, otherwise false.
This method provides a way to append 1 or more points to the points already in the CPolygon object. There are several methods for adding points to a CPolygon:
Methods for Adding Points to a CPolygon
Appends 1 or more points to those already in the CPolygon. |
|
Replaces all existing points with those in another CPolygon. |
|
Inserts a new point at an index already in the CPolygon and increases by 1 the indices of all points above the insertion point. |
|
Assigns new x,y values to an existing point index. |
Suppose a CPolygon A already exists and may or may not contain points. The following script illustrates adding points to the polygon.
|
|
|
-- add a point with (x=2, y=3) |
|
|
|
-- create tables x and y points |
|
-- add 4 more points to A |
|
|
|
-- create a CPoint |
|
-- add 1 point with (x=2,y=4) |
|
|
|
-- create x and y tables with 6 points |
|
-- create a new CPolygon |
|
-- add 6 points to A |
|
-- result: Count = 10 |
|
-- delete B object if no longer needed |