Skip to content
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

new plugin: decrease accuracy of floating-point numbers #8

Closed
deepsweet opened this issue Oct 17, 2012 · 4 comments
Closed

new plugin: decrease accuracy of floating-point numbers #8

deepsweet opened this issue Oct 17, 2012 · 4 comments
Assignees
Milestone

Comments

@deepsweet
Copy link
Member

like in convertPathData plugin but at least for polyline and polygon data.

but if the default width/height are very small then increase the accuracy or do something else to reduce distortion.

@ghost ghost assigned deepsweet Oct 17, 2012
@GreLI
Copy link
Member

GreLI commented Oct 19, 2012

SVG allows relative coordinates, so it's important to avoid a systematic error by accumulation rounding errors from the every coordinate. I believe the rounding procedure should work with absolute coordinates. So, the conversion must be done before the rounding.

@deepsweet
Copy link
Member Author

you're right, and that's how it happens in the existing convertPathData plugin.
first - convert absolute to relative, and only then - floating-point numbers rouding.

but there is a problem with the absolute->relative convertion that is not dependent on svgo own rounding - some browsers rounds relative coordinates calculation in their own way, and as a result it's impossible to get a "pixel lossless" optimization.

@GreLI
Copy link
Member

GreLI commented Oct 19, 2012

No, no, no. I was saying quite opposite: first, convert to absolute if needed, then round the values, and then you can convert back to the relative. Otherwise the error will be accumulated on each path step.

@deepsweet
Copy link
Member Author

oh, now i understand.

thank you, i'll keep it in mind :)

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

No branches or pull requests

2 participants