[cairo] Help: Question on Cairo::OPERATOR_XOR of set_operator?

Will lisb at cs.man.ac.uk
Wed Oct 8 09:14:13 PDT 2008


Hi, Travis:

Thanks a lot for the reply.

If use alpha channel and color channel (set_source_rgba) together, can
we manage to draw with effect of RGB xor mode?

Thanks again.



On Wed, 2008-10-08 at 08:16 -0700, Travis Griggs wrote:
> On Oct 8, 2008, at 6:06 AM, Will wrote:
> 
> > Hi,
> >
> >        I am a new user of cairo and I am wondering how to use the XOR
> >        mode.
> >
> >        In computer graphics, the screen can restore original color if
> >        we draw
> >        the same operation 2 times in XOR mode. I understand that cairo
> >        supports
> >        the function. Intuitively, I wrote the following codes for
> >        testing XOR
> >        mode use:
> >
> >                cr->set_line_width(1.0);
> >                cr->set_source_rgb(0.0, 0.8, 0.0);
> >                cr->move_to(0,0);
> >                cr->line_to(50,50);
> >
> >                cr->set_operator(Cairo::OPERATOR_XOR);
> >                cr->stroke_preserve();
> >                cr->stroke();
> >
> >        However, the original color is not restored. I tried several
> >        other ways
> >        but there is no way out.
> >
> >        Can any one give me some hints?
> 
> 
> Will, the operator applies to the alpha channel, not the rgb channels.  
> I was surprised by this too. IIRC, the operator modes were basically  
> lifted from one of the other specs (PDF maybe?). And someone once  
> explained to me why an RGB xor mode would be difficult. IIRC, it was  
> basically that not all backends have a byte based color spec on the  
> backend. E.g. if the model's uses color descriptions 0.0 - 1.0 (rather  
> than 0 - 255), what does an xor mean? That all said... I still wish  
> there was an XOR RGB way to draw to screens and the like.
> 
> --
> Travis Griggs
> Objologist
> If you can't say "Did it First!", you'd better be able to say "Did it  
> Better!"
> 
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo



More information about the cairo mailing list