svgo icon indicating copy to clipboard operation
svgo copied to clipboard

Variable floatPrecision

Open Paul-Browne opened this issue 1 year ago • 3 comments

I would like the option to use a different floatPrecision to round stroke-width, stroke-opacity to 2dp and paths to 0dp

eg.

<path fill="none" stroke="#F9ED69" stroke-miterlimit="10" stroke-opacity=".74698" stroke-width=".33333" d="m110.5 166.7 16.8 18.4 24.9 2.8 13.5 21 24.7-4 24.2-6.2 24.4-5.4 24.8...

would become

<path fill="none" stroke="#F9ED69" stroke-miterlimit="10" stroke-opacity=".75" stroke-width=".33" d="m111 167 17 18 25 3 14 21 25-4 24-6 24-5 25...

Maybe the floatPrecision option can be extended? Something like...

const result = optimize(data, {
    multipass: true,
    floatPrecision: {
        default: 3,
        path: 0,
        strokeWidth: 2,
        strokeOpacity: 4
    }
});

Paul-Browne avatar Nov 15 '23 07:11 Paul-Browne

relevant: https://github.com/svg/svgo/issues/1828

KTibow avatar Nov 15 '23 14:11 KTibow

https://github.com/svg/svgo/pull/1843

Paul-Browne avatar Nov 21 '23 08:11 Paul-Browne

If that closes this you should add "closes #1838" to the PR description

KTibow avatar Nov 21 '23 14:11 KTibow