Page 1 of 1

How to write the text inside the circle

Posted: Mon Jun 28, 2010 1:20 am
by crajesh
Hi all,

I am new in Php GD. I need to create the circle, inside the circle i need to write the text. how to do this? please help me?

I have create the circle. but i am not able to write the text inside the circle. How to write the text inside the circle.

This is my code

Code: Select all

<?php
create_image();
?>

<table>
<tr>
<td> <?php print "<img src=image.png?".date("U").">"; ?> </td>
<td> <?php print "<img src=image.png?".date("U").">"; ?> </td>
</tr>
</table>

<?php
function  create_image(){
        $im = @imagecreate(600, 200) or die("Cannot Initialize new GD image stream");
        $background_color = imagecolorallocate($im, 255, 255, 255);  
        $red = imagecolorallocate($im, 255, 0, 0);            
        imageellipse($im, 50, 50, 40, 60, $red);
        imageline ($im,65,56,78,78,$blue); 
        imagepng($im,"image.png");
        imagedestroy($im);
}
?>

Thanks
C.Rajesh

Re: How to write the text inside the circle

Posted: Mon Jun 28, 2010 6:12 am
by Benjamin
:arrow: Moved to PHP - Code

Re: How to write the text inside the circle

Posted: Mon Jun 28, 2010 4:16 pm
by McInfo
crajesh wrote:How to write the text inside the circle.
Are you asking how to draw arced text like might be found along the circumference of a coin, or straight text that fits within the area of the circle/ellipse?

PHP's GD library does not have a function to draw arced text (that I know of), but imagettftext() and imagepstext() both have an angle parameter to allow you to draw text at a particular angle. If you read up on calculus, you can write a function to calculate the slope of a line tangent to an ellipse at a particular point and convert the slope to an angle. For circles, a tangent line is perpendicular to a radial line at the same point. Draw letters individually at different points on the ellipse with the appropriate angles. For letters placed within the ellipse (rather than on the outer circumference), base your calculations on a smaller ellipse.

Re: How to write the text inside the circle

Posted: Tue Jun 29, 2010 7:37 am
by pollock
crajesh wrote:Hi all,

I am new in Php GD. I need to create the circle, inside the circle i need to write the text. how to do this? please help me?

I have create the circle. but i am not able to write the text inside the circle. How to write the text inside the circle.

This is my code

Code: Select all

<?php
create_image();
?>

<table>
<tr>
<td> <?php print "<img src=image.png?".date("U").">"; ?> </td>
<td> <?php print "<img src=image.png?".date("U").">"; ?> </td>
</tr>
</table>

<?php
function  create_image(){
        $im = @imagecreate(600, 200) or die("Cannot Initialize new GD image stream");
        $background_color = imagecolorallocate($im, 255, 255, 255);  
        $red = imagecolorallocate($im, 255, 0, 0);            
        imageellipse($im, 50, 50, 40, 60, $red);
        imageline ($im,65,56,78,78,$blue); 
        imagepng($im,"image.png");
        imagedestroy($im);
}
?>

Thanks
C.Rajesh



you will go through this link http://www.hypergurl.com/insidecircle.html here given a php tutorial and explain step by step how to write the text inside the circle.

Warm regards

Re: How to write the text inside the circle

Posted: Tue Jun 29, 2010 12:08 pm
by McInfo
pollock wrote:you will go through this link http://www.hypergurl.com/insidecircle.html here given a php tutorial and explain step by step how to write the text inside the circle.
That tutorial is for PSP (Paint Shop Pro), not PHP.

Re: How to write the text inside the circle

Posted: Thu Nov 11, 2010 9:45 am
by sunny82
Here is the function name "gdImageStringFTCircle" from GD version 2.0.33 that puts text in circular way in image http://www.boutell.com/gd/manual2.0.33. ... ngFTCircle

Thanks
S

Re: How to write the text inside the circle

Posted: Thu Nov 11, 2010 11:14 am
by McInfo
sunny82 wrote:gdImageStringFTCircle
That is a C function that is not implemented in PHP's GD library.