color-mapping
A flexible library to map numerical values to colors
Install
npm install -S color-mapping
Basic Usage
; let colors = 1 0 0 0 1 0 0 0 1;let domain = 0 100;let range = 0 1;let scale = ;let colorMap = ;let values = 0 25 50 75 100;let output = values;// output is [[1,0,0], [0.5,0.5,0], [0,1,0], [0,0.5,0.5], [0,0,1]]
Advanced Usage
The colors array doesn't necessarily need to span evenly the [0, 1]
interval.
; let colors = value: -10 color: 0 0 1 value: 00 color: 1 0 0 value: 05 color: 0 1 0 value: 20 color: 0 0 1 ;let domain = 0 100;let range = -1 2;let scale = ;let colorMap = ;let values = 0 25 50 75 100;let output = values;// output is [[0,0,1], [0.75,0,0.25], [0,1,0], [0,0.5,0.5], [0,0,1]]