我正在尝试创建一个带有圆圈的图像和一些文本,其中文本围绕圆圈内部弯曲。圆是自适应的,我希望它内部的文本是自适应的。
到目前为止,我有以下代码生成一个曲线的文本:
$row1="line1";
$degrees = (130/strlen($row1));
imageellipse ( $im , 250 , 250 , 390 , 390 , $black );
imageellipse ( $im , 250 , 250 , 398 , 398 , $black );
for ($i=0;$i<strlen($row1);$i++)
{
$a = ($degrees*$i)+126-strlen($row1)/3;
$cos = cos(deg2rad($a));
$sin = sin(deg2rad($a));
$x = 0;
$y = 180;
$xt = round($cos*($x) - $sin*($y));
$yt = round($sin*($x) + $cos*($y));
imagettftext($im,14,180-($a),250+$xt,270+$yt,$red,'fonts\times.TTF',$row1[$i]);
}
请告诉我如何使其适应性,以便能够适应生成的椭圆?
答案 0 :(得分:0)
希望这会有所帮助:
$image = imagecreatetruecolor(400,400);
$white = imagecolorallocate($image,255,255,255);
imagefill($image,0,0,$white);
$red = imagecolorallocate($image,255,0,0);
$degrees = (360/strlen($text));
for($i=0;$i<strlen($text);$i++)
{
$a = ($degrees*$i)+180;
$cos = cos(deg2rad($a));
$sin = sin(deg2rad($a));
$x = 0;
$y = 180;
$xt = round($cos*($x) - $sin*($y));
$yt = round($sin*($x) + $cos*($y));
imagettftext($image,20,180-($a),200+$xt,200+$yt,$red,"C:/WINNT/Fonts
arial.ttf",$text[$i]);
}