首页> 基础笔记 >PHP基础学习 >GD库图像处理 GD库图像处理
使用PHP的GD库绘制圆弧
作者:小萝卜 2019-08-23 【 PHP GD库 】 浏览 1135
简介使用PHP的GD库绘制圆弧
<?php
//使用PHP的GD库绘制圆弧
//1. 创建一个画布,准备颜色
$im = imagecreatetruecolor(400,400); //创建一个基于真彩的画布
$bg = imagecolorallocate($im,220,220,220); //灰色
$c1 = imagecolorallocate($im,0,0,255); //篮色
$c2 = imagecolorallocate($im,106,23,106);
$c3 = imagecolorallocate($im,18,88,18);
$c4 = imagecolorallocate($im,109,20,34);
$c5 = imagecolorallocate($im,20,61,71);
//2. 开始绘画
imagefill($im,0,0,$bg);
//imagearc($im,100,100,180,90,270,90,$blue);
for($i=0;$i<30;$i++){
imagefilledarc($im,100,100-$i,180,90,0,60,$c1,IMG_ARC_PIE);
imagefilledarc($im,100,100-$i,180,90,60,90,$c2,IMG_ARC_PIE);
imagefilledarc($im,100,100-$i,180,90,90,160,$c3,IMG_ARC_PIE);
imagefilledarc($im,100,100-$i,180,90,160,280,$c4,IMG_ARC_PIE);
imagefilledarc($im,100,100-$i,180,90,280,360,$c5,IMG_ARC_PIE);
}
//3. 输出图像
header("Content-Type:image/png");
imagepng($im);
//4. 释放资源
imagedestroy($im);
很赞哦! (0)
上一篇:使用PHP的GD库绘制字串
下一篇:使用PHP的GD库绘制正圆/椭圆