Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I wasn't able to reproduce the problem. Also, the script needed some changes to run under strict.

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?

$canvas->createRectangle( $i * $ps, $j * $ps, $i * $ps + $ps, $j * $ps + $ps, -fill => $c, -outline => $c, -tags => ['bg']); }
The erase routine can be now simplified to
sub erase{ $canvas->delete('bg'); }
No need to store any tags/ids anywhere. That's usually the reason why to use the Canvas.

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');

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: Perl Tk canvases / abuse... by choroba
in thread Perl Tk canvases / abuse... by Montain_Gman

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-09-24 20:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found