williamngan / pts

A library for visualization and creative-coding
https://ptsjs.org
Apache License 2.0
5.16k stars 182 forks source link

Built-in SVG interactions #210

Open alexander-welshtein opened 6 months ago

alexander-welshtein commented 6 months ago

I continue the section of those things that we have developed while working with this tool. In our tasks, each shape must be exported as a separate SVG. At the same time, we keep working with shapes within CanvasSpace. We export to SVG manually, including the text paragraph (by overriding the functionality of the Canvas/paragraphBox and Canvas/_textTruncate methods). Based on this, two points that can be considered as improvements to the library:

  1. Possibility of exporting the entire canvas and/or each shape to SVG. (maximum, may differ from the direction of library development)
  2. Utility access to the text paragraph content functions mentioned above. (minimum)

In this case, I can prepare a PR if the development is approved. Or need more information?

P.S. Also, perhaps these things could be solved by a more developed SVGSpace/SVGForm compatible with CanvasSpace/CanvasForm

williamngan commented 6 months ago

@alexander-welshtein Thanks for these suggestions! I think improving SVGSpace would be the best approach, but it's a bigger effect and currently my time for maintaining this project is very limited.

Happy to review smaller PRs like the text paragraph issue in #2. I agree that getting the text contents can be useful. The paragraphBox function can potentially return an array of text instead of this.

alexander-welshtein commented 6 months ago

@alexander-welshtein Thanks for these suggestions! I think improving SVGSpace would be the best approach, but it's a bigger effect and currently my time for maintaining this project is very limited.

Happy to review smaller PRs like the text paragraph issue in #2. I agree that getting the text contents can be useful. The paragraphBox function can potentially return an array of text instead of this.

Great! Then I will consider adding this small PR that will allow us to remove borrowings from our solution. And I’ll see how the SVGSpace works as time permits. Possible changes can be discussed.