This commit is contained in:
2025-01-04 00:34:03 +01:00
parent 41829408dc
commit 0ca14bbc19
18111 changed files with 1871397 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
"use strict";
var _const = require("../const.js"), Rectangle = require("./Rectangle.js");
class Circle {
/**
* @param x - The X coordinate of the center of this circle
* @param y - The Y coordinate of the center of this circle
* @param radius - The radius of the circle
*/
constructor(x = 0, y = 0, radius = 0) {
this.x = x, this.y = y, this.radius = radius, this.type = _const.SHAPES.CIRC;
}
/**
* Creates a clone of this Circle instance
* @returns A copy of the Circle
*/
clone() {
return new Circle(this.x, this.y, this.radius);
}
/**
* Checks whether the x and y coordinates given are contained within this circle
* @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 coordinates are within this Circle
*/
contains(x, y) {
if (this.radius <= 0)
return !1;
const r2 = this.radius * this.radius;
let dx = this.x - x, dy = this.y - y;
return dx *= dx, dy *= dy, dx + dy <= r2;
}
/**
* Returns the framing rectangle of the circle as a Rectangle object
* @returns The framing rectangle
*/
getBounds() {
return new Rectangle.Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);
}
}
Circle.prototype.toString = function() {
return `[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;
};
exports.Circle = Circle;
//# sourceMappingURL=Circle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Circle.js","sources":["../../src/shapes/Circle.ts"],"sourcesContent":["import { SHAPES } from './../const';\nimport { Rectangle } from './Rectangle';\n\n/**\n * The Circle 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 Circle\n{\n /** @default 0 */\n public x: number;\n\n /** @default 0 */\n public y: number;\n\n /** @default 0 */\n public radius: number;\n\n /**\n * The type of the object, mainly used to avoid `instanceof` checks\n * @default PIXI.SHAPES.CIRC\n * @see PIXI.SHAPES\n */\n public readonly type: SHAPES.CIRC;\n\n /**\n * @param x - The X coordinate of the center of this circle\n * @param y - The Y coordinate of the center of this circle\n * @param radius - The radius of the circle\n */\n constructor(x = 0, y = 0, radius = 0)\n {\n this.x = x;\n this.y = y;\n this.radius = radius;\n\n this.type = SHAPES.CIRC;\n }\n\n /**\n * Creates a clone of this Circle instance\n * @returns A copy of the Circle\n */\n clone(): Circle\n {\n return new Circle(this.x, this.y, this.radius);\n }\n\n /**\n * Checks whether the x and y coordinates given are contained within this circle\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 coordinates are within this Circle\n */\n contains(x: number, y: number): boolean\n {\n if (this.radius <= 0)\n {\n return false;\n }\n\n const r2 = this.radius * this.radius;\n let dx = (this.x - x);\n let dy = (this.y - y);\n\n dx *= dx;\n dy *= dy;\n\n return (dx + dy <= r2);\n }\n\n /**\n * Returns the framing rectangle of the circle as a Rectangle object\n * @returns The framing rectangle\n */\n getBounds(): Rectangle\n {\n return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);\n }\n}\n\nif (process.env.DEBUG)\n{\n Circle.prototype.toString = function toString(): string\n {\n return `[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;\n };\n}\n"],"names":["SHAPES","Rectangle"],"mappings":";;AAOO,MAAM,OACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBI,YAAY,IAAI,GAAG,IAAI,GAAG,SAAS,GACnC;AACS,SAAA,IAAI,GACT,KAAK,IAAI,GACT,KAAK,SAAS,QAEd,KAAK,OAAOA,OAAAA,OAAO;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACI,WAAO,IAAI,OAAO,KAAK,GAAG,KAAK,GAAG,KAAK,MAAM;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,GAAW,GACpB;AACI,QAAI,KAAK,UAAU;AAER,aAAA;AAGL,UAAA,KAAK,KAAK,SAAS,KAAK;AAC9B,QAAI,KAAM,KAAK,IAAI,GACf,KAAM,KAAK,IAAI;AAEnB,WAAA,MAAM,IACN,MAAM,IAEE,KAAK,MAAM;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YACA;AACI,WAAO,IAAIC,UAAA,UAAU,KAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,KAAK,QAAQ,KAAK,SAAS,GAAG,KAAK,SAAS,CAAC;AAAA,EACrG;AACJ;AAII,OAAO,UAAU,WAAW,WAC5B;AACW,SAAA,wBAAwB,KAAK,CAAC,MAAM,KAAK,CAAC,WAAW,KAAK,MAAM;AAC3E;;"}

View File

@@ -0,0 +1,46 @@
import { SHAPES } from "../const.mjs";
import { Rectangle } from "./Rectangle.mjs";
class Circle {
/**
* @param x - The X coordinate of the center of this circle
* @param y - The Y coordinate of the center of this circle
* @param radius - The radius of the circle
*/
constructor(x = 0, y = 0, radius = 0) {
this.x = x, this.y = y, this.radius = radius, this.type = SHAPES.CIRC;
}
/**
* Creates a clone of this Circle instance
* @returns A copy of the Circle
*/
clone() {
return new Circle(this.x, this.y, this.radius);
}
/**
* Checks whether the x and y coordinates given are contained within this circle
* @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 coordinates are within this Circle
*/
contains(x, y) {
if (this.radius <= 0)
return !1;
const r2 = this.radius * this.radius;
let dx = this.x - x, dy = this.y - y;
return dx *= dx, dy *= dy, dx + dy <= r2;
}
/**
* Returns the framing rectangle of the circle as a Rectangle object
* @returns The framing rectangle
*/
getBounds() {
return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);
}
}
Circle.prototype.toString = function() {
return `[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;
};
export {
Circle
};
//# sourceMappingURL=Circle.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Circle.mjs","sources":["../../src/shapes/Circle.ts"],"sourcesContent":["import { SHAPES } from './../const';\nimport { Rectangle } from './Rectangle';\n\n/**\n * The Circle 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 Circle\n{\n /** @default 0 */\n public x: number;\n\n /** @default 0 */\n public y: number;\n\n /** @default 0 */\n public radius: number;\n\n /**\n * The type of the object, mainly used to avoid `instanceof` checks\n * @default PIXI.SHAPES.CIRC\n * @see PIXI.SHAPES\n */\n public readonly type: SHAPES.CIRC;\n\n /**\n * @param x - The X coordinate of the center of this circle\n * @param y - The Y coordinate of the center of this circle\n * @param radius - The radius of the circle\n */\n constructor(x = 0, y = 0, radius = 0)\n {\n this.x = x;\n this.y = y;\n this.radius = radius;\n\n this.type = SHAPES.CIRC;\n }\n\n /**\n * Creates a clone of this Circle instance\n * @returns A copy of the Circle\n */\n clone(): Circle\n {\n return new Circle(this.x, this.y, this.radius);\n }\n\n /**\n * Checks whether the x and y coordinates given are contained within this circle\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 coordinates are within this Circle\n */\n contains(x: number, y: number): boolean\n {\n if (this.radius <= 0)\n {\n return false;\n }\n\n const r2 = this.radius * this.radius;\n let dx = (this.x - x);\n let dy = (this.y - y);\n\n dx *= dx;\n dy *= dy;\n\n return (dx + dy <= r2);\n }\n\n /**\n * Returns the framing rectangle of the circle as a Rectangle object\n * @returns The framing rectangle\n */\n getBounds(): Rectangle\n {\n return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);\n }\n}\n\nif (process.env.DEBUG)\n{\n Circle.prototype.toString = function toString(): string\n {\n return `[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;\n };\n}\n"],"names":[],"mappings":";;AAOO,MAAM,OACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBI,YAAY,IAAI,GAAG,IAAI,GAAG,SAAS,GACnC;AACS,SAAA,IAAI,GACT,KAAK,IAAI,GACT,KAAK,SAAS,QAEd,KAAK,OAAO,OAAO;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACI,WAAO,IAAI,OAAO,KAAK,GAAG,KAAK,GAAG,KAAK,MAAM;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,GAAW,GACpB;AACI,QAAI,KAAK,UAAU;AAER,aAAA;AAGL,UAAA,KAAK,KAAK,SAAS,KAAK;AAC9B,QAAI,KAAM,KAAK,IAAI,GACf,KAAM,KAAK,IAAI;AAEnB,WAAA,MAAM,IACN,MAAM,IAEE,KAAK,MAAM;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YACA;AACI,WAAO,IAAI,UAAU,KAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,KAAK,QAAQ,KAAK,SAAS,GAAG,KAAK,SAAS,CAAC;AAAA,EACrG;AACJ;AAII,OAAO,UAAU,WAAW,WAC5B;AACW,SAAA,wBAAwB,KAAK,CAAC,MAAM,KAAK,CAAC,WAAW,KAAK,MAAM;AAC3E;"}

View 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

View File

@@ -0,0 +1 @@
{"version":3,"file":"Ellipse.js","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\nif (process.env.DEBUG)\n{\n Ellipse.prototype.toString = function toString(): string\n {\n return `[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;\n };\n}\n"],"names":["SHAPES","Rectangle"],"mappings":";;AAOO,MAAM,QACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BI,YAAY,IAAI,GAAG,IAAI,GAAG,YAAY,GAAG,aAAa,GACtD;AACI,SAAK,IAAI,GACT,KAAK,IAAI,GACT,KAAK,QAAQ,WACb,KAAK,SAAS,YAEd,KAAK,OAAOA,OAAO,OAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACW,WAAA,IAAI,QAAQ,KAAK,GAAG,KAAK,GAAG,KAAK,OAAO,KAAK,MAAM;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,GAAW,GACpB;AACI,QAAI,KAAK,SAAS,KAAK,KAAK,UAAU;AAE3B,aAAA;AAIP,QAAA,SAAU,IAAI,KAAK,KAAK,KAAK,OAC7B,SAAU,IAAI,KAAK,KAAK,KAAK;AAEjC,WAAA,SAAS,OACT,SAAS,OAED,QAAQ,SAAS;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YACA;AACI,WAAO,IAAIC,UAAA,UAAU,KAAK,IAAI,KAAK,OAAO,KAAK,IAAI,KAAK,QAAQ,KAAK,OAAO,KAAK,MAAM;AAAA,EAC3F;AACJ;AAII,QAAQ,UAAU,WAAW,WAC7B;AACW,SAAA,yBAAyB,KAAK,CAAC,MAAM,KAAK,CAAC,UAAU,KAAK,KAAK,WAAW,KAAK,MAAM;AAChG;;"}

View File

@@ -0,0 +1,46 @@
import { SHAPES } from "../const.mjs";
import { Rectangle } from "./Rectangle.mjs";
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 = 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(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}]`;
};
export {
Ellipse
};
//# sourceMappingURL=Ellipse.mjs.map

View File

@@ -0,0 +1 @@
{"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\nif (process.env.DEBUG)\n{\n Ellipse.prototype.toString = function toString(): string\n {\n return `[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;\n };\n}\n"],"names":[],"mappings":";;AAOO,MAAM,QACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BI,YAAY,IAAI,GAAG,IAAI,GAAG,YAAY,GAAG,aAAa,GACtD;AACI,SAAK,IAAI,GACT,KAAK,IAAI,GACT,KAAK,QAAQ,WACb,KAAK,SAAS,YAEd,KAAK,OAAO,OAAO;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACW,WAAA,IAAI,QAAQ,KAAK,GAAG,KAAK,GAAG,KAAK,OAAO,KAAK,MAAM;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,GAAW,GACpB;AACI,QAAI,KAAK,SAAS,KAAK,KAAK,UAAU;AAE3B,aAAA;AAIP,QAAA,SAAU,IAAI,KAAK,KAAK,KAAK,OAC7B,SAAU,IAAI,KAAK,KAAK,KAAK;AAEjC,WAAA,SAAS,OACT,SAAS,OAED,QAAQ,SAAS;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YACA;AACI,WAAO,IAAI,UAAU,KAAK,IAAI,KAAK,OAAO,KAAK,IAAI,KAAK,QAAQ,KAAK,OAAO,KAAK,MAAM;AAAA,EAC3F;AACJ;AAII,QAAQ,UAAU,WAAW,WAC7B;AACW,SAAA,yBAAyB,KAAK,CAAC,MAAM,KAAK,CAAC,UAAU,KAAK,KAAK,WAAW,KAAK,MAAM;AAChG;"}

View File

@@ -0,0 +1,49 @@
"use strict";
var _const = require("../const.js");
class Polygon {
/**
* @param {PIXI.IPointData[]|number[]} points - This can be an array of Points
* that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or
* the arguments passed can be all the points of the polygon e.g.
* `new Polygon(new Point(), new Point(), ...)`, or the arguments passed can be flat
* x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers.
*/
constructor(...points) {
let flat = Array.isArray(points[0]) ? points[0] : points;
if (typeof flat[0] != "number") {
const p = [];
for (let i = 0, il = flat.length; i < il; i++)
p.push(flat[i].x, flat[i].y);
flat = p;
}
this.points = flat, this.type = _const.SHAPES.POLY, this.closeStroke = !0;
}
/**
* Creates a clone of this polygon.
* @returns - A copy of the polygon.
*/
clone() {
const points = this.points.slice(), polygon = new Polygon(points);
return polygon.closeStroke = this.closeStroke, polygon;
}
/**
* Checks whether the x and y coordinates passed to this function are contained within this polygon.
* @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 coordinates are within this polygon.
*/
contains(x, y) {
let inside = !1;
const length = this.points.length / 2;
for (let i = 0, j = length - 1; i < length; j = i++) {
const xi = this.points[i * 2], yi = this.points[i * 2 + 1], xj = this.points[j * 2], yj = this.points[j * 2 + 1];
yi > y != yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi && (inside = !inside);
}
return inside;
}
}
Polygon.prototype.toString = function() {
return `[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((pointsDesc, currentPoint) => `${pointsDesc}, ${currentPoint}`, "")}]`;
};
exports.Polygon = Polygon;
//# sourceMappingURL=Polygon.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Polygon.js","sources":["../../src/shapes/Polygon.ts"],"sourcesContent":["import { SHAPES } from '../const';\n\nimport type { IPointData } from '../IPointData';\n\n/**\n * A class to define a shape via user defined coordinates.\n * @memberof PIXI\n */\nexport class Polygon\n{\n /** An array of the points of this polygon. */\n public points: number[];\n\n /** `false` after moveTo, `true` after `closePath`. In all other cases it is `true`. */\n public closeStroke: boolean;\n\n /**\n * The type of the object, mainly used to avoid `instanceof` checks\n * @default PIXI.SHAPES.POLY\n * @see PIXI.SHAPES\n */\n public readonly type: SHAPES.POLY;\n\n constructor(points: IPointData[] | number[]);\n constructor(...points: IPointData[] | number[]);\n\n /**\n * @param {PIXI.IPointData[]|number[]} points - This can be an array of Points\n * that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or\n * the arguments passed can be all the points of the polygon e.g.\n * `new Polygon(new Point(), new Point(), ...)`, or the arguments passed can be flat\n * x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers.\n */\n constructor(...points: any[])\n {\n let flat: IPointData[] | number[] = Array.isArray(points[0]) ? points[0] : points;\n\n // if this is an array of points, convert it to a flat array of numbers\n if (typeof flat[0] !== 'number')\n {\n const p: number[] = [];\n\n for (let i = 0, il = flat.length; i < il; i++)\n {\n p.push((flat[i] as IPointData).x, (flat[i] as IPointData).y);\n }\n\n flat = p;\n }\n\n this.points = flat as number[];\n this.type = SHAPES.POLY;\n this.closeStroke = true;\n }\n\n /**\n * Creates a clone of this polygon.\n * @returns - A copy of the polygon.\n */\n clone(): Polygon\n {\n const points = this.points.slice();\n const polygon = new Polygon(points);\n\n polygon.closeStroke = this.closeStroke;\n\n return polygon;\n }\n\n /**\n * Checks whether the x and y coordinates passed to this function are contained within this polygon.\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 coordinates are within this polygon.\n */\n contains(x: number, y: number): boolean\n {\n let inside = false;\n\n // use some raycasting to test hits\n // https://github.com/substack/point-in-polygon/blob/master/index.js\n const length = this.points.length / 2;\n\n for (let i = 0, j = length - 1; i < length; j = i++)\n {\n const xi = this.points[i * 2];\n const yi = this.points[(i * 2) + 1];\n const xj = this.points[j * 2];\n const yj = this.points[(j * 2) + 1];\n const intersect = ((yi > y) !== (yj > y)) && (x < ((xj - xi) * ((y - yi) / (yj - yi))) + xi);\n\n if (intersect)\n {\n inside = !inside;\n }\n }\n\n return inside;\n }\n}\n\nif (process.env.DEBUG)\n{\n Polygon.prototype.toString = function toString(): string\n {\n return `[@pixi/math:Polygon`\n + `closeStroke=${this.closeStroke}`\n + `points=${this.points.reduce((pointsDesc, currentPoint) => `${pointsDesc}, ${currentPoint}`, '')}]`;\n };\n}\n"],"names":["SHAPES"],"mappings":";;AAQO,MAAM,QACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwBI,eAAe,QACf;AACQ,QAAA,OAAgC,MAAM,QAAQ,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI;AAG3E,QAAI,OAAO,KAAK,CAAC,KAAM,UACvB;AACI,YAAM,IAAc,CAAA;AAEpB,eAAS,IAAI,GAAG,KAAK,KAAK,QAAQ,IAAI,IAAI;AAEpC,UAAA,KAAM,KAAK,CAAC,EAAiB,GAAI,KAAK,CAAC,EAAiB,CAAC;AAGxD,aAAA;AAAA,IACX;AAEA,SAAK,SAAS,MACd,KAAK,OAAOA,cAAO,MACnB,KAAK,cAAc;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACU,UAAA,SAAS,KAAK,OAAO,SACrB,UAAU,IAAI,QAAQ,MAAM;AAE1B,WAAA,QAAA,cAAc,KAAK,aAEpB;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,GAAW,GACpB;AACI,QAAI,SAAS;AAIP,UAAA,SAAS,KAAK,OAAO,SAAS;AAE3B,aAAA,IAAI,GAAG,IAAI,SAAS,GAAG,IAAI,QAAQ,IAAI,KAChD;AACU,YAAA,KAAK,KAAK,OAAO,IAAI,CAAC,GACtB,KAAK,KAAK,OAAQ,IAAI,IAAK,CAAC,GAC5B,KAAK,KAAK,OAAO,IAAI,CAAC,GACtB,KAAK,KAAK,OAAQ,IAAI,IAAK,CAAC;AACd,WAAK,KAAQ,KAAK,KAAQ,KAAM,KAAK,QAAQ,IAAI,OAAO,KAAK,OAAQ,OAIrF,SAAS,CAAC;AAAA,IAElB;AAEO,WAAA;AAAA,EACX;AACJ;AAII,QAAQ,UAAU,WAAW,WAC7B;AACI,SAAO,kCACc,KAAK,WAAW,UACrB,KAAK,OAAO,OAAO,CAAC,YAAY,iBAAiB,GAAG,UAAU,KAAK,YAAY,IAAI,EAAE,CAAC;AAC1G;;"}

View File

@@ -0,0 +1,50 @@
import { SHAPES } from "../const.mjs";
class Polygon {
/**
* @param {PIXI.IPointData[]|number[]} points - This can be an array of Points
* that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or
* the arguments passed can be all the points of the polygon e.g.
* `new Polygon(new Point(), new Point(), ...)`, or the arguments passed can be flat
* x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers.
*/
constructor(...points) {
let flat = Array.isArray(points[0]) ? points[0] : points;
if (typeof flat[0] != "number") {
const p = [];
for (let i = 0, il = flat.length; i < il; i++)
p.push(flat[i].x, flat[i].y);
flat = p;
}
this.points = flat, this.type = SHAPES.POLY, this.closeStroke = !0;
}
/**
* Creates a clone of this polygon.
* @returns - A copy of the polygon.
*/
clone() {
const points = this.points.slice(), polygon = new Polygon(points);
return polygon.closeStroke = this.closeStroke, polygon;
}
/**
* Checks whether the x and y coordinates passed to this function are contained within this polygon.
* @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 coordinates are within this polygon.
*/
contains(x, y) {
let inside = !1;
const length = this.points.length / 2;
for (let i = 0, j = length - 1; i < length; j = i++) {
const xi = this.points[i * 2], yi = this.points[i * 2 + 1], xj = this.points[j * 2], yj = this.points[j * 2 + 1];
yi > y != yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi && (inside = !inside);
}
return inside;
}
}
Polygon.prototype.toString = function() {
return `[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((pointsDesc, currentPoint) => `${pointsDesc}, ${currentPoint}`, "")}]`;
};
export {
Polygon
};
//# sourceMappingURL=Polygon.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Polygon.mjs","sources":["../../src/shapes/Polygon.ts"],"sourcesContent":["import { SHAPES } from '../const';\n\nimport type { IPointData } from '../IPointData';\n\n/**\n * A class to define a shape via user defined coordinates.\n * @memberof PIXI\n */\nexport class Polygon\n{\n /** An array of the points of this polygon. */\n public points: number[];\n\n /** `false` after moveTo, `true` after `closePath`. In all other cases it is `true`. */\n public closeStroke: boolean;\n\n /**\n * The type of the object, mainly used to avoid `instanceof` checks\n * @default PIXI.SHAPES.POLY\n * @see PIXI.SHAPES\n */\n public readonly type: SHAPES.POLY;\n\n constructor(points: IPointData[] | number[]);\n constructor(...points: IPointData[] | number[]);\n\n /**\n * @param {PIXI.IPointData[]|number[]} points - This can be an array of Points\n * that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or\n * the arguments passed can be all the points of the polygon e.g.\n * `new Polygon(new Point(), new Point(), ...)`, or the arguments passed can be flat\n * x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers.\n */\n constructor(...points: any[])\n {\n let flat: IPointData[] | number[] = Array.isArray(points[0]) ? points[0] : points;\n\n // if this is an array of points, convert it to a flat array of numbers\n if (typeof flat[0] !== 'number')\n {\n const p: number[] = [];\n\n for (let i = 0, il = flat.length; i < il; i++)\n {\n p.push((flat[i] as IPointData).x, (flat[i] as IPointData).y);\n }\n\n flat = p;\n }\n\n this.points = flat as number[];\n this.type = SHAPES.POLY;\n this.closeStroke = true;\n }\n\n /**\n * Creates a clone of this polygon.\n * @returns - A copy of the polygon.\n */\n clone(): Polygon\n {\n const points = this.points.slice();\n const polygon = new Polygon(points);\n\n polygon.closeStroke = this.closeStroke;\n\n return polygon;\n }\n\n /**\n * Checks whether the x and y coordinates passed to this function are contained within this polygon.\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 coordinates are within this polygon.\n */\n contains(x: number, y: number): boolean\n {\n let inside = false;\n\n // use some raycasting to test hits\n // https://github.com/substack/point-in-polygon/blob/master/index.js\n const length = this.points.length / 2;\n\n for (let i = 0, j = length - 1; i < length; j = i++)\n {\n const xi = this.points[i * 2];\n const yi = this.points[(i * 2) + 1];\n const xj = this.points[j * 2];\n const yj = this.points[(j * 2) + 1];\n const intersect = ((yi > y) !== (yj > y)) && (x < ((xj - xi) * ((y - yi) / (yj - yi))) + xi);\n\n if (intersect)\n {\n inside = !inside;\n }\n }\n\n return inside;\n }\n}\n\nif (process.env.DEBUG)\n{\n Polygon.prototype.toString = function toString(): string\n {\n return `[@pixi/math:Polygon`\n + `closeStroke=${this.closeStroke}`\n + `points=${this.points.reduce((pointsDesc, currentPoint) => `${pointsDesc}, ${currentPoint}`, '')}]`;\n };\n}\n"],"names":[],"mappings":";AAQO,MAAM,QACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwBI,eAAe,QACf;AACQ,QAAA,OAAgC,MAAM,QAAQ,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI;AAG3E,QAAI,OAAO,KAAK,CAAC,KAAM,UACvB;AACI,YAAM,IAAc,CAAA;AAEpB,eAAS,IAAI,GAAG,KAAK,KAAK,QAAQ,IAAI,IAAI;AAEpC,UAAA,KAAM,KAAK,CAAC,EAAiB,GAAI,KAAK,CAAC,EAAiB,CAAC;AAGxD,aAAA;AAAA,IACX;AAEA,SAAK,SAAS,MACd,KAAK,OAAO,OAAO,MACnB,KAAK,cAAc;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACU,UAAA,SAAS,KAAK,OAAO,SACrB,UAAU,IAAI,QAAQ,MAAM;AAE1B,WAAA,QAAA,cAAc,KAAK,aAEpB;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,GAAW,GACpB;AACI,QAAI,SAAS;AAIP,UAAA,SAAS,KAAK,OAAO,SAAS;AAE3B,aAAA,IAAI,GAAG,IAAI,SAAS,GAAG,IAAI,QAAQ,IAAI,KAChD;AACU,YAAA,KAAK,KAAK,OAAO,IAAI,CAAC,GACtB,KAAK,KAAK,OAAQ,IAAI,IAAK,CAAC,GAC5B,KAAK,KAAK,OAAO,IAAI,CAAC,GACtB,KAAK,KAAK,OAAQ,IAAI,IAAK,CAAC;AACd,WAAK,KAAQ,KAAK,KAAQ,KAAM,KAAK,QAAQ,IAAI,OAAO,KAAK,OAAQ,OAIrF,SAAS,CAAC;AAAA,IAElB;AAEO,WAAA;AAAA,EACX;AACJ;AAII,QAAQ,UAAU,WAAW,WAC7B;AACI,SAAO,kCACc,KAAK,WAAW,UACrB,KAAK,OAAO,OAAO,CAAC,YAAY,iBAAiB,GAAG,UAAU,KAAK,YAAY,IAAI,EAAE,CAAC;AAC1G;"}

View File

@@ -0,0 +1,141 @@
"use strict";
var _const = require("../const.js"), Point = require("../Point.js");
const tempPoints = [new Point.Point(), new Point.Point(), new Point.Point(), new Point.Point()];
class Rectangle {
/**
* @param x - The X coordinate of the upper-left corner of the rectangle
* @param y - The Y coordinate of the upper-left corner of the rectangle
* @param width - The overall width of the rectangle
* @param height - The overall height of the rectangle
*/
constructor(x = 0, y = 0, width = 0, height = 0) {
this.x = Number(x), this.y = Number(y), this.width = Number(width), this.height = Number(height), this.type = _const.SHAPES.RECT;
}
/** Returns the left edge of the rectangle. */
get left() {
return this.x;
}
/** Returns the right edge of the rectangle. */
get right() {
return this.x + this.width;
}
/** Returns the top edge of the rectangle. */
get top() {
return this.y;
}
/** Returns the bottom edge of the rectangle. */
get bottom() {
return this.y + this.height;
}
/** A constant empty rectangle. */
static get EMPTY() {
return new Rectangle(0, 0, 0, 0);
}
/**
* Creates a clone of this Rectangle
* @returns a copy of the rectangle
*/
clone() {
return new Rectangle(this.x, this.y, this.width, this.height);
}
/**
* Copies another rectangle to this one.
* @param rectangle - The rectangle to copy from.
* @returns Returns itself.
*/
copyFrom(rectangle) {
return this.x = rectangle.x, this.y = rectangle.y, this.width = rectangle.width, this.height = rectangle.height, this;
}
/**
* Copies this rectangle to another one.
* @param rectangle - The rectangle to copy to.
* @returns Returns given parameter.
*/
copyTo(rectangle) {
return rectangle.x = this.x, rectangle.y = this.y, rectangle.width = this.width, rectangle.height = this.height, rectangle;
}
/**
* Checks whether the x and y coordinates given are contained within this Rectangle
* @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 coordinates are within this Rectangle
*/
contains(x, y) {
return this.width <= 0 || this.height <= 0 ? !1 : x >= this.x && x < this.x + this.width && y >= this.y && y < this.y + this.height;
}
/**
* Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.
* Returns true only if the area of the intersection is >0, this means that Rectangles
* sharing a side are not overlapping. Another side effect is that an arealess rectangle
* (width or height equal to zero) can't intersect any other rectangle.
* @param {Rectangle} other - The Rectangle to intersect with `this`.
* @param {Matrix} transform - The transformation matrix of `other`.
* @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.
*/
intersects(other, transform) {
if (!transform) {
const x02 = this.x < other.x ? other.x : this.x;
if ((this.right > other.right ? other.right : this.right) <= x02)
return !1;
const y02 = this.y < other.y ? other.y : this.y;
return (this.bottom > other.bottom ? other.bottom : this.bottom) > y02;
}
const x0 = this.left, x1 = this.right, y0 = this.top, y1 = this.bottom;
if (x1 <= x0 || y1 <= y0)
return !1;
const lt = tempPoints[0].set(other.left, other.top), lb = tempPoints[1].set(other.left, other.bottom), rt = tempPoints[2].set(other.right, other.top), rb = tempPoints[3].set(other.right, other.bottom);
if (rt.x <= lt.x || lb.y <= lt.y)
return !1;
const s = Math.sign(transform.a * transform.d - transform.b * transform.c);
if (s === 0 || (transform.apply(lt, lt), transform.apply(lb, lb), transform.apply(rt, rt), transform.apply(rb, rb), Math.max(lt.x, lb.x, rt.x, rb.x) <= x0 || Math.min(lt.x, lb.x, rt.x, rb.x) >= x1 || Math.max(lt.y, lb.y, rt.y, rb.y) <= y0 || Math.min(lt.y, lb.y, rt.y, rb.y) >= y1))
return !1;
const nx = s * (lb.y - lt.y), ny = s * (lt.x - lb.x), n00 = nx * x0 + ny * y0, n10 = nx * x1 + ny * y0, n01 = nx * x0 + ny * y1, n11 = nx * x1 + ny * y1;
if (Math.max(n00, n10, n01, n11) <= nx * lt.x + ny * lt.y || Math.min(n00, n10, n01, n11) >= nx * rb.x + ny * rb.y)
return !1;
const mx = s * (lt.y - rt.y), my = s * (rt.x - lt.x), m00 = mx * x0 + my * y0, m10 = mx * x1 + my * y0, m01 = mx * x0 + my * y1, m11 = mx * x1 + my * y1;
return !(Math.max(m00, m10, m01, m11) <= mx * lt.x + my * lt.y || Math.min(m00, m10, m01, m11) >= mx * rb.x + my * rb.y);
}
/**
* Pads the rectangle making it grow in all directions.
* If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
* @param paddingX - The horizontal padding amount.
* @param paddingY - The vertical padding amount.
* @returns Returns itself.
*/
pad(paddingX = 0, paddingY = paddingX) {
return this.x -= paddingX, this.y -= paddingY, this.width += paddingX * 2, this.height += paddingY * 2, this;
}
/**
* Fits this rectangle around the passed one.
* @param rectangle - The rectangle to fit.
* @returns Returns itself.
*/
fit(rectangle) {
const x1 = Math.max(this.x, rectangle.x), x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width), y1 = Math.max(this.y, rectangle.y), y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
return this.x = x1, this.width = Math.max(x2 - x1, 0), this.y = y1, this.height = Math.max(y2 - y1, 0), this;
}
/**
* Enlarges rectangle that way its corners lie on grid
* @param resolution - resolution
* @param eps - precision
* @returns Returns itself.
*/
ceil(resolution = 1, eps = 1e-3) {
const x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution, y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
return this.x = Math.floor((this.x + eps) * resolution) / resolution, this.y = Math.floor((this.y + eps) * resolution) / resolution, this.width = x2 - this.x, this.height = y2 - this.y, this;
}
/**
* Enlarges this rectangle to include the passed rectangle.
* @param rectangle - The rectangle to include.
* @returns Returns itself.
*/
enlarge(rectangle) {
const x1 = Math.min(this.x, rectangle.x), x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width), y1 = Math.min(this.y, rectangle.y), y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
return this.x = x1, this.width = x2 - x1, this.y = y1, this.height = y2 - y1, this;
}
}
Rectangle.prototype.toString = function() {
return `[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;
};
exports.Rectangle = Rectangle;
//# sourceMappingURL=Rectangle.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,143 @@
import { SHAPES } from "../const.mjs";
import { Point } from "../Point.mjs";
const tempPoints = [new Point(), new Point(), new Point(), new Point()];
class Rectangle {
/**
* @param x - The X coordinate of the upper-left corner of the rectangle
* @param y - The Y coordinate of the upper-left corner of the rectangle
* @param width - The overall width of the rectangle
* @param height - The overall height of the rectangle
*/
constructor(x = 0, y = 0, width = 0, height = 0) {
this.x = Number(x), this.y = Number(y), this.width = Number(width), this.height = Number(height), this.type = SHAPES.RECT;
}
/** Returns the left edge of the rectangle. */
get left() {
return this.x;
}
/** Returns the right edge of the rectangle. */
get right() {
return this.x + this.width;
}
/** Returns the top edge of the rectangle. */
get top() {
return this.y;
}
/** Returns the bottom edge of the rectangle. */
get bottom() {
return this.y + this.height;
}
/** A constant empty rectangle. */
static get EMPTY() {
return new Rectangle(0, 0, 0, 0);
}
/**
* Creates a clone of this Rectangle
* @returns a copy of the rectangle
*/
clone() {
return new Rectangle(this.x, this.y, this.width, this.height);
}
/**
* Copies another rectangle to this one.
* @param rectangle - The rectangle to copy from.
* @returns Returns itself.
*/
copyFrom(rectangle) {
return this.x = rectangle.x, this.y = rectangle.y, this.width = rectangle.width, this.height = rectangle.height, this;
}
/**
* Copies this rectangle to another one.
* @param rectangle - The rectangle to copy to.
* @returns Returns given parameter.
*/
copyTo(rectangle) {
return rectangle.x = this.x, rectangle.y = this.y, rectangle.width = this.width, rectangle.height = this.height, rectangle;
}
/**
* Checks whether the x and y coordinates given are contained within this Rectangle
* @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 coordinates are within this Rectangle
*/
contains(x, y) {
return this.width <= 0 || this.height <= 0 ? !1 : x >= this.x && x < this.x + this.width && y >= this.y && y < this.y + this.height;
}
/**
* Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.
* Returns true only if the area of the intersection is >0, this means that Rectangles
* sharing a side are not overlapping. Another side effect is that an arealess rectangle
* (width or height equal to zero) can't intersect any other rectangle.
* @param {Rectangle} other - The Rectangle to intersect with `this`.
* @param {Matrix} transform - The transformation matrix of `other`.
* @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.
*/
intersects(other, transform) {
if (!transform) {
const x02 = this.x < other.x ? other.x : this.x;
if ((this.right > other.right ? other.right : this.right) <= x02)
return !1;
const y02 = this.y < other.y ? other.y : this.y;
return (this.bottom > other.bottom ? other.bottom : this.bottom) > y02;
}
const x0 = this.left, x1 = this.right, y0 = this.top, y1 = this.bottom;
if (x1 <= x0 || y1 <= y0)
return !1;
const lt = tempPoints[0].set(other.left, other.top), lb = tempPoints[1].set(other.left, other.bottom), rt = tempPoints[2].set(other.right, other.top), rb = tempPoints[3].set(other.right, other.bottom);
if (rt.x <= lt.x || lb.y <= lt.y)
return !1;
const s = Math.sign(transform.a * transform.d - transform.b * transform.c);
if (s === 0 || (transform.apply(lt, lt), transform.apply(lb, lb), transform.apply(rt, rt), transform.apply(rb, rb), Math.max(lt.x, lb.x, rt.x, rb.x) <= x0 || Math.min(lt.x, lb.x, rt.x, rb.x) >= x1 || Math.max(lt.y, lb.y, rt.y, rb.y) <= y0 || Math.min(lt.y, lb.y, rt.y, rb.y) >= y1))
return !1;
const nx = s * (lb.y - lt.y), ny = s * (lt.x - lb.x), n00 = nx * x0 + ny * y0, n10 = nx * x1 + ny * y0, n01 = nx * x0 + ny * y1, n11 = nx * x1 + ny * y1;
if (Math.max(n00, n10, n01, n11) <= nx * lt.x + ny * lt.y || Math.min(n00, n10, n01, n11) >= nx * rb.x + ny * rb.y)
return !1;
const mx = s * (lt.y - rt.y), my = s * (rt.x - lt.x), m00 = mx * x0 + my * y0, m10 = mx * x1 + my * y0, m01 = mx * x0 + my * y1, m11 = mx * x1 + my * y1;
return !(Math.max(m00, m10, m01, m11) <= mx * lt.x + my * lt.y || Math.min(m00, m10, m01, m11) >= mx * rb.x + my * rb.y);
}
/**
* Pads the rectangle making it grow in all directions.
* If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
* @param paddingX - The horizontal padding amount.
* @param paddingY - The vertical padding amount.
* @returns Returns itself.
*/
pad(paddingX = 0, paddingY = paddingX) {
return this.x -= paddingX, this.y -= paddingY, this.width += paddingX * 2, this.height += paddingY * 2, this;
}
/**
* Fits this rectangle around the passed one.
* @param rectangle - The rectangle to fit.
* @returns Returns itself.
*/
fit(rectangle) {
const x1 = Math.max(this.x, rectangle.x), x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width), y1 = Math.max(this.y, rectangle.y), y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
return this.x = x1, this.width = Math.max(x2 - x1, 0), this.y = y1, this.height = Math.max(y2 - y1, 0), this;
}
/**
* Enlarges rectangle that way its corners lie on grid
* @param resolution - resolution
* @param eps - precision
* @returns Returns itself.
*/
ceil(resolution = 1, eps = 1e-3) {
const x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution, y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
return this.x = Math.floor((this.x + eps) * resolution) / resolution, this.y = Math.floor((this.y + eps) * resolution) / resolution, this.width = x2 - this.x, this.height = y2 - this.y, this;
}
/**
* Enlarges this rectangle to include the passed rectangle.
* @param rectangle - The rectangle to include.
* @returns Returns itself.
*/
enlarge(rectangle) {
const x1 = Math.min(this.x, rectangle.x), x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width), y1 = Math.min(this.y, rectangle.y), y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
return this.x = x1, this.width = x2 - x1, this.y = y1, this.height = y2 - y1, this;
}
}
Rectangle.prototype.toString = function() {
return `[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;
};
export {
Rectangle
};
//# sourceMappingURL=Rectangle.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,46 @@
"use strict";
var _const = require("../const.js");
class RoundedRectangle {
/**
* @param x - The X coordinate of the upper-left corner of the rounded rectangle
* @param y - The Y coordinate of the upper-left corner of the rounded rectangle
* @param width - The overall width of this rounded rectangle
* @param height - The overall height of this rounded rectangle
* @param radius - Controls the radius of the rounded corners
*/
constructor(x = 0, y = 0, width = 0, height = 0, radius = 20) {
this.x = x, this.y = y, this.width = width, this.height = height, this.radius = radius, this.type = _const.SHAPES.RREC;
}
/**
* Creates a clone of this Rounded Rectangle.
* @returns - A copy of the rounded rectangle.
*/
clone() {
return new RoundedRectangle(this.x, this.y, this.width, this.height, this.radius);
}
/**
* Checks whether the x and y coordinates given are contained within this Rounded Rectangle
* @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 coordinates are within this Rounded Rectangle.
*/
contains(x, y) {
if (this.width <= 0 || this.height <= 0)
return !1;
if (x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height) {
const radius = Math.max(0, Math.min(this.radius, Math.min(this.width, this.height) / 2));
if (y >= this.y + radius && y <= this.y + this.height - radius || x >= this.x + radius && x <= this.x + this.width - radius)
return !0;
let dx = x - (this.x + radius), dy = y - (this.y + radius);
const radius2 = radius * radius;
if (dx * dx + dy * dy <= radius2 || (dx = x - (this.x + this.width - radius), dx * dx + dy * dy <= radius2) || (dy = y - (this.y + this.height - radius), dx * dx + dy * dy <= radius2) || (dx = x - (this.x + radius), dx * dx + dy * dy <= radius2))
return !0;
}
return !1;
}
}
RoundedRectangle.prototype.toString = function() {
return `[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`;
};
exports.RoundedRectangle = RoundedRectangle;
//# sourceMappingURL=RoundedRectangle.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
import { SHAPES } from "../const.mjs";
class RoundedRectangle {
/**
* @param x - The X coordinate of the upper-left corner of the rounded rectangle
* @param y - The Y coordinate of the upper-left corner of the rounded rectangle
* @param width - The overall width of this rounded rectangle
* @param height - The overall height of this rounded rectangle
* @param radius - Controls the radius of the rounded corners
*/
constructor(x = 0, y = 0, width = 0, height = 0, radius = 20) {
this.x = x, this.y = y, this.width = width, this.height = height, this.radius = radius, this.type = SHAPES.RREC;
}
/**
* Creates a clone of this Rounded Rectangle.
* @returns - A copy of the rounded rectangle.
*/
clone() {
return new RoundedRectangle(this.x, this.y, this.width, this.height, this.radius);
}
/**
* Checks whether the x and y coordinates given are contained within this Rounded Rectangle
* @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 coordinates are within this Rounded Rectangle.
*/
contains(x, y) {
if (this.width <= 0 || this.height <= 0)
return !1;
if (x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height) {
const radius = Math.max(0, Math.min(this.radius, Math.min(this.width, this.height) / 2));
if (y >= this.y + radius && y <= this.y + this.height - radius || x >= this.x + radius && x <= this.x + this.width - radius)
return !0;
let dx = x - (this.x + radius), dy = y - (this.y + radius);
const radius2 = radius * radius;
if (dx * dx + dy * dy <= radius2 || (dx = x - (this.x + this.width - radius), dx * dx + dy * dy <= radius2) || (dy = y - (this.y + this.height - radius), dx * dx + dy * dy <= radius2) || (dx = x - (this.x + radius), dx * dx + dy * dy <= radius2))
return !0;
}
return !1;
}
}
RoundedRectangle.prototype.toString = function() {
return `[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`;
};
export {
RoundedRectangle
};
//# sourceMappingURL=RoundedRectangle.mjs.map

File diff suppressed because one or more lines are too long