Mega Code Archive

 
Categories / Php / Graphics
 

Changing colors with a loop

<?php     $image = imagecreate(400,300);     $gold = imagecolorallocate($image, 255, 240, 00);     $white = imagecolorallocate($image, 255, 255, 255);     $color = $white;     for ($i = 400, $j = 300; $i > 0; $i -= 4, $j -= 3) {             if ($color =  = $white) {                     $color = $gold;             } else {                     $color = $white;             }             imagefilledrectangle($image, 400 - $i, 300 - $j, $i, $j, $color);     }     imagepng($image);     imagedestroy($image); ?>