Snapping to grid is too weak
Summary:
- My use case is that I create designs for things like mosaic tilings where I want to create things which are (a) tessellations and (b) the shapes have standard sizes using fixed measuring units.
- Snap to grid should mean precisely that. The page should be divided by the grid into a number of cells and the position and size of every shape drawn when grid snapping is enabled should be defined according to which grid points the key points of the shape lie on. (This sounds more complicated than it is.) Everything that's drawn should be "on the grid". This is the common meaning of aligning things to a grid.
- Snap to grid in Inkscape doesn't currently mean snapping so that every position lies on a grid point. It currently means that sometimes it'll snap to grid points but other times it'll treat grid lines as though they were guide lines, and at other times still it just won't snap the shape to anything at all.
- Inkscape decides these things using concepts internal to itself which the user has no control over and the existence of some of them can only be inferred indirectly (either through their effects or by reading documentation for older versions of the product where UI settings are described which no longer exist).
- These "hidden" elements are:
- The two distinct concepts of a "grid intersection" and a "grid line" which appear differently in infotips yet only a single option appears in the snapping controls relating to grids and it's unclear which of these two things the option is referring to or how the user is supposed to disable snapping to one of them without disabling snapping to other.
- The requirement that in order to effect a snap the pointer needs to be within a certain maximum distance from the grid point the user wants to snap to, the "tolerance". The existence of the tolerance, how big it is, or how to change it are unclear.
Steps to reproduce:
- Open Inkscape.
- Open Document Properties.
- Create a rectangular grid
- Ensure snapping to grids is enabled.
- Zoom in.
- Select the rectangle tool.
- Draw a rectangle.
What happened?
One of three things happens with respect to each of the two points which are used to define the rectangle, depending on the positions of the mouse pointer with respect to the boundaries of the nearest enclosing grid cells:
- The correct thing happens. I.e. each corner snaps to the point on the grid which was nearest to where the mouse pointer was located (or as Inkscape calls them "grid intersections"). Here's a screenshot where one corner is snapped correctly but the other 3 corners are not. I probably took the screenshot during a move operation but the behaviour is the same during shape creation. https://pasteboard.co/SeR1HUOFhnnT.png
- One or both points snap to places which lie along a grid line but are not points on the grid. In this case we no longer have a functioning grid coordinate system but rather the grid is acting as though it were a whole bunch of guides placed at regular intervals horizontally and vertically. In this case Inkscape tells you that it's snapping to a "grid line" which it treats as a distinctly different semantic concept from a "grid intersection". https://pasteboard.co/g2Bs4ulruLT4.png
- One or both both points don't snap to anything because the mouse pointer was placed too far away from any of the grid lines or grid intersections according to some hidden tolerance factor which doesn't seem to be adjustable from anywhere in the UI.
What should have happened?
- It should be possible to create designs using grids in such a way that everything is locked to the grid.
- If snapping to "grid lines" at places which aren't "grid intersections" is a thing that some people want then snapping to grid lines and snapping to grid intersections need to be listed as two separate items on the advanced snapping menu so that they enabled or disabled separately. https://pasteboard.co/nPjRdk0vokVh.png (Though what it would mean to enable snapping to grid lines but simultaneously disable snapping to grid intersections I don't know, since in mathematics a point has zero area.)
- It should be possible to increase or decrease the overall snapping tolerance in general.
- In the case of snapping to the grid it should be possible (but optional) to override the general tolerance with an "infinite" tolerance while grids are displayed, thus guaranteeing that no matter how far away something is placed from a grid intersection it will always snap to a point on the grid (AKA grid intersection).
Workaround
After messing about with this for a whole day, tearing my hair out, discussing it in the forum with people who didn't seem to get why this would be a problem (https://inkscape.org/forums/beyond/how-to-restore-previous-grid-snapping-behaviour/), searching the web and confirming that older versions of Inkscape contained the features that I need, finding something called gridtolerance inside my preferences.xml file which unfortunately seems to be non-functional, and then finally searching through the source code and following a trail of interesting clues, I finally discovered that the following steps will activate a hidden feature that works (for now).
- Open the XML editor.
- Find something called namedview1.
- Add an attribute called gridtolerance and set its value to 65535.
It really shouldn't be this hard to set up a basic grid based design though!
(Unfortunately I'm a JavaScript person rather than a competent C++ or GTK programmer, so I didn't get as far a putting together a pull request.)
Version info
Inkscape 1.3 (0e150ed6c4, 2023-07-21)
Windows 10 version 22H2