This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

74
node_modules/pixi.js/lib/maths/shapes/Circle.d.ts generated vendored Normal file
View File

@@ -0,0 +1,74 @@
import { Rectangle } from './Rectangle';
import type { SHAPE_PRIMITIVE } from '../misc/const';
import type { ShapePrimitive } from './ShapePrimitive';
/**
* The Circle object is used to help draw graphics and can also be used to specify a hit area for containers.
* @memberof maths
*/
export declare class Circle implements ShapePrimitive {
/**
* The X coordinate of the center of this circle
* @default 0
*/
x: number;
/**
* The Y coordinate of the center of this circle
* @default 0
*/
y: number;
/**
* The radius of the circle
* @default 0
*/
radius: number;
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'circle'
*/
readonly type: SHAPE_PRIMITIVE;
/**
* @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?: number, y?: number, radius?: number);
/**
* Creates a clone of this Circle instance
* @returns A copy of the Circle
*/
clone(): Circle;
/**
* 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: number, y: number): boolean;
/**
* Checks whether the x and y coordinates given are contained within this circle including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param width - The width of the line to check
* @returns Whether the x/y coordinates are within this Circle
*/
strokeContains(x: number, y: number, width: number): boolean;
/**
* Returns the framing rectangle of the circle as a Rectangle object
* @param out
* @returns The framing rectangle
*/
getBounds(out?: Rectangle): Rectangle;
/**
* Copies another circle to this one.
* @param circle - The circle to copy from.
* @returns Returns itself.
*/
copyFrom(circle: Circle): this;
/**
* Copies this circle to another one.
* @param circle - The circle to copy to.
* @returns Returns given parameter.
*/
copyTo(circle: Circle): Circle;
toString(): string;
}

101
node_modules/pixi.js/lib/maths/shapes/Circle.js generated vendored Normal file
View File

@@ -0,0 +1,101 @@
'use strict';
var Rectangle = require('./Rectangle.js');
"use strict";
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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'circle'
*/
this.type = "circle";
this.x = x;
this.y = y;
this.radius = radius;
}
/**
* 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 false;
const r2 = this.radius * this.radius;
let dx = this.x - x;
let dy = this.y - y;
dx *= dx;
dy *= dy;
return dx + dy <= r2;
}
/**
* Checks whether the x and y coordinates given are contained within this circle including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param width - The width of the line to check
* @returns Whether the x/y coordinates are within this Circle
*/
strokeContains(x, y, width) {
if (this.radius === 0)
return false;
const dx = this.x - x;
const dy = this.y - y;
const r = this.radius;
const w2 = width / 2;
const distance = Math.sqrt(dx * dx + dy * dy);
return distance < r + w2 && distance > r - w2;
}
/**
* Returns the framing rectangle of the circle as a Rectangle object
* @param out
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle.Rectangle();
out.x = this.x - this.radius;
out.y = this.y - this.radius;
out.width = this.radius * 2;
out.height = this.radius * 2;
return out;
}
/**
* Copies another circle to this one.
* @param circle - The circle to copy from.
* @returns Returns itself.
*/
copyFrom(circle) {
this.x = circle.x;
this.y = circle.y;
this.radius = circle.radius;
return this;
}
/**
* Copies this circle to another one.
* @param circle - The circle to copy to.
* @returns Returns given parameter.
*/
copyTo(circle) {
circle.copyFrom(this);
return circle;
}
toString() {
return `[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;
}
}
exports.Circle = Circle;
//# sourceMappingURL=Circle.js.map

1
node_modules/pixi.js/lib/maths/shapes/Circle.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

99
node_modules/pixi.js/lib/maths/shapes/Circle.mjs generated vendored Normal file
View File

@@ -0,0 +1,99 @@
import { Rectangle } from './Rectangle.mjs';
"use strict";
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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'circle'
*/
this.type = "circle";
this.x = x;
this.y = y;
this.radius = radius;
}
/**
* 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 false;
const r2 = this.radius * this.radius;
let dx = this.x - x;
let dy = this.y - y;
dx *= dx;
dy *= dy;
return dx + dy <= r2;
}
/**
* Checks whether the x and y coordinates given are contained within this circle including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param width - The width of the line to check
* @returns Whether the x/y coordinates are within this Circle
*/
strokeContains(x, y, width) {
if (this.radius === 0)
return false;
const dx = this.x - x;
const dy = this.y - y;
const r = this.radius;
const w2 = width / 2;
const distance = Math.sqrt(dx * dx + dy * dy);
return distance < r + w2 && distance > r - w2;
}
/**
* Returns the framing rectangle of the circle as a Rectangle object
* @param out
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle();
out.x = this.x - this.radius;
out.y = this.y - this.radius;
out.width = this.radius * 2;
out.height = this.radius * 2;
return out;
}
/**
* Copies another circle to this one.
* @param circle - The circle to copy from.
* @returns Returns itself.
*/
copyFrom(circle) {
this.x = circle.x;
this.y = circle.y;
this.radius = circle.radius;
return this;
}
/**
* Copies this circle to another one.
* @param circle - The circle to copy to.
* @returns Returns given parameter.
*/
copyTo(circle) {
circle.copyFrom(this);
return circle;
}
toString() {
return `[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;
}
}
export { Circle };
//# sourceMappingURL=Circle.mjs.map

1
node_modules/pixi.js/lib/maths/shapes/Circle.mjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

85
node_modules/pixi.js/lib/maths/shapes/Ellipse.d.ts generated vendored Normal file
View File

@@ -0,0 +1,85 @@
import { Rectangle } from './Rectangle';
import type { ShapePrimitive } from './ShapePrimitive';
/**
* The Ellipse object is used to help draw graphics and can also be used to specify a hit area for containers.
* ```js
* import { Ellipse } from 'pixi.js';
*
* const ellipse = new Ellipse(0, 0, 20, 10); // 40x20 rectangle
* const isPointInEllipse = ellipse.contains(0, 0); // true
* ```
* @memberof maths
*/
export declare class Ellipse implements ShapePrimitive {
/**
* The X coordinate of the center of this ellipse
* @default 0
*/
x: number;
/**
* The Y coordinate of the center of this ellipse
* @default 0
*/
y: number;
/**
* The half width of this ellipse
* @default 0
*/
halfWidth: number;
/**
* The half height of this ellipse
* @default 0
*/
halfHeight: number;
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'ellipse'
*/
readonly type = "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?: number, y?: number, halfWidth?: number, halfHeight?: number);
/**
* Creates a clone of this Ellipse instance
* @returns {Ellipse} A copy of the ellipse
*/
clone(): Ellipse;
/**
* 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: number, y: number): boolean;
/**
* Checks whether the x and y coordinates given are contained within this ellipse including stroke
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param width
* @returns Whether the x/y coords are within this ellipse
*/
strokeContains(x: number, y: number, width: number): boolean;
/**
* Returns the framing rectangle of the ellipse as a Rectangle object
* @param out
* @returns The framing rectangle
*/
getBounds(out?: Rectangle): Rectangle;
/**
* Copies another ellipse to this one.
* @param ellipse - The ellipse to copy from.
* @returns Returns itself.
*/
copyFrom(ellipse: Ellipse): this;
/**
* Copies this ellipse to another one.
* @param ellipse - The ellipse to copy to.
* @returns Returns given parameter.
*/
copyTo(ellipse: Ellipse): Ellipse;
toString(): string;
}

110
node_modules/pixi.js/lib/maths/shapes/Ellipse.js generated vendored Normal file
View File

@@ -0,0 +1,110 @@
'use strict';
var Rectangle = require('./Rectangle.js');
"use strict";
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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'ellipse'
*/
this.type = "ellipse";
this.x = x;
this.y = y;
this.halfWidth = halfWidth;
this.halfHeight = halfHeight;
}
/**
* Creates a clone of this Ellipse instance
* @returns {Ellipse} A copy of the ellipse
*/
clone() {
return new Ellipse(this.x, this.y, this.halfWidth, this.halfHeight);
}
/**
* 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.halfWidth <= 0 || this.halfHeight <= 0) {
return false;
}
let normx = (x - this.x) / this.halfWidth;
let normy = (y - this.y) / this.halfHeight;
normx *= normx;
normy *= normy;
return normx + normy <= 1;
}
/**
* Checks whether the x and y coordinates given are contained within this ellipse including stroke
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param width
* @returns Whether the x/y coords are within this ellipse
*/
strokeContains(x, y, width) {
const { halfWidth, halfHeight } = this;
if (halfWidth <= 0 || halfHeight <= 0) {
return false;
}
const halfStrokeWidth = width / 2;
const innerA = halfWidth - halfStrokeWidth;
const innerB = halfHeight - halfStrokeWidth;
const outerA = halfWidth + halfStrokeWidth;
const outerB = halfHeight + halfStrokeWidth;
const normalizedX = x - this.x;
const normalizedY = y - this.y;
const innerEllipse = normalizedX * normalizedX / (innerA * innerA) + normalizedY * normalizedY / (innerB * innerB);
const outerEllipse = normalizedX * normalizedX / (outerA * outerA) + normalizedY * normalizedY / (outerB * outerB);
return innerEllipse > 1 && outerEllipse <= 1;
}
/**
* Returns the framing rectangle of the ellipse as a Rectangle object
* @param out
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle.Rectangle();
out.x = this.x - this.halfWidth;
out.y = this.y - this.halfHeight;
out.width = this.halfWidth * 2;
out.height = this.halfHeight * 2;
return out;
}
/**
* Copies another ellipse to this one.
* @param ellipse - The ellipse to copy from.
* @returns Returns itself.
*/
copyFrom(ellipse) {
this.x = ellipse.x;
this.y = ellipse.y;
this.halfWidth = ellipse.halfWidth;
this.halfHeight = ellipse.halfHeight;
return this;
}
/**
* Copies this ellipse to another one.
* @param ellipse - The ellipse to copy to.
* @returns Returns given parameter.
*/
copyTo(ellipse) {
ellipse.copyFrom(this);
return ellipse;
}
toString() {
return `[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`;
}
}
exports.Ellipse = Ellipse;
//# sourceMappingURL=Ellipse.js.map

1
node_modules/pixi.js/lib/maths/shapes/Ellipse.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

108
node_modules/pixi.js/lib/maths/shapes/Ellipse.mjs generated vendored Normal file
View File

@@ -0,0 +1,108 @@
import { Rectangle } from './Rectangle.mjs';
"use strict";
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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'ellipse'
*/
this.type = "ellipse";
this.x = x;
this.y = y;
this.halfWidth = halfWidth;
this.halfHeight = halfHeight;
}
/**
* Creates a clone of this Ellipse instance
* @returns {Ellipse} A copy of the ellipse
*/
clone() {
return new Ellipse(this.x, this.y, this.halfWidth, this.halfHeight);
}
/**
* 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.halfWidth <= 0 || this.halfHeight <= 0) {
return false;
}
let normx = (x - this.x) / this.halfWidth;
let normy = (y - this.y) / this.halfHeight;
normx *= normx;
normy *= normy;
return normx + normy <= 1;
}
/**
* Checks whether the x and y coordinates given are contained within this ellipse including stroke
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param width
* @returns Whether the x/y coords are within this ellipse
*/
strokeContains(x, y, width) {
const { halfWidth, halfHeight } = this;
if (halfWidth <= 0 || halfHeight <= 0) {
return false;
}
const halfStrokeWidth = width / 2;
const innerA = halfWidth - halfStrokeWidth;
const innerB = halfHeight - halfStrokeWidth;
const outerA = halfWidth + halfStrokeWidth;
const outerB = halfHeight + halfStrokeWidth;
const normalizedX = x - this.x;
const normalizedY = y - this.y;
const innerEllipse = normalizedX * normalizedX / (innerA * innerA) + normalizedY * normalizedY / (innerB * innerB);
const outerEllipse = normalizedX * normalizedX / (outerA * outerA) + normalizedY * normalizedY / (outerB * outerB);
return innerEllipse > 1 && outerEllipse <= 1;
}
/**
* Returns the framing rectangle of the ellipse as a Rectangle object
* @param out
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle();
out.x = this.x - this.halfWidth;
out.y = this.y - this.halfHeight;
out.width = this.halfWidth * 2;
out.height = this.halfHeight * 2;
return out;
}
/**
* Copies another ellipse to this one.
* @param ellipse - The ellipse to copy from.
* @returns Returns itself.
*/
copyFrom(ellipse) {
this.x = ellipse.x;
this.y = ellipse.y;
this.halfWidth = ellipse.halfWidth;
this.halfHeight = ellipse.halfHeight;
return this;
}
/**
* Copies this ellipse to another one.
* @param ellipse - The ellipse to copy to.
* @returns Returns given parameter.
*/
copyTo(ellipse) {
ellipse.copyFrom(this);
return ellipse;
}
toString() {
return `[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`;
}
}
export { Ellipse };
//# sourceMappingURL=Ellipse.mjs.map

File diff suppressed because one or more lines are too long

99
node_modules/pixi.js/lib/maths/shapes/Polygon.d.ts generated vendored Normal file
View File

@@ -0,0 +1,99 @@
import { Rectangle } from './Rectangle';
import type { SHAPE_PRIMITIVE } from '../misc/const';
import type { PointData } from '../point/PointData';
import type { ShapePrimitive } from './ShapePrimitive';
/**
* A class to define a shape via user defined coordinates.
*
*
* `Polygon` can accept the following different constructor arguments:
* - An array of `Point` objects
* - An array of coordinate pairs
*
*
* These can be passed as a single array, or as a sequence of arguments.
* ```js
* import { Polygon } from 'pixi.js';
*
* // create a polygon object from an array of points, or an array of coordinate pairs
* const polygon1 = new Polygon([ new Point(0, 0), new Point(0, 100), new Point(100, 100) ]);
* const polygon2 = new Polygon([ 0, 0, 0, 100, 100, 100 ]);
*
* // or create a polygon object from a sequence of points, or coordinate pairs
* const polygon3 = new Polygon(new Point(0, 0), new Point(0, 100), new Point(100, 100));
* const polygon4 = new Polygon(0, 0, 0, 100, 100, 100);
* ```
* @memberof maths
*/
export declare class Polygon implements ShapePrimitive {
/** An array of the points of this polygon. */
points: number[];
/** `false` after moveTo, `true` after `closePath`. In all other cases it is `true`. */
closePath: boolean;
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'polygon'
*/
readonly type: SHAPE_PRIMITIVE;
constructor(points: PointData[] | number[]);
constructor(...points: PointData[] | number[]);
/**
* Creates a clone of this polygon.
* @returns - A copy of the polygon.
*/
clone(): 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: number, y: number): boolean;
/**
* Checks whether the x and y coordinates given are contained within this polygon including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this polygon
*/
strokeContains(x: number, y: number, strokeWidth: number): boolean;
/**
* Returns the framing rectangle of the polygon as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out?: Rectangle): Rectangle;
/**
* Copies another polygon to this one.
* @param polygon - The polygon to copy from.
* @returns Returns itself.
*/
copyFrom(polygon: Polygon): this;
/**
* Copies this polygon to another one.
* @param polygon - The polygon to copy to.
* @returns Returns given parameter.
*/
copyTo(polygon: Polygon): Polygon;
toString(): string;
/**
* Get the last X coordinate of the polygon
* @readonly
*/
get lastX(): number;
/**
* Get the last Y coordinate of the polygon
* @readonly
*/
get lastY(): number;
/**
* Get the first X coordinate of the polygon
* @readonly
*/
get x(): number;
/**
* Get the first Y coordinate of the polygon
* @readonly
*/
get y(): number;
}

166
node_modules/pixi.js/lib/maths/shapes/Polygon.js generated vendored Normal file
View File

@@ -0,0 +1,166 @@
'use strict';
var squaredDistanceToLineSegment = require('../misc/squaredDistanceToLineSegment.js');
var Rectangle = require('./Rectangle.js');
"use strict";
class Polygon {
/**
* @param 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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'polygon'
*/
this.type = "polygon";
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.closePath = true;
}
/**
* Creates a clone of this polygon.
* @returns - A copy of the polygon.
*/
clone() {
const points = this.points.slice();
const polygon = new Polygon(points);
polygon.closePath = this.closePath;
return 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 = false;
const length = this.points.length / 2;
for (let i = 0, j = length - 1; i < length; j = i++) {
const xi = this.points[i * 2];
const yi = this.points[i * 2 + 1];
const xj = this.points[j * 2];
const yj = this.points[j * 2 + 1];
const intersect = yi > y !== yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi;
if (intersect) {
inside = !inside;
}
}
return inside;
}
/**
* Checks whether the x and y coordinates given are contained within this polygon including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this polygon
*/
strokeContains(x, y, strokeWidth) {
const halfStrokeWidth = strokeWidth / 2;
const halfStrokeWidthSqrd = halfStrokeWidth * halfStrokeWidth;
const { points } = this;
const iterationLength = points.length - (this.closePath ? 0 : 2);
for (let i = 0; i < iterationLength; i += 2) {
const x1 = points[i];
const y1 = points[i + 1];
const x2 = points[(i + 2) % points.length];
const y2 = points[(i + 3) % points.length];
const distanceSqrd = squaredDistanceToLineSegment.squaredDistanceToLineSegment(x, y, x1, y1, x2, y2);
if (distanceSqrd <= halfStrokeWidthSqrd) {
return true;
}
}
return false;
}
/**
* Returns the framing rectangle of the polygon as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle.Rectangle();
const points = this.points;
let minX = Infinity;
let maxX = -Infinity;
let minY = Infinity;
let maxY = -Infinity;
for (let i = 0, n = points.length; i < n; i += 2) {
const x = points[i];
const y = points[i + 1];
minX = x < minX ? x : minX;
maxX = x > maxX ? x : maxX;
minY = y < minY ? y : minY;
maxY = y > maxY ? y : maxY;
}
out.x = minX;
out.width = maxX - minX;
out.y = minY;
out.height = maxY - minY;
return out;
}
/**
* Copies another polygon to this one.
* @param polygon - The polygon to copy from.
* @returns Returns itself.
*/
copyFrom(polygon) {
this.points = polygon.points.slice();
this.closePath = polygon.closePath;
return this;
}
/**
* Copies this polygon to another one.
* @param polygon - The polygon to copy to.
* @returns Returns given parameter.
*/
copyTo(polygon) {
polygon.copyFrom(this);
return polygon;
}
toString() {
return `[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((pointsDesc, currentPoint) => `${pointsDesc}, ${currentPoint}`, "")}]`;
}
/**
* Get the last X coordinate of the polygon
* @readonly
*/
get lastX() {
return this.points[this.points.length - 2];
}
/**
* Get the last Y coordinate of the polygon
* @readonly
*/
get lastY() {
return this.points[this.points.length - 1];
}
/**
* Get the first X coordinate of the polygon
* @readonly
*/
get x() {
return this.points[this.points.length - 2];
}
/**
* Get the first Y coordinate of the polygon
* @readonly
*/
get y() {
return this.points[this.points.length - 1];
}
}
exports.Polygon = Polygon;
//# sourceMappingURL=Polygon.js.map

1
node_modules/pixi.js/lib/maths/shapes/Polygon.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

164
node_modules/pixi.js/lib/maths/shapes/Polygon.mjs generated vendored Normal file
View File

@@ -0,0 +1,164 @@
import { squaredDistanceToLineSegment } from '../misc/squaredDistanceToLineSegment.mjs';
import { Rectangle } from './Rectangle.mjs';
"use strict";
class Polygon {
/**
* @param 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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'polygon'
*/
this.type = "polygon";
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.closePath = true;
}
/**
* Creates a clone of this polygon.
* @returns - A copy of the polygon.
*/
clone() {
const points = this.points.slice();
const polygon = new Polygon(points);
polygon.closePath = this.closePath;
return 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 = false;
const length = this.points.length / 2;
for (let i = 0, j = length - 1; i < length; j = i++) {
const xi = this.points[i * 2];
const yi = this.points[i * 2 + 1];
const xj = this.points[j * 2];
const yj = this.points[j * 2 + 1];
const intersect = yi > y !== yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi;
if (intersect) {
inside = !inside;
}
}
return inside;
}
/**
* Checks whether the x and y coordinates given are contained within this polygon including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this polygon
*/
strokeContains(x, y, strokeWidth) {
const halfStrokeWidth = strokeWidth / 2;
const halfStrokeWidthSqrd = halfStrokeWidth * halfStrokeWidth;
const { points } = this;
const iterationLength = points.length - (this.closePath ? 0 : 2);
for (let i = 0; i < iterationLength; i += 2) {
const x1 = points[i];
const y1 = points[i + 1];
const x2 = points[(i + 2) % points.length];
const y2 = points[(i + 3) % points.length];
const distanceSqrd = squaredDistanceToLineSegment(x, y, x1, y1, x2, y2);
if (distanceSqrd <= halfStrokeWidthSqrd) {
return true;
}
}
return false;
}
/**
* Returns the framing rectangle of the polygon as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle();
const points = this.points;
let minX = Infinity;
let maxX = -Infinity;
let minY = Infinity;
let maxY = -Infinity;
for (let i = 0, n = points.length; i < n; i += 2) {
const x = points[i];
const y = points[i + 1];
minX = x < minX ? x : minX;
maxX = x > maxX ? x : maxX;
minY = y < minY ? y : minY;
maxY = y > maxY ? y : maxY;
}
out.x = minX;
out.width = maxX - minX;
out.y = minY;
out.height = maxY - minY;
return out;
}
/**
* Copies another polygon to this one.
* @param polygon - The polygon to copy from.
* @returns Returns itself.
*/
copyFrom(polygon) {
this.points = polygon.points.slice();
this.closePath = polygon.closePath;
return this;
}
/**
* Copies this polygon to another one.
* @param polygon - The polygon to copy to.
* @returns Returns given parameter.
*/
copyTo(polygon) {
polygon.copyFrom(this);
return polygon;
}
toString() {
return `[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((pointsDesc, currentPoint) => `${pointsDesc}, ${currentPoint}`, "")}]`;
}
/**
* Get the last X coordinate of the polygon
* @readonly
*/
get lastX() {
return this.points[this.points.length - 2];
}
/**
* Get the last Y coordinate of the polygon
* @readonly
*/
get lastY() {
return this.points[this.points.length - 1];
}
/**
* Get the first X coordinate of the polygon
* @readonly
*/
get x() {
return this.points[this.points.length - 2];
}
/**
* Get the first Y coordinate of the polygon
* @readonly
*/
get y() {
return this.points[this.points.length - 1];
}
}
export { Polygon };
//# sourceMappingURL=Polygon.mjs.map

File diff suppressed because one or more lines are too long

142
node_modules/pixi.js/lib/maths/shapes/Rectangle.d.ts generated vendored Normal file
View File

@@ -0,0 +1,142 @@
import type { Bounds } from '../../scene/container/bounds/Bounds';
import type { Matrix } from '../matrix/Matrix';
import type { SHAPE_PRIMITIVE } from '../misc/const';
import type { ShapePrimitive } from './ShapePrimitive';
export interface Rectangle extends PixiMixins.Rectangle {
}
/**
* The `Rectangle` object is an area defined by its position, as indicated by its top-left corner
* point (`x`, `y`) and by its `width` and its `height`.
*
* It also provides convenience methods to get and set the position and size of the rectangle such as
* {@link maths.Rectangle#bottom|bottom}, {@link maths.Rectangle#right|right} and {@link maths.Rectangle#isEmpty|isEmpty}.
* @memberof maths
*/
export declare class Rectangle implements ShapePrimitive {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'rectangle'
*/
readonly type: SHAPE_PRIMITIVE;
/**
* The X coordinate of the upper-left corner of the rectangle
* @default 0
*/
x: number;
/**
* The Y coordinate of the upper-left corner of the rectangle
* @default 0
*/
y: number;
/**
* The overall width of this rectangle
* @default 0
*/
width: number;
/**
* The overall height of this rectangle
* @default 0
*/
height: number;
/**
* @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?: string | number, y?: string | number, width?: string | number, height?: string | number);
/** Returns the left edge of the rectangle. */
get left(): number;
/** Returns the right edge of the rectangle. */
get right(): number;
/** Returns the top edge of the rectangle. */
get top(): number;
/** Returns the bottom edge of the rectangle. */
get bottom(): number;
/** Determines whether the Rectangle is empty. */
isEmpty(): boolean;
/** A constant empty rectangle. This is a new object every time the property is accessed */
static get EMPTY(): Rectangle;
/**
* Creates a clone of this Rectangle
* @returns a copy of the rectangle
*/
clone(): Rectangle;
/**
* Converts a Bounds object to a Rectangle object.
* @param bounds - The bounds to copy and convert to a rectangle.
* @returns Returns itself.
*/
copyFromBounds(bounds: Bounds): this;
/**
* Copies another rectangle to this one.
* @param rectangle - The rectangle to copy from.
* @returns Returns itself.
*/
copyFrom(rectangle: Rectangle): Rectangle;
/**
* Copies this rectangle to another one.
* @param rectangle - The rectangle to copy to.
* @returns Returns given parameter.
*/
copyTo(rectangle: Rectangle): 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: number, y: number): boolean;
/**
* Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this rectangle
*/
strokeContains(x: number, y: number, strokeWidth: number): boolean;
/**
* 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: Rectangle, transform?: Matrix): boolean;
/**
* 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?: number, paddingY?: number): this;
/**
* Fits this rectangle around the passed one.
* @param rectangle - The rectangle to fit.
* @returns Returns itself.
*/
fit(rectangle: Rectangle): this;
/**
* Enlarges rectangle that way its corners lie on grid
* @param resolution - resolution
* @param eps - precision
* @returns Returns itself.
*/
ceil(resolution?: number, eps?: number): this;
/**
* Enlarges this rectangle to include the passed rectangle.
* @param rectangle - The rectangle to include.
* @returns Returns itself.
*/
enlarge(rectangle: Rectangle): this;
/**
* Returns the framing rectangle of the rectangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out?: Rectangle): Rectangle;
toString(): string;
}

271
node_modules/pixi.js/lib/maths/shapes/Rectangle.js generated vendored Normal file
View File

@@ -0,0 +1,271 @@
'use strict';
var Point = require('../point/Point.js');
"use strict";
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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'rectangle'
*/
this.type = "rectangle";
this.x = Number(x);
this.y = Number(y);
this.width = Number(width);
this.height = Number(height);
}
/** 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;
}
/** Determines whether the Rectangle is empty. */
isEmpty() {
return this.left === this.right || this.top === this.bottom;
}
/** A constant empty rectangle. This is a new object every time the property is accessed */
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);
}
/**
* Converts a Bounds object to a Rectangle object.
* @param bounds - The bounds to copy and convert to a rectangle.
* @returns Returns itself.
*/
copyFromBounds(bounds) {
this.x = bounds.minX;
this.y = bounds.minY;
this.width = bounds.maxX - bounds.minX;
this.height = bounds.maxY - bounds.minY;
return this;
}
/**
* Copies another rectangle to this one.
* @param rectangle - The rectangle to copy from.
* @returns Returns itself.
*/
copyFrom(rectangle) {
this.x = rectangle.x;
this.y = rectangle.y;
this.width = rectangle.width;
this.height = rectangle.height;
return this;
}
/**
* Copies this rectangle to another one.
* @param rectangle - The rectangle to copy to.
* @returns Returns given parameter.
*/
copyTo(rectangle) {
rectangle.copyFrom(this);
return 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) {
if (this.width <= 0 || this.height <= 0) {
return false;
}
if (x >= this.x && x < this.x + this.width) {
if (y >= this.y && y < this.y + this.height) {
return true;
}
}
return false;
}
/**
* Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this rectangle
*/
strokeContains(x, y, strokeWidth) {
const { width, height } = this;
if (width <= 0 || height <= 0)
return false;
const _x = this.x;
const _y = this.y;
const outerLeft = _x - strokeWidth / 2;
const outerRight = _x + width + strokeWidth / 2;
const outerTop = _y - strokeWidth / 2;
const outerBottom = _y + height + strokeWidth / 2;
const innerLeft = _x + strokeWidth / 2;
const innerRight = _x + width - strokeWidth / 2;
const innerTop = _y + strokeWidth / 2;
const innerBottom = _y + height - strokeWidth / 2;
return x >= outerLeft && x <= outerRight && y >= outerTop && y <= outerBottom && !(x > innerLeft && x < innerRight && y > innerTop && y < innerBottom);
}
/**
* 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;
const x12 = this.right > other.right ? other.right : this.right;
if (x12 <= x02) {
return false;
}
const y02 = this.y < other.y ? other.y : this.y;
const y12 = this.bottom > other.bottom ? other.bottom : this.bottom;
return y12 > y02;
}
const x0 = this.left;
const x1 = this.right;
const y0 = this.top;
const y1 = this.bottom;
if (x1 <= x0 || y1 <= y0) {
return false;
}
const lt = tempPoints[0].set(other.left, other.top);
const lb = tempPoints[1].set(other.left, other.bottom);
const rt = tempPoints[2].set(other.right, other.top);
const rb = tempPoints[3].set(other.right, other.bottom);
if (rt.x <= lt.x || lb.y <= lt.y) {
return false;
}
const s = Math.sign(transform.a * transform.d - transform.b * transform.c);
if (s === 0) {
return false;
}
transform.apply(lt, lt);
transform.apply(lb, lb);
transform.apply(rt, rt);
transform.apply(rb, rb);
if (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 false;
}
const nx = s * (lb.y - lt.y);
const ny = s * (lt.x - lb.x);
const n00 = nx * x0 + ny * y0;
const n10 = nx * x1 + ny * y0;
const n01 = nx * x0 + ny * y1;
const 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 false;
}
const mx = s * (lt.y - rt.y);
const my = s * (rt.x - lt.x);
const m00 = mx * x0 + my * y0;
const m10 = mx * x1 + my * y0;
const m01 = mx * x0 + my * y1;
const m11 = mx * x1 + my * y1;
if (Math.max(m00, m10, m01, m11) <= mx * lt.x + my * lt.y || Math.min(m00, m10, m01, m11) >= mx * rb.x + my * rb.y) {
return false;
}
return true;
}
/**
* 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) {
this.x -= paddingX;
this.y -= paddingY;
this.width += paddingX * 2;
this.height += paddingY * 2;
return 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);
const x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);
const y1 = Math.max(this.y, rectangle.y);
const y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
this.x = x1;
this.width = Math.max(x2 - x1, 0);
this.y = y1;
this.height = Math.max(y2 - y1, 0);
return 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;
const y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
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;
return 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);
const x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);
const y1 = Math.min(this.y, rectangle.y);
const y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
this.x = x1;
this.width = x2 - x1;
this.y = y1;
this.height = y2 - y1;
return this;
}
/**
* Returns the framing rectangle of the rectangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle();
out.copyFrom(this);
return out;
}
toString() {
return `[pixi.js/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

269
node_modules/pixi.js/lib/maths/shapes/Rectangle.mjs generated vendored Normal file
View File

@@ -0,0 +1,269 @@
import { Point } from '../point/Point.mjs';
"use strict";
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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'rectangle'
*/
this.type = "rectangle";
this.x = Number(x);
this.y = Number(y);
this.width = Number(width);
this.height = Number(height);
}
/** 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;
}
/** Determines whether the Rectangle is empty. */
isEmpty() {
return this.left === this.right || this.top === this.bottom;
}
/** A constant empty rectangle. This is a new object every time the property is accessed */
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);
}
/**
* Converts a Bounds object to a Rectangle object.
* @param bounds - The bounds to copy and convert to a rectangle.
* @returns Returns itself.
*/
copyFromBounds(bounds) {
this.x = bounds.minX;
this.y = bounds.minY;
this.width = bounds.maxX - bounds.minX;
this.height = bounds.maxY - bounds.minY;
return this;
}
/**
* Copies another rectangle to this one.
* @param rectangle - The rectangle to copy from.
* @returns Returns itself.
*/
copyFrom(rectangle) {
this.x = rectangle.x;
this.y = rectangle.y;
this.width = rectangle.width;
this.height = rectangle.height;
return this;
}
/**
* Copies this rectangle to another one.
* @param rectangle - The rectangle to copy to.
* @returns Returns given parameter.
*/
copyTo(rectangle) {
rectangle.copyFrom(this);
return 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) {
if (this.width <= 0 || this.height <= 0) {
return false;
}
if (x >= this.x && x < this.x + this.width) {
if (y >= this.y && y < this.y + this.height) {
return true;
}
}
return false;
}
/**
* Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
* @param x - The X coordinate of the point to test
* @param y - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this rectangle
*/
strokeContains(x, y, strokeWidth) {
const { width, height } = this;
if (width <= 0 || height <= 0)
return false;
const _x = this.x;
const _y = this.y;
const outerLeft = _x - strokeWidth / 2;
const outerRight = _x + width + strokeWidth / 2;
const outerTop = _y - strokeWidth / 2;
const outerBottom = _y + height + strokeWidth / 2;
const innerLeft = _x + strokeWidth / 2;
const innerRight = _x + width - strokeWidth / 2;
const innerTop = _y + strokeWidth / 2;
const innerBottom = _y + height - strokeWidth / 2;
return x >= outerLeft && x <= outerRight && y >= outerTop && y <= outerBottom && !(x > innerLeft && x < innerRight && y > innerTop && y < innerBottom);
}
/**
* 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;
const x12 = this.right > other.right ? other.right : this.right;
if (x12 <= x02) {
return false;
}
const y02 = this.y < other.y ? other.y : this.y;
const y12 = this.bottom > other.bottom ? other.bottom : this.bottom;
return y12 > y02;
}
const x0 = this.left;
const x1 = this.right;
const y0 = this.top;
const y1 = this.bottom;
if (x1 <= x0 || y1 <= y0) {
return false;
}
const lt = tempPoints[0].set(other.left, other.top);
const lb = tempPoints[1].set(other.left, other.bottom);
const rt = tempPoints[2].set(other.right, other.top);
const rb = tempPoints[3].set(other.right, other.bottom);
if (rt.x <= lt.x || lb.y <= lt.y) {
return false;
}
const s = Math.sign(transform.a * transform.d - transform.b * transform.c);
if (s === 0) {
return false;
}
transform.apply(lt, lt);
transform.apply(lb, lb);
transform.apply(rt, rt);
transform.apply(rb, rb);
if (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 false;
}
const nx = s * (lb.y - lt.y);
const ny = s * (lt.x - lb.x);
const n00 = nx * x0 + ny * y0;
const n10 = nx * x1 + ny * y0;
const n01 = nx * x0 + ny * y1;
const 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 false;
}
const mx = s * (lt.y - rt.y);
const my = s * (rt.x - lt.x);
const m00 = mx * x0 + my * y0;
const m10 = mx * x1 + my * y0;
const m01 = mx * x0 + my * y1;
const m11 = mx * x1 + my * y1;
if (Math.max(m00, m10, m01, m11) <= mx * lt.x + my * lt.y || Math.min(m00, m10, m01, m11) >= mx * rb.x + my * rb.y) {
return false;
}
return true;
}
/**
* 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) {
this.x -= paddingX;
this.y -= paddingY;
this.width += paddingX * 2;
this.height += paddingY * 2;
return 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);
const x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);
const y1 = Math.max(this.y, rectangle.y);
const y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
this.x = x1;
this.width = Math.max(x2 - x1, 0);
this.y = y1;
this.height = Math.max(y2 - y1, 0);
return 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;
const y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
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;
return 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);
const x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);
const y1 = Math.min(this.y, rectangle.y);
const y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
this.x = x1;
this.width = x2 - x1;
this.y = y1;
this.height = y2 - y1;
return this;
}
/**
* Returns the framing rectangle of the rectangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle();
out.copyFrom(this);
return out;
}
toString() {
return `[pixi.js/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,87 @@
import { Rectangle } from './Rectangle';
import type { ShapePrimitive } from './ShapePrimitive';
/**
* The `RoundedRectangle` object is an area defined by its position, as indicated by its top-left corner
* point (`x`, `y`) and by its `width` and its `height`, including a `radius` property that
* defines the radius of the rounded corners.
* @memberof maths
*/
export declare class RoundedRectangle implements ShapePrimitive {
/**
* The X coordinate of the upper-left corner of the rounded rectangle
* @default 0
*/
x: number;
/**
* The Y coordinate of the upper-left corner of the rounded rectangle
* @default 0
*/
y: number;
/**
* The overall width of this rounded rectangle
* @default 0
*/
width: number;
/**
* The overall height of this rounded rectangle
* @default 0
*/
height: number;
/**
* Controls the radius of the rounded corners
* @default 20
*/
radius: number;
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'roundedRectangle'
*/
readonly type = "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?: number, y?: number, width?: number, height?: number, radius?: number);
/**
* Returns the framing rectangle of the rounded rectangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out?: Rectangle): Rectangle;
/**
* Creates a clone of this Rounded Rectangle.
* @returns - A copy of the rounded rectangle.
*/
clone(): RoundedRectangle;
/**
* Copies another rectangle to this one.
* @param rectangle - The rectangle to copy from.
* @returns Returns itself.
*/
copyFrom(rectangle: RoundedRectangle): this;
/**
* Copies this rectangle to another one.
* @param rectangle - The rectangle to copy to.
* @returns Returns given parameter.
*/
copyTo(rectangle: RoundedRectangle): RoundedRectangle;
/**
* 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: number, y: number): boolean;
/**
* Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
* @param pX - The X coordinate of the point to test
* @param pY - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this rectangle
*/
strokeContains(pX: number, pY: number, strokeWidth: number): boolean;
toString(): string;
}

View File

@@ -0,0 +1,144 @@
'use strict';
var Rectangle = require('./Rectangle.js');
"use strict";
const isCornerWithinStroke = (pX, pY, cornerX, cornerY, radius, halfStrokeWidth) => {
const dx = pX - cornerX;
const dy = pY - cornerY;
const distance = Math.sqrt(dx * dx + dy * dy);
return distance >= radius - halfStrokeWidth && distance <= radius + halfStrokeWidth;
};
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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'roundedRectangle'
*/
this.type = "roundedRectangle";
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.radius = radius;
}
/**
* Returns the framing rectangle of the rounded rectangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle.Rectangle();
out.x = this.x;
out.y = this.y;
out.width = this.width;
out.height = this.height;
return out;
}
/**
* 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);
}
/**
* Copies another rectangle to this one.
* @param rectangle - The rectangle to copy from.
* @returns Returns itself.
*/
copyFrom(rectangle) {
this.x = rectangle.x;
this.y = rectangle.y;
this.width = rectangle.width;
this.height = rectangle.height;
return this;
}
/**
* Copies this rectangle to another one.
* @param rectangle - The rectangle to copy to.
* @returns Returns given parameter.
*/
copyTo(rectangle) {
rectangle.copyFrom(this);
return rectangle;
}
/**
* 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 false;
}
if (x >= this.x && x <= this.x + this.width) {
if (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 true;
}
let dx = x - (this.x + radius);
let dy = y - (this.y + radius);
const radius2 = radius * radius;
if (dx * dx + dy * dy <= radius2) {
return true;
}
dx = x - (this.x + this.width - radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
dy = y - (this.y + this.height - radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
dx = x - (this.x + radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
}
}
return false;
}
/**
* Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
* @param pX - The X coordinate of the point to test
* @param pY - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this rectangle
*/
strokeContains(pX, pY, strokeWidth) {
const { x, y, width, height, radius } = this;
const halfStrokeWidth = strokeWidth / 2;
const innerX = x + radius;
const innerY = y + radius;
const innerWidth = width - radius * 2;
const innerHeight = height - radius * 2;
const rightBound = x + width;
const bottomBound = y + height;
if ((pX >= x - halfStrokeWidth && pX <= x + halfStrokeWidth || pX >= rightBound - halfStrokeWidth && pX <= rightBound + halfStrokeWidth) && pY >= innerY && pY <= innerY + innerHeight) {
return true;
}
if ((pY >= y - halfStrokeWidth && pY <= y + halfStrokeWidth || pY >= bottomBound - halfStrokeWidth && pY <= bottomBound + halfStrokeWidth) && pX >= innerX && pX <= innerX + innerWidth) {
return true;
}
return (
// Top-left
pX < innerX && pY < innerY && isCornerWithinStroke(pX, pY, innerX, innerY, radius, halfStrokeWidth) || pX > rightBound - radius && pY < innerY && isCornerWithinStroke(pX, pY, rightBound - radius, innerY, radius, halfStrokeWidth) || pX > rightBound - radius && pY > bottomBound - radius && isCornerWithinStroke(pX, pY, rightBound - radius, bottomBound - radius, radius, halfStrokeWidth) || pX < innerX && pY > bottomBound - radius && isCornerWithinStroke(pX, pY, innerX, bottomBound - radius, radius, halfStrokeWidth)
);
}
toString() {
return `[pixi.js/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,142 @@
import { Rectangle } from './Rectangle.mjs';
"use strict";
const isCornerWithinStroke = (pX, pY, cornerX, cornerY, radius, halfStrokeWidth) => {
const dx = pX - cornerX;
const dy = pY - cornerY;
const distance = Math.sqrt(dx * dx + dy * dy);
return distance >= radius - halfStrokeWidth && distance <= radius + halfStrokeWidth;
};
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) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'roundedRectangle'
*/
this.type = "roundedRectangle";
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.radius = radius;
}
/**
* Returns the framing rectangle of the rounded rectangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle();
out.x = this.x;
out.y = this.y;
out.width = this.width;
out.height = this.height;
return out;
}
/**
* 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);
}
/**
* Copies another rectangle to this one.
* @param rectangle - The rectangle to copy from.
* @returns Returns itself.
*/
copyFrom(rectangle) {
this.x = rectangle.x;
this.y = rectangle.y;
this.width = rectangle.width;
this.height = rectangle.height;
return this;
}
/**
* Copies this rectangle to another one.
* @param rectangle - The rectangle to copy to.
* @returns Returns given parameter.
*/
copyTo(rectangle) {
rectangle.copyFrom(this);
return rectangle;
}
/**
* 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 false;
}
if (x >= this.x && x <= this.x + this.width) {
if (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 true;
}
let dx = x - (this.x + radius);
let dy = y - (this.y + radius);
const radius2 = radius * radius;
if (dx * dx + dy * dy <= radius2) {
return true;
}
dx = x - (this.x + this.width - radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
dy = y - (this.y + this.height - radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
dx = x - (this.x + radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
}
}
return false;
}
/**
* Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
* @param pX - The X coordinate of the point to test
* @param pY - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this rectangle
*/
strokeContains(pX, pY, strokeWidth) {
const { x, y, width, height, radius } = this;
const halfStrokeWidth = strokeWidth / 2;
const innerX = x + radius;
const innerY = y + radius;
const innerWidth = width - radius * 2;
const innerHeight = height - radius * 2;
const rightBound = x + width;
const bottomBound = y + height;
if ((pX >= x - halfStrokeWidth && pX <= x + halfStrokeWidth || pX >= rightBound - halfStrokeWidth && pX <= rightBound + halfStrokeWidth) && pY >= innerY && pY <= innerY + innerHeight) {
return true;
}
if ((pY >= y - halfStrokeWidth && pY <= y + halfStrokeWidth || pY >= bottomBound - halfStrokeWidth && pY <= bottomBound + halfStrokeWidth) && pX >= innerX && pX <= innerX + innerWidth) {
return true;
}
return (
// Top-left
pX < innerX && pY < innerY && isCornerWithinStroke(pX, pY, innerX, innerY, radius, halfStrokeWidth) || pX > rightBound - radius && pY < innerY && isCornerWithinStroke(pX, pY, rightBound - radius, innerY, radius, halfStrokeWidth) || pX > rightBound - radius && pY > bottomBound - radius && isCornerWithinStroke(pX, pY, rightBound - radius, bottomBound - radius, radius, halfStrokeWidth) || pX < innerX && pY > bottomBound - radius && isCornerWithinStroke(pX, pY, innerX, bottomBound - radius, radius, halfStrokeWidth)
);
}
toString() {
return `[pixi.js/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

View File

@@ -0,0 +1,26 @@
import type { SHAPE_PRIMITIVE } from '../misc/const';
import type { Rectangle } from './Rectangle';
/**
* A basic object to define a Pixi shape.
* @memberof maths
*/
export interface ShapePrimitive {
/** The type of the object, mainly used to avoid `instanceof` checks */
readonly type: SHAPE_PRIMITIVE;
/** Checks whether the x and y coordinates passed to this function are contained within this ShapePrimitive. */
contains(x: number, y: number): boolean;
/** Checks whether the x and y coordinates passed to this function are contained within the stroke of this shape */
strokeContains(x: number, y: number, strokeWidth: number): boolean;
/** Creates a clone of this ShapePrimitive instance. */
clone(): ShapePrimitive;
/** Copies the properties from another ShapePrimitive to this ShapePrimitive. */
copyFrom(source: ShapePrimitive): void;
/** Copies the properties from this ShapePrimitive to another ShapePrimitive. */
copyTo(destination: ShapePrimitive): void;
/** Returns the framing rectangle of the ShapePrimitive as a Rectangle object. */
getBounds(out?: Rectangle): Rectangle;
/** The X coordinate of the shape */
readonly x: number;
/** The Y coordinate of the shape */
readonly y: number;
}

View File

@@ -0,0 +1,4 @@
'use strict';
"use strict";
//# sourceMappingURL=ShapePrimitive.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ShapePrimitive.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}

View File

@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=ShapePrimitive.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ShapePrimitive.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}

99
node_modules/pixi.js/lib/maths/shapes/Triangle.d.ts generated vendored Normal file
View File

@@ -0,0 +1,99 @@
import { Rectangle } from './Rectangle';
import type { SHAPE_PRIMITIVE } from '../misc/const';
import type { ShapePrimitive } from './ShapePrimitive';
/**
* A class to define a shape of a triangle via user defined coordinates.
*
* Create a `Triangle` object with the `x`, `y`, `x2`, `y2`, `x3`, `y3` properties.
*
* ```js
* import { Triangle } from 'pixi.js';
*
* const triangle = new Triangle(0, 0, 100, 0, 50, 50);
* ```
* @memberof maths
*/
export declare class Triangle implements ShapePrimitive {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'triangle'
*/
readonly type: SHAPE_PRIMITIVE;
/**
* The X coord of the first point.
* @default 0
*/
x: number;
/**
* The Y coord of the first point.
* @default 0
*/
y: number;
/**
* The X coord of the second point.
* @default 0
*/
x2: number;
/**
* The Y coord of the second point.
* @default 0
*/
y2: number;
/**
* The X coord of the third point.
* @default 0
*/
x3: number;
/**
* The Y coord of the third point.
* @default 0
*/
y3: number;
/**
* @param x - The X coord of the first point.
* @param y - The Y coord of the first point.
* @param x2 - The X coord of the second point.
* @param y2 - The Y coord of the second point.
* @param x3 - The X coord of the third point.
* @param y3 - The Y coord of the third point.
*/
constructor(x?: number, y?: number, x2?: number, y2?: number, x3?: number, y3?: number);
/**
* Checks whether the x and y coordinates given are contained within this triangle
* @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 Triangle
*/
contains(x: number, y: number): boolean;
/**
* Checks whether the x and y coordinates given are contained within this triangle including the stroke.
* @param pointX - The X coordinate of the point to test
* @param pointY - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this triangle
*/
strokeContains(pointX: number, pointY: number, strokeWidth: number): boolean;
/**
* Creates a clone of this Triangle
* @returns a copy of the triangle
*/
clone(): ShapePrimitive;
/**
* Copies another triangle to this one.
* @param triangle - The triangle to copy from.
* @returns Returns itself.
*/
copyFrom(triangle: Triangle): this;
/**
* Copies this triangle to another one.
* @param triangle - The triangle to copy to.
* @returns Returns given parameter.
*/
copyTo(triangle: Triangle): Triangle;
/**
* Returns the framing rectangle of the triangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out?: Rectangle): Rectangle;
}

118
node_modules/pixi.js/lib/maths/shapes/Triangle.js generated vendored Normal file
View File

@@ -0,0 +1,118 @@
'use strict';
var squaredDistanceToLineSegment = require('../misc/squaredDistanceToLineSegment.js');
var Rectangle = require('./Rectangle.js');
"use strict";
class Triangle {
/**
* @param x - The X coord of the first point.
* @param y - The Y coord of the first point.
* @param x2 - The X coord of the second point.
* @param y2 - The Y coord of the second point.
* @param x3 - The X coord of the third point.
* @param y3 - The Y coord of the third point.
*/
constructor(x = 0, y = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'triangle'
*/
this.type = "triangle";
this.x = x;
this.y = y;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
}
/**
* Checks whether the x and y coordinates given are contained within this triangle
* @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 Triangle
*/
contains(x, y) {
const s = (this.x - this.x3) * (y - this.y3) - (this.y - this.y3) * (x - this.x3);
const t = (this.x2 - this.x) * (y - this.y) - (this.y2 - this.y) * (x - this.x);
if (s < 0 !== t < 0 && s !== 0 && t !== 0) {
return false;
}
const d = (this.x3 - this.x2) * (y - this.y2) - (this.y3 - this.y2) * (x - this.x2);
return d === 0 || d < 0 === s + t <= 0;
}
/**
* Checks whether the x and y coordinates given are contained within this triangle including the stroke.
* @param pointX - The X coordinate of the point to test
* @param pointY - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this triangle
*/
strokeContains(pointX, pointY, strokeWidth) {
const halfStrokeWidth = strokeWidth / 2;
const halfStrokeWidthSquared = halfStrokeWidth * halfStrokeWidth;
const { x, x2, x3, y, y2, y3 } = this;
if (squaredDistanceToLineSegment.squaredDistanceToLineSegment(pointX, pointY, x, y, x2, y3) <= halfStrokeWidthSquared || squaredDistanceToLineSegment.squaredDistanceToLineSegment(pointX, pointY, x2, y2, x3, y3) <= halfStrokeWidthSquared || squaredDistanceToLineSegment.squaredDistanceToLineSegment(pointX, pointY, x3, y3, x, y) <= halfStrokeWidthSquared) {
return true;
}
return false;
}
/**
* Creates a clone of this Triangle
* @returns a copy of the triangle
*/
clone() {
const triangle = new Triangle(
this.x,
this.y,
this.x2,
this.y2,
this.x3,
this.y3
);
return triangle;
}
/**
* Copies another triangle to this one.
* @param triangle - The triangle to copy from.
* @returns Returns itself.
*/
copyFrom(triangle) {
this.x = triangle.x;
this.y = triangle.y;
this.x2 = triangle.x2;
this.y2 = triangle.y2;
this.x3 = triangle.x3;
this.y3 = triangle.y3;
return this;
}
/**
* Copies this triangle to another one.
* @param triangle - The triangle to copy to.
* @returns Returns given parameter.
*/
copyTo(triangle) {
triangle.copyFrom(this);
return triangle;
}
/**
* Returns the framing rectangle of the triangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle.Rectangle();
const minX = Math.min(this.x, this.x2, this.x3);
const maxX = Math.max(this.x, this.x2, this.x3);
const minY = Math.min(this.y, this.y2, this.y3);
const maxY = Math.max(this.y, this.y2, this.y3);
out.x = minX;
out.y = minY;
out.width = maxX - minX;
out.height = maxY - minY;
return out;
}
}
exports.Triangle = Triangle;
//# sourceMappingURL=Triangle.js.map

File diff suppressed because one or more lines are too long

116
node_modules/pixi.js/lib/maths/shapes/Triangle.mjs generated vendored Normal file
View File

@@ -0,0 +1,116 @@
import { squaredDistanceToLineSegment } from '../misc/squaredDistanceToLineSegment.mjs';
import { Rectangle } from './Rectangle.mjs';
"use strict";
class Triangle {
/**
* @param x - The X coord of the first point.
* @param y - The Y coord of the first point.
* @param x2 - The X coord of the second point.
* @param y2 - The Y coord of the second point.
* @param x3 - The X coord of the third point.
* @param y3 - The Y coord of the third point.
*/
constructor(x = 0, y = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0) {
/**
* The type of the object, mainly used to avoid `instanceof` checks
* @default 'triangle'
*/
this.type = "triangle";
this.x = x;
this.y = y;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
}
/**
* Checks whether the x and y coordinates given are contained within this triangle
* @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 Triangle
*/
contains(x, y) {
const s = (this.x - this.x3) * (y - this.y3) - (this.y - this.y3) * (x - this.x3);
const t = (this.x2 - this.x) * (y - this.y) - (this.y2 - this.y) * (x - this.x);
if (s < 0 !== t < 0 && s !== 0 && t !== 0) {
return false;
}
const d = (this.x3 - this.x2) * (y - this.y2) - (this.y3 - this.y2) * (x - this.x2);
return d === 0 || d < 0 === s + t <= 0;
}
/**
* Checks whether the x and y coordinates given are contained within this triangle including the stroke.
* @param pointX - The X coordinate of the point to test
* @param pointY - The Y coordinate of the point to test
* @param strokeWidth - The width of the line to check
* @returns Whether the x/y coordinates are within this triangle
*/
strokeContains(pointX, pointY, strokeWidth) {
const halfStrokeWidth = strokeWidth / 2;
const halfStrokeWidthSquared = halfStrokeWidth * halfStrokeWidth;
const { x, x2, x3, y, y2, y3 } = this;
if (squaredDistanceToLineSegment(pointX, pointY, x, y, x2, y3) <= halfStrokeWidthSquared || squaredDistanceToLineSegment(pointX, pointY, x2, y2, x3, y3) <= halfStrokeWidthSquared || squaredDistanceToLineSegment(pointX, pointY, x3, y3, x, y) <= halfStrokeWidthSquared) {
return true;
}
return false;
}
/**
* Creates a clone of this Triangle
* @returns a copy of the triangle
*/
clone() {
const triangle = new Triangle(
this.x,
this.y,
this.x2,
this.y2,
this.x3,
this.y3
);
return triangle;
}
/**
* Copies another triangle to this one.
* @param triangle - The triangle to copy from.
* @returns Returns itself.
*/
copyFrom(triangle) {
this.x = triangle.x;
this.y = triangle.y;
this.x2 = triangle.x2;
this.y2 = triangle.y2;
this.x3 = triangle.x3;
this.y3 = triangle.y3;
return this;
}
/**
* Copies this triangle to another one.
* @param triangle - The triangle to copy to.
* @returns Returns given parameter.
*/
copyTo(triangle) {
triangle.copyFrom(this);
return triangle;
}
/**
* Returns the framing rectangle of the triangle as a Rectangle object
* @param out - optional rectangle to store the result
* @returns The framing rectangle
*/
getBounds(out) {
out = out || new Rectangle();
const minX = Math.min(this.x, this.x2, this.x3);
const maxX = Math.max(this.x, this.x2, this.x3);
const minY = Math.min(this.y, this.y2, this.y3);
const maxY = Math.max(this.y, this.y2, this.y3);
out.x = minX;
out.y = minY;
out.width = maxX - minX;
out.height = maxY - minY;
return out;
}
}
export { Triangle };
//# sourceMappingURL=Triangle.mjs.map

File diff suppressed because one or more lines are too long