CPoint:new


The new method constructs a new instance of a CPoint object. You must call this method before using the class. Note that the object can also be created using new_point.

Syntax

P = CPoint:new()

P = CPoint:new( x0 )

P = CPoint:new( x0, y0 )

P = CPoint:new( CPoint_old )

P = CPoint:new( CRect_old )

P = CPoint:new( tbl )

bullet.gif    WIth no parameters, this method creates a CPoint object, assigns x=0 and y=0, and returns the new object.

bullet.gif    x0 is a single number for initializing both the x and y class members.

bullet.gif    y0 is the second number, which initializes the class x and y to x0 and y0.

bullet.gif    CPoint_old is an existing CPoint object.

bullet.gif    CRect_old is an existing CRect object. The class member x is inialized to the rectangle width and y is initialized to the rectangle height.

bullet.gif    tbl is a 1-dimensional array with values that are numbers. with 2 numbers at index 1 and index 2. The class property x is initialized to tbl[1] and the class property y is initalized to tbl[2].

bullet.gif    P is returned as a new instance of the CPoint class.

bullet.gif    On failure, nil is returned.

Example

The following script creates various CPoint objects.

P = CPoint:new()

-- create a CPoint object

P:Set(4,12)

-- set the values for point members x and y

P1 = CPoint:new(-4,15.2)

-- create a CPoint object with intial values

R = new_rect(1,3,7,12)

-- create a new rectangle object

P3 = P1 + R + 2

-- add the rectangle width and height to P1 and add 2

Related Topics

CPoint class, delete, new_point


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.