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 22:43:52 +1100
Message-Id: <49VRVK.PYHFZCPO7ND@abbra.com>
To: Dirk Schulze <vbs85@gmx.de>
Cc: Jeff Schiller <codedread@gmail.com>, www-svg <www-svg@w3.org>

Hi Dirk,

--Original Message--:
>Hi Alex,
>> Sorry I don't understand what you are trying to say.
>> 
>> Yes I agree the transform is applied, and the gradient uses the
>> user space of the rect in the example.
>> 
>> The user space for x1,y1->x2,y2 goes along a diagonal direction,
>> not a horiztonal one, so the gradient should be perpendicular to
>> that vector.
>> 
>> Alex
>
>You're right, the vector starts from (x1,y2) and ends on (x2,y2). And
>the color on a imaginary orhtogonal line to this vector, should allways
>be constant. This is what you mean with "so the gradient should be
>perpendicular to that vector".

Yes.

>I mean that the two points should be mapped to the user space coordinat
>space of the element that uses the gradient.

Yes.

>I disagree that y2 is unnecessary in some way for userSpaceOnUse, like
>you mentioned in your first post. This is part of the second point of
>the vector and is neccessary.

True.

>Nevertheless Opera doesn't map all coordinates of the gradient to the
>coordinate space of the element, but seems to do it for patterns.
>Please correct me if I'm wrong.
>
>I hope this is more understandable.

Yes, indeed.

Now let's look at the example, cut down to the rectangle in dispute:

<?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>
 </defs>

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

</svg>

The rect has origin 0,0 (as defaults) with width and height 400x50.
This then has a scale of 0.25 in x, 1 in y.

This should scale 0.25 in x and 1 in y for user space->device space.

So, x1,y1 (0,0) and x2,y2 (400,50) should scale to:
0,0->100,50

i.e. the vector of the gradient is from 0,0->100,50, hence
the orthogonal colour should show a diagonal view like Opera
does.

There is no rotation in the transform.

Firefox, etc. show a gradient that is vertically aligned as if
the vector was along the top or bottom of the rectangle.

I believe that is incorrect.

Alex

>-Dirk
>
>
>
Received on Tuesday, 5 January 2010 11:44:33 UTC

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