[cairo] Subtractive Clipping Again

Carl Worth cworth at cworth.org
Sat Apr 28 22:03:00 PDT 2007


On Sat, 28 Apr 2007 12:09:42 -0700, Travis Griggs wrote:
> Yup, that was it. Has to be part of the same path. It would be handy
> if one could query the path that was used to set the clip. But I
> assume that's lost after the clip.

If you want to be able to set the outer rounded rectangle as the clip,
and then subsequently "subtract" your cheese grater circles, then you
can do that just fine.

The key is that you don't need to have exactly the same rounded
rectangle around the circles when you clip again---any shape that
encompasses the original clip will do. Previously I had suggested
using a rectangle the same size as the surface bounds. But as you
suggest being able to query the clip path, (which, you're correct, is
not available), it occurs to me that just querying the clip extents
should work just fine.

So for your complete example you should be able to do something like
the following:

	my_rounded_rectangle_path (cr);
	cairo_clip (cr);

	...

	cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
	cairo_rectangle (cr, x1, y1, x2 - x1, y2 - y1);
	my_negative_arc_cheese_grater_circles_path (cr);
	cairo_clip (cr);

If you give that a try, let me know if it doesn't work for you.

-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.freedesktop.org/archives/cairo/attachments/20070428/d97ca22b/attachment.pgp


More information about the cairo mailing list