-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Something I often do with SVGs is to have a "master SVG" that has named objects and groups, then selectively change the style of some of these groups during rendering. Thinking about TinyVG use cases, imagine a "Checkbox" SVG. It might look something like this:
<svg>
<rect ...>
<path id="checkmark" d="..." fill="green">
<path id="cross" d="..." fill="red">
</svg>
The renderer can then select any of the styles by rendering with an override of `fill="none" for one of the IDs.
I don't think that explicitly specifying this type of CSS-like behavior makes sense as part of a format like TinyVG. However, it would be nice if it would be possible to uniquely identify individual elements or groups of elements in a TinyVG file from the outside.
One way of doing this could be to have "id start" and "id end" commands in between graphical commands. These would have no effect on the actual graphical rendering and can be ignored during rendering since in contrast to SVG groups they do not change graphical state such as style or transform. IDs could be variable-length strings, which would not make implementing a parser worse since there are already variable-length integers and lists anyway. Example TinyVG file structure for the checkmark example above:
[header]
[color table]
<outline rect ...>
<start id "checkmark>
<fill path ... color=green>
<end id "checkmark>
<start id "cross">
<fill path ... color=red>
<fill path ... color=red>
<end id cross>
[EOF]