JAXA Earth API for JavaScript
    Preparing search index...

    Class ColorMap

    Creates a color map for visualization.

    import * as je from "./jaxa.earth.esm.js";

    // To paint 0 to 6000 in rainbow colors
    const cmap1 = new je.image.ColorMap({
    min: 0,
    max: 6000,
    colors: je.Colors.JET,
    });

    // Retrieve the color for the value 3000
    console.log(cmap1.getColor(3000)); //=> {r: 159, g: 246, b: 72, a: 255}
    console.log(cmap1.getColorUint8ClampedArray(3000)); //=> Uint8ClampedArray(4) [159, 246, 72, 255]

    // Display the legend on the browser as an HTMLCanvasElement (width 500px, height 50px)
    document.body.appendChild(cmap1.createColorBarCanvas(500, 50))

    // To paint 0 to 3000 in white -> red -> blue, and 3000 to 6000 in blue -> black
    const cmap2 = new je.image.ColorMap([
    { min: 0, max: 3000, colors: ["ffffff", "ff0000", "0000ff"] },
    { min: 3000, max: 6000, colors: ["0000ff", "000000"] }
    ]);
    Index

    Constructors

    Methods

    • Returns the color at the value x as an object {r(red component), g(green component), b(blue component), a(alpha component)}. Each component has a value from 0 to 255.

      Parameters

      • x: number

      Returns { r: number; g: number; b: number; a: number }

    • Returns the color at the value x as a Uint8ClampedArray. The Uint8ClampedArray is an array of [R(red component), G(green component), B(blue component), A(alpha component)], and each component has a value from 0 to 255.

      Parameters

      • x: number

      Returns Uint8ClampedArray

    • Returns the legend image of this ColorMap as an HTMLCanvasElement.

      Parameters

      • width: number

        The width of the image (in pixels).

      • height: number

        The height of the image (in pixels).

      Returns HTMLCanvasElement

      Available only on the browser's main thread.

    • Returns the legend image of this ColorMap as a PNG image Uint8Array.

      Parameters

      • width: number

        The width of the image (in pixels).

      • height: number

        The height of the image (in pixels).

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Returns the legend image of this ColorMap as an ImageDataObject.

      Parameters

      • width: number

        The width of the image (in pixels).

      • height: number

        The height of the image (in pixels).

      Returns ImageDataObject

    • Returns the legend image of this ColorMap (with scale values and unit text annotated) as an HTMLCanvasElement.

      Parameters

      • width: number

        The width of the entire image including scales and units (in pixels).

      • height: number

        The height of the entire image including scales and units (in pixels).

      • size: number

        The size of the text.

      • unit: string

        The unit text to annotate within the legend image.

      Returns HTMLCanvasElement

      Available only on the browser's main thread.