php imagettftext文字颜色,php imagettftext 为文字添加阴影实例

array imagettftext ( resource image, int size, int angle, int x, int y, int color, string fontfile, string text)

imagettftext() 将字符串 text 画到 image 所代表的图像上,从坐标 x,y(左上角为 0, 0)开始,角度为 angle,颜色为 color,使用 fontfile 所指定的 truetype 字体文件。根据 php教程 所使用的 gd 库的不同,如果 fontfile 没有以 '/'开头,则 '.ttf' 将被加到文件名之后并且会搜索库定义字体路径。

*/

//发送头文件

header("content-type: image/png");

//创建图像

$im=imagecreatetruecolor(400, 30);

//定义颜色

$white=imagecolorallocate($im,255,255,255);

$grey=imagecolorallocate($im,128,128,128);

$black=imagecolorallocate($im,0,0,0);

imagefilledrectangle($im, 0, 0, 399, 29, $white);

//定义文本

$text='hello world!';

//这里是字体文件的路径

$font='arial.ttf';

//为文字添加阴影,即为灰色画出文本

imagettftext($im,20,0,13,23,$grey,$font,$text);

//添加文本,即用黑色画出文本

imagettftext($im,20,0,10,20,$black,$font,$text);

//输出png图像

imagepng($im);

imagedestroy($im);

/*

本函数同时需要 gd 库和 freetype 库。

*/

转载随意^^请带上本文地址!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值