Skip to content

Arc command optimization causes a circle to disappear when rounding to 3 digits #2104

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

Open
parpalak opened this issue Apr 12, 2025 · 0 comments
Labels

Comments

@parpalak
Copy link

Describe the bug
When optimizing an SVG file that contains a dot rendered with a path (see example), SVGO converts the path to an elliptical arc (a) and applies rounding (e.g. floatPrecision: 3). If the arc's start and end points become identical due to rounding, the resulting path effectively disappears in the output.

This leads to a loss of visible elements in the SVG.

To Reproduce

Minimal example:

<?xml version='1.0' encoding='UTF-8'?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="590" height="310"
     viewBox="2195.656274 1486.713736 52.67746 185.305106">
    <rect x="2206.68" y="1566.64061" width="40" height="40" fill="lime" />
    <g id='page1'>
        <path d='m2226.68 1586.64061c0-.550781-.45-.996093-.996-.996093c-.551 0-.997 .445312-.997 .996093c0 .550782 .446 .996094 .997 .996094c.546 0 .996-.445312 .996-.996094z' />
    </g>
</svg>

Steps to reproduce the behavior:

  1. Create an SVG file with the content from example above.
  2. Run svgo on it with default plugins and floatPrecision: 3 (2 and 4 works fine!).
  3. Open the optimized SVG in a browser.
  4. Observe that the dot is missing in the optimized file.

Expected behavior
Even after optimization and rounding, small shapes like dots should remain visible.

Screenshots

Image

Desktop (please complete the following information):

  • SVGO Version 3.3.2
  • Node.js Version v18.19.0
  • OS: Debian 12.10

Additional context
Reproduced online (https://jakearchibald.github.io/svgomg/ with default options) and at the local environment.

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

No branches or pull requests

1 participant