CPolygon:DeletePt


The DeletePt function deletes a point from the CPolygon and closes the hole with the point indices above it. If the index is outside the range [1, CPolygon:Count()], the method fails.

Syntax

bSuccess = CPolygon:DeletePt( nIndex )

where

    nIndex is the index where to delete the point.

    bSuccess is the returned success code. On success it is true, otherwise false.

Example

The following script creates a CPolygon object and then deletes the point at index 5.

x {-1,0,1,2,3,4} ; y = {4,5,6,7,8,9}

 

A = NewPolygon( x, y )

-- create a CPolygon with 6 points

Printf("[5] = %lg,%lg", A:GetPt(5) )

-- result: [5] = 3,8

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

-- result: Count = 6

 

 

bSuccess = A:DeletePt( 5 )

-- delete at index [5]

if bSuccess then

 

  Printf("[5] = %lg,%lg", A:GetPt(5) )

-- result: [5] = 4,9

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

-- result: Count = 5

else Printf("Point not deleted") end

 

Related Topics

Add

SetPt

CPolygon class