Skip to main content

Rect

Defined in: js-api/src/grid.ts:78

Represents a rectangle.

Constructors​

Constructor​

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

Defined in: js-api/src/grid.ts:84

Parameters​

ParameterType
xnumber
ynumber
widthnumber
heightnumber

Returns​

Rect

Properties​

PropertyTypeDefined in
heightnumberjs-api/src/grid.ts:82
widthnumberjs-api/src/grid.ts:81
xnumberjs-api/src/grid.ts:79
ynumberjs-api/src/grid.ts:80

Accessors​

bottom​

Get Signature​

get bottom(): number

Defined in: js-api/src/grid.ts:182

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

Returns​

number


left​

Get Signature​

get left(): number

Defined in: js-api/src/grid.ts:167

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

Returns​

number


maxX​

Get Signature​

get maxX(): number

Defined in: js-api/src/grid.ts:158

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

Returns​

number


maxY​

Get Signature​

get maxY(): number

Defined in: js-api/src/grid.ts:164

Same as (y + height), or (bottom)

Returns​

number


midX​

Get Signature​

get midX(): number

Defined in: js-api/src/grid.ts:145

The midpoint of the rectangle along the x-axis.

Returns​

number


midY​

Get Signature​

get midY(): number

Defined in: js-api/src/grid.ts:150

The midpoint of the rectangle along the y-axis.

Returns​

number


minX​

Get Signature​

get minX(): number

Defined in: js-api/src/grid.ts:155

Same as x

Returns​

number


minY​

Get Signature​

get minY(): number

Defined in: js-api/src/grid.ts:161

Same as (y)

Returns​

number


Get Signature​

get right(): number

Defined in: js-api/src/grid.ts:177

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

Returns​

number


top​

Get Signature​

get top(): number

Defined in: js-api/src/grid.ts:172

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

Returns​

number

Methods​

above()​

above(height): Rect

Defined in: js-api/src/grid.ts:307

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: js-api/src/grid.ts:301

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: js-api/src/grid.ts:454

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

Parameters​

ParameterType
xnumber
ynumber

Returns​

boolean


containsPoint()​

containsPoint(p): boolean

Defined in: js-api/src/grid.ts:459

Checks if this Rect contains the specified point

Parameters​

ParameterType
pPoint

Returns​

boolean


cutBottom()​

cutBottom(dh): Rect

Defined in: js-api/src/grid.ts:286

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: js-api/src/grid.ts:272

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: js-api/src/grid.ts:293

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: js-api/src/grid.ts:279

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: js-api/src/grid.ts:447

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: js-api/src/grid.ts:439

Square fitted (inscribed) to the original rectangle

Returns​

Rect


fromCenterSize()​

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

Defined in: js-api/src/grid.ts:140

Parameters​

ParameterType
cxnumber
cynumber
widthnumber
heightnumber

Returns​

Rect

Deprecated​

Use the static Rect.fromCenterSize; this instance form ignores the receiver. Removed in 1.29.


getBottom()​

getBottom(height): Rect

Defined in: js-api/src/grid.ts:207

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: js-api/src/grid.ts:253

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: js-api/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: js-api/src/grid.ts:352

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: js-api/src/grid.ts:400

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: js-api/src/grid.ts:216

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: js-api/src/grid.ts:388

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: js-api/src/grid.ts:360

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: js-api/src/grid.ts:225

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: js-api/src/grid.ts:368

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: js-api/src/grid.ts:198

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: js-api/src/grid.ts:234

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: js-api/src/grid.ts:378

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: js-api/src/grid.ts:243

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: js-api/src/grid.ts:344

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: js-api/src/grid.ts:414

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: js-api/src/grid.ts:434

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: js-api/src/grid.ts:425

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: js-api/src/grid.ts:189

Moves rectangle by the specified offsets.

Parameters​

ParameterType
dxnumber
dynumber

Returns​

Rect


toDart()​

toDart(): any

Defined in: js-api/src/grid.ts:126

Returns​

any


toTheBottom()​

toTheBottom(height): Rect

Defined in: js-api/src/grid.ts:334

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: js-api/src/grid.ts:313

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: js-api/src/grid.ts:320

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: js-api/src/grid.ts:327

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: js-api/src/grid.ts:464

Returns a rectangle that contains both this and r.

Parameters​

ParameterType
rRect

Returns​

Rect


fromCenterSize()​

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

Defined in: js-api/src/grid.ts:135

Rectangle of the specified size, with the specified center.

Parameters​

ParameterType
cxnumber
cynumber
widthnumber
heightnumber

Returns​

Rect


fromDart()​

static fromDart(dart): Rect

Defined in: js-api/src/grid.ts:113

Parameters​

ParameterType
dartany

Returns​

Rect


fromPoints()​

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

Defined in: js-api/src/grid.ts:91

Parameters​

ParameterType
x1number
y1number
x2number
y2number

Returns​

Rect


fromXYArrays()​

static fromXYArrays(x, y): Rect

Defined in: js-api/src/grid.ts:97

Parameters​

ParameterType
xnumber[]
ynumber[]

Returns​

Rect


toDart()​

static toDart(rect): any

Defined in: js-api/src/grid.ts:118

Parameters​

ParameterType
rectRect

Returns​

any