image editing
|textures
Textures
Textures are one of the hardest text effects possible. This is due to the fact that you need to know how to use a mask to create the texture.
full source of textures [ line 1 - 25 ] | download textures
| 1 | <?php |
| 2 | function imagettftexttexture (& $im ,& $textureim ,$size ,$angle ,$x ,$y ,$fontfile ,$text ) |
| 3 | { |
| 4 | $width = imagesx ($im ); // Get the width of the image |
| 5 | $height = imagesy ($im ); // Get the height of the image |
| 6 | $buffer = imagecreate ($width ,$height ); // Create the buffer image |
| 7 | $tile_w = imagesx ($textureim ); // Get the width of the texture image |
| 8 | $tile_h = imagesy ($textureim ); // Get the height of the texture image |
| 9 | $fits_x = (int)( $im_w /$tile_w ); // Find out how many times it fits horizontally |
| 10 | $fits_y = (int)( $im_h /$tile_h ); // Find out how many times it fits vertically |
| 11 | for ( $i =0;$i <= $fits_x ;$i ++) { // Loop through every time (and another, for extra space) it fits horizontally |
| 12 | $x = (int)( $tile_w *$i ); // Change the X location based on where in the loop it is |
| 13 | for ( $i2 =0;$i2 <= $fits_y ;$i2 ++) { // Loop through every time it fits vertically |
| 14 | $y = (int)( $tile_h *$i2 ); // Change the Y location |
| 15 | $copy = imagecopy ($im ,$textureim ,$x ,$y ,0,0,$tile_w ,$tile_h ); // Copy the image to the X,Y location |
| 16 | } |
| 17 | } |
| 18 | $pink = imagecolorclosest ($im ,255 ,0,255 ); // Create magic pink, a color commonly used for masks |
| 19 | $trans = imagecolortransparent ($im ,$pink ); // Make magic pink the transparent color |
| 20 | imagettftext ($im ,$size ,$angle ,$x ,$y ,- $pink ,$fontfile ,$text ); // Draw text over magic pink without aliasing |
| 21 | imagecopy ($buffer ,$im ,0,0,0,0,$width ,$height ); // Copy the main image onto the buffer |
| 22 | imagecopy ($im ,$buffer ,0,0,0,0,$width ,$height ); // Copy the buffer back onto the main image |
| 23 | imagedestroy ($buffer ); // Destroy the buffer |
| 24 | } |
| 25 | ?> |
20 hits by 12 users in the last 30 minutes.