vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

Add class names to drawing commands for svg shipout #402

Closed ProgramComputer closed 8 months ago

ProgramComputer commented 8 months ago

Currently, SVG is drawn based on the order of drawing commands on asymptote. Adding classes in ASY before shipout will ease future SVG animation uses in ECMAScript. Maybe legend from draw could be used but it's preferable to be able to add multiple classes such as "id27 group2".

Below is an example ASY and sample use case HTML of SVG after I put in classes and IDs manually https://gist.github.com/ProgramComputer/f8062118e55462b88bfdb2e776cdf0df

johncbowman commented 8 months ago

Here's an example of how to added a class counter to circle objects. Hopefully you don't really need these labels added to "<use" since those are generated by dvisvgm. Feel free to extend this to other required objects and submit a pull request.

ProgramComputer commented 8 months ago

@johncbowman

Here's an example of how to added a class counter to circle objects. Hopefully you don't really need these labels added to "<use" since those are generated by dvisvgm. Feel free to extend this to other required objects and submit a pull request.

Is the example a hyperlink? I don't see it in your comment.

johncbowman commented 8 months ago

Sorry, here is the example: svgclass.txt