home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!crcnis1.unl.edu!cse.unl.edu!bvh
- From: bvh@cse.unl.edu (Obi-Wan)
- Newsgroups: comp.graphics
- Subject: Re: Drawing in the background.
- Date: 10 Nov 1992 02:28:03 GMT
- Organization: MicroImages, Inc.
- Lines: 38
- Distribution: world
- Message-ID: <1dn6njINNmt7@crcnis1.unl.edu>
- References: <BxF4t6.AuF@CAM.ORG>
- NNTP-Posting-Host: cse.unl.edu
-
- In article <BxF4t6.AuF@CAM.ORG>, gelinas@CAM.ORG (Daniel Gelinas) writes:
- > The goal of my program( in C) is to draw
- > 4 laser beams(one from each corner of the screen) shooting out and
- > spelling a word. My only problem is when I try to do this normally
- > I have to use 1 function to draw a line in green, and then I use the
- > same function to draw another line in black. This way the laser beam
- > s can move around. That's all fine and dandy but it won't work with
- > 4 laser beams because when I write over them in black it also writes
- > of everything else on the screen.
-
- Dan,
-
- I'm assuming you have the ability to draw by XORing the current screen
- pixels with another value. Xor has the nifty property that when you
- xor A and B to get C, if you then xor B and C you get A again. Many
- programs don't actually overwrite the current screen values, they just
- xor them with some value to draw the line, then xor them again with
- the same value to get the previous pixel value back again.
-
- To draw in a specific color, you first xor your expected background color
- with the color you want to draw with. The resulting pixel value is the
- value you should xor with the background in order to produce your drawing
- color.
-
- Whenever 2 lines that are "drawn" in different colors cross, the resulting
- color might be kind of strange, but you can be assured that erasing one
- of the lines will leave behind the correct color.
-
- Sorry if this doesn't sound too clear, let me know. It really doesn make
- sense when explained well!
-
- -- Obi-Wan
-
- --
- |\_/| AACK! || Genius may have its || "Obi-Wan" (Ben Hollingsworth)
- \'o.0'/ || limitations, but || MicroImages, Inc. Lincoln, Nebraska
- =(___)= || stupidity is not thus || University of Nebraska - Lincoln
- U PTHAT! || handicapped. || email: bvh@cse.unl.edu
-