[cairo] xor fill

Fred Kiefer fredkiefer at gmx.de
Thu Jan 22 00:42:46 PST 2009

Travis Griggs wrote:
> On Jan 20, 2009, at 7:18 PM, Dan McMahill wrote:
>> is there a way to do an xor fill with cairo?  I know about  
>> cairo_fill()
>> and cairo_fill_preserve() but can't seem to figure out how to do an  
>> xor
>> fill.
> No, there is not. Having whined about it myself once upon a time, I  
> feel obligated to pass on the news. That said, I've found that Cairo  
> has allowed me to do graphical things in place of xor solutions that I  
> liked way better anyway. In short, it's a bummer, because if you just  
> want to port an older idea of portraying something, you can't, but  
> OTOH, it's cool, because Cairo will force you to do it cooler anyway.
> It would be interesting to hear what you were hoping to use it for, we  
> might suggest something cooler. :)

I know that this offer was not directed at me, still I will jump in and
take it :-)

At GNUstep we use cairo to implement OpenStep/Cocoa drawing style
functions. One of these is NSHighlightRect, described in the
documentation as:

"Highlights the rectangle referred to by aRect. Light gray becomes
white, and white becomes light gray. This function must be called twice,
once to highlight the rectangle and once to unhighlight it; the
rectangle should not be left in its highlighted state. When not drawing
on the screen, the compositing operation is replaced by one that fills
the rectangle with light gray."

When drawing directly with X functions we use XOR to implement this, but
for cairo we haven't come up with a proper replacement. Do you have
anything "cool" to suggest?


More information about the cairo mailing list