-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add option for rounding to set number of decimals #262
base: master
Are you sure you want to change the base?
Conversation
I'm still mulling over this. In general I'm not opposed, but it has the potential to break images if used wrongly (which the existing precision option usually does not!) and on top of that it will be confusing for people to have two separate options to control numeric precision. I might consider accepting it as an "interim solution" until we can come up with something that ticks all checkboxes, i.e. is user-friendly, ensures image quality and achieves smallest file size. A "proper" fix likely would be what I suggested in #141 (comment), as I ensures precision matches the size of objects, but it will be a bit more work to implement (also as absolute coordinates would probably need to be treated differently from relative coordinates). In any case the MR can't be accepted as-is, as it's currently rounding the numbers on import. That means numeric errors will be "amplified" while processing the file (and doing things like applying transforms, etc.). Instead any rounding needs to be done at the very end of all processing when writing out the numbers as a string. |
Hey, thanks for the review! I totally agree, rounding / precision should be done on output, and not on import. I will try to look into how it can be implemented. If you have any ideas, please share :) |
I would really like such an "absolute precision" mode (i.e. being able to determine how many digits after the comma the result has). For me it makes more sense than the current mode, which I would call "relative precision". For positions in the current, "relative" precision mode it depends where in the image a coordinate is to determine its actual precision in the output. Let me give an example of what I mean:
As this examples below show, this has the potential to introduce different look of regions in the resulting images depending on where in the image objects are positioned!. Example .svg file:
Output (produced using Inkscape 1.2.2 with Scour "0.31+", as far as I understand the settings regarding precision haven't changed since?):
As you can see, the two rects close to the origin are really well-preserved; but the two rects at 100.x are moved over one another! In contrast, if there was an option for a fixed number of decimal points, the output would look like this (for e.g. 1 digits after comma):
Which would use a little more space than above of course, but would be much more consistent: The distance between to rect 1 and 2 would be the same as the distance between rect 3 and 4, instead of 3 and 4 being moved to exactly the same coordinates! Where it could make sense in my opinion to use a "relative precision" (i.e. significant digits overall) is for encoding length; but even then the "environment" has to be taken into account; for example:
EDIT: Just saw that somebody else has made the same point over in that issue already! |
Fixes #141