new Rect( [ p1 [, p2 [, p3 [, p4 ] ] ] ] )

Description
Rect Class
Parameters
Name Type Attributes Description
p1 Vector2 | Object | Number <optional>
Vector2 like object of the start position | position.x
p2 Vector2 | Object | Number <optional>
Vector2 like object of the size | position.y
p3 Number <optional>
size.x
p4 Number <optional>
size.y
Properties
Name Type Description
position Vector2
size Vector2
Details

Members


position :Vector2

Description
The start position of the rect
Details

size :Vector2

Description
The size of the rect
Details

<readonly> region :Array.<Array>

Description
Get region for polybooljs plugin, can be also be used for GeoJson. Return a double level array ([[x, y], [x, y], ...])
Details
Array.<Array>

<readonly> points :Array.<Vector2>

Description
Get points of the Polygon
Details
Array.<Vector2>

<readonly> lines :Array.<Line>

Description
Get lines of the Polygon
Details
Array.<Line>

<readonly> area :Number

Description
Get area of the Polygon
Details
Number

<readonly> isConvex :Boolean

Description
Did the polygon is convex
Details
Boolean

isConcave


<readonly> isConcave :Boolean

Description
Did the polygon is concave
Details
Boolean

isConvex


<readonly> hull :Polygon

Description
Convert the current polygon to a hull polygon (convert to convex)
Details

<readonly> convex :Polygon

Description
Alias of hull
Details

hull


<readonly> clone :Polygon

Description
Clonning the current polygon, usefull to not modify the current polygon
Details

Methods


pointIsInside( point ) → {boolean}

Description
Wrapper for checking if point is inside a rect
Parameters
Name Type Description
point Vector2 Point to check
Returns
Details

pointIsInsideRect( point ) → {Boolean}

Description
Check if a point is inside a Rect
Parameters
Name Type Description
point Vector2 The Vector2 like object
Returns
Details

pointIsInsidePolygon( point ) → {boolean}

Description
Checking if point is inside a polygon
Parameters
Name Type Description
point Vector2 Point to check
Returns

setChildren( polygons ) → {Polygon}

Description
Setting all children polygons (for holes)
Parameters
Name Type Description
polygons Array.<Polygon> Children to set
Returns
Details

addChild( polygon ) → {Polygon}

Description
Adding a child polygon (for hole)
Parameters
Name Type Description
polygon Polygon Child polygon to add
Returns
Details

setVertexes( vertices ) → {Polygon}

Description
Setting vertices of the polygon
Parameters
Name Type Description
vertices Array.<Vector2> Vertices to set
Returns
Details

true


setElements( vertices ) → {Polygon}

Description
Setting elements of the polygon
Parameters
Name Type Description
vertices Array.<(Vector2|BezierCurve)> Vertices to set
Returns
Details

addVertex( vertice ) → {Polygon}

Description
Add a new vertices to the end
Parameters
Name Type Description
vertice Vector2 the vertice to add
Returns
Details

true


<static> Box( p ) → {Rect}

Description
Get the box around a polygon or around points
Parameters
Name Type Description
p Polygon | Array.<Vector2> The polygon, or array of Vector2
Returns
Details

addElement( element ) → {Polygon}

Description
Add a new vertices to the end
Parameters
Name Type Description
element Vector2 | BezierCurve the vertice or curve to add
Returns
Details

colliding( polygon ) → {Boolean}

Description
Is the current polygon colliding with the given polygon
Parameters
Name Type Description
polygon Polygon the second polygon for the collision
Returns
Details

intersect( polygon ) → {Array.<Polygon>}

Description
Intersect boolean operation on this polygon with the given polygon
Parameters
Name Type Description
polygon Polygon the second polygon for the operation
Returns
Details

difference( polygon ) → {Array.<Polygon>}

Description
Difference boolean operation on this polygon with the given polygon
Parameters
Name Type Description
polygon Polygon the second polygon for the operation
Returns
Details

union( polygon ) → {Array.<Polygon>}

Description
Union boolean operation on this polygon with the given polygon
Parameters
Name Type Description
polygon Polygon the second polygon for the operation
Returns
Details

xor( polygon ) → {Array.<Polygon>}

Description
Xor boolean operation on this polygon with the given polygon
Parameters
Name Type Description
polygon Polygon the second polygon for the operation
Returns
Details

moveBy( value ) → {Vector2}

Description
Move all vertices of the polygon by a Vector2
Parameters
Name Type Description
value Vector2 The value to move by
Returns
Details