Files
nothoughts/node_modules/pixi.js/lib/maths/shapes/Circle.mjs.map
2025-08-04 18:57:35 +02:00

1 line
6.1 KiB
Plaintext

{"version":3,"file":"Circle.mjs","sources":["../../../src/maths/shapes/Circle.ts"],"sourcesContent":["import { Rectangle } from './Rectangle';\n\nimport type { SHAPE_PRIMITIVE } from '../misc/const';\nimport type { ShapePrimitive } from './ShapePrimitive';\n\n/**\n * The Circle object is used to help draw graphics and can also be used to specify a hit area for containers.\n * @memberof maths\n */\nexport class Circle implements ShapePrimitive\n{\n /**\n * The X coordinate of the center of this circle\n * @default 0\n */\n public x: number;\n\n /**\n * The Y coordinate of the center of this circle\n * @default 0\n */\n public y: number;\n\n /**\n * The radius of the circle\n * @default 0\n */\n public radius: number;\n\n /**\n * The type of the object, mainly used to avoid `instanceof` checks\n * @default 'circle'\n */\n public readonly type: SHAPE_PRIMITIVE = 'circle';\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\n /**\n * Creates a clone of this Circle instance\n * @returns A copy of the Circle\n */\n public 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 public contains(x: number, y: number): boolean\n {\n if (this.radius <= 0) return false;\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 * Checks whether the x and y coordinates given are contained within this circle including the stroke.\n * @param x - The X coordinate of the point to test\n * @param y - The Y coordinate of the point to test\n * @param width - The width of the line to check\n * @returns Whether the x/y coordinates are within this Circle\n */\n public strokeContains(x: number, y: number, width: number): boolean\n {\n if (this.radius === 0) return false;\n\n const dx = (this.x - x);\n const dy = (this.y - y);\n const r = this.radius;\n const w2 = width / 2;\n const distance = Math.sqrt((dx * dx) + (dy * dy));\n\n return (distance < r + w2 && distance > r - w2);\n }\n\n /**\n * Returns the framing rectangle of the circle as a Rectangle object\n * @param out\n * @returns The framing rectangle\n */\n public getBounds(out?: Rectangle): Rectangle\n {\n out = out || new Rectangle();\n\n out.x = this.x - this.radius;\n out.y = this.y - this.radius;\n out.width = this.radius * 2;\n out.height = this.radius * 2;\n\n return out;\n }\n\n /**\n * Copies another circle to this one.\n * @param circle - The circle to copy from.\n * @returns Returns itself.\n */\n public copyFrom(circle: Circle): this\n {\n this.x = circle.x;\n this.y = circle.y;\n this.radius = circle.radius;\n\n return this;\n }\n\n /**\n * Copies this circle to another one.\n * @param circle - The circle to copy to.\n * @returns Returns given parameter.\n */\n public copyTo(circle: Circle): Circle\n {\n circle.copyFrom(this);\n\n return circle;\n }\n\n // #if _DEBUG\n public toString(): string\n {\n return `[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;\n }\n // #endif\n}\n"],"names":[],"mappings":";;;AASO,MAAM,MACb,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8BI,YAAY,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,CAAA,EAAG,SAAS,CACnC,EAAA;AARA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAgB,IAAwB,GAAA,QAAA,CAAA;AASpC,IAAA,IAAA,CAAK,CAAI,GAAA,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,CAAI,GAAA,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AAAA,GAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,KACP,GAAA;AACI,IAAA,OAAO,IAAI,MAAO,CAAA,IAAA,CAAK,GAAG,IAAK,CAAA,CAAA,EAAG,KAAK,MAAM,CAAA,CAAA;AAAA,GACjD;AAAA;AAAA;AAAA;AAAA;AA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