lab 9 - create tmap image directly instead of using Tk
The changes were straight forward. The Tk cmd
TkCmd(t, sprint(".fc.c create rectangle %.1f %.1f %.1f %.1f " + " -fill #%s -outline black -width %.2f", r.x, r.y, r.x+r.w, r.y+r.h, dc[depth], 0.5));
rect := Rect((int r.x, int r.y), (int(r.x+r.w), int(r.y+r.h))); img.draw(rect, t.display.color(dc[depth]), nil, (0,0)); img.border(rect, 1, t.display.black, (0,0));
where img is the global Image destination. I then update the image on the canvas
tk->putimage(t, "tmap", img, nil); tk->cmd(t, ".fc.c coords tmap 0 0; update");
It works much faster and uses much less main memory. It still uses a lot of heap memory. Tk is nice but has it's limits. It works well for creating and removing the highlight rectangles. But it isn't appropriate for creating the main image, because I don't want to keep track of every rectangle image, and there can be so many entries. The largest I tried was about 300,000 entries. I'd like to try creating a large image with 1 million entries.
I'm still improving this because I intend to use it as some kind of radar for monitoring file system activity.