JSPM

colorscale-interpolate

1.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 4
    • Score
      100M100P100Q23486F
    • License ISC

    Takes a color scale such as the legend of a heat map and allows calculating the color at any point along the scale.

    Package Exports

    • colorscale-interpolate
    • colorscale-interpolate/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (colorscale-interpolate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    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 }