Blogger Information
Blog 4
fans 0
comment 0
visits 3309
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
制作圆饼统计图
薈瞢的博客
Original
1417 people have browsed it

//创建画布,返回一个资源类型的变量$image,并在内存中开辟一个临时区域
$image = imagecreatetruecolor(100, 100);                //创建画布大小为100x100

//设置图像中所需的颜色,相当于在画画时准备的染料盒
$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);          //为图像分配颜色为白色
$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);           //为图像分配颜色为灰色
$darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);       //为图像分配颜色为暗灰色
$navy = imagecolorallocate($image, 0x00, 0x00, 0x80);           //为图像分配颜色为深蓝色
$darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);       //为图像分配颜色为暗深蓝色
$red = imagecolorallocate($image, 0xFF, 0x00, 0x00);           //为图像分配颜色为红色
$darkred = imagecolorallocate($image, 0x90, 0x00, 0x00);       //为图像分配颜色为暗红色

imagefill($image, 0, 0, $white);            //为画布背景填充背景颜色
//动态制作3D效果
for ($i = 60; $i >50; $i--){                //循环10次画出立体效果
   imagefilledarc($image, 50, $i, 100, 50, -160, 40, $darknavy, IMG_ARC_PIE);
   imagefilledarc($image, 50, $i, 100, 50, 40, 75, $darkgray, IMG_ARC_PIE);
   imagefilledarc($image, 50, $i, 100, 50, 75, 200, $darkred, IMG_ARC_PIE);
}

imagefilledarc($image, 50, 50, 100, 50, -160, 40, $navy, IMG_ARC_PIE);      //画一椭圆弧且填充
imagefilledarc($image, 50, 50, 100, 50, 40 , 75, $gray, IMG_ARC_PIE);      //画一椭圆弧且填充
imagefilledarc($image, 50, 50, 100, 50, 75, 200, $red, IMG_ARC_PIE);      //画一椭圆弧且填充

imagestring($image, 1, 15, 55, '34.7%', $white);                //水平地画一行字符串
imagestring($image, 1, 45, 35, '55.5%', $white);                //水平地画一行字符串

//向浏览器中输出一个GIF格式的图片
header('Content-type:image/png');               //使用头函数告诉浏览器以图像方式处理以下输出
imagepng($image);                       //向浏览器输出
imagedestroy($image);                   //销毁图像释放资源

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!