You don't need that big of a float precision
So I love using SVGO for optimizing my SVGs. One of the integral
parameters is floatPrecision
, which determines how many
decmial points to use when writing out numbers. It's set to 3 by
default, but it can probably be lowered.
We're going to assume that we're scaling your SVG up to the height of my laptop's screen, 1824px. My laptop is relatively high density, so we're going to say we won't tolerate an on-screen error of more than 0.5px. Now let's calculate how big of a precision you need based on your SVG's size.
- 3648px or bigger: floatPrecision of 0
- 365px or bigger: floatPrecision of 1
- 37px or bigger: floatPrecision of 2
- 4px or bigger: floatPrecision of 3
Now let's look at errors for some common SVG sizes.
- 24px: 3 -> 0.076px error, 2 -> 0.76px error
- 48px: 3 -> 0.038px error, 2 -> 0.38px error
- 192px: 2 -> 0.095px error, 1 -> 0.95px error
- 625px: 2 -> 0.029px error, 1 -> 0.292px error
- 1024px: 2 -> 0.018px error, 1 -> 0.178px error
- 1080px: 2 -> 0.017px error, 1 -> 0.169px error
Here's a calculator too.
Warning: When converting to absolute, SVGO sometimes loses precision, since it rounds twice.