Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.