in reply to Perl Tk canvases / abuse...
The word "tag" has a special meaning in the Tk domain. You aren't storing any tags in the @TAGS array, you're storing ids of the rectangles.
What about using a single tag for the background?
The erase routine can be now simplified to$canvas->createRectangle( $i * $ps, $j * $ps, $i * $ps + $ps, $j * $ps + $ps, -fill => $c, -outline => $c, -tags => ['bg']); }
No need to store any tags/ids anywhere. That's usually the reason why to use the Canvas.sub erase{ $canvas->delete('bg'); }
Update: I would also use tags for the lines, so you can easily raise them above the new background.
$canvas->createLine($start_x, $start_y, $x1, $y1, -width => 2, -fill => 'white', -tags => ['fg']); # ... # and after drawing the new background: $canvas->raise('fg', 'bg');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Tk canvases / abuse...
by Montain_Gman (Initiate) on May 12, 2021 at 12:05 UTC |