Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: ImageString

  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    43
    Thanks
    2
    Thanked 0 Times in 0 Posts

    ImageString

    hey, how do i put my image string like this:

    Code:
             /
           /
         /
       /
    and not like this:

    Code:
    ----------

  • #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Well, I presumed that you wanted each character to be on a new line? Yeah, okay so I whipped up this simple example for you.
    PHP Code:
    <?php

    $width  
    250;
    $height 80;

    $image imagecreate($width$height);

    $background imagecolorallocate($image255255255);
    $textColor  imagecolorallocate($image00255);

    $string 'Hello';
    $length strlen($string);

    for (
    $i 0$i $length$i++)
    {
      
    // Where ($i* 15) - 15 is the rate at which it moves left
      // Where ($width / 2) - is to start the decline from the middle

      
    imagestring($image5, ($width 2) - ($i 15), $i 15$string[$i], $textColor);
    }

    header('Content-type: image/gif');

    imagegif($image);
    imagedestroy($image);
    Also I did.. this
    PHP Code:
    <?php

    $image 
    imagecreate(25080);

    $background imagecolorallocate($image255255255);
    $textColor  imagecolorallocate($image00255);

    $string 'Hello';
    $length strlen($string);

    for (
    $i 0$i $length$i++)
    {
      
    // Where ($length - $i) * 2 - is the padding from the left in spaces

      
    $char str_pad($string[$i], ($length $i) * 2' 'STR_PAD_LEFT);

      
    imagestring($image50$i 15$char$textColor);
    }

    header('Content-type: image/gif');

    imagegif($image);
    imagedestroy($image);
    I like the first method, it's a lot nicer, if you didn't notice by now - I like experimenting :P


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •