meerk40t / svgelements

SVG Parsing for Elements, Paths, and other SVG Objects.
MIT License
124 stars 28 forks source link

Add support for Inkscape arc shapes #253

Open dojoe opened 2 months ago

dojoe commented 2 months ago

This PR adds support for Inkscape's not-quite-a-circle shapes. They're derived from the _RoundShape class and extend them by allowing a start and stop angle, with different options for closing the open path.

I'm sure I'm missing some details in my PR, like specific code formatting or more docstrings/comments. Please let me know what you'd like changed and I'll be happy to make the updates.

Also let me know if you think this is beyond the scope of svgelements. This PR solves a problem for me and I'll happily contribute back but I also understand if you'd like to stick to plain SVG. That said, there are other Inkscape shapes like stars and spirals that might be fun to add as well :)

tatarize commented 1 month ago

This may be out of scope. Inkscape implements svg and does not define it. That said this really does seem quite nice and I do find myself shoehorning in some inkscape things like Label, but at the project level. There may be an interesting need for a sister project that implements a lot of the inkscape additions. Tho with #87. I might not add such things, or really encourage a fork from this code directly. It seems like parsing the svg to dom, then dom to shapes is cleaner and more inline with modern web rendering.

It seems that if we had a parse into nodes, then render into mostly correct shapes or only paths, allowing the node alterations to yield new rendering that added correctness is still quite justified. Then the additional work of inkscape stars are likely just in the DOM to render as path pipeline.

Its likely out of scope, but the better project I sort of have in mind may simply require small additional corrections. So I'll take some time to consider these

dojoe commented 1 month ago

Thanks, I appreciate the feedback and understand your concerns.

If you ultimately decide not to support Inkscape shapes in this project, would it be an option to include the changes I made to _RoundShape in svgelements? That would enable other projects to build Inkscape arcs on top of that class instead of having to reimplement most of the segments() code.