You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Teck Hua Lee <gt...@gmail.com> on 2010/04/08 21:00:39 UTC

Line element does not render with gradient stroke

When using the PNGTranscoder (1.7 and trunk), I noticed that lines with
gradient strokes will not render.

In the example below "line2" will not be drawn.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="
http://www.w3.org/1999/xlink" version="1.1">
<defs>
<linearGradient id="grad">
<stop offset="0" stop-color="black" />
<stop offset="1" stop-color="white" />
</linearGradient>
</defs>
  <line id="line1" x1="0" y1="180" x2="480" y2="180" stroke="green"
stroke-width="20"/>
  <line id="line2" x1="410" y1="10" x2="70" y2="350" stroke="url(#grad)"
stroke-width="20"/>
</svg>

I tracked this down to SVGLinearGradientElementBridge.buildGradient:128
where the code returns a null Paint because the line's width is 0px.
However, shouldn't the code be checking the stroke-width instead? (20px)

This example is based on the following W3C SVG spec test file which renders
correctly in Firefox and Chrome.
http://www.w3.org/Graphics/SVG/Test/20061213/svggen/pservers-grad-17-b.svg

Is this a known issue or should I file a bug?

Re: Line element does not render with gradient stroke

Posted by Helder Magalhães <he...@gmail.com>.
Hi Teck Hua Lee,


Thanks for investigating and reporting this. :-)


> When using the PNGTranscoder (1.7 and trunk), I noticed that lines with
> gradient strokes will not render.
[...]
> Is this a known issue or should I file a bug?

Apparently it is correct as-is: a good explanation is available in a
similar test [1] for the SVG 1.1 Second Edition (both test suite and
specification are currently draft). You'll notice Batik matches the
reference rendering (I've checked with Squiggle trunk using the direct
SVG link [2]). Note that Opera 10.51 also matches the expected
rendering, while Firefox 3.7a and Chrome 5.0dev only partially pass
the test. ;-)


Cheers,
 Helder


[1] http://dev.w3.org/SVG/profiles/1.1F2/test/harness/htmlObject/pservers-grad-17-b.html
[2] http://dev.w3.org/SVG/profiles/1.1F2/test/svg/pservers-grad-17-b.svg

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Line element does not render with gradient stroke

Posted by Teck Hua Lee <gt...@gmail.com>.
Sorry, this is the correct example which is a simplified version of
http://www.w3.org/Graphics/SVG/Test/20061213/svggen/pservers-grad-17-b.svg.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="
http://www.w3.org/1999/xlink" version="1.1">
<defs>
<linearGradient id="grad">
<stop offset="0" stop-color="black" />
<stop offset="1" stop-color="white" />
</linearGradient>
</defs>
  <line id="line1" x1="0" y1="180" x2="480" y2="180" stroke="green"
stroke-width="20"/>
<line id="line2" x1="0" y1="180" x2="480" y2="180" stroke="url(#grad)"
stroke-width="20" transform="rotate(90, 240, 180)"/>
</svg>

On Thu, Apr 8, 2010 at 3:00 PM, Teck Hua Lee <gt...@gmail.com> wrote:

> When using the PNGTranscoder (1.7 and trunk), I noticed that lines with
> gradient strokes will not render.
>
> In the example below "line2" will not be drawn.
>
> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="
> http://www.w3.org/1999/xlink" version="1.1">
>  <defs>
> <linearGradient id="grad">
> <stop offset="0" stop-color="black" />
>  <stop offset="1" stop-color="white" />
> </linearGradient>
>  </defs>
>   <line id="line1" x1="0" y1="180" x2="480" y2="180" stroke="green"
> stroke-width="20"/>
>   <line id="line2" x1="410" y1="10" x2="70" y2="350" stroke="url(#grad)"
> stroke-width="20"/>
> </svg>
>
> I tracked this down to SVGLinearGradientElementBridge.buildGradient:128
> where the code returns a null Paint because the line's width is 0px.
> However, shouldn't the code be checking the stroke-width instead? (20px)
>
> This example is based on the following W3C SVG spec test file which renders
> correctly in Firefox and Chrome.
> http://www.w3.org/Graphics/SVG/Test/20061213/svggen/pservers-grad-17-b.svg
>
> Is this a known issue or should I file a bug?
>

Re: Line element does not render with gradient stroke

Posted by Teck Hua Lee <gt...@gmail.com>.
Sorry, this is the correct example which is a simplified version of
http://www.w3.org/Graphics/SVG/Test/20061213/svggen/pservers-grad-17-b.svg.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="
http://www.w3.org/1999/xlink" version="1.1">
<defs>
<linearGradient id="grad">
<stop offset="0" stop-color="black" />
<stop offset="1" stop-color="white" />
</linearGradient>
</defs>
  <line id="line1" x1="0" y1="180" x2="480" y2="180" stroke="green"
stroke-width="20"/>
<line id="line2" x1="0" y1="180" x2="480" y2="180" stroke="url(#grad)"
stroke-width="20" transform="rotate(90, 240, 180)"/>
</svg>

On Thu, Apr 8, 2010 at 3:00 PM, Teck Hua Lee <gt...@gmail.com> wrote:

> When using the PNGTranscoder (1.7 and trunk), I noticed that lines with
> gradient strokes will not render.
>
> In the example below "line2" will not be drawn.
>
> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="
> http://www.w3.org/1999/xlink" version="1.1">
>  <defs>
> <linearGradient id="grad">
> <stop offset="0" stop-color="black" />
>  <stop offset="1" stop-color="white" />
> </linearGradient>
>  </defs>
>   <line id="line1" x1="0" y1="180" x2="480" y2="180" stroke="green"
> stroke-width="20"/>
>   <line id="line2" x1="410" y1="10" x2="70" y2="350" stroke="url(#grad)"
> stroke-width="20"/>
> </svg>
>
> I tracked this down to SVGLinearGradientElementBridge.buildGradient:128
> where the code returns a null Paint because the line's width is 0px.
> However, shouldn't the code be checking the stroke-width instead? (20px)
>
> This example is based on the following W3C SVG spec test file which renders
> correctly in Firefox and Chrome.
> http://www.w3.org/Graphics/SVG/Test/20061213/svggen/pservers-grad-17-b.svg
>
> Is this a known issue or should I file a bug?
>

Re: Line element does not render with gradient stroke

Posted by Helder Magalhães <he...@gmail.com>.
Hi Teck Hua Lee,


Thanks for investigating and reporting this. :-)


> When using the PNGTranscoder (1.7 and trunk), I noticed that lines with
> gradient strokes will not render.
[...]
> Is this a known issue or should I file a bug?

Apparently it is correct as-is: a good explanation is available in a
similar test [1] for the SVG 1.1 Second Edition (both test suite and
specification are currently draft). You'll notice Batik matches the
reference rendering (I've checked with Squiggle trunk using the direct
SVG link [2]). Note that Opera 10.51 also matches the expected
rendering, while Firefox 3.7a and Chrome 5.0dev only partially pass
the test. ;-)


Cheers,
 Helder


[1] http://dev.w3.org/SVG/profiles/1.1F2/test/harness/htmlObject/pservers-grad-17-b.html
[2] http://dev.w3.org/SVG/profiles/1.1F2/test/svg/pservers-grad-17-b.svg

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org