您的位置:首页 > 编程语言 > PHP开发

PHP绘制多边形

2016-01-03 16:00 621 查看
效果图如下:1.绘制三角形代码:(1)第一步,创建图形
$image=imagecreate(200,200);//创建背景图形
$background=imagecolorallocate($image,255,255,255);//背景色设为白色
$blue=imagecolorallocate($image,0,0,255);//定义蓝色
(2)第二步,定义坐标数组
$coords=array(100,90,200,90,150,10);
(2)第三步,画出多边形
imagepolygon($image,$coords,3,$blue);//画出多边形header("Content-type:image/gif");imagegif($image);imagedestroy($image);
2.绘制五边行
$image=imagecreate(200,200);//创建背景图形
$background=imagecolorallocate($image,255,255,255);//背景色设为白色
$blue=imagecolorallocate($image,0,0,255);//定义蓝色
$coords=array(100,25,24,80,53,170,147,170,176,80);//定义坐标数组imagepolygon($image,$coords,5,$blue);//画出多边形header("Content-type:image/gif");imagegif($image);imagedestroy($image);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: