Svgo: convertShapeToPath.convertArcs with convertPathData.collapseRepeated produces wrong path arc

Created on 19 Jul 2019  路  4Comments  路  Source: svg/svgo

Suppose we have the following svg:

<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
  <circle cx="20" cy="20" r="20" fill="#4D4D4D"/>
</svg>

And run the following command:

svgo this.svg -o this_compressed.svg --config='{"plugins":[{ "convertShapeToPath": { "convertArcs": true } }, {"convertPathData": {"collapseRepeated": true}}]}'

The produced svg is:

<svg width="40" height="40" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#4D4D4D" d="M20 0a20 20 0 100 40 20 20 0 100-40z"/></svg>

Which seems not right because arc command requires up to 7 params (specs)

If we make collapseRepeated false, then result will be okay:

<svg width="40" height="40" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#4D4D4D" d="M20 0a20 20 0 100 40a20 20 0 100-40z"/></svg>

Is it expected behavior? svgo 1.3.0.

Most helpful comment

There are 14 numbers: 20, 20, 0, 1, 0, 0, 40, 20, 20, 0, 1, 0, 0, -40. There is just no space between 1, 0, 0 twice.

All 4 comments

It's all fine. Arc flags (4th and 5tg parameters) don't need spaces after itself, see #822. An optimization that removes that spaces were added in v1.3.0.

@GreLI Sorry, it seems I do not undertsand.
You say that it is okay that ten numbers are in arc command - 'a20 20 0 100 40 20 20 0 100-40'?

There are 14 numbers: 20, 20, 0, 1, 0, 0, 40, 20, 20, 0, 1, 0, 0, -40. There is just no space between 1, 0, 0 twice.

@GreLI I see what you mean. a20 20 0 100 40 20 20 0 100-40 = a20 20 0 100 40 a20 20 0 100-40.
Thank you.

Was this page helpful?
0 / 5 - 0 ratings