Closed OrangeTux closed 2 years ago
Hello, the interface is not designed for modification. But perhaps this is not what you actually want. The example shows that you are trying to construct something from scratch. In such a case, just create each child separately and then append to the parent.
Thanks for the answer @IvanUkhov .
The example shows that you are trying to construct something from scratch. In such a case, just create each child separately and then append to the parent.
My example is reduction of a bigger problem. I want to write a tool that takes an existing SVG and modifies it to make it friendlier to be 'consumed' by a pen plotter.
I read the file using an svg::Parser
and turn it into an svg::Document
. My idea is to pass this svg::Document
down to several functions that modify the svg::Document
. Than I'd like to write the modified SVG to disk. But that doesn't seem to be possible as you write:
the interface is not designed for modification.
Thanks for the answer!
I see. Then indeed it would be difficult to achieve with this crate, unless one is willing to change the approach, such as to parse and augment at the same time. Sorry. I close this one then.
I've an SVG file and want to modify it. Among other things, I'd like to do is adding a "id" attribute to certain tags.
My approach is to read the file and create an
svg::Parser
. Iterate over the parser to create ansvg::Document
. I'll pass thissvg::Document
around to functions that modify it. But that doesn't work.Consider the following code:
That fails to compile with:
Even if this would work, how would I know whether the
child
is a 'line', 'path' or any other tag is?