neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
2 use strict; 3 use GD; 4 5 my $length = 2; #number of repeats 6 my $image = new GD::Image($length*37+1,13); 7 my $white = $image->colorAllocate(200,200,200); 8 #$image->transparent($white); 9 my $yellow = $image->colorAllocate(255,255,0); 10 my $black = $image->colorAllocate(0,0,0); 11 my ($x, @para1, @para2); 12 13 while ($x <= $length-1){ 14 $para1[$x] = new GD::Polygon; 15 $para1[$x]->addPt(0+$x*12,0); 16 $para1[$x]->addPt(12+$x*12,12); 17 $para1[$x]->addPt(24+$x*12,12); 18 $para1[$x]->addPt(12+$x*12,0); 19 20 $para2[$x] = new GD::Polygon; 21 $para2[$x]->addPt(13+$x*12,0); 22 $para2[$x]->addPt(25+$x*12,12); 23 $para2[$x]->addPt(37+$x*12,12); 24 $para2[$x]->addPt(25+$x*12,0); 25 26 $x++; 27 } 28 29 while ($x >= 0){ 30 $image->filledPolygon($para1[$x], $black); 31 $image->filledPolygon($para2[$x], $yellow); 32 33 $x--; 34 } 35 print $image->png();
I'm am receiving this error Can't call method "length" on an undefined value at line 30
Can anyone offer some advice as to the cause?
Neil Watson
watson-wilson.ca
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GD, arrays, and Polygons
by pfaut (Priest) on Mar 23, 2003 at 17:25 UTC | |
by neilwatson (Priest) on Mar 23, 2003 at 17:38 UTC |