CPoint:Offset


The Offset method moves a point to new coordinates. The offset can be specified in several different ways and can be positive or negative. The + Operator gives similar results.

Syntax

CPoint:Offset( CPoint2 )

CPoint:Offset( x )

CPoint:Offset( x, y )

where

    CPoint2 is another CPoint object.

    x is a single offset applied to both values.

    x and y are offsets applied individually to the CPoint values.

Example

The following script moves and resizes the CPoint P using various argument lists. Note that CPoint:Get returns 2 arguments, which can be automatically filled into the 2 fields of the Printf function if located as the right-most item in the Printf argument list.

P = NewRect(100, 200)

-- create a CPoint object P

Printf("%lg %lg\n", P:Get())

-- result: 100 200.

 

 

P:Offset( 2, 10 )

-- move and resize the point P

Printf("%lg %lg\n", P:Get())

-- result: 102 210

 

 

P:Offset( 0, 30 )

-- resize the point P

Printf("%lg:%lg\n", P:Get())

-- result: 102 240

 

 

P:Offset( 100 )

-- move the point P

Printf("%lg %lg\n", P:Get())

-- result: 202 340

 

 

P:Offset( 10 )

-- move the point P

Printf("%lg:%lg, %lg:%lg\n", P:Get())

-- result: 212 350

 

 

Pnew = NewRect( 0, 60 )

-- create another CPoint object

P:Offset( Pnew )

-- resize P using another point

Printf("%lg %lg\n", P:Get())

-- result: 212 410

Related Topics

Get

CPoint Operators

CPoint class