[cairo] masking in herds

Travis Griggs tgriggs at cincom.com
Tue Nov 6 09:14:15 PST 2007

On Nov 6, 2007, at 8:41, Carl Worth wrote:

> 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.

Could this include XOR drawing?

What I often find myself wanting is a way to just define a "computed  
paint" for the source. Where I define a function whose input is the  
underlying RGBA value, and maybe the position, and then I can define  
any combinatorial combination I want.

Travis Griggs
Time and Countertops. They both get used up way too fast.

More information about the cairo mailing list