CPoint:Round


The Round method replaces the x and y members of the CPoint with the nearest integer value. For example, x=1.8 rounds up to x=2, and x=-16.8 rounds down to x=-17.

Syntax

P = CPoint:Round()

bullet.gif    P returned is the original CPoint object. This allows the Round 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 applies the Round method to its values.

P = new_point(4.4,-13.2)

-- create a CPoint object

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

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

P:Round()

-- compute the rounded values

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

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

Related Topics

CPoint class, Ceil, Floor, CPoint Math Operators


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