2025-02-03 23:33:28 +02:00
|
|
|
type RGBAu8 = [number, number, number, number]
|
|
|
|
|
|
2025-02-04 21:59:39 +02:00
|
|
|
const DRIZZLE: RGBAu8 = [5, 200, 0, 255]
|
|
|
|
|
const RAIN: RGBAu8 = [50, 150, 0, 255]
|
|
|
|
|
const SLEET: RGBAu8 = [255, 175, 0, 255]
|
|
|
|
|
const SNOW: RGBAu8 = [0, 160, 255, 255]
|
|
|
|
|
const FREEZING_DRIZZLE: RGBAu8 = [255, 100, 120, 255]
|
|
|
|
|
const FREEZING_RAIN: RGBAu8 = [255, 0, 0, 255]
|
|
|
|
|
const GRAUPEL: RGBAu8 = [230, 40, 250, 255]
|
|
|
|
|
const HAIL: RGBAu8 = [180, 0, 250, 255]
|
|
|
|
|
|
2025-02-03 23:33:28 +02:00
|
|
|
export function categoricalRainColors(value: number): RGBAu8 {
|
|
|
|
|
switch (value) {
|
|
|
|
|
case 0:
|
2025-02-04 21:59:39 +02:00
|
|
|
return DRIZZLE
|
2025-02-03 23:33:28 +02:00
|
|
|
case 1*32:
|
2025-02-04 21:59:39 +02:00
|
|
|
return RAIN
|
2025-02-03 23:33:28 +02:00
|
|
|
case 2*32:
|
2025-02-04 21:59:39 +02:00
|
|
|
return SLEET
|
2025-02-03 23:33:28 +02:00
|
|
|
case 3*32:
|
2025-02-04 21:59:39 +02:00
|
|
|
return SNOW
|
2025-02-03 23:33:28 +02:00
|
|
|
case 4*32:
|
2025-02-04 21:59:39 +02:00
|
|
|
return FREEZING_DRIZZLE
|
2025-02-03 23:33:28 +02:00
|
|
|
case 5*32:
|
2025-02-04 21:59:39 +02:00
|
|
|
return FREEZING_RAIN
|
2025-02-03 23:33:28 +02:00
|
|
|
case 6*32:
|
2025-02-04 21:59:39 +02:00
|
|
|
return GRAUPEL
|
|
|
|
|
case 7*32:
|
|
|
|
|
return HAIL
|
2025-02-03 23:33:28 +02:00
|
|
|
default:
|
|
|
|
|
return [255, 255, 255, 0]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function hexToU8(hex: string): [number, number, number] {
|
|
|
|
|
return [parseInt('0x'+hex.slice(0, 2)), parseInt('0x'+hex.slice(2, 4)), parseInt('0x'+hex.slice(4, 6))]
|
|
|
|
|
}
|