CPolygon:GetRect


The GetRect method returns the bounding rectangle for the CPolygon.

Syntax

R = CPolygon:GetRect()

where

    R is a CRect object containing the extrema of the CPolygon.

 

This method simply returns the current values for the bounding rectangle. It does not update the calculation of the bounding rectangle after the vertex set is changed by adding or deleting points. In that case, use CalcRect to update the bounding rectangle.

Example

The following script creates a CPolygon from 2 arrays and returns the bounding rectangle:

A = NewPolygon( {4,5,6,7}, {1,2,-3,5} )

-- create CPolygon A

Printf("R = [%lg:%lg,%lg:%lg]", A:GetRect() )

-- result: R = [4:7,-3:5]

 

 

A:Add( -2, 9 )

-- add another point

Printf("R = [%lg:%lg,%lg:%lg]", A:GetRect() )

-- result: R = [4:7,-3:5]

 

 

A:CalcRect()

-- update the bounding rectangle

Printf("R = [%lg:%lg,%lg:%lg]", A:GetRect() )

-- result: R = [-2:7,-3:9]

Related Topics

CalcRect

CPolygon class