src/colors/colormap.js
function createLinearSegmentedColormap (segmentedData, N, gamma) {
  let i;
  const lut = [];

  N = N === null ? 256 : N;
  gamma = gamma === null ? 1 : gamma;

  const redLut = makeMappingArray(N, segmentedData.red, gamma);
  const greenLut = makeMappingArray(N, segmentedData.green, gamma);
  const blueLut = makeMappingArray(N, segmentedData.blue, gamma);

  for (i = 0; i < N; i++) {
    const red = Math.round(redLut[i] * 255);
    const green = Math.round(greenLut[i] * 255);
    const blue = Math.round(blueLut[i] * 255);
    const rgba = [red, green, blue, 255];

    lut.push(rgba);
  }

  return lut;
}
function createLinearSegmentedColormap (segmentedData, N, gamma) {
  let i;
  const lut = [];

  N = N === null ? 256 : N;
  gamma = gamma === null ? 1 : gamma;

  const redLut = makeMappingArray(N, segmentedData.red, gamma);
  const greenLut = makeMappingArray(N, segmentedData.green, gamma);
  const blueLut = makeMappingArray(N, segmentedData.blue, gamma);

  for (i = 0; i < N; i++) {
    const red = Math.round(redLut[i] * 255);
    const green = Math.round(greenLut[i] * 255);
    const blue = Math.round(blueLut[i] * 255);
    const rgba = [red, green, blue, 255];

    lut.push(rgba);
  }

  return lut;
}
function createLinearSegmentedColormap ( segmentedData , N , gamma ) { let i ; const lut = [ ] ; N = N === null ? 256 : N ; gamma = gamma === null ? 1 : gamma ; const redLut = makeMappingArray ( N , segmentedData . red , gamma ) ; const greenLut = makeMappingArray ( N , segmentedData . green , gamma ) ; const blueLut = makeMappingArray ( N , segmentedData . blue , gamma ) ; for ( i = 0 ; i < N ; i ++ ) { const red = Math . round ( redLut [ i ] * 255 ) ; const green = Math . round ( greenLut [ i ] * 255 ) ; const blue = Math . round ( blueLut [ i ] * 255 ) ; const rgba = [ red , green , blue , 255 ] ; lut . push ( rgba ) ; } return lut ; }
Creates a Colormap based on lookup tables using linear segments.
@param {{red:Array, green:Array, blue:Array}} segmentedData An object with a red, green and blue entries.
Each entry should be a list of x, y0, y1 tuples, forming rows in a table.
@param {Number} N The number of elements in the result Colormap
@param {any} gamma value denotes a "gamma curve" value which adjusts the brightness
at the bottom and top of the Colormap.
@returns {Array} The created Colormap object
@description The lookup table is generated using linear interpolation for each
Primary color, with the 0-1 domain divided into any number of
Segments.
https://github.com/stefanv/matplotlib/blob/3f1a23755e86fef97d51e30e106195f34425c9e3/lib/matplotlib/colors.py#L663
@memberof Colors
Creates a Colormap based on lookup tables using linear segments .