[cairo] Re: 2 clipping questions
rael at edge.ping.de
Thu Apr 26 12:56:59 PDT 2007
> 2. Using the winding fill rule (which is also the default):
> cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
> cairo_rectangle (cr, 200, 200, 600, 600);
> cairo_rectangle (cr, 400, 600, -200, 200);
> cairo_clip (cr);
Thank you. That did work as expected. I hope I can have multiple
subtractive rectangles (it looks like it works)!?
> However, your original example talked about doing a "subtractive"
> clip. That suggests to me that you might want to first set the clip to
> the large rectangle, and then later subtract the interior rectangle from
> the clip with a second call to cairo_clip.
No. Subtractive clips in my code work by initially defining a clip
region and then (multiple times) "cutting out" subtractive regions.
For anybody that is interested the API looks like:
void PushClip(size_t x, size_t y, size_t width, size_t height);
void PushClipBegin(size_t x, size_t y, size_t width, size_t height);
void AddClipRegion(size_t x, size_t y, size_t width, size_t height);
void SubClipRegion(size_t x, size_t y, size_t width, size_t height);
So this exactly matches your example :-)
> But, yes, if you want cairo's clipping, then use cairo's call. In
> fact, I think it would be a bug if any of cairo's internal state,
> (such as clipping), leaked out and had any effect on system-specific
> drawing you did external to cairo but to the same surfaces.
Using surfaces instead of directly working with XCopyArea did indeed
honored my clipping regions. So a thanks for this one, too :-)
More information about the cairo