Kareen and Ryan

Ryan's Blog

Dedicated to Kareen. Without you, none of this would be. Life is difficult and complicated, but you inspire me to rise above and reach for dreams.

 

Other Articles

CAKEPHP FX View Helper v01.00

2/22/10

I have been wanting a method to easily create custom font headings on the fly. Using a cakephp helper I can easily accomplish this. Now all I have to do is enter my text with the handy cakephp FX view helper.

Download: http://www.ryanhafer.info/files/downloads/fx.zip

Install:
1 - Just place the extracted fx.php file in your app/views/helpers directory.
2 - create the directory app/fonts and add any .ttf files you want to use.
3 - Add "Fx" to the controller var $helpers array.

text2image (string $text, array $Options=array())

Creates the heading image as .png file and returns an image tag of the text value with options applied. Created images are cached in the /app/webroot/img/fx directory.

Default Options

"height"=>22, The height in pixels of the heading. Should generally be larger than  the font size.
"width"=>160, The width in pixels of the heading.
"font"=>"kremlin.ttf", The font to be used for the heading
"colorHex"=>"", Hex color of font. NOTE: setting Hex will override any RGB color.
"colorRGB"=>"139,35,35", RGB color of font.
"size"=>20, The font size in pixels of the heading.
"angle"=>0, The angle of the text output.
"style"=>'', The styling to be applied to the outputted image tag.
"shadow"=>true, Boolean for creating a 1 pixel drop shadow of the text.

Example:

<h1>
<?php

$fx->text2image("I love Design",array("style"=>"border:0px","font"=>"arialblack.ttf","colorHex"=>"C0C0C0"));

?>
</h1>

Post A Comment

 
 
Switch themes | © 2010 RyanHafer.info. All Rights Reserved
xhtml validated css validated