note 36254 added to function.imagettftext
| From: | marius at trodat dot ro | Date: | Thu, 02 Oct 2003 13:43:25 +0000 |
| Subject: | note 36254 added to function.imagettftext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57609@lists.php.net to get a copy of this message | ||
Hello!
Here is how u can put a text around a circle (i use it to create on line stamps). I have no remarks,
sorry. U figure it out. Its so weird even i cant understand much now :))
<?php
header('Content-type: image/png');
$imp = imagecreatefromgif('cerc.gif');
$dim=getimagesize('cerc.gif');
$lung=$dim[0];
$lat=$dim[1];
$im=imagecreatetruecolor($lung,$lat);
imagecopyresampled ($im,$imp,0,0,0,0,$lung,$lat,$lung,$lat);
$bg = imagecolorallocate($im, 200, 200, 200);
$black = imagecolorallocate($im, 0, 0, 0);
$red = imagecolorallocate($im,255,0,0);
$alb=imagecolorallocate($im,255,255,255);
$i=0;
$text='Societatea Comerciala';
$total=strlen($text);
$puncte=16;
$inaltmax=0;
$unghirefer=0;
while($i<$total):
$litera=substr($text,$i,1);
$iau=ImageTTFText($im,$puncte,0,0,$lat,$alb, "serif.ttf",$litera);
$lungime[$i]=($iau[2]-$iau[0]);
$inalt[$i]=($iau[5]-$iau[3]);
if ($inaltmax > $inalt[$i]) {
$inaltmax=$inalt[$i];
}
$unghi[$i]=rad2deg(atan($lungime[$i]/(($lung/2)
+$inaltmax+2-($puncte/2.2))));
$unghirefer=$unghirefer+$unghi[$i];
$i++;
endwhile;
$i=0;
$unghitot=100-$unghirefer/2;
while ($i<$total):
$bc=$lung/2-(sin(deg2rad($unghitot))*
(($lung/2+$inaltmax-($puncte/2.2))))+
(sin(deg2rad(90-$unghitot))*(($lungime[$i])));
$ab=$lung/2-(sin(deg2rad(90-$unghitot))*
(($lung/2+$inaltmax-($puncte/2.2))))-
(sin(deg2rad($unghitot))*(($lungime[$i])));
$litera=substr($text,$i,1);
ImageTTFText($im,$puncte,90-$unghitot,$ab,$bc,$black, "serif.ttf",$litera);
$i++;
$unghitot=$unghitot+$unghi[$i];
endwhile;
imagepng($im);
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagettftext.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36254
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36254&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36254&report=yes