home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / bit / listserv / csgl / 711 < prev    next >
Encoding:
Text File  |  1992-08-17  |  2.8 KB  |  72 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!VAXF.COLORADO.EDU!POWERS_W
  3. X-Envelope-to: CSG-L@vmd.cso.uiuc.edu
  4. X-VMS-To: @CSG
  5. MIME-version: 1.0
  6. Content-transfer-encoding: 7BIT
  7. Message-ID: <01GNOKS5OTIQ0000J3@VAXF.COLORADO.EDU>
  8. Newsgroups: bit.listserv.csg-l
  9. Date:         Mon, 17 Aug 1992 08:55:01 -0600
  10. Sender:       "Control Systems Group Network (CSGnet)" <CSG-L@UIUCVMD.BITNET>
  11. From:         "William T. Powers" <POWERS_W%FLC@VAXF.COLORADO.EDU>
  12. Subject:      Erasing circles
  13. X-To:         CSG-L@vmd.cso.uiuc.edu
  14. Lines: 56
  15.  
  16. [From Bill Powers (920817.0900)]
  17.  
  18. Avery Andrews (920816) --
  19.  
  20. >.. is there any fast & sensible way to erase circles in CGA Hi Res >mode?
  21.  
  22. No. The method is neither fast nor sensible but it's inevitable. It's the
  23. method you've been hoping to avoid. You have to erase every pixel by
  24. changing it back to the background color.
  25.  
  26. There are two methods in general:
  27.  
  28. 1. Change color to black (setcolor(BLACK)) and draw the figure in the old
  29. position, then change color back to white (setcolor(WHITE)) and draw it in
  30. the new position. This usually means saving the old arguments for each
  31. instance of a figure, using them with the color set to BLACK to erase all
  32. the old figures, changing the saved arguments to the new arguments, then
  33. with the color set to WHITE drawing the figure again.
  34.  
  35. 2. Change the mode of writing to XOR. This is done with
  36.  
  37.    setwritemode(1).  (The normal mode is 0)
  38.  
  39. In the XOR mode, drawing a figure puts it on the screen, and drawing it
  40. again in the same place erases it: it toggles on and off. This is nice
  41. because it doesn't erase intersecting lines -- just reverses the common
  42. pixels, then on erasure reverses them back.
  43.  
  44. This is a little trickier because you have to make sure to draw the figure
  45. before it's erased (it's erased by drawing again to the same place).
  46. Generally you want to erase then write very quickly to avoid flicker, so
  47. this means doing a preliminary write of all the figures before entering the
  48. loop where you erase before writing. It's slightly faster than the first
  49. method, and as mentioned doesn't destroy overlapping figures.
  50.  
  51. ---------------------------------------------
  52.  
  53. XOR will work for circles, rectangles, lines, polygons (drawpoly), and
  54. ellipses. XOR does not work for putpixel, which takes a color argument as
  55. its third argument.
  56.  
  57. NEITHER method works for erasing graphics text! When you write with
  58. graphics text colored black, nothing happens to whatever was there. Black
  59. is evidently treated as transparent if the background color is already
  60. black. I eventually discovered an easy way to do it:
  61.  
  62. setfillstyle(0,0)
  63. bar(x,y,x+textwidth("string to be erased"), y+textheight('W'));
  64.  
  65. This is for top left justified text (settextjustify).
  66. ---------------------------------------------------------------
  67.  
  68. Best,
  69.  
  70.  
  71. Bill P.
  72.