Open jdbosser opened 1 year ago
Hello, yes, indeed. There is no higher-level interface for doing this. I myself use exactly the approach you described. Since for constructing data
for path
s we have it, it could make sense to have it for transformations too.
https://github.com/bodoni/svg/blob/main/src/node/element/path/data.rs
I just want to add that stored transforms must be a list Vec<Transform>
because svg allows several different transforms at the same time: translate(100 100) scale(0.5 0.5)
. Also the API should be not element.transform(transform: Transform)
but rather element.transform(transform: Transform, squash: bool)
because user can want to get one matrix after several transforms and not a list of transforms
P.S If you want to know when the list of transforms is more preferable than matrix:
If I am not mistaken, current API does not include support for transformations of the svgs.
This can likely be solved for those who need to apply transformations to their code by the
.add("transformation", "rotate(45)")
, for example.However, it would be nice to create some rust interface that enumerates the possible transformations and their parameters that is included in this repo, like the commands in the paths module.