Linux初探欢迎您的投稿,投放方法请点击
这里查看,我们会定期赠送精美小礼品给优秀的投稿作者。海纳百川 取则行远!LinuxGoo欢迎您的到来。
一直想发表点东西。最近刚把php4中的php_gd.dll搞定,就迫不及待的想做点图形程序玩玩。看到有许多php做饼图的例子,看了一下都是2维的,于是就想做个3维的。经过努力p......
$B=($clr) & 0xff; return imagecolorallocate($img,$R,$G,$B); }
?>
-------------------------- | pie3d.php //三维饼图文件 | --------------------------
require("pie3dfun.php");
$a=150;//椭圆长半轴 $b=50;//椭圆段半轴 $v=20;//圆饼高度 $font=5;//字体
$ox=5 $a; $oy=5 $b; $fw=imagefontwidth($font); $fh=imagefontheight($font);
$datLst=array(30,10,20,20,10,20,10,20);//数据 $labLst=array("a1","a2","a3","a4","a5","a6","a7","a8");//标签 $clrLst=array(0x99ff00,0xff6666,0x0099ff,0xff99ff,0xffff99,0x99ffff,0xff3333,0x009999);
$w=10 $a*2; $h=10 $b*2 $v ($fh 2)*count($datLst);
$img=imagecreate($w,$h);
//转RGB为索引色 for($i=0;$i $clrbk=imagecolorallocate($img,0xff,0xff,0xff); $clrt=imagecolorallocate($img,0x00,0x00,0x00); //填充背景色 imagefill($img,0,0,$clrbk); //求和 $tot=0; for($i=0;$i $sd=0; $ed=0; $ly=10 $b*2 $v; for($i=0;$i $sd=$ed; $ed =$datLst[$i]/$tot*360; //画圆饼 chx_sector3d($img,$ox,$oy,$a,$b,$v,$sd,$ed,$clrLst[$i]);//$sd,$ed,$clrLst[$i]); //画标签 imagefilledrectangle($img,5,$ly,5 $fw,$ly $fh,$clrLst[$i]); imagerectangle($img,5,$ly,5 $fw,$ly $fh,$clrt); imagestring($img,$font,5 2*$fw,$ly, $labLst[$i].":".$datLst[$i]."(".(round(10000*($datLst[$i]/$tot))/100)."%)", $clrt); $ly =$fh 2; } //输出图形 header("Content-type:image/gif"); imagegif($img);
?>
2/2 首页 上一页 1 2 |