chakkaln has asked for the wisdom of the Perl Monks concerning the following question:
I am faced with a Problem related perl GD. I am generating random colors and using it to draws lines and polygons in a loop. What I observed was after certain number of cycles, the line color allocated is not changing. I tried to print the output of RGB which appears to be all different. I was wondering whether there is any limit in size in using the colorAllocate method (if so how can I handle the issue)or is there any thing wrong in the way I am implicating it. The following code would reproduce the problem. Thanks for your attention. Please note that I am new to GD. Nagesh
#!/usr/local/bin/perl use GD; $im = new GD::Image(1000,20); $ctr =0; $x=0; $y=10; while ($ctr <1000) { $randomRed=int(rand(256))+0; $randomGreen=int(rand(256))+0; $randomBlue=int(rand(256))+0; $getColor=$im->colorAllocate($randomRed,$randomGreen,$randomBlue); $im->line($x,$y+5,$x,$y-5,$getColor); $x++; $ctr++ } print $im->png;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl GD problem
by ikegami (Patriarch) on Aug 17, 2005 at 14:22 UTC | |
by chakkaln (Sexton) on Aug 17, 2005 at 14:28 UTC | |
by xdg (Monsignor) on Aug 17, 2005 at 14:44 UTC | |
by chakkaln (Sexton) on Aug 17, 2005 at 14:51 UTC | |
by muntfish (Chaplain) on Aug 17, 2005 at 15:35 UTC | |
by radiantmatrix (Parson) on Aug 17, 2005 at 18:59 UTC |