Jump to content

[SOLVED] Problems with dynamic userbar


SirChick

Recommended Posts

I have a bar which i need to change its max using fields from my table but i need the size and height to be the same..example of what i mean:

 

Max E - 100

Current E - 50

Green will be half way on the bar.

 

Max E - 150 (still the same length physically how ever as the 100 E bar)

Current E - 50

Green will be a third of the way up on the bar.

 

 

so i have:

 

maxE and currentE  i need the width and height always at 76 wide and 5 height. But the green to red need to be scalled differently if maxE is larger.

 

 

this is what i got so far:

 

//the two fields from user table set as variables
$MaxEnergy = $row["MaxEnergy"];
$CurrentEnergy = $row["CurrentEnergy"];

$height = 5;
$width = 76;
$im = Imagecreatetruecolor($width, $height);
$red = Imagecolorallocate($im, 400, 0, 10);
$green = Imagecolorallocate($im, 0, 400, 10);
imagefill($im, 0, 0, $red);
imagefilledrectangle($im, 0, 0, $CurrentEnergy, $height, $green);
header("Content-type: image/png");
Imagepng($im);
Imagedestroy($im);

 

the problem at the moment is im unsure on where i should put my "Maximum E " into the script for it to work the way i need it to?

Link to comment
https://forums.phpfreaks.com/topic/65696-solved-problems-with-dynamic-userbar/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.