gradient to bbox edges, not to rect edges
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
New
|
Wishlist
|
Unassigned |
Bug Description
While working on bug #1171109 I noticed the following:
1. Create a rect with a 2 px wide border, initially solid Fill and Stroke.
2. Change the FILL to a linear gradient using the Fill and Stroke pane.
3. Save the SVG and inspect it.
The linear gradient starts 1 pixel to the left of the rectangle, and ends 1 pixel to the right. Repeated with different stroke widths = S and the result was always that the gradient starts S/2 to the left and ends S/2 to the right (for a horizontal gradient).
Apparently the bounding box including the stroke around the edges is being used to determine the extents of the gradient.
It is possible to get the gradient initially to match the rect nearly exactly by drawing with a thin Stroke. However, if the stroke is later resized, and the rectangle readjusted, the bounds jump out again to -S/2 and +S/2 (left and right).
Presumably the correct thing to do is to use the bounding box as if the Stroke width was 0, since the Fill should be independent from the stroke. For a gradient on the stroke, the current situation would be correct. The only complication I can see in changing this would be if for some reason one wanted to have exactly the same gradient on the fill and the stroke, in which case one would have to manually fiddle with the settings to make them match.
This is taking place in sp_gradient_ reset_to_ userspace in gradient_ chemistry. cpp. A bbox is created from the item but there are no tests for whether it is a fill or a stroke.