colorPalettes.js 1.66 KB
Newer Older
1
2
3
//Shadow palette for coloring the roofs
// color pallet from https://colorbrewer2.org/#type=sequential&scheme=BuGn&n=3

4
var pvPotentialPallet = ['#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#034e7b']
5
6
7
pvPotentialPallet = pvPotentialPallet.reverse();

//color pallet      white->black
8
9
var colorPalette = ['#bdbdbd', '#969696', '#737373', '#525252', '#252525'];
const shadowPalette = colorPalette;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

//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";
    }

    
}