例一:输出蓝色背景和交叉白线的图形
<?php $width=35; $height=35; //创建对象 $image=imagecreate($width,$height); //提取颜色 $color_white=imagecolorallocate($image,255,255,255);//白色 $color_blue=imagecolorallocate($image,0,0,108);//蓝色 imagefill($image,0,0,$color_blue); //作图 //线宽 imagesetthickness($image,3); imageline($image,0,0,$width,$height ,$color_white); imageline($image,$width,0,0,$height ,$color_white);
//发送对象至头 header('content-type:image/png'); imagepng($image); /* //发送对象至文件 $filename="ex1.png"; imagepng($image,$filename); */ //销毁对象 imagedestroy($image); ?>
输出图象:
在线演示: http://www.phzzy.org/temp/5do8/ex1.php
例二: 阴阳图
<?php $width=400; $height=400; $image=imagecreatetruecolor($width,$height); //提取颜色 $color_black=imagecolorallocate($image,0,2,0);// $color_white=imagecolorallocate($image,255,255,255);//白色 $color_blue=imagecolorallocate($image,0,0,108);//蓝色 $color_red=imagecolorallocate($image,151,0,4);//红色 $color_my=imagecolorallocate($image,192,192,255);//背景 $color_temp=imagecolorallocate($image,199,199,199);//背景 //作图 imagefill($image,0,0,$color_white);
//第一个是大圆 imagefilledarc ($image,$width/2,$height/2,$height,$height,0,360,$color_blue,IMG_ARC_PIE); //两个小圆 imagefilledellipse ($image,$width/2,$height/4 ,$height/2,$height/2,$color_red); imagefilledellipse ($image,$width/2,$height/4 * 3,$height/2,$height/2,$color_blue); /*imagefilledellipse -- 画一椭圆并填充*/ imagefilledarc ($image,$width/2,$height/2,$height,$height,-90,90,$color_red,IMG_ARC_PIE); imagefilledellipse ($image,$width/2,$height/4 * 3,$height/2,$height/2,$color_blue); //发送对象至头 header('content-type:image/png'); imagepng($image); /* //发送对象至文件 $filename="ex1.png"; imagepng($image,$filename); */ //销毁对象 imagedestroy($image); ?>
演示: http://www.phzzy.org/temp/5do8/ex2.php
例三:3D图像--cool
<?php $width=400; $height=400; $image = imagecreatetruecolor($width, $height); $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0); $darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90); $navy = imagecolorallocate($image, 0x00, 0x00, 0x80); $darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50); $red = imagecolorallocate($image, 0xFF, 0x00, 0x00); $darkred = imagecolorallocate($image, 0x90, 0x00, 0x00); imagefill($image,0,0,$white);
// make the 3D effect for ($i = $height /2 +20; $i > $height /2; $i--) { imagefilledarc($image, $width/2, $i, $width/2, $height /2, 0, 45, $darknavy, IMG_ARC_PIE); imagefilledarc($image, $width/2, $i, $width/2, $height /2, 45, 75 , $darkgray, IMG_ARC_PIE); imagefilledarc($image, $width/2, $i, $width/2, $height /2, 75, 360 , $darkred, IMG_ARC_PIE); }
imagefilledarc($image, $width/2, $height /2, $width/2, $height /2, 0, 45, $navy, IMG_ARC_PIE); imagefilledarc($image, $width/2, $height /2, $width/2, $height /2, 45, 75 , $gray, IMG_ARC_PIE); imagefilledarc($image, $width/2, $height /2, $width/2, $height /2, 75, 360 , $red, IMG_ARC_PIE);
// flush image header('Content-type: image/png'); imagepng($image); imagedestroy($image); /* //发送对象至文件 $filename="ex1.png"; imagepng($image,$filename); */
?>
演示: http://www.phzzy.org/temp/5do8/ex3.php
出处:蓝色理想
责任编辑:moby
上一页 玩转图像函数库—常见图形操作 [1] 下一页 玩转图像函数库—常见图形操作 [3]
◎进入论坛网络编程版块参加讨论
|