maplibre-gl-svg-sprite - v0.1.0
    Preparing search index...

    Function applySvgFgBg

    • Apply foreground and background colors to SVG elements with data-fg/data-bg attributes

      Injects CSS rules to style elements marked with data-fg or data-bg attributes.

      Parameters

      • svg: string

        SVG markup string

      • Optionalfg: string

        Foreground color (applied to elements with data-fg attribute)

      • Optionalbg: string

        Background color (applied to elements with data-bg attribute)

      • Optionalopts: { debug?: boolean }

      Returns string

      Modified SVG string with injected styles

      const svg = '<svg><path data-fg="true"/><rect data-bg="true"/></svg>';
      const colored = applySvgFgBg(svg, '#ff0000', '#0000ff');