CPoint:Set


The Set method assigns new values to the x and y members of the CPoint. This allows the CPoint values to be reset after the object is created, or you could use expressions to assign the x and y values directly.

Syntax

P = CPoint:Set( x0 )

P = CPoint:Set( x0, y0 )

P = CPoint:Set( CPoint_old )

P = CPoint:Set( CRect_old )

P = CPoint:Set( tblSet )

bullet.gif    x0 is the new value to assign both the x and y members of the CPoint.

bullet.gif    x0 and y0 are values to apply respectively to the x and y members of the CPoint.

bullet.gif    CPoint_old is another CPoint object. Its x and y members are copied to the current CPoint.

bullet.gif    CRect_old is a CRect object. Its Width and Height are computed and respectively copied to the x and y values of the CPoint.

bullet.gif    tblOffset is a 1-dimensional array. Element 1 is assigned to the x member and element 2 is assigned to the y member of the CPoint.

bullet.gif    P returned is the original CPoint object. This allows the Set method to be used as part of an operator expression, if desired.

bullet.gif    On failure, nil is returned.

Example

The following script creates a CPoint object and resets its values using the Set method.

P = new_point(4.4,-12.7)

-- create a CPoint object

Printf("x=%lg, y=%lg\n", P.x, P.y)

-- result: x=4.4, y=-12.7

P:Set( 4, -6 )

-- reset the values

Printf("x=%lg, y=%lg\n", P.x, P.y)

-- result: x=4, y=-6

P:Set( new_rect(1,2,5,8) )

-- create a rectable in the method call

Printf("x=%lg, y=%lg\n", P.x, P.y)

-- result: x=1, y=3 (apply width and height)

Related Topics

CPoint class, CRect class, CPoint Math Operators


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