最終的輸出應該是這樣的圖像(HELLO WORLD)繪製文本: PHP GD如何通過線
下面是我在做什麼: -
$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, $x1, $y1, $txtcol, $font, $txt); // Drawing text over line at line's angle
和電流輸出像:
任何人能告訴什麼錯我的代碼?
感謝
'imagettftext'中定義了$ ty嗎? – webnoob 2013-02-15 12:52:19
對不起,不是$ ty其$ y1 @webnoob感謝通知我:) – ROBIN 2013-02-15 13:15:32
我認爲問題是找到線角度。你認爲@webnoob – ROBIN 2013-02-15 13:23:53