Home  >  Article  >  php教程  >  php绘制一个扇形的方法

php绘制一个扇形的方法

WBOY
WBOYOriginal
2016-06-06 20:12:301460browse

这篇文章主要介绍了php绘制一个扇形的方法,涉及GD库中imagefilledarc方法的使用技巧,需要的朋友可以参考下

本文实例讲述了php绘制一个扇形的方法。分享给大家供大家参考。具体如下:

php绘制一个扇形。关于参数说明,除最后一个参数外,其它都与弧线的参数一样,请参考上一篇《php绘制一条弧线的方法》。最后一个参数有四种类型。分别是:

IMG_ARC_PIE、IMG_ARC_CHORD、IMG_ARC_NOFILL和IMG_ARC_EDGED,,具体参数说明见php手册的 imagefilledarc 画扇形函数。

复制代码 代码如下:

//1、创建画布
$im = imagecreatetruecolor(300,200);//新建一个真彩色图像,默认背景是黑色,返回图像标识符。另外还有一个函数 imagecreate 已经不推荐使用。
//2、绘制所需要的图像
$red = imagecolorallocate($im,255,0,0);//创建一个颜色
imagefilledarc($im,100,80,120,90,0,120,$red,IMG_ARC_PIE);//画扇形函数
//3、输出图像
header("content-type: image/png");
imagepng($im);//输出到页面。如果有第二个参数[,$filename],则表示保存图像
//4、销毁图像,释放内存
imagedestroy($im);
?>

希望本文所述对大家的php程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn