W3C home > Mailing lists > Public > www-svg@w3.org > January 2010

Re: Fwd: Question on gradient userSpaceOnUse

From: Alex Danilo <alex@abbra.com>
Date: Tue, 05 Jan 2010 19:18:17 +1100
Message-Id: <HQLRVK.51Z8EYV44GK@abbra.com>
To: Jeff Schiller <codedread@gmail.com>
Cc: www-svg <www-svg@w3.org>

Hi Jeff,


	What a cool test, and what inconsistency! More below:

--Original Message--:
>Hi www-svg,
>This is an email I forwarded to Erik Dahlstrom to question about Opera
>behavior, but thought it appropriate for general SVG WG discussion.
>Consider the following sample:
><?xml version="1.0"?>
><svg xmlns="http://www.w3.org/2000/svg"
> <linearGradient id="g1" x1="0" y1="0" x2="400" y2="50"
>   <stop offset="0" stop-color="red"/>
>   <stop offset="0.5" stop-color="green"/>
>   <stop offset="1.0" stop-color="blue"/>
> </linearGradient>
> <linearGradient id="g2" x1="0" y1="100" x2="100" y2="150"
>   <stop offset="0" stop-color="red"/>
>   <stop offset="0.5" stop-color="green"/>
>   <stop offset="1.0" stop-color="blue"/>
> </linearGradient>
><g transform="translate(100,100)">
> <rect width="400" height="50" fill="url(#g1)" transform="scale(0.25,1)"/>
> <rect y="100" width="100" height="50" fill="url(#g2)" />
>In the above test, Firefox, WebKit and Batik show the top gradient as
>nearly horizontal while Opera shows the two gradients identically.

For the record Abbra's implementation does what Opera does.

So we could both be wrong, so I tested more:
Result A is Firefox, Batik and WebKit behaviour.
Result B is Opera, Abbra

ASV3 - A
Chrome (WebKit) - A
Leading mobile vendor 1 - A
Leading mobile vendor 2 - A
Corel SVG viewer - B

So we have clear disagreement.

Note, the SVG group did consider Corel's viewer to be far
more correct in regard to the spec. than ASV. I suspect that
most viewers have copied what ASV does, not that I claim
to be absolutely correct alongside Opera and Corel.

>The spec says userSpaceOnUse "shall represent values in the coordinate
>system that results from taking the current user coordinate system in
>place at the time when the gradient element is referenced".
>Can someone please clarify what is the correct behavior here?

The spec also says:
"'x1', 'y1', 'x2', 'y2' define a gradient vector for the linear
gradient. This gradient vector provides starting and ending points
onto which the gradient stops shall be mapped."

There is clarification for the weird perpendicular behaviour of
the gradients for 'objectBoundingBox' where they 'squish' for
non-square areas, but no mention of what is expected for

Personally, I would interpret a gradient vector as being
the vector along which the gradient stops are placed and
also being a vector, that the gradient itself be perpendicular
to that vector.

That seems to be implicit in the extra clarification for
'objectBoundingBox' that says:
"When gradientUnits="objectBoundingBox" the stripes of the
linear gradient shall be perpendicular to the gradient vector
in object bounding box space..."

So, my take is that Opera is correct, and many others
are incorrect.

I'd be happy for anyone else to clarify the alternative
since it makes 'y2' completely useless in the 'userSpaceOnUse'
case. If so, then Opera and us will have to change our
implementations, but I suspect that is unnecessary.


Received on Tuesday, 5 January 2010 08:18:59 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:25 UTC