| AND OR | string words | *

image editing

|

outlining


Outlining

Outlining text is also fairly simple to do. If you think about it, an outline is just drawing the text left and right, above and below the main text, then drawing the main text over it. This theoretically works with every font because it moves one pixel at a time. To create an outline, you need only know the width of the outline, then write a for loop:


function imagettftextoutline( ) [ line 2 ]



full source of outlining [ line 1 - 17 ] | download outlining

1    <?php
2   function imagettftextoutline (& $im ,$size ,$angle ,$x ,$y ,& $col ,& $outlinecol ,$fontfile ,$text ,$width )
3   {
4       // For every X pixel to the left and the right
5       for ( $xc =$x -abs ($width ); $xc <= $x +abs ($width ); $xc ++)
6       {
7           // For every Y pixel to the top and the bottom
8            for ( $yc =$y -abs ($width ); $yc <= $y +abs ($width ); $yc ++)
9           {
10               // Draw the text in the outline color
11               $text1 imagettftext ($im ,$size ,$angle ,$xc ,$yc ,$outlinecol ,$fontfile ,$text );
12           }
13       }
14       // Draw the main text
15       $text2 imagettftext ($im ,$size ,$angle ,$x ,$y ,$col ,$fontfile ,$text );
16   }
17   ?>



29 hits by 19 users in the last 30 minutes.