Initial
This commit is contained in:
44
resources/app/node_modules/@pixi/math/lib/shapes/Ellipse.js
generated
vendored
Normal file
44
resources/app/node_modules/@pixi/math/lib/shapes/Ellipse.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
var _const = require("../const.js"), Rectangle = require("./Rectangle.js");
|
||||
class Ellipse {
|
||||
/**
|
||||
* @param x - The X coordinate of the center of this ellipse
|
||||
* @param y - The Y coordinate of the center of this ellipse
|
||||
* @param halfWidth - The half width of this ellipse
|
||||
* @param halfHeight - The half height of this ellipse
|
||||
*/
|
||||
constructor(x = 0, y = 0, halfWidth = 0, halfHeight = 0) {
|
||||
this.x = x, this.y = y, this.width = halfWidth, this.height = halfHeight, this.type = _const.SHAPES.ELIP;
|
||||
}
|
||||
/**
|
||||
* Creates a clone of this Ellipse instance
|
||||
* @returns {PIXI.Ellipse} A copy of the ellipse
|
||||
*/
|
||||
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 x - The X coordinate of the point to test
|
||||
* @param y - The Y coordinate of the point to test
|
||||
* @returns Whether the x/y coords are within this ellipse
|
||||
*/
|
||||
contains(x, y) {
|
||||
if (this.width <= 0 || this.height <= 0)
|
||||
return !1;
|
||||
let normx = (x - this.x) / this.width, normy = (y - this.y) / this.height;
|
||||
return normx *= normx, normy *= normy, normx + normy <= 1;
|
||||
}
|
||||
/**
|
||||
* Returns the framing rectangle of the ellipse as a Rectangle object
|
||||
* @returns The framing rectangle
|
||||
*/
|
||||
getBounds() {
|
||||
return new Rectangle.Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
|
||||
}
|
||||
}
|
||||
Ellipse.prototype.toString = function() {
|
||||
return `[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;
|
||||
};
|
||||
exports.Ellipse = Ellipse;
|
||||
//# sourceMappingURL=Ellipse.js.map
|
||||
Reference in New Issue
Block a user