SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    I'm not a human
    Join Date
    Aug 2006
    Location
    India
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to have a zigzag font?

    hi

    i'm using the image functions of the PHP to create a image from the given string and then display..


    I want to know how to get the text to be displayed in zigzag format such as used in common sites as yahoo, google etc..

    Is there any special function for that or any special attributes with the imagestring function???
    Regards,
    Vijay
    Follow me on twitter @vijaycbe
    World Holiday Calander || My Cricket Blog

  2. #2
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use imageloadfont() . Maybe this can help you.

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looking in my crystal ball, I'm guessing you're looking for
    captcha+php
    Hope this helps

  4. #4
    I'm not a human
    Join Date
    Aug 2006
    Location
    India
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi iulian & stereofrog,


    you both got it right.

    I got the api from one of the site which gives a code to us to form a captcha ..


    Thanks for ur answers..

    But i need to have a format where the letters are arranged in a zigzag format and not in a straight line.. all the sites which provides for this is having a straight line format, even the imageloadfont() function loads the image from font , it displays it striaght.

    Is there any other function specifically handle this?
    Regards,
    Vijay
    Follow me on twitter @vijaycbe
    World Holiday Calander || My Cricket Blog

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes i have done same thing like you need so i want to share it here.
    Save the following code as randomize.php
    PHP Code:
        session_start();
        function 
    random_string($len=5$str=''){
          for(
    $i 1$i <= $len$i++){
            
    $ord rand(4890);
            if(((
    $ord >= 48) && ($ord <= 57)) || (($ord >= 65) && ($ord <= 90)))
                
    $str .= chr($ord);
            else
                
    $str .= random_string(1);
          }
          return 
    $str;
        }
        
    $rand_str random_string(5);
        
    $_SESSION['image_value'] = md5($rand_str);
        
        
    $letter1 substr($rand_str,0,1);
        
    $letter2 substr($rand_str,1,1);
        
    $letter3 substr($rand_str,2,1);
        
    $letter4 substr($rand_str,3,1);
        
    $letter5 substr($rand_str,4,1);
        
        
    $image imagecreatefrompng("./images/noise.png");
        
    $angle1 rand(-2020);
        
    $angle2 rand(-2020);
        
    $angle3 rand(-2020);
        
    $angle4 rand(-2020);
        
    $angle5 rand(-2020);
        
        
    $font1 "fonts/" rand(16).".ttf";
        
    $font2 "fonts/" rand(16).".ttf";
        
    $font3 "fonts/" rand(16).".ttf";
        
    $font4 "fonts/" rand(16).".ttf";
        
    $font5 "fonts/" rand(16).".ttf";
        
        
    $colors[0] = array(122,229,112);
        
    $colors[1] = array(85,178,85);
        
    $colors[2] = array(226,108,97);
        
    $colors[3] = array(141,214,210);
        
    $colors[4] = array(214,141,205);
        
    $colors[5] = array(100,138,204);
        
        
    $color1 rand(05);
        
    $color2 rand(05);
        
    $color3 rand(05);
        
    $color4 rand(05);
        
    $color5 rand(05);

        
    $textColor1 imagecolorallocate ($image$colors[$color1][0],$colors[$color1][1], $colors[$color1][2]);
        
    $textColor2 imagecolorallocate ($image$colors[$color2][0],$colors[$color2][1], $colors[$color2][2]);
        
    $textColor3 imagecolorallocate ($image$colors[$color3][0],$colors[$color3][1], $colors[$color3][2]);
        
    $textColor4 imagecolorallocate ($image$colors[$color4][0],$colors[$color4][1], $colors[$color4][2]);
        
    $textColor4 imagecolorallocate ($image$colors[$color5][0],$colors[$color5][1], $colors[$color5][2]);
        
        
    $size 20;
        
    imagettftext($image$size$angle110$size+15$textColor1$font1$letter1);
        
    imagettftext($image$size$angle235$size+15$textColor2$font2$letter2);
        
    imagettftext($image$size$angle360$size+15$textColor3$font3$letter3);
        
    imagettftext($image$size$angle485$size+15$textColor4$font4$letter4);
        
    imagettftext($image$size$angle5110$size+15$textColor5$font5$letter5);
        
        
    header('Content-type: image/jpeg');
        
    imagejpeg($image);
        
    imagedestroy($image); 
    Then call the randomize.php file like this somewhere in your HTML form area or anywhere.
    HTML Code:
    <img src="randomize.php">
    You should have two folders:
    fonts = for storing at least 6 fonts names 1.ttf,2.ttf,3.ttf,4.ttf,5.ttf,6.ttf (you can use any of the fonts of your chose but the names must be like above 1,2...,6 with the extension.)
    images = for storing a background image.

    Good luck!!
    Cheers!
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

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