1// Magma colormap (perceptually uniform, dark = quiet, bright = loud), 9 anchors interpolated.
2const ANCHORS: [number, number, number][] = [
3 [0, 0, 4],
4 [28, 16, 68],
5 [79, 18, 123],
6 [129, 37, 129],
7 [181, 54, 122],
8 [229, 80, 100],
9 [251, 135, 97],
10 [254, 194, 135],
11 [252, 253, 191],
12];
14export function magma(t: number): [number, number, number] {
15 const u = t * (ANCHORS.length - 1);
16 const i = Math.min(ANCHORS.length - 2, Math.floor(u));
17 const f = u - i;
18 const a = ANCHORS[i];
19 const b = ANCHORS[i + 1];
20 return [a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f];
21}