目前共有2篇帖子。 內容轉換:不轉換▼
 
點擊 回復
237 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)
 

本帖信息

點擊數:237 回複數:1
評論數: ?
作者: 巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2015-11-30 22:18
 
©2010-2024 Arslanbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。