$size = 300;
$image = imagecreatetruecolor($size,$size);
//用白色背景,黑色边框画方框
$back = imagecolorallocate($image,255,255,255);
$border = imagecolorallocate($image,0,0,0);
imagefilledrectangle($image,0,0,$size,$size,$back); //画出白色背景
imagerectangle($image,0,0,$size-1,$size-1,$border); //画出黑色边框
$yellow_x = 150;
$yellow_y = 75;
$red_x = 100;
$red_y = 160;
$blue_x = 200;
$blue_y = 160;
$radius = 150;
$yellow = imagecolorallocatealpha($image,255,255,0,75); //此函数将黄色的alpha值调为75,就是透明度
$red = imagecolorallocatealpha($image,255,0,0,75);
$blue = imagecolorallocatealpha($image,0,0,255,75);
//画三个交叠的圆
imagefilledellipse($image,$yellow_x,$yellow_y,$radius,$radius,$yellow); //此函数就是我要在$image上画一个圆心($yellow_x,$yellow_y)半径为$radius/2颜色为$yellow的圆
imagefilledellipse($image,$red_x,$red_y,$radius,$radius,$red);
imagefilledellipse($image,$blue_x,$blue_y,$radius,$radius,$blue);
//输出正确的header
header(“Content-type: image/png”);
//输出结果
imagepng($image);
imagedestroy($image);
转自:http://yq329.blog.163.com/blog/static/117379566201131821330796/