CPolygon:new
The new method creates and returns a new CPolygon object.
P = CPolygon:new() P = CPolygon:new( CPolygonOld ) P = CPolygon:new( arrayX, arrayY ) where The first form, with no arguments, creates a default CPolygon object with default properties. CPolygonOld is an existing CPolygon object. This form creates a new CPolygon object initialized to the properties of CPolygonOld. arrayX, arrayY are two lua arrays containing, respectively, the x values and y values to be used for the polygon points. P is a new CPolygon object. |
The following script illustrates using various forms of CPolygon:new.
|
|
|
-- create a CPolygon A |
|
-- result: [0,0] = 0 |
|
|
|
-- copy CPolygon A to a new CPolygon B |
|
-- specify the center values |
|
-- result: [2.5,-2.1] = 0 |
|
|
|
-- create some x and y data |
|
-- create a CPolygon C from arrays |
|
-- calculate the center of mass |
|
-- result: [5.5,-1.25] = 4 |