'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 Circle object can be used to specify a hit area for displayObjects * * @class * @memberof PIXI */ var Circle = 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} [radius=0] - The radius of the circle */ function Circle() { var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var radius = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; _classCallCheck(this, Circle); /** * @member {number} * @default 0 */ this.x = x; /** * @member {number} * @default 0 */ this.y = y; /** * @member {number} * @default 0 */ this.radius = radius; /** * The type of the object, mainly used to avoid `instanceof` checks * * @member {number} * @readOnly * @default PIXI.SHAPES.CIRC * @see PIXI.SHAPES */ this.type = _const.SHAPES.CIRC; } /** * Creates a clone of this Circle instance * * @return {PIXI.Circle} a copy of the Circle */ Circle.prototype.clone = function clone() { return new Circle(this.x, this.y, this.radius); }; /** * Checks whether the x and y coordinates given are contained within this circle * * @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 coordinates are within this Circle */ Circle.prototype.contains = function contains(x, y) { if (this.radius <= 0) { return false; } var r2 = this.radius * this.radius; var dx = this.x - x; var dy = this.y - y; dx *= dx; dy *= dy; return dx + dy <= r2; }; /** * Returns the framing rectangle of the circle as a Rectangle object * * @return {PIXI.Rectangle} the framing rectangle */ Circle.prototype.getBounds = function getBounds() { return new _Rectangle2.default(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); }; return Circle; }(); exports.default = Circle; //# sourceMappingURL=Circle.js.map