Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for transformations #64

Open
jdbosser opened this issue Feb 1, 2023 · 2 comments
Open

Add support for transformations #64

jdbosser opened this issue Feb 1, 2023 · 2 comments

Comments

@jdbosser
Copy link

jdbosser commented Feb 1, 2023

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.

@IvanUkhov
Copy link
Member

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 paths 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

@IvanUkhov IvanUkhov changed the title Support for transformations Add support for transformations Jul 22, 2023
@dustdfg
Copy link

dustdfg commented Feb 5, 2024

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:

  1. The svg is suited for people reading/editing
  2. You can easily emulate transfom-origin property from svg2 via several sequential transforms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants