home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / graphics / 11668 < prev    next >
Encoding:
Internet Message Format  |  1992-11-09  |  2.2 KB

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