Skip to main content

Class: Rect

Common.Rect(x, y, width, height)

Represents rectangle in screen coordinate system

Constructor

new Rect(x, y, width, height)

Creates a rect with the given dimensions

Parameters:
NameTypeDescription
xfloatThe x coordinate of the Rect's origin
yfloatThe y coordinate of the Rect's origin
widthfloatThe width of the Rect
heightfloatThe height of the Rect
Properties:
NameTypeDescription
leftfloatx coordinate
xfloatleft alias
topfloaty coordinate
yfloattop alias
rightfloatx + width
bottomfloaty + height
widthfloatrect width
heightfloatrect height
centerPointrect center
sizeSizerect size

Methods

ceil(evenopt) → Common.Rect

Floor LeftTop, Ceil BottomRight points

Parameters:
NameTypeAttributesDefaultDescription
evenboolean<optional>falseRect width and height will be multiples of 2
Returns:

Ceiling result

Type

Common.Rect

contains(point) → {boolean}

Is point part from rect

Parameters:
NameTypeDescription
pointCommon.Point
Returns:

Is point part from rect

Type

boolean

floor(evenopt) → Common.Rect

Ceil LeftTop, Floor BottomRight points

Parameters:
NameTypeAttributesDefaultDescription
evenboolean<optional>falseRect width and height will be multiples of 2
Returns:

Flooring result

Type

Common.Rect

includes(rect) → {boolean}

Parameters:
NameTypeDescription
rectCommon.Rect
Returns:

Is rect part from rect

Type

boolean

intersect(rect) → Common.Rect

Intersects 2 rects

Parameters:
NameTypeDescription
rectCommon.RectIntersect with area
Returns:

Intersection result

Type

Common.Rect

intersects(rect, edgesopt) → {boolean}

Check are 2 rects have common part

Parameters:
NameTypeAttributesDefaultDescription
rectCommon.RectIntersect with area
edgesboolean<optional>falseIncludes edges for verification
Returns:

Intersection availability

Type

boolean

transform(matrix) → Common.Rect

Transform rect. Result rect is bounds of transformed edges.When matrix is identity matrix transform not happens and result is current instance.

Parameters:
NameTypeDescription
matrixCommon.MatrixTransform matrix
Returns:

Transformed rect

Type

Common.Rect

union(rect) → Common.Rect

Union 2 rects

Parameters:
NameTypeDescription
rectCommon.RectUnion with area
Returns:

Union result

Type

Common.Rect

(static) fromRect(rect) → Common.Rect

Creates a rect from a given rect data

Parameters:
NameTypeDescription
rectCommon.RectRect data
Returns:

Rect instance

Type

Common.Rect

(static) intersect(rectA, rectB) → Common.Rect

Intersects 2 rects

Parameters:
NameTypeDescription
rectACommon.Rect
rectBCommon.Rect
Returns:

Intersection result

Type

Common.Rect

(static) isRect(data) → {boolean}

Check object is match with rect

Parameters:
NameTypeDescription
dataRectDataRect data to check
Returns:

true if left, top, width and height

Type

boolean

(static) ofEdges(aX, aY, bX, bY) → Common.Rect

Creates new instance

Parameters:
NameTypeDescription
aXfloat
aYfloat
bXfloat
bYfloat
Returns:

New instance

Type

Common.Rect

(static) ofPolygon(poly) → Common.Rect

Computes polygon area

Parameters:
NameTypeDescription
polyPathBuilding.Path|PathBuilding.Polygon
Returns:

polygon bounds

Type

Common.Rect

(static) ofSpline(spline, scatteringopt) → Common.Rect

Computes interpolated spline area

Parameters:
NameTypeAttributesDefaultDescription
splinePathBuilding.InterpolatedSpline
scatteringfloat<optional>0BrushGL scattering configuration
Returns:

Polygon bounds

Type

Common.Rect

(static) union(rectA, rectB) → Common.Rect

Union 2 rects

Parameters:
NameTypeDescription
rectACommon.Rect
rectBCommon.Rect
Returns:

Union result

Type

Common.Rect

Home