All files / Sources/Rendering/Core/ColorTransferFunction ColorMaps.js

44.44% Statements 8/18
0% Branches 0/8
66.66% Functions 4/6
44.44% Lines 8/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56    1x   1x 188x 121x   120x         1x 1x         2x                                                                        
import vtkColorMaps from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.json';
 
const presetMap = Object.create(null);
 
vtkColorMaps
  .filter((p) => p.RGBPoints)
  .filter((p) => p.ColorSpace !== 'CIELAB')
  .forEach((p) => {
    presetMap[p.Name] = p;
  });
 
// ----------------------------------------------------------------------------
 
const rgbPresetNames = Object.keys(presetMap);
rgbPresetNames.sort();
 
// ----------------------------------------------------------------------------
 
function getPresetByName(name) {
  return presetMap[name];
}
 
// ----------------------------------------------------------------------------
 
function addPreset(preset) {
  if (!preset.RGBPoints || preset.ColorSpace === 'CIELAB') {
    return;
  }
 
  if (!presetMap[preset.Name]) {
    rgbPresetNames.push(preset.Name);
    rgbPresetNames.sort();
  }
 
  presetMap[preset.Name] = preset;
}
 
// ----------------------------------------------------------------------------
 
function removePresetByName(name) {
  const index = rgbPresetNames.indexOf(name);
  if (index > -1) {
    rgbPresetNames.splice(index, 1);
  }
  delete presetMap[name];
}
 
// ----------------------------------------------------------------------------
 
export default {
  addPreset,
  removePresetByName,
  getPresetByName,
  rgbPresetNames,
};