svgpathtools icon indicating copy to clipboard operation
svgpathtools copied to clipboard

Public API for matrix transformation?

Open matthijskooijman opened this issue 4 years ago • 1 comments

I'm looking at applying matrix transformations to paths and path segments. I see there is a translated(), scaled() and rotated() method on various classes, but there is no such method to apply a transformation matrix. There is a svgpathtools.path.transform() function that works, but I wonder if that is considered public API, or if there should be wrapper methods just like for translation etc.?

On a related note, I see there is a svgpathtools.parser.parse_transform() function that looks useful. Is that also considered public API?

matthijskooijman avatar Feb 12 '21 10:02 matthijskooijman

https://github.com/meerk40t/svgelements/issues svgelements has that feature. Lets you directly use the strings like matrices.

It looks like it's somewhat in there too. Calls: https://github.com/mathandy/svgpathtools/blob/3a1fe8695dd6236af81b5477714e74a094e3b088/svgpathtools/path.py#L292 which looks about right. Though yeah, this should be built into Path much like Path("M0,0L20,20") is now a permitted value. In svgelements I let you multiply by strings of matrices. path * "scale(1.2)" is a perfectly valid and understandable command, and might even be too liberal.

tatarize avatar Feb 26 '21 17:02 tatarize