{"version":3,"file":"Ellipse.mjs","sources":["../../src/shapes/Ellipse.ts"],"sourcesContent":["import { SHAPES } from '../const';\nimport { Rectangle } from './Rectangle';\n\n/**\n * The Ellipse object is used to help draw graphics and can also be used to specify a hit area for displayObjects.\n * @memberof PIXI\n */\nexport class Ellipse\n{\n    /** @default 0 */\n    public x: number;\n\n    /** @default 0 */\n    public y: number;\n\n    /** @default 0 */\n    public width: number;\n\n    /** @default 0 */\n    public height: number;\n\n    /**\n     * The type of the object, mainly used to avoid `instanceof` checks\n     * @default PIXI.SHAPES.ELIP\n     * @see PIXI.SHAPES\n     */\n    public readonly type: SHAPES.ELIP;\n\n    /**\n     * @param x - The X coordinate of the center of this ellipse\n     * @param y - The Y coordinate of the center of this ellipse\n     * @param halfWidth - The half width of this ellipse\n     * @param halfHeight - The half height of this ellipse\n     */\n    constructor(x = 0, y = 0, halfWidth = 0, halfHeight = 0)\n    {\n        this.x = x;\n        this.y = y;\n        this.width = halfWidth;\n        this.height = halfHeight;\n\n        this.type = SHAPES.ELIP;\n    }\n\n    /**\n     * Creates a clone of this Ellipse instance\n     * @returns {PIXI.Ellipse} A copy of the ellipse\n     */\n    clone(): Ellipse\n    {\n        return new Ellipse(this.x, this.y, this.width, this.height);\n    }\n\n    /**\n     * Checks whether the x and y coordinates given are contained within this ellipse\n     * @param x - The X coordinate of the point to test\n     * @param y - The Y coordinate of the point to test\n     * @returns Whether the x/y coords are within this ellipse\n     */\n    contains(x: number, y: number): boolean\n    {\n        if (this.width <= 0 || this.height <= 0)\n        {\n            return false;\n        }\n\n        // normalize the coords to an ellipse with center 0,0\n        let normx = ((x - this.x) / this.width);\n        let normy = ((y - this.y) / this.height);\n\n        normx *= normx;\n        normy *= normy;\n\n        return (normx + normy <= 1);\n    }\n\n    /**\n     * Returns the framing rectangle of the ellipse as a Rectangle object\n     * @returns The framing rectangle\n     */\n    getBounds(): Rectangle\n    {\n        return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);\n    }\n\n    // #if _DEBUG\n    toString(): string\n    {\n        return `[pixijs/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;\n    }\n    // #endif\n}\n"],"names":[],"mappings":";;;AAOO,MAAM,OACb,CAAA;AAAA,EA0BI,WAAA,CAAY,IAAI,CAAG,EAAA,CAAA,GAAI,GAAG,SAAY,GAAA,CAAA,EAAG,aAAa,CACtD,EAAA;AACI,IAAA,IAAA,CAAK,CAAI,GAAA,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,CAAI,GAAA,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,KAAQ,GAAA,SAAA,CAAA;AACb,IAAA,IAAA,CAAK,MAAS,GAAA,UAAA,CAAA;AAEd,IAAA,IAAA,CAAK,OAAO,MAAO,CAAA,IAAA,CAAA;AAAA,GACvB;AAAA,EAMA,KACA,GAAA;AACI,IAAO,OAAA,IAAI,QAAQ,IAAK,CAAA,CAAA,EAAG,KAAK,CAAG,EAAA,IAAA,CAAK,KAAO,EAAA,IAAA,CAAK,MAAM,CAAA,CAAA;AAAA,GAC9D;AAAA,EAQA,QAAA,CAAS,GAAW,CACpB,EAAA;AACI,IAAA,IAAI,IAAK,CAAA,KAAA,IAAS,CAAK,IAAA,IAAA,CAAK,UAAU,CACtC,EAAA;AACI,MAAO,OAAA,KAAA,CAAA;AAAA,KACX;AAGA,IAAA,IAAI,KAAU,GAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,IAAK,IAAK,CAAA,KAAA,CAAA;AACjC,IAAA,IAAI,KAAU,GAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,IAAK,IAAK,CAAA,MAAA,CAAA;AAEjC,IAAS,KAAA,IAAA,KAAA,CAAA;AACT,IAAS,KAAA,IAAA,KAAA,CAAA;AAET,IAAA,OAAQ,QAAQ,KAAS,IAAA,CAAA,CAAA;AAAA,GAC7B;AAAA,EAMA,SACA,GAAA;AACI,IAAA,OAAO,IAAI,SAAA,CAAU,IAAK,CAAA,CAAA,GA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