RaposoTKD

Grafico.php

Mar 18th, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?php
  2.     $im=imagecreatetruecolor(800,600);
  3.     $preto=imagecolorallocate($im,0,0,0);
  4.     $a=array(20,10,45,88,75,10,5,20,25,30,40,55);
  5.     $amarelo=imagecolorallocate($im,255,255,0);
  6.     $n=count($a);
  7.     $w=800;
  8.     $h=500;
  9.     $im=imagecreatetruecolor($w,$h);
  10.     $margem=20;
  11.     $wr=($w-2*$margem)/$n;
  12.     $hmax=$h-2*margem;
  13.     $wr80=($wr*8)/10;
  14.     $pi1y=$h-$margem;
  15.  
  16.     for($i=0;$i<$n;$i++){
  17.         $hi=($hmax*$a[$i])/100;
  18.         $xri=$margem+$i*$wr;
  19.         $pi1x=$xri+$wr/10;
  20.         $pi2x=$pi1x+$wr80;
  21.         $pi2y=$pi1y-$hi;
  22.         imagefilledrectangle($im,$pi1x,$pi1y,$pi2x,$pi2y,$amarelo);
  23.     }
  24.  
  25.     imagepng($im);
  26.     imagecolordeallocate($im,$preto);
  27.     imagecolordeallocate($im,$amarelo);
  28.     imagedestroy($im);
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment