Re: stroke=gradient for lines or horizontal paths

Hi Andreas & David,

	Yes I agree this is non-intuitive.

	Our implementation does the wrong thing in this
case and _does_ produce the gradient the same as ASV.

	The object bounding box in this case has 0 size
as per what's returned from getBBox(). But of course the
actual physical extent of the stroked object has a size
and that's what ASV and we use as the bounding box for
the gradient fill.

	Putting my author hat on, I think the current
definition is bad since it confuses people. It seems
pretty intuitive to expect that the bounding box of
something you can see is actually the bounding box
used for these calculations.

	Which of course begs the question - how do you get
the bounding box of a stroked object through the DOM?

Alex

--Original Message--:
> Hi David,
>
> I learned about this limitation a few years ago when I programmed a 
> little color picker with sliders that had gradients on a line. I had to 
> change to <rect/> elements instead of <line/> elements for this purpose.
>
> 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 am not sure if the SVG WG is able to fix this issue?
>
> Andreas
>
> On Tue, 12 Jul 2011 20:04:34 -0400, David Dailey wrote:
>> Hi folks,
>>
>> In the relatively simple file at
>> http://srufaculty.sru.edu/david.dailey/svg/text/gradientLines.svg [1]
>> (source code included below), a series of five nearly horizontal 
>> lines
>> is drawn using either  or  . In three cases the stroke value is a
>> pointer to a gradient. In one of those cases, the line is drawn to be
>> just a tad off of true horizontal.
>>
>> The following browsers fail to properly portray the gradient in the
>> two cases that a truly horizontal line is stroked by a gradient:
>>
>> Opera 11.5
>>
>> Firefox 5
>>
>> IE 9
>>
>> Chrome
>>
>> Safari
>>
>> Safari and FF actually draw five lines (the others draw only three),
>> but the gradients are ignored.
>>
>> Sigh… it looks like ASV passes the test though, so we can't hardly
>> call it an "acid test" now can we since ASV was born before Hixie?
>>
>> Actually, since so many browsers seem to misfire here, perhaps the
>> spec should say something like "lines may be stroked by gradients 
>> even
>> when they are horizontal."
>>
>> Cheers
>>
>> David (whose reason for creating this example may be made clearer by
>> my next post)
>>
>> --------------source code---------------
>>
>>
>>
>> Links:
>> ------
>> [1] http://srufaculty.sru.edu/david.dailey/svg/text/gradientLines.svg
>
>-- 
> --
> Andreas Neumann
> Böschacherstrasse 10A
> 8624 Grüt (Gossau ZH)
> Switzerland
>
>
>

Received on Wednesday, 13 July 2011 07:04:01 UTC