Skip to content

Approximate quadratic bezier curves with arcs and other minor improvements - #1213

Open
sivukhin wants to merge 8 commits into
svg:mainfrom
sivukhin:addSeperateProfitInfo
Open

Approximate quadratic bezier curves with arcs and other minor improvements#1213
sivukhin wants to merge 8 commits into
svg:mainfrom
sivukhin:addSeperateProfitInfo

Conversation

@sivukhin

@sivukhin sivukhin commented Feb 2, 2020

Copy link
Copy Markdown

I want to say, that I spent a great time exploring svgo and creating this little patch. Big thanks to all of the maintainers for this cool project

This PR introduces several changes:

  1. Added two options: --apply-plugins-at-once and --report-profit-after-every-pass for the sake of exploring your current configuration of svgo and making it more performant by tuning parameters/adding new plugins/removing useless plugins that just waste computing time. If you enable both of these options you can see the following output in your console:
Iter. 1: 0.793 KiB - 0.9% = 0.786 KiB
    removeDoctype
Iter. 1: 0.793 KiB - 0.5% = 0.782 KiB
    cleanupNumericValues
Iter. 1: 0.793 KiB - 1.5% = 0.771 KiB
    removeUnknownsAndDefaults
Iter. 1: 0.793 KiB - 24% = 0.58 KiB
    convertPathData
Iter. 2: 0.793 KiB - 1.7% = 0.566 KiB
    convertPathData
  1. Also, I fix a few bugs:
    a. reusePaths plugin can increase svg output size if there are no elements for reuse because this plugin always add <defs/> block
    b. reusePaths plugin always expect that first element of svg will be an <svg> tag, but this can be not true in case where we do not want to strip comments and meta-headers
  2. Added sketch of the plugin part, that tries to replace a sequence of quadratic Bezier curves with circular arcs. This may look a little bit odd, because usually, vector graphics software represents arcs with cubic bezier curves, not quadratic, but I recently saw such example in gitter/sidecar repository and thought it will be nice to support such functionality in the svgo. Code for convertPathData looks a little bit scary for me and my patch with new functionality looks a little bit alien in this place of code. If you think that this bit of functionality is interesting than I can try to refactor loop with filters or create a separate plugin for the type of optimization

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

Successfully merging this pull request may close these issues.

1 participant