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.

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.