Heizungssteuerung Web-Interface
HV_colorMap
To have a unicly defined color map for all temperatures this function returns the appropriate color for the given temperature argument. (Additionally a text color which contrasts nicely to the temperature color is returned.)
If the temperature argument is set to 'bar', the color bar is composed and returned as html.
<?php /* published under GPL www.gnu.org/licenses/gpl.html */ /* echo "<html><table>"; $bar = HV_colorMap("bar"); echo $bar; } echo "</table></html>"; */ function HV_colorMap($T){ /* old set $bgc["-10"]=" #000066"; $txt["-10"]="white"; $bgc["0"] =" #0000ff"; $txt["0"] ="white"; $bgc["10"] =" #0066ff"; $txt["10"] ="black"; $bgc["20"] =" #00ffd6"; $txt["20"] ="black"; $bgc["30"] =" #00ff33"; $txt["30"] ="black"; $bgc["40"] =" #ffff00"; $txt["40"] ="black"; $bgc["50"] =" #ff9900"; $txt["50"] ="black"; $bgc["60"] =" #ff0000"; $txt["60"] ="white"; $bgc["70"] =" #b80096"; $txt["70"] ="white"; $bgc["80"] ="fuchsia"; $txt["80"] ="black"; */ $bgc["-1000"]=" #ffffff"; $txt["-1000"]="white"; $bgc["-10"]=" #01006c"; $txt["-10"]="white"; $bgc["-5"] =" #0000fe"; $txt["-5"] ="white"; $bgc["0"] =" #0c2df6"; $txt["0"] ="white"; $bgc["5"] =" #0062ff"; $txt["5"] ="white"; $bgc["10"] =" #0099ff"; $txt["10"] ="black"; $bgc["15"] =" #00ccff"; $txt["15"] ="black"; $bgc["20"] =" #339933"; $txt["20"] ="white"; $bgc["25"] =" #009900"; $txt["25"] ="white"; $bgc["30"] =" #33cc33"; $txt["30"] ="black"; $bgc["35"] =" #69ff65"; $txt["35"] ="black"; $bgc["40"] =" #ffff66"; $txt["40"] ="black"; $bgc["45"] =" #ffff00"; $txt["45"] ="black"; $bgc["50"] =" #ff9703"; $txt["50"] ="black"; $bgc["55"] =" #fc6700"; $txt["55"] ="black"; $bgc["60"] =" #ff3300"; $txt["60"] ="white"; $bgc["65"] =" #ff68a5"; $txt["65"] ="white"; $bgc["70"] =" #cc3467"; $txt["70"] ="white"; $bgc["75"] ="fuchsia"; $txt["75"] ="black"; if($T=="bar"){ $colorBar ="<table>"; $keys = array_keys($bgc); $NoColors=count($bgc); for($c=0;$c<$NoColors;$c++){ $cc=$NoColors-$c-1; $colorBar.="<tr><td align='right' style='background-color:".$bgc[$keys[$cc]]."; color:".$txt[$keys[$cc]].";'>".$keys[$cc]."</td></tr>"; } #c $colorBar.="</table>"; return $colorBar; }else{ $keys = array_keys($bgc); $NoColors=count($bgc); for($c=0;$c<$NoColors;$c++){ $thisKey=$keys[$NoColors-$c-1]; if($T>1.0*$thisKey-2.5){ return array($bgc[$thisKey],$txt[$thisKey]); } #fi } #c return array("white","black"); } } ?>
Index of Library
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.