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 8 of 8
  1. #1
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tab Image generation (version 1)

    PHP Code:
    <?php
    // functions
    function convertHEX($hex){
    $r hexdec(substr($hex,0,2));
    $g hexdec(substr($hex,2,2));
    $b hexdec(substr($hex,4,2));
    $rs = array('r'=>$r,'g'=>$g,'b'=>$b);
    return(
    $rs);
    }
    function 
    reduceHEX($hex){
    $r hexdec(substr($hex,0,2));
    $g hexdec(substr($hex,2,2));
    $b hexdec(substr($hex,4,2));
    if(
    $r $g && $r $b){
    $g $g*1.1$b $b*1.1;
    } else if(
    $g $r && $g $b){
    $r $r*1.1$b $b*1.1;
    } else if(
    $b $g && $b $r){
    $g $g*1.1$r $r*1.1;
    }
    if(
    $r 255){ $r 255;}
    if(
    $g 255){ $g 255;}
    if(
    $b 255){ $b 255;}
    $rs = array('r'=>$r,'g'=>$g,'b'=>$b);
    return(
    $rs);
    }

    /// main
    $width intval($_REQUEST['width']);
    $height intval($_REQUEST['height']);
    $color convertHEX($_REQUEST['color']);
    $bgcolor convertHEX($_REQUEST['bgcolor']);

    $image imagecreatetruecolor($width,$height);

    $bg imagecolorallocate($image$bgcolor['r'],$bgcolor['g'],$bgcolor['b']); // image bg colour
    imagefill($image00$bg);

    $col imagecolorallocate $image$color['r'],$color['g'],$color['b']); // image foreground colour

    $corColor reduceHEX($_REQUEST['color']); // for colour edge fix
    $colCor imagecolorallocate $image$corColor['r'],$corColor['g'],$corColor['b']);

    imagefilledarc $image$height/2, ($height/2)-1$height+1$height180270$colCorIMG_ARC_PIE); // left side arc correction

    imagefilledarc $image$height/2$height/2$height-1$height-1180270$colIMG_ARC_PIE); // left side arc

    imagefilledarc $image$width-($height/2), ($height/2)-1$height+1$height270360$colCorIMG_ARC_PIE); // right side arc correction

    imagefilledarc $image$width-($height/2), $height/2$height-1$height-1270360$colIMG_ARC_PIE); // right side arc

    imagefilledrectangle $image0, ($height/2)-1$width$height$col ); // bottom rectangle

    imagefilledrectangle $image$height/20$width-($height/2)+2, ($height/2), $col ); // top rectangle

    header("Content-type: image/png");
    imagepng($image);

    ?>
    there it is.

    can be seen here http://rlemon.com/upgrade/

    Edit: * functionality removed *
    notice i have added the functionality to put a small strip of colour at the top. i'm using this for a mouseover effect (maybe).
    Edit: * functionality removed *


    usage:

    ImageTab.php?height=IMAGE_HEIGHT&width=IMAGE_WIDTH&color=COLOR_CODE_WITHOUT_#&bgcolor=BG_COLOR_CODE_WITHOUT_#
    Last edited by rlemon; 03-10-2006 at 03:49 PM.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Note,
    the corner correction is just a lighter version of the fill colour layered in behind the regular colour with 1.1x larger max width and height.

    Also note, i have removed the top line - it was ugly.
    Last edited by rlemon; 03-10-2006 at 04:01 AM.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #3
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Its printing out the new line feed on your demo page. I didn't see any \n in the code above so maybe somewhere else in your code its not encapsulated by double quotes.
    Also, check your javascript code. It is throwing out 2 errors so the mouseover & mouseout effects do not work. I think its in the link .js not sure tho.

    Other than that--pretty cool.
    Last edited by StupidRalph; 03-13-2006 at 03:36 AM.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #4
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yea i've been playing around, if you can't tell by the url it's my upgrade page - so expect it to be changing. however the tabs are the ones generated by the code above.

    the code above simply creates the image, and is called as an image would be
    i.e. <img src="....">
    or
    <div style="background-image: url('...');">
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #5
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Oh okay I didn't realize you were working live on the script.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #6
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yea - sorry bout that
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #7
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, I tested the code in my linux server but it's not working. I also tested the code on the link you gave (http://rlemon.com/upgrade/ImageTab.p...CODE_WITHOUT_#)
    and it is not working either. Thank you!

  • #8
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by slpkwr View Post
    Hi, I tested the code in my linux server but it's not working. I also tested the code on the link you gave (http://rlemon.com/upgrade/ImageTab.p...CODE_WITHOUT_#)
    and it is not working either. Thank you!

    Server is down. Sorry... Code should work. what is your problem?>
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<


  •  

    Posting Permissions

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