Created
January 29, 2016 03:05
-
-
Save tonyhschu/ffccd24828eca83deaa1 to your computer and use it in GitHub Desktop.
Mapping [0,1] to a hex color.
This file contains 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
var c = function(n) { | |
var string = ''; | |
n = Math.floor(n * Math.pow(256, 3)); | |
for (var i = 5; i >= 0; i--) { | |
string += (Math.floor(n / Math.pow(16, i)) % 16).toString(16); | |
} | |
return '#' + string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment