Home Tutorial Php Phpgd PHP GD circle

 
 

PHP GD circle
Posted on: November 4, 2009 at 12:00 AM
This example shows how to make circle in php gd.

<?php

$text = "RoseindiaRoseindiaRoseindiaRoseindiaRoseindia ";

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

}

header("Content-type: image/jpeg");

imagejpeg($image,"",100);

imagedestroy($image);

?>

After running the program you will get the following output

Related Tags for PHP GD circle:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.