PokéRogue
    Preparing search index...

    An Ellipse object.

    An Ellipse is defined by its center position (x, y), a total width, and a total height. It can be used for geometric intersection tests (point-in-ellipse containment), sampling evenly-spaced or random points on its circumference or interior, and as a lightweight shape descriptor for collision or hit-area purposes.

    This is a geometry object, containing numerical values and related methods to inspect and modify them. It is not a Game Object, in that you cannot add it to the display list, and it has no texture. To render an Ellipse you should look at the capabilities of the Graphics class.

    Index
    • Parameters

      • Optionalx: number

        The x position of the center of the ellipse. Default 0.

      • Optionaly: number

        The y position of the center of the ellipse. Default 0.

      • Optionalwidth: number

        The width of the ellipse. Default 0.

      • Optionalheight: number

        The height of the ellipse. Default 0.

      Returns Ellipse

    bottom: number

    The bottom position of the Ellipse.

    height: number

    The height of the ellipse.

    left: number

    The left position of the Ellipse.

    right: number

    The right position of the Ellipse.

    top: number

    The top position of the Ellipse.

    type: number

    The geometry constant type of this object: GEOM_CONST.ELLIPSE. Used for fast type comparisons.

    width: number

    The width of the ellipse.

    x: number

    The x position of the center of the ellipse.

    y: number

    The y position of the center of the ellipse.

    • Check to see if the Ellipse contains the given x / y coordinates.

      Parameters

      • x: number

        The x coordinate to check within the ellipse.

      • y: number

        The y coordinate to check within the ellipse.

      Returns boolean

      True if the coordinates are within the ellipse, otherwise false.

    • Returns the major radius of the ellipse. Also known as the Semi Major Axis.undefined

      Returns number

      The major radius.

    • Returns the minor radius of the ellipse. Also known as the Semi Minor Axis.undefined

      Returns number

      The minor radius.

    • Returns a Vector2 object containing the coordinates of a point on the circumference of the Ellipse based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point at 180 degrees around the ellipse.

      Type Parameters

      Parameters

      • position: number

        A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse.

      • Optionalpoint: Vector2

        A Vector2 to store the return values in. If not given a Vector2 object will be created.

      Returns O

      A Vector2 instance containing the coordinates of the point around the ellipse.

    • Returns an array of Vector2 objects containing the coordinates of the points around the circumference of the Ellipse, based on the given quantity or stepRate values.

      Type Parameters

      Parameters

      • quantity: number

        The amount of points to return. If a falsey value the quantity will be derived from the stepRate instead.

      • OptionalstepRate: number

        Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate.

      • Optionaloutput: O

        An array to insert the Vector2s in. If not provided a new array will be created.

      Returns O

      An array of Vector2 objects pertaining to the points around the circumference of the ellipse.

    • Returns a uniformly distributed random point from anywhere within the given Ellipse.

      Type Parameters

      Parameters

      • Optionalvec: Vector2

        A Vector2 object to set the random x and y values in.

      Returns O

      A Vector2 object with the random values set in the x and y properties.

    • Checks to see if the Ellipse is empty: has a width or height of zero or less.undefined

      Returns boolean

      True if the Ellipse is empty, otherwise false.

    • Sets this Ellipse to be empty with a width and height of zero. Does not change its position.undefined

      Returns this

      This Ellipse object.

    • Sets the position of this Ellipse. If the y argument is omitted, both the x and y positions will be set to the value of x.

      Parameters

      • x: number

        The x position of the center of the ellipse.

      • y: number

        The y position of the center of the ellipse.

      Returns this

      This Ellipse object.

    • Sets the size of this Ellipse. Does not change its position. If the height argument is omitted it will be set equal to width, producing a circle.

      Parameters

      • width: number

        The width of the ellipse.

      • Optionalheight: number

        The height of the ellipse. Default width.

      Returns this

      This Ellipse object.

    • Sets the x, y, width and height of this ellipse.

      Parameters

      • x: number

        The x position of the center of the ellipse.

      • y: number

        The y position of the center of the ellipse.

      • width: number

        The width of the ellipse.

      • height: number

        The height of the ellipse.

      Returns this

      This Ellipse object.

    • Calculates the area of the given Ellipse using the formula: π × majorRadius × minorRadius. Returns 0 if the Ellipse is empty (i.e. has no width or height).

      Parameters

      • ellipse: Ellipse

        The Ellipse to get the area of.

      Returns number

      The area of the Ellipse, or 0 if the Ellipse is empty.

    • Returns the circumference of the given Ellipse.

      Parameters

      • ellipse: Ellipse

        The Ellipse to get the circumference of.

      Returns number

      The circumference of the Ellipse.

    • Returns a Vector2 containing the coordinates of a point on the circumference of the Ellipse based on the given angle.

      Type Parameters

      Parameters

      • ellipse: Ellipse

        The Ellipse to get the circumference point on.

      • angle: number

        The angle from the center of the Ellipse to the circumference to return the point from. Given in radians.

      • Optionalout: O

        A Vector2 to store the results in. If not given a Vector2 will be created.

      Returns O

      A Vector2 object where the x and y properties are the point on the circumference.

    • Creates a new Ellipse instance based on the values contained in the given source.

      Parameters

      • source: Ellipse

        The Ellipse to be cloned. Can be an instance of an Ellipse or an ellipse-like object, with x, y, width and height properties.

      Returns Ellipse

      A clone of the source Ellipse.

    • Check to see if the Ellipse contains the given x / y coordinates.

      Parameters

      • ellipse: Ellipse

        The Ellipse to check.

      • x: number

        The x coordinate to check within the ellipse.

      • y: number

        The y coordinate to check within the ellipse.

      Returns boolean

      True if the coordinates are within the ellipse, otherwise false.

    • Check to see if the Ellipse contains the given x and y coordinates as stored in the Vector2.

      Parameters

      • ellipse: Ellipse

        The Ellipse to check.

      • vec: Vector2

        The Vector2 object to check if its coordinates are within the Ellipse or not.

      Returns boolean

      True if the Vector2 coordinates are within the ellipse, otherwise false.

    • Check to see if the Ellipse contains all four points of the given Rectangle object.

      Parameters

      • ellipse: Ellipse

        The Ellipse to check.

      • rect: object | Rectangle

        The Rectangle object to check if it's within the Ellipse or not.

      Returns boolean

      True if all of the Rectangle coordinates are within the ellipse, otherwise false.

    • Copies the x, y, width and height properties from the source Ellipse into the given dest Ellipse, then returns the dest Ellipse.

      Type Parameters

      Parameters

      • source: Ellipse

        The source Ellipse to copy the values from.

      • dest: O

        The destination Ellipse to copy the values to.

      Returns O

      The destination Ellipse.

    • Compares the x, y, width and height properties of the two given Ellipses. Returns true if they all match, otherwise returns false.

      Parameters

      • ellipse: Ellipse

        The first Ellipse to compare.

      • toCompare: Ellipse

        The second Ellipse to compare.

      Returns boolean

      true if the two Ellipse equal each other, otherwise false.

    • Returns the bounds of the Ellipse object.

      Type Parameters

      Parameters

      • ellipse: Ellipse

        The Ellipse to get the bounds from.

      • Optionalout: O

        A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created.

      Returns O

      The Rectangle object containing the Ellipse bounds.

    • Returns a Vector2 object containing the coordinates of a point on the circumference of the Ellipse based on the given angle normalized to the range 0 to 1. i.e. a value of 0.5 will give the point at 180 degrees around the ellipse.

      Type Parameters

      Parameters

      • ellipse: Ellipse

        The Ellipse to get the circumference point on.

      • position: number

        A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 degrees around the ellipse.

      • Optionalout: O

        A Vector2 object to store the return values in. If not given a new Vector2 object will be created.

      Returns O

      A Vector2 object, containing the coordinates of the point around the ellipse.

    • Returns an array of Vector2 objects containing the coordinates of the points around the circumference of the Ellipse, based on the given quantity or stepRate values.

      Type Parameters

      Parameters

      • ellipse: Ellipse

        The Ellipse to get the points from.

      • quantity: number

        The amount of points to return. If a falsy value the quantity will be derived from the stepRate instead.

      • OptionalstepRate: number

        Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate.

      • Optionalout: O

        An array to insert the Vector2 objects into. If not provided a new array will be created.

      Returns O

      An array of Vector2 objects pertaining to the points around the circumference of the ellipse.

    • Offsets the Ellipse by the values given.

      Type Parameters

      Parameters

      • ellipse: O

        The Ellipse to be offset (translated).

      • x: number

        The amount to horizontally offset the Ellipse by.

      • y: number

        The amount to vertically offset the Ellipse by.

      Returns O

      The Ellipse that was offset.

    • Offsets the Ellipse by the values given in the x and y properties of the Vector2 object.

      Type Parameters

      Parameters

      • ellipse: O

        The Ellipse to be offset (translated.)

      • vec: Vector2

        The Vector2 object containing the values to offset the Ellipse by.

      Returns O

      The Ellipse that was offset.

    • Returns a uniformly distributed random point from anywhere within the given Ellipse.

      Type Parameters

      Parameters

      • ellipse: Ellipse

        The Ellipse to get a random point from.

      • Optionalout: O

        A Vector2 object to set the random x and y values in.

      Returns O

      A Vector2 object with the random values set in the x and y properties.