bueno aca les dejo el codigo para que se guien
Código:
grafi1.php<html> <body> <img src="grafi1.php" height="200" width="200" alt="Sales going down" /> </body> </html>
Código PHP:
<?
if ($t<>0) {
if (substr($t,-1)==chr(176)) {
$deg=$t/2;
$rad=M_PI*$deg/180;
} else {
$rad=$t/2;
$deg=180*$rad/M_PI;
}
} elseif ($r<>0 && $s<>0) {
$rad=$s/(2*$r);
$deg=180*$rad/M_PI;
} elseif ($s<>0 && $a<>0) {
$rad=$s*$s/(4*$a);
$deg=180*$rad/M_PI;
} elseif ($r<>0 && $a<>0) {
$rad=$a/($r*$r);
$deg=180*$rad/M_PI;
} else {
echo "Trouble.<br>\n";
echo "t=$t, r=$r, s=$s, a=$a.";
exit;
}
$im=ImageCreateTrueColor(220,200);
$white=ImageColorAllocate($im,255,255,255);
$red=ImageColorAllocate($im,255,0,0);
$green=ImageColorAllocate($im,0,160,0);
$black=ImageColorAllocate($im,0,0,0);
$blue=ImageColorAllocate($im,0,0,255);
// Draw angle
ImageLine($im,75,100,75+round(71*cos($rad)),100-round(71*sin($rad)),$blue);
ImageLine($im,75,100,75+round(71*cos($rad)),100+round(71*sin($rad)),$blue);
// Draw circle (with arc in red)
Imagearc($im,75,100,140,140,360-$deg,360+$deg,$red);
Imagearc($im,75,100,140,140,$deg,360-$deg,$black);
// Fill in sector
Imagefill($im,100,100,$green);
// Draw small arc to mark angle
imagearc($im,75,100,30,30,360-$deg,360+$deg,$white);
// Add labels
imagestring($im,4,150,100-imagefontheight(4),$s,$red);
if ($deg<90) {
imagestring($im,4,73+round(35*cos($rad))-strlen($r)*imagefontwidth(4),100-round(35*sin($rad))-imagefontheight(4),$r,$blue);
} else {
imagestring($im,4,73+round(35*cos($rad))-strlen($r)*imagefontwidth(4),100-round(35*sin($rad)),$r,$blue);
}
imagestring($im,4,92,100-imagefontheight(4)/2,$t,$white);
imagestring($im,4,150,120,"Area",$green);
imagestring($im,4,150,122+imagefontheight(4),$a,$green);
imagestring($im,3,150+strlen($a)*imagefontwidth(4),122+3*imagefontheight(4)/4,"2",$green);
// Output Image
header("Content-type: image/png");
imagepng($im);
// clean up
ImageDestroy($im);
?>