PHP 图像填充
- imagefill() 用于区域填充
bool imagefill( resource image, int x, int y, int color )
$image 为画布资源,x 和 y 为要填充区域内任意一点,color 为要填充的颜色
<?php
header('Content-type: image/png');
$image=imagecreatetruecolor(200,200);
$wihte=imagecolorallocate($image,255,255,255);
imagefill($image,0,0,$wihte);
imagepng($image);
imagedestroy($image);
- imagefilledarc() 画一个椭圆弧并填充
bool imagefilledarc( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )
cx,cy 为椭圆圆心坐标,w,h 为椭圆的狂傲,s,e 为角度开始和结束,30 度角用 0 表示,color 为填充颜色。style 为填充方式
填充方式 | 说明 |
---|---|
IMG_ARC_PIE | 普通填充,产生圆形边界 |
IMG_ARC_CHORD | 只是用直线连接了起始和结束点,与 IMG_ARC_PIE 方式互斥 |
IMG_ARC_NOFILL | 指明弧或弦只有轮廓,不填充 |
IMG_ARC_EDGED | 指明用直线将起始和结束点与中心点相连 |
<?php
header('Content-type: image/png');
$image=imagecreatetruecolor(200,200);
$wihte=imagecolorallocate($image,255,255,255);
imagefilledarc($image,100,100,200,200,0,360,$wihte,IMG_ARC_PIE);
imagepng($image);
imagedestroy($image);
- imagefilledrectangle() 画一个矩形并填充
bool imagefilledrectangle( resource image, int x1, int y1, int x2, int y2, int color )
image 表示画布资源,x1,y1 是左上角坐标,x2,y2 是右下角坐标
<?php
header('Content-type: image/png');
$image=imagecreatetruecolor(200,200);
$wihte=imagecolorallocate($image,255,255,255);
imagefilledrectangle($image,0,0,200,200,$wihte);
imagepng($image);
imagedestroy($image);
- imagefilledpolygon() 画一个多边形并填充
bool imagefilledpolygon( resource image, array points, int num_points, int color )
image 画布资源,point 点数组,num 定点总数
<?php
header('Content-type: image/png');
$image=imagecreatetruecolor(200,200);
$wihte=imagecolorallocate($image,255,255,255);
$points = array(
50, 50, // Point 1 (x, y)
100, 50, // Point 2 (x, y)
150, 100, // Point 3 (x, y)
150, 150, // Point 4 (x, y)
100, 150, // Point 5 (x, y)
50, 100 // Point 6 (x, y)
);
imagefilledpolygon($image,$points,5,$wihte);
imagepng($image);
imagedestroy($image);
展开阅读全文
版权声明:
本文内容由互联网用户自发贡献,版权归作者所有,本社区不拥有所有权,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:jaagool@sina.cn 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。
本文内容由互联网用户自发贡献,版权归作者所有,本社区不拥有所有权,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:jaagool@sina.cn 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。