加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP生成3D的百分比图形统计成效

发布时间:2023-05-29 12:35:59 所属栏目:PHP教程 来源:
导读:本程序是根据用户提供的数据生成3D效果的百分比图片统计效果,实例代码如下:$image = imagecreatetruecolor(200,200); //创建一张200*200的画布; //创建多种又区分的颜色 $red = imagecolorallocate($image,255,0,0

本程序是根据用户提供的数据生成3D效果的百分比图片统计效果,实例代码如下:

$image = imagecreatetruecolor(200,200);  //创建一张200*200的画布; 

//创建多种又区分的颜色 

$red = imagecolorallocate($image,255,0,0); 

$blue  = imagecolorallocate($image,0,0,255); 

$yellow = imagecolorallocate($image,255,255,0); 

$violet = imagecolorallocate($image,255,0,255); 

$white = imagecolorallocate($image,255,255,255); 

$black = imagecolorallocate($image,0,0,0); 

//使用for循环创建3d效果底层效果 

for($i=120;$i>100;$i--){ 

    imagefilledarc($image,100,$i,200,120,0,30,$red,img_arc_pie);//img_arc_pie注释如下: 

    imagefilledarc($image,100,$i,200,120,30,80,$blue,img_arc_pie); 

    imagefilledarc($image,100,$i,200,120,80,360,$yellow,img_arc_pie); 

//bool imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style ) 

// 

//imagefilledarc() 在 image 所代表的图像中以 cx,cy(图像左上角为 0, 0)画一椭圆弧。如果成功则返回 true,失败则返回 false。w 和 h 分别指定了椭圆的宽和高,s 和 e 参数以角度指定了起始和结束点。style 可以是下列值按位或(or)后的值: 

// 

//img_arc_pie 

// 

//img_arc_chord 

// 

//img_arc_nofill 

// 

//img_arc_edged 

//这个层是最上面一层的效果,这样立体效果就出来了! 

    imagearc($image,100,100,200,120,0,360,$black);//添加一个黑色的边圈,这样3d效果看起来更加明显点 

    imagefilledarc($image,100,100,200,120,0,30,$red,img_arc_pie); 

    imagefilledarc($image,100,100,200,120,30,80,$blue,img_arc_pie); 

    imagefilledarc($image,100,100,200,120,80,360,$yellow,img_arc_pie); 

//添加百分比数据,当然此处必要的时候可以批量的进行一定的运算将输入输入到图片上 

    $str = iconv ("gbk","utf-8","36%");//如果要输入中文需要此转换。example:占用:30%; 

    imagettftext($image,10,360-15,100+70,115,$white,"simhei.ttf",$str); 

//开源代码Cuoxin.com 

imagejpeg($image); 

imagedestroy($image); 

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!