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

Feature Request: Allow to provide path data as array of segments #170

Open
aleksey-shmatov opened this issue Aug 4, 2020 · 2 comments
Open

Comments

@aleksey-shmatov
Copy link

Currently path method accepts data as a string. In the internals it is being parse twice once in pointsOnPath and another time in svgPath. In my case I want to do some preprocessing to the path data before applying roughness. Currently I am basically forced to:

  1. Parse string to segments.
  2. Apply my own transformations to path data.
  3. Convert transformed data back to string.
  4. This string will be parsed twice inside RoughJS library.
@pshihn
Copy link
Collaborator

pshihn commented May 9, 2021

Sorry for the late response. But if you are still interested in this, can you give a bit more details and context. Maybe some example of what you are trying to achieve? thanks!

@aleksey-shmatov
Copy link
Author

I want to implement real-time resizing of the shapes. I can't just use scaling because the way RoughJS works is based on the absolute distance values. So for example if you apply roughness to 10px line and then scale it 10x result will not be same as applying roughness to the 100px line. In second case there would be more "roughness" and result looks more natural. So what I am doing is adjusting shape/path data according to a new size and then pass down adjusted data to the RoughJS library. The problem is that RoughJS accepts only a string. This basically results in 3 path data parsing operations. One is my own because I need to adjust data to a new size and another two inside RoughJS(not sure why it happens twice pretty sure this can be optimised to single one). All these additional parsing slows down things quite a bit and for more complex shapes I am seeing performance issues during resize.

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

No branches or pull requests

2 participants