in reply to Many Rectangles in Tk

I had the same problem while drawing the map-overview in my roguelike game. What I did was make a large blank image, the size of the map, and a another image with 1-by-1 boxes containing all the possible values for color.
Then I used the copy facility of the photo widget to copy the right color into the right spot on the map image. So in your algorithm just replace the createRectangle call with a call to Photo->copy. It was a lot faster and less memory intensize than the rectangle method.
I could dig up the code if needed.

-pete
"I am Jack's utter lack of disbelief"

Replies are listed 'Best First'.
Re: Re: Many Rectangles in Tk
by gri6507 (Deacon) on Mar 11, 2002 at 21:07 UTC
    Thank you very much. This sounds much like what I need. The only question is, is it absolutely necessary to have a 1x1 image for each possible color beforehand? The program is not very scaleable this way. Can Tk::Images or Tk::Photos be created on the fly by specifying the colors of the pixels (or pixel as the case may be)?
      I found the answer to this to be "yes". Tk:Photo allows me to put data in one pixel at a time. It is significantly faster, but no as fast as I thought it should be. Regardless, this is not a critical part of my emulation, so this ought to do.