Created
May 8, 2015 09:56
-
-
Save eddy1982/69fb102ccf86473bedef to your computer and use it in GitHub Desktop.
Map value to color scale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Map value to color scale --> | |
<?php | |
function lineargradient($ra,$ga,$ba,$rz,$gz,$bz,$iterationnr) { | |
$colorindex = array(); | |
for($iterationc=1; $iterationc<=$iterationnr; $iterationc++) { | |
$iterationdiff = $iterationnr-$iterationc; | |
$colorindex[] = '#'. | |
dechex(intval((($ra*$iterationc)+($rz*$iterationdiff))/$iterationnr)). | |
dechex(intval((($ga*$iterationc)+($gz*$iterationdiff))/$iterationnr)). | |
dechex(intval((($ba*$iterationc)+($bz*$iterationdiff))/$iterationnr)); | |
} | |
return $colorindex; | |
} | |
$colorindex = lineargradient( | |
100, 0, 0, // rgb of the start color | |
0, 255, 255, // rgb of the end color | |
100 // number of colors in your linear gradient | |
); | |
$color = $colorindex[1]; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment