melonJS
    Preparing search index...

    Class RoundRect

    a rectangle object with rounded corners

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • x: number

        position of the rounded rectangle

      • y: number

        position of the rounded rectangle

      • width: number

        the rectangle width

      • height: number

        the rectangle height

      • Optionalradius: number = DEFAULT_RADIUS

        the radius of the rounded corner

      Returns RoundRect

    Properties

    _height: number

    stored height

    _radius: number

    Corner radius.

    _width: number

    stored width

    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 rectangle

      Parameters

      • rectangle: { bottom: number; left: number; right: number; top: number }

        rectangle to test

        • bottom: number

          bottom coordinate

        • left: number

          left coordinate

        • right: number

          right coordinate

        • top: number

          top coordinate

      Returns boolean

      true if contained

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

      Returns boolean | null

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

    • Scales the polygon by the given factors along the x and y axes.

      Parameters

      • x: number

        The factor by which to scale the polygon along the x-axis.

      • Optionaly: number = x

        The factor by which to scale the polygon along the y-axis. Defaults to the value of x.

      Returns RoundRect

      Reference to this object for method chaining

    • set new value to the Polygon

      Parameters

      • x: number

        position of the Polygon

      • y: number

        position of the Polygon

      • points: PolygonVertices | LineVertices

        array of vector or vertices defining the Polygon

      Returns RoundRect

      this instance for object chaining

    • Shifts the Polygon to the given position vector.

      Parameters

      • x: number

        The x coordinate or a vector point to shift to.

      • Optionaly: number

        The y coordinate. This parameter is required if the first parameter is a number.

      Returns void

      polygon.shift(10, 10);
      // or
      polygon.shift(myVector2d);
    • Shifts the Polygon to the given position vector.

      Parameters

      Returns void

      polygon.shift(10, 10);
      // or
      polygon.shift(myVector2d);