Re: Fwd: Question on gradient userSpaceOnUse

On Tue, 05 Jan 2010 09:18:17 +0100, Alex Danilo <alex@abbra.com> wrote:

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

Just to test for consistency I also verified that moving the transform  
attribute from the rect in the example Jeff posted up to a surrounding g  
element does the same thing. Basically confirming that the current user  
space includes the transform on the element itself too. All viewers I  
tested displayed the gradients it the same way as in Jeff's original  
example.

I also added a couple of lines to illustrate what the spec says the  
gradient vector should be.

Modified example:

<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink">
   <defs>
     <linearGradient id="g1" x1="0" y1="0" x2="400" y2="50"  
gradientUnits="userSpaceOnUse">
       <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"  
gradientUnits="userSpaceOnUse">
       <stop offset="0" stop-color="red"/>
       <stop offset="0.5" stop-color="green"/>
       <stop offset="1.0" stop-color="blue"/>
     </linearGradient>
   </defs>

   <g transform="translate(100,100)">
     <g transform="scale(0.25,1)">
       <rect width="400" height="50" fill="url(#g1)" />

       <!-- show the gradient vector in current user space -->
       <line x1="0" y1="0" x2="400" y2="50" stroke="black"/>
     </g>
     <rect y="100" width="100" height="50" fill="url(#g2)" />

     <!-- show the gradient vector in current user space -->
     <line x1="0" y1="100" x2="100" y2="150" stroke="black"/>
   </g>
</svg>

...

> 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
> 'userSpaceOnUse'.
>
> 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.

I agree that it makes sense to make the gradient perpendicular to the  
gradient vector for both 'objectBoundingBox' and 'userSpaceOnUse'.

Cheers
/Erik

-- 
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed

Received on Tuesday, 5 January 2010 10:09:23 UTC