Jump to content

Colorize based on value


silkfire

Recommended Posts

How is this a PHP Coding Question?

 

 

The "algorithm?". Well, that would depend on what "red" and what "green" you want to use. It would be presumptuous for me to assume that you want to use the red "FF0000" or the green "00FF00". That red is probably a safe bet, but the "full" green is a pukey lime green. A better choice might be something closer to a hunter green such as "008000".

 

Assuming those are the two colors you will use. The red parameter goes though the full 256 values and the green goes through 128 values.

 

10,000 / 256 = 39

10,000 / 128 = 78

 

So, starting with 00FF00"" for 0 units, for every 39 units you would subtract 1 from the red component of the color code and for every 78 units you would add 1 to the green component. I'll let you figure out the programming.

Link to comment
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.