[cairo] Path Gradients

Behdad Esfahbod behdad at behdad.org
Fri Jan 4 12:31:52 PST 2008


On Fri, 2008-01-04 at 12:05 -0800, Bill Spitzak wrote:
> Behdad Esfahbod wrote:
> > On Fri, 2008-01-04 at 11:12 -0800, Bill Spitzak wrote:
> >> Behdad Esfahbod wrote:
> >>
> >>>> It was unclear what happens with multiple-step gradients, which some
> >>>> of 
> >>>> the examples show. Does it only change the last step, or is there an
> >>>> api 
> >>>> to change all the steps?
> >>> The actual radial stops where done in the code using a Blend object,
> >>> that's like just having stops for alpha value.  That is, instead of the
> >>> linear interpolation between the two ends, user can provide a detailed
> >>> blend function.  No separate color stops.
> >> I'm sorry, I thought you were talking about the example where the color 
> >> along the edge changes, as shown by the top-left triangle in this picture:
> >>
> >> http://www.java2s.com/Code/VBImages/PathGradientBrushesDiamondRectangleCirlceandquad.PNG
> >>
> >> It is apparent from the examples that they support multi-stop gradients, 
> >> but there is no example of what happens if you specify *both* this and 
> >> if you change the colors along the path. Does it only change the last 
> >> stop? Or is there an api to change all the stops? Or does it just not work?
> > 
> > IIUC the multiple stops are one per path point.  That's for the conical
> > part of the thing.  AFAIU you can't do cairo radial gradients using it
> > because on the radial side it just accepts a blend function.  No
> > separate color data.
> 
> The example in this paper, near the bottom, with the colored star, seems 
> to show a multi-stop gradient being used:
> 
> http://www.bobpowell.net/pgb.htm

Ah sorry, I totally missed that one on first reading.  Seems like
there's SurroundColors that does conical, and InterpolationColors that
does radial.  I wouldn't be surprised if it's one or the other.

The ref docs don't talk about it either:

http://msdn2.microsoft.com/en-us/library/system.drawing.drawing2d.pathgradientbrush_properties.aspx


> > That is, given path P, color stops S, center C, center color Cc, and
> > blend function F, the color at x0,y0 will be computed as...
> 
> Yes this is my best guess as well. However it is unclear how they 
> achieve rectangular shapes with nice fixed-thickness edges. If they are 
> drawing several shapes with different gradients, this could be very 
> annoying, as reproducing the same results without seams will require 
> bug-for-bug compatability with whatever they are doing.

No idea what you mean here.  I assume you are referring to the square
here for example?

http://www.java2s.com/Code/VBImages/PathGradientBrushesDiamondRectangleCirlceandquad.PNG

What is so hard about it?  Sorry for keep asking stupid questions BTW.

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list