colorscale-interpolate
v1.0.1
Published
Takes a color scale such as the legend of a heat map and allows calculating the color at any point along the scale.
Readme
Color Scale Interpolate
Takes a color scale such as the legend of a heat map and allows calculating the color at any point along the scale.
Usage
import { ColorScale, interpolateColorScale } from "colorscale-interpolate";
const scale: ColorScale = [
{ color: "#FFFFFF", opacity: 1, threshold: 0.0 },
{ color: "#EEEEEE", opacity: 0.9, threshold: 0.1 },
{ color: "#DDDDDD", opacity: 0.8, threshold: 0.2 },
{ color: "#CCCCCC", opacity: 0.7, threshold: 0.3 },
{ color: "#BBBBBB", opacity: 0.6, threshold: 0.4 },
{ color: "#AAAAAA", opacity: 0.5, threshold: 0.5 },
{ color: "#999999", opacity: 0.4, threshold: 0.6 },
{ color: "#888888", opacity: 0.3, threshold: 0.7 },
{ color: "#777777", opacity: 0.2, threshold: 0.8 },
{ color: "#666666", opacity: 0.1, threshold: 0.9 },
{ color: "#555555", opacity: 0, threshold: 1.0 },
];
const colorValue = interpolateColorScale(scale, 0.55); // { color: '#a2a2a2', opacity: 0.45 }