# Class: Rectangle

# Hierarchy

  • Shape

    Rectangle

# Constructors

# constructor

+ new Rectangle(): Rectangle

Defined in rectangle.ts:10

Returns: Rectangle

+ new Rectangle(points: object): Rectangle

Defined in rectangle.ts:12

Parameters:

points: object

Name Type
from AnyPoint2D
to AnyPoint2D

Returns: Rectangle

+ new Rectangle(x: number, y: number, width: number, height: number): Rectangle

Defined in rectangle.ts:13

Parameters:

Name Type
x number
y number
width number
height number

Returns: Rectangle

# Properties

# height

height: number = 0

Defined in rectangle.ts:10


# width

width: number = 0

Defined in rectangle.ts:9


# x

x: number = 0

Defined in rectangle.ts:7


# y

y: number = 0

Defined in rectangle.ts:8

# Accessors

# area

get area(): number

Overrides void

Defined in rectangle.ts:50

Returns: number


# bottomLeft

get bottomLeft(): Point2D

Defined in rectangle.ts:74

The bottom-left point of the rectangle.

Returns: Point2D

bottom-left point


# bottomRight

get bottomRight(): Point2D

Defined in rectangle.ts:90

The bottom-right point of the rectangle.

Returns: Point2D

bottom-right point


# bounds

get bounds(): Rectangle

Overrides void

Defined in rectangle.ts:54

Returns: Rectangle


# size

get size(): Point2D

Defined in rectangle.ts:58

Returns: Point2D


# topLeft

get topLeft(): Point2D

Defined in rectangle.ts:66

The top-left point of the rectangle.

Returns: Point2D

top-left point


# topRight

get topRight(): Point2D

Defined in rectangle.ts:82

The top-right point of the rectangle.

Returns: Point2D

top-right point


# xywh

get xywh(): [number, number, number, number]

Defined in rectangle.ts:94

Returns: [number, number, number, number]


# xyxy

get xyxy(): [number, number, number, number]

Defined in rectangle.ts:98

Returns: [number, number, number, number]

# Methods

# contains

contains(a: Point2D): boolean

Defined in rectangle.ts:121

Tests if the specified point is inside the boundary of the rectangle.

Parameters:

Name Type
a Point2D

Returns: boolean

@true if the point is inside the rectangle's boundary

contains(a: Rectangle): boolean

Defined in rectangle.ts:130

Tests if the interior of the rectangle entirely contains the specified rectangle.

Parameters:

Name Type
a Rectangle

Returns: boolean

@true if the rectangle entirely contains the specified rectangle


# include

include(point: Point2D): Rectangle

Defined in rectangle.ts:169

Adds a point to this rectangle. The resulting rectangle is the smallest rectangle that contains both the original rectangle and the specified point.

Parameters:

Name Type Description
point Point2D point to be included

Returns: Rectangle

the smallest rectangle that contains both the original rectangle and the specified point


# polygon

polygon(): Polygon

Defined in rectangle.ts:102

Returns: Polygon


# segmentation

segmentation(): number[]

Defined in rectangle.ts:111

Returns: number[]


# unite

unite(rect: Rectangle): Rectangle

Defined in rectangle.ts:151

Returns a new rectangle representing the union of this rectangle with the specified rectangle.

Parameters:

Name Type Description
rect Rectangle the rectangle to be combined with this rectangle

Returns: Rectangle

the smallest rectangle containing both the specified rectangle and this rectangle