NewPoint
The NewPoint function returns a new CPoint object. This function is a global form of the CPoint:new method. The CPoint class includes x and y properties. You can use this object as a coordinate point or simply as a pair of numbers that are processed together.
P = NewPoint() P = NewPoint( CPointOld ) P = NewPoint( x, y ) P = NewPoint( x ) P = NewPoint( CPoint ) P = NewPoint( CRect ) P = NewPoint( array ) where The first form with no arguments creates a default CPoint object with properties initialized to the default values 0,0. If a CPoint is passed, a new CPoint object is created initialized to the properties of the CPointOld argument. x, y are numbers, If two numbers are passed, the new CPoint is inialized accordingly. If one number is passed, both x and y properties are initialized to the same value. If a CRect is passed, the CPoiont is initialized to the width and height of the rectangle. This is useful for using the CPoint as a size measurement. If a lua array is passed, the new CPoint is initialized to the first 2 values in a Lua array, in particular, the values of array[1] and array[2]. A new CPoint object, P, is returned. |
Since this function returns a new CPoint object, it is useful in expressions like I:Setn(NewPoint(t)).
The following script illustrates using various forms of NewPoint. All produce the same result:
|
|
|
-- create CPoint A and set values |
|
-- result: 100 300 |
|
|
|
-- copy CPoint A to a new CPoint B |
|
-- result: 100 300 |
|
|
|
-- create a default CPoint C |
|
|
|
-- result: 100 300 |