效果图如下:
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);