CPolygon:Copy


The Copy method copies all the points and properties of an existing CPolygon into the current one. This effectivly makes the current polygon a cuplicate of the other polygon. All points in the current CPolygon are deleted before copying starts.

Syntax

bSuccess = CPolygon:Copy( CPolygon2 )

where

    CPolygon2 is an existing CPolygon that is copies into the current CPolygon object. In place of CPolygons, use the name of the actual object to be copied.

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

  

To make the current CPolygon B adopt all the properties and points of the an existing CPolygon A, use the Copy method. This is useful when the polygon B already exists but needs to be replaced with other data. For example,

  bSuccess = B:Copy( A )

-- CPolygon A is copied into B

To create a new CPolygon B that is a copy of an existing CPolygon A, use the copy constructor, as in

  B = CPolygon:new( A )

-- CPolygon A already exists

Choose the syntax that fits best with your script.

Example

Assume that a CPolygon A already exists. The following script creates a new CPolygonA2 from 2 data arrays, then replaces the old CPolygon A with the new CPolygon A2:

A = CPolygon:new()

-- create CPolygon A

-- do something with CPolygon A

 

 

 

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

-- create some x and y data

A2 = CPolygon:new( x, y )

-- create CPolygon A2 from x and y

 

 

bSuccess = A:Copy( A2 )

-- copy the new A2 into the old A

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

-- result: N = 4,4

Related Topics

new

CopyPts

CPolygon class