Search code examples
inkscape

Inkscape: round coordinates


Is there a command in Inkscape to round coordinates of a path to the closest integer value.

For instance, to replace this path:

m 0,0 261.98828,-890.8828 -299.999999,-900 2593.486319,54.4063 -253.9941,850.09565 264.3594,870.83005 z

by this:

m 0,0 262,-891 -300,-900 2593,54 -254,850 264,871 z

Solution

  • Option 1: You'd need to use snapping when you create the path, or snap the nodes after creating the path. Set a grid to be 1px by 1px, and snap while drawing.

    Option 2: Or you'd need to write a script that finds all 'd' attributes in the SVG file, and rounds the values in them to integer numbers.

    There are two ways to set the numeric precision (for the SVG itself and when saving to Optimized SVG) - BUT those only define the length of the whole number - so if you set it to 4, you can get 200.1 as well as 1200 or 12.48 , so that's not going to help in this case.