Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to clear one color from canvas

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I made a simple maze type program (I used lineto's and moveto's from the canvas application to draw the maze in blue) and then I used a few timer functions to be able to control the direction. However, I need to know how to clear the black trail that the timers leave behind w/o clearing the maze. The only way I can think of doing this is to be able to set all the black to the btnface color on the timers before it draws the next dot, but I don't know how to do this...if anyone could help (need it by tomorrow) it'd be MUCH appreciated!
 
For a start, there's a Pixels[] property off your canvas. You could just loop through that looking for black pixels. Could be slow, though.

A smarter way might be to keep a memory of where you've been but have not yet cleaned up. Say a TList or a TStringList. Every time you move, add a new entry to the tail of the list, and read the entry off the head of the list. Clean up the old trail at the location pointed to by the head of the list, and then draw your new stuff in for your new point. This might flicker a little.

I suggested TStringList above because it's a little easier to work with than TList -- no messy New() and Dispose() for the list items pointed to by the TList nodes; you just slam your data straight into the TStringList elements. Of course, that means your data has to be of type string, so there might be a bit of messy converting back and forth between Integer and string there. -- Doug Burbidge mailto:doug@ultrazone.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top