{"version":3,"file":"Point.mjs","sources":["../../../src/maths/point/Point.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport type { PointData } from './PointData';\nimport type { PointLike } from './PointLike';\n\n// eslint-disable-next-line max-len\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type, requireExport/require-export-jsdoc, requireMemberAPI/require-member-api-doc\nexport interface Point extends PixiMixins.Point { }\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 *\n * Many Pixi functions accept the `PointData` type as an alternative to `Point`,\n * which only requires `x` and `y` properties.\n * @example\n * ```ts\n * // Basic point creation\n * const point = new Point(100, 200);\n *\n * // Using with transformations\n * const matrix = new Matrix();\n * matrix.translate(50, 50).apply(point);\n *\n * // Point arithmetic\n * const start = new Point(0, 0);\n * const end = new Point(100, 100);\n * const middle = new Point(\n *     (start.x + end.x) / 2,\n *     (start.y + end.y) / 2\n * );\n * ```\n * @see {@link PointData} For basic x,y interface\n * @see {@link PointLike} For point manipulation interface\n * @see {@link ObservablePoint} For observable version\n * @category maths\n * @standard\n */\nexport class Point implements PointLike\n{\n    /**\n     * Position of the point on the x axis\n     * @example\n     * ```ts\n     * // Set x position\n     * const point = new Point();\n     * point.x = 100;\n     *\n     * // Use in calculations\n     * const width = rightPoint.x - leftPoint.x;\n     * ```\n     */\n    public x = 0;\n    /**\n     * Position of the point on the y axis\n     * @example\n     * ```ts\n     * // Set y position\n     * const point = new Point();\n     * point.y = 200;\n     *\n     * // Use in calculations\n     * const height = bottomPoint.y - topPoint.y;\n     * ```\n     */\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, which is a new instance with the same `x` and `y` values.\n     * @example\n     * ```ts\n     * // Basic point cloning\n     * const original = new Point(100, 200);\n     * const copy = original.clone();\n     *\n     * // Clone and modify\n     * const modified = original.clone();\n     * modified.set(300, 400);\n     *\n     * // Verify independence\n     * console.log(original); // Point(100, 200)\n     * console.log(modified); // Point(300, 400)\n     * ```\n     * @remarks\n     * - Creates new Point instance\n     * - Deep copies x and y values\n     * - Independent from original\n     * - Useful for preserving values\n     * @returns A clone of this point\n     * @see {@link Point.copyFrom} For copying into existing point\n     * @see {@link Point.copyTo} For copying to existing point\n     */\n    public 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     * @example\n     * ```ts\n     * // Basic copying\n     * const source = new Point(100, 200);\n     * const target = new Point();\n     * target.copyFrom(source);\n     *\n     * // Copy and chain operations\n     * const point = new Point()\n     *     .copyFrom(source)\n     *     .set(x + 50, y + 50);\n     *\n     * // Copy from any PointData\n     * const data = { x: 10, y: 20 };\n     * point.copyFrom(data);\n     * ```\n     * @param p - The point to copy from\n     * @returns The point instance itself\n     * @see {@link Point.copyTo} For copying to another point\n     * @see {@link Point.clone} For creating new point copy\n     */\n    public copyFrom(p: PointData): 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.\n     * @example\n     * ```ts\n     * // Basic copying\n     * const source = new Point(100, 200);\n     * const target = new Point();\n     * source.copyTo(target);\n     * ```\n     * @param p - The point to copy to. Can be any type that is or extends `PointLike`\n     * @returns The point (`p`) with values updated\n     * @see {@link Point.copyFrom} For copying from another point\n     * @see {@link Point.clone} For creating new point copy\n     */\n    public copyTo<T extends PointLike>(p: T): T\n    {\n        p.set(this.x, this.y);\n\n        return p;\n    }\n\n    /**\n     * Checks if another point is equal to this point.\n     *\n     * Compares x and y values using strict equality.\n     * @example\n     * ```ts\n     * // Basic equality check\n     * const p1 = new Point(100, 200);\n     * const p2 = new Point(100, 200);\n     * console.log(p1.equals(p2)); // true\n     *\n     * // Compare with PointData\n     * const data = { x: 100, y: 200 };\n     * console.log(p1.equals(data)); // true\n     *\n     * // Check different points\n     * const p3 = new Point(200, 300);\n     * console.log(p1.equals(p3)); // false\n     * ```\n     * @param p - The point to check\n     * @returns `true` if both `x` and `y` are equal\n     * @see {@link Point.copyFrom} For making points equal\n     * @see {@link PointData} For point data interface\n     */\n    public equals(p: PointData): 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     *\n     * If y is omitted, both x and y will be set to x.\n     * @example\n     * ```ts\n     * // Basic position setting\n     * const point = new Point();\n     * point.set(100, 200);\n     *\n     * // Set both x and y to same value\n     * point.set(50); // x=50, y=50\n     *\n     * // Chain with other operations\n     * point\n     *     .set(10, 20)\n     *     .copyTo(otherPoint);\n     * ```\n     * @param x - Position on the x axis\n     * @param y - Position on the y axis, defaults to x\n     * @returns The point instance itself\n     * @see {@link Point.copyFrom} For copying from another point\n     * @see {@link Point.equals} For comparing positions\n     */\n    public set(x = 0, y: number = x): this\n    {\n        this.x = x;\n        this.y = y;\n\n        return this;\n    }\n\n    // #if _DEBUG\n    public toString(): string\n    {\n        return `[pixi.js/math:Point x=${this.x} y=${this.y}]`;\n    }\n    // #endif\n\n    /**\n     * A static Point object with `x` and `y` values of `0`.\n     *\n     * This shared instance is reset to zero values when accessed.\n     *\n     * > [!IMPORTANT] This point is shared and temporary. Do not store references to it.\n     * @example\n     * ```ts\n     * // Use for temporary calculations\n     * const tempPoint = Point.shared;\n     * tempPoint.set(100, 200);\n     * matrix.apply(tempPoint);\n     *\n     * // Will be reset to (0,0) on next access\n     * const fresh = Point.shared; // x=0, y=0\n     * ```\n     * @readonly\n     * @returns A fresh zeroed point for temporary use\n     * @see {@link Point.constructor} For creating new points\n     * @see {@link PointData} For basic point interface\n     */\n    static get shared(): Point\n    {\n        tempPoint.x = 0;\n        tempPoint.y = 0;\n\n        return tempPoint;\n    }\n}\n\nconst tempPoint = new Point();\n"],"names":[],"mappings":";AAqCO,MAAM,KAAA,CACb;A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