Skip to content

Rectangle

Defined in: util/rectangle.ts:10

The Rectangle class is a utility class used in many different parts of the framework. Please note that there are cases where the framework uses absolute (pixel) measurements, and cases where relative measurements are required (0 being the left/top edges and 1 being the right/bottom edges.)

Please check the documentation of each function to determine the necessary parameters for the Rectangle to be created.

new Rectangle(): Rectangle

Rectangle

getBottom(): number

Defined in: util/rectangle.ts:73

Gets the bottom value

number


getHeight(): number

Defined in: util/rectangle.ts:109

Gets the height value

number


getLeft(): number

Defined in: util/rectangle.ts:37

Gets the left value

number


getRight(): number

Defined in: util/rectangle.ts:55

Gets the right value

number


getTop(): number

Defined in: util/rectangle.ts:19

Gets the top value

number


getWidth(): number

Defined in: util/rectangle.ts:91

Gets the width value

number


setBottom(bottom): Rectangle

Defined in: util/rectangle.ts:78

Sets the bottom value

number

Rectangle


setHeight(height): Rectangle

Defined in: util/rectangle.ts:114

Sets the height value

number

Rectangle


setLeft(left): Rectangle

Defined in: util/rectangle.ts:42

Sets the left value

number

Rectangle


setRight(right): Rectangle

Defined in: util/rectangle.ts:60

Sets the right value

number

Rectangle


setTop(top): Rectangle

Defined in: util/rectangle.ts:24

Sets the top value

number

Rectangle


setWidth(width): Rectangle

Defined in: util/rectangle.ts:96

Sets the width value

number

Rectangle


toCoordinateString(): string

Defined in: util/rectangle.ts:185

return: string

Returns a comma-separated string containing the coordinates in the order: left, top, right, bottom.

string


toDimensionString(): string

Defined in: util/rectangle.ts:175

return: string

Returns a comma-separated string containing the width and height values.

string


toString(value?): string

Defined in: util/rectangle.ts:214

return: string

param: (format ?: string)

Returns a string representation of the Rectangle object. If the format optional parameter is omitted, then this is simply the string from toDimensionString(). Sample usage:

console.log(rect.toString('Origin is at (:left, :top)'));```
You can format the output string by specifying the following markers in
the parameter:
- :left
- :top
- :right
- :bottom
- :width
- :height
#### Parameters
##### value?
`string`
#### Returns
`string`
***
### fromCoordinates()
> `static` **fromCoordinates**(`left`, `top`, `right`, `bottom`): `Rectangle`
Defined in: [util/rectangle.ts:155](https://github.com/SplitmediaLabsLimited/xjs/blob/927d35f9a718e2b9c3aa77475162a90bef8959a5/src/util/rectangle.ts#L155)
param: (left: number, top: number, right: number, bottom: number)

return: Rectangle

Creates a rectangle from coordinates. Absolute (pixels)
and relative (0-1) dimensions are accepted. Refer to the documentation
of each individual function to see which one is necessary.
#### Parameters
##### left
`number`
##### top
`number`
##### right
`number`
##### bottom
`number`
#### Returns
`Rectangle`
***
### fromDimensions()
> `static` **fromDimensions**(`width`, `height`): `Rectangle`
Defined in: [util/rectangle.ts:135](https://github.com/SplitmediaLabsLimited/xjs/blob/927d35f9a718e2b9c3aa77475162a90bef8959a5/src/util/rectangle.ts#L135)
param: (width: number, height: number)

return: Rectangle

Creates a rectangle from width and height dimensions. Absolute (pixels)
and relative (0-1) dimensions are accepted. Refer to the documentation
of each individual function to see which one is necessary.
#### Parameters
##### width
`number`
##### height
`number`
#### Returns
`Rectangle`