home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!VAXF.COLORADO.EDU!POWERS_W
- X-Envelope-to: CSG-L@vmd.cso.uiuc.edu
- X-VMS-To: @CSG
- MIME-version: 1.0
- Content-transfer-encoding: 7BIT
- Message-ID: <01GNOKS5OTIQ0000J3@VAXF.COLORADO.EDU>
- Newsgroups: bit.listserv.csg-l
- Date: Mon, 17 Aug 1992 08:55:01 -0600
- Sender: "Control Systems Group Network (CSGnet)" <CSG-L@UIUCVMD.BITNET>
- From: "William T. Powers" <POWERS_W%FLC@VAXF.COLORADO.EDU>
- Subject: Erasing circles
- X-To: CSG-L@vmd.cso.uiuc.edu
- Lines: 56
-
- [From Bill Powers (920817.0900)]
-
- Avery Andrews (920816) --
-
- >.. is there any fast & sensible way to erase circles in CGA Hi Res >mode?
-
- No. The method is neither fast nor sensible but it's inevitable. It's the
- method you've been hoping to avoid. You have to erase every pixel by
- changing it back to the background color.
-
- There are two methods in general:
-
- 1. Change color to black (setcolor(BLACK)) and draw the figure in the old
- position, then change color back to white (setcolor(WHITE)) and draw it in
- the new position. This usually means saving the old arguments for each
- instance of a figure, using them with the color set to BLACK to erase all
- the old figures, changing the saved arguments to the new arguments, then
- with the color set to WHITE drawing the figure again.
-
- 2. Change the mode of writing to XOR. This is done with
-
- setwritemode(1). (The normal mode is 0)
-
- In the XOR mode, drawing a figure puts it on the screen, and drawing it
- again in the same place erases it: it toggles on and off. This is nice
- because it doesn't erase intersecting lines -- just reverses the common
- pixels, then on erasure reverses them back.
-
- This is a little trickier because you have to make sure to draw the figure
- before it's erased (it's erased by drawing again to the same place).
- Generally you want to erase then write very quickly to avoid flicker, so
- this means doing a preliminary write of all the figures before entering the
- loop where you erase before writing. It's slightly faster than the first
- method, and as mentioned doesn't destroy overlapping figures.
-
- ---------------------------------------------
-
- XOR will work for circles, rectangles, lines, polygons (drawpoly), and
- ellipses. XOR does not work for putpixel, which takes a color argument as
- its third argument.
-
- NEITHER method works for erasing graphics text! When you write with
- graphics text colored black, nothing happens to whatever was there. Black
- is evidently treated as transparent if the background color is already
- black. I eventually discovered an easy way to do it:
-
- setfillstyle(0,0)
- bar(x,y,x+textwidth("string to be erased"), y+textheight('W'));
-
- This is for top left justified text (settextjustify).
- ---------------------------------------------------------------
-
- Best,
-
-
- Bill P.
-