Hello
I’m trying to build a custom LUT, but I can’t translate one example from python/c++ to javascript. My code fails at the line vtkLookupTable.setNumberOfTableValues(256) saying that it is not a function.
What is wrong here?
function buildLookupTable(){
// Same colors as for 2D
const grad = ["#FFFAFA", "#FFEDD6", "#FFE1B2", "#FFD58E", "#FFC96B",
"#FFBD47", "#FFB123", "#FFA500", "#FF8D00", "#FF7500", "#FF5E00",
"#FF4600", "#FF2F00", "#FF1700", "#FF0000"];
// Build the color transfer function
let ctransfer = vtk.Rendering.Core.vtkColorTransferFunction.newInstance();
for (i = 0; i < grad.length; i++) {
let color = hexToRgbA(grad[i]);
ctransfer.addRGBPoint(i, ...color);
}
ctransfer.build();
// Build the lookup table with 256 colors and 1/5 transparent
let numberOfColors = 256;
let lut = vtk.Common.Core.vtkLookupTable.newInstance();
lut.setNumberOfTableValues(numberOfColors);
for (i = 0; i < numberOfColors; i++) {
let rgb = ctransfer.getColor( ((i * grad.length)/numberOfColors ) );
lut.setTableValue(i, rgb[0],rgb[1],rgb[1], Math.min(1, i*5/numberOfColors));
}
lut.setNanColor(1,0,1,0);
lut.build();
return lut;
}
Best regards
Alex