abey79 / vsvg

Fast and portable tools for plotter users
http://whisk.rs
MIT License
106 stars 12 forks source link

Exporting SVG #13

Open abey79 opened 1 year ago

abey79 commented 1 year ago

Working on my initial take at the SVG writer, it appears useful to come up with some quick and dirty spec, more or less inspired by what is currently implemented in vpype.

1) No real need for an xml prolog as we're utf-8 (vpype includes one). 2) Metadata in the correct format, as vpype currently does.

   <metadata>
     <rdf:RDF>
       <cc:Work>
         <dc:format>image/svg+xml</dc:format>
         <dc:source>vpype random -n 1 write -f svg -</dc:source>
         <dc:date>2023-03-28T11:08:16.164053</dc:date>
       </cc:Work>
     </rdf:RDF>
   </metadata>

3) All path in their respective layers. 4) Attributes that are uniform within a layer should appear at the layer level (as opposed to the path level). 5) Attributes whose value corresponds to the SVG default should be omitted. 6) Path should be converted to the closest corresponding SVG representation.

abey79 commented 1 year ago

Initial implementation in 50c3a6b569089c36e5c0d1f12a25033d81e486f6. Far from implementing the full spec. svg is probably too limited to handle that properly, in particular with regards to indentation. Maybe it can still help in the context of a more manual approach.

Edit: it's super slow too! ~13s for Drain4tests.svg!

Edit: no it's ok, it just needs a BufWriter.