[cairo] Radii of radial gradients

Michael Urman murman at gmail.com
Sat Feb 24 10:46:35 PST 2007

On 2/23/07, Carl Worth <cworth at cworth.org> wrote:
> > I don't see a model problem with the slight position change leading to
> > a change between sphere and cone modes,
> Well the problem that can be caused here is if some unrelated event
> triggers the transition. For example, one might be zooming in or out
> in a program like inkscape, and different rounding at different zoom
> levels might trigger arbitrarily large portions of the drawing to be
> colored differently.

Ahah, after playing with it, I see the problem now. If you think in
terms of t ranging from 0 to 1, it's not a big deal where exactly the
wall of the cone is pointing. However with an infinite range of t,
there's a magic spot by that egde where the entire range t > 1 flips
from outside the "inner" radius to by all on one side of the inner
center. Since often all of t > 1 has the same solid color, suddenly a
section of your infinite background is no longer infinite; similarly
either that color goes over or under the point of the cone, oblitering
almost everything, or disappearing.

If you think of representing this as a cone with the t axis growing
towards your eye, this is where the wall of the cone crosses pure
vertical, and all rays along the walls of the cone have the same
general slope direction as the center of the cone.

Here's a toy python gtk app that lets you play with endpoints of a
predefined radial gradient drawn manually. Move the endpoints by
clicking, and size their radius before letting up. Use the controls on
the left to twiddle the drawing order and number of steps. If nothing
else, this app shows the real implementation cannot easily be done as
a series of circles without asking for lots of aliasing.


Michael Urman

More information about the cairo mailing list