header('content-type:image/gif');
ob_clean();
//创建一个画布
//$canvas = imagecreatetruecolor(500, 500);
$canvas = imagecreate(500, 500);
$background = imagecolorallocate($canvas,255,200,255);// 改变背景色
//蓝色的笔
$blue = imagecolorallocate($canvas, 0, 0, 255);
//白的的笔
$white = imagecolorallocate($canvas,255,255,255);
//黑色的笔
$black = imagecolorallocate($canvas,0,0,0);
//红色的笔
$red = imagecolorallocate($canvas,255,0,0);
//画头,画一个填充颜色是蓝色的圆。
imagefilledellipse($canvas, 150, 150, 130, 105, $blue);
//画脸,画一个填充颜色是白色的圆。但是圆的原点比头的原点要往下一点。
imagefilledellipse($canvas, 150, 160, 110, 90, $white);
//画两个眼睛
imageellipse($canvas, 140, 130, 20, 30, $black);
imageellipse($canvas, 160, 130, 20, 30, $black);
//画两个眼珠
imagefilledellipse($canvas, 140, 130, 5, 5, $black);
imagefilledellipse($canvas, 160, 130, 5, 5, $black);
//画鼻子
imagefilledellipse($canvas, 150, 150, 10, 10, $red);
//画鼻子下面的一条线
imageline($canvas,150,155,150,165,$black);
//画嘴
imagefilledarc($canvas, 150,165, 75, 60, 0, 180, $red,IMG_ARC_PIE);
//画嘴的两个角
imagearc($canvas, 114,156, 20, 20, 90, 270, $black);
imageline($canvas,114,165,187,165,$black);
imagearc($canvas, 187,156, 20, 20, 270, 90, $black);
//把嘴巴画成黑色
imagearc($canvas, 150,165, 75, 60, 0, 180, $black);
header("content-type:image/png");
imagepng($canvas);
imagedestroy($canvas);
网友评论