Created
October 27, 2023 16:34
-
-
Save leoherzog/bad205e3cf6e327b630c2cfb442e18c5 to your computer and use it in GitHub Desktop.
Temperature Color Gradients
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
#include "map2colour.h" | |
uint32_t wundergroundColors[] = { | |
0x00111111, 0x0021006B, 0x004C006B, 0x006B006B, 0x00990099, 0x00B300B3, | |
0x00CC00CC, 0x00E600E6, 0x00FF02FF, 0x00D100FF, 0x009E01FF, 0x006600FF, | |
0x001800FF, 0x00144AFF, 0x000E74FF, 0x0000A4FF, 0x0000CBFF, 0x0000E6FF, | |
0x0000FFFF, 0x0001FFB3, 0x007FFF00, 0x00CEFF00, 0x00FEFF00, 0x00FFE601, | |
0x00FFCB00, 0x00FFAE00, 0x00FF9900, 0x00FE7F00, 0x00FF4F00, 0x00FF0700, | |
0x00FF4545, 0x00FF6968, 0x00FF8787, 0x00FF9E9E, 0x00FFB5B5, 0x00FFCFCF, | |
0x00FFE8E8, 0x00EEEEEE | |
}; | |
float wundergroundDomain[] = {−60,−55,−50,−45,−40,−35,−30,−25,−20,−15,−10,−5,0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125}; | |
uint32_t nwsColors[] = { | |
0x00ffffff, 0x00ffd2ff, 0x00df8ee2, 0x00a760c8, 0x005e4eac, | |
0x0037c4e2, 0x0033de9d, 0x007ed634, 0x00ffff32, 0x00fb9232, | |
0x00da4f33, 0x00b23833, 0x00000000 | |
}; | |
float nwsDomain[] = {−10,0,10,20,30,40,50,60,70,80,90,100,110}; | |
uint32_t windyColors[] = { | |
0x00734669, 0x00caacc3, 0x00a24691, 0x008f59a9, 0x009ddbd9, | |
0x006abfb5, 0x0064a6bd, 0x005d85c6, 0x00447d63, 0x00809318, | |
0x00f3b704, 0x00e85319, 0x00470e00 | |
}; | |
float windyDomain[] = {-94,-67,-40,-13,5,17,25,32,34,50,70,86,116}; | |
map2colour m2c(13); // number of temp colors in the array | |
void setup() { | |
// m2c.begin(wundergroundDomain, wundergroundColors); // Uncomment for wunderground scale | |
// m2c.begin(nwsDomain, nwsColors); // Uncomment for nws scale | |
m2c.begin(windyDomain, windyColors); // Default to windy.com scale | |
} | |
void loop() { | |
int temp = 60; // degrees f | |
uint32_t rgbColor = m2c.map2RGB(temp); | |
byte r = (rgbColor >> 16) & 0xFF; | |
byte g = (rgbColor >> 8) & 0xFF; | |
byte b = rgbColor & 0xFF; | |
} |
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
// const tempScale = chroma.scale(["#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"]).domain([-60,125]).mode('hsl'); // wunderground scale | |
// const tempScale = chroma.scale(["#ffffff", "#ffd2ff", "#df8ee2", "#a760c8", "#5e4eac", "#37c4e2", "#33de9d", "#7ed634", "#ffff32", "#fb9232", "#da4f33", "#b23833", "#000000"]).domain([-10,110]).mode('hsl'); // nws scale | |
const tempScale = chroma.scale(["#734669","#caacc3","#a24691","#8f59a9","#9ddbd9","#6abfb5","#64a6bd","#5d85c6","#447d63","#809318","#f3b704","#e85319","#470e00"]).domain([[-94,-67,-40,-13,5,17,25,32,34,50,70,86,116]]).mode('hsl'); // windy.com default | |
let color = tempScale(60).hex(); // degrees f |
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
import spectra | |
# tempScale = spectra.scale(["#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"]).domain([-60,125]) # wunderground scale | |
# tempScale = spectra.scale(["#ffffff", "#ffd2ff", "#df8ee2", "#a760c8", "#5e4eac", "#37c4e2", "#33de9d", "#7ed634", "#ffff32", "#fb9232", "#da4f33", "#b23833", "#000000"]).domain([-10,110]) # nws scale | |
tempScale = spectra.scale(["#734669","#caacc3","#a24691","#8f59a9","#9ddbd9","#6abfb5","#64a6bd","#5d85c6","#447d63","#809318","#f3b704","#e85319","#470e00"]).domain([-94,-67,-40,-13,5,17,25,32,34,50,70,86,116]) # windy.com default | |
color = tempScale(60).hexcode # degrees f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment