Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $im=imagecreatetruecolor(800,600);
- $preto=imagecolorallocate($im,0,0,0);
- $a=array(20,10,45,88,75,10,5,20,25,30,40,55);
- $amarelo=imagecolorallocate($im,255,255,0);
- $n=count($a);
- $w=800;
- $h=500;
- $im=imagecreatetruecolor($w,$h);
- $margem=20;
- $wr=($w-2*$margem)/$n;
- $hmax=$h-2*margem;
- $wr80=($wr*8)/10;
- $pi1y=$h-$margem;
- for($i=0;$i<$n;$i++){
- $hi=($hmax*$a[$i])/100;
- $xri=$margem+$i*$wr;
- $pi1x=$xri+$wr/10;
- $pi2x=$pi1x+$wr80;
- $pi2y=$pi1y-$hi;
- imagefilledrectangle($im,$pi1x,$pi1y,$pi2x,$pi2y,$amarelo);
- }
- imagepng($im);
- imagecolordeallocate($im,$preto);
- imagecolordeallocate($im,$amarelo);
- imagedestroy($im);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment