UNPKG

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 1.31 kB
{"version":3,"file":"parseSVGFloatAttribute.mjs","sources":["../../../../../src/scene/graphics/shared/svg/parseSVGFloatAttribute.ts"],"sourcesContent":["/**\n * Parses a float value from an SVG element's attribute.\n * This is commonly used for parsing numeric attributes like coordinates, dimensions,\n * and other measurements from SVG elements.\n * @param svg - The SVG element to get the attribute from\n * @param id - The name of the attribute to parse (e.g. 'x', 'y', 'width', etc)\n * @param defaultValue - The value to return if the attribute doesn't exist or can't be parsed\n * @returns The parsed float value, or the default value if parsing fails\n * @example\n * // For SVG: <rect x=\"10.5\" width=\"20\"/>\n * parseSVGFloatAttribute(rectElement, 'x', 0) // Returns 10.5\n * parseSVGFloatAttribute(rectElement, 'y', 0) // Returns 0 since y is not specified\n * @internal\n */\nexport function parseSVGFloatAttribute(svg: SVGElement, id: string, defaultValue: number): number\n{\n const value = svg.getAttribute(id) as string;\n\n return value ? Number(value) : defaultValue;\n}\n"],"names":[],"mappings":";AAcgB,SAAA,sBAAA,CAAuB,GAAiB,EAAA,EAAA,EAAY,YACpE,EAAA;AACI,EAAM,MAAA,KAAA,GAAQ,GAAI,CAAA,YAAA,CAAa,EAAE,CAAA,CAAA;AAEjC,EAAO,OAAA,KAAA,GAAQ,MAAO,CAAA,KAAK,CAAI,GAAA,YAAA,CAAA;AACnC;;;;"}