Skip to main content

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

ParameterType
xnumber
ynumber
widthnumber
heightnumber

Returns

Rect

Properties

PropertyTypeDefined in
heightnumbersrc/grid.ts:79
widthnumbersrc/grid.ts:78
xnumbersrc/grid.ts:76
ynumbersrc/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


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

ParameterTypeDescription
heightnumber{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

ParameterTypeDescription
heightnumber{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

ParameterType
xnumber
ynumber

Returns

boolean


containsPoint()

containsPoint(p): boolean

Defined in: src/grid.ts:479

Checks if this Rect contains the specified point

Parameters

ParameterType
pPoint

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

ParameterTypeDescription
dhnumber{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

ParameterTypeDescription
dwnumber{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

ParameterTypeDescription
dwnumber{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

ParameterTypeDescription
dhnumber{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

ParameterType
widthnumber
heightnumber

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

ParameterType
cxnumber
cynumber
widthnumber
heightnumber

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

ParameterTypeDescription
heightnumber{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

ParameterTypeDescription
widthnumber{number} new rectangle width
heightnumber{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

ParameterTypeDescription
widthnumber{number} new rectangle width
heightnumber{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

ParameterTypeDescription
rationumber{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

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


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

ParameterTypeDescription
widthnumber{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

ParameterTypeDescription
countnumber{number} count of parts to divide rectangle horizontally
indexnumber{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

ParameterTypeDescription
rationumber{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

ParameterTypeDescription
widthnumber{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

ParameterTypeDescription
rationumber{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

ParameterTypeDescription
heightnumber{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

ParameterTypeDescription
widthnumber{number} new rectangle width
heightnumber{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

ParameterTypeDescription
countnumber{number} count of parts to divide the rectangle vertically
indexnumber{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

ParameterTypeDescription
widthnumber{number} new rectangle width
heightnumber{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

ParameterTypeDescription
rationumber{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

ParameterTypeDescription
dxnumber{number} vertical borders shift delta along x-axis
dynumber{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

ParameterTypeDescription
dxRationumber{number} width scale ratio
dyRationumber{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

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

Returns

Rect


move()

move(dx, dy): Rect

Defined in: src/grid.ts:181

Moves rectangle by the specified offsets.

Parameters

ParameterType
dxnumber
dynumber

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

ParameterTypeDescription
heightnumber{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

ParameterTypeDescription
widthnumber{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

ParameterTypeDescription
widthnumber{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

ParameterTypeDescription
heightnumber{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

ParameterType
rRect

Returns

Rect


fromDart()

static fromDart(dart): Rect

Defined in: src/grid.ts:110

Parameters

ParameterType
dartany

Returns

Rect


fromPoints()

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

Defined in: src/grid.ts:88

Parameters

ParameterType
x1number
y1number
x2number
y2number

Returns

Rect


fromXYArrays()

static fromXYArrays(x, y): Rect

Defined in: src/grid.ts:94

Parameters

ParameterType
xnumber[]
ynumber[]

Returns

Rect


toDart()

static toDart(rect): any

Defined in: src/grid.ts:115

Parameters

ParameterType
rectRect

Returns

any