Options
All
  • Public
  • Public/Protected
  • All
Menu

Class to represent a rectangle in 2D space

Hierarchy

  • Rect

Index

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

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number

    Returns Rect

Properties

Readonly height

height: number

Gets or sets the height

Readonly width

width: number

Gets or sets the width

Readonly x

x: number

Gets or sets the top left X coordinate

Readonly y

y: number

Gets or sets the top left Y coordinate

Accessors

bottom

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

    Returns number

left

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

    Returns number

right

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

    Returns number

top

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

    Returns number

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

    • rect: Rect

      The rect

    Returns Point

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

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number

    Returns Rect

Static createCopy

  • Clones a rect

    Parameters

    Returns Rect

Static createWithCoords

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

    Parameters

    • left: number
    • top: number
    • right: number
    • bottom: number

    Returns Rect

Static createWithPoints

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

    Parameters

    Returns Rect

Static createZero

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

    Returns Rect

Static isEqual

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

    Parameters

    Returns boolean

Generated using TypeDoc