Discussion: Templated objects in SVG
Open, WishlistPublic


In SVG there is a feature of instantiating multiple elements of single vector objects. That is, you can define one "template" object and create as many its clones as you like. What is more, each instantiated clone can be transformed or have any style modifications if needed [0]. That is, each clone can have its own stroke, fill, clipping path and clipping mask options. The options defined during instantiation override the options mentioned in the template.

This cloning feature can be applied not only to vector objects themselves, but also to the implicit objects that are used in styles, like patterns, gradients, clipping paths and masks.

So I have a set of questions, how should we handle this sharing of the objects? And should we handle it at all?

Basically, I want you to answer a set of questions for a set of possible (shareable) objects.

Set of objects:

  1. Gradient
  2. Pattern (consists of a set of usual objects, like in inkscape)
  3. Clip path (also consists of a set of objects that define an outline)
  4. Clip mask (the same as clip path, but also takes objects' opacity into account)
  5. Regular objects (first we define an invisible "template" object and create a lot of "instantiations" of it)

Set of questions:

  1. Do we need this sharing, or the loaded object should be deep-copied at the stage of loading the document?
  2. If we need sharing:
    1. How should we display that the object is instantiated using a template? Should we somehow group the objects having the same template?
    2. How the user whould "enter" the source (template) object and edit it?
    3. How the user should edit a particular instantiation of the template object? Please remember that an instantiation can also have some properties attached, that override the corresponding properties of the template.

I am really not sure about how we should proceed with it. Of course, the feature is quite advanced and probably not of the first priority, but we need to have an "ideal" design which we should seek to. The answers to the questions listed above define the basic design of the system I work at the moment :)

[0] - https://www.w3.org/TR/SVG/struct.html#UseElement

dkazakov created this task.Nov 24 2016, 7:28 PM
rempt added a subscriber: rempt.Nov 28 2016, 4:21 PM

Quick thoughts

Q2.A: maybe with a different decoration in the selection rectangle?
Q2.B: seems to me the same as Q2.C: any edit to any instance of the clone object should be reflected in all the others.

We could use a different copy/paste action: paste as clone, maybe?

woltherav added a subscriber: woltherav.EditedFeb 19 2017, 8:25 AM

In inkscape these can currently be edited with the symbol definition. I suspect mostly for us, it'd be cool if we could load such symbols into the add shape docker, either the symbols for the current document, or just loading svg defines in general.

But I suspect this'll need to go to Krita: abyss?

woltherav triaged this task as Wishlist priority.Feb 28 2017, 11:22 AM

In Inkscape 0.91+ These are accesible via the symbols dialog: http://wiki.inkscape.org/wiki/index.php/SymbolsDialog

From playing with it, any object can be thrown into the def symbols, but when retrieving and using them (va <use>), they cannot be edited in inkscape. So only when you remove the object from the def symbols it can be edited...