weisJ/jsvg

SVG -> Shape

DSGolovkov opened this issue · 6 comments

Hello! I want to use your library to obtain a Shape, which I then plan to modify (add an outline, convert into an Area, etc.). Is this possible using the current functionality?

There currently is no public API for this at the moment, however there are internal methods to do this. The reason it isn't in the public facing API at the moment is that I am not entirely sure how it should behave in all situations:

  • Clips should also clip the computed shape
  • Masks is not so clear what should happen. Anything besides just ignoring them is very difficult but possibly wrong.
  • Filters are a whole different beast as they can drastically alter the appearance of the content. And there probably are cases where one would like the result to include the added appearance in the geometry.
  • Should strokes be outlined or returned as lines without thickness? (This is probably the most relevant question)

Could you elaborate more on your use case what sort of SVGs you are expect to use it with?

SVGs can be anything. The goal is to have a mechanism to create a protective area to cut out modifiers (small icons) from the icons on which they are superimposed. That is, I want to convert the resulting Shape of the modifier to an Area, add a stroke, and merge it into a new Area. So, the final Area will be a protective area which will be deleted from the main icon.

image

Just to be clarify: You want to obtain the shape of the modifier and not the icon it is imposed on correct?

I think I'll be able to provide a basic non-complete implementation, which should cover most use cases (i.e. ignoring masks and filters). Strokes probably should be configurable.

Yeah, that's right. All I need is to be able to get Shape. About the cutout of the protective area - the scenario for which it is needed.

It will be perfect!

The latest snapshot includes the changes from #58. You can get the shape using SVGDocument#computeShape.

Now available in version 1.4.0