[cairo] XOR drawing and color replacements

Krzysztof Kosiński tweenk.pl at gmail.com
Sat Jun 19 06:31:04 PDT 2010


Hello

I am porting Inkscape to use Cairo drawing everywhere, and I have two questions.

1. We draw some UI elements (notably control points used for path
nodes) using XOR drawing. The definition of this operation for each
color channel is as follows, and alpha of the destination is
unchanged:
#define COMPOSE_X(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar)
(0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) *
((guchar) a) ) )
I found a mail on this list that said that this kind of XOR drawing is
not possible with cairo. If that's indeed the case, can anyone suggest
a different method of drawing the control points in a way that makes
them visible regardless of the color of the underlying drawing?

2. I have an .xpm file that has only 3 color values: 100% transparent,
white, and black. Transparent should be left alone, white should be
replaced by one user-defined color, and black by a different
user-defined color. Can this be done without directly accessing the
surface data?

Regards, Krzysztof


More information about the cairo mailing list