最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php imagettftext 为文字添加阴影实例
时间:2022-06-24 20:11:28 编辑:袖梨 来源:一聚教程网
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 库。
*/
相关文章
- boss智能门锁如何设置密码 04-29
- 王者荣耀世界橘右京厉害吗 04-29
- 《青云劫攻略天赋技能,成就无敌仙侠》(解锁潜能,掌握绝学,成就仙侠传奇) 04-29
- 桃源深处有人家藏经室悟证一至七日通关答案 04-29
- 怎么击败《Saros》中的“破碎崛起”先知 Boss 04-29
- 宫小攻略技能推荐2023(玩转宫小,轻松游戏攻略指南) 04-29