+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Dynamic Image

  1. #1
    liguehs is offline x10Hosting Member liguehs is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    62

    Dynamic Image

    Hi guys,
    OK so I have a number that I am getting from a DB...

    So what I want is that the number retreieved is the width of an image.

    So for easy, but here is the tough part:

    If that number is a negative, I want the image starting from the middle and goes to the left, and if its positive, starts from the middle and goes to the right.

    I attached an image of what I would like to make...

    Thanks for your help,
    Attached Thumbnails Attached Thumbnails Dynamic Image-show.jpg  

  2. #2
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: Dynamic Image

    edit: see next post by descalzo
    Last edited by Scoochi2; 09-05-2009 at 05:34 PM.
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  3. #3
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Dynamic Image

    PHP Code:
    ## constants depending on the size/margins of image
    $image_width XXX# width of image
    $image_margin XXX# size of left/right margins if you do not want to edge
    $value_max XXXX# max abs input value, probably 100
     
     
    $value From DB ;
     
    # maximum width of color bar
     
    $bar_max floor( ($image_width 2*$image_margin) / ) ;
     
    $image_midpoint floor$image_width/);
     
    # actual width of color bar
     
    $bar_length = (abs($value) /$value_max ) * $bar_max ;
     
    # find left and right enpoints of bar, and the color
     
    if( $value ){
       
    $left $image_midpoint ;
       
    $right $left $bar_length ;
       
    $color POSITIVE_COLOR ;
    } else {
       
    $right $image_midpoint ;
       
    $left $image_midpoint $bar_length ;
       
    $color NEGATIVE_COLOR ;

    Then use $left, $right, $color in your drawing program (GD based?).

    Edit:

    Like this
    Last edited by descalzo; 09-05-2009 at 01:58 PM.
    Nothing is always absolutely so.

  4. #4
    liguehs is offline x10Hosting Member liguehs is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    62

    Re: Dynamic Image

    Thanks so much,

    I will try it as soon as I get home.

  5. #5
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: Dynamic Image

    if you need further help: i also wrote a tutorial on this before. the link is in my sig.

  6. #6
    liguehs is offline x10Hosting Member liguehs is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    62

    Re: Dynamic Image

    Hi,
    Just wondering, how do I show the bar?
    What should i echo?

  7. #7
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Dynamic Image

    In your code to display the page you put

    PHP Code:
    $value = value you want to display...
     
    <img src="plusminus.php?value=<?php echo($value?>" height="30" width="100" 
             alt="test" id="plusminus" name="plusminus">
    plusminus.php would be a separate script that gets called with a query string of '?value=XX' an outputs the dynamic image.
    Nothing is always absolutely so.

  8. #8
    liguehs is offline x10Hosting Member liguehs is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    62

    Re: Dynamic Image

    I dont quite follow you here..

    So what is $value on the same page equlas too?

    And also, The value changes for each players...
    so it would be best if its get called in the while loop no?
    Last edited by liguehs; 09-09-2009 at 04:04 PM.

  9. #9
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Dynamic Image

    Quote Originally Posted by liguehs View Post
    I dont quite follow you here..

    So what is $value on the same page equlas too?

    And also, The value changes for each players...
    so it would be best if its get called in the while loop no?
    It's this number....

    OK so I have a number that I am getting from a DB...
    Nothing is always absolutely so.

  10. #10
    liguehs is offline x10Hosting Member liguehs is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    62

    Re: Dynamic Image

    Quote Originally Posted by descalzo View Post
    plusminus.php would be a separate script that gets called with a query string of '?value=XX' an outputs the dynamic image.
    Ok,
    but why call it in a separate file?

    Thats where I am getting lost...

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Dynamic images with PHP
    By marshian in forum Tutorials
    Replies: 24
    Last Post: 10-30-2008, 11:14 AM
  2. PHP Dynamic Image Script error.
    By Blazer9131 in forum Programming Help
    Replies: 10
    Last Post: 08-08-2008, 03:24 PM
  3. Replies: 11
    Last Post: 03-12-2008, 11:47 AM
  4. errors while attaching
    By mattspec in forum Feedback and Suggestions
    Replies: 0
    Last Post: 12-19-2005, 01:50 PM
  5. November Desktop
    By n4tec in forum Off Topic
    Replies: 12
    Last Post: 11-08-2005, 07:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers