Subject: | $canvas->bbox bug? |
Perl version: This is perl, v5.6.1 built for i386-linux
perl-tk version:
# $tk_version and $tk_patchLevel are reset by pTk when a mainwindow
# is created, $VERSION is checked by bootstrap
$Tk::version = '8.0';
$Tk::patchLevel = '8.0';
$Tk::VERSION = '800.024';
The bbox returned on an item in a canvas appears to have it's max coordinates 1 too large.
For instance, if I create a rectangle with coordinates (100, 200, 300, 400), the bounding box
returned by bbox is (99, 199, 302, 402) whereas I would expect (99, 199, 301, 401).
Here's an example program, in case the attachment didn't work.
#!/usr/bin/perl -w
use Tk;
######################################################################
######################################################################
#
$main = MainWindow->new;
$main->title("bbox test");
$canvas = $main->Canvas(
-width => 500,
-height => 500
);
@rect_coords = (100, 200, 300, 400);
$rect_id = $canvas->createRectangle(
@rect_coords,
-fill => "green",
-tags => "test_box"
);
@box = $canvas->bbox($rect_id);
for($i=0; $i<=$#box; $i++) {
printf("rect_coords[%d] = %d\n", $i, $rect_coords[$i]);
}
printf("\n");
for($i=0; $i<=$#box; $i++) {
printf("box[%d] = %d\n", $i, $box[$i]);
}
$canvas->pack();
MainLoop;
#!/usr/bin/perl -w
use Tk;
######################################################################
######################################################################
#
$main = MainWindow->new;
$main->title("bbox test");
$canvas = $main->Canvas(
-width => 500,
-height => 500
);
@rect_coords = (100, 200, 300, 400);
$rect_id = $canvas->createRectangle(
@rect_coords,
-fill => "green",
-tags => "test_box"
);
@box = $canvas->bbox($rect_id);
for($i=0; $i<=$#box; $i++) {
printf("rect_coords[%d] = %d\n", $i, $rect_coords[$i]);
}
printf("\n");
for($i=0; $i<=$#box; $i++) {
printf("box[%d] = %d\n", $i, $box[$i]);
}
$canvas->pack();
MainLoop;
#################################################################