gamehead200 Posted July 8, 2003 Share Posted July 8, 2003 Guys, I'm currently editing the code for my sig (which I found here). What I want is for the percentage to stay in the middle of the bar...This is how it looks right now:- removed -And I want to change the position of the percentage...This is the code I have to edit:<?phpHeader ('Content-type: image/jpeg');Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');Header('Pragma: no-cache');// Set the dimensions$img_width = 430;$img_height = 50;// Create the image$image = imagecreate(430, 50);// Set the colours$black = imagecolorallocate($image, 0, 0, 0);$white = imagecolorallocate($image, 255, 255, 255);$red = imagecolorallocate($image, 255, 0, 0);$grey = imagecolorallocate($image, 204, 204, 204);$green = imagecolorallocate($image, 128, 220, 0);// set the bg colour and borderimagefilledrectangle($image, 0, 0, $img_width, $img_height, $white);imageline($image, 0, 0, 0, $img_height, $black); // left borderimageline($image, 0, 0, $img_width, 0, $black); // top borderimageline($image, 0, $img_height - 1, $img_width, $img_height - 1, $black); // bottom borderimageline($image, $img_width - 1, 0, $img_width - 1, $img_height - 1, $black); // right border// Get song info from the text file$song_info = file("info.txt");$main_info = explode(" - ", $song_info[0]);$artist = trim($main_info[0]);$title = trim($main_info[1]);$real_length = $song_info[1];$for = time() - $song_info[2];$total = trim($song_info[4]);$minutes = $for / 60;$break = explode(".", $minutes);$current_secs = $for % 60;$current_mins = $break[0];$length = $song_info[4];$totalmins = $current_mins * 60;$totalsecs = $current_secs + $totalmins;$percent = $totalsecs / $length * 100;$percent = round($percent, 0);$font = '/path/to/ttf/font';if ($for <= $total){ ImageTTFText ($image, 8, 0, 10, 17, $black, $font, "gamehead200 is listening to ".$artist." - ".$title); // progress bar $width = $percent * 3; $width = round($width, 0); imagefilledrectangle($image, 11, 22, $width, 40, $red); imageline($image, 10, 21, 310, 21, $black); // top border imageline($image, 10, 21, 10, 41, $black); // left border imageline($image, 10, 41, 310, 41, $black); // bottom border imageline($image, 310, 21, 310, 41, $black); // right border if ($current_secs <= 9) { $current_secs = "0" . $current_secs; } ImageTTFText ($image, 11, 0, $width - 7, 37, $black, $font, $percent . "%"); ImageTTFText ($image, 11, 0, 315, 37, $black, $font, $current_mins .":".$current_secs."/".$real_length);}else{ ImageTTFText ($image, 8, 0, 10, 27, $black, $font, "I am currently not listening to any music OR Winamp is not open!");} // output and destroyimagepng($image);imagedestroy($image);?>Any ideas on how to do this? Link to comment Share on other sites More sharing options...
AlmondScar Posted July 9, 2003 Share Posted July 9, 2003 try and change $width = $percent * 3; $width = round($width, 0);to something a bit further on, like * 53, or where ever you want it Link to comment Share on other sites More sharing options...
gamehead200 Posted July 9, 2003 Author Share Posted July 9, 2003 try and change $width = $percent * 3; $width = round($width, 0);to something a bit further on, like * 53, or where ever you want itNo, the thing is that when the bar moves, so does the percentage, so it won't work that way...I think I have to change something in the bar properties as well... Link to comment Share on other sites More sharing options...
AlmondScar Posted July 9, 2003 Share Posted July 9, 2003 eep ImageTTFText ($image, 11, 0, $width - 7, 37, $black, $font, $percent . "%"); ImageTTFText ($image, 11, 0, 315, 37, $black, $font, $current_mins .":".$current_secs."/".$real_length);mayeb its to do with this, but the only thing i know is HTMl i don't even know what kind of coding this is, is it php? Link to comment Share on other sites More sharing options...
gamehead200 Posted July 9, 2003 Author Share Posted July 9, 2003 eep ImageTTFText ($image, 11, 0, $width - 7, 37, $black, $font, $percent . "%"); ImageTTFText ($image, 11, 0, 315, 37, $black, $font, $current_mins .":".$current_secs."/".$real_length);mayeb its to do with this, but the only thing i know is HTMl i don't even know what kind of coding this is, is it php?Yes! Its PHP, with GD! Link to comment Share on other sites More sharing options...
AlmondScar Posted July 10, 2003 Share Posted July 10, 2003 GD? lol im outta here Link to comment Share on other sites More sharing options...
gamehead200 Posted July 10, 2003 Author Share Posted July 10, 2003 See? This is GD as well...Its PHP in a JPEG or PNG that makes it into a viewable image...- removed - Link to comment Share on other sites More sharing options...
AlmondScar Posted July 12, 2003 Share Posted July 12, 2003 Argh, my Ip address has changed! oh wait, lol, i forgot i got a new isp Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now