W3C home > Mailing lists > Public > www-svg@w3.org > August 2012

Re: [svg2] radialGradient @fr constraints

From: Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
Date: Fri, 31 Aug 2012 09:20:45 +0200
Message-ID: <504065CD.30902@hccnet.nl>
To: www-svg@w3.org
On 30-08-12 12:44, Dr. Olaf Hoffmann wrote:
> Jasper van de Gronde:
>> If you take the absolute value before interpolating, then you get the
>> weird situation that a cone (for example) first gets "thinner" and then
>> thicker again as you change the radius of one end from positive to negative.
> For animation?

I was more thinking about someone tinkering with the source of an SVG or 
modifying a radius in a GUI.

>> It also makes perfect sense if you represent a circle by x^2+y^2=r^2, or
>> using a parametric representation.
> Is there really a difference between positive and negative r in a real
> number space?
> In the example you give, the main difference seems to be, that the
> center of the circle is changed, but the radius is always not negative.

I think I may not have been clear enough about what the examples 
actually show. Both the center and the radius varied. And you're right 
that there isn't (much) of a difference between a positive and a 
negative radius, but there is a difference between interpolating from 
radius 5 to 5 and interpolating from radius 5 to -5, as demonstrated by 
my first and last examples:
In the first case you get a tube (constant radius), in the last one you 
get a double cone (the radius is zero at t=0.5).

>> The images were drawn by solving
>> (x-cx(t))^2+(y-cy(t))^2-r(t)^2
> = 0?

Yes, the =0 was missing. (I think Canvas uses the same equation and 
mostly the same notation btw.)

> Still you can interpolate with values="5;0;5" for r and
> values="-5;5" for cx to get the same effect.

I think you might be referring to animation here (and I'm not), but in 
principle you're right that you can get the same effect by splitting up 
the gradient in two. As such I'm not necessarily advocating allowing 
negative radii (although it should have negligible impact on 
implementation complexity), but I am trying to show why it makes no 
sense to take the absolute values of the radii at the endpoints and then 
interpolate. Basically negative radii do have an interpretation and it 
results in something other than what you get when you first take the 
absolute values. So I would suggest either allowing negative radii (and 
using their natural interpretation), or not allowing them (and clamping 
to zero for example).

> And if it is allowed to set fx,fy outside the circle, fr positive or negative,
> one still needs to define the effect for spreadMethod as already mentioned.
> Because this is already problematic, if the point is on the
> circle, do you have any idea about a meaningful behaviour
> of spreadMethod, if fx,fy is outside and not corrected?
> spreadMethod seems to be only simple, if there is not selfintersection
> of the gradient.

Actually, spreadMethod is pretty straightforward, regardless of where 
the fx,fy is in relation to the (other) circle. If you solve a quadratic 
equation like I did (and Cairo does, and probably many others), then you 
simply don't discard t values outside [0,1] and do whatever you want 
with them (repeat, reflect, pad, whatever). If you really draw circles, 
then you just draw them for all t that have some effect on the image. Of 
course, if the focus is exactly on the circle and you're trying to solve 
the quadratic equation, then you get some numerical problems, but that's 
regardless of whether or not you use spreadMethod or allow the focus to 
lie outside the circle (outside the circle is no problem, only /on/ the 
circle is a bit of a problem).

(I'll try posting some more examples over the weekend.)
Received on Friday, 31 August 2012 07:21:16 UTC

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