mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-22 00:18:10 -07:00
heatmaps: part 4
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
/** @import { HeatmapColorFn } from "./types.js" */
|
||||
|
||||
const INFERNO_STOPS = [
|
||||
[0, 0, 0, 0],
|
||||
[0.13, 40, 11, 84],
|
||||
@@ -12,6 +14,21 @@ const INFERNO_STOPS = [
|
||||
|
||||
export const INFERNO_LUT = createColorLut(INFERNO_STOPS);
|
||||
|
||||
/**
|
||||
* @param {Object} args
|
||||
* @param {ArrayLike<number>} args.light
|
||||
* @param {ArrayLike<number>} args.dark
|
||||
* @returns {HeatmapColorFn}
|
||||
*/
|
||||
export function intensityColor({ light, dark }) {
|
||||
return (value, context) => {
|
||||
if (!Number.isFinite(value)) return 0x00000000;
|
||||
const lut = context.dark ? dark : light;
|
||||
const index = Math.min(255, Math.max(0, Math.round(value * 255)));
|
||||
return lut[index] ?? 0x00000000;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number[][]} stops - Tuples of [position, red, green, blue].
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user