PHP/Graphics Image/imagefilledrectangle

Материал из Web эксперт
Перейти к: навигация, поиск

Changing colors with a loop

   <source lang="html4strict">

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

?>

 </source>
   
  


Creating and Applying Different Shapes and Patterns

   <source lang="html4strict">

<?php

   $animage = imagecreate (500, 500);
   $white = imagecolorallocate ($animage, 255, 255, 255);
   $black = imagecolorallocate ($animage, 0, 0, 0);
   imagefilledrectangle ($animage, 0, 0, 500, 500, $black);
   $blue = imagecolorallocate ($animage, 0, 0, 255);
   $green = imagecolorallocate ($animage, 0, 255, 0);
   $myvalues = array ("1","2","3","4","5","6");
   $barwidth = (int) (500 / ((count ($myvalues) * 2)+ 1));
   $barheightpernum = (int) (500 / 10);
      imagefilledrectangle ($animage, 1, 300,498, $black);
     
   imagepng ($animage);
   header ("Content-type: image/png");
   imagedestroy ($animage);

?>

 </source>
   
  


Draw a rectangle

   <source lang="html4strict">

<?php

   $image = imagecreate(400,300);
   $white = imagecolorallocate($image, 255, 255, 255);
   imagefilledrectangle($image, 10, 10, 390, 290, $white);

?>

 </source>