C:InsertPt
The InsertPt function inserts a point at an index that already exists in the CPolygon. If the index is outside the range [1, CPolygon:Count()], the method fails.
bSuccess = CPolygon:InsertPt( nIndex, x, y ) bSuccess = CPolygon:InsertPt( nIndex, array ) bSuccess = CPolygon:InsertPt( nIndex, CPoint ) where |
nIndex is the index where to insert the point.
x, y are two numbers for a new point inserted at index nIndex.
array is a Lua array with indices [1] and [2] which are inserted as a new vertex at index nIndex.
CPoint is a CPoint whose (x,y) values are inserted at index nIndex.
bSuccess is the returned success code. On success it is true, otherwise false.
The following script creates a CPolygon object and then changes the (x,y) values at index 5.
|
|
|
-- create a CPolygon with 6 points |
|
-- result: [5] = 3,8 |
|
-- result: Count = 6 |
|
|
|
-- insert at index [5] |
|
|
|
-- result: [5] = 100,200 |
|
-- result: Count = 7 |
|
|
|
|
|
-- create a table with at least index 1 and 2 |
|
-- insert at index [5] |
|
|
|
-- result: [5] = 10,11 |
|
-- result: Count = 8 |
|
|
The next example follows the above script by attempting to insert a point at index [21], which is out of bounds:
|
-- insert at index [21] |
|
|
|
-- result: Count = 8 |
|
|
|
-- result: Point not inserted |