[PHP] GD库(十一)图像填充 imagefill、imagefilledarc 与 imagefilledrectangle() 函数
来源:互联网 发布:动漫 神作 知乎 编辑:程序博客网 时间:2024/06/07 12:54
#[PHP] GD库(十一)图像填充 imagefill、imagefilledarc 与 imagefilledrectangle() 函数
- imagefill() 函数用于图像区域填充。
- imagefilledarc() 函数画一椭圆弧并填充。
- imagefilledrectangle() 函数画一矩形并填充。
- imagefilledpolygon() 函数画一多边形并填充。
- imagefill()
- imagefill() 函数用于区域填充。
语法: bool imagefill( resource image, int x, int y, int color )
x,y 分别为填充的起始 x 坐标和 y 坐标,与 x, y 点颜色相同且相邻的点都会被填充。
例子:
<?phpheader("Content-type: image/png");$im = @imagecreatetruecolor(200, 200);$red = imagecolorallocate($im, 255, 0, 0);//用 $red 颜色填充图像imagefill( $im, 0, 0, $red );imagepng($im);imagedestroy($im);?>
提示:对于用 imagecreate() 建立的图像,第一次调用 imagecolorallocate() 会自动给图像填充背景色。
imagefilledarc()
imagefilledarc() 函数画一椭圆弧并填充。
语法:
bool imagefilledarc( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )
该函数参数用法可参考绘制椭圆弧函数 imagearc() ,只是本函数增加 style 参数表示填充方式。
style 填充方式说明:
例子:
<?phpheader('Content-type: image/png');$im = imagecreatetruecolor(100, 100);$red = imagecolorallocate($im, 255, 0, 0);imagefilledarc($im, 50, 50, 100, 50, 0, 360 , $red, IMG_ARC_PIE);imagepng($im);imagedestroy($im);?>
该函数典型应用之一是画饼状统计图。
imagefilledrectangle()
imagefilledrectangle() 函数画一矩形并填充。
语法: bool imagefilledrectangle( resource image, int x1, int y1, int x2, int y2, int color )
x1,y1为左上角左边,x2,y2为右下角坐标。
例子:
<?phpheader('Content-type: image/png');$im = imagecreatetruecolor(200, 200);$yellow = imagecolorallocate($im, 255, 255, 0);imagefilledrectangle($im, 20, 150, 40, 200, $yellow);imagefilledrectangle($im, 50, 80, 70, 200, $yellow);imagepng($im);imagedestroy($im);?>
该函数典型应用之一是柱状统计图。
imagefilledpolygon()
imagefilledpolygon() 函数画一多边形并填充。
语法: bool imagefilledpolygon( resource image, array points, int num_points, int color )
参数说明:
绘制一个用红色填充的六边形例子:
<?phpheader('Content-type: image/png');$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) );$im = imagecreatetruecolor(200, 200);$red = imagecolorallocate($im, 255, 0, 0);imagefilledpolygon($im, $points, 6, $red);imagepng($im);imagedestroy($im);?>
- [PHP] GD库(十一)图像填充 imagefill、imagefilledarc 与 imagefilledrectangle() 函数
- 10. PHP 图像填充 imagefill、imagefilledarc 与 imagefilledrectangle() 函数
- [PHP] GD库(四):创建图像、销毁图像 imagecreate 与 imagedestroy 函数
- [PHP] GD库(六):输出图像 imagegif 、imagejpeg 与 imagepng 函数
- [PHP] GD库(七):分配、取消图像颜色 imagecolorallocate 与 imagecolordeallocate 函数
- [PHP] GD库(八)拷贝图像 imagecopy 与 imagecopyresized 函数
- php(gd库)输出中文图像的转换函数
- php(gd库)输出中文图像的转换函数
- [PHP] GD库(三):获取图像信息 getimagesize 函数
- [PHP] GD库(五):载入图像 imagecreatefrom_gif_jpeg_png 系列函数
- [PHP] GD库(一):图像处理
- PHP GD库生成图像的几个函数总结
- PHP GD库相关图像生成和处理函数
- php之gd图像库
- PHP的imagefilledarc()函数参数详解
- [PHP] GD库(九)合并图像 imagecopymerge 函数(水印制作实例)
- 【PHP学习】GD库分析(图像生成和处理)
- php编程之gd库图像处理(一)---gd库函数大全手册
- JVM运行时数据区和垃圾回收机制
- 秒杀模块碎碎念笔记(1)-Dao层
- OGNL的对象栈栈map栈详解
- [PHP] GD库(十)绘制线段与圆弧 imageline、imagesetstyle 与 imagearc 函数
- 秒杀模块碎碎念笔记(2)-Service层
- [PHP] GD库(十一)图像填充 imagefill、imagefilledarc 与 imagefilledrectangle() 函数
- Spring 实现AOP的四种方式
- 《零基础入门学习Python》学习过程笔记【012列表的常用函数,逻辑关系,+,*,in,列表推导式】
- Linux中JAVA的安装配置
- java实例对象的创建方式
- 杭电acm1164 分解成质因数
- 几个常用快速无损压缩算法性能比较
- 宜信2017 数据挖掘笔试题(广度优先遍历)
- 201312-1 出现次数最多的数