LogoPixi’VN
pixi-jsFunctions

Function: parseSVGFloatAttribute()

> parseSVGFloatAttribute(svg, id, defaultValue): number

Defined in: node_modules/pixi.js/lib/scene/graphics/shared/svg/parseSVGFloatAttribute.d.ts:15

Internal

Parses a float value from an SVG element's attribute. This is commonly used for parsing numeric attributes like coordinates, dimensions, and other measurements from SVG elements.

Parameters

svg

SVGElement

The SVG element to get the attribute from

id

string

The name of the attribute to parse (e.g. 'x', 'y', 'width', etc)

defaultValue

number

The value to return if the attribute doesn't exist or can't be parsed

Returns

number

The parsed float value, or the default value if parsing fails

Example

// For SVG: <rect x="10.5" width="20"/>
parseSVGFloatAttribute(rectElement, 'x', 0) // Returns 10.5
parseSVGFloatAttribute(rectElement, 'y', 0) // Returns 0 since y is not specified
@internal