pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
1 lines • 3.59 kB
Source Map (JSON)
{"version":3,"file":"pathOperations.mjs","sources":["../../../../../../src/scene/graphics/shared/svg/utils/pathOperations.ts"],"sourcesContent":["import { GraphicsPath } from '../../path/GraphicsPath';\n\n/**\n * Extracts individual subpaths from SVG path data by splitting on Move commands.\n * @param pathData - The SVG path data string\n * @returns Array of subpath strings\n * @internal\n */\nexport function extractSubpaths(pathData: string): string[]\n{\n // Split on Move commands (M or m) to get individual subpaths\n const parts = pathData.split(/(?=[Mm])/);\n const subpaths = parts.filter((part) => part.trim().length > 0);\n\n return subpaths;\n}\n\n/**\n * Calculates the area of a path using bounding box estimation.\n * @param pathData - The SVG path data string\n * @returns The estimated area of the path\n * @internal\n */\nexport function calculatePathArea(pathData: string): number\n{\n const coords = pathData.match(/[-+]?[0-9]*\\.?[0-9]+/g);\n\n if (!coords || coords.length < 4) return 0;\n\n const numbers = coords.map(Number);\n const xs = [];\n const ys = [];\n\n for (let i = 0; i < numbers.length; i += 2)\n {\n if (i + 1 < numbers.length)\n {\n xs.push(numbers[i]);\n ys.push(numbers[i + 1]);\n }\n }\n\n if (xs.length === 0 || ys.length === 0) return 0;\n\n const minX = Math.min(...xs);\n const maxX = Math.max(...xs);\n const minY = Math.min(...ys);\n const maxY = Math.max(...ys);\n\n const area = (maxX - minX) * (maxY - minY);\n\n return area;\n}\n\n/**\n * Parses SVG path data and appends instructions to a GraphicsPath.\n * @param pathData - The SVG path data string\n * @param graphicsPath - The GraphicsPath to append instructions to\n * @internal\n */\nexport function appendSVGPath(pathData: string, graphicsPath: GraphicsPath): void\n{\n const tempPath = new GraphicsPath(pathData, false);\n\n for (const instruction of tempPath.instructions)\n {\n graphicsPath.instructions.push(instruction);\n }\n}\n"],"names":[],"mappings":";;;AAQ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