PHP画简单的图形步骤

<?php
//1.创建一个画布
$image = imagecreatetruecolor(500, 300);
//2.分配颜色,并填充画布
//分配一个绿色,作为画布的颜色
$green = imagecolorallocate($image,22, 153, 0);
//分配一个白色,作为画笔的颜色
$white = imagecolorallocate($image, 255, 255,255);
//使用绿色填充画布
imagefill($image, 0, 0, $green);
//3.在画布中用白色绘制图像
/*
 * 用imageellipse方法画一个(椭)圆
 * 参数:画布,圆心坐标,圆半径,使用的颜色
 */
imageellipse($image, 150,150, 150, 150, $white);

//3.在浏览器输出图像资源
header("Content-type:image/jpeg");
imagejpeg($image);
//4.销毁图像资源
imagedestroy($image);

猜你喜欢

转载自blog.csdn.net/ZhaoXinDa/article/details/82931197