Remove trailing zeroes from decimal numbers #3
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.
Hi! Thank you for creating this library. I noticed a problem using it when
precision
is set to anything above0
. So, I made a small change to remove trailing zeroes from decimal numbers in the output paths. This change serves two purposes:A
command will no longer cause some renderers to fail. Previously, the "large-arc" and "sweep" flags were being set to0.0
instead of0
and causing some renderers to fail.For example, try testing the following SVG path (tested in Firefox and Edge w/ WebKit):
M11,0H5A1,1,0,0,0,4,1V4H6V2H10V10H6V8H4V11A1,1,0,0,0,5,12H11A1,1,0,0,0,12,11V1A1,1,0,0,0,11,0zM8,5H3V3L0,6L3,9V7H8V5
This works. Now try changing one inconspicuous
0
to0.0
:M11,0H5A1,1,0,0.0,0,4,1V4H6V2H10V10H6V8H4V11A1,1,0,0,0,5,12H11A1,1,0,0,0,12,11V1A1,1,0,0,0,11,0zM8,5H3V3L0,6L3,9V7H8V5
This now doesn't work.
If this change is accepted, you may also consider changing the default
precision
from0
to something moderate like4
, since trailing zeroes will no longer inflate the output size unnecessarily, and this extra default precision would help the library work better for a wider range of inputs.Thanks again for your hard work and thanks for reading!