[cairo] Path Gradients
cworth at cworth.org
Fri Dec 21 11:06:57 PST 2007
On Fri, 21 Dec 2007 10:03:00 -0800, Bobby Salazar wrote:
> 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);
Thanks for starting this.
> Then you can add colors stops as needed.
Is there enough information in this API for there to be an unambiguous
result? With the existing color-stop interface you get to specify a
single scalar parameter with each color value. So there must be an
unambiguous mapping from any point in 2D space to a one-dimensional
For example, with the linear gradients, the mapping involves finding
the nearest point on the line segment defining the gradient. For the
radial gradients, the mapping involves computing the radius for the
So what's the mapping in the "path gradient" you're proposing?
First, is the color along the inner path entirely uniform? If so, then
that would have to be another color specified, (presumably as part of
create_path_gradient). Second, for the outer-path do we simply map the
relative position along the path, (in terms of total length), to our
color-stop line? And then for all other intermediate 2D points we do
what? Do we conceptually connect corresponding relative positions of
the inner path to the outer path?
So that might all be possible. But it does seem like the
implementation could become fairly complex, and it's not obvious to me
how useful this is for general drawing, (other than the case of
attempting to emulate an existing GDI+ primitive).
Personally, I think I'd much rather see a general "mesh gradient" get
added to cairo that would provide support for any possible
user-specified gradient. On top of that, it should then be quite easy
to implement the path gradient you want, (whatever its precise
specification is), and in that case, that implementation could even
live outside of cairo.
As for how to specify the mesh gradient, I know there's stuff in PDF
for this. And it would be worthwhile for someone to investigate to see
if the PDF stuff is the same as the mesh gradient primitive provided
by Adobe Illustrator, for example, (since there we *know* that the
gradient primitive has proven useful for actual artistic creation).
So there are some of my thoughts for anyone that would want to pursue
this kind of thing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071221/f99685d2/attachment.pgp
More information about the cairo