color question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to shade the back ground of a series of table cells.
based on a series of integers
0 =white
100=greem
-100 =red
there are values inbetween and i want to go red to white as the numbers get
close to 0 and from 0 to 100 it goes from white to green
any one do something like this?
 
I want to shade the back ground of a series of table cells.
based on a series of integers
0 =white
100=greem
-100 =red
there are values inbetween and i want to go red to white as the numbers get
close to 0 and from 0 to 100 it goes from white to green
any one do something like this?

The question is how do you want to do that. By giving the background a
gradient using CSS, or by giving a fixed RGB value?
 
for this situation fixed rgb

if v is your value (-100..100)

if (v<0) {
x=255 - v*(-2.55);
color = rgb(255,x,x);
} else {
x=255 - v*2.55;
color = rgb(x,255,x);
}
 
Back
Top