Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- help with GD module
March 2, 2009, 12:12 pm
rate this thread
my @data = (
[ 8, 3, 1, 2],
my $chart = GD::Graph::bars->new(700,500);
$chart->set(title => 'Ostrich diet');
my $gd_object = $chart->plot(\@data);
but don't work, only open a cmd windown a nothing else!
how I can create a window with graphics?
Re: help with GD module
You can use Image Magick's display utility, or even easier, put the
output in a Tk window.
Example: (attention: Tk likes it's photo's base64 encoded )
my $main = new MainWindow;
my $photo_obj = $main->Photo(-data => get_graph() );
my $display = $main->Label(-image => $photo_obj,
$main->Button(-text => 'exit',
-command => sub
my $gd = GD::Image->new(400,300);
my $white = $gd->colorAllocate(255, 255, 255);
my $black = $gd->colorAllocate( 0, 0, 0);
my $red = $gd->colorAllocate(255, 0, 0);
my $green = $gd->colorAllocate( 0, 255, 0);
my $blue = $gd->colorAllocate( 0, 0, 255);
my $yellow = $gd->colorAllocate(255, 255, 0);
$gd->filledRectangle(0, 129, 199, 169, $blue);
my $poly = GD::Polygon->new();
$gd->polygon ($poly, $black);
$gd->arc(199, 149, 250, 250, 0, 360, $red);
# Tk likes it's images base64encoded
return encode_base64( $gd->png() );
I'm not really a human, but I play one on earth.
- » list context of cgi param problem in hash initialization
- — Previous thread in » PERL Discussions