Skip to content

Instantly share code, notes, and snippets.

@richjenks
Last active August 29, 2015 14:08
Show Gist options
  • Save richjenks/1636158f2547cb96c910 to your computer and use it in GitHub Desktop.
Save richjenks/1636158f2547cb96c910 to your computer and use it in GitHub Desktop.
Returns a hue value between green and red for an int between 0–100
<?php
/**
* heatmap
*
* Returns a hue value for HSL colors when given a level between 0–100
* Will accept higher/lower values, but will be outside of heatmap range
* Converts a percentage to a number between 0—120 in reverse
*
* @param int $level Integer between 0–100
* @return inst Integer between 0—120
*/
function heatmap($level) { return 120 - ( ( 120 / 100 ) * $level ); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment