Skip to content

Instantly share code, notes, and snippets.

@tonyhschu
Created January 29, 2016 03:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyhschu/ffccd24828eca83deaa1 to your computer and use it in GitHub Desktop.
Save tonyhschu/ffccd24828eca83deaa1 to your computer and use it in GitHub Desktop.
Mapping [0,1] to a hex color.
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