communication
 databases
 directories
 file handling
 html and code
 image editing
 image listing
 sessions and co
 string handling
 information
 forms
 apple stuff
 image handling
 array handling
 lixlpixel
php - snippets
google search terms detected and highlighted.
remove highlighting | keep highlighting
make snippet in "image editing" - download "outlining"
 search
php - snippets

Valid CSS!

php webring logo
prev next
random list
join the Ring!

image editing - outlining was created/last modified on Mon 06 Oct 2003 7:08 PM

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:

<?php
function imagettftextoutline (& $im ,$size ,$angle ,$x ,$y ,& $col ,& $outlinecol ,$fontfile ,$text ,$width )
{
    
// For every X pixel to the left and the right
    
for ( $xc =$x -abs ($width ); $xc <= $x +abs ($width ); $xc ++)
    {
        
// For every Y pixel to the top and the bottom
          
for ( $yc =$y -abs ($width ); $yc <= $y +abs ($width ); $yc ++)
        {
            
// Draw the text in the outline color
            
$text1 = imagettftext ($im ,$size ,$angle ,$xc ,$yc ,$outlinecol ,$fontfile ,$text );
        }
    }
    
// Draw the main text
    
$text2 = imagettftext ($im ,$size ,$angle ,$x ,$y ,$col ,$fontfile ,$text );
}
?>

learn more about some of the PHP functions used in this snippet: abs, file, for, function, imagettftext, time

view the GNU general license - view the GNU library license - search on PHPsnippets - see your code like this

 a lixlpixel.com site

PHParadise.com - PHP-classes.org - your site on safari