good chemistry is complicated,and a little bit messy -LW PerlMonks

Comment on

 Need Help??

I'm making a julia fractal, i've added the code:

```use GD;
use Math::Complex;
\$img = new GD::Image(400,400);
\$black = \$img->colorAllocate(0,0,0);
\$bl = \$img->colorAllocate(0,0,50);
\$blue = \$img->colorAllocate(0,0,50);
\$c = cplx(-0.70,-0.38);
for(\$x=-200;\$x<=200;\$x++){
for(\$y=-200;\$y<=200;\$y++){
\$z = cplx(\$x/100,\$y/100);
\$teller = 0;
che();
}
}
binmode STDOUT;
print \$img->png;

sub che(){
\$zz = \$z**2 + \$c;
if(abs(\$zz)>2){
if(\$teller<=3){
\$img->setPixel(200+\$x,200+\$y,\$blue);}
else{
\$img->colorDeallocate(\$bl);
\$bl = \$img->colorAllocate(0,0,25*\$teller);
\$img->setPixel(200+\$x,200+\$y,\$bl);}
}
elsif(abs(\$zz<2)){
if(\$teller<8){
\$teller++;
\$z = \$zz;
che();
}
}
}

So after 3 iterations i want the blue component(\$bl) to be 25 * \$teller, so a maximum of 200. But on the picture the blue becomes brighter(must be 100) only once. As if it deallocated once(it was 50 to start with, as you can see at the beginning) and not every time that part of code is executed. So my question is: can you deallocate a color and then allocate it again like in my program. And is this really necessary, because like i said in my original question sometimes you can simply allocate it with different rgb-components without deallocating it first. Thank you.

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
 [pryrt]: discipulus, were you naughty, or stopped believing in the vote fairy? She visited my vote bank last night....

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-06-24 18:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
How many monitors do you use while coding?

Results (562 votes). Check out past polls.