1 line
3.3 KiB
Plaintext
1 line
3.3 KiB
Plaintext
{"version":3,"file":"Point.mjs","sources":["../src/Point.ts"],"sourcesContent":["import type { IPoint } from './IPoint';\nimport type { IPointData } from './IPointData';\n\nexport interface Point extends GlobalMixins.Point, IPoint {}\n\n/**\n * The Point object represents a location in a two-dimensional coordinate system, where `x` represents\n * the position on the horizontal axis and `y` represents the position on the vertical axis\n * @class\n * @memberof PIXI\n * @implements {IPoint}\n */\nexport class Point implements IPoint\n{\n /** Position of the point on the x axis */\n public x = 0;\n /** Position of the point on the y axis */\n public y = 0;\n\n /**\n * Creates a new `Point`\n * @param {number} [x=0] - position of the point on the x axis\n * @param {number} [y=0] - position of the point on the y axis\n */\n constructor(x = 0, y = 0)\n {\n this.x = x;\n this.y = y;\n }\n\n /**\n * Creates a clone of this point\n * @returns A clone of this point\n */\n clone(): Point\n {\n return new Point(this.x, this.y);\n }\n\n /**\n * Copies `x` and `y` from the given point into this point\n * @param p - The point to copy from\n * @returns The point instance itself\n */\n copyFrom(p: IPointData): this\n {\n this.set(p.x, p.y);\n\n return this;\n }\n\n /**\n * Copies this point's x and y into the given point (`p`).\n * @param p - The point to copy to. Can be any of type that is or extends `IPointData`\n * @returns The point (`p`) with values updated\n */\n copyTo<T extends IPoint>(p: T): T\n {\n p.set(this.x, this.y);\n\n return p;\n }\n\n /**\n * Accepts another point (`p`) and returns `true` if the given point is equal to this point\n * @param p - The point to check\n * @returns Returns `true` if both `x` and `y` are equal\n */\n equals(p: IPointData): boolean\n {\n return (p.x === this.x) && (p.y === this.y);\n }\n\n /**\n * Sets the point to a new `x` and `y` position.\n * If `y` is omitted, both `x` and `y` will be set to `x`.\n * @param {number} [x=0] - position of the point on the `x` axis\n * @param {number} [y=x] - position of the point on the `y` axis\n * @returns The point instance itself\n */\n set(x = 0, y = x): this\n {\n this.x = x;\n this.y = y;\n\n return this;\n }\n}\n\nif (process.env.DEBUG)\n{\n Point.prototype.toString = function toString(): string\n {\n return `[@pixi/math:Point x=${this.x} y=${this.y}]`;\n };\n}\n"],"names":[],"mappings":"AAYO,MAAM,MACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWI,YAAY,IAAI,GAAG,IAAI,GACvB;AAVA,SAAO,IAAI,GAEX,KAAO,IAAI,GASF,KAAA,IAAI,GACT,KAAK,IAAI;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACI,WAAO,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS,GACT;AACI,WAAA,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,GAEV;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAyB,GACzB;AACI,WAAA,EAAE,IAAI,KAAK,GAAG,KAAK,CAAC,GAEb;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,GACP;AACI,WAAQ,EAAE,MAAM,KAAK,KAAO,EAAE,MAAM,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAI,IAAI,GAAG,IAAI,GACf;AACI,WAAA,KAAK,IAAI,GACT,KAAK,IAAI,GAEF;AAAA,EACX;AACJ;AAII,MAAM,UAAU,WAAW,WAC3B;AACI,SAAO,uBAAuB,KAAK,CAAC,MAAM,KAAK,CAAC;AACpD;"} |