home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!noc.near.net!gateway!miki!oj
- From: oj@miki.pictel.com (Oliver Jones)
- Subject: Re: Help with GXxor option ?
- Message-ID: <1992Nov21.003435.3363@miki.pictel.com>
- Organization: PictureTel Corporation
- References: <1egjpnINN9c0@news.aero.org>
- Date: Sat, 21 Nov 1992 00:34:35 GMT
- Lines: 35
-
- In article <1egjpnINN9c0@news.aero.org> gurlitz@aero.org (Thomas R. Gurlitz) writes:
-
- >The program (modelled on "helloworld.c") is intended to draw a line,
- >wait a few seconds, then erase the line. At each mouse button press,
- >a slightly different line segment should be drawn, displayed a few
- >seconds, then erased. The print statements tell me when each line is drawn
- >or undrawn.
-
- The trick with XOR drawing is to use the same GC settings to draw and
- undraw the line.
-
- You need to make sure of the following:
-
- (1) the GC function is set to GXxor before the first time you draw
- (it isn't in your example).
-
- (2) the foreground in the XOR-drawing GC is set to
- myforeground ^ mybackground -- the differences in
- bits between your foreground and background pixel values.
- (it wasn't).
-
- (3) the window is initialized so it contains only background
- and foreground bits (it is, automatically, when mapped).
-
-
- What you're doing when xor drawing is toggling the state of
- foreground bits to background and vice versa. That's why drawing
- twice reverses the effect of drawing. Setting the GC foreground
- as shown in (2) allows the drawing operation to toggle the
- bits.
-
- See the example on page 154 in the same book you got your example
- program from.
-
- Oliver Jones
-