Evanovich has asked for the wisdom of the Perl Monks concerning the following question:
My problem is that when I allocate all these colors (%angles contains about 1000 values) the $im turns a funny color, and I can't print anything. What I'm trying to do is print 1000 of these circles out onto a file and display it. Thanks for any help you can give!my %angles; #I get angles from a file my ($key1, $key2, @colors); my ($i, $j) = 0; my $red_val= 0; my $yellow_val = 90; my $green_val = 180; my $angle; my $im = new GD::Image (150, 1500); foreach $key1 (sort (keys %angles)) { foreach $key2 (sort (keys %{$angles{$key1}})) { $angle = ${$angles{$key1}}{$key2} if ($angle <= $yellow_val) { $colors[$i]->[$j] = $im->colorAllocate(255, 255*(($ang +le-$red_val)/($yellow_val-$red_val)), 0); } else { $colors[$i]->[$j] = $im->colorAllocate(255*(($green_v +al - $angle)/($yellow_val - $red_val)), 255*(1-(1-($angle-$green_val) +/($yellow_val-$green_val)))*.5, 0); } $j++; } $j = 0; $i++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Allocating colors with GD
by leriksen (Curate) on May 19, 2003 at 03:12 UTC | |
by strat (Canon) on May 19, 2003 at 11:12 UTC | |
|
Re: Allocating colors with GD
by Anonymous Monk on May 19, 2003 at 21:44 UTC |