glan: imagecolorallocate: klappt nur einmal

Hallo,
ich will mit PHP mehrere Farben mittels imagesetpixel zufällig in eine Grafik einfügen...

Der Code:

  
<?php  
  
header('Content-Type: image/gif');  
  
$bild = imagecreate(100, 100);  
  
// Generiert 20 zufällig aussehende Zufallspixel:  
for($h = 0; $h != 20; ++$h)  
 {  
 $farbe = imagecolorallocate($bild, rand(0, 255), rand(0, 255), rand(0, 255));  
 imagesetpixel($bild, rand(0, 99), rand(0, 99), $farbe);  
 }  
  
// Der folgende Block funzt einfach nimmer:  
for($h = 0, $r = 0, $g = 0, $b = 0; $h != 100; ++$h, ++$r, ++$g, ++$b)  
 {  
 $farbe2 = imagecolorallocate($bild, $r, $g, $b);  
 imagesetpixel($bild, rand(0, 99), rand(0, 99), $farbe2);  
 }  
  
imagegif($bild);  
imagedestroy($bild);  
?>  

Warum funktionier das in der 2. For-Schleife nimmer? Ideen?

Danke im Vorraus... :D

MfG

--
How long? Not long! 'Cause what you reap, is what you sow!!!
SELF forever
[Mein Selfcode: ie:% br:< fl:( va:) ls:< fo:} rl:( n4:~ de:> ss:} ch:| js:| mo:| sh:( zu:{](http://selfspezial.atomic-eggs.com/scode/selfcode.php?decodieren=ie:% br:< fl:( va:) ls:< fo:} rl:( n4:~ de:> ss:} ch:| js:| mo:| sh:( zu:{)
Neuer Selfcode encoder?
  1. Moin!

    // Der folgende Block funzt einfach nimmer:
    for($h = 0, $r = 0, $g = 0, $b = 0; $h != 100; ++$h, ++$r, ++$g, ++$b)
    {
    $farbe2 = imagecolorallocate($bild, $r, $g, $b);
    imagesetpixel($bild, rand(0, 99), rand(0, 99), $farbe2);
    }

    Das liegt aber viel eher an der falschen for-Syntax, als am imagecolorallocate.

    Warum funktionier das in der 2. For-Schleife nimmer? Ideen?

    Mach die for-Schleife mal "vorschriftsgemäß". Das meiste dort brauchst du nicht IM for-Statement, sondern dahinter.

    - Sven Rautenberg

    --
    "Love your nation - respect the others."