jbosboom / svg-tiler

tiles SVGs from ASCII input (deprecated: use edemaine/svgtiler instead)
1 stars 0 forks source link

Support defining symbols as styles over other symbols #1

Open jbosboom opened 8 years ago

jbosboom commented 8 years ago

Suppose we want to tile a chess position. The black and white pieces probably have the same shape, but differ in their color. Currently we'd have a mapping file like

K @white-king.svg
k @black-king.svg
Q @white-queen.svg
q @black-queen.svg

where the SVG files have the same paths with different stroke and fill colors. This duplication makes changing the shapes or colors unnecessarily difficult.

SVG supports CSS-like styles, and we should use them. I see two particular ways forward:

edemaine commented 8 years ago

Does Inkscape support named CSS class references? E.g., can you make a polygon of class "player", and later style "player" to use fill white? I think so, but worth checking, to see if we could reasonably use this approach. I assume it also binds the style within the file, though -- perhaps SVG Tiler could separate the built-in style from the content, so that restyling is possible?

jbosboom commented 8 years ago

According to the Inkscape manual, you can only add class attributes and embedded stylesheets with Inkscape's XML editor. The FAQ mentions it may reformat embedded stylesheets, which at least means Inkscape has thought about preserving them.

The tiler can easily remove embedded stylesheets if we're willing to always lose them; I just don't want to be trying to preserve some elements while removing others. I don't know what happens if we leave them in with conflicting definitions from outside, but I'm guessing the inner definition will win, which would be the opposite of what we want.