@@ -5,7 +5,7 @@ function interpolateColorScaleHSL(colors: Array<string>, steps: number) {
5
5
const stepsPerSegment = Math . floor ( steps / segments ) ;
6
6
const remainder = steps % segments ;
7
7
8
- const rgbArray = [ ] ;
8
+ const rgbArray : number [ ] [ ] = [ ] ;
9
9
10
10
for ( let i = 0 ; i < segments ; i ++ ) {
11
11
const startColor = colors [ i ] ;
@@ -27,7 +27,29 @@ function interpolateColorScaleHSL(colors: Array<string>, steps: number) {
27
27
return rgbArray ;
28
28
}
29
29
30
- export const colorScales = {
30
+ type ColorScale = {
31
+ min : number ;
32
+ max : number ;
33
+ scalefactor : number ;
34
+ colors : number [ ] [ ] ;
35
+ } ;
36
+
37
+ type ColorScales = {
38
+ [ key : string ] : ColorScale ;
39
+ } ;
40
+
41
+ const precipScale : ColorScale = {
42
+ min : 0 ,
43
+ max : 20 ,
44
+ scalefactor : 1 ,
45
+ colors : [
46
+ ...interpolateColorScaleHSL ( [ 'blue' , 'green' ] , 5 ) , // 0 to 5mm
47
+ ...interpolateColorScaleHSL ( [ 'green' , 'orange' ] , 5 ) , // 5 to 10mm
48
+ ...interpolateColorScaleHSL ( [ 'orange' , 'red' ] , 10 ) // 10 to 20mm
49
+ ]
50
+ } ;
51
+
52
+ export const colorScales : ColorScales = {
31
53
cape : {
32
54
min : 0 ,
33
55
max : 4000 ,
@@ -47,15 +69,7 @@ export const colorScales = {
47
69
...interpolateColorScaleHSL ( [ '#FFF' , '#c3c2c2' ] , 100 ) // 0 to 100%
48
70
]
49
71
} ,
50
- precipitation : {
51
- min : 0 ,
52
- max : 20 ,
53
- colors : [
54
- ...interpolateColorScaleHSL ( [ 'blue' , 'green' ] , 5 ) , // 0 to 5mm
55
- ...interpolateColorScaleHSL ( [ 'green' , 'orange' ] , 5 ) , // 5 to 10mm
56
- ...interpolateColorScaleHSL ( [ 'orange' , 'red' ] , 10 ) // 10 to 20mm
57
- ]
58
- } ,
72
+ precipitation : precipScale ,
59
73
pressure : {
60
74
min : 950 ,
61
75
max : 1050 ,
@@ -65,6 +79,7 @@ export const colorScales = {
65
79
...interpolateColorScaleHSL ( [ '#FFFFFF' , '#FF4444' ] , 25 ) // 1000hPa to 1050hPa
66
80
]
67
81
} ,
82
+ rain : precipScale ,
68
83
relative : {
69
84
min : 0 ,
70
85
max : 100 ,
0 commit comments