- From: Ian Hickson <ian@hixie.ch>
- Date: Mon, 14 May 2007 18:49:43 -0700
On 5/4/07, Philip Taylor <excors+whatwg at gmail.com> wrote: > For radial gradients, I've been looking into what happens when the two > circles that define the gradient are not fully overlapping (i.e. not > one entirely inside the other) - this appears to not be implemented or > specified accurately. No kidding. Wow. > Negative radius values don't sound very useful or sensible to me, and > they're not implemented in a useful or compatible way, so I think they > ought to be handled as either: > * Always take the absolute value of r0 and r1. > or > * Throw INDEX_SIZE_ERR when passed a negative r0 or r1 (for similarity > with arc). > I don't know which would be better. I'll guess the first for now, > since it matches Firefox. Fixed. > So, I would suggest defining something like: > > <<<< > Once a gradient has been created (see below), stops must be placed > along it to define how the colors are distributed along the gradient. > Between each such stop, the colors and the alpha component must be > linearly interpolated over the RGBA space to find the color to use at > that offset. Before the lowest stop, the color of the lowest stop must > be used. After the highest stop, the color of the highest stop must be > used. > > [Clarified to "linearly interpolated". Changed what happens outside > the range of the stops - since this text is shared with linear > gradients, I'm assuming they are both changed to be the same.] Done. > Radial gradients must be rendered as follows: > > * If one of the start circle and end circle is enclosed within the > other circle, and their circumferences touch in at least one point, > then the gradient must be rendered as the color at offset 0. > > * Otherwise, a cone or cylinder must be created from the circles, such > that at the circumference of the starting circle the color at offset 0 > is used, that at the circumference of the ending circle the color at > offset 1 is used, that the circumference of a circle drawn a certain > fraction of the way along the line between the two origins with a > radius the same fraction of the way between the two radii has the > color at that offset (interpolation happening as described above) for > all offsets such that the radius of the circle at that offset is > positive; that the end circle appear to be above the start circle, and > that any points not described by the gradient are a transparent black. I did basically what you described as your second bulletpoint. The only case this doesn't cover is the x0,y0,r0=x1,y1,r1 case, but that doesn't really make any sense to me from a radial gradient point of view. I've made it paint nothing. It could raise an exception, I guess. Or paint a circle of the second colour against a background of the first colour. -- Ian Hickson
Received on Monday, 14 May 2007 18:49:43 UTC