phpknight Posted June 27, 2007 Share Posted June 27, 2007 I am writing a program with the GD library and need to arc a font like Photoshop does. I know how to write text, slant a font, etc., but I cannot figure out how to arc it and do other things. Is this possible with PHP? phpknight Quote Link to comment Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 It's certainly possible if you know the trigonometry involved. You'd have to place each character individually. positioned on the curve and at an angle tangential to the curve at that point. Character spacing would also need calculating. Or, as in my sig, do it by displacing pixels to follow (in this case) a sine wave Quote Link to comment Share on other sites More sharing options...
phpknight Posted June 27, 2007 Author Share Posted June 27, 2007 Barand, Thanks. It seems like the latter option--getting it to follow a curve--is more like what I would be looking for since the characters themselves would be curved. Please send any info along to help me get started--possible useful functions, etc. phpknight Quote Link to comment Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 You need a source image containing the text placed using http://www.php.net/imagettftext and you need a destination image. Loop through the rows and columns of the source image to get each individual pixel http://www.php.net/imagecolorat Place them in the destination image off-setting the y position according the curve you want to follow http://www.php.net/imagesetpixel Quote Link to comment Share on other sites More sharing options...
phpknight Posted June 27, 2007 Author Share Posted June 27, 2007 Okay, then every pixel in the same column would be offset by the same amount, right? Basically, I would be adjusting every column by adjusting every pixel in that column. Is this what you mean? phpknight Quote Link to comment Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 Yes. In my sig image I complicated it a little by also applying a linear skew so the x positions are also offset by ever-increasing amounts from bottom to top Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 27, 2007 Share Posted June 27, 2007 Barand Do a quick tutoral for all of us pretty please lol. I love ur tutorals m8. Quote Link to comment Share on other sites More sharing options...
phpknight Posted June 28, 2007 Author Share Posted June 28, 2007 Barand, I was just thinking about that horizontal thing. What is the function for that skew? Or how do you know which way to adjust each pixel horizontally? phpknight Quote Link to comment Share on other sites More sharing options...
Barand Posted June 28, 2007 Share Posted June 28, 2007 Maximum x offset, say -50 px (left skew) Image height 50 px So at bottom of the image the offset is zero, at the top it is -50 px If you are on row Y, the offset is maxOffset * Y / imageHeight Quote Link to comment Share on other sites More sharing options...
Barand Posted June 28, 2007 Share Posted June 28, 2007 Correction maxOffset * (imageHeight - Y) / imageHeight as y increases from top to bottom Quote Link to comment Share on other sites More sharing options...
Barand Posted June 28, 2007 Share Posted June 28, 2007 Do a quick tutoral for all of us pretty please lol. OK, Red, see http://www.phpfreaks.com/forums/index.php/topic,147174.msg630982.html#msg630982 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.