Fetch binary chunk and draw on canvas

This commit is contained in:
Guntis Smaukstelis
2025-02-03 23:33:28 +02:00
parent c1b1226678
commit df8d16ed4a
18 changed files with 898 additions and 6 deletions
+17
View File
@@ -0,0 +1,17 @@
import { valueToColorInterpolated, valueToColorThreshold } from '../../helpers/interpolateColors'
import { MeteoConversion } from '../../interfaces/interfaces'
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)
}