[cairo] masking in herds

On Tue, 6 Nov 2007 12:17:44 +0200, Donn wrote:
> How can I wrap Box.draw() so that the circle is cropped by the box.
>> <cairo voodoo mask begin>
> <cairo voodoo use Box.draw()>
> Circle.draw()
> OtherStuff.draw()
> <cairo voodoo mask ends>
...
> After writing that I sort of see the push_group thing in my immediate
> future :)
Yeah, quite likely. Here's one route that might be useful:
cairo_push_group (cr);
draw_mask (cr);
mask = cairo_pop_group (cr);
cairo_push_group (cr);
draw_other_stuff (cr);
cairo_pop_group_to_source (cr);
cairo_mask (cr, mask);
Alternately, if your masking is only something like "restrict to a
circle" you could do something like:
create_circle_path (cr);
cairo_clip (cr);
draw_other_stuff (cr);
But it sounds like what you want is more complicated than a single
path, (you said things about stroke and fill for example).
Finally, note that cairo's current mask operation operates only on the
alpha channel of the mask, and not on the color channels. Some people
have wanted something else, (for example, SVG has an image mask
operation that multiplies the luminance of the color channels with the
alpha channel). It might make sense to add something like that to
cairo, (not to mention XRender-like component-alpha masking), but such
functionality doesn't exist currently.
Keep the good questions coming,
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071106/37067258/attachment.pgp