Usage: GD::Image::colorAllocate(image, r, g, b) at /home/hesco/sb/GD-Graph-Thermometer/lib/GD/Graph/Thermometer.pm line 133.
####
package GD::Graph::Thermometer;
use warnings;
use strict;
use Carp;
use GD;
use GD::Text::Align;
use Data::Dumper;
use constant PI => 3.14;
sub new {
my $self = shift;
my $args = shift;
. . .
my $image = new GD::Image($args->{width},$args->{height});
my $colors = $self->_define_colors($image, {
background_color => $args->{'background_color'},
outline_color => $args->{'outline_color'},
text_color => $args->{'text_color'},
mercury_color => $args->{'mercury_color'}
});
. . .
return;
}
sub _define_colors {
my $self = shift;
my $image = shift;
my $custom_colors = shift;
print STDERR Dumper($self,$image,$custom_colors);
. . .
my $text_color;
if (defined($custom_colors->{text_color})) {
$text_color = $image->colorAllocate($custom_colors->{text_color});
} else {
$text_color = $self->_black($image);
}
. . .
return $colors;
}
####
#!/usr/bin/perl -w
use strict;
use warnings;
use lib qw{/home/hesco/sb/GD-Graph-Thermometer/lib};
use GD::Graph::Thermometer;
my $result = GD::Graph::Thermometer->new({
image_path => '/home/hesco/GD-Thermometer.png',
goal => '80000',
current => '50000',
title => 'Funding the League in 2007 ($)',
width => '100',
height => '200',
# background_color => '',
text_color => [0,0,255],
# outline_color => '',
# mercury_color => ''
});
1;
####
$ ./render_thermometer.pl
$VAR1 = 'GD::Graph::Thermometer';
$VAR2 = bless( do{\(my $o = 137557384)}, 'GD::Image' );
$VAR3 = {
'mercury_color' => undef,
'background_color' => undef,
'outline_color' => undef,
'text_color' => [
0,
0,
255
]
};
Usage: GD::Image::colorAllocate(image, r, g, b) at /home/hesco/sb/GD-Graph-Thermometer/lib/GD/Graph/Thermometer.pm line 133.
####
Not an ARRAY reference at /home/hesco/sb/GD-Graph-Thermometer/lib/GD/Graph/Thermometer.pm line 133.
####
my $text_color;
if (defined($custom_colors->{text_color})) {
$text_color = $image->colorAllocate(
$custom_colors->{text_color}[0],
$custom_colors->{text_color}[1],
$custom_colors->{text_color}[2]
);
} else {
$text_color = $self->_black($image);
}