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:
Name | Type | Description |
---|---|---|
x | float | The x coordinate of the Rect's origin |
y | float | The y coordinate of the Rect's origin |
width | float | The width of the Rect |
height | float | The height of the Rect |
Properties:
Name | Type | Description |
---|---|---|
left | float | x coordinate |
x | float | left alias |
top | float | y coordinate |
y | float | top alias |
right | float | x + width |
bottom | float | y + height |
width | float | rect width |
height | float | rect height |
center | Point | rect center |
size | Size | rect size |
Methods
ceil(evenopt) → Common.Rect
Floor LeftTop, Ceil BottomRight points
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
even | boolean | <optional> | false | Rect width and height will be multiples of 2 |
Returns:
Ceiling result
Type
contains(point) → {boolean}
Is point part from rect
Parameters:
Name | Type | Description |
---|---|---|
point | Common.Point |
Returns:
Is point part from rect
Type
boolean
floor(evenopt) → Common.Rect
Ceil LeftTop, Floor BottomRight points
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
even | boolean | <optional> | false | Rect width and height will be multiples of 2 |
Returns:
Flooring result
Type
includes(rect) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
rect | Common.Rect |
Returns:
Is rect part from rect
Type
boolean
intersect(rect) → Common.Rect
Intersects 2 rects
Parameters:
Name | Type | Description |
---|---|---|
rect | Common.Rect | Intersect with area |
Returns:
Intersection result
Type
intersects(rect, edgesopt) → {boolean}
Check are 2 rects have common part
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect | Intersect with area | ||
edges | boolean | <optional> | false | Includes 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:
Name | Type | Description |
---|---|---|
matrix | Common.Matrix | Transform matrix |
Returns:
Transformed rect
Type
union(rect) → Common.Rect
Union 2 rects
Parameters:
Name | Type | Description |
---|---|---|
rect | Common.Rect | Union with area |
Returns:
Union result
Type
(static) fromRect(rect) → Common.Rect
Creates a rect from a given rect data
Parameters:
Name | Type | Description |
---|---|---|
rect | Common.Rect | Rect data |
Returns:
Rect instance
Type
(static) intersect(rectA, rectB) → Common.Rect
Intersects 2 rects
Parameters:
Name | Type | Description |
---|---|---|
rectA | Common.Rect | |
rectB | Common.Rect |
Returns:
Intersection result
Type
(static) isRect(data) → {boolean}
Check object is match with rect
Parameters:
Name | Type | Description |
---|---|---|
data | RectData | Rect 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:
Name | Type | Description |
---|---|---|
aX | float | |
aY | float | |
bX | float | |
bY | float |
Returns:
New instance
Type
(static) ofPolygon(poly) → Common.Rect
Computes polygon area
Parameters:
Name | Type | Description |
---|---|---|
poly | PathBuilding.Path|PathBuilding.Polygon |
Returns:
polygon bounds
Type
(static) ofSpline(spline, scatteringopt) → Common.Rect
Computes interpolated spline area
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
spline | PathBuilding.InterpolatedSpline | |||
scattering | float | <optional> | 0 | BrushGL scattering configuration |
Returns:
Polygon bounds
Type
(static) union(rectA, rectB) → Common.Rect
Union 2 rects
Parameters:
Name | Type | Description |
---|---|---|
rectA | Common.Rect | |
rectB | Common.Rect |
Returns:
Union result
Type