
In SVG, when an object uses a gradient fill, there are two ways to specify the points that define the gradient position (two ends of the vector for linear; center, focus, and radius for radial). First, you can use userspace coordinates which are just regular coordinates in the document space, much like any other coordinates that govern the placement of objects. And second, you can use bounding box coordinates which are relative to the bbox of the object that uses the gradient; for example, the point (0.5, 0.5) will be at the center of its bbox.
These two coordinate systems are functionally equivalent, i.e. there's no gradient that can be expressed in one system and not the other. Obviously, bbox coordinates are more convenient for those who read/write SVG manually. For an interactive editor like Inkscape, however, bbox coords are a nightmare. The reason is simple: for arbitrary transformations of arbitrary objects, you cannot predict the bbox after transformation, because it depends on the shape of the object.
A simple example: a circle and a square, with equal bboxes, are both rotated 45 deg; now their bboxes are very different. This means that if both use a gradient with bbox coordinates, the gradients will be displaced differently relative to these shapes after the transformation. With userspace coords, however, you just multiply each gradient point by the same transfomation matrix, and the object is transformed along with its gradient as a whole, without any displacement or desynchronnization.
So, when I decided to sanitize gradient handling, the first thing I did was write a function that translates a gradient from bbox coords to userspace coords. This function is now called whenever you transform an object with gradient. Without this, it would be impossible to implement the "transform with object" switch which now works reliably for any shapes or paths, in both "preserve" and "optimize" modes. This means, however, that gradients with bbox coords can only survive so long as you don't transform their users.
Now, initially my plan was to add a reverse function to convert userspace back to bbox (relative to the object's new bbox, of course) after the transformation, if initially it used bbox coords. This is the least intrusive approach, but the more I think about it the less I like it. This adds more complexity to the already quite complex system of adjustments and compensations that fires every time you transform something. And more importantly, it's just useless. Bbox coords offer no advantages whatsoever in an interactive application; they just make things more complex and potentially confusing to the user.
So, now my plan is:
- Do not convert gradients to bbox coords ever, only from bbox to userspace (as now).
- In Fill&Stroke, remove the "Coordinates" switch from the gradient pane, and make it always create gradients with userspace coords. This switch has no visible effect anyway, so it is likely to be confusing, especially for novices.
In other words, the ability to _show_ bbox coords remains, but I plan to remove the ability to _create_ them, and they won't be preserved when you transform things.
I have found only one situation where userspace/bbox makes a difference: Paste style. Consider a rect with a vertical linear gradient, black to white. Copy it and paste the style (Ctrl+Shift+V) to another rect which is below the first one. If the coords were bbox, then the new rect will also be black-to white in its place. If the coords were userspace, however, the new rect will be all white, and its black-to-white transition will be outside of its shape, in line with the old rect above it.
As for me, I do not consider this a disadvantage, because I often need exactly this behavior (i.e. I want the gradient to stay unmoved relative to the canvas so that the new objects "continue" it) and rarely if ever need the other behavior (where pasted gradient is moved to the position of the new object). Others however may have different preferences. There may also exist advantages to bbox coords that I'm missing. Hence this call for opinions; please put forward your thoughts on this. If there's no opposition, I'll proceed with the above plan.