Znalazłem w sieci coś takiego -
http://www.herethere.net/~samson/php/color...00&steps=50Zatem gdybyś w takim kodzie:
$theColorBegin = 0x00ff00;
$theColorEnd = 0xff0000;
$theNumSteps = 50;
$theR0 = ($theColorBegin & 0xff0000) >> 16;
$theG0 = ($theColorBegin & 0x00ff00) >> 8;
$theB0 = ($theColorBegin & 0x0000ff) >> 0;
$theR1 = ($theColorEnd & 0xff0000) >> 16;
$theG1 = ($theColorEnd & 0x00ff00) >> 8;
$theB1 = ($theColorEnd & 0x0000ff) >> 0;
function interpolate($pBegin, $pEnd, $pStep, $pMax) {
if ($pBegin < $pEnd) {
return (($pEnd - $pBegin) * ($pStep / $pMax)) + $pBegin;
} else {
return (($pBegin - $pEnd) * (1 - ($pStep / $pMax))) + $pEnd;
}
}
for ($i = 0; $i <= $theNumSteps; $i++) {
$theR = interpolate($theR0, $theR1, $i, $theNumSteps);
$theG = interpolate($theG0, $theG1, $i, $theNumSteps);
$theB = interpolate($theB0, $theB1, $i, $theNumSteps);
$theVal = substr("000000".dechex(((($theR << 8
) | $theG) << 8
) | $theB), -6
);
echo "<span style='color:#".$theVal."'>".$theVal."</span>\n"; }
zamiast wyświetlać span, wrzucił sobie te kolorki w tablice z indeksami od 50 do 100, mógłbyś wyświetlając liczbę dawać jej kolor a tablicy, gdzie liczba ta jest indeksem.