home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / windows / x / 19421 < prev    next >
Encoding:
Text File  |  1992-11-20  |  1.6 KB  |  46 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!noc.near.net!gateway!miki!oj
  3. From: oj@miki.pictel.com (Oliver Jones)
  4. Subject: Re: Help with GXxor option ?
  5. Message-ID: <1992Nov21.003435.3363@miki.pictel.com>
  6. Organization: PictureTel Corporation
  7. References: <1egjpnINN9c0@news.aero.org>
  8. Date: Sat, 21 Nov 1992 00:34:35 GMT
  9. Lines: 35
  10.  
  11. In article <1egjpnINN9c0@news.aero.org> gurlitz@aero.org (Thomas R. Gurlitz) writes:
  12.  
  13. >The program (modelled on "helloworld.c") is intended to draw a line,
  14. >wait a few seconds, then erase the line. At each mouse button press,
  15. >a slightly different line segment should be drawn, displayed a few
  16. >seconds, then erased. The print statements tell me when each line is drawn
  17. >or undrawn.
  18.  
  19. The trick with XOR drawing is to use the same GC settings to draw and
  20. undraw the line.
  21.  
  22. You need to make sure of the following:
  23.  
  24. (1) the GC function is set to GXxor before the first time you draw
  25.     (it isn't in your example).
  26.  
  27. (2) the foreground in the XOR-drawing GC is set to 
  28.     myforeground ^ mybackground -- the differences in
  29.     bits between your foreground and background pixel values.
  30.     (it wasn't).
  31.  
  32. (3) the window is initialized so it contains only background
  33.     and foreground bits (it is, automatically, when mapped).
  34.  
  35.  
  36. What you're doing when xor drawing is toggling the state of
  37. foreground bits to background and vice versa.  That's why drawing
  38. twice reverses the effect of drawing.  Setting the GC foreground
  39. as shown in (2) allows the drawing operation to toggle the
  40. bits.  
  41.  
  42. See the example on page 154 in the same book you got your example
  43. program from.
  44.  
  45. Oliver Jones
  46.