Skip to main content

Rect

Represents a rectangle.

Constructors

new Rect()

new Rect(x, y, width, height): Rect

Parameters

ParameterType
xnumber
ynumber
widthnumber
heightnumber

Returns

Rect

Source

src/grid.ts:73

Properties

PropertyType
heightnumber
widthnumber
xnumber
ynumber

Accessors

bottom

get bottom(): number

Bottom border position of the rectangle along the y-axis.

Returns

number

Source

src/grid.ts:166


left

get left(): number

Left border position of the rectangle along the x-axis.

Returns

number

Source

src/grid.ts:151


maxX

get maxX(): number

Same as (x + width), or (right)

Returns

number

Source

src/grid.ts:142


maxY

get maxY(): number

Same as x + width

Returns

number

Source

src/grid.ts:148


midX

get midX(): number

The midpoint of the rectangle along the x-axis.

Returns

number

Source

src/grid.ts:129


midY

get midY(): number

The midpoint of the rectangle along the y-axis.

Returns

number

Source

src/grid.ts:134


minX

get minX(): number

Same as x

Returns

number

Source

src/grid.ts:139


minY

get minY(): number

Same as (y)

Returns

number

Source

src/grid.ts:145


get right(): number

Right border position of the rectangle along the x-axis.

Returns

number

Source

src/grid.ts:161


top

get top(): number

Top border position of the rectangle along the y-axis.

Returns

number

Source

src/grid.ts:156

Methods

above()

above(height): Rect

New rectangle above the original with a height of height.

Parameters

ParameterTypeDescription
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:305


below()

below(height): Rect

New rectangle below the original with a height of height.

Parameters

ParameterTypeDescription
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:298


contains()

contains(x, y): boolean

Checks if this Rect contains the point (x; y) inside

Parameters

ParameterType
xnumber
ynumber

Returns

boolean

Source

src/grid.ts:466


containsPoint()

containsPoint(p): boolean

Checks if this Rect contains the specified point

Parameters

ParameterType
pPoint

Returns

boolean

Source

src/grid.ts:471


cutBottom()

cutBottom(dh): Rect

New rectangle with the same top border as the original, but with the bottom border clipped by dh.

Parameters

ParameterTypeDescription
dhnumber{number} delta height

Returns

Rect

Source

src/grid.ts:281


cutLeft()

cutLeft(dw): Rect

New rectangle with the same right border as the original, but with the left border clipped by dw.

Parameters

ParameterTypeDescription
dwnumber{number} delta width

Returns

Rect

Source

src/grid.ts:265


cutRight()

cutRight(dw): Rect

New rectangle with the same left border as the original, but with the right border clipped by dw.

Parameters

ParameterTypeDescription
dwnumber{number} delta width

Returns

Rect

Source

src/grid.ts:289


cutTop()

cutTop(dh): Rect

New rectangle with the same bottom border as the original, but with the top border clipped by dh.

Parameters

ParameterTypeDescription
dhnumber{number} delta height

Returns

Rect

Source

src/grid.ts:273


fit()

fit(width, height): Rect

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

ParameterType
widthnumber
heightnumber

Returns

Rect

Source

src/grid.ts:459


fitSquare()

fitSquare(): Rect

Square fitted (inscribed) to the original rectangle

Returns

Rect

Source

src/grid.ts:451


fromCenterSize()

fromCenterSize(cx, cy, width, height): Rect

Rectangle of the specified size, with the specified center

Parameters

ParameterType
cxnumber
cynumber
widthnumber
heightnumber

Returns

Rect

Source

src/grid.ts:124


getBottom()

getBottom(height): Rect

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

ParameterTypeDescription
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:193


getBottomLeft()

getBottomLeft(width, height): Rect

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

ParameterTypeDescription
widthnumber{number} new rectangle width
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:244


getBottomRight()

getBottomRight(width, height): Rect

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

ParameterTypeDescription
widthnumber{number} new rectangle width
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:255


getBottomScaled()

getBottomScaled(ratio): Rect

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

ParameterTypeDescription
rationumber{number} height scale factor

Returns

Rect

Source

src/grid.ts:356


getGridPart()

getGridPart(xCount, yCount, x, y): Rect

Returns (x, y) part of the original rectangle divided into parts by a grid.

Parameters

ParameterTypeDescription
xCountnumber{number} dividing grid size along x-axis
yCountnumber{number} dividing grid size along y-axis
xnumber{number} index of part to return along x-axis
ynumber{number} index of part to return along y-axis

Returns

Rect

Source

src/grid.ts:409


getLeft()

getLeft(width): Rect

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

ParameterTypeDescription
widthnumber{number} new rectangle width

Returns

Rect

Source

src/grid.ts:203


getLeftPart()

getLeftPart(count, index): Rect

Vertical part of index of the original rectangle slices on count parts.

Parameters

ParameterTypeDescription
countnumber{number} count of parts to divide rectangle horizontally
indexnumber{number} index of part to return

Returns

Rect

Source

src/grid.ts:396


getLeftScaled()

getLeftScaled(ratio): Rect

New rectangle with the same left border as the original, but with a width scaled with ratio of original width. See also getLeft.

Parameters

ParameterTypeDescription
rationumber{number} width scale factor

Returns

Rect

Source

src/grid.ts:365


getRight()

getRight(width): Rect

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

ParameterTypeDescription
widthnumber{number} new rectangle width

Returns

Rect

Source

src/grid.ts:213


getRightScaled()

getRightScaled(ratio): Rect

New rectangle with the same right border as the original, but with a width scaled with ratio of original width. See also getRight.

Parameters

ParameterTypeDescription
rationumber{number} width scale factor

Returns

Rect

Source

src/grid.ts:374


getTop()

getTop(height): Rect

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

ParameterTypeDescription
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:183


getTopLeft()

getTopLeft(width, height): Rect

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

ParameterTypeDescription
widthnumber{number} new rectangle width
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:223


getTopPart()

getTopPart(count, index): Rect

Horizontal part of index of the original rectangle sliced on count parts.

Parameters

ParameterTypeDescription
countnumber{number} count of parts to divide the rectangle vertically
indexnumber{number} index of part to return

Returns

Rect

Source

src/grid.ts:385


getTopRight()

getTopRight(width, height): Rect

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

ParameterTypeDescription
widthnumber{number} new rectangle width
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:233


getTopScaled()

getTopScaled(ratio): Rect

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

ParameterTypeDescription
rationumber{number} height scale factor

Returns

Rect

Source

src/grid.ts:347


inflate()

inflate(dx, dy): Rect

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 2dx along x-axis, and by 2dy along y-axis.

Parameters

ParameterTypeDescription
dxnumber{number} vertical borders shift delta along x-axis
dynumber{number} horizontal borders shift delta along y-axis

Returns

Rect

Source

src/grid.ts:424


inflateRel()

inflateRel(dxRatio, dyRatio): Rect

Inflated rectangle with new width scaled by dxRatio of the original and height scaled by dyRatio.

Parameters

ParameterTypeDescription
dxRationumber{number} width scale ratio
dyRationumber{number} height scale ratio

Returns

Rect

Source

src/grid.ts:446


inflateSize()

inflateSize(dw, dh): Rect

Inflated rectangle with right border of the original shifted outside by dw and bottom border shifted outside by dh.

Parameters

ParameterTypeDescription
dwnumber{number} delta width
dhnumber{number} delta height

Returns

Rect

Source

src/grid.ts:436


move()

move(dx, dy): Rect

Moves rectangle by the specified offsets.

Parameters

ParameterType
dxnumber
dynumber

Returns

Rect

Source

src/grid.ts:173


toDart()

toDart(): any

Returns

any

Source

src/grid.ts:115


toTheBottom()

toTheBottom(height): Rect

New rectangle below the original with a height of height. See below.

Parameters

ParameterTypeDescription
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:336


toTheLeft()

toTheLeft(width): Rect

New rectangle to the left of the original with a width of width.

Parameters

ParameterTypeDescription
widthnumber{number} new rectangle width

Returns

Rect

Source

src/grid.ts:312


toTheRight()

toTheRight(width): Rect

New rectangle to the right of the original with a width of width.

Parameters

ParameterTypeDescription
widthnumber{number} new rectangle width

Returns

Rect

Source

src/grid.ts:320


toTheTop()

toTheTop(height): Rect

New rectangle above the original with a height of height. See above.

Parameters

ParameterTypeDescription
heightnumber{number} new rectangle height

Returns

Rect

Source

src/grid.ts:328


union()

union(r): Rect

Returns a rectangle that contains both this and r.

Parameters

ParameterType
rRect

Returns

Rect

Source

src/grid.ts:476


fromDart()

static fromDart(dart): Rect

Parameters

ParameterType
dartany

Returns

Rect

Source

src/grid.ts:102


fromPoints()

static fromPoints(x1, y1, x2, y2): Rect

Parameters

ParameterType
x1number
y1number
x2number
y2number

Returns

Rect

Source

src/grid.ts:80


fromXYArrays()

static fromXYArrays(x, y): Rect

Parameters

ParameterType
xnumber[]
ynumber[]

Returns

Rect

Source

src/grid.ts:86


toDart()

static toDart(rect): any

Parameters

ParameterType
rectRect

Returns

any

Source

src/grid.ts:107