加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP GD如何通过一行绘制文本

发布时间:2020-12-13 17:57:14 所属栏目:PHP教程 来源:网络整理
导读:最终输出应该像图像(HELLO WORLD): 这是我在做什么: – $im = imagecreate(400,400); $txtcol = imagecolorallocate($im,0xFF,0x00,0x00);$size = 20;$txt = 'DUMMY TEXT';$font = './font/Capriola-Regular.ttf';/*two points for base line*/$x1 = 50; $
最终输出应该像图像(HELLO WORLD):

这是我在做什么: –

$im = imagecreate(400,400); 

$txtcol = imagecolorallocate($im,0xFF,0x00,0x00);

$size = 20;

$txt = 'DUMMY TEXT';

$font = './font/Capriola-Regular.ttf';

/*two points for base line*/

$x1 = 50; $x2 = 300; 

$y1 = 150; $y2 = 170;

/*bof finding line angle*/

$delta_x = $x2-$x1;

$delta_y = $y2-$y1;

$texangle = (rad2deg(atan2($delta_y,$delta_x)) * 180 / M_PI)-360;

/*eof finding the line angle*/


imageline($im,$x1,$y1,$x2,$y2,$txtcol); //Drawing line

imagettftext($im,$size,$texangle,$txtcol,$font,$txt); // Drawing text over line at line's angle

目前的输出如下:

任何人都可以告诉我的代码有什么问题吗?

谢谢

好的,一直在玩.尝试更换:
$texangle = (rad2deg(atan2($delta_y,$delta_x)) * 180 / M_PI)-360;

附:

$texangle = (atan2($delta_y,$delta_x) * -180 / M_PI)-360;

输出您的值:

输出与其他值:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读