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 • 2.99 kB
Source Map (JSON)
{"version":3,"file":"fillOperations.mjs","sources":["../../../../../../src/scene/graphics/shared/svg/utils/fillOperations.ts"],"sourcesContent":["import type {\n FillInstruction,\n GraphicsContext,\n} from '../../GraphicsContext';\n\n/**\n * Determines if subpaths represent nested shapes or multiple holes pattern.\n * @param subpathsWithArea - Array of subpaths with their calculated areas\n * @returns True if nested pattern, false if multiple holes pattern\n * @internal\n */\nexport function checkForNestedPattern(subpathsWithArea: Array<{path: string, area: number}>): boolean\n{\n if (subpathsWithArea.length <= 2)\n {\n return true;\n }\n\n const areas = subpathsWithArea.map((s) => s.area).sort((a, b) => b - a);\n\n const [largestArea, secondArea] = areas;\n const smallestArea = areas[areas.length - 1];\n\n const largestToSecondRatio = largestArea / secondArea;\n const secondToSmallestRatio = secondArea / smallestArea;\n\n // If the largest shape is significantly bigger than the second (3x+)\n // AND the smaller shapes are similar in size (2x or less difference),\n // it suggests multiple holes pattern rather than nested shapes\n if (largestToSecondRatio > 3 && secondToSmallestRatio < 2)\n {\n return false; // Multiple holes\n }\n\n return true; // Default to nested\n}\n\n/**\n * Gets fill instruction data from a graphics context.\n * @param context - The graphics context\n * @param index - Index of the fill instruction (default: 0)\n * @returns The fill instruction data\n * @throws Error if instruction at index is not a fill instruction\n * @internal\n */\nexport function getFillInstructionData(context: GraphicsContext, index: number = 0)\n{\n const instruction = context.instructions[index];\n\n if (!instruction || instruction.action !== 'fill')\n {\n throw new Error(`Expected fill instruction at index ${index}, got ${instruction?.action || 'undefined'}`);\n }\n\n return (instruction as FillInstruction).data;\n}\n"],"names":[],"mappings":";AAWO,SAAS,sBAAsB,gBACtC,EAAA;AACI,EAAI,IAAA,gBAAA,CAAiB,UAAU,CAC/B,EAAA;AACI,IAAO,OAAA,IAAA,CAAA;AAAA,GACX;AAEA,EAAA,MAAM,KAAQ,GAAA,gBAAA,CAAiB,GAAI,CAAA,CAAC,CAAM,KAAA,CAAA,CAAE,IAAI,CAAA,CAAE,IAAK,CAAA,CAAC,CAAG,EAAA,CAAA,KAAM,IAAI,CAAC,CAAA,CAAA;AAEtE,EAAM,MAAA,CAAC,WAAa,EAAA,UAAU,CAAI,GAAA,KAAA,CAAA;AAClC,EAAA,MAAM,YAAe,GAAA,KAAA,CAAM,KAAM,CAAA,MAAA,GAAS,CAAC,CAAA,CAAA;AAE3C,EAAA,MAAM,uBAAuB,WAAc,GAAA,UAAA,CAAA;AAC3C,EAAA,MAAM,wBAAwB,UAAa,GAAA,YAAA,CAAA;AAK3C,EAAI,IAAA,oBAAA,GAAuB,CAAK,IAAA,qBAAA,GAAwB,CACxD,EAAA;AACI,IAAO,OAAA,KAAA,CAAA;AAAA,GACX;AAEA,EAAO,OAAA,IAAA,CAAA;AACX,CAAA;AAUgB,SAAA,sBAAA,CAAuB,OAA0B,EAAA,KAAA,GAAgB,CACjF,EAAA;AACI,EAAM,MAAA,WAAA,GAAc,OAAQ,CAAA,YAAA,CAAa,KAAK,CAAA,CAAA;AAE9C,EAAA,IAAI,CAAC,WAAA,IAAe,WAAY,CAAA,MAAA,KAAW,MAC3C,EAAA;AACI,IAAM,MAAA,IAAI,MAAM,CAAsC,mCAAA,EAAA,KAAK,SAAS,WAAa,EAAA,MAAA,IAAU,WAAW,CAAE,CAAA,CAAA,CAAA;AAAA,GAC5G;AAEA,EAAA,OAAQ,WAAgC,CAAA,IAAA,CAAA;AAC5C;;;;"}