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

Option to emit mildly optimized svg paths #18

Open
6 of 9 tasks
rsheeter opened this issue May 17, 2024 · 1 comment
Open
6 of 9 tasks

Option to emit mildly optimized svg paths #18

rsheeter opened this issue May 17, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@rsheeter
Copy link
Contributor

rsheeter commented May 17, 2024

To enable deletion of some java code and a somewhat slow step in icon svg processing provide an optional optimized svg path that does the following if/when it produces a shorter string:

  • Use relative vs absolute coords
  • Collapse repeated lines (e.g. h20 h30 -> h50)
  • Use lineto shorthands (e.g. horizontal or vertical line)
  • Remove nop instructions, e.g. l0,0 but more generally any command that doesn't move the pen
  • Decrease accuracy of floats
  • Convert degenerate curves to lines
  • Drop leading 0 when possible (e.g 0.5 => .5)
  • Drop separator between coords when second is negative, e.g. emit 160-160 not 160,-160
  • Use "smooth" cubic/quadratic curve commands when possible (reflection of end of previous gives first control)

That is, implement most optimizations from https://github.com/svg/svgo/blob/main/plugins/convertPathData.js but apply during generation of a String for a BezPath instead of as a standalone step. Consider not implementing arc conversion; arcs have a way of breaking things.

Impact: should cut minutes off the time to produce a complete set of icons.

See:

@tomasdev
Copy link
Member

tomasdev commented Jun 6, 2024

Collapse Repeated from SVGO https://github.com/svg/svgo/blob/main/plugins/convertPathData.js#L748-L767

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants