2012-11-07 3 views
4

원 안에 이미지가있는 원을 그려서 이미지를 만들려고합니다. 원은 적응 적이며 내부의 텍스트를 적응시켜야합니다.PHP에서 원 안에 곡선이되는 적응 형 텍스트를 생성하는 방법은 무엇입니까?

지금까지 내가 가지고 텍스트를 생성하는 다음 코드가 곡선 :

$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

희망이 도움이 :

 $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]); 
     } 
+0

그것이 원의 크기에 따라 적응 하는가? 귀하의 코드가 더 많은 것을 추가한다고 생각하지 않습니다 ... –

관련 문제