目前共有2篇帖子。 字体大小:较小 - 100% (默认)▼  内容转换:台灣正體▼
 
点击 回复
622 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)
 

本帖信息

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