[cairo-bugs] [Bug 40918] Radial gradients misrendered if focus is exactly on the outer circle
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Fri Sep 16 10:33:52 PDT 2011
https://bugs.freedesktop.org/show_bug.cgi?id=40918
--- Comment #5 from Bill Spitzak <spitzak at gmail.com> 2011-09-16 10:33:51 PDT ---
Would it violate the SVG spec too badly if repeats other than NONE
filled the entire rest of the plane with the repeated color all the
time? Ie when the point is outside the circle all the points outside the
cone shape are always colored the same as when the point is inside the
circle.
bugzilla-daemon at freedesktop.org wrote:
> https://bugs.freedesktop.org/show_bug.cgi?id=40918
>
> --- Comment #3 from Andrea Canciani <ranma42 at gmail.com> 2011-09-16 08:47:40 PDT ---
> (In reply to comment #0)
>> Created an attachment (id=51242)
--> (https://bugs.freedesktop.org/attachment.cgi?id=51242)
> --> (https://bugs.freedesktop.org/attachment.cgi?id=51242)
>> Reduced test case
>>
>> When the focus of a radial gradient lies almost exactly on the outer circle of
>> the gradient, the gradient randomly switches to a different mode of rendering,
>> which results in an abrupt change of appearance. This makes it rather hard to
>> clip the focus point to the outer circle of the gradient as required by the SVG
>> specification.
>
> In order to get consistent results ad to be able to follow the SVG
> specification you probably want to render it using CAIRO_EXTEND_NONE or you
> could cheat a little bit and move the focus slightly inside.
> (I would rather go for CAIRO_EXTEND_NONE, but it's probably much more work
> because you might have to recompute the big circle and the color stops)
>
>> Attached is a reduced testcase. It should render a green surface with a red
>> gradient extending from the edge of the outer circle regardless of the value of
>> the "angle" constant, but most of the time it actually renders only green with
>> some transparency. For an example of correct behavior, set "angle" to zero.
>
> (In reply to comment #2)
>> I've taken the liberty of slapping a BSD-ish licence on your example and adding
>> it to the test-suite:
>>
>> commit f09361cff16776b49e9159c60eea4e8a049865d6
>> Author: Krzysztof Kosinski <tweenk.pl at gmail.com>
>> Date: Fri Sep 16 15:59:38 2011 +0100
>>
>> test: Add radial-outer-focus
>>
>> Numerical instability in the computation of gradients leads to random
>> results.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=40918
>>
>>
>> Andrea, it looks like numerical instability, can you take a closer look?
>
> The very definition of radial gradient is not well-behaved when its focus point
> is on the outer circle and the repeat mode is not NONE. This happens because
> when the focus point is (slightly) inside the outer circle, the radial gradient
> colors the whole plane, when it is exactly on the circle it colors exactly an
> half-plane and when it is outside it colors the region in an angle.
> The focus point can obviously go from inside to outside and vice versa even
> moving by a very small amount (example: rounding error) when it is supposed to
> be exactly on the outer circle.
> Unfortunately ill-conditioned problems and rounding errors hate each other :(
>
--
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the cairo-bugs
mailing list