[cairo] path gradients and cairo
David Reveman
c99drn at cs.umu.se
Mon Apr 26 00:52:16 PDT 2004
On Sun, 2004-04-25 at 20:00 -0700, Vladimir Vukicevic wrote:
> David Reveman wrote:
> > I think a "path gradient" pattern can be quite useful.
> > Something similar to:
> >
> > cairo_pattern_t *
> > cairo_pattern_create_for_current_path (cairo_t *cr);
> >
> > would be nice and we would probably need to add on or two functions for
> > setting the center and surrounding color points, right?
>
> Mmm. I was thinking of something like this, but I have a hard time
> figuring out how you'd specify the colors. Concievably, the current
> path could include curves and the like.. I'm not sure how you'd specify
> what point to attach a color to. The "simple" implementation would be
> cairo_pattern_create_path (cairo_point_t *points, cairo_color_t *colors,
> int num_points) -- but this doesn't really fit with any of the current
> API functions (especially considering there's no publicly exported
> cairo_point_t nor cairo_color_t).
>
> It also probably wouldn't make sense to extend paths to be able to store
> color ops, so I'm not sure of the right way to specify the color data.
I'd suggest that we use the current path API. The center and surrounding
points could be set with something like:
cairo_pattern_set_center_color (cairo_pattern_t *p,
double r, double g, double b, double a);
cairo_pattern_set_surround_color (cairo_pattern_t *p, int point,
double r, double g, double b, double a);
not all points on a path would have to be specified. The color for not
specified points could be interpolated from the color of nearest
specified points. The same color interpolation would be used for curves
where we'll have to internally generate a bunch of points for smooth
curved shaped gradients.
- David
--
David Reveman <c99drn at cs.umu.se>
More information about the cairo
mailing list