Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!rutgers!apple!well!ewhac From: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Newsgroups: comp.sys.amiga Subject: Re: Non-distruction graphics Message-ID: <7761@well.UUCP> Date: 26 Nov 88 09:59:21 GMT References: <6287@dayton.UUCP> Reply-To: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Organization: Network 23 (XXIII) Lines: 38 Quote: "I've got this shocking pain right behind the eyes." -- Vila "Have you considered amputation?" -- Avon In article <6287@dayton.UUCP> joe@dayton.UUCP (Joseph P. Larson) writes: > [ ... ] I'm working on >a little draw program. I've implemented the ever-famous rubber-band >line... However, as I move around, I'm destroying what was on >the screen before. [ ... ] > >What I need instead of draw and erase (erase is basically redraw old >line with background color) is draw and recover old. The best method >I have discovered for this would be to write a DrawXOR routine to replace >my use of Draw(). [ ... ] But this sounds rather slow. > Not slow at all; the graphics.library can draw XOR lines for you. This is the incantation: SetDrMd (rastport, COMPLEMENT); Move (rastport, ); Draw (rastport, ); There is a bug with COMPLEMENT as documented. The manual says that the FgPen is XORed into the destination. This is wrong. All bits in the destination pixel are complemented (on a 4 plane display, a pixel that was 1 would turn into 14). However, COMPLEMENT does observe the RastPort.Mask field, so you can stick the value you wish to XOR into the bitmap into there. This capability may be necessary if you wish to XOR in a line of a specific color. If you ever choose to add DPaint-style brush grabbing to your program, you may find the above approach insufficient. I started out with the above approach when I first started on Onion, and later had to dump it when things got a little more sophisticated. However, for your purposes, it should be quite sufficient. _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ Leo L. Schwab -- The Guy in The Cape INET: well!ewhac@ucbvax.Berkeley.EDU \_ -_ Recumbent Bikes: UUCP: pacbell > !{well,unicom}!ewhac O----^o The Only Way To Fly. hplabs / (pronounced "AE-wack") "Work FOR? I don't work FOR anybody! I'm just having fun." -- The Doctor