PHP中的绘图技术画比例圆
<?php /* 燕十八 公益PHP培训 课堂地址:YY频道88354001 学习社区:www.zixue.it 原型图测试文件 */ header('content-type:text/html;charset=utf-8'); //POST接受数据 $smaller = $_POST['smaller']+0; $middle = $_POST['middle']+0; $college = $_POST['college']+0; $doctor = $_POST['doctor']+0; $all = $smaller+$middle+$college+$doctor; $one = ($smaller/$all)*360; $two = ($middle/$all)*360; $three = ($college/$all)*360; $four = ($doctor/$all)*360; //画布 $im = imagecreatetruecolor(300,200); //颜料 $color = imagecolorallocate($im,255,255,255); $color1 = imagecolorallocate($im,0,50,40); $color2 = imagecolorallocate($im,0,50,255); $color3 = imagecolorallocate($im,0,250,0); $color4 = imagecolorallocate($im,50,50,30); $color5 = imagecolorallocate($im,255,255,255); $color6 = imagecolorallocate($im,255,255,51); $color7 = imagecolorallocate($im,255,27,255); $color8 = imagecolorallocate($im,25,27,255); $color9 = imagecolorallocate($im,25,27,55); //填充 imagefill($im,0,0,$color); //画图 imagefilledarc($im,102,102,105,105,0,360,$color7,4); imagefilledarc($im,100,100,100,100,0,$one,$color1,0); //画矩形 imagefilledrectangle($im,5,5,30,30,$color1); imagefttext($im,5,0,7,20,$color5,'simhei.ttf','小学生'); imagefilledarc($im,100,100,100,100,$one,$one+$two,$color2,0); //画矩形 imagefilledrectangle($im,35,5,60,30,$color2); imagefttext($im,5,0,37,20,$color5,'simhei.ttf','中学生'); imagefilledarc($im,100,100,100,100,$one+$two,$one+$two+$three,$color3,0); //画矩形 imagefilledrectangle($im,65,5,90,30,$color3); imagefttext($im,5,0,67,20,$color5,'simhei.ttf','大学生'); imagefilledarc($im,100,100,100,100,$one+$two+$three,$one+$two+$three+$four,$color4,0); //画矩形 imagefilledrectangle($im,95,5,120,30,$color4); imagefttext($im,5,0,97,20,$color5,'simhei.ttf','博士生'); header('content-type:image/jpeg'); imagejpeg($im); imagedestroy($im);