linear-gradient
calculates the color representing a number based on the gradient supplied
Purpose
When using charts and maps to visualize data, it is useful to map values to a color gradient.
This package provides the functions to map values to color gradients.
Examples
Instantiate object with the graident palette, then use it to calculate the color representing a value
var Gradient = require('linear-gradient');
var grad1 = new Gradient([
[0,0,0],
[0,80,0],
[0,160,80],
[80,80,80],
[160,40,40],
[255,0,0]
]);
console.log(grad1.calcArray(0));
console.log(grad1.calcArray(1));
console.log(grad1.calcArray(0.25));
console.log(grad1.calcArray(0.5));
console.log(grad1.calcArray(0.75));
console.log(grad1.calcHex(1));
console.log(grad1.calcHex(0.25));