Rotate letters in a string

ok did a little research (someone pointed if out to me) and found a function that does just what im loioking for,
Changed my for loop to…

	for ( $i = 0; $i < $l; $i++ ) {
		$angle = 10 * $i;
	    //$char = $input[i];
		$char = substr( $input, $i, 1 );
		//write each character to the image
		//imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
		imagettftext($my_img, 20, $angle, $i*25+5, 35, $text_color, 'fonts/KeepCalm-Medium.ttf', $char);
	}

and viola


Thanks for your help though, would you happen to know how to center the text?

You have full control over how the characters are positioned - you just need to use something other than $i*25+5 to position them. As you’ve started with an image of width 200, and you’ll have five characters of (I assume from the above) 25 pixels wide, it should be relatively easy to calculate what x-offset you need to use to place them closer to the centre.

1 Like

I have been trying to do something similar. Would you mind posting your completed full code so I am able to see where I may be going wrong with mine?

Or, you could post your code and people could look at what’s wrong with it.

4 Likes

Actually, I just figured out what I was doing wrong… of all things it wasn’t the logic, it was an error on my part forgetting to close with ‘}’ on one of my functions. Rookie mistake, I know…

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.