CPolygon:Class Operators


The CPolygon class supports several addition operations between polygons and other data. Operators make it possible for a script to contain expressions like the following:

P2 = P + t

-- appends a point to polygon P.

P3 = P1 + P2

-- Adds polygon P1 to polygon P2.

A primary difference between operators and methods is that the operators create the result as a new CPolygon object, whereas methods operate on the object that calls them.

Addition

P1 + P2

Adds two CPolygons. For example,

P3 = P1 + P2

is equivalent to

P3 = NewPolygon( P2 )

P3:Add( P1 )

P + pt

Adds a CPoint to a CPolygon. For example,

P2 = P + pt

is equivalent to

P2 = NewPolygon( P )

P2:Add( pt )

P + t

Adds elements [1] and [2] of a Lua array to a CPolygon. For example,

P2 = P + t

is equivalent to

P2 = NewPolygon( P )

P2:Add( t )

Related Topics

CPolygon class