Re: stroke=gradient for lines or horizontal paths

On 13-07-11 08:55, Cameron McCormack wrote:
> Andreas Neumann:
>> I think this is a ugly limitation in SVG, and although Rob is right
>> that the browsers are ok (those <line/> elements do not establish a
>> bounding box), due to the spec, it is hard to explain to users that
>> one cannot easily have gradients on vertical or horizontal lines.
> 
> I agree that it is ugly and I think it should be changed.
> Alternatively, it should be possible to specify that the bounding box
> region that the gradient applies to is not just the bounding box of the
> shape geometry, but something that includes the stroke as well; that
> would result in a bounding box with some area in the case of a stroked
> horizontal or vertical line.

In the specific example that was given here it really shouldn't be a
problem. The object bounding box might have zero height, but it does
have non-zero dimensions in the direction of the gradient, which makes
the gradient well-defined. And it's not like with filters where the
output is clipped or something, the bounding box is just used to find
certain coordinates, which is perfectly possible.

Most likely the comment about disregarding elements using
objectBoundingBox when the bounding box has zero width or height was
made with some other use case in mind. So it might be best to either
special case its use in gradients or revise that comment altogether. (In
fact, I can't immediately think of a reason for this comment, in most
cases it shouldn't cause any real problems to use objectBoundingBox
units with zero width/height objects, it's usually just not what you want.)

BTW, Inkscape apparently has no problems interpreting these gradients
either. So this means there are at least two implementations in the wild
that handle this "intuitively".

Received on Wednesday, 13 July 2011 07:58:54 UTC