[cairo] Path Gradients

Bobby Salazar bobby8934 at inbox.com
Fri Dec 21 10:03:00 PST 2007

Ok then. From what I understand of the GDI+ implementation, you have a path and a center point (or an outer path and an inner path instead of a single center point). Then you set color stops that define how the gradient looks going from the center point (or the inner path) to the outer path. IIRC, if you use an inner path, the entire path is filled with the first color stop, and then the gradient starts at the edges of the inner path.

So perhaps an API that looks something like this:

cairo_pattern_t* cairo_pattern_create_path_gradient(const cairo_path_t *outer_path, const cairo_path_t *inner_path);

Then you can add colors stops as needed. It seems to me that the center point could be represented using the function above. But you could also provide an additional function that creates a pattern based on an X and Y center point instead of an inner_path. Another function could be provided that uses the current path (and either inner_path or center point) to construct the pattern.

Questions, thoughts, etc.?

BTW - here is a good page on using GDI+ path gradients: http://msdn2.microsoft.com/en-us/library/ms533917.aspx

> -----Original Message-----
> From: behdad at behdad.org
> Sent: Wed, 19 Dec 2007 16:48:33 -0500
> To: bobby8934 at inbox.com
> Subject: Re: [cairo] Path Gradients
> On Wed, 2007-12-19 at 16:29 -0500, Bobby Salazar wrote:
>> That's too bad. Perhaps it would help if I were to put up some money to
>> the
>> person or people who implement it? Speak up if you're interested in
>> working
>> on this, and I can come up with an amount.
>> As for the API, I don't really care how it worked as long as it was
>> simple and
>> straight-forward. And you could always take a look at the GDI+ API for
>> this.
> Maybe you can look at the GDI+ API and come up with a suggestion based
> on it?  That helps more than monetary offers...
> behdad
>>> -----Original Message-----
>>> From: cworth at cworth.org
>>> Sent: Wed, 19 Dec 2007 10:42:05 -0800
>>> To: bobby8934 at inbox.com
>>> Subject: Re: [cairo] Path Gradients
>>> On Tue, 18 Dec 2007 14:03:50 -0800, Bobby Salazar wrote:
>>>> Is it possible to fill a shape with a path gradient (similar to
>>>> GDI+) using Cairo?
>>> Not currently, no.
>>> People have expressed interest in something like that before. The two
>>> things we are missing are:
>>> 	1. A detailed description of what the API would look like.
>>> 	2. An implementation of that.
>>> Anyone is free to help out with either or both parts as they would
>>> like to.
>>> Sorry that we don't have anything like this yet. But I do hope you
>>> still have fun with cairo!
>>> -Carl
>> ____________________________________________________________
>> http://www.inbox.com/smileys
>> Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™
>> and most webmails
>> _______________________________________________
>> cairo mailing list
>> cairo at cairographics.org
>> http://lists.cairographics.org/mailman/listinfo/cairo
> --
> behdad
> http://behdad.org/
> ...very few phenomena can pull someone out of Deep Hack Mode, with two
> noted exceptions: being struck by lightning, or worse, your *computer*
> being struck by lightning.  -- Matt Welsh

More information about the cairo mailing list