//Shadow palette for coloring the roofs // color pallet from https://colorbrewer2.org/#type=sequential&scheme=BuGn&n=3 var pvPotentialPallet = ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#034e7b'] pvPotentialPallet = pvPotentialPallet.reverse(); //color pallet white->black var colorPalette = ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525']; const shadowPalette = colorPalette.reverse(); //returns the responding color from the shadowPalette, depending on the inputShadowValue(0 to 1 in float) function getShadowPalette(inputShadowValue) { //checking for the float values var index = Math.ceil((shadowPalette.length - 1) * inputShadowValue); //console.log(inputShadowValue,"---",shadowPalette[index]); return shadowPalette[index]; } /** returns a color from the chosen colorpalette, depending on the inputvalue * @param {float} inputValue - inputValue on which the colorpalette should be calculated (normalized range 0.0-1.0) * @param {string} colorPalette - "pvPotential" or "shadowValue" * @returns {string} a hex color string */ function getColorFromPalette(inputValue,colorPalette) { //returns the responding color from the shadowPalette, depending on the inputShadowValue(0 to 1 in float) if(colorPalette==="shadowValue"){ var index = Math.ceil((shadowPalette.length - 1) * inputValue); //checking for the float values return shadowPalette[index]; }else if(colorPalette==="pvPotential"){ var index = Math.ceil((pvPotentialPallet.length - 1) * inputValue); //checking for the float values return pvPotentialPallet[index]; }else{ throw "chose wrong colorPalette"; } }