September 5, 2008 – 10:25 am
function get_color($start, $end, $percent) {
$pc = $percent/100;
$r =
floor($r1+
($pc*
($r2-
$r1)) + .
5);
$g =
floor($g1+
($pc*
($g2-
$g1)) + .
5);
$b =
floor($b1+
($pc*
($b2-
$b1)) + .
5);
return(sprintf('#%02X%02X%02X',
$r,
$g,
$b));
}
// Shows all of the colors between $start and $end at ten percent intervals.
function color_scale($start, $end, $max = 'red') {
$i = 0;
$str = "
<table border=0>
<tr>";
for($i = 0; $i < 101; $i += 10) {
$color = get_color($start, $end, $i);
$str .= "
<td bgcolor=$color>$i</td>
";
}
$str .= "
<td bgcolor=$max>M</td>
";
$str .= "</tr>
</table>
";
return($str);
}