From: drand@spinner.osf.org (Douglas S. Rand)
Subject: Re: Drawing Lines (inverse/xor)
In-Reply-To: singg@alf.uib.no's message of Wed, 21 Apr 93 11:19:19 GMT
Organization: Open Software Foundation
Lines: 47

In article <1993Apr21.111919.5281@alf.uib.no> singg@alf.uib.no (Kurt George Gjerde) writes:

   In article <1993Apr19.191531.15865@news.media.mit.edu>, dyoung@media.mit.edu (David Young) writes:

     :
     :

   |>    XSetFunction( myDisplay, gc, GXxor);
   |>    XSetForeground( myDisplay, gc, drawIndex);
   |> 
   |> Then to draw I do:
   |> 
   |>    XDrawLine( myDisplay, XtWindow( drawingArea1), gc, x1, y1, x2, y2);
   |>    XFlush( myDisplay);
   |> 
   |> And when I'm all done, to return things to normal I do:
   |> 
   |>    XSetFunction( myDisplay, gc, GXcopy);
   |> 
   |> 
   |> What I'd like to happen is for the lines I draw to be the inverse of
   |> whatever I'm drawing over.  Instead what happens is I get white lines.  If
   |> the lines are over a white background - nothing shows up.  If the lines are
   |> over a black area - nothing shows up!  It's very strange.  But the GXxor
   |> function seems right - since if I do a rubber-banding box, it erases and
   |> redraws itself correctly (ie. not disturbing the underlying image).
   |> 
   |> Any suggestions what I'm doing wrong?
   |> 
   |> david


      Try change the GXxor to GXequiv.  I have to do this for programs that
      are to run on NCD terminals (on Sun terminals I have to change it
      back to GXxor)...

There is a small section in the O'Reilly Xlib books that describes
the right thing to do.  The key is to set the plane_mask in the
GC to the OR of the foreground and background pixel values.



--
Douglas S. Rand <drand@osf.org>		OSF/Motif Dev.
Snail:         11 Cambridge Center,  Cambridge,  MA  02142
Disclaimer:    I don't know if OSF agrees with me... let's vote on it.
Amateur Radio: KC1KJ
