-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(optimizePathOrder): new plugin #1848
Open
KTibow
wants to merge
36
commits into
svg:main
Choose a base branch
from
KTibow:patch-optimize-order
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+610
−1
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
d17ccee
New plugin: optimize path order
KTibow 37fe2d6
properly account for precision
KTibow 1a3ee7c
update logic to account for more stuff
KTibow e305966
implement arcs
KTibow 913f27c
add a doc page
KTibow 7007104
rename data to arc
KTibow 192d29c
less hacky way of reducing precision
KTibow 68b3c34
Fix ternaries
KTibow e31afa2
switch to a for loop
KTibow 5bfef70
fix formatting & use a faster, better stringifyargs
KTibow 2016d6a
properly handle fill none
KTibow d7bf163
use an even faster way of stringifying args
KTibow ad9d5da
faster way to estimate path length
KTibow 876afcb
don't run process on identical version
KTibow 94f45cd
use estimation in base size, fix estimation
KTibow 87bb736
also optimize curves
KTibow a2bf7ec
add polylineOnly
KTibow b2ea7a2
go from transformPath to transformCommand
KTibow b54e168
speed: roll through commands
KTibow 25377cd
also stage the shortened svgs
KTibow 6883612
assume fill
KTibow ab5a098
allow changing direction if there is only one part
KTibow 991fcd3
Merge remote-tracking branch 'upstream' into patch-optimize-order
KTibow 88782bc
Merge remote-tracking branch 'upstream' into patch-optimize-order
KTibow c0c4cf0
don't crash if convertPathData is off and add tests
KTibow f6d3906
Make it not on by default
KTibow b50a6e7
fix formatting
KTibow 927c326
Merge remote-tracking branch 'upstream/main' into patch-optimize-order
KTibow e62675a
use new set
KTibow 444e12f
Merge remote-tracking branch 'upstream/main' into patch-optimize-order
KTibow d065475
update to esm, return early for perf
KTibow 6d1e7d5
rearrange statement, use tofixed, fix test
KTibow ea8237f
more efficient estimatepathlength
KTibow 9b8e1e3
marginally improve estimatelength perf
KTibow 462b7c0
skip on totally unsafe
KTibow 7675369
fix ts issue
KTibow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: Optimize Path Order | ||
svgo: | ||
pluginId: optimizePathOrder | ||
parameters: | ||
floatPrecision: | ||
description: Number of decimal places to round to, using conventional rounding rules. | ||
default: 3 | ||
noSpaceAfterFlags: | ||
description: If to omit spaces after flags. Flags are values that can only be <code>0</code> or <code>1</code> and are used by some path commands, namely <a href="https://developer.mozilla.org/docs/Web/SVG/Attribute/d#elliptical_arc_curve" target="_blank"><code>A</code> and <code>a</code></a>. | ||
default: false | ||
polylineOnly: | ||
description: If to skip path parts that include curves. This will speed up optimization but not get as good of a result. | ||
default: false | ||
--- | ||
|
||
Optimizes parts of paths by starting in different places and reversing them. | ||
|
||
## Usage | ||
|
||
<PluginUsage /> | ||
|
||
### Parameters | ||
|
||
<PluginParams /> | ||
|
||
## Demo | ||
|
||
<PluginDemo /> | ||
|
||
## Implementation | ||
|
||
- https://github.com/svg/svgo/blob/main/plugins/optimizePathOrder.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I don't do this, whenever I set an exact value for an argument it leaks out, despite my plugin having a default set. (js2path stores the value exactly, and if it gets called later with a different precision it overrides.)