Class Rect

A rectangle object.

Hierarchy (view full)

Constructors

constructor

Properties

edges

edges: Vector2d []

The edges here are the direction of the nth edge of the polygon, relative to the nth point. If you want to draw a given edge from the edge value, you must first translate to the position of the starting point.

indices

indices: number[]

a list of indices for all vertices composing this polygon

points

points: Vector2d []

Array of points defining the Polygon
Note: If you manually change points, you must call recalcafterwards so that the changes get applied correctly.

pos

pos: Vector2d

origin point of the Polygon

type

type: string = "Rectangle"

The shape type (used internally).

Accessors

bottom

centerX

centerY

height

left

right

top

width

Methods

centerOn

  • centerOn(x, y): Rect
  • center the rectangle position around the given coordinates

    Parameters

    • x: number

      the x coordinate around which to center this rectangle

    • y: number

      the y coordinate around which to center this rectangle

    Returns Rect

    this rectangle

clone

contains

  • contains(x, y): boolean
  • Returns true if the polygon contains the given point.
    (Note: it is highly recommended to first do a hit test on the corresponding
    bounding rect, as the function can be highly consuming with complex shapes)

    Parameters

    • x: number

      x coordinate or a vector point to check

    • y: number

      y coordinate

    Returns boolean

    True if the polygon contain the point, otherwise false

    Example

    if (polygon.contains(10, 10)) {
    // do something
    }
    // or
    if (polygon.contains(myVector2d)) {
    // do something
    }
  • contains(vector): boolean
  • Returns true if the polygon contains the given point.
    (Note: it is highly recommended to first do a hit test on the corresponding
    bounding rect, as the function can be highly consuming with complex shapes)

    Parameters

    Returns boolean

    True if the polygon contain the point, otherwise false

    Example

    if (polygon.contains(10, 10)) {
    // do something
    }
    // or
    if (polygon.contains(myVector2d)) {
    // do something
    }

containsRectangle

  • containsRectangle(rectangle): boolean
  • Returns true if the rectangle contains the given rectangle

    Parameters

    • rectangle: Rect

      rectangle to test

    Returns boolean

    True if the rectangle contain the given rectangle, otherwise false

    Example

    if (rect.containsRectangle(myRect)) {
    // do something
    }

copy

equals

getBounds

getIndices

isConvex

  • isConvex(): null | boolean
  • Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).

    Returns null | boolean

    true if the vertices are convex, false if not, null if not computable

isFinite

  • isFinite(): boolean
  • Determines whether all coordinates of this rectangle are finite numbers.

    Returns boolean

    false if all coordinates are positive or negative Infinity or NaN; otherwise, true.

overlaps

recalc

resize

rotate

scale

scaleV

setShape

setSize

setVertices

shift

to2d

toIso

toPolygon

transform

translate

union

updateBounds

Settings

Member Visibility

On This Page

AltStyle によって変換されたページ (->オリジナル) /