Last active
December 9, 2020 15:34
-
-
Save leoherzog/c290d291e3325575094ab545314953ae to your computer and use it in GitHub Desktop.
Wunderground Color Temperature Scale with Chroma.js
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
//<script src="//cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.3/chroma.min.js"></script> | |
function getColorFromTemp(tempInF) { | |
// establish the chroma 'scale' object | |
var tempScaleColors = ["#111111", "#21006B", "#4C006B", "#6B006B", "#990099", "#B300B3", "#CC00CC", "#E600E6", "#FF02FF", "#D100FF", "#9E01FF", "#6600FF", "#1800FF", "#144AFF", "#0E74FF", "#00A4FF", "#00CBFF", "#00E6FF", "#00FFFF", "#01FFB3", "#7FFF00", "#CEFF00", "#FEFF00", "#FFE601", "#FFCB00", "#FFAE00", "#FF9900", "#FE7F00", "#FF4F00", "#FF0700", "#FF4545", "#FF6968", "#FF8787", "#FF9E9E", "#FFB5B5", "#FFCFCF", "#FFE8E8", "#EEEEEE"]; | |
var tempScale = chroma.scale(tempScaleColors).domain([-60,130]).mode('lab'); | |
// extract color from chroma scale by giving it a temp number | |
var color = tempScale(tempInF); | |
return color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment