折雨的天空

博客介绍:本博客当前共有文章【963】篇,总阅读量【5,103,859】次,第一篇博客发表于【2011年04月06日 10时34分】,距今已【4944】天,感谢您的使用!

您的位置:折雨的天空 >php开发> PHP的GD库生成发光文字

PHP的GD库生成发光文字

用到一个开源库:

https://imagettftextblur.agjgd.org/examples/shadow/


github地址:https://github.com/andrewgjohnson/imagettftextblur


使用示例:


//引入文字发光
include __ROOTDIR__."libs/imagettftextblur/imagettftextblur.php";

// 背景颜色
$text_color = imagecolorallocate($im, 216, 227, 231);
$shadow_color = imagecolorallocate($im, 57, 47, 65);

//定义x轴在字体上增加的大小
            $xleft=6;
            foreach ($str as $k=>$v){

                if ($type=='1'){
                    //imagettftext($im, $size, 0, ($width-mb_strlen($v)*($size+$xleft))/2, ($height-$k*($size+56))/2+(count($str)*10), $text_color, $font, $v);
                    $x_offset=($width-mb_strlen($v)*($size+$xleft))/2;
                    $y_offset=($height-$k*($size+56))/2+(count($str)*10);
                }else{
                    //imagettftext($im, $size, 0, ($width-mb_strlen($v)*($size+$xleft))/2, ($height-$k*($size+36))/2+(count($str)*12), $text_color, $font, $v);
                    $x_offset=($width-mb_strlen($v)*($size+$xleft))/2;
                    $y_offset=($height-$k*($size+36))/2+(count($str)*12);
                }
                // place the shadow onto our image
                imagettftextblur($im, $size, 0, $x_offset + 5, $y_offset + 5, $shadow_color, $font,$v, 10);
                // place the text onto our image
                imagettftextblur($im, $size, 0, $x_offset, $y_offset, $text_color, $font, $v);
            }

生成示例:

20240612-11.png

------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------

转载请注明本文标题和链接:《PHP的GD库生成发光文字

奖励一下

取消

分享不易,烦请有多多打赏,如您也困难,点击右边关闭即可!

扫码支持
扫码打赏,5元,10元,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

-秒后自动关闭,如已打赏,或者不愿打赏,请点击右上角关闭图标。

发表评论

路人甲 表情
看不清楚?点图切换