# Class: Rectangle

# Hierarchy

  • Shape

    Rectangle

# Constructors

# constructor

+ new Rectangle(): Rectangle

Defined in rectangle.ts:10 (opens new window)

Returns: Rectangle

+ new Rectangle(points: object): Rectangle

Defined in rectangle.ts:12 (opens new window)

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 (opens new window)

Parameters:

Name Type
x number
y number
width number
height number

Returns: Rectangle

# Properties

# height

height: number = 0

Defined in rectangle.ts:10 (opens new window)


# width

width: number = 0

Defined in rectangle.ts:9 (opens new window)


# x

x: number = 0

Defined in rectangle.ts:7 (opens new window)


# y

y: number = 0

Defined in rectangle.ts:8 (opens new window)

# Accessors

# area

get area(): number

Overrides void

Defined in rectangle.ts:50 (opens new window)

Returns: number


# bottomLeft

get bottomLeft(): Point2D

Defined in rectangle.ts:74 (opens new window)

The bottom-left point of the rectangle.

Returns: Point2D

bottom-left point


# bottomRight

get bottomRight(): Point2D

Defined in rectangle.ts:90 (opens new window)

The bottom-right point of the rectangle.

Returns: Point2D

bottom-right point


# bounds

get bounds(): Rectangle

Overrides void

Defined in rectangle.ts:54 (opens new window)

Returns: Rectangle


# size

get size(): Point2D

Defined in rectangle.ts:58 (opens new window)

Returns: Point2D


# topLeft

get topLeft(): Point2D

Defined in rectangle.ts:66 (opens new window)

The top-left point of the rectangle.

Returns: Point2D

top-left point


# topRight

get topRight(): Point2D

Defined in rectangle.ts:82 (opens new window)

The top-right point of the rectangle.

Returns: Point2D

top-right point


# xywh

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

Defined in rectangle.ts:94 (opens new window)

Returns: [number, number, number, number]


# xyxy

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

Defined in rectangle.ts:98 (opens new window)

Returns: [number, number, number, number]

# Methods

# contains

contains(a: Point2D): boolean

Defined in rectangle.ts:121 (opens new window)

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 (opens new window)

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 (opens new window)

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 (opens new window)

Returns: Polygon


# segmentation

segmentation(): number[]

Defined in rectangle.ts:111 (opens new window)

Returns: number[]


# unite

unite(rect: Rectangle): Rectangle

Defined in rectangle.ts:151 (opens new window)

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