Inkscape.org
Beginners' Questions Set Pixels (px) or Points (pt) as Units and perform any of the six main Path Operations will change the resulting shape’
  1. #1
    suenkachun suenkachun @suenkachun

    I recently encountered this tiny issue regarding the six main Path Options: Union, Difference, Intersection, Exclusion, Division and Cut Path, when all of the document “Units” are set as either Pixels (px) or Points (pt) and the Shapes/Paths involved do not have a Whole Number Width/Height value. Hopefully, someone can help to check whether this is expected behaviour or a new bug which needs to be reported.

    Operating System: Windows 11 Home Version (64-bit), Inkscape Version 1.2.2.

    Basic Setup: Open a new Inkscape document then open “Document Properties”, set both “Units” to either “px” or “pt” then change the “Scale:” back to “1.000000”, while the “Page Size:” can remain random.

    Scenario 1: Draw a Square with Dimensions 111.111 px times 111.111 px, then Align it to the top-left corner of the page. Either draw another Square of the same size or Copy and Paste/Duplicate the Square then place it directly beside the first Square on the right side (X Position 111.111/Y Position 0). Select the two Squares and the total Width now becomes 222.222 px, but use “Union” under the “Path” drop-down menu to combine the two Squares into one Shape and the total Width now becomes 222.223 px thus 0.001 px more than the original. In this scenario, the “Combine” option can be used instead where the total Width of the resulting Shape will remain the same still at 222.222 px, but the resulting paths and nodes will be different and may affect further editing. When using “pt” as the “Units” the exact same results will be observed.

    Scenario 2: Draw a Square with Dimensions 200 px times 200 px and place it anywhere on the page, then draw another Square with Dimensions 111.111 px times 111.111 px and Align the two Squares with each other in the middle. Select both Squares and use “Intersection” under the “Path” drop-down menu, this time the resulting smaller Square in the middle will become 111.109 px times 111.109 px thus 0.002 px less on each side compared to the original. If either “Difference” or “Exclusion” are used on the two Squares, use the “Edit Paths by nodes (N)” function to extract the middle Square and its Dimensions will also be 111.109 px times 111.109 px. However, when using “pt” as the “Units” the resulting middle Square will be correctly sized with Dimensions still at 111.111 pt times 111.111 pt using the options mentioned here.

    A difference of 0.001 px or 0.002 px can be small and insignificant but in the most perfect cases, these resulting shapes should not increase or decrease in size at all. If all Shapes involved are Squares and Rectangles then the issue can be fixed afterwards by dragging nodes using the “Edit Paths by nodes (N)” function or adjusting the edges of the resulting shape, but Circles and irregular Shapes will be harder to adjust manually. At the moment, only Pixels (px) and Points (pt) are affected but all other measurements will work as intended, I even looked up information regarding “antialiasing” but this did not seem to help. Thank you in advance.

  2. #2
    Tyler Durden Tyler Durden @TylerDurden

    Precision can be affected a number of ways:

    It is essential to account for stroke width, either by turning stroke off, or setting the bounding box preferences to "geometric" (rather than "visual).

    Positioning can have snapping to the bounding box or to paths/nodes.

    The level of precision can be set in the Preferences>Input/Output>SVG Output>Numbers>Numeric precision, Minimum exponent.

  3. #3
    suenkachun suenkachun @suenkachun

    Thank you for the reply. I experimented with the settings you mentioned but the issue is still there, the Pixels or Points will continue to increase or decrease after performing the six main Path Options. However, thanks to these settings which I did not know about before I soon discovered the XML Editor and successfully created the desired shapes error-free.  As this time I’m trying to modify pre-existing shapes within SVG files downloaded online (such as cutting away a certain section to achieve no background colour), the key is to improve the precision of these shapes. On my end the pre-created shapes/paths all used the “d” attribute to represent all Dimensions and Location values instead of individual values, thus affecting precision. Therefore, I simply recreated any existing shapes by manually applying all values onto a newly created square/rectangle/circle, essentially converting the “d” value back into individual attributes. By using “Difference” on these newly created shapes, the dimensions of the resulting removed section was finally not altered. Using “Union” may still cause issues so I will stick with manually creating the desired shapes then using “Difference” for now.

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Set Pixels (px) or Points (pt) as Units and perform any of the six main Path Operations will change the resulting shape’