PHP GD circle


 

PHP GD circle

This example shows how to make circle in php gd.

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

Ads