Changing colors with a loop : imagefilledrectangle « Graphics Image « PHP






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);
?>
  
  








Related examples in the same category

1.Drawing a Filled Rectangle with imagefilledrectangle()
2.Creating and Applying Different Shapes and Patterns
3.Draw a rectangle