Options
All
• Public
• Public/Protected
• All

# Class Rect

Class to represent a rectangle in 2D space

• Rect

## Constructors

### constructor

• new Rect(x: number, y: number, width: number, height: number): Rect
• Creates a rect with X,Y,Width,Height

remarks

To create a rect with two points, or with left, top right bottom, see the factory functions Rect.createWithPoints or Rect.createWithCoords

## Properties

height: number

Gets or sets the height

width: number

Gets or sets the width

x: number

Gets or sets the top left X coordinate

y: number

Gets or sets the top left Y coordinate

## Accessors

### bottom

• get bottom(): number
• Gets the bottom edge of the rect

### left

• get left(): number
• Gets the left edge of the rect

### right

• get right(): number
• Gets the right edge of the rect

### top

• get top(): number
• Gets the top edge of the rect

## Methods

### Static clipPointToRect

• Clips a point to the rect, so if the point is outside the rect it will be on the boundary of the rect after this operation

#### Parameters

• ##### point: Point

The point to clip

The rect

### Static create

• create(x: number, y: number, width: number, height: number): Rect
• Creates a rectangle with X,Y top left coordinate and width and height

### Static createCopy

• Clones a rect

### Static createWithCoords

• createWithCoords(left: number, top: number, right: number, bottom: number): Rect
• Creates a rectangle with left, top ,right, bottom

### Static createWithPoints

• Create a rectangle with two points which could be top-left, bottom-right

### Static createZero

• createZero(): Rect
• Creates a zero rect with x,y,w,h = 0

### Static isEqual

• isEqual(rect1: Rect, rect2: Rect): boolean
• Returns true if a rect numerically equals another rect

#### Returns boolean

Generated using TypeDoc