W3C home > Mailing lists > Public > www-svg@w3.org > July 2011

Re: stroke=gradient for lines or horizontal paths

From: Alex Danilo <alex@abbra.com>
Date: Wed, 13 Jul 2011 17:03:27 +1000
Message-Id: <RLF9OL.HSES4CUU8INM@abbra.com>
To: Andreas Neumann <a.neumann@carto.net>
Cc: <www-svg@w3.org>
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?


--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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:25 UTC