Class RoundRect

a rectangle object with rounded corners

Hierarchy (view full)

Constructors

Properties

_radius: number

Corner radius.

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: number[]

a list of indices for all vertices composing this polygon

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.

origin point of the Polygon

type: string = "RoundRect"

the shape type (used internally)

Accessors

Methods

  • Returns true if the rounded rectangle contains the given point or rectangle

    Parameters

    • x: number

      x coordinate or a vector point, or a Rect to test

    • Optionaly: number

      y coordinate

    Returns boolean

    True if the rounded rectangle contain the given point or rectangle, otherwise false

    if (rect.contains(10, 10)) {
    // do something
    }
    // or
    if (rect.contains(myVector2d)) {
    // do something
    }
    if (rect.contains(myRect)) {
    // do something
    }
  • 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

    if (polygon.contains(10, 10)) {
    // do something
    }
    // or
    if (polygon.contains(myVector2d)) {
    // do something
    }
  • 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

    if (rect.containsRectangle(myRect)) {
    // do something
    }
  • 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