目前共有2篇帖子。 内容转换:不转换▼
 
点击 回复
261 1
原来PHP GD库中的imagefill函数就相当于“画图”中的喷枪工具
一派护法 十九级
1楼 发表于:2015-11-30 22:17
比如代码:
<?php
header('Content-Type: image/png');
$im = imagecreatetruecolor(500, 500);

$white = imagecolorallocate($im, 0xff, 0xff, 0xff); // #FFFFFF
imagefill($im, 0, 0, $white); // 设置背景颜色

$blue = imagecolorallocate($im, 0x00, 0x00, 0xff); // #0000FF
imageline($im, 40, 20, 390, 450, $blue);
imageline($im, 420, 20, 380, 450, $blue);
imageline($im, 28, 35, 460, 28, $blue);

$green = imagecolorallocate($im, 0xb5, 0xe6, 0x1d); // #B5E61D
imagefill($im, 300, 200, $green);
imagesetpixel($im, 300, 200, $blue);

imagepng($im);
imagedestroy($im);
?>
输出的图像为:

一派护法 十九级
2楼 发表于:2015-11-30 22:18
刚开始,图像中什么都没有,所以执行imagefill($im, 0, 0, $white);自然而然就把整个图像涂成了白色。
后来画了三条直线,再执行imagefill($im, 300, 200, $green);在中间点击喷枪,就把三条直线中间形成的三角形涂成了绿色。
 

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
(快捷键:Ctrl+Enter)
 

本帖信息

点击数:261 回复数:1
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2015-11-30 22:18
 
©2010-2024 Purasbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。