Description
Currently, the only way to render an SVG is by creating a transparent CEF browser and loading the SVG through the browser.
I think it would be useful to have SVG support built-in to MTA, which would most likely need less resources than creating a CEF instance just to display a single SVG.
I propose a function that returns an xmlnode
(since we already have XML parsing built in) but wrapped as a custom type to identify that it's an svg (something like svgnode
)
svgnode svgCreate(string rawData / filePath) -- Further parameters may be added for important options
Since an SVG is essentially just XML data, and the svgnode
type is basically just an alias/wrapper for xmlnode
, it would be compatible with most of the existing xml* functions (such as xmlNodeSetAttribute).
Would it be better for code readability to again wrap/alias the existing xml functions with an svg
prefix instead? (e.g: xmlNodeSetAttribute
-> svgNodeSetAttribute
).
As for actually displaying the SVG, a function would be provided to get the SVG texture as a render target (which would be automatically updated if the SVG data is changed at all) - such as:
svgGetTexture(svgnode svgRootNode)
I'd like some other input on this, as you may have some better ideas. I do plan to implement this myself, however.