Class Rect

The Rect is normally expressed as a top-left corner and a size.

Hierarchy

  • Rect

Constructors

  • Constructs a rect with (x, y) as its top-left corner and the given width and height.

    Parameters

    • x: number = 0
    • y: number = 0
    • width: number = 0
    • height: number = 0

    Returns Rect

Properties

m_x1: number
m_x2: number
m_y1: number
m_y2: number

Accessors

  • get bottom(): number
  • Returns the y-coordinate of the rect's bottom edge.

    Returns number

  • set bottom(pos): void
  • Sets the bottom edge of the rect to the given pos.

    Parameters

    • pos: number

    Returns void

  • get bottomLeft(): Point
  • Returns the position of the rect's bottom-left corner.

    Returns Point

  • get bottomRight(): Point
  • Returns the position of the rect's bottom-right corner.

    Returns Point

  • get center(): Point
  • Returns the center point of the rect.

    Returns Point

  • get height(): number
  • Returns the height of the rect.

    Returns number

  • set height(h): void
  • Sets the height of the rect to the given h. The bottom edge is changed, but not the top one.

    Parameters

    • h: number

    Returns void

  • get left(): number
  • Returns the x-coordinate of the rect's left edge. Equivalent to x.

    Returns number

  • set left(pos): void
  • Sets the left edge of the rect to the given pos.

    Parameters

    • pos: number

    Returns void

  • get right(): number
  • Returns the x-coordinate of the rect's right edge.

    Returns number

  • set right(pos): void
  • Sets the right edge of the rect to the given pos.

    Parameters

    • pos: number

    Returns void

  • get size(): Size
  • Returns the size of the rect.

    Returns Size

  • get top(): number
  • Returns the y-coordinate of the rect's top edge. Equivalent to y.

    Returns number

  • set top(pos): void
  • Sets the top edge of the rect to the given pos.

    Parameters

    • pos: number

    Returns void

  • get topLeft(): Point
  • Returns the position of the rect's top-left corner.

    Returns Point

  • get topRight(): Point
  • Returns the position of the rect's top-right corner.

    Returns Point

  • get width(): number
  • Returns the width of the rect.

    Returns number

  • set width(w): void
  • Sets the width of the rect to the given w. The right edge is changed, but not the left one.

    Parameters

    • w: number

    Returns void

  • get x(): number
  • Returns number

  • set x(x): void
  • Equivalent to left.

    Parameters

    • x: number

    Returns void

  • get y(): number
  • Returns number

  • set y(y): void
  • Equivalent to top.

    Parameters

    • y: number

    Returns void

Methods

  • Returns a copy of this rect.

    Returns Rect

  • Returns true if this rect and other are equal; otherwise returns false.

    Parameters

    Returns boolean

  • Returns true if the given p is inside or on the edge of the rect, otherwise returns false.

    Parameters

    • p: Point
    • proper: boolean = false

      The default value is false. If proper is true, this function only returns true if the given p is inside the rect (i.e., not on the edge).

    Returns boolean

  • Copies the other rect to this rect.

    Parameters

    Returns void

  • Returns true if both the width and height is 0, otherwise returns false.

    Returns boolean

  • Returns true if the rect is valid(left <= right && top <= bottom), otherwise returns false.

    Returns boolean

  • Moves the rect horizontally, leaving the rect's left edge at the given x coordinate.

    Parameters

    • left: number

    Returns void

  • Moves the rect horizontally, leaving the rect's right edge at the given x coordinate.

    Parameters

    • right: number

    Returns void

  • Moves the rect, leaving the top-left corner at the given position (x, y).

    Parameters

    • x: number
    • y: number

    Returns void

  • Moves dx along the x axis and dy along the y axis, relative to the current position.

    Parameters

    • dx: number
    • dy: number

    Returns void

  • Returns a copy of the rect that is translated dx along the x axis and dy along the y axis, relative to the current position.

    Parameters

    • dx: number
    • dy: number

    Returns Rect

  • Constructs a rect with the given topLeft and bottomRight corners.

    Parameters

    Returns Rect

Generated using TypeDoc