Files
WeatherTool/web/src/harmonie/draw/precipitation.ts
T

18 lines
740 B
TypeScript
Raw Normal View History

2025-02-03 23:33:28 +02:00
import { valueToColorInterpolated, valueToColorThreshold } from '../../helpers/interpolateColors'
import { MeteoConversion } from '../interfaces'
2025-02-03 23:33:28 +02:00
import { PRECIPITATION } from './constants'
export function precipitationColors(
encodedValue: number,
{ reference, binaryScale, decimalScale}: MeteoConversion,
isInterpolated = true,
): [number, number, number, number] {
// const rainMM = (reference + encodedValue * Math.pow(2, binaryScale)) * Math.pow(10, -decimalScale) / 1000
const rainMM = (reference + encodedValue * Math.pow(2, binaryScale)) * Math.pow(10, -decimalScale)
return isInterpolated
? valueToColorInterpolated(rainMM, PRECIPITATION)
: valueToColorThreshold(rainMM, PRECIPITATION)
}