Is there a maximum number of points permitted in a single line in Tk::Canvas? If there is, is there some way to change it?
When I try to plot a line with more than 1048572 points, my script exits. The exit occurs after the callback containing the createLine call returns. Sometimes, I get the message
X connection to :2.0 broken (explicit kill or server shutdown).
on exit, sometimes not. It isn't a maximum number of points in the canvas; I can plot many lines of 1048572 points, but no lines of 1048573 points. Note that 1048572 is very close to 1024*1024 (2^10 or 1048576), but I couldn't find either number anywhere in the Perl::Tk source. Here is an example script to show the problem. I am running under Solaris 5.10 on a SPARC Enterprise M5000, displaying on a SunRay 2FS. Perl version is 5.8.8, Perl::Tk is 804.028, all compiled under the Sun Studio 11 compiler, 64 bit.
use Tk; use strict; use warnings; my ($wf_canvas, $wid); my $mw = MainWindow->new; $mw->geometry("600x300+10+10"); my $menubar_frame = $mw->Frame(-relief => 'ridge', -borderwidth => 2) ->pack(-side => 'top', -anchor => 'n', -fill => 'x'); my $plot1_button = $menubar_frame->Button( -command => [\&plotwave1], -text => 'Plot short') ->pack(-side => 'left'); my $plot2_button = $menubar_frame->Button( -command => [\&plotwave2], -text => 'Plot long') ->pack(-side => 'left'); my $exit_button = $menubar_frame->Button( -command => sub {$mw->destroy}, -text => 'Exit') ->pack(-side => 'left'); MainLoop; exit; sub wfplot_canvas() { if (! Exists($wf_canvas)) { $wf_canvas = $mw->Canvas(-background => 'white'); $wf_canvas->pack(-expand => 1, -fill => 'both', -side => 'left'); } } sub plotwave($) { my $len = shift; my $xscale = $mw->width() / $len; my @xy = (); my $i; foreach $i (0 .. ($len - 1)) { push @xy, $i * $xscale, 100 - sin(0.00001 * $i) * 100; } $wid = $wf_canvas->createLine(@xy, -fill => 'black', -joinstyle => ' +bevel'); my @bbox = $wf_canvas->bbox('all'); $wf_canvas->configure(-height => ($bbox[3] - $bbox[1]), -width => ($bbox[2] - $bbox[0])); return; } sub plotwave1() { wfplot_canvas() if ! Exists($wf_canvas); $wf_canvas->delete($wid) if $wid; plotwave(1048572); } sub plotwave2() { wfplot_canvas() if ! Exists($wf_canvas); $wf_canvas->delete($wid) if $wid; plotwave(1048573); }
In reply to Tk::Canvas->createLine max? by stead
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |