Press "m" to cycle through color maps
Active Color Map: Gray
let demoFiles = [];
let counter = 0;
const getDemoFileNames = function () {
let demoFileList = [];
for (let i = 1; i < 25; i++) {
let filename = "anon" + i;
demoFileList.push(filename);
}
return demoFileList;
};
// init all
larvitar.initializeImageLoader();
larvitar.initializeCSTools();
larvitar.store.initialize();
larvitar.store.addViewport("viewer");
async function createFile(fileName, cb) {
let response = await fetch("./demo/" + fileName);
let data = await response.blob();
let file = new File([data], fileName);
demoFiles.push(file);
counter++;
if (counter == 24) {
cb();
}
}
function renderSerie() {
larvitar
.readFiles(demoFiles)
.then(seriesStack => {
// render the first series of the study
let seriesId = _.keys(seriesStack)[0];
let serie = seriesStack[seriesId];
larvitar.renderImage(serie, "viewer").then(() => {
console.log("Image has been rendered");
});
larvitar.addDefaultTools();
larvitar.setToolActive("Wwwc");
})
.catch(err => console.log(err));
}
let demoFileList = getDemoFileNames();
_.each(demoFileList, function (demoFile) {
createFile(demoFile, renderSerie);
});
let color_counter = 0;
document.onkeypress = function (e) {
e = e || window.event;
let color_maps = larvitar.getColormapsList();
color_counter =
color_counter == color_maps.length - 1 ? 0 : color_counter + 1;
let color_map = color_maps[color_counter];
if (e.keyCode == 109) {
larvitar.applyColorMap(color_map.id);
$("#active-color-map").html("Active Color Map: " + color_map.name);
}
};