Re: Deleting and erasing lines [message #10482] |
Thu, 11 December 1997 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Andrew A. Baker (andy.baker@bristol.ac.uk) writes:
> I wish to draw a line on top of an image which follows the cursor as
> the mouse is moved and continously updates the line on the screen
> (after, of course, an initial point has been chosen). Drawing the
> line is easy using PLOTS, but how do I erase it and leave the original
> image intact? I don't wish to redraw the entire image, of course, for
> speed reasons.
>
> The best method that I know from other programming endeavours is to use
> XOR (exclusive-OR), so that the colour drawn depends on the colour
> already there and reversal (i.e. erasing the line) is then a trivial
> process. I don't need a line of one colour only, so is there a way of
> doing non-absolute colours? Or is there a better way?
Whoa! Do you believe in coincidences? I was just correcting
typos in this section of my book when your note arrived. :-)
The XOR method is fast and easy. It just doesn't look all
that great normally. The reason is that it will only work
*correctly* if you have 256 contiguous colors in the color
table. (By correctly I mean you would be able to predict
what kind of color the XOR would produce.) Since this rarely
happens, the result is a line that is a kind of mish-mash
of colors. We often think of this as the "opposite" or
"contrasting" color, and don't worry too much about what
that means.
In more professional programs, lines are drawn in a specific
color (usually user-specified to accommodate individual
tastes and vision). This is almost always accomplished by
using the "Device Copy" technique with a pixmap. I need to
get this into my Tips database, but typos beckon. Look up
the COPY keyword to the DEVICE command and the PIXMAP keyword
to the WINDOW command for more information. Let me know if
you need some more help.
Cheers,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|