'use strict'; exports.__esModule = true; var _Rectangle = require('./Rectangle'); var _Rectangle2 = _interopRequireDefault(_Rectangle); var _const = require('../../const'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * The Ellipse object can be used to specify a hit area for displayObjects * * @class * @memberof PIXI */ var Ellipse = function () { /** * @param {number} [x=0] - The X coordinate of the center of this circle * @param {number} [y=0] - The Y coordinate of the center of this circle * @param {number} [width=0] - The half width of this ellipse * @param {number} [height=0] - The half height of this ellipse */ function Ellipse() { var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var height = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; _classCallCheck(this, Ellipse); /** * @member {number} * @default 0 */ this.x = x; /** * @member {number} * @default 0 */ this.y = y; /** * @member {number} * @default 0 */ this.width = width; /** * @member {number} * @default 0 */ this.height = height; /** * The type of the object, mainly used to avoid `instanceof` checks * * @member {number} * @readOnly * @default PIXI.SHAPES.ELIP * @see PIXI.SHAPES */ this.type = _const.SHAPES.ELIP; } /** * Creates a clone of this Ellipse instance * * @return {PIXI.Ellipse} a copy of the ellipse */ Ellipse.prototype.clone = function clone() { return new Ellipse(this.x, this.y, this.width, this.height); }; /** * Checks whether the x and y coordinates given are contained within this ellipse * * @param {number} x - The X coordinate of the point to test * @param {number} y - The Y coordinate of the point to test * @return {boolean} Whether the x/y coords are within this ellipse */ Ellipse.prototype.contains = function contains(x, y) { if (this.width <= 0 || this.height <= 0) { return false; } // normalize the coords to an ellipse with center 0,0 var normx = (x - this.x) / this.width; var normy = (y - this.y) / this.height; normx *= normx; normy *= normy; return normx + normy <= 1; }; /** * Returns the framing rectangle of the ellipse as a Rectangle object * * @return {PIXI.Rectangle} the framing rectangle */ Ellipse.prototype.getBounds = function getBounds() { return new _Rectangle2.default(this.x - this.width, this.y - this.height, this.width, this.height); }; return Ellipse; }(); exports.default = Ellipse; //# sourceMappingURL=Ellipse.js.map