Rect
Defined in: src/grid.ts:75
Represents a rectangle.
Constructors
Constructor
new Rect(
x,y,width,height):Rect
Defined in: src/grid.ts:81
Parameters
| Parameter | Type |
|---|---|
x | number |
y | number |
width | number |
height | number |
Returns
Rect
Properties
| Property | Type | Defined in |
|---|---|---|
height | number | src/grid.ts:79 |
width | number | src/grid.ts:78 |
x | number | src/grid.ts:76 |
y | number | src/grid.ts:77 |
Accessors
bottom
Get Signature
get bottom():
number
Defined in: src/grid.ts:174
Bottom border position of the rectangle along the y-axis.
Returns
number
left
Get Signature
get left():
number
Defined in: src/grid.ts:159
Left border position of the rectangle along the x-axis.
Returns
number
maxX
Get Signature
get maxX():
number
Defined in: src/grid.ts:150
Same as (x + width), or (right)
Returns
number
maxY
Get Signature
get maxY():
number
Defined in: src/grid.ts:156
Same as x + width
Returns
number
midX
Get Signature
get midX():
number
Defined in: src/grid.ts:137
The midpoint of the rectangle along the x-axis.
Returns
number
midY
Get Signature
get midY():
number
Defined in: src/grid.ts:142
The midpoint of the rectangle along the y-axis.
Returns
number
minX
Get Signature
get minX():
number
Defined in: src/grid.ts:147
Same as x
Returns
number
minY
Get Signature
get minY():
number
Defined in: src/grid.ts:153
Same as (y)
Returns
number
right
Get Signature
get right():
number
Defined in: src/grid.ts:169
Right border position of the rectangle along the x-axis.
Returns
number
top
Get Signature
get top():
number
Defined in: src/grid.ts:164
Top border position of the rectangle along the y-axis.
Returns
number
Methods
above()
above(
height):Rect
Defined in: src/grid.ts:313
New rectangle above the original with a height of height.
Parameters
| Parameter | Type | Description |
|---|---|---|
height | number | {number} new rectangle height |
Returns
Rect
below()
below(
height):Rect
Defined in: src/grid.ts:306
New rectangle below the original with a height of height.
Parameters
| Parameter | Type | Description |
|---|---|---|
height | number | {number} new rectangle height |
Returns
Rect
contains()
contains(
x,y):boolean
Defined in: src/grid.ts:474
Checks if this Rect contains the point (x; y) inside
Parameters
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns
boolean
containsPoint()
containsPoint(
p):boolean
Defined in: src/grid.ts:479
Checks if this Rect contains the specified point
Parameters
| Parameter | Type |
|---|---|
p | Point |
Returns
boolean
cutBottom()
cutBottom(
dh):Rect
Defined in: src/grid.ts:289
New rectangle with the same top border as the original, but with the bottom border clipped by dh.
Parameters
| Parameter | Type | Description |
|---|---|---|
dh | number | {number} delta height |
Returns
Rect
cutLeft()
cutLeft(
dw):Rect
Defined in: src/grid.ts:273
New rectangle with the same right border as the original, but with the left border clipped by dw.
Parameters
| Parameter | Type | Description |
|---|---|---|
dw | number | {number} delta width |
Returns
Rect
cutRight()
cutRight(
dw):Rect
Defined in: src/grid.ts:297
New rectangle with the same left border as the original, but with the right border clipped by dw.
Parameters
| Parameter | Type | Description |
|---|---|---|
dw | number | {number} delta width |
Returns
Rect
cutTop()
cutTop(
dh):Rect
Defined in: src/grid.ts:281
New rectangle with the same bottom border as the original, but with the top border clipped by dh.
Parameters
| Parameter | Type | Description |
|---|---|---|
dh | number | {number} delta height |
Returns
Rect
fit()
fit(
width,height):Rect
Defined in: src/grid.ts:467
The biggest rectangle that fits within this rect that keeps the width/height aspect ratio Positioned in the center. Useful for rendering images in cells.
Parameters
| Parameter | Type |
|---|---|
width | number |
height | number |
Returns
Rect
fitSquare()
fitSquare():
Rect
Defined in: src/grid.ts:459
Square fitted (inscribed) to the original rectangle
Returns
Rect
fromCenterSize()
fromCenterSize(
cx,cy,width,height):Rect
Defined in: src/grid.ts:132
Rectangle of the specified size, with the specified center
Parameters
| Parameter | Type |
|---|---|
cx | number |
cy | number |
width | number |
height | number |
Returns
Rect
getBottom()
getBottom(
height):Rect
Defined in: src/grid.ts:201
Rectangle's bottom part of height height. New rectangle with the same bottom border as the original, but with a height of height. The result may be larger than the original rectangle along y-axis.
Parameters
| Parameter | Type | Description |
|---|---|---|
height | number | {number} new rectangle height |
Returns
Rect
getBottomLeft()
getBottomLeft(
width,height):Rect
Defined in: src/grid.ts:252
New rectangle with the same bottom-left corner as the original, but with new width and height. The result may be larger than the original rectangle on both axes.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | {number} new rectangle width |
height | number | {number} new rectangle height |
Returns
Rect
getBottomRight()
getBottomRight(
width,height):Rect
Defined in: src/grid.ts:263
New rectangle with the same bottom-right corner as the original, but with new width and height. The result may be larger than the original rectangle on both axes.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | {number} new rectangle width |
height | number | {number} new rectangle height |
Returns
Rect
getBottomScaled()
getBottomScaled(
ratio):Rect
Defined in: src/grid.ts:364
New rectangle with the same bottom border as the original, but with a height scaled with ratio of the original height. See also getBottom.
Parameters
| Parameter | Type | Description |
|---|---|---|
ratio | number | {number} height scale factor |
Returns
Rect
getGridPart()
getGridPart(
xCount,yCount,x,y):Rect
Defined in: src/grid.ts:417
Returns (x, y) part of the original rectangle divided into parts by a grid.
Parameters
| Parameter | Type | Description |
|---|---|---|
xCount | number | {number} dividing grid size along x-axis |
yCount | number | {number} dividing grid size along y-axis |
x | number | {number} index of part to return along x-axis |
y | number | {number} index of part to return along y-axis |
Returns
Rect
getLeft()
getLeft(
width):Rect
Defined in: src/grid.ts:211
Rectangle's left part of width width. New rectangle with the same left border as the original, but with a width of width. The result may be larger than the original rectangle along x-axis.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | {number} new rectangle width |
Returns
Rect
getLeftPart()
getLeftPart(
count,index):Rect
Defined in: src/grid.ts:404
Vertical part of index of the original rectangle slices on count parts.
Parameters
| Parameter | Type | Description |
|---|---|---|
count | number | {number} count of parts to divide rectangle horizontally |
index | number | {number} index of part to return |
Returns
Rect
getLeftScaled()
getLeftScaled(
ratio):Rect
Defined in: src/grid.ts:373
New rectangle with the same left border as the original, but with a width scaled with ratio of original width. See also getLeft.
Parameters
| Parameter | Type | Description |
|---|---|---|
ratio | number | {number} width scale factor |
Returns
Rect
getRight()
getRight(
width):Rect
Defined in: src/grid.ts:221
Rectangle's right part of width width. New rectangle with the same right border as the original, but with a width of width. The result may be larger than the original rectangle along x-axis.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | {number} new rectangle width |
Returns
Rect
getRightScaled()
getRightScaled(
ratio):Rect
Defined in: src/grid.ts:382
New rectangle with the same right border as the original, but with a width scaled with ratio of original width. See also getRight.
Parameters
| Parameter | Type | Description |
|---|---|---|
ratio | number | {number} width scale factor |
Returns
Rect
getTop()
getTop(
height):Rect
Defined in: src/grid.ts:191
Rectangle's top part of height height. New rectangle with the same top border as the original, but with a height of height. The result may be larger than the original rectangle along y-axis.
Parameters
| Parameter | Type | Description |
|---|---|---|
height | number | {number} new rectangle height |
Returns
Rect
getTopLeft()
getTopLeft(
width,height):Rect
Defined in: src/grid.ts:231
New rectangle with the same top-left corner as the original, but with new width and height. The result may be larger than the original rectangle on both axes.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | {number} new rectangle width |
height | number | {number} new rectangle height |
Returns
Rect
getTopPart()
getTopPart(
count,index):Rect
Defined in: src/grid.ts:393
Horizontal part of index of the original rectangle sliced on count parts.
Parameters
| Parameter | Type | Description |
|---|---|---|
count | number | {number} count of parts to divide the rectangle vertically |
index | number | {number} index of part to return |
Returns
Rect
getTopRight()
getTopRight(
width,height):Rect
Defined in: src/grid.ts:241
New rectangle with the same top-right corner as the original, but with new width and height. The result may be larger than the original rectangle on both axes.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | {number} new rectangle width |
height | number | {number} new rectangle height |
Returns
Rect
getTopScaled()
getTopScaled(
ratio):Rect
Defined in: src/grid.ts:355
New rectangle with the same top border as the original, but with a height scaled with ratio of the original height. See also getTop.
Parameters
| Parameter | Type | Description |
|---|---|---|
ratio | number | {number} height scale factor |
Returns
Rect
inflate()
inflate(
dx,dy):Rect
Defined in: src/grid.ts:432
Inflated rectangle with left and right borders of the original shifted outside by dx and top and bottom borders shifted outside by dy. Overall size increased by 2*dx along x-axis, and by 2*dy along y-axis.
Parameters
| Parameter | Type | Description |
|---|---|---|
dx | number | {number} vertical borders shift delta along x-axis |
dy | number | {number} horizontal borders shift delta along y-axis |
Returns
Rect
inflateRel()
inflateRel(
dxRatio,dyRatio):Rect
Defined in: src/grid.ts:454
Inflated rectangle with new width scaled by dxRatio of the original and height scaled by dyRatio.
Parameters
| Parameter | Type | Description |
|---|---|---|
dxRatio | number | {number} width scale ratio |
dyRatio | number | {number} height scale ratio |
Returns
Rect
inflateSize()
inflateSize(
dw,dh):Rect
Defined in: src/grid.ts:444
Inflated rectangle with right border of the original shifted outside by dw and bottom border shifted outside by dh.
Parameters
| Parameter | Type | Description |
|---|---|---|
dw | number | {number} delta width |
dh | number | {number} delta height |
Returns
Rect
move()
move(
dx,dy):Rect
Defined in: src/grid.ts:181
Moves rectangle by the specified offsets.
Parameters
| Parameter | Type |
|---|---|
dx | number |
dy | number |
Returns
Rect
toDart()
toDart():
any
Defined in: src/grid.ts:123
Returns
any
toTheBottom()
toTheBottom(
height):Rect
Defined in: src/grid.ts:344
New rectangle below the original with a height of height. See below.
Parameters
| Parameter | Type | Description |
|---|---|---|
height | number | {number} new rectangle height |
Returns
Rect
toTheLeft()
toTheLeft(
width):Rect
Defined in: src/grid.ts:320
New rectangle to the left of the original with a width of width.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | {number} new rectangle width |
Returns
Rect
toTheRight()
toTheRight(
width):Rect
Defined in: src/grid.ts:328
New rectangle to the right of the original with a width of width.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | {number} new rectangle width |
Returns
Rect
toTheTop()
toTheTop(
height):Rect
Defined in: src/grid.ts:336
New rectangle above the original with a height of height. See above.
Parameters
| Parameter | Type | Description |
|---|---|---|
height | number | {number} new rectangle height |
Returns
Rect
union()
union(
r):Rect
Defined in: src/grid.ts:484
Returns a rectangle that contains both this and r.
Parameters
| Parameter | Type |
|---|---|
r | Rect |
Returns
Rect
fromDart()
staticfromDart(dart):Rect
Defined in: src/grid.ts:110
Parameters
| Parameter | Type |
|---|---|
dart | any |
Returns
Rect
fromPoints()
staticfromPoints(x1,y1,x2,y2):Rect
Defined in: src/grid.ts:88
Parameters
| Parameter | Type |
|---|---|
x1 | number |
y1 | number |
x2 | number |
y2 | number |
Returns
Rect
fromXYArrays()
staticfromXYArrays(x,y):Rect
Defined in: src/grid.ts:94
Parameters
| Parameter | Type |
|---|---|
x | number[] |
y | number[] |
Returns
Rect
toDart()
statictoDart(rect):any
Defined in: src/grid.ts:115
Parameters
| Parameter | Type |
|---|---|
rect | Rect |
Returns
any