{ "version": 3, "sources": [ "webpack://cornerstone/webpack/universalModuleDefinition", "webpack://cornerstone/webpack/bootstrap", "webpack://cornerstone/./events.js", "webpack://cornerstone/./enabledElements.js", "webpack://cornerstone/./internal/guid.js", "webpack://cornerstone/./internal/setDefaultViewport.js", "webpack://cornerstone/./internal/validator.js", "webpack://cornerstone/./internal/getImageSize.js", "webpack://cornerstone/./internal/getImageFitScale.js", "webpack://cornerstone/./internal/getDefaultViewport.js", "webpack://cornerstone/./internal/createViewport.js", "webpack://cornerstone/./internal/getDisplayedArea.js", "webpack://cornerstone/./internal/drawImage.js", "webpack://cornerstone/./updateImage.js", "webpack://cornerstone/./triggerEvent.js", "webpack://cornerstone/./layers.js", "webpack://cornerstone/./colors/lookupTable.js", "webpack://cornerstone/./colors/colormap.js", "webpack://cornerstone/./colors/index.js", "webpack://cornerstone/./pixelDataToFalseColorData.js", "webpack://cornerstone/./falseColorMapping.js", "webpack://cornerstone/./enabledElementData.js", "webpack://cornerstone/./imageCache.js", "webpack://cornerstone/./imageLoader.js", "webpack://cornerstone/./requestPool/RequestPoolManager.ts", "webpack://cornerstone/./requestPool/imageLoadPoolManager.ts", "webpack://cornerstone/./requestPool/imageRetrievalPoolManager.ts", "webpack://cornerstone/./internal/transform.js", "webpack://cornerstone/./internal/calculateTransform.js", "webpack://cornerstone/./internal/getTransform.js", "webpack://cornerstone/./canvasToPixel.js", "webpack://cornerstone/./disable.js", "webpack://cornerstone/./internal/now.js", "webpack://cornerstone/./displayImage.js", "webpack://cornerstone/./draw.js", "webpack://cornerstone/./drawInvalidated.js", "webpack://cornerstone/./fitToWindow.js", "webpack://cornerstone/./resize.js", "webpack://cornerstone/./internal/getFillStyle.js", "webpack://cornerstone/./internal/storedPixelDataToCanvasImageData.js", "webpack://cornerstone/./internal/storedPixelDataToCanvasImageDataRGBA.js", "webpack://cornerstone/./setToPixelCoordinateSystem.js", "webpack://cornerstone/./webgl/shaders/int16.js", "webpack://cornerstone/./webgl/shaders/int8.js", "webpack://cornerstone/./webgl/shaders/rgb.js", "webpack://cornerstone/./webgl/shaders/uint16.js", "webpack://cornerstone/./webgl/shaders/uint8.js", "webpack://cornerstone/./webgl/shaders/index.js", "webpack://cornerstone/./webgl/vertexShader.js", "webpack://cornerstone/./webgl/textureCache.js", "webpack://cornerstone/./webgl/createProgramFromString.js", "webpack://cornerstone/./webgl/renderer.js", "webpack://cornerstone/./webgl/index.js", "webpack://cornerstone/./internal/computeAutoVoi.js", "webpack://cornerstone/./rendering/lutMatches.js", "webpack://cornerstone/./internal/getModalityLUT.js", "webpack://cornerstone/./internal/getVOILut.js", "webpack://cornerstone/./internal/generateLut.js", "webpack://cornerstone/./rendering/getLut.js", "webpack://cornerstone/./rendering/doesImageNeedToBeRendered.js", "webpack://cornerstone/./rendering/initializeRenderCanvas.js", "webpack://cornerstone/./rendering/saveLastRendered.js", "webpack://cornerstone/./rendering/renderGrayscaleImage.js", "webpack://cornerstone/./internal/generateColorLut.js", "webpack://cornerstone/./internal/storedColorPixelDataToCanvasImageData.js", "webpack://cornerstone/./internal/storedRGBAPixelDataToCanvasImageData.js", "webpack://cornerstone/./rendering/renderColorImage.js", "webpack://cornerstone/./internal/storedPixelDataToCanvasImageDataPseudocolorLUT.js", "webpack://cornerstone/./rendering/renderPseudoColorImage.js", "webpack://cornerstone/./internal/storedPixelDataToCanvasImageDataColorLUT.js", "webpack://cornerstone/./rendering/renderLabelMapImage.js", "webpack://cornerstone/./internal/drawCompositeImage.js", "webpack://cornerstone/./internal/drawImageSync.js", "webpack://cornerstone/./internal/requestAnimationFrame.js", "webpack://cornerstone/./internal/tryEnableWebgl.js", "webpack://cornerstone/./internal/getCanvas.js", "webpack://cornerstone/./enable.js", "webpack://cornerstone/./generateUUID.js", "webpack://cornerstone/./getDefaultViewportForImage.js", "webpack://cornerstone/./getImage.js", "webpack://cornerstone/./getStoredPixels.js", "webpack://cornerstone/./getPixels.js", "webpack://cornerstone/./getViewport.js", "webpack://cornerstone/./internal/index.js", "webpack://cornerstone/./invalidate.js", "webpack://cornerstone/./invalidateImageId.js", "webpack://cornerstone/./metaData.js", "webpack://cornerstone/./pageToPixel.js", "webpack://cornerstone/./pixelToCanvas.js", "webpack://cornerstone/./rendering/renderToCanvas.js", "webpack://cornerstone/./rendering/renderWebImage.js", "webpack://cornerstone/./rendering/index.js", "webpack://cornerstone/./reset.js", "webpack://cornerstone/./setViewport.js", "webpack://cornerstone/./index.js" ], "names": [ "root", "factory", "exports", "module", "define", "amd", "window", "installedModules", "__webpack_require__", "moduleId", "i", "l", "modules", "call", "m", "c", "d", "name", "getter", "o", "Object", "defineProperty", "enumerable", "get", "r", "Symbol", "toStringTag", "value", "t", "mode", "__esModule", "ns", "create", "key", "bind", "n", "object", "property", "prototype", "hasOwnProperty", "p", "s", "events", "NEW_IMAGE", "INVALIDATED", "PRE_RENDER", "IMAGE_CACHE_MAXIMUM_SIZE_CHANGED", "IMAGE_CACHE_PROMISE_REMOVED", "IMAGE_CACHE_FULL", "IMAGE_CACHE_CHANGED", "WEBGL_TEXTURE_REMOVED", "WEBGL_TEXTURE_CACHE_FULL", "IMAGE_LOADED", "IMAGE_LOAD_PROGRESS", "IMAGE_LOAD_FAILED", "ELEMENT_RESIZED", "IMAGE_RENDERED", "LAYER_ADDED", "LAYER_REMOVED", "ACTIVE_LAYER_CHANGED", "ELEMENT_DISABLED", "ELEMENT_ENABLED", "events_events", "EventTarget", "_classCallCheck", "this", "listeners", "namespaces", "type", "callback", "indexOf", "addEventListener", "split", "removeEventListener", "addEventNamespaceListener", "push", "removeEventNamespaceListener", "stack", "length", "splice", "event", "slice", "defaultPrevented", "enabledElements_enabledElements", "getEnabledElement", "element", "undefined", "Error", "addEnabledElement", "enabledElement", "getEnabledElementsByImageId", "imageId", "ees", "forEach", "image", "getEnabledElements", "s4", "Math", "floor", "random", "toString", "substring", "state", "viewport", "setDefaultViewport", "validateParameterUndefinedOrNull", "checkParam", "errorMsg", "getImageSize", "rotation", "arguments", "width", "height", "getImageFitScale", "windowSize", "imageSize", "rowPixelSpacing", "columnPixelSpacing", "verticalRatio", "horizontalRatio", "verticalScale", "horizontalScale", "scaleFactor", "min", "getDefaultViewport", "canvas", "initialDefaultViewport", "scale", "translation", "x", "y", "voi", "windowWidth", "windowCenter", "invert", "pixelReplication", "hflip", "vflip", "modalityLUT", "voiLUT", "colormap", "labelmap", "displayedArea", "assign", "Boolean", "getDisplayedArea", "tlhc", "brhc", "columns", "rows", "presentationSizeMode", "drawImage", "invalidated", "needsRedraw", "invalid", "updateImage", "triggerEvent", "el", "detail", "CustomEvent", "cancelable", "document", "createEvent", "initCustomEvent", "dispatchEvent", "triggerEventForLayer", "eventName", "layerId", "rescaleImage", "baseLayer", "targetLayer", "baseImage", "targetImage", "targetDisplayedArea", "baseDisplayedArea", "colRelative", "viewportRatio", "addLayer", "options", "concat", "layers", "syncViewports", "newLayer", "renderingTools", "setActiveLayer", "removeLayer", "index", "findIndex", "layer", "activeLayerId", "getLayer", "find", "getLayers", "getVisibleLayers", "filter", "visible", "opacity", "setLayerImage", "getActiveLayer", "defaultViewport", "purgeLayers", "lastSyncViewportsState", "HSVToRGB", "hue", "sat", "val", "rgb", "hueCase", "frac", "lx", "ly", "lz", "colors_lookupTable", "LookupTable", "lookupTable_classCallCheck", "NumberOfColors", "Ramp", "TableRange", "HueRange", "SaturationRange", "ValueRange", "AlphaRange", "NaNColor", "BelowRangeColor", "UseBelowRangeColor", "AboveRangeColor", "UseAboveRangeColor", "InputRange", "Table", "number", "ramp", "start", "end", "scalar", "mapValue", "force", "hinc", "sinc", "vinc", "ainc", "maxIndex", "alpha", "c_rgba", "cos", "PI", "sqrt", "buildSpecialColors", "numberOfColors", "belowRangeColorIndex", "aboveRangeColorIndex", "nanColorIndex", "v", "getIndex", "MaxIndex", "Shift", "Scale", "Number", "MAX_VALUE", "Range", "isNaN", "dIndex", "rgba", "Array", "COLOR_TRANSPARENT", "colormapsData", "hotIron", "numOfColors", "colors", "pet", "numColors", "hotMetalBlue", "pet20Step", "gray", "gamma", "segmentedData", "red", "green", "blue", "jet", "hsv", "hot", "cool", "spring", "summer", "autumn", "winter", "bone", "copper", "spectral", "coolwarm", "blues", "getRank", "array", "elem", "left", "right", "mid", "midElem", "makeMappingArray", "N", "data", "y0", "y1", "lut", "xLinSpace", "a", "b", "increment", "vector", "linspace", "pow", "xLinSpaceIndexes", "inputArray", "values", "indexes", "len", "sort", "searchSorted", "colorPercent", "colorDelta", "getColormap", "id", "colormapData", "redLut", "greenLut", "blueLut", "round", "createLinearSegmentedColormap", "getId", "getColorSchemeName", "setColorSchemeName", "getNumberOfColors", "setNumberOfColors", "getColor", "isValidIndex", "getColorRepeating", "setColor", "addColor", "insertColor", "removeColor", "clearColors", "buildLookupTable", "setNumberOfTableValues", "setTableValue", "createLookupTable", "getColormapsList", "colormaps", "keys", "aName", "toLowerCase", "bName", "pixelDataToFalseColorData", "lookupTable", "color", "falseColor", "sp", "mapped", "minPixelValue", "canvasImageDataIndex", "storedPixelDataIndex", "numPixels", "origPixelData", "getPixelData", "storedColorPixelData", "Uint8Array", "build", "cachedLut", "render", "slope", "intercept", "maxPixelValue", "restoreImage", "restore", "convertImageToFalseColorImage", "colormapId", "pixelData", "getRestoreImageMethod", "setTableRange", "pixelValues", "pixel", "MIN_VALUE", "getPixelValues", "convertToFalseColorImage", "getElementData", "dataType", "ee", "removeElementData", "maximumSizeInBytes", "cacheSizeInBytes", "imageCacheDict", "cachedImages", "purgeCacheIfNecessary", "timeStamp", "removeImageLoadObject", "cacheInfo", "getCacheInfo", "putImageLoadObject", "imageLoadObject", "promise", "cancelFn", "cachedImage", "loaded", "sharedCacheKey", "Date", "now", "sizeInBytes", "then", "toFixed", "eventDetails", "action", "getImageLoadObject", "decache", "numberOfImagesCached", "unknownImageLoader", "imageCache", "setMaximumSizeBytes", "numBytes", "purgeCache", "changeImageIdCacheSize", "newCacheSize", "cacheEntry", "cacheSizeDifference", "imageLoaders", "loadImageFromImageLoader", "colonIndex", "scheme", "loader", "error", "errorObject", "loadImage", "loadAndCacheImage", "registerImageLoader", "imageLoader", "registerUnknownImageLoader", "oldImageLoader", "RequestPoolManager", "RequestPoolManager_classCallCheck", "_defineProperty", "requestPool", "interaction", "0", "thumbnail", "prefetch", "awake", "grabDelay", "numRequests", "maxNumRequests", "timeoutHandle", "clearTimeout", "requestFn", "additionalDetails", "priority", "addToBeginning", "requestDetails", "unshift", "startGrabbing", "filterFunction", "_this", "requestType", "_ref", "_this2", "startAgain", "requestsToSend", "getNextRequest", "sendRequest", "_this3", "setTimeout", "_this4", "map", "_step", "interactionPriorities", "getSortedPriorityGroups", "_iterator", "_createForOfIteratorHelper", "done", "shift", "err", "e", "f", "_step2", "thumbnailPriorities", "_iterator2", "_step3", "prefetchPriorities", "_iterator3", "imageLoadPoolManager", "requestPool_imageLoadPoolManager", "imageRetrievalPoolManager", "requestPool_imageRetrievalPoolManager", "Transform", "transform_classCallCheck", "reset", "transform", "matrix", "m11", "m12", "m21", "m22", "dx", "dy", "m0", "m1", "m2", "m3", "m4", "m5", "rad", "sin", "sx", "sy", "px", "py", "calculateTransform", "translate", "angle", "rotate", "widthScale", "heightScale", "imageDisplayedArea", "offsetX", "offsetY", "getTransform", "canvasToPixel", "pt", "transformPoint", "disable", "enabledElements", "eventData", "removeChild", "performance", "displayImage", "frameRate", "oldImage", "attrname", "lastImageTimeStamp", "newImageEventData", "draw_0", "drawInvalidated", "fitToWindow", "resize", "forceFitToWindow", "oldCanvasWidth", "oldCanvasHeight", "clientWidth", "style", "clientHeight", "relWidthChange", "relHeightChange", "relChange", "imageWidth", "imageHeight", "getFillStyle", "fillStyle", "storedPixelDataToCanvasImageData", "canvasImageDataData", "stats", "lastGetPixelDataTime", "Int16Array", "Uint16Array", "lastStoredPixelDataToCanvasImageDataTime", "storedPixelDataToCanvasImageDataRGBA", "pixelValue", "setToPixelCoordinateSystem", "context", "setTransform", "int16Shader", "int16DataUtilities", "storedPixelDataToImageData", "offset", "abs", "frag", "int8Shader", "int8DataUtilities", "rgbShader", "rgbDataUtilities", "numStoredPixels", "numOutputPixels", "storedPixelData", "uint16Shader", "uint16DataUtilities", "uint8Shader", "uint8DataUtilities", "shaders", "int16", "int8", "uint16", "uint8", "dataUtilities", "vertexShader", "textureCache_imageCache", "textureCache_cachedImages", "textureCache_maximumSizeInBytes", "textureCache_cacheSizeInBytes", "textureCache_purgeCacheIfNecessary", "lastCachedImage", "pop", "textureCache", "removedCachedImage", "getImageTexture", "imageTexture", "putImageTexture", "removeImageTexture", "compileShader", "gl", "shaderSource", "shaderType", "shader", "createShader", "getShaderParameter", "COMPILE_STATUS", "isContextLost", "infoLog", "getShaderInfoLog", "console", "texCoordBuffer", "positionBuffer", "createProgramFromString", "vertexShaderSrc", "fragShaderSrc", "fragmentShader", "program", "createProgram", "attachShader", "linkProgram", "getProgramParameter", "LINK_STATUS", "getProgramInfoLog", "VERTEX_SHADER", "FRAGMENT_SHADER", "renderer_renderCanvas", "createElement", "isWebGLInitialized", "initRenderer", "desynchronized", "preserveDrawingBuffer", "getContext", "handleLostContext", "handleRestoredContext", "initWebGL", "createBuffer", "bindBuffer", "ARRAY_BUFFER", "bufferData", "Float32Array", "STATIC_DRAW", "attributes", "uniforms", "vert", "texCoordLocation", "getAttribLocation", "enableVertexAttribArray", "positionLocation", "resolutionLocation", "getUniformLocation", "initShaders", "preventDefault", "warn", "getImageDataType", "Int8Array", "renderer_getImageTexture", "TEXTURE_FORMAT", "LUMINANCE", "LUMINANCE_ALPHA", "RGB", "imageDataType", "format", "texture", "createTexture", "bindTexture", "TEXTURE_2D", "texParameteri", "TEXTURE_MIN_FILTER", "NEAREST", "TEXTURE_MAG_FILTER", "TEXTURE_WRAP_S", "CLAMP_TO_EDGE", "TEXTURE_WRAP_T", "pixelStorei", "UNPACK_ALIGNMENT", "imageData", "texImage2D", "UNSIGNED_BYTE", "generateTexture", "renderQuad", "parameters", "clearColor", "clear", "COLOR_BUFFER_BIT", "DEPTH_BUFFER_BIT", "useProgram", "vertexAttribPointer", "FLOAT", "uniformLocation", "uniform", "uniform1i", "uniform1f", "uniform2f", "activeTexture", "TEXTURE0", "drawArrays", "TRIANGLE_STRIP", "mod", "renderer", "datatype", "u_resolution", "wc", "ww", "getRenderCanvas", "isWebGLAvailable", "failIfMajorPerformanceCaveat", "WebGLRenderingContext", "configurable", "webgl", "computeAutoVoi", "maxVoi", "minVoi", "lutMatches", "getModalityLUT", "minValue", "maxValue", "maxValueMapped", "firstValueMapped", "storedPixelValue", "getVOILut", "roundModalityLUTValues", "max", "apply", "_toConsumableArray", "modalityLutValue", "generateLut", "lutArray", "Uint8ClampedArray", "slopeOrInterceptAreFloat", "mlutfn", "vlutfn", "storedValue", "getLut", "doesImageNeedToBeRendered", "lastRenderedImageId", "lastRenderedViewport", "initializeRenderCanvas", "renderCanvas", "canvasContext", "fillRect", "renderCanvasData", "getImageData", "renderCanvasContext", "saveLastRendered", "isColor", "lastRenderedIsColor", "renderGrayscaleImage_getRenderCanvas", "useAlphaChannel", "canvasWasColor", "lastLutGenerateTime", "putImageData", "lastPutImageDataTime", "renderGrayscaleImage", "imageSmoothingEnabled", "mozImageSmoothingEnabled", "generateColorLut", "storedColorPixelDataToCanvasImageData", "storedRGBAPixelDataToCanvasImageData", "renderColorImage_getRenderCanvas", "getCanvas", "colorLut", "renderColorImage", "internal_storedPixelDataToCanvasImageDataPseudocolorLUT", "grayscaleLut", "clut", "renderPseudoColorImage_getRenderCanvas", "renderPseudoColorImage", "internal_storedPixelDataToCanvasImageDataColorLUT", "renderLabelMapImage_getRenderCanvas", "renderLabelMapImage", "updateLayerSyncProps", "syncProps", "originalScale", "activeLayer", "renderLayers", "save", "isInvalid", "addLabelMapLayer", "addPseudoColorLayer", "addColorLayer", "addGrayscaleLayer", "globalAlpha", "layerDisplayedArea", "drawImageSync", "lastRenderTime", "allLayers", "visibleLayers", "resynced", "drawCompositeImage", "renderTimeInMs", "requestAnimationFrame", "webkitRequestAnimationFrame", "mozRequestAnimationFrame", "oRequestAnimationFrame", "msRequestAnimationFrame", "tryEnableWebgl", "CANVAS_CSS_CLASS", "selector", "querySelector", "display", "classList", "add", "appendChild", "enable", "uuid", "getTime", "replace", "draw", "timestamp", "getDefaultViewportForImage", "getImage", "getStoredPixels", "storedPixels", "row", "column", "spIndex", "getPixels", "getViewport", "internal", "storedPixelDataToCanvasImageDataColorLUT", "storedPixelDataToCanvasImageDataPseudocolorLUT", "invalidate", "invalidateImageId", "providers", "metaData", "addProvider", "provider", "removeProvider", "result", "pageToPixel", "pageX", "pageY", "rect", "getBoundingClientRect", "pageXOffset", "top", "pageYOffset", "pixelToCanvas", "renderToCanvas", "enabledElementStub", "renderWebImage", "rendering", "colorImage", "grayscaleImage", "webImage", "pseudoColorImage", "labelMapImage", "toCanvas", "reset_0", "setViewport", "__webpack_exports__", "cornerstone", "webGL", "EVENTS" ], "mappings": ";CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,IACA,mBAAAG,eAAAC,IACAD,OAAA,sBAAAH,GACA,iBAAAC,QACAA,QAAA,oBAAAD,IAEAD,EAAA,YAAAC,IARA,CASCK,OAAA,WACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAP,QAGA,IAAAC,EAAAI,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAT,QAAA,IAUA,OANAU,EAAAH,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAQ,GAAA,EAGAR,EAAAD,QA0DA,OArDAM,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CV,EAAAgB,EAAA,SAAAtB,GACA,oBAAAuB,eAAAC,aACAN,OAAAC,eAAAnB,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nQ,EAAAQ,EAAAs0B,EAAA,kDAAAje,IAAA7W,EAAAQ,EAAAs0B,EAAA,6CAAAxd,IAAAtX,EAAAQ,EAAAs0B,EAAA,iCAAAne,IAAA3W,EAAAQ,EAAAs0B,EAAA,2BAAA5yB,IAAAlC,EAAAQ,EAAAs0B,EAAA,2BAAAxxB,IAAAtD,EAAAQ,EAAAs0B,EAAA,iCAAA1rB,IAAApJ,EAAAQ,EAAAs0B,EAAA,yCAAAhX,KAAA9d,EAAAQ,EAAAs0B,EAAA,8CAAA9W,KAAAhe,EAAAQ,EAAAs0B,EAAA,uCAAAna,KA6FA,IAAMoa,GAAc,CAClBhsB,YACAkkB,eACA7lB,qBACA8pB,yBACAjP,oCACA+M,yCACA+D,yCAAApD,GACAqD,+CAAA1D,GACAwD,YACAjD,uBACAH,0BACAL,oBACAT,wBACAwF,kBACAF,kBACAhU,iBACAG,WACAK,gBACAyR,KAAAnR,GACAC,mBACA8Q,UACAxa,iBACAG,oBACA9S,oBACAI,oBACAE,8BACAK,qBACAkF,WACAQ,cACAK,WACAE,YACAC,mBACAT,iBACAc,iBACAE,cACAH,gBACAqV,eACAmR,8BACA5pB,mBACAzC,qBACAssB,YACAM,aACAL,mBACAM,eACAxY,aACAC,qBACAC,uBACAE,8BACAwY,cACAC,qBACAO,eACAQ,iBACA9V,MAAAyW,GACAzT,UACAuB,8BACAmS,eACA1rB,cACAoM,4BACA8e,aACA/a,cACA8Z,YACA4B,MAAAhJ,GACA7b,SACA0G,gCACAS,2BACAX,eACAse,OAAA/yB,EACAA,OAAAoB,EACA8F,eACAyU,qBAAAC,GACAC,0BAAAC,GACArD,uBA8Eama,EAAA", "file": "cornerstone.min.js", "sourcesContent": [ "(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"cornerstone-core\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cornerstone-core\"] = factory();\n\telse\n\t\troot[\"cornerstone\"] = factory();\n})(window, function() {\nreturn ", " \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n", "const EVENTS = {\n NEW_IMAGE: 'cornerstonenewimage',\n INVALIDATED: 'cornerstoneinvalidated',\n PRE_RENDER: 'cornerstoneprerender',\n IMAGE_CACHE_MAXIMUM_SIZE_CHANGED: 'cornerstoneimagecachemaximumsizechanged',\n IMAGE_CACHE_PROMISE_REMOVED: 'cornerstoneimagecachepromiseremoved',\n IMAGE_CACHE_FULL: 'cornerstoneimagecachefull',\n IMAGE_CACHE_CHANGED: 'cornerstoneimagecachechanged',\n WEBGL_TEXTURE_REMOVED: 'cornerstonewebgltextureremoved',\n WEBGL_TEXTURE_CACHE_FULL: 'cornerstonewebgltexturecachefull',\n IMAGE_LOADED: 'cornerstoneimageloaded',\n IMAGE_LOAD_PROGRESS: 'cornerstoneimageloadprogress',\n IMAGE_LOAD_FAILED: 'cornerstoneimageloadfailed',\n ELEMENT_RESIZED: 'cornerstoneelementresized',\n IMAGE_RENDERED: 'cornerstoneimagerendered',\n LAYER_ADDED: 'cornerstonelayeradded',\n LAYER_REMOVED: 'cornerstonelayerremoved',\n ACTIVE_LAYER_CHANGED: 'cornerstoneactivelayerchanged',\n ELEMENT_DISABLED: 'cornerstoneelementdisabled',\n ELEMENT_ENABLED: 'cornerstoneelementenabled'\n};\n\nexport default EVENTS;\n\n/**\n * EventTarget - Provides the [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) interface\n *\n * @class\n * @memberof Polyfills\n */\nclass EventTarget {\n constructor () {\n this.listeners = {};\n this.namespaces = {};\n }\n\n addEventNamespaceListener (type, callback) {\n if (type.indexOf('.') <= 0) {\n return;\n }\n\n this.namespaces[type] = callback;\n this.addEventListener(type.split('.')[0], callback);\n }\n\n removeEventNamespaceListener (type) {\n if (type.indexOf('.') <= 0 || !this.namespaces[type]) {\n return;\n }\n\n this.removeEventListener(type.split('.')[0], this.namespaces[type]);\n delete this.namespaces[type];\n }\n\n addEventListener (type, callback) {\n // Check if it is an event namespace\n if (type.indexOf('.') > 0) {\n this.addEventNamespaceListener(type, callback);\n\n return;\n }\n\n if (!(type in this.listeners)) {\n this.listeners[type] = [];\n }\n\n this.listeners[type].push(callback);\n }\n\n removeEventListener (type, callback) {\n // Check if it is an event namespace\n if (type.indexOf('.') > 0) {\n this.removeEventNamespaceListener(type);\n\n return;\n }\n\n if (!(type in this.listeners)) {\n return;\n }\n\n const stack = this.listeners[type];\n\n for (let i = 0, l = stack.length; i < l; i++) {\n if (stack[i] === callback) {\n stack.splice(i, 1);\n\n return;\n }\n }\n }\n\n dispatchEvent (event) {\n if (!(event.type in this.listeners)) {\n return true;\n }\n\n const stack = this.listeners[event.type].slice();\n\n for (let i = 0, l = stack.length; i < l; i++) {\n stack[i].call(this, event);\n }\n\n return !event.defaultPrevented;\n }\n}\n\n\nexport const events = new EventTarget();\n", "const enabledElements = [];\n\n/**\n * @module EnabledElements\n */\n\n/**\n * @module Objects\n */\n\n/**\n * A two-dimensional vector\n *\n * @typedef {Object} vec2\n * @memberof Objects\n * @param {Number} x - The x distance\n * @param {Number} y - The y distance\n */\n\n/**\n * VOI\n *\n * @typedef {Object} VOI\n * @memberof Objects\n * @param {Number} windowWidth - Window Width for display\n * @param {Number} windowCenter - Window Center for display\n */\n\n/**\n * Lookup Table Array\n *\n * @typedef {Object} LUT\n * @memberof Objects\n * @property {Number} firstValueMapped\n * @property {Number} numBitsPerEntry\n * @property {Array} lut\n */\n\n/**\n * Image Statistics Object\n *\n * @typedef {Object} ImageStats\n * @memberof Objects\n * @property {Number} [lastGetPixelDataTime] The time in ms taken to retrieve stored pixels required to draw the image\n * @property {Number} [lastStoredPixelDataToCanvasImageDataTime] The time in ms taken to map from stored pixel array to canvas pixel array\n * @property {Number} [lastPutImageDataTime] The time in ms taken for putImageData to put the canvas pixel data into the canvas context\n * @property {Number} [lastRenderTime] The total time in ms taken for the entire rendering function to run\n * @property {Number} [lastLutGenerateTime] The time in ms taken to generate the lookup table for the image\n */\n\n/**\n * An Image Object in Cornerstone\n *\n * @typedef {Object} Image\n * @memberof Objects\n * @property {string} imageId - The imageId associated with this image object\n * @property {Number} minPixelValue - the minimum stored pixel value in the image\n * @property {Number} maxPixelValue - the maximum stored pixel value in the image\n * @property {Number} slope - the rescale slope to convert stored pixel values to modality pixel values or 1 if not specified\n * @property {Number} intercept - the rescale intercept used to convert stored pixel values to modality values or 0 if not specified\n * @property {Number} windowCenter - the default windowCenter to apply to the image\n * @property {Number} windowWidth - the default windowWidth to apply to the image\n * @property {function} getPixelData - a function that returns the underlying pixel data. An array of integers for grayscale and an array of RGBA for color\n * @property {function} getImageData - a function that returns a canvas imageData object for the image. This is only needed for color images\n * @property {function} getCanvas - a function that returns a canvas element with the image loaded into it. This is only needed for color images.\n * @property {function} getImage - a function that returns a JavaScript Image object with the image data. This is optional and typically used for images encoded in standard web JPEG and PNG formats\n * @property {Number} rows - number of rows in the image. This is the same as height but duplicated for convenience\n * @property {Number} columns - number of columns in the image. This is the same as width but duplicated for convenience\n * @property {Number} height - the height of the image. This is the same as rows but duplicated for convenience\n * @property {Number} width - the width of the image. This is the same as columns but duplicated for convenience\n * @property {Boolean} color - true if pixel data is RGB, false if grayscale\n * @property {Object} lut - The Lookup Table\n * @property {Boolean} rgba - Is the color pixel data stored in RGBA?\n * @property {Number} columnPixelSpacing - horizontal distance between the middle of each pixel (or width of each pixel) in mm or undefined if not known\n * @property {Number} rowPixelSpacing - vertical distance between the middle of each pixel (or height of each pixel) in mm or undefined if not known\n * @property {Boolean} invert - true if the the image should initially be displayed be inverted, false if not. This is here mainly to support DICOM images with a photometric interpretation of MONOCHROME1\n * @property {Number} sizeInBytes - the number of bytes used to store the pixels for this image.\n * @property {Boolean} [falseColor=false] - Whether or not the image has undergone false color mapping\n * @property {Array} [origPixelData] - Original pixel data for an image after it has undergone false color mapping\n * @property {ImageStats} [stats] - Statistics for the last redraw of the image\n * @property {Object} cachedLut - Cached Lookup Table for this image.\n * @property {String|Colormap} [colormap] - Depreacted. Use viewport.colormap instead. an optional colormap ID or colormap object (from colors/colormap.js). This will be applied during rendering to convert the image to pseudocolor\n * @property {Boolean} [labelmap=false] - whether or not to render this image as a label map (i.e. skip modality and VOI LUT pipelines and use only a color lookup table)\n */\n\n/**\n * A Viewport Settings Object Cornerstone\n *\n * @typedef {Object} Viewport\n * @memberof Objects\n * @property {Number} [scale=1.0] - The scale applied to the image. A scale of 1.0 will display no zoom (one image pixel takes up one screen pixel). A scale of 2.0 will be double zoom and a scale of .5 will be zoomed out by 2x\n * @property {vec2} [translation] - An object with properties x and y which describe the translation to apply in the pixel coordinate system. Note that the image is initially displayed centered in the enabled element with a x and y translation of 0 and 0 respectively.\n * @property {VOI} [voi] - an object with properties windowWidth and windowCenter.\n * @property {boolean} [invert=false] - Whether or not the image is inverted.\n * @property {boolean} [pixelReplication=false] - true if the image smooth / interpolation should be used when zoomed in on the image or false if pixel replication should be used.\n * @property {boolean} [hflip=false] - true if the image is flipped horizontally. Default is false\n * @property {boolean} [vflip=false] - true if the image is flipped vertically. Default is false\n * @property {Number} [rotation=0] - the rotation of the image (90 degree increments). Default is 0\n * @property {LUT} [modalityLUT] - the modality LUT to apply or undefined if none\n * @property {LUT} [voiLUT] - the modality LUT to apply or undefined if none\n * @property {String|Colormap} [colormap] - an optional colormap ID or colormap object (from colors/colormap.js). This will be applied during rendering to convert the image to pseudocolor\n * @property {Boolean} [labelmap=false] - whether or not to render this image as a label map (i.e. skip modality and VOI LUT pipelines and use only a color lookup table)\n */\n\n/**\n * An Enabled Element in Cornerstone\n *\n * @typedef {Object} EnabledElement\n * @memberof Objects\n * @property {HTMLElement} element - The DOM element which has been enabled for use by Cornerstone\n * @property {Image} [image] - The image currently displayed in the enabledElement\n * @property {Viewport} [viewport] - The current viewport settings of the enabledElement\n * @property {HTMLCanvasElement} [canvas] - The current canvas for this enabledElement\n * @property {Boolean} invalid - Whether or not the image pixel data underlying the enabledElement has been changed, necessitating a redraw\n * @property {Boolean} needsRedraw - A flag for triggering a redraw of the canvas without re-retrieving the pixel data, since it remains valid\n * @property {EnabledElementLayer[]} [layers] - The layers that have been added to the enabledElement\n * @property {Boolean} [syncViewports] - Whether or not to synchronize the viewport parameters\n * for each of the enabled element's layers\n * @property {Boolean} [lastSyncViewportsState] - The previous state for the sync viewport boolean\n */\n\n/**\n * An Enabled Element Layer in Cornerstone\n *\n * @typedef {Object} EnabledElementLayer\n * @memberof Objects\n * @property {HTMLElement} element - The DOM element which has been enabled for use by Cornerstone\n * @property {Image} [image] - The image currently displayed in the enabledElement\n * @property {Viewport} [viewport] - The current viewport settings of the enabledElement\n * @property {HTMLCanvasElement} [canvas] - The current canvas for this enabledElement\n * @property {Object} [options] - Layer drawing options\n * @property {Boolean} invalid - Whether or not the image pixel data underlying the enabledElement has been changed, necessitating a redraw\n * @property {Boolean} needsRedraw - A flag for triggering a redraw of the canvas without re-retrieving the pixel data, since it remains valid\n */\n\n/**\n * An Image Load Object\n *\n * @typedef {Object} ImageLoadObject\n * @memberof Objects\n * @property {Promise} promise - The Promise tracking the loading of this image\n * @property {Function|undefined} cancelFn - A function to cancel the image load request\n */\n\n/**\n * Retrieves a Cornerstone Enabled Element object\n *\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\n *\n * @returns {EnabledElement} A Cornerstone Enabled Element\n * @memberof EnabledElements\n */\nexport function getEnabledElement (element) {\n if (element === undefined) {\n throw new Error('getEnabledElement: parameter element must not be undefined');\n }\n for (let i = 0; i < enabledElements.length; i++) {\n if (enabledElements[i].element === element) {\n return enabledElements[i];\n }\n }\n\n throw new Error('element not enabled');\n}\n\n/**\n * Adds a Cornerstone Enabled Element object to the central store of enabledElements\n *\n * @param {EnabledElement} enabledElement A Cornerstone enabledElement Object\n * @returns {void}\n * @memberof EnabledElements\n */\nexport function addEnabledElement (enabledElement) {\n if (enabledElement === undefined) {\n throw new Error('getEnabledElement: enabledElement element must not be undefined');\n }\n\n enabledElements.push(enabledElement);\n}\n\n/**\n * Adds a Cornerstone Enabled Element object to the central store of enabledElements\n *\n * @param {string} imageId A Cornerstone Image ID\n * @returns {EnabledElement[]} An Array of Cornerstone enabledElement Objects\n * @memberof EnabledElements\n */\nexport function getEnabledElementsByImageId (imageId) {\n const ees = [];\n\n enabledElements.forEach(function (enabledElement) {\n if (enabledElement.image && enabledElement.image.imageId === imageId) {\n ees.push(enabledElement);\n }\n });\n\n return ees;\n}\n\n/**\n * Retrieve all of the currently enabled Cornerstone elements\n *\n * @return {EnabledElement[]} An Array of Cornerstone enabledElement Objects\n * @memberof EnabledElements\n */\nexport function getEnabledElements () {\n return enabledElements;\n}\n", "function s4 () {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16).\n substring(1);\n}\n\n/**\n * Generate a unique identifier\n *\n * @return {string} A unique identifier\n * @memberof Internal\n */\nexport default function () {\n return `${s4() + s4()}-${s4()}-${s4()}-${\n s4()}-${s4()}${s4()}${s4()}`;\n}\n", "const state = {\n viewport: {}\n};\n\n/**\n * Sets new default values for `getDefaultViewport`\n *\n * @param {Object} viewport - Object that sets new default values for getDefaultViewport\n * @returns {undefined}\n */\nexport default function (viewport) {\n state.viewport = viewport || {};\n}\n\nexport { state };\n", "\n/**\n * Check if the supplied parameter is undefined and throws and error\n * @param {any} checkParam the parameter to validate for undefined\n * @param {any} errorMsg the error message to be thrown\n * @returns {void}\n * @memberof internal\n */\nexport function validateParameterUndefined (checkParam, errorMsg) {\n if (checkParam === undefined) {\n throw new Error(errorMsg);\n }\n}\n\n\n/**\n * Check if the supplied parameter is undefined or null and throws and error\n * @param {any} checkParam the parameter to validate for undefined\n * @param {any} errorMsg the error message to be thrown\n * @returns {void}\n * @memberof internal\n */\nexport function validateParameterUndefinedOrNull (checkParam, errorMsg) {\n if (checkParam === undefined || checkParam === null) {\n throw new Error(errorMsg);\n }\n}\n", "import { validateParameterUndefinedOrNull } from './validator.js';\n\n/**\n * Check if the angle is rotated\n * @param {Number} rotation the rotation angle\n * @returns {Boolean} true if the angle is rotated; Otherwise, false.\n * @memberof Internal\n */\nfunction isRotated (rotation) {\n return !(rotation === null || rotation === undefined || rotation === 0 || rotation === 180);\n}\n\n/**\n * Retrieves the current image dimensions given an enabled element\n *\n * @param {any} image The Cornerstone image.\n * @param {Number} rotation Optional. The rotation angle of the image.\n * @return {{width:Number, height:Number}} The Image dimensions\n * @memberof Internal\n */\nexport default function (image, rotation = null) {\n\n validateParameterUndefinedOrNull(image, 'getImageSize: parameter image must not be undefined');\n validateParameterUndefinedOrNull(image.width, 'getImageSize: parameter image must have width');\n validateParameterUndefinedOrNull(image.height, 'getImageSize: parameter image must have height');\n\n\n if (isRotated(rotation)) {\n return {\n height: image.width,\n width: image.height\n };\n }\n\n return {\n width: image.width,\n height: image.height\n };\n}\n", "import { validateParameterUndefinedOrNull } from './validator.js';\nimport getImageSize from './getImageSize.js';\n\n\n/**\n * Calculates the horizontal, vertical and minimum scale factor for an image\n @param {{width, height}} windowSize The window size where the image is displayed. This can be any HTML element or structure with a width, height fields (e.g. canvas).\n * @param {any} image The cornerstone image object\n * @param {Number} rotation Optional. The rotation angle of the image.\n * @return {{horizontalScale, verticalScale, scaleFactor}} The calculated horizontal, vertical and minimum scale factor\n * @memberof Internal\n */\nexport default function (windowSize, image, rotation = null) {\n\n validateParameterUndefinedOrNull(windowSize, 'getImageScale: parameter windowSize must not be undefined');\n validateParameterUndefinedOrNull(image, 'getImageScale: parameter image must not be undefined');\n\n const imageSize = getImageSize(image, rotation);\n const rowPixelSpacing = image.rowPixelSpacing || 1;\n const columnPixelSpacing = image.columnPixelSpacing || 1;\n let verticalRatio = 1;\n let horizontalRatio = 1;\n\n if (rowPixelSpacing < columnPixelSpacing) {\n horizontalRatio = columnPixelSpacing / rowPixelSpacing;\n } else {\n // even if they are equal we want to calculate this ratio (the ration might be 0.5)\n verticalRatio = rowPixelSpacing / columnPixelSpacing;\n }\n\n const verticalScale = windowSize.height / imageSize.height / verticalRatio;\n const horizontalScale = windowSize.width / imageSize.width / horizontalRatio;\n\n // Fit image to window\n return {\n verticalScale,\n horizontalScale,\n scaleFactor: Math.min(horizontalScale, verticalScale)\n };\n}\n", "import createViewport from './createViewport.js';\nimport getImageFitScale from './getImageFitScale.js';\n\n/**\n * Creates a new viewport object containing default values for the image and canvas\n *\n * @param {HTMLElement} canvas A Canvas DOM element\n * @param {Image} image A Cornerstone Image Object\n * @returns {Viewport} viewport object\n * @memberof Internal\n */\nexport default function (canvas, image) {\n if (canvas === undefined) {\n throw new Error('getDefaultViewport: parameter canvas must not be undefined');\n }\n\n if (image === undefined) {\n return createViewport();\n }\n\n // Fit image to window\n const scale = getImageFitScale(canvas, image, 0).scaleFactor;\n\n return {\n scale,\n translation: {\n x: 0,\n y: 0\n },\n voi: {\n windowWidth: image.windowWidth,\n windowCenter: image.windowCenter\n },\n invert: image.invert,\n pixelReplication: false,\n rotation: 0,\n hflip: false,\n vflip: false,\n modalityLUT: image.modalityLUT,\n voiLUT: image.voiLUT,\n colormap: image.colormap,\n labelmap: Boolean(image.labelmap),\n displayedArea: undefined\n };\n}\n", "import { state } from './setDefaultViewport.js';\n\n/**\n * Creates a new viewport object containing default values\n *\n * @returns {Viewport} viewport object\n * @memberof Internal\n */\nexport default function () {\n const initialDefaultViewport = {\n scale: 1,\n translation: {\n x: 0,\n y: 0\n },\n voi: {\n windowWidth: undefined,\n windowCenter: undefined\n },\n invert: false,\n pixelReplication: false,\n rotation: 0,\n hflip: false,\n vflip: false,\n modalityLUT: undefined,\n voiLUT: undefined,\n colormap: undefined,\n labelmap: false,\n displayedArea: undefined\n };\n\n return Object.assign({}, initialDefaultViewport, state.viewport);\n}\n", "/**\n * Returns the displayedArea from the viewport if exists or\n * creates a new displayedArea object containing default values for the image\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {Viewport} viewport An optional viewport Object\n * @returns {DisplayedArea} displayedArea object\n * @memberof Internal\n */\nexport default function (image, viewport = null) {\n if (viewport && viewport.displayedArea) {\n return viewport.displayedArea;\n }\n\n if (image === undefined) {\n throw new Error('getDisplayedArea: parameter image must not be undefined');\n }\n\n return {\n tlhc: {\n x: 1,\n y: 1\n },\n brhc: {\n x: image.columns,\n y: image.rows\n },\n rowPixelSpacing: image.rowPixelSpacing === undefined ? 1 : image.rowPixelSpacing,\n columnPixelSpacing: image.columnPixelSpacing === undefined ? 1 : image.columnPixelSpacing,\n presentationSizeMode: 'NONE'\n };\n}\n", "/**\n * Internal API function to draw an image to a given enabled element\n *\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element to redraw\n * @param {Boolean} [invalidated = false] - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n * @memberof Internal\n */\nexport default function (enabledElement, invalidated = false) {\n enabledElement.needsRedraw = true;\n if (invalidated) {\n enabledElement.invalid = true;\n }\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport drawImage from './internal/drawImage.js';\n\n/**\n * Forces the image to be updated/redrawn for the specified enabled element\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\n * @param {Boolean} [invalidated=false] Whether or not the image pixel data has been changed, necessitating a redraw\n *\n * @returns {void}\n * @memberof Drawing\n */\nexport default function (element, invalidated = false) {\n const enabledElement = getEnabledElement(element);\n\n drawImage(enabledElement, invalidated);\n}\n", "/**\n * Trigger a CustomEvent\n *\n * @param {EventTarget} el The element or EventTarget to trigger the event upon\n * @param {String} type The event type name\n * @param {Object|null} detail=null The event data to be sent\n * @returns {Boolean} The return value is false if at least one event listener called preventDefault(). Otherwise it returns true.\n */\nexport default function triggerEvent (el, type, detail = null) {\n let event;\n\n // This check is needed to polyfill CustomEvent on IE11-\n if (typeof window.CustomEvent === 'function') {\n event = new CustomEvent(type, {\n detail,\n cancelable: true\n });\n } else {\n event = document.createEvent('CustomEvent');\n event.initCustomEvent(type, true, true, detail);\n }\n\n return el.dispatchEvent(event);\n}\n", "import guid from './internal/guid.js';\nimport { getEnabledElement } from './enabledElements.js';\nimport getDefaultViewport from './internal/getDefaultViewport.js';\nimport getDisplayedArea from './internal/getDisplayedArea.js';\nimport updateImage from './updateImage.js';\nimport triggerCustomEvent from './triggerEvent.js';\nimport EVENTS from './events.js';\n\n/**\n * @module EnabledElementLayers\n */\n\n/**\n * Helper function to trigger an event on a Cornerstone element with\n * a specific layerId\n *\n * @param {String} eventName The event name (e.g. CornerstoneLayerAdded)\n * @param {EnabledElement} enabledElement The Cornerstone enabled element\n * @param {String} layerId The layer's unique identifier\n * @returns {void}\n * @memberof EnabledElementLayers\n */\nfunction triggerEventForLayer (eventName, enabledElement, layerId) {\n const element = enabledElement.element;\n const eventData = {\n viewport: enabledElement.viewport,\n element: enabledElement.element,\n image: enabledElement.image,\n enabledElement,\n layerId\n };\n\n triggerCustomEvent(element, eventName, eventData);\n}\n\n/**\n * Rescale the target layer to the base layer based on the\n * relative size of each image and their pixel dimensions.\n *\n * This function will update the Viewport parameters of the\n * target layer to a new scale.\n *\n * @param {EnabledElementLayer} baseLayer The base layer\n * @param {EnabledElementLayer} targetLayer The target layer to rescale\n * @returns {void}\n * @memberof EnabledElementLayers\n */\nexport function rescaleImage (baseLayer, targetLayer) {\n if (baseLayer.layerId === targetLayer.layerId) {\n throw new Error('rescaleImage: both arguments represent the same layer');\n }\n\n const baseImage = baseLayer.image;\n const targetImage = targetLayer.image;\n\n // Return if these images don't have an imageId (e.g. for dynamic images)\n if (!baseImage.imageId || !targetImage.imageId) {\n return;\n }\n\n // Column pixel spacing need to be considered when calculating the\n // ratio between the layer added and base layer images\n const targetDisplayedArea = getDisplayedArea(targetImage, targetLayer.viewport);\n const baseDisplayedArea = getDisplayedArea(baseImage, baseLayer.viewport);\n const colRelative = (targetDisplayedArea.columnPixelSpacing * targetImage.width) /\n (baseDisplayedArea.columnPixelSpacing * baseImage.width);\n const viewportRatio = targetLayer.viewport.scale / baseLayer.viewport.scale * colRelative;\n\n targetLayer.viewport.scale = baseLayer.viewport.scale * viewportRatio;\n}\n\n/**\n * Add a layer to a Cornerstone element\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @param {Image} image A Cornerstone Image object to add as a new layer\n * @param {Object} options Options for the layer\n *\n * @returns {String} layerId The new layer's unique identifier\n * @memberof EnabledElementLayers\n */\nexport function addLayer (element, image, options) {\n const layerId = guid();\n const enabledElement = getEnabledElement(element);\n const layers = enabledElement.layers;\n let viewport;\n\n if (image) {\n viewport = getDefaultViewport(enabledElement.canvas, image);\n\n // Override the defaults if any optional viewport settings\n // have been specified\n if (options && options.viewport) {\n viewport = Object.assign(viewport, options.viewport);\n }\n }\n\n // Set syncViewports to true by default when a new layer is added\n if (enabledElement.syncViewports !== false) {\n enabledElement.syncViewports = true;\n }\n\n const newLayer = {\n image,\n layerId,\n viewport,\n options: options || {},\n renderingTools: {}\n };\n\n // Rescale the new layer based on the base layer to make sure\n // they will have a proportional size (pixel spacing)\n if (layers.length && image) {\n rescaleImage(layers[0], newLayer);\n }\n\n layers.push(newLayer);\n\n triggerEventForLayer(EVENTS.LAYER_ADDED, enabledElement, layerId);\n\n // Set the layer as active if it's the first layer added\n if (layers.length === 1 && image) {\n setActiveLayer(element, layerId);\n }\n\n return layerId;\n}\n\n/**\n * Remove a layer from a Cornerstone element given a layer ID\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @param {String} layerId The unique identifier for the layer\n * @returns {void}\n * @memberof EnabledElementLayers\n */\nexport function removeLayer (element, layerId) {\n const enabledElement = getEnabledElement(element);\n const layers = enabledElement.layers;\n const index = enabledElement.layers.findIndex((layer) => layer.layerId === layerId);\n\n if (index !== -1) {\n layers.splice(index, 1);\n\n // If the current layer is active, and we have other layers,\n // switch to the first layer that remains in the array\n if (layerId === enabledElement.activeLayerId && layers.length) {\n setActiveLayer(element, layers[0].layerId);\n }\n\n triggerEventForLayer(EVENTS.LAYER_REMOVED, enabledElement, layerId);\n }\n}\n\n/**\n * Retrieve a layer from a Cornerstone element given a layer ID\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @param {String} layerId The unique identifier for the layer\n * @return {EnabledElementLayer} The layer\n * @memberof EnabledElementLayers\n */\nexport function getLayer (element, layerId) {\n const enabledElement = getEnabledElement(element);\n\n\n return enabledElement.layers.find((layer) => layer.layerId === layerId);\n}\n\n/**\n * Retrieve all layers for a Cornerstone element\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n *\n * @return {EnabledElementLayer[]} An array of layers\n * @memberof EnabledElementLayers\n */\nexport function getLayers (element) {\n const enabledElement = getEnabledElement(element);\n\n\n return enabledElement.layers;\n}\n\n/**\n * Retrieve all visible layers for a Cornerstone element\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n *\n * @return {EnabledElementLayer[]} An array of layers\n * @memberof EnabledElementLayers\n */\nexport function getVisibleLayers (element) {\n const enabledElement = getEnabledElement(element);\n\n return enabledElement.layers.filter((layer) => layer.options &&\n layer.options.visible !== false &&\n layer.options.opacity !== 0);\n}\n\n/**\n * Set the active layer for a Cornerstone element\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @param {String} layerId The unique identifier for the layer\n * @returns {void}\n * @memberof EnabledElementLayers\n */\nexport function setActiveLayer (element, layerId) {\n const enabledElement = getEnabledElement(element);\n\n // Stop here if this layer is already active\n if (enabledElement.activeLayerId === layerId) {\n return;\n }\n\n const index = enabledElement.layers.findIndex((layer) => layer.layerId === layerId);\n\n if (index === -1) {\n throw new Error('setActiveLayer: layer not found in layers array');\n }\n\n const layer = enabledElement.layers[index];\n\n if (!layer.image) {\n throw new Error('setActiveLayer: layer with undefined image cannot be set as active.');\n }\n\n enabledElement.activeLayerId = layerId;\n enabledElement.image = layer.image;\n enabledElement.viewport = layer.viewport;\n\n updateImage(element);\n triggerEventForLayer(EVENTS.ACTIVE_LAYER_CHANGED, enabledElement, layerId);\n}\n\n/**\n * Set a new image for a specific layerId\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @param {Image} image The image to be displayed in this layer\n * @param {String} [layerId] The unique identifier for the layer\n * @returns {void}\n * @memberof EnabledElementLayers\n */\nexport function setLayerImage (element, image, layerId) {\n const enabledElement = getEnabledElement(element);\n const baseLayer = enabledElement.layers[0];\n\n let layer;\n\n if (layerId) {\n layer = getLayer(element, layerId);\n } else {\n layer = getActiveLayer(element);\n }\n\n if (!layer) {\n throw new Error('setLayerImage: Layer not found');\n }\n\n layer.image = image;\n\n if (!image) {\n layer.viewport = undefined;\n\n return;\n }\n\n if (!layer.viewport) {\n const defaultViewport = getDefaultViewport(enabledElement.canvas, image);\n\n // Override the defaults if any optional viewport settings\n // have been specified\n if (layer.options && layer.options.viewport) {\n layer.viewport = Object.assign(defaultViewport, layer.options.viewport);\n }\n\n if (baseLayer.layerId !== layerId) {\n rescaleImage(baseLayer, layer);\n }\n }\n}\n\n/**\n * Retrieve the currently active layer for a Cornerstone element\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @return {EnabledElementLayer} The currently active layer\n * @memberof EnabledElementLayers\n */\nexport function getActiveLayer (element) {\n const enabledElement = getEnabledElement(element);\n\n\n return enabledElement.layers.find((layer) => layer.layerId === enabledElement.activeLayerId);\n}\n\n/**\n * Purge the layers\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n *\n * @returns {void}\n */\nexport function purgeLayers (element) {\n const enabledElement = getEnabledElement(element);\n\n enabledElement.layers = [];\n delete enabledElement.activeLayerId;\n delete enabledElement.lastSyncViewportsState;\n}\n", "// This code was created based on vtkLookupTable\n// http://www.vtk.org/doc/release/5.0/html/a01697.html\n// https://github.com/Kitware/VTK/blob/master/Common/Core/vtkLookupTable.cxx\nconst BELOW_RANGE_COLOR_INDEX = 0;\nconst ABOVE_RANGE_COLOR_INDEX = 1;\nconst NAN_COLOR_INDEX = 2;\n\n/**\n * Converts an HSV (Hue, Saturation, Value) color to RGB (Red, Green, Blue) color value\n * @param {Number} hue A number representing the hue color value\n * @param {any} sat A number representing the saturation color value\n * @param {any} val A number representing the value color value\n * @returns {Numberp[]} An RGB color array\n */\nfunction HSVToRGB (hue, sat, val) {\n if (hue > 1) {\n throw new Error('HSVToRGB expects hue < 1');\n }\n\n const rgb = [];\n\n if (sat === 0) {\n rgb[0] = val;\n rgb[1] = val;\n rgb[2] = val;\n\n return rgb;\n }\n\n const hueCase = Math.floor(hue * 6);\n const frac = 6 * hue - hueCase;\n const lx = val * (1 - sat);\n const ly = val * (1 - sat * frac);\n const lz = val * (1 - sat * (1 - frac));\n\n switch (hueCase) {\n\n /* 0 p.Range[1]) {\n dIndex = p.MaxIndex + ABOVE_RANGE_COLOR_INDEX + 1.5;\n } else {\n dIndex = (v + p.Shift) * p.Scale;\n }\n\n return Math.floor(dIndex);\n}\n\n/**\n * Maps scalar values into colors via a lookup table\n * LookupTable is an object that is used by mapper objects to map scalar values into rgba (red-green-blue-alpha transparency) color specification,\n * or rgba into scalar values. The color table can be created by direct insertion of color values, or by specifying hue, saturation, value, and alpha range and generating a table\n */\nclass LookupTable {\n\n /**\n * Creates a default linear LookupTable object with 256 colors.\n */\n constructor () {\n this.NumberOfColors = 256;\n this.Ramp = 'linear';\n this.TableRange = [0, 255];\n this.HueRange = [0, 0.66667];\n this.SaturationRange = [1, 1];\n this.ValueRange = [1, 1];\n this.AlphaRange = [1, 1];\n this.NaNColor = [128, 0, 0, 255];\n this.BelowRangeColor = [0, 0, 0, 255];\n this.UseBelowRangeColor = true;\n this.AboveRangeColor = [255, 255, 255, 255];\n this.UseAboveRangeColor = true;\n this.InputRange = [0, 255];\n this.Table = [];\n }\n\n /**\n * Specify the number of values (i.e., colors) in the lookup table.\n * @param {Number} number The number of colors in he LookupTable\n * @returns {void}\n * @memberof Colors\n */\n setNumberOfTableValues (number) {\n this.NumberOfColors = number;\n }\n\n /**\n * Set the shape of the table ramp to either 'linear', 'scurve' or 'sqrt'\n * @param {String} ramp A string value representing the shape of the table. Allowed values are 'linear', 'scurve' or 'sqrt'\n * @returns {void}\n * @memberof Colors\n */\n setRamp (ramp) {\n this.Ramp = ramp;\n }\n\n /**\n * Sets the minimum/maximum scalar values for scalar mapping.\n * Scalar values less than minimum range value are clamped to minimum range value.\n * Scalar values greater than maximum range value are clamped to maximum range value.\n * @param {Number} start A double representing the minimum scaler value of the LookupTable\n * @param {any} end A double representing the maximum scaler value of the LookupTable\n * @returns {void}\n * @memberof Colors\n */\n setTableRange (start, end) {\n this.TableRange[0] = start;\n this.TableRange[1] = end;\n }\n\n /**\n * Set the range in hue (using automatic generation). Hue ranges between [0,1].\n * @param {Number} start A double representing the minimum hue value in a range. Min. is 0\n * @param {Number} end A double representing the maximum hue value in a range. Max. is 1\n * @returns {void}\n * @memberof Colors\n */\n setHueRange (start, end) {\n this.HueRange[0] = start;\n this.HueRange[1] = end;\n }\n\n /**\n * Set the range in saturation (using automatic generation). Saturation ranges between [0,1].\n * @param {Number} start A double representing the minimum Saturation value in a range. Min. is 0\n * @param {Number} end A double representing the maximum Saturation value in a range. Max. is 1\n * @returns {void}\n * @memberof Colors\n */\n setSaturationRange (start, end) {\n this.SaturationRange[0] = start;\n this.SaturationRange[1] = end;\n }\n\n /**\n * Set the range in value (using automatic generation). Value ranges between [0,1].\n * @param {Numeber } start A double representing the minimum value in a range. Min. is 0\n * @param {Numeber} end A double representing the maximum value in a range. Max. is 1\n * @returns {void}\n * @memberof Colors\n */\n setValueRange (start, end) {\n // Set the range in value (using automatic generation). Value ranges between [0,1].\n this.ValueRange[0] = start;\n this.ValueRange[1] = end;\n }\n\n /**\n * (Not Used) Sets the range of scalars which will be mapped.\n * @param {Number} start the minimum scalar value in the range\n * @param {Number} end the maximum scalar value in the range\n * @returns {void}\n * @memberof Colors\n */\n setRange (start, end) {\n this.InputRange[0] = start;\n this.InputRange[1] = end;\n }\n\n /**\n * Set the range in alpha (using automatic generation). Alpha ranges from [0,1].\n * @param {Number} start A double representing the minimum alpha value\n * @param {Number} end A double representing the maximum alpha value\n * @returns {void}\n * @memberof Colors\n */\n setAlphaRange (start, end) {\n // Set the range in alpha (using automatic generation). Alpha ranges from [0,1].\n this.AlphaRange[0] = start;\n this.AlphaRange[1] = end;\n }\n\n /**\n * Map one value through the lookup table and return the color as an\n * RGBA array of doubles between 0 and 1.\n * @param {Number} scalar A double scalar value which will be mapped to a color in the LookupTable\n * @returns {Number[]} An RGBA array of doubles between 0 and 1\n * @memberof Colors\n */\n getColor (scalar) {\n\n return this.mapValue(scalar);\n }\n\n /**\n * Generate lookup table from hue, saturation, value, alpha min/max values. Table is built from linear ramp of each value.\n * @param {Boolean} force true to force the build of the LookupTable. Otherwie, false. This is useful if a lookup table has been defined manually\n * (using SetTableValue) and then an application decides to rebuild the lookup table using the implicit process.\n * @returns {void}\n * @memberof Colors\n */\n build (force) {\n if (this.Table.length > 1 && !force) {\n return;\n }\n\n // Clear the table\n this.Table = [];\n\n const maxIndex = this.NumberOfColors - 1;\n\n let hinc, sinc, vinc, ainc;\n\n if (maxIndex) {\n hinc = (this.HueRange[1] - this.HueRange[0]) / maxIndex;\n sinc = (this.SaturationRange[1] - this.SaturationRange[0]) / maxIndex;\n vinc = (this.ValueRange[1] - this.ValueRange[0]) / maxIndex;\n ainc = (this.AlphaRange[1] - this.AlphaRange[0]) / maxIndex;\n } else {\n hinc = sinc = vinc = ainc = 0.0;\n }\n\n for (let i = 0; i <= maxIndex; i++) {\n const hue = this.HueRange[0] + i * hinc;\n const sat = this.SaturationRange[0] + i * sinc;\n const val = this.ValueRange[0] + i * vinc;\n const alpha = this.AlphaRange[0] + i * ainc;\n\n const rgb = HSVToRGB(hue, sat, val);\n const c_rgba = [];\n\n switch (this.Ramp) {\n case 'scurve':\n c_rgba[0] = Math.floor(127.5 * (1.0 + Math.cos((1.0 - rgb[0]) * Math.PI)));\n c_rgba[1] = Math.floor(127.5 * (1.0 + Math.cos((1.0 - rgb[1]) * Math.PI)));\n c_rgba[2] = Math.floor(127.5 * (1.0 + Math.cos((1.0 - rgb[2]) * Math.PI)));\n c_rgba[3] = Math.floor(alpha * 255);\n break;\n case 'linear':\n c_rgba[0] = Math.floor(rgb[0] * 255 + 0.5);\n c_rgba[1] = Math.floor(rgb[1] * 255 + 0.5);\n c_rgba[2] = Math.floor(rgb[2] * 255 + 0.5);\n c_rgba[3] = Math.floor(alpha * 255 + 0.5);\n break;\n case 'sqrt':\n c_rgba[0] = Math.floor(Math.sqrt(rgb[0]) * 255 + 0.5);\n c_rgba[1] = Math.floor(Math.sqrt(rgb[1]) * 255 + 0.5);\n c_rgba[2] = Math.floor(Math.sqrt(rgb[2]) * 255 + 0.5);\n c_rgba[3] = Math.floor(Math.sqrt(alpha) * 255 + 0.5);\n break;\n default:\n throw new Error(`Invalid Ramp value (${this.Ramp})`);\n }\n\n this.Table.push(c_rgba);\n }\n\n this.buildSpecialColors();\n }\n\n /**\n * Ensures the out-of-range colors (Below range and Above range) are set correctly.\n * @returns {void}\n * @memberof Colors\n */\n buildSpecialColors () {\n const numberOfColors = this.NumberOfColors;\n const belowRangeColorIndex = numberOfColors + BELOW_RANGE_COLOR_INDEX;\n const aboveRangeColorIndex = numberOfColors + ABOVE_RANGE_COLOR_INDEX;\n const nanColorIndex = numberOfColors + NAN_COLOR_INDEX;\n\n // Below range color\n if (this.UseBelowRangeColor || numberOfColors === 0) {\n this.Table[belowRangeColorIndex] = this.BelowRangeColor;\n } else {\n // Duplicate the first color in the table.\n this.Table[belowRangeColorIndex] = this.Table[0];\n }\n\n // Above range color\n if (this.UseAboveRangeColor || numberOfColors === 0) {\n this.Table[aboveRangeColorIndex] = this.AboveRangeColor;\n } else {\n // Duplicate the last color in the table.\n this.Table[aboveRangeColorIndex] = this.Table[numberOfColors - 1];\n }\n\n // Always use NanColor\n this.Table[nanColorIndex] = this.NaNColor;\n }\n\n /**\n * Similar to GetColor - Map one value through the lookup table and return the color as an\n * RGBA array of doubles between 0 and 1.\n * @param {Numeber} v A double scalar value which will be mapped to a color in the LookupTable\n * @returns {Number[]} An RGBA array of doubles between 0 and 1\n * @memberof Colors\n */\n mapValue (v) {\n const index = this.getIndex(v);\n\n if (index < 0) {\n return this.NaNColor;\n } else if (index === 0) {\n if (this.UseBelowRangeColor && v < this.TableRange[0]) {\n return this.BelowRangeColor;\n }\n } else if (index === this.NumberOfColors - 1) {\n if (this.UseAboveRangeColor && v > this.TableRange[1]) {\n return this.AboveRangeColor;\n }\n }\n\n return this.Table[index];\n }\n\n /**\n * Return the table index associated with a particular value.\n * @param {Number} v A double value which table index will be returned.\n * @returns {Number} The index in the LookupTable\n * @memberof Colors\n */\n getIndex (v) {\n const p = {};\n\n p.Range = [];\n p.MaxIndex = this.NumberOfColors - 1;\n\n // This was LookupShiftAndScale\n p.Shift = -this.TableRange[0];\n if (this.TableRange[1] <= this.TableRange[0]) {\n p.Scale = Number.MAX_VALUE;\n } else {\n p.Scale = p.MaxIndex / (this.TableRange[1] - this.TableRange[0]);\n }\n\n p.Range[0] = this.TableRange[0];\n p.Range[1] = this.TableRange[1];\n\n // First, check whether we have a number...\n if (isNaN(v)) {\n // For backwards compatibility\n return -1;\n }\n\n // Map to an index:\n let index = linearIndexLookupMain(v, p);\n\n // For backwards compatibility, if the index indicates an\n // Out-of-range value, truncate to index range for in-range colors.\n if (index === this.NumberOfColors + BELOW_RANGE_COLOR_INDEX) {\n index = 0;\n } else if (index === this.NumberOfColors + ABOVE_RANGE_COLOR_INDEX) {\n index = this.NumberOfColors - 1;\n }\n\n return index;\n }\n\n\n /**\n * Directly load color into lookup table. Use [0,1] double values for color component specification.\n * Make sure that you've either used the Build() method or used SetNumberOfTableValues() prior to using this method.\n * @param {Number} index The index in the LookupTable of where to insert the color value\n * @param {Number[]} rgba An array of [0,1] double values for an RGBA color component\n * @returns {void}\n * @memberof Colors\n */\n setTableValue (index, rgba) {\n // Check if it index, red, green, blue and alpha were passed as parameter\n if (arguments.length === 5) {\n rgba = Array.prototype.slice.call(arguments, 1);\n }\n\n // Check the index to make sure it is valid\n if (index < 0) {\n throw new Error(`Can't set the table value for negative index (${index})`);\n }\n\n if (index >= this.NumberOfColors) {\n new Error(`Index ${index} is greater than the number of colors ${this.NumberOfColors}`);\n }\n\n this.Table[index] = rgba;\n\n if ((index === 0) || (index === this.NumberOfColors - 1)) {\n // This is needed due to the way the special colors are stored in\n // The internal table. If Above/BelowRangeColors are not used and\n // The min/max colors are changed in the table with this member\n // Function, then the colors used for values outside the range may\n // Be incorrect. Calling this here ensures the out-of-range colors\n // Are set correctly.\n this.buildSpecialColors();\n }\n }\n}\n\nexport default LookupTable;\n", "import LookupTable from './lookupTable.js';\n\nconst COLOR_TRANSPARENT = [0, 0, 0, 0];\n\n// Colormaps\n//\n// Hot Iron, PET, Hot Metal Blue and PET 20 Step are color palettes\n// Defined by the DICOM standard\n// http://dicom.nema.org/dicom/2013/output/chtml/part06/chapter_B.html\n//\n// All Linear Segmented Colormaps were copied from matplotlib\n// https://github.com/stefanv/matplotlib/blob/master/lib/matplotlib/_cm.py\n\nconst colormapsData = {\n hotIron: {\n name: 'Hot Iron',\n numOfColors: 256,\n colors: [\n [0, 0, 0, 255], [2, 0, 0, 255], [4, 0, 0, 255], [6, 0, 0, 255], [8, 0, 0, 255],\n [10, 0, 0, 255], [12, 0, 0, 255], [14, 0, 0, 255], [16, 0, 0, 255], [18, 0, 0, 255],\n [20, 0, 0, 255], [22, 0, 0, 255], [24, 0, 0, 255], [26, 0, 0, 255], [28, 0, 0, 255],\n [30, 0, 0, 255], [32, 0, 0, 255], [34, 0, 0, 255], [36, 0, 0, 255], [38, 0, 0, 255],\n [40, 0, 0, 255], [42, 0, 0, 255], [44, 0, 0, 255], [46, 0, 0, 255], [48, 0, 0, 255],\n [50, 0, 0, 255], [52, 0, 0, 255], [54, 0, 0, 255], [56, 0, 0, 255], [58, 0, 0, 255],\n [60, 0, 0, 255], [62, 0, 0, 255], [64, 0, 0, 255], [66, 0, 0, 255], [68, 0, 0, 255],\n [70, 0, 0, 255], [72, 0, 0, 255], [74, 0, 0, 255], [76, 0, 0, 255], [78, 0, 0, 255],\n [80, 0, 0, 255], [82, 0, 0, 255], [84, 0, 0, 255], [86, 0, 0, 255], [88, 0, 0, 255],\n [90, 0, 0, 255], [92, 0, 0, 255], [94, 0, 0, 255], [96, 0, 0, 255], [98, 0, 0, 255],\n [100, 0, 0, 255], [102, 0, 0, 255], [104, 0, 0, 255], [106, 0, 0, 255], [108, 0, 0, 255],\n [110, 0, 0, 255], [112, 0, 0, 255], [114, 0, 0, 255], [116, 0, 0, 255], [118, 0, 0, 255],\n [120, 0, 0, 255], [122, 0, 0, 255], [124, 0, 0, 255], [126, 0, 0, 255], [128, 0, 0, 255],\n [130, 0, 0, 255], [132, 0, 0, 255], [134, 0, 0, 255], [136, 0, 0, 255], [138, 0, 0, 255],\n [140, 0, 0, 255], [142, 0, 0, 255], [144, 0, 0, 255], [146, 0, 0, 255], [148, 0, 0, 255],\n [150, 0, 0, 255], [152, 0, 0, 255], [154, 0, 0, 255], [156, 0, 0, 255], [158, 0, 0, 255],\n [160, 0, 0, 255], [162, 0, 0, 255], [164, 0, 0, 255], [166, 0, 0, 255], [168, 0, 0, 255],\n [170, 0, 0, 255], [172, 0, 0, 255], [174, 0, 0, 255], [176, 0, 0, 255], [178, 0, 0, 255],\n [180, 0, 0, 255], [182, 0, 0, 255], [184, 0, 0, 255], [186, 0, 0, 255], [188, 0, 0, 255],\n [190, 0, 0, 255], [192, 0, 0, 255], [194, 0, 0, 255], [196, 0, 0, 255], [198, 0, 0, 255],\n [200, 0, 0, 255], [202, 0, 0, 255], [204, 0, 0, 255], [206, 0, 0, 255], [208, 0, 0, 255],\n [210, 0, 0, 255], [212, 0, 0, 255], [214, 0, 0, 255], [216, 0, 0, 255], [218, 0, 0, 255],\n [220, 0, 0, 255], [222, 0, 0, 255], [224, 0, 0, 255], [226, 0, 0, 255], [228, 0, 0, 255],\n [230, 0, 0, 255], [232, 0, 0, 255], [234, 0, 0, 255], [236, 0, 0, 255], [238, 0, 0, 255],\n [240, 0, 0, 255], [242, 0, 0, 255], [244, 0, 0, 255], [246, 0, 0, 255], [248, 0, 0, 255],\n [250, 0, 0, 255], [252, 0, 0, 255], [254, 0, 0, 255], [255, 0, 0, 255], [255, 2, 0, 255],\n [255, 4, 0, 255], [255, 6, 0, 255], [255, 8, 0, 255], [255, 10, 0, 255], [255, 12, 0, 255],\n [255, 14, 0, 255], [255, 16, 0, 255], [255, 18, 0, 255], [255, 20, 0, 255], [255, 22, 0, 255],\n [255, 24, 0, 255], [255, 26, 0, 255], [255, 28, 0, 255], [255, 30, 0, 255], [255, 32, 0, 255],\n [255, 34, 0, 255], [255, 36, 0, 255], [255, 38, 0, 255], [255, 40, 0, 255], [255, 42, 0, 255],\n [255, 44, 0, 255], [255, 46, 0, 255], [255, 48, 0, 255], [255, 50, 0, 255], [255, 52, 0, 255],\n [255, 54, 0, 255], [255, 56, 0, 255], [255, 58, 0, 255], [255, 60, 0, 255], [255, 62, 0, 255],\n [255, 64, 0, 255], [255, 66, 0, 255], [255, 68, 0, 255], [255, 70, 0, 255], [255, 72, 0, 255],\n [255, 74, 0, 255], [255, 76, 0, 255], [255, 78, 0, 255], [255, 80, 0, 255], [255, 82, 0, 255],\n [255, 84, 0, 255], [255, 86, 0, 255], [255, 88, 0, 255], [255, 90, 0, 255], [255, 92, 0, 255],\n [255, 94, 0, 255], [255, 96, 0, 255], [255, 98, 0, 255], [255, 100, 0, 255], [255, 102, 0, 255],\n [255, 104, 0, 255], [255, 106, 0, 255], [255, 108, 0, 255], [255, 110, 0, 255], [255, 112, 0, 255],\n [255, 114, 0, 255], [255, 116, 0, 255], [255, 118, 0, 255], [255, 120, 0, 255], [255, 122, 0, 255],\n [255, 124, 0, 255], [255, 126, 0, 255], [255, 128, 4, 255], [255, 130, 8, 255], [255, 132, 12, 255],\n [255, 134, 16, 255], [255, 136, 20, 255], [255, 138, 24, 255], [255, 140, 28, 255], [255, 142, 32, 255],\n [255, 144, 36, 255], [255, 146, 40, 255], [255, 148, 44, 255], [255, 150, 48, 255], [255, 152, 52, 255],\n [255, 154, 56, 255], [255, 156, 60, 255], [255, 158, 64, 255], [255, 160, 68, 255], [255, 162, 72, 255],\n [255, 164, 76, 255], [255, 166, 80, 255], [255, 168, 84, 255], [255, 170, 88, 255], [255, 172, 92, 255],\n [255, 174, 96, 255], [255, 176, 100, 255], [255, 178, 104, 255], [255, 180, 108, 255], [255, 182, 112, 255],\n [255, 184, 116, 255], [255, 186, 120, 255], [255, 188, 124, 255], [255, 190, 128, 255], [255, 192, 132, 255],\n [255, 194, 136, 255], [255, 196, 140, 255], [255, 198, 144, 255], [255, 200, 148, 255], [255, 202, 152, 255],\n [255, 204, 156, 255], [255, 206, 160, 255], [255, 208, 164, 255], [255, 210, 168, 255], [255, 212, 172, 255],\n [255, 214, 176, 255], [255, 216, 180, 255], [255, 218, 184, 255], [255, 220, 188, 255], [255, 222, 192, 255],\n [255, 224, 196, 255], [255, 226, 200, 255], [255, 228, 204, 255], [255, 230, 208, 255], [255, 232, 212, 255],\n [255, 234, 216, 255], [255, 236, 220, 255], [255, 238, 224, 255], [255, 240, 228, 255], [255, 242, 232, 255],\n [255, 244, 236, 255], [255, 246, 240, 255], [255, 248, 244, 255], [255, 250, 248, 255], [255, 252, 252, 255],\n [255, 255, 255, 255]\n ]\n },\n pet: {\n name: 'PET',\n numColors: 256,\n colors: [\n [0, 0, 0, 255], [0, 2, 1, 255], [0, 4, 3, 255], [0, 6, 5, 255], [0, 8, 7, 255],\n [0, 10, 9, 255], [0, 12, 11, 255], [0, 14, 13, 255], [0, 16, 15, 255], [0, 18, 17, 255],\n [0, 20, 19, 255], [0, 22, 21, 255], [0, 24, 23, 255], [0, 26, 25, 255], [0, 28, 27, 255],\n [0, 30, 29, 255], [0, 32, 31, 255], [0, 34, 33, 255], [0, 36, 35, 255], [0, 38, 37, 255],\n [0, 40, 39, 255], [0, 42, 41, 255], [0, 44, 43, 255], [0, 46, 45, 255], [0, 48, 47, 255],\n [0, 50, 49, 255], [0, 52, 51, 255], [0, 54, 53, 255], [0, 56, 55, 255], [0, 58, 57, 255],\n [0, 60, 59, 255], [0, 62, 61, 255], [0, 65, 63, 255], [0, 67, 65, 255], [0, 69, 67, 255],\n [0, 71, 69, 255], [0, 73, 71, 255], [0, 75, 73, 255], [0, 77, 75, 255], [0, 79, 77, 255],\n [0, 81, 79, 255], [0, 83, 81, 255], [0, 85, 83, 255], [0, 87, 85, 255], [0, 89, 87, 255],\n [0, 91, 89, 255], [0, 93, 91, 255], [0, 95, 93, 255], [0, 97, 95, 255], [0, 99, 97, 255],\n [0, 101, 99, 255], [0, 103, 101, 255], [0, 105, 103, 255], [0, 107, 105, 255], [0, 109, 107, 255],\n [0, 111, 109, 255], [0, 113, 111, 255], [0, 115, 113, 255], [0, 117, 115, 255], [0, 119, 117, 255],\n [0, 121, 119, 255], [0, 123, 121, 255], [0, 125, 123, 255], [0, 128, 125, 255], [1, 126, 127, 255],\n [3, 124, 129, 255], [5, 122, 131, 255], [7, 120, 133, 255], [9, 118, 135, 255], [11, 116, 137, 255],\n [13, 114, 139, 255], [15, 112, 141, 255], [17, 110, 143, 255], [19, 108, 145, 255], [21, 106, 147, 255],\n [23, 104, 149, 255], [25, 102, 151, 255], [27, 100, 153, 255], [29, 98, 155, 255], [31, 96, 157, 255],\n [33, 94, 159, 255], [35, 92, 161, 255], [37, 90, 163, 255], [39, 88, 165, 255], [41, 86, 167, 255],\n [43, 84, 169, 255], [45, 82, 171, 255], [47, 80, 173, 255], [49, 78, 175, 255], [51, 76, 177, 255],\n [53, 74, 179, 255], [55, 72, 181, 255], [57, 70, 183, 255], [59, 68, 185, 255], [61, 66, 187, 255],\n [63, 64, 189, 255], [65, 63, 191, 255], [67, 61, 193, 255], [69, 59, 195, 255], [71, 57, 197, 255],\n [73, 55, 199, 255], [75, 53, 201, 255], [77, 51, 203, 255], [79, 49, 205, 255], [81, 47, 207, 255],\n [83, 45, 209, 255], [85, 43, 211, 255], [86, 41, 213, 255], [88, 39, 215, 255], [90, 37, 217, 255],\n [92, 35, 219, 255], [94, 33, 221, 255], [96, 31, 223, 255], [98, 29, 225, 255], [100, 27, 227, 255],\n [102, 25, 229, 255], [104, 23, 231, 255], [106, 21, 233, 255], [108, 19, 235, 255], [110, 17, 237, 255],\n [112, 15, 239, 255], [114, 13, 241, 255], [116, 11, 243, 255], [118, 9, 245, 255], [120, 7, 247, 255],\n [122, 5, 249, 255], [124, 3, 251, 255], [126, 1, 253, 255], [128, 0, 255, 255], [130, 2, 252, 255],\n [132, 4, 248, 255], [134, 6, 244, 255], [136, 8, 240, 255], [138, 10, 236, 255], [140, 12, 232, 255],\n [142, 14, 228, 255], [144, 16, 224, 255], [146, 18, 220, 255], [148, 20, 216, 255], [150, 22, 212, 255],\n [152, 24, 208, 255], [154, 26, 204, 255], [156, 28, 200, 255], [158, 30, 196, 255], [160, 32, 192, 255],\n [162, 34, 188, 255], [164, 36, 184, 255], [166, 38, 180, 255], [168, 40, 176, 255], [170, 42, 172, 255],\n [171, 44, 168, 255], [173, 46, 164, 255], [175, 48, 160, 255], [177, 50, 156, 255], [179, 52, 152, 255],\n [181, 54, 148, 255], [183, 56, 144, 255], [185, 58, 140, 255], [187, 60, 136, 255], [189, 62, 132, 255],\n [191, 64, 128, 255], [193, 66, 124, 255], [195, 68, 120, 255], [197, 70, 116, 255], [199, 72, 112, 255],\n [201, 74, 108, 255], [203, 76, 104, 255], [205, 78, 100, 255], [207, 80, 96, 255], [209, 82, 92, 255],\n [211, 84, 88, 255], [213, 86, 84, 255], [215, 88, 80, 255], [217, 90, 76, 255], [219, 92, 72, 255],\n [221, 94, 68, 255], [223, 96, 64, 255], [225, 98, 60, 255], [227, 100, 56, 255], [229, 102, 52, 255],\n [231, 104, 48, 255], [233, 106, 44, 255], [235, 108, 40, 255], [237, 110, 36, 255], [239, 112, 32, 255],\n [241, 114, 28, 255], [243, 116, 24, 255], [245, 118, 20, 255], [247, 120, 16, 255], [249, 122, 12, 255],\n [251, 124, 8, 255], [253, 126, 4, 255], [255, 128, 0, 255], [255, 130, 4, 255], [255, 132, 8, 255],\n [255, 134, 12, 255], [255, 136, 16, 255], [255, 138, 20, 255], [255, 140, 24, 255], [255, 142, 28, 255],\n [255, 144, 32, 255], [255, 146, 36, 255], [255, 148, 40, 255], [255, 150, 44, 255], [255, 152, 48, 255],\n [255, 154, 52, 255], [255, 156, 56, 255], [255, 158, 60, 255], [255, 160, 64, 255], [255, 162, 68, 255],\n [255, 164, 72, 255], [255, 166, 76, 255], [255, 168, 80, 255], [255, 170, 85, 255], [255, 172, 89, 255],\n [255, 174, 93, 255], [255, 176, 97, 255], [255, 178, 101, 255], [255, 180, 105, 255], [255, 182, 109, 255],\n [255, 184, 113, 255], [255, 186, 117, 255], [255, 188, 121, 255], [255, 190, 125, 255], [255, 192, 129, 255],\n [255, 194, 133, 255], [255, 196, 137, 255], [255, 198, 141, 255], [255, 200, 145, 255], [255, 202, 149, 255],\n [255, 204, 153, 255], [255, 206, 157, 255], [255, 208, 161, 255], [255, 210, 165, 255], [255, 212, 170, 255],\n [255, 214, 174, 255], [255, 216, 178, 255], [255, 218, 182, 255], [255, 220, 186, 255], [255, 222, 190, 255],\n [255, 224, 194, 255], [255, 226, 198, 255], [255, 228, 202, 255], [255, 230, 206, 255], [255, 232, 210, 255],\n [255, 234, 214, 255], [255, 236, 218, 255], [255, 238, 222, 255], [255, 240, 226, 255], [255, 242, 230, 255],\n [255, 244, 234, 255], [255, 246, 238, 255], [255, 248, 242, 255], [255, 250, 246, 255], [255, 252, 250, 255],\n [255, 255, 255, 255]\n ]\n },\n hotMetalBlue: {\n name: 'Hot Metal Blue',\n numColors: 256,\n colors: [\n [0, 0, 0, 255], [0, 0, 2, 255], [0, 0, 4, 255], [0, 0, 6, 255], [0, 0, 8, 255],\n [0, 0, 10, 255], [0, 0, 12, 255], [0, 0, 14, 255], [0, 0, 16, 255], [0, 0, 17, 255],\n [0, 0, 19, 255], [0, 0, 21, 255], [0, 0, 23, 255], [0, 0, 25, 255], [0, 0, 27, 255],\n [0, 0, 29, 255], [0, 0, 31, 255], [0, 0, 33, 255], [0, 0, 35, 255], [0, 0, 37, 255],\n [0, 0, 39, 255], [0, 0, 41, 255], [0, 0, 43, 255], [0, 0, 45, 255], [0, 0, 47, 255],\n [0, 0, 49, 255], [0, 0, 51, 255], [0, 0, 53, 255], [0, 0, 55, 255], [0, 0, 57, 255],\n [0, 0, 59, 255], [0, 0, 61, 255], [0, 0, 63, 255], [0, 0, 65, 255], [0, 0, 67, 255],\n [0, 0, 69, 255], [0, 0, 71, 255], [0, 0, 73, 255], [0, 0, 75, 255], [0, 0, 77, 255],\n [0, 0, 79, 255], [0, 0, 81, 255], [0, 0, 83, 255], [0, 0, 84, 255], [0, 0, 86, 255],\n [0, 0, 88, 255], [0, 0, 90, 255], [0, 0, 92, 255], [0, 0, 94, 255], [0, 0, 96, 255],\n [0, 0, 98, 255], [0, 0, 100, 255], [0, 0, 102, 255], [0, 0, 104, 255], [0, 0, 106, 255],\n [0, 0, 108, 255], [0, 0, 110, 255], [0, 0, 112, 255], [0, 0, 114, 255], [0, 0, 116, 255],\n [0, 0, 117, 255], [0, 0, 119, 255], [0, 0, 121, 255], [0, 0, 123, 255], [0, 0, 125, 255],\n [0, 0, 127, 255], [0, 0, 129, 255], [0, 0, 131, 255], [0, 0, 133, 255], [0, 0, 135, 255],\n [0, 0, 137, 255], [0, 0, 139, 255], [0, 0, 141, 255], [0, 0, 143, 255], [0, 0, 145, 255],\n [0, 0, 147, 255], [0, 0, 149, 255], [0, 0, 151, 255], [0, 0, 153, 255], [0, 0, 155, 255],\n [0, 0, 157, 255], [0, 0, 159, 255], [0, 0, 161, 255], [0, 0, 163, 255], [0, 0, 165, 255],\n [0, 0, 167, 255], [3, 0, 169, 255], [6, 0, 171, 255], [9, 0, 173, 255], [12, 0, 175, 255],\n [15, 0, 177, 255], [18, 0, 179, 255], [21, 0, 181, 255], [24, 0, 183, 255], [26, 0, 184, 255],\n [29, 0, 186, 255], [32, 0, 188, 255], [35, 0, 190, 255], [38, 0, 192, 255], [41, 0, 194, 255],\n [44, 0, 196, 255], [47, 0, 198, 255], [50, 0, 200, 255], [52, 0, 197, 255], [55, 0, 194, 255],\n [57, 0, 191, 255], [59, 0, 188, 255], [62, 0, 185, 255], [64, 0, 182, 255], [66, 0, 179, 255],\n [69, 0, 176, 255], [71, 0, 174, 255], [74, 0, 171, 255], [76, 0, 168, 255], [78, 0, 165, 255],\n [81, 0, 162, 255], [83, 0, 159, 255], [85, 0, 156, 255], [88, 0, 153, 255], [90, 0, 150, 255],\n [93, 2, 144, 255], [96, 4, 138, 255], [99, 6, 132, 255], [102, 8, 126, 255], [105, 9, 121, 255],\n [108, 11, 115, 255], [111, 13, 109, 255], [114, 15, 103, 255], [116, 17, 97, 255], [119, 19, 91, 255],\n [122, 21, 85, 255], [125, 23, 79, 255], [128, 24, 74, 255], [131, 26, 68, 255], [134, 28, 62, 255],\n [137, 30, 56, 255], [140, 32, 50, 255], [143, 34, 47, 255], [146, 36, 44, 255], [149, 38, 41, 255],\n [152, 40, 38, 255], [155, 41, 35, 255], [158, 43, 32, 255], [161, 45, 29, 255], [164, 47, 26, 255],\n [166, 49, 24, 255], [169, 51, 21, 255], [172, 53, 18, 255], [175, 55, 15, 255], [178, 56, 12, 255],\n [181, 58, 9, 255], [184, 60, 6, 255], [187, 62, 3, 255], [190, 64, 0, 255], [194, 66, 0, 255],\n [198, 68, 0, 255], [201, 70, 0, 255], [205, 72, 0, 255], [209, 73, 0, 255], [213, 75, 0, 255],\n [217, 77, 0, 255], [221, 79, 0, 255], [224, 81, 0, 255], [228, 83, 0, 255], [232, 85, 0, 255],\n [236, 87, 0, 255], [240, 88, 0, 255], [244, 90, 0, 255], [247, 92, 0, 255], [251, 94, 0, 255],\n [255, 96, 0, 255], [255, 98, 3, 255], [255, 100, 6, 255], [255, 102, 9, 255], [255, 104, 12, 255],\n [255, 105, 15, 255], [255, 107, 18, 255], [255, 109, 21, 255], [255, 111, 24, 255], [255, 113, 26, 255],\n [255, 115, 29, 255], [255, 117, 32, 255], [255, 119, 35, 255], [255, 120, 38, 255], [255, 122, 41, 255],\n [255, 124, 44, 255], [255, 126, 47, 255], [255, 128, 50, 255], [255, 130, 53, 255], [255, 132, 56, 255],\n [255, 134, 59, 255], [255, 136, 62, 255], [255, 137, 65, 255], [255, 139, 68, 255], [255, 141, 71, 255],\n [255, 143, 74, 255], [255, 145, 76, 255], [255, 147, 79, 255], [255, 149, 82, 255], [255, 151, 85, 255],\n [255, 152, 88, 255], [255, 154, 91, 255], [255, 156, 94, 255], [255, 158, 97, 255], [255, 160, 100, 255],\n [255, 162, 103, 255], [255, 164, 106, 255], [255, 166, 109, 255], [255, 168, 112, 255], [255, 169, 115, 255],\n [255, 171, 118, 255], [255, 173, 121, 255], [255, 175, 124, 255], [255, 177, 126, 255], [255, 179, 129, 255],\n [255, 181, 132, 255], [255, 183, 135, 255], [255, 184, 138, 255], [255, 186, 141, 255], [255, 188, 144, 255],\n [255, 190, 147, 255], [255, 192, 150, 255], [255, 194, 153, 255], [255, 196, 156, 255], [255, 198, 159, 255],\n [255, 200, 162, 255], [255, 201, 165, 255], [255, 203, 168, 255], [255, 205, 171, 255], [255, 207, 174, 255],\n [255, 209, 176, 255], [255, 211, 179, 255], [255, 213, 182, 255], [255, 215, 185, 255], [255, 216, 188, 255],\n [255, 218, 191, 255], [255, 220, 194, 255], [255, 222, 197, 255], [255, 224, 200, 255], [255, 226, 203, 255],\n [255, 228, 206, 255], [255, 229, 210, 255], [255, 231, 213, 255], [255, 233, 216, 255], [255, 235, 219, 255],\n [255, 237, 223, 255], [255, 239, 226, 255], [255, 240, 229, 255], [255, 242, 232, 255], [255, 244, 236, 255],\n [255, 246, 239, 255], [255, 248, 242, 255], [255, 250, 245, 255], [255, 251, 249, 255], [255, 253, 252, 255],\n [255, 255, 255, 255]\n ]\n },\n pet20Step: {\n name: 'PET 20 Step',\n numColors: 256,\n colors: [\n [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255],\n [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255],\n [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [96, 0, 80, 255], [96, 0, 80, 255],\n [96, 0, 80, 255], [96, 0, 80, 255], [96, 0, 80, 255], [96, 0, 80, 255], [96, 0, 80, 255],\n [96, 0, 80, 255], [96, 0, 80, 255], [96, 0, 80, 255], [96, 0, 80, 255], [96, 0, 80, 255],\n [96, 0, 80, 255], [48, 48, 80, 255], [48, 48, 80, 255], [48, 48, 80, 255], [48, 48, 80, 255],\n [48, 48, 80, 255], [48, 48, 80, 255], [48, 48, 80, 255], [48, 48, 80, 255], [48, 48, 80, 255],\n [48, 48, 80, 255], [48, 48, 80, 255], [48, 48, 80, 255], [48, 48, 80, 255], [48, 48, 112, 255],\n [48, 48, 112, 255], [48, 48, 112, 255], [48, 48, 112, 255], [48, 48, 112, 255], [48, 48, 112, 255],\n [48, 48, 112, 255], [48, 48, 112, 255], [48, 48, 112, 255], [48, 48, 112, 255], [48, 48, 112, 255],\n [48, 48, 112, 255], [80, 80, 128, 255], [80, 80, 128, 255], [80, 80, 128, 255], [80, 80, 128, 255],\n [80, 80, 128, 255], [80, 80, 128, 255], [80, 80, 128, 255], [80, 80, 128, 255], [80, 80, 128, 255],\n [80, 80, 128, 255], [80, 80, 128, 255], [80, 80, 128, 255], [80, 80, 128, 255], [96, 96, 176, 255],\n [96, 96, 176, 255], [96, 96, 176, 255], [96, 96, 176, 255], [96, 96, 176, 255], [96, 96, 176, 255],\n [96, 96, 176, 255], [96, 96, 176, 255], [96, 96, 176, 255], [96, 96, 176, 255], [96, 96, 176, 255],\n [96, 96, 176, 255], [96, 96, 176, 255], [112, 112, 192, 255], [112, 112, 192, 255], [112, 112, 192, 255],\n [112, 112, 192, 255], [112, 112, 192, 255], [112, 112, 192, 255], [112, 112, 192, 255], [112, 112, 192, 255],\n [112, 112, 192, 255], [112, 112, 192, 255], [112, 112, 192, 255], [112, 112, 192, 255], [112, 112, 192, 255],\n [128, 128, 224, 255], [128, 128, 224, 255], [128, 128, 224, 255], [128, 128, 224, 255], [128, 128, 224, 255],\n [128, 128, 224, 255], [128, 128, 224, 255], [128, 128, 224, 255], [128, 128, 224, 255], [128, 128, 224, 255],\n [128, 128, 224, 255], [128, 128, 224, 255], [48, 96, 48, 255], [48, 96, 48, 255], [48, 96, 48, 255],\n [48, 96, 48, 255], [48, 96, 48, 255], [48, 96, 48, 255], [48, 96, 48, 255], [48, 96, 48, 255],\n [48, 96, 48, 255], [48, 96, 48, 255], [48, 96, 48, 255], [48, 96, 48, 255], [48, 96, 48, 255],\n [48, 144, 48, 255], [48, 144, 48, 255], [48, 144, 48, 255], [48, 144, 48, 255], [48, 144, 48, 255],\n [48, 144, 48, 255], [48, 144, 48, 255], [48, 144, 48, 255], [48, 144, 48, 255], [48, 144, 48, 255],\n [48, 144, 48, 255], [48, 144, 48, 255], [48, 144, 48, 255], [80, 192, 80, 255], [80, 192, 80, 255],\n [80, 192, 80, 255], [80, 192, 80, 255], [80, 192, 80, 255], [80, 192, 80, 255], [80, 192, 80, 255],\n [80, 192, 80, 255], [80, 192, 80, 255], [80, 192, 80, 255], [80, 192, 80, 255], [80, 192, 80, 255],\n [80, 192, 80, 255], [64, 224, 64, 255], [64, 224, 64, 255], [64, 224, 64, 255], [64, 224, 64, 255],\n [64, 224, 64, 255], [64, 224, 64, 255], [64, 224, 64, 255], [64, 224, 64, 255], [64, 224, 64, 255],\n [64, 224, 64, 255], [64, 224, 64, 255], [64, 224, 64, 255], [224, 224, 80, 255], [224, 224, 80, 255],\n [224, 224, 80, 255], [224, 224, 80, 255], [224, 224, 80, 255], [224, 224, 80, 255], [224, 224, 80, 255],\n [224, 224, 80, 255], [224, 224, 80, 255], [224, 224, 80, 255], [224, 224, 80, 255], [224, 224, 80, 255],\n [224, 224, 80, 255], [208, 208, 96, 255], [208, 208, 96, 255], [208, 208, 96, 255], [208, 208, 96, 255],\n [208, 208, 96, 255], [208, 208, 96, 255], [208, 208, 96, 255], [208, 208, 96, 255], [208, 208, 96, 255],\n [208, 208, 96, 255], [208, 208, 96, 255], [208, 208, 96, 255], [208, 208, 96, 255], [208, 176, 64, 255],\n [208, 176, 64, 255], [208, 176, 64, 255], [208, 176, 64, 255], [208, 176, 64, 255], [208, 176, 64, 255],\n [208, 176, 64, 255], [208, 176, 64, 255], [208, 176, 64, 255], [208, 176, 64, 255], [208, 176, 64, 255],\n [208, 176, 64, 255], [208, 176, 64, 255], [208, 144, 0, 255], [208, 144, 0, 255], [208, 144, 0, 255],\n [208, 144, 0, 255], [208, 144, 0, 255], [208, 144, 0, 255], [208, 144, 0, 255], [208, 144, 0, 255],\n [208, 144, 0, 255], [208, 144, 0, 255], [208, 144, 0, 255], [208, 144, 0, 255], [192, 96, 0, 255],\n [192, 96, 0, 255], [192, 96, 0, 255], [192, 96, 0, 255], [192, 96, 0, 255], [192, 96, 0, 255],\n [192, 96, 0, 255], [192, 96, 0, 255], [192, 96, 0, 255], [192, 96, 0, 255], [192, 96, 0, 255],\n [192, 96, 0, 255], [192, 96, 0, 255], [176, 48, 0, 255], [176, 48, 0, 255], [176, 48, 0, 255],\n [176, 48, 0, 255], [176, 48, 0, 255], [176, 48, 0, 255], [176, 48, 0, 255], [176, 48, 0, 255],\n [176, 48, 0, 255], [176, 48, 0, 255], [176, 48, 0, 255], [176, 48, 0, 255], [176, 48, 0, 255],\n [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255],\n [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255],\n [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 255, 255, 255], [255, 255, 255, 255],\n [255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255],\n [255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255],\n [255, 255, 255, 255]\n ]\n },\n gray: {\n name: 'Gray',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0, 0], [1, 1, 1]],\n green: [[0, 0, 0], [1, 1, 1]],\n blue: [[0, 0, 0], [1, 1, 1]]\n }\n },\n jet: {\n name: 'Jet',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0, 0], [0.35, 0, 0], [0.66, 1, 1], [0.89, 1, 1], [1, 0.5, 0.5]],\n green: [[0, 0, 0], [0.125, 0, 0], [0.375, 1, 1], [0.64, 1, 1], [0.91, 0, 0], [1, 0, 0]],\n blue: [[0, 0.5, 0.5], [0.11, 1, 1], [0.34, 1, 1], [0.65, 0, 0], [1, 0, 0]]\n }\n },\n hsv: {\n name: 'HSV',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 1, 1], [0.158730, 1, 1], [0.174603, 0.968750, 0.968750],\n [0.333333, 0.031250, 0.031250], [0.349206, 0, 0], [0.666667, 0, 0],\n [0.682540, 0.031250, 0.031250], [0.841270, 0.968750, 0.968750],\n [0.857143, 1, 1], [1, 1, 1]],\n green: [[0, 0, 0], [0.158730, 0.937500, 0.937500], [0.174603, 1, 1],\n [0.507937, 1, 1], [0.666667, 0.062500, 0.062500],\n [0.682540, 0, 0], [1, 0, 0]],\n blue: [[0, 0, 0], [0.333333, 0, 0], [0.349206, 0.062500, 0.062500],\n [0.507937, 1, 1], [0.841270, 1, 1], [0.857143, 0.937500, 0.937500],\n [1, 0.09375, 0.09375]]\n }\n },\n hot: {\n name: 'Hot',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0.0416, 0.0416], [0.365079, 1, 1], [1, 1, 1]],\n green: [[0, 0, 0], [0.365079, 0, 0], [0.746032, 1, 1], [1, 1, 1]],\n blue: [[0, 0, 0], [0.746032, 0, 0], [1, 1, 1]]\n }\n },\n cool: {\n name: 'Cool',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0, 0], [1, 1, 1]],\n green: [[0, 1, 1], [1, 0, 0]],\n blue: [[0, 1, 1], [1, 1, 1]]\n }\n },\n spring: {\n name: 'Spring',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 1, 1], [1, 1, 1]],\n green: [[0, 0, 0], [1, 1, 1]],\n blue: [[0, 1, 1], [1, 0, 0]]\n }\n },\n summer: {\n name: 'Summer',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0, 0], [1, 1, 1]],\n green: [[0, 0.5, 0.5], [1, 1, 1]],\n blue: [[0, 0.4, 0.4], [1, 0.4, 0.4]]\n }\n },\n autumn: {\n name: 'Autumn',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 1, 1], [1, 1, 1]],\n green: [[0, 0, 0], [1, 1, 1]],\n blue: [[0, 0, 0], [1, 0, 0]]\n }\n },\n winter: {\n name: 'Winter',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0, 0], [1, 0, 0]],\n green: [[0, 0, 0], [1, 1, 1]],\n blue: [[0, 1, 1], [1, 0.5, 0.5]]\n }\n },\n bone: {\n name: 'Bone',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0, 0], [0.746032, 0.652778, 0.652778], [1, 1, 1]],\n green: [[0, 0, 0], [0.365079, 0.319444, 0.319444], [0.746032, 0.777778, 0.777778], [1, 1, 1]],\n blue: [[0, 0, 0], [0.365079, 0.444444, 0.444444], [1, 1, 1]]\n }\n },\n copper: {\n name: 'Copper',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0, 0], [0.809524, 1, 1], [1, 1, 1]],\n green: [[0, 0, 0], [1, 0.7812, 0.7812]],\n blue: [[0, 0, 0], [1, 0.4975, 0.4975]]\n }\n },\n spectral: {\n name: 'Spectral',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0, 0], [0.05, 0.4667, 0.4667], [0.10, 0.5333, 0.5333], [0.15, 0, 0],\n [0.20, 0, 0], [0.25, 0, 0], [0.30, 0, 0], [0.35, 0, 0],\n [0.40, 0, 0], [0.45, 0, 0], [0.50, 0, 0], [0.55, 0, 0],\n [0.60, 0, 0], [0.65, 0.7333, 0.7333], [0.70, 0.9333, 0.9333], [0.75, 1, 1],\n [0.80, 1, 1], [0.85, 1, 1], [0.90, 0.8667, 0.8667], [0.95, 0.80, 0.80],\n [1, 0.80, 0.80]],\n green: [[0, 0, 0], [0.05, 0, 0], [0.10, 0, 0], [0.15, 0, 0],\n [0.20, 0, 0], [0.25, 0.4667, 0.4667], [0.30, 0.6000, 0.6000],\n [0.35, 0.6667, 0.6667], [0.40, 0.6667, 0.6667], [0.45, 0.6000, 0.6000],\n [0.50, 0.7333, 0.7333], [0.55, 0.8667, 0.8667], [0.60, 1, 1], [0.65, 1, 1],\n [0.70, 0.9333, 0.9333], [0.75, 0.8000, 0.8000],\n [0.80, 0.6000, 0.6000], [0.85, 0, 0],\n [0.90, 0, 0], [0.95, 0, 0], [1, 0.80, 0.80]],\n blue: [[0, 0, 0], [0.05, 0.5333, 0.5333], [0.10, 0.6000, 0.6000], [0.15, 0.6667, 0.6667],\n [0.20, 0.8667, 0.8667], [0.25, 0.8667, 0.8667], [0.30, 0.8667, 0.8667],\n [0.35, 0.6667, 0.6667], [0.40, 0.5333, 0.5333], [0.45, 0, 0],\n [0.5, 0, 0], [0.55, 0, 0], [0.60, 0, 0], [0.65, 0, 0], [0.70, 0, 0], [0.75, 0, 0],\n [0.80, 0, 0], [0.85, 0, 0], [0.90, 0, 0], [0.95, 0, 0], [1, 0.80, 0.80]]\n }\n },\n coolwarm: {\n name: 'CoolWarm',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0.2298057, 0.2298057], [0.03125, 0.26623388, 0.26623388],\n [0.0625, 0.30386891, 0.30386891], [0.09375, 0.342804478, 0.342804478],\n [0.125, 0.38301334, 0.38301334], [0.15625, 0.424369608, 0.424369608],\n [0.1875, 0.46666708, 0.46666708], [0.21875, 0.509635204, 0.509635204],\n [0.25, 0.552953156, 0.552953156], [0.28125, 0.596262162, 0.596262162],\n [0.3125, 0.639176211, 0.639176211], [0.34375, 0.681291281, 0.681291281],\n [0.375, 0.722193294, 0.722193294], [0.40625, 0.761464949, 0.761464949],\n [0.4375, 0.798691636, 0.798691636], [0.46875, 0.833466556, 0.833466556],\n [0.5, 0.865395197, 0.865395197], [0.53125, 0.897787179, 0.897787179],\n [0.5625, 0.924127593, 0.924127593], [0.59375, 0.944468518, 0.944468518],\n [0.625, 0.958852946, 0.958852946], [0.65625, 0.96732803, 0.96732803],\n [0.6875, 0.969954137, 0.969954137], [0.71875, 0.966811177, 0.966811177],\n [0.75, 0.958003065, 0.958003065], [0.78125, 0.943660866, 0.943660866],\n [0.8125, 0.923944917, 0.923944917], [0.84375, 0.89904617, 0.89904617],\n [0.875, 0.869186849, 0.869186849], [0.90625, 0.834620542, 0.834620542],\n [0.9375, 0.795631745, 0.795631745], [0.96875, 0.752534934, 0.752534934],\n [1, 0.705673158, 0.705673158]],\n green: [[0, 0.298717966, 0.298717966], [0.03125, 0.353094838, 0.353094838],\n [0.0625, 0.406535296, 0.406535296], [0.09375, 0.458757618, 0.458757618],\n [0.125, 0.50941904, 0.50941904], [0.15625, 0.558148092, 0.558148092],\n [0.1875, 0.604562568, 0.604562568], [0.21875, 0.648280772, 0.648280772],\n [0.25, 0.688929332, 0.688929332], [0.28125, 0.726149107, 0.726149107],\n [0.3125, 0.759599947, 0.759599947], [0.34375, 0.788964712, 0.788964712],\n [0.375, 0.813952739, 0.813952739], [0.40625, 0.834302879, 0.834302879],\n [0.4375, 0.849786142, 0.849786142], [0.46875, 0.860207984, 0.860207984],\n [0.5, 0.86541021, 0.86541021], [0.53125, 0.848937047, 0.848937047],\n [0.5625, 0.827384882, 0.827384882], [0.59375, 0.800927443, 0.800927443],\n [0.625, 0.769767752, 0.769767752], [0.65625, 0.734132809, 0.734132809],\n [0.6875, 0.694266682, 0.694266682], [0.71875, 0.650421156, 0.650421156],\n [0.75, 0.602842431, 0.602842431], [0.78125, 0.551750968, 0.551750968],\n [0.8125, 0.49730856, 0.49730856], [0.84375, 0.439559467, 0.439559467],\n [0.875, 0.378313092, 0.378313092], [0.90625, 0.312874446, 0.312874446],\n [0.9375, 0.24128379, 0.24128379], [0.96875, 0.157246067, 0.157246067],\n [1, 0.01555616, 0.01555616]],\n blue: [[0, 0.753683153, 0.753683153], [0.03125, 0.801466763, 0.801466763],\n [0.0625, 0.84495867, 0.84495867], [0.09375, 0.883725899, 0.883725899],\n [0.125, 0.917387822, 0.917387822], [0.15625, 0.945619588, 0.945619588],\n [0.1875, 0.968154911, 0.968154911], [0.21875, 0.98478814, 0.98478814],\n [0.25, 0.995375608, 0.995375608], [0.28125, 0.999836203, 0.999836203],\n [0.3125, 0.998151185, 0.998151185], [0.34375, 0.990363227, 0.990363227],\n [0.375, 0.976574709, 0.976574709], [0.40625, 0.956945269, 0.956945269],\n [0.4375, 0.931688648, 0.931688648], [0.46875, 0.901068838, 0.901068838],\n [0.5, 0.865395561, 0.865395561], [0.53125, 0.820880546, 0.820880546],\n [0.5625, 0.774508472, 0.774508472], [0.59375, 0.726736146, 0.726736146],\n [0.625, 0.678007945, 0.678007945], [0.65625, 0.628751763, 0.628751763],\n [0.6875, 0.579375448, 0.579375448], [0.71875, 0.530263762, 0.530263762],\n [0.75, 0.481775914, 0.481775914], [0.78125, 0.434243684, 0.434243684],\n [0.8125, 0.387970225, 0.387970225], [0.84375, 0.343229596, 0.343229596],\n [0.875, 0.300267182, 0.300267182], [0.90625, 0.259301199, 0.259301199],\n [0.9375, 0.220525627, 0.220525627], [0.96875, 0.184115123, 0.184115123],\n [1, 0.150232812, 0.150232812]]\n }\n },\n blues: {\n name: 'Blues',\n numColors: 256,\n gamma: 1,\n segmentedData: {\n red: [[0, 0.9686274528503418, 0.9686274528503418], [0.125, 0.87058824300765991, 0.87058824300765991],\n [0.25, 0.7764706015586853, 0.7764706015586853], [0.375, 0.61960786581039429, 0.61960786581039429],\n [0.5, 0.41960784792900085, 0.41960784792900085], [0.625, 0.25882354378700256, 0.25882354378700256],\n [0.75, 0.12941177189350128, 0.12941177189350128], [0.875, 0.031372550874948502, 0.031372550874948502],\n [1, 0.031372550874948502, 0.031372550874948502]],\n green: [[0, 0.9843137264251709, 0.9843137264251709], [0.125, 0.92156863212585449, 0.92156863212585449],\n [0.25, 0.85882353782653809, 0.85882353782653809], [0.375, 0.7921568751335144, 0.7921568751335144],\n [0.5, 0.68235296010971069, 0.68235296010971069], [0.625, 0.57254904508590698, 0.57254904508590698],\n [0.75, 0.44313725829124451, 0.44313725829124451], [0.875, 0.31764706969261169, 0.31764706969261169],\n [1, 0.18823529779911041, 0.18823529779911041]],\n blue: [[0, 1, 1], [0.125, 0.9686274528503418, 0.9686274528503418], [0.25, 0.93725490570068359, 0.93725490570068359],\n [0.375, 0.88235294818878174, 0.88235294818878174], [0.5, 0.83921569585800171, 0.83921569585800171],\n [0.625, 0.7764706015586853, 0.7764706015586853], [0.75, 0.70980393886566162, 0.70980393886566162],\n [0.875, 0.61176472902297974, 0.61176472902297974], [1, 0.41960784792900085, 0.41960784792900085]]\n }\n }\n};\n\n/**\n * Generate linearly spaced vectors\n* http://cens.ioc.ee/local/man/matlab/techdoc/ref/linspace.html\n * @param {Number} a A number representing the first vector\n * @param {Number} b A number representing the second vector\n * @param {Number} n The number of linear spaced vectors to generate\n * @returns {Array} An array of points representing linear spaced vectors.\n * @memberof Colors\n */\nfunction linspace (a, b, n) {\n n = n === null ? 100 : n;\n\n const increment = (b - a) / (n - 1);\n const vector = [];\n\n while (n-- > 0) {\n vector.push(a);\n a += increment;\n }\n\n // Make sure the last item will always be \"b\" because most of the\n // Time we'll get numbers like 1.0000000000000002 instead of 1.\n vector[vector.length - 1] = b;\n\n return vector;\n}\n\n/**\n * Returns the \"rank/index\" of the element in a sorted array if found or the highest index if not. Uses (binary search)\n * @param {Array} array A sorted array to search in\n * @param {any} elem the element in the array to search for\n * @returns {number} The rank/index of the element in the given array\n * @memberof Colors\n */\nfunction getRank (array, elem) {\n let left = 0;\n let right = array.length - 1;\n\n while (left <= right) {\n const mid = left + Math.floor((right - left) / 2);\n const midElem = array[mid];\n\n if (midElem === elem) {\n return mid;\n } else if (elem < midElem) {\n right = mid - 1;\n } else {\n left = mid + 1;\n }\n }\n\n return left;\n}\n\n/**\n * Find the indices into a sorted array a such that, if the corresponding elements\n * In v were inserted before the indices, the order of a would be preserved.\n * http://lagrange.univ-lyon1.fr/docs/numpy/1.11.0/reference/generated/numpy.searchsorted.html\n * @param {Array} inputArray The array where the values will be inserted\n * @param {Array} values An array of the values to be inserted into the inputArray\n * @returns {Array} The indices where elements should be inserted to maintain order.\n * @memberof Colors\n */\nfunction searchSorted (inputArray, values) {\n let i;\n const indexes = [];\n const len = values.length;\n\n inputArray.sort(function (a, b) {\n return a - b;\n });\n\n for (i = 0; i < len; i++) {\n indexes[i] = getRank(inputArray, values[i]);\n }\n\n return indexes;\n}\n\n/**\n * Creates an *N* -element 1-d lookup table\n * @param {Number} N The number of elements in the result lookup table\n * @param {Array} data represented by a list of x,y0,y1 mapping correspondences. Each element in this\n * List represents how a value between 0 and 1 (inclusive) represented by x is mapped to\n * A corresponding value between 0 and 1 (inclusive). The two values of y are to allow for\n * Discontinuous mapping functions (say as might be found in a sawtooth) where y0 represents\n * The value of y for values of x <= to that given, and y1 is the value to be used for x >\n * Than that given). The list must start with x=0, end with x=1, and all values of x must be\n * In increasing order. Values between the given mapping points are determined by simple linear\n * Interpolation.\n * @param {any} gamma value denotes a \"gamma curve\" value which adjusts the brightness\n * at the bottom and top of the map.\n * @returns {any[]} an array \"result\" where result[x*(N-1)] gives the closest value for\n * Values of x between 0 and 1.\n * @memberof Colors\n */\nfunction makeMappingArray (N, data, gamma) {\n let i;\n const x = [];\n const y0 = [];\n const y1 = [];\n const lut = [];\n\n gamma = gamma === null ? 1 : gamma;\n\n for (i = 0; i < data.length; i++) {\n const element = data[i];\n\n x.push((N - 1) * element[0]);\n y0.push(element[1]);\n y1.push(element[1]);\n }\n\n const xLinSpace = linspace(0, 1, N);\n\n for (i = 0; i < N; i++) {\n xLinSpace[i] = (N - 1) * Math.pow(xLinSpace[i], gamma);\n }\n\n const xLinSpaceIndexes = searchSorted(x, xLinSpace);\n\n for (i = 1; i < N - 1; i++) {\n const index = xLinSpaceIndexes[i];\n const colorPercent = ((xLinSpace[i] - x[index - 1]) / (x[index] - x[index - 1]));\n const colorDelta = (y0[index] - y1[index - 1]);\n\n lut[i] = colorPercent * colorDelta + y1[index - 1];\n }\n\n lut[0] = y1[0];\n lut[N - 1] = y0[data.length - 1];\n\n return lut;\n}\n\n/**\n * Creates a Colormap based on lookup tables using linear segments.\n * @param {{red:Array, green:Array, blue:Array}} segmentedData An object with a red, green and blue entries.\n * Each entry should be a list of x, y0, y1 tuples, forming rows in a table.\n * @param {Number} N The number of elements in the result Colormap\n * @param {any} gamma value denotes a \"gamma curve\" value which adjusts the brightness\n * at the bottom and top of the Colormap.\n * @returns {Array} The created Colormap object\n * @description The lookup table is generated using linear interpolation for each\n * Primary color, with the 0-1 domain divided into any number of\n * Segments.\n * https://github.com/stefanv/matplotlib/blob/3f1a23755e86fef97d51e30e106195f34425c9e3/lib/matplotlib/colors.py#L663\n * @memberof Colors\n */\nfunction createLinearSegmentedColormap (segmentedData, N, gamma) {\n let i;\n const lut = [];\n\n N = N === null ? 256 : N;\n gamma = gamma === null ? 1 : gamma;\n\n const redLut = makeMappingArray(N, segmentedData.red, gamma);\n const greenLut = makeMappingArray(N, segmentedData.green, gamma);\n const blueLut = makeMappingArray(N, segmentedData.blue, gamma);\n\n for (i = 0; i < N; i++) {\n const red = Math.round(redLut[i] * 255);\n const green = Math.round(greenLut[i] * 255);\n const blue = Math.round(blueLut[i] * 255);\n const rgba = [red, green, blue, 255];\n\n lut.push(rgba);\n }\n\n return lut;\n}\n\n/**\n * Return all available colormaps (id and name)\n * @returns {Array<{id,key}>} An array of colormaps with an object containing the \"id\" and display \"name\"\n * @memberof Colors\n */\nexport function getColormapsList () {\n const colormaps = [];\n const keys = Object.keys(colormapsData);\n\n keys.forEach(function (key) {\n if (colormapsData.hasOwnProperty(key)) {\n const colormap = colormapsData[key];\n\n colormaps.push({\n id: key,\n name: colormap.name\n });\n }\n });\n\n colormaps.sort(function (a, b) {\n const aName = a.name.toLowerCase();\n const bName = b.name.toLowerCase();\n\n if (aName === bName) {\n return 0;\n }\n\n return aName < bName ? -1 : 1;\n });\n\n return colormaps;\n}\n\n/**\n * Return a colorMap object with the provided id and colormapData\n * if the Id matches existent colorMap objects (check colormapsData) the colormapData is ignored.\n * if the colormapData is not empty, the colorMap will be added to the colormapsData list. Otherwise, an empty colorMap object is returned.\n * @param {string} id The ID of the colormap\n * @param {Object} colormapData - An object that can contain a name, numColors, gama, segmentedData and/or colors\n * @returns {*} The Colormap Object\n * @memberof Colors\n*/\nexport function getColormap (id, colormapData) {\n let colormap = colormapsData[id];\n\n if (!colormap) {\n colormap = colormapsData[id] = colormapData || {\n name: '',\n colors: []\n };\n }\n\n if (!colormap.colors && colormap.segmentedData) {\n colormap.colors = createLinearSegmentedColormap(colormap.segmentedData, colormap.numColors, colormap.gamma);\n }\n\n return {\n getId () {\n return id;\n },\n\n getColorSchemeName () {\n return colormap.name;\n },\n\n setColorSchemeName (name) {\n colormap.name = name;\n },\n\n getNumberOfColors () {\n return colormap.colors.length;\n },\n\n setNumberOfColors (numColors) {\n while (colormap.colors.length < numColors) {\n colormap.colors.push(COLOR_TRANSPARENT);\n }\n\n colormap.colors.length = numColors;\n },\n\n getColor (index) {\n if (this.isValidIndex(index)) {\n return colormap.colors[index];\n }\n\n return COLOR_TRANSPARENT;\n },\n\n getColorRepeating (index) {\n const numColors = colormap.colors.length;\n\n index = numColors ? index % numColors : 0;\n\n return this.getColor(index);\n },\n\n setColor (index, rgba) {\n if (this.isValidIndex(index)) {\n colormap.colors[index] = rgba;\n }\n },\n\n addColor (rgba) {\n colormap.colors.push(rgba);\n },\n\n insertColor (index, rgba) {\n if (this.isValidIndex(index)) {\n colormap.colors.splice(index, 1, rgba);\n }\n },\n\n removeColor (index) {\n if (this.isValidIndex(index)) {\n colormap.colors.splice(index, 1);\n }\n },\n\n clearColors () {\n colormap.colors = [];\n },\n\n buildLookupTable (lut) {\n if (!lut) {\n return;\n }\n\n const numColors = colormap.colors.length;\n\n lut.setNumberOfTableValues(numColors);\n\n for (let i = 0; i < numColors; i++) {\n lut.setTableValue(i, colormap.colors[i]);\n }\n },\n\n createLookupTable () {\n const lut = new LookupTable();\n\n this.buildLookupTable(lut);\n\n return lut;\n },\n\n isValidIndex (index) {\n return (index >= 0) && (index < colormap.colors.length);\n }\n };\n}\n", "import { getColormap, getColormapsList } from './colormap.js';\nimport LookupTable from './lookupTable.js';\n\nexport default {\n getColormap,\n getColormapsList,\n LookupTable\n};\n", "import colors from './colors/index.js';\n\n/**\n * Converts the image pixel data into a false color data\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {Object} lookupTable A lookup table Object\n *\n * @returns {void}\n * @deprecated This function is superseded by the ability to set the Viewport parameters\n * to include colormaps.\n */\nexport default function pixelDataToFalseColorData (image, lookupTable) {\n if (image.color && !image.falseColor) {\n throw new Error('Color transforms are not implemented yet');\n }\n\n const minPixelValue = image.minPixelValue;\n let canvasImageDataIndex = 0;\n let storedPixelDataIndex = 0;\n const numPixels = image.width * image.height;\n const origPixelData = image.origPixelData || image.getPixelData();\n const storedColorPixelData = new Uint8Array(numPixels * 4);\n let sp;\n let mapped;\n\n image.color = true;\n image.falseColor = true;\n image.origPixelData = origPixelData;\n\n if (lookupTable instanceof colors.LookupTable) {\n lookupTable.build();\n\n while (storedPixelDataIndex < numPixels) {\n sp = origPixelData[storedPixelDataIndex++];\n mapped = lookupTable.mapValue(sp);\n storedColorPixelData[canvasImageDataIndex++] = mapped[0];\n storedColorPixelData[canvasImageDataIndex++] = mapped[1];\n storedColorPixelData[canvasImageDataIndex++] = mapped[2];\n storedColorPixelData[canvasImageDataIndex++] = mapped[3];\n }\n } else if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n sp = origPixelData[storedPixelDataIndex++];\n storedColorPixelData[canvasImageDataIndex++] = lookupTable[sp + (-minPixelValue)][0]; // Red\n storedColorPixelData[canvasImageDataIndex++] = lookupTable[sp + (-minPixelValue)][1]; // Green\n storedColorPixelData[canvasImageDataIndex++] = lookupTable[sp + (-minPixelValue)][2]; // Blue\n storedColorPixelData[canvasImageDataIndex++] = lookupTable[sp + (-minPixelValue)][3]; // Alpha\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n sp = origPixelData[storedPixelDataIndex++];\n storedColorPixelData[canvasImageDataIndex++] = lookupTable[sp][0]; // Red\n storedColorPixelData[canvasImageDataIndex++] = lookupTable[sp][1]; // Green\n storedColorPixelData[canvasImageDataIndex++] = lookupTable[sp][2]; // Blue\n storedColorPixelData[canvasImageDataIndex++] = lookupTable[sp][3]; // Alpha\n }\n }\n\n image.rgba = true;\n image.cachedLut = undefined;\n image.render = undefined;\n image.slope = 1;\n image.intercept = 0;\n image.minPixelValue = 0;\n image.maxPixelValue = 255;\n image.windowWidth = 255;\n image.windowCenter = 128;\n image.getPixelData = () => storedColorPixelData;\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport pixelDataToFalseColorData from './pixelDataToFalseColorData.js';\nimport { getColormap } from './colors/colormap.js';\n\n/**\n * Retrieves the minimum and maximum pixel values from an Array of pixel data\n *\n * @param {Array} pixelData The input pixel data array\n *\n * @returns {{minPixelValue: Number, maxPixelValue: Number}} The minimum and maximum pixel values in the input Array\n */\nfunction getPixelValues (pixelData) {\n let minPixelValue = Number.MAX_VALUE;\n let maxPixelValue = Number.MIN_VALUE;\n const len = pixelData.length;\n let pixel;\n\n for (let i = 0; i < len; i++) {\n pixel = pixelData[i];\n minPixelValue = minPixelValue < pixel ? minPixelValue : pixel;\n maxPixelValue = maxPixelValue > pixel ? maxPixelValue : pixel;\n }\n\n return {\n minPixelValue,\n maxPixelValue\n };\n}\n\n/**\n * Retrieve a function that will allow an image object to be reset to its original form\n * after a false color mapping transformation\n *\n * @param {Image} image A Cornerstone Image Object\n *\n * @return {Function} A function for resetting an Image Object to its original form\n */\nfunction getRestoreImageMethod (image) {\n if (image.restore) {\n return image.restore;\n }\n\n const color = image.color;\n const rgba = image.rgba;\n const cachedLut = image.cachedLut;\n const slope = image.slope;\n const windowWidth = image.windowWidth;\n const windowCenter = image.windowCenter;\n const minPixelValue = image.minPixelValue;\n const maxPixelValue = image.maxPixelValue;\n\n return function () {\n image.color = color;\n image.rgba = rgba;\n image.cachedLut = cachedLut;\n image.slope = slope;\n image.windowWidth = windowWidth;\n image.windowCenter = windowCenter;\n image.minPixelValue = minPixelValue;\n image.maxPixelValue = maxPixelValue;\n\n if (image.origPixelData) {\n const pixelData = image.origPixelData;\n\n image.getPixelData = () => pixelData;\n }\n\n // Remove some attributes added by false color mapping\n image.origPixelData = undefined;\n image.colormapId = undefined;\n image.falseColor = undefined;\n };\n}\n\n//\n// Then we need to make sure it will be converted into a colormap object if it's as string.\n\n/**\n * User can pass a colormap or its id as string to some of these public functions.\n * Then we need to make sure it will be converted into a colormap object if it's a string.\n *\n * @param {*} colormap A colormap ID or Object\n * @return {*} The colormap\n */\nfunction ensuresColormap (colormap) {\n if (colormap && (typeof colormap === 'string')) {\n colormap = getColormap(colormap);\n }\n\n return colormap;\n}\n\n/**\n * Restores a false color image to its original version\n *\n * @param {Image} image A Cornerstone Image Object\n * @returns {Boolean} True if the image object had a valid restore function, which was run. Otherwise, false.\n */\nfunction restoreImage (image) {\n if (image.restore && (typeof image.restore === 'function')) {\n image.restore();\n\n return true;\n }\n\n return false;\n}\n\n/**\n * Convert an image to a false color image\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {String|Object} colormap - it can be a colormap object or a colormap id (string)\n *\n * @returns {Boolean} - Whether or not the image has been converted to a false color image\n */\nfunction convertImageToFalseColorImage (image, colormap) {\n if (image.color && !image.falseColor) {\n throw new Error('Color transforms are not implemented yet');\n }\n\n // User can pass a colormap id or a colormap object\n colormap = ensuresColormap(colormap);\n\n const colormapId = colormap.getId();\n\n // Doesn't do anything if colormapId hasn't changed\n if (image.colormapId === colormapId) {\n // It has already being converted into a false color image\n // Using the colormapId passed as parameter\n return false;\n }\n\n // Restore the image attributes updated when converting to a false color image\n restoreImage(image);\n\n // Convert the image to a false color image\n if (colormapId) {\n const minPixelValue = image.minPixelValue || 0;\n const maxPixelValue = image.maxPixelValue || 255;\n\n image.restore = getRestoreImageMethod(image);\n\n const lookupTable = colormap.createLookupTable();\n\n lookupTable.setTableRange(minPixelValue, maxPixelValue);\n\n // Update the pixel data and render the new image\n pixelDataToFalseColorData(image, lookupTable);\n\n // Update min and max pixel values\n const pixelValues = getPixelValues(image.getPixelData());\n\n image.minPixelValue = pixelValues.minPixelValue;\n image.maxPixelValue = pixelValues.maxPixelValue;\n\n image.windowWidth = 255;\n image.windowCenter = 128;\n\n // Cache the last colormapId used for performance\n // Then it doesn't need to be re-rendered on next\n // Time if the user hasn't updated it\n image.colormapId = colormapId;\n }\n\n // Return `true` to tell the caller that the image has got updated\n return true;\n}\n\n/**\n * Convert the image of a element to a false color image\n *\n * @param {HTMLElement} element The Cornerstone element\n * @param {*} colormap - it can be a colormap object or a colormap id (string)\n *\n * @returns {void}\n */\nfunction convertToFalseColorImage (element, colormap) {\n const enabledElement = getEnabledElement(element);\n\n\n return convertImageToFalseColorImage(enabledElement.image, colormap);\n}\n\nexport { convertImageToFalseColorImage,\n convertToFalseColorImage,\n restoreImage };\n", "import { getEnabledElement } from './enabledElements.js';\n\n/**\n * Retrieves any data for a Cornerstone enabledElement for a specific string\n * dataType\n *\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\n * @param {string} dataType A string name for an arbitrary set of data\n * @returns {*} Whatever data is stored for this enabled element\n */\nexport function getElementData (element, dataType) {\n const ee = getEnabledElement(element);\n\n if (ee.data.hasOwnProperty(dataType) === false) {\n ee.data[dataType] = {};\n }\n\n return ee.data[dataType];\n}\n\n/**\n * Clears any data for a Cornerstone enabledElement for a specific string\n * dataType\n *\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\n * @param {string} dataType A string name for an arbitrary set of data\n *\n * @returns {void}\n */\nexport function removeElementData (element, dataType) {\n const ee = getEnabledElement(element);\n\n delete ee.data[dataType];\n}\n", "import EVENTS, { events } from './events.js';\nimport triggerEvent from './triggerEvent.js';\n\n/**\n * This module deals with caching images\n * @module ImageCache\n */\n\nlet maximumSizeInBytes = 1024 * 1024 * 1024; // 1 GB\nlet cacheSizeInBytes = 0;\n\n// Dictionary of imageId to cachedImage objects\nconst imageCacheDict = {};\n\n// Array of cachedImage objects\nexport const cachedImages = [];\n\n/** Sets the maximum size of cache and purges cache contents if necessary.\n *\n * @param {number} numBytes The maximun size that the cache should occupy.\n * @returns {void}\n */\nexport function setMaximumSizeBytes (numBytes) {\n if (numBytes === undefined) {\n throw new Error('setMaximumSizeBytes: parameter numBytes must not be undefined');\n }\n if (numBytes.toFixed === undefined) {\n throw new Error('setMaximumSizeBytes: parameter numBytes must be a number');\n }\n\n maximumSizeInBytes = numBytes;\n\n triggerEvent(events, EVENTS.IMAGE_CACHE_MAXIMUM_SIZE_CHANGED);\n\n purgeCacheIfNecessary();\n}\n\n/**\n * Purges the cache if size exceeds maximum\n * @returns {void}\n */\nfunction purgeCacheIfNecessary () {\n // If max cache size has not been exceeded, do nothing\n if (cacheSizeInBytes <= maximumSizeInBytes) {\n return;\n }\n\n // Cache size has been exceeded, create list of images sorted by timeStamp\n // So we can purge the least recently used image\n function compare (a, b) {\n if (a.timeStamp > b.timeStamp) {\n return -1;\n }\n if (a.timeStamp < b.timeStamp) {\n return 1;\n }\n\n return 0;\n }\n cachedImages.sort(compare);\n\n // Remove images as necessary)\n while (cacheSizeInBytes > maximumSizeInBytes) {\n const lastCachedImage = cachedImages[cachedImages.length - 1];\n const imageId = lastCachedImage.imageId;\n\n removeImageLoadObject(imageId);\n\n triggerEvent(events, EVENTS.IMAGE_CACHE_PROMISE_REMOVED, { imageId });\n }\n\n const cacheInfo = getCacheInfo();\n\n triggerEvent(events, EVENTS.IMAGE_CACHE_FULL, cacheInfo);\n}\n\n/**\n * Puts a new image loader into the cache\n *\n * @param {string} imageId ImageId of the image loader\n * @param {Object} imageLoadObject The object that is loading or loaded the image\n * @returns {void}\n */\nexport function putImageLoadObject (imageId, imageLoadObject) {\n if (imageId === undefined) {\n throw new Error('putImageLoadObject: imageId must not be undefined');\n }\n if (imageLoadObject.promise === undefined) {\n throw new Error('putImageLoadObject: imageLoadObject.promise must not be undefined');\n }\n if (imageCacheDict.hasOwnProperty(imageId) === true) {\n throw new Error('putImageLoadObject: imageId already in cache');\n }\n if (imageLoadObject.cancelFn && typeof imageLoadObject.cancelFn !== 'function') {\n throw new Error('putImageLoadObject: imageLoadObject.cancelFn must be a function');\n }\n\n const cachedImage = {\n loaded: false,\n imageId,\n sharedCacheKey: undefined, // The sharedCacheKey for this imageId. undefined by default\n imageLoadObject,\n timeStamp: Date.now(),\n sizeInBytes: 0\n };\n\n imageCacheDict[imageId] = cachedImage;\n cachedImages.push(cachedImage);\n\n imageLoadObject.promise.then(function (image) {\n if (cachedImages.indexOf(cachedImage) === -1) {\n // If the image has been purged before being loaded, we stop here.\n return;\n }\n\n cachedImage.loaded = true;\n cachedImage.image = image;\n\n if (image.sizeInBytes === undefined) {\n throw new Error('putImageLoadObject: image.sizeInBytes must not be undefined');\n }\n if (image.sizeInBytes.toFixed === undefined) {\n throw new Error('putImageLoadObject: image.sizeInBytes is not a number');\n }\n\n cachedImage.sizeInBytes = image.sizeInBytes;\n cacheSizeInBytes += cachedImage.sizeInBytes;\n\n const eventDetails = {\n action: 'addImage',\n image: cachedImage\n };\n\n triggerEvent(events, EVENTS.IMAGE_CACHE_CHANGED, eventDetails);\n\n cachedImage.sharedCacheKey = image.sharedCacheKey;\n\n purgeCacheIfNecessary();\n }, () => {\n const cachedImage = imageCacheDict[imageId];\n\n cachedImages.splice(cachedImages.indexOf(cachedImage), 1);\n delete imageCacheDict[imageId];\n });\n}\n\n/**\n * Retuns the object that is loading a given imageId\n *\n * @param {string} imageId Image ID\n * @returns {void}\n */\nexport function getImageLoadObject (imageId) {\n if (imageId === undefined) {\n throw new Error('getImageLoadObject: imageId must not be undefined');\n }\n const cachedImage = imageCacheDict[imageId];\n\n if (cachedImage === undefined) {\n return;\n }\n\n // Bump time stamp for cached image\n cachedImage.timeStamp = Date.now();\n\n return cachedImage.imageLoadObject;\n}\n\n/**\n * Removes the image loader associated with a given Id from the cache\n *\n * @param {string} imageId Image ID\n * @returns {void}\n */\nexport function removeImageLoadObject (imageId) {\n if (imageId === undefined) {\n throw new Error('removeImageLoadObject: imageId must not be undefined');\n }\n const cachedImage = imageCacheDict[imageId];\n\n if (cachedImage === undefined) {\n throw new Error('removeImageLoadObject: imageId was not present in imageCache');\n }\n\n cachedImages.splice(cachedImages.indexOf(cachedImage), 1);\n cacheSizeInBytes -= cachedImage.sizeInBytes;\n\n const eventDetails = {\n action: 'deleteImage',\n image: cachedImage\n };\n\n triggerEvent(events, EVENTS.IMAGE_CACHE_CHANGED, eventDetails);\n decache(cachedImage.imageLoadObject);\n\n delete imageCacheDict[imageId];\n}\n\n/**\n * @typedef {Object} CacheInformation\n * @property {number} maximumSizeInBytes The maximum size of the cache in bytes\n * @property {number} cacheSizeInBytes Currently occupied space in the cache in bytes\n * @property {number} numberOfImagesCached Number of ImageLoaders in the cache\n * @returns {void}\n */\n\n/**\n * Gets the current state of the cache\n * @returns {void}\n */\nexport function getCacheInfo () {\n return {\n maximumSizeInBytes,\n cacheSizeInBytes,\n numberOfImagesCached: cachedImages.length\n };\n}\n\n// This method should only be called by `removeImageLoadObject` because it's\n// The one that knows how to deal with shared cache keys and cache size.\n/**\n * INTERNAL: Removes and ImageLoader from the cache\n *\n * @param {Object} imageLoadObject Image Loader Object to remove\n * @returns {void}\n */\nfunction decache (imageLoadObject) {\n imageLoadObject.promise.then(\n function () {\n if (imageLoadObject.decache) {\n imageLoadObject.decache();\n }\n },\n function () {\n if (imageLoadObject.decache) {\n imageLoadObject.decache();\n }\n }\n );\n}\n\n/**\n * Removes all images from cache\n * @returns {void}\n */\nexport function purgeCache () {\n while (cachedImages.length > 0) {\n const removedCachedImage = cachedImages[0];\n\n removeImageLoadObject(removedCachedImage.imageId);\n }\n}\n\n/**\n * Updates the space than an image is using in the cache\n *\n * @param {string} imageId Image ID\n * @param {number} newCacheSize New image size\n * @returns {void}\n */\nexport function changeImageIdCacheSize (imageId, newCacheSize) {\n const cacheEntry = imageCacheDict[imageId];\n\n if (cacheEntry) {\n cacheEntry.imageLoadObject.promise.then(function (image) {\n const cacheSizeDifference = newCacheSize - image.sizeInBytes;\n\n image.sizeInBytes = newCacheSize;\n cacheEntry.sizeInBytes = newCacheSize;\n cacheSizeInBytes += cacheSizeDifference;\n\n const eventDetails = {\n action: 'changeImageSize',\n image\n };\n\n triggerEvent(events, EVENTS.IMAGE_CACHE_CHANGED, eventDetails);\n });\n }\n}\n\nexport default {\n imageCache: imageCacheDict,\n cachedImages,\n setMaximumSizeBytes,\n putImageLoadObject,\n getImageLoadObject,\n removeImageLoadObject,\n getCacheInfo,\n purgeCache,\n changeImageIdCacheSize\n};\n", "import { getImageLoadObject, putImageLoadObject } from './imageCache.js';\r\nimport EVENTS, { events } from './events.js';\r\nimport triggerEvent from './triggerEvent.js';\r\n\r\n/**\r\n * This module deals with ImageLoaders, loading images and caching images\r\n * @module ImageLoader\r\n */\r\n\r\n\r\nconst imageLoaders = {};\r\n\r\nlet unknownImageLoader;\r\n\r\n/**\r\n * Load an image using a registered Cornerstone Image Loader.\r\n *\r\n * The image loader that is used will be\r\n * determined by the image loader scheme matching against the imageId.\r\n *\r\n * @param {String} imageId A Cornerstone Image Object's imageId\r\n * @param {Object} [options] Options to be passed to the Image Loader\r\n *\r\n * @returns {ImageLoadObject} An Object which can be used to act after an image is loaded or loading fails\r\n * @memberof ImageLoader\r\n */\r\nfunction loadImageFromImageLoader (imageId, options) {\r\n const colonIndex = imageId.indexOf(':');\r\n const scheme = imageId.substring(0, colonIndex);\r\n const loader = imageLoaders[scheme];\r\n\r\n if (loader === undefined || loader === null) {\r\n if (unknownImageLoader !== undefined) {\r\n return unknownImageLoader(imageId);\r\n }\r\n\r\n throw new Error('loadImageFromImageLoader: no image loader for imageId');\r\n }\r\n\r\n const imageLoadObject = loader(imageId, options);\r\n\r\n // Broadcast an image loaded event once the image is loaded\r\n imageLoadObject.promise.then(function (image) {\r\n triggerEvent(events, EVENTS.IMAGE_LOADED, { image });\r\n }, function (error) {\r\n const errorObject = {\r\n imageId,\r\n error\r\n };\r\n\r\n triggerEvent(events, EVENTS.IMAGE_LOAD_FAILED, errorObject);\r\n });\r\n\r\n return imageLoadObject;\r\n}\r\n\r\n/**\r\n * Loads an image given an imageId and optional priority and returns a promise which will resolve to\r\n * the loaded image object or fail if an error occurred. The loaded image is not stored in the cache.\r\n *\r\n * @param {String} imageId A Cornerstone Image Object's imageId\r\n * @param {Object} [options] Options to be passed to the Image Loader\r\n *\r\n * @returns {ImageLoadObject} An Object which can be used to act after an image is loaded or loading fails\r\n * @memberof ImageLoader\r\n */\r\nexport function loadImage (imageId, options) {\r\n if (imageId === undefined) {\r\n throw new Error('loadImage: parameter imageId must not be undefined');\r\n }\r\n\r\n const imageLoadObject = getImageLoadObject(imageId);\r\n\r\n if (imageLoadObject !== undefined) {\r\n return imageLoadObject.promise;\r\n }\r\n\r\n return loadImageFromImageLoader(imageId, options).promise;\r\n}\r\n\r\n//\r\n\r\n/**\r\n * Loads an image given an imageId and optional priority and returns a promise which will resolve to\r\n * the loaded image object or fail if an error occurred. The image is stored in the cache.\r\n *\r\n * @param {String} imageId A Cornerstone Image Object's imageId\r\n * @param {Object} [options] Options to be passed to the Image Loader\r\n *\r\n * @returns {ImageLoadObject} Image Loader Object\r\n * @memberof ImageLoader\r\n */\r\nexport function loadAndCacheImage (imageId, options) {\r\n if (imageId === undefined) {\r\n throw new Error('loadAndCacheImage: parameter imageId must not be undefined');\r\n }\r\n\r\n let imageLoadObject = getImageLoadObject(imageId);\r\n\r\n if (imageLoadObject !== undefined) {\r\n return imageLoadObject.promise;\r\n }\r\n\r\n imageLoadObject = loadImageFromImageLoader(imageId, options);\r\n\r\n putImageLoadObject(imageId, imageLoadObject);\r\n\r\n return imageLoadObject.promise;\r\n}\r\n\r\n/**\r\n * Registers an imageLoader plugin with cornerstone for the specified scheme\r\n *\r\n * @param {String} scheme The scheme to use for this image loader (e.g. 'dicomweb', 'wadouri', 'http')\r\n * @param {Function} imageLoader A Cornerstone Image Loader function\r\n * @returns {void}\r\n * @memberof ImageLoader\r\n */\r\nexport function registerImageLoader (scheme, imageLoader) {\r\n imageLoaders[scheme] = imageLoader;\r\n}\r\n\r\n/**\r\n * Registers a new unknownImageLoader and returns the previous one\r\n *\r\n * @param {Function} imageLoader A Cornerstone Image Loader\r\n *\r\n * @returns {Function|Undefined} The previous Unknown Image Loader\r\n * @memberof ImageLoader\r\n */\r\nexport function registerUnknownImageLoader (imageLoader) {\r\n const oldImageLoader = unknownImageLoader;\r\n\r\n unknownImageLoader = imageLoader;\r\n\r\n return oldImageLoader;\r\n}\r\n", "type AdditionalDetails = {\n imageId?: string\n volumeUID?: string\n }\n \n type RequestDetailsInterface = {\n requestFn: () => Promise\n type: string\n additionalDetails: AdditionalDetails\n }\n \n type RequestPool = {\n interaction: { [key: number]: [] }\n thumbnail: { [key: number]: [] }\n prefetch: { [key: number]: [] }\n }\n\n class RequestPoolManager {\n // priority is fixed for interaction and thumbnail to be 0, however,\n // the priority of prefetch can be configured and it can have priorities other\n // than 0 (highest priority)\n\n // TODO: Some of this stuff shouldn't be public but it's easier right now\n private requestPool: RequestPool;\n private awake: boolean;\n private numRequests: {\n interaction: number;\n thumbnail: number;\n prefetch: number;\n };\n public maxNumRequests: {\n interaction: number;\n thumbnail: number;\n prefetch: number;\n };\n public grabDelay: number;\n private timeoutHandle: number;\n\n constructor() {\n this.requestPool = {\n interaction: { 0: [] },\n thumbnail: { 0: [] },\n prefetch: { 0: [] },\n };\n\n this.awake = false;\n this.grabDelay = 5;\n\n this.numRequests = {\n interaction: 0,\n thumbnail: 0,\n prefetch: 0,\n };\n\n this.maxNumRequests = {\n interaction: 6,\n thumbnail: 6,\n prefetch: 5,\n };\n }\n\n destroy() {\n if (this.timeoutHandle) {\n window.clearTimeout(this.timeoutHandle);\n }\n }\n\n /**\n * Adds the requests to the pool of requests.\n *\n * @param requestFn - A function that returns a promise which resolves in the image\n * @param type - Priority category, it can be either of interaction, prefetch,\n * or thumbnail.\n * @param additionalDetails - Additional details that requests can contain.\n * For instance the volumeUID for the volume requests\n * @param priority - Priority number for each category of requests. Its default\n * value is priority 0. The lower the priority number, the higher the priority number\n *\n * @returns void\n *\n */\n addRequest(\n requestFn: () => Promise,\n type: string,\n additionalDetails: Record,\n priority = 0,\n addToBeginning = false\n ): void {\n // Describe the request\n const requestDetails: RequestDetailsInterface = {\n requestFn,\n type,\n additionalDetails,\n };\n\n // Check if the priority group exists on the request type\n if (this.requestPool[type][priority] === undefined) {\n this.requestPool[type][priority] = [];\n }\n\n // Adding the request to the correct priority group of the request type\n if (addToBeginning) {\n // Add it to the beginning of the stack\n this.requestPool[type][priority].unshift(requestDetails);\n } else {\n // Add it to the end of the stack\n this.requestPool[type][priority].push(requestDetails);\n }\n\n // Wake up\n if (!this.awake) {\n this.awake = true;\n this.startGrabbing();\n }\n }\n\n /**\n * Filter the requestPoolManager's pool of request based on the result of\n * provided filter function. The provided filter function needs to return false or true\n *\n * @param filterFunction The filter function for filtering of the requests to keep\n * @category requestPool\n */\n filterRequests(\n filterFunction: (requestDetails: RequestDetailsInterface) => boolean\n ): void {\n Object.keys(this.requestPool).forEach((type: string) => {\n const requestType = this.requestPool[type];\n Object.keys(requestType).forEach((priority) => {\n requestType[priority] = requestType[priority].filter(\n (requestDetails: RequestDetailsInterface) => {\n return filterFunction(requestDetails);\n }\n );\n });\n });\n }\n\n /**\n * Clears the requests specific to the provided type. For instance, the\n * pool of requests of type 'interaction' can be cleared via this function.\n *\n *\n * @param type category of the request (either interaction, prefetch or thumbnail)\n * @category requestPool\n */\n clearRequestStack(type: string): void {\n if (!this.requestPool[type]) {\n throw new Error(`No category for the type ${type} found`);\n }\n this.requestPool[type] = { 0: [] };\n }\n\n sendRequest({ requestFn, type }: RequestDetailsInterface) {\n // Increment the number of current requests of this type\n this.numRequests[type]++;\n this.awake = true;\n\n requestFn().finally(() => {\n this.numRequests[type]--;\n\n this.startAgain();\n });\n }\n\n startGrabbing(): void {\n // Begin by grabbing X images\n\n // TODO: This is the reason things aren't going as fast as expected\n // const maxSimultaneousRequests = getMaxSimultaneousRequests()\n // this.maxNumRequests = {\n // interaction: Math.max(maxSimultaneousRequests, 1),\n // thumbnail: Math.max(maxSimultaneousRequests - 2, 1),\n // prefetch: Math.max(maxSimultaneousRequests - 1, 1),\n // }\n\n const maxRequests =\n this.maxNumRequests.interaction +\n this.maxNumRequests.thumbnail +\n this.maxNumRequests.prefetch;\n const currentRequests =\n this.numRequests.interaction +\n this.numRequests.thumbnail +\n this.numRequests.prefetch;\n const requestsToSend = maxRequests - currentRequests;\n for (let i = 0; i < requestsToSend; i++) {\n const requestDetails = this.getNextRequest();\n if (requestDetails === false) {\n break;\n } else if (requestDetails) {\n this.sendRequest(requestDetails);\n }\n }\n }\n\n startAgain(): void {\n if (!this.awake) {\n return;\n }\n\n if (this.grabDelay) {\n this.timeoutHandle = window.setTimeout(() => {\n this.startGrabbing();\n }, this.grabDelay);\n } else {\n this.startGrabbing();\n }\n }\n\n getSortedPriorityGroups(type: string): Array {\n const priorities = Object.keys(this.requestPool[type])\n .map(Number)\n .filter((priority) => this.requestPool[type][priority].length)\n .sort();\n return priorities;\n }\n\n getNextRequest(): RequestDetailsInterface | false {\n const interactionPriorities = this.getSortedPriorityGroups('interaction');\n for (const priority of interactionPriorities) {\n if (\n this.requestPool.interaction[priority].length &&\n this.numRequests.interaction < this.maxNumRequests.interaction\n ) {\n return this.requestPool.interaction[priority].shift();\n }\n }\n const thumbnailPriorities = this.getSortedPriorityGroups('thumbnail');\n for (const priority of thumbnailPriorities) {\n if (\n this.requestPool.thumbnail[priority].length &&\n this.numRequests.thumbnail < this.maxNumRequests.thumbnail\n ) {\n return this.requestPool.thumbnail[priority].shift();\n }\n }\n const prefetchPriorities = this.getSortedPriorityGroups('prefetch');\n for (const priority of prefetchPriorities) {\n if (\n this.requestPool.prefetch[priority].length &&\n this.numRequests.prefetch < this.maxNumRequests.prefetch\n ) {\n return this.requestPool.prefetch[priority].shift();\n }\n }\n\n if (\n !interactionPriorities.length &&\n !thumbnailPriorities.length &&\n !prefetchPriorities.length\n ) {\n this.awake = false;\n }\n return false;\n }\n\n /**\n * Returns the request pool containing different categories, their priority and\n * the added request details.\n *\n * @returns\n * @category requestPool\n */\n getRequestPool(): RequestPool {\n return this.requestPool;\n }\n }\n \n\n export { RequestPoolManager }\n ", "import { RequestPoolManager } from './RequestPoolManager.ts'\n\n// Loading = Retrieval + Decoding\nconst imageLoadPoolManager = new RequestPoolManager()\n\nimageLoadPoolManager.maxNumRequests = { interaction: 1000, thumbnail: 1000, prefetch: 1000 };\nimageLoadPoolManager.grabDelay = 0;\n\nexport default imageLoadPoolManager\n", "import { RequestPoolManager } from './RequestPoolManager.ts'\n\n// Retrieval (usually) === XHR requests\nconst imageRetrievalPoolManager = new RequestPoolManager()\n\nimageRetrievalPoolManager.maxNumRequests = { interaction: 20, thumbnail: 20, prefetch: 20 };\nimageRetrievalPoolManager.grabDelay = 0;\n\nexport default imageRetrievalPoolManager\n", "// By Simon Sarris\n// Www.simonsarris.com\n// Sarris@acm.org\n//\n// Free to use and distribute at will\n// So long as you are nice to people, etc\n\n// Simple class for keeping track of the current transformation matrix\n\n// For instance:\n// Var t = new Transform();\n// T.rotate(5);\n// Var m = t.m;\n// Ctx.setTransform(m[0], m[1], m[2], m[3], m[4], m[5]);\n\n// Is equivalent to:\n// Ctx.rotate(5);\n\n// But now you can retrieve it :)\n\n\n// Remember that this does not account for any CSS transforms applied to the canvas\nexport class Transform {\n constructor () {\n this.reset();\n }\n\n reset () {\n this.m = [1, 0, 0, 1, 0, 0];\n }\n\n clone () {\n const transform = new Transform();\n\n transform.m[0] = this.m[0];\n transform.m[1] = this.m[1];\n transform.m[2] = this.m[2];\n transform.m[3] = this.m[3];\n transform.m[4] = this.m[4];\n transform.m[5] = this.m[5];\n\n return transform;\n }\n\n multiply (matrix) {\n const m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];\n const m12 = this.m[1] * matrix.m[0] + this.m[3] * matrix.m[1];\n\n const m21 = this.m[0] * matrix.m[2] + this.m[2] * matrix.m[3];\n const m22 = this.m[1] * matrix.m[2] + this.m[3] * matrix.m[3];\n\n const dx = this.m[0] * matrix.m[4] + this.m[2] * matrix.m[5] + this.m[4];\n const dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];\n\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n this.m[4] = dx;\n this.m[5] = dy;\n }\n\n invert () {\n const d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]);\n const m0 = this.m[3] * d;\n const m1 = -this.m[1] * d;\n const m2 = -this.m[2] * d;\n const m3 = this.m[0] * d;\n const m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]);\n const m5 = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);\n\n this.m[0] = m0;\n this.m[1] = m1;\n this.m[2] = m2;\n this.m[3] = m3;\n this.m[4] = m4;\n this.m[5] = m5;\n }\n\n rotate (rad) {\n const c = Math.cos(rad);\n const s = Math.sin(rad);\n const m11 = this.m[0] * c + this.m[2] * s;\n const m12 = this.m[1] * c + this.m[3] * s;\n const m21 = this.m[0] * -s + this.m[2] * c;\n const m22 = this.m[1] * -s + this.m[3] * c;\n\n this.m[0] = m11;\n this.m[1] = m12;\n this.m[2] = m21;\n this.m[3] = m22;\n }\n\n translate (x, y) {\n this.m[4] += this.m[0] * x + this.m[2] * y;\n this.m[5] += this.m[1] * x + this.m[3] * y;\n }\n\n scale (sx, sy) {\n this.m[0] *= sx;\n this.m[1] *= sx;\n this.m[2] *= sy;\n this.m[3] *= sy;\n }\n\n transformPoint (px, py) {\n const x = px;\n const y = py;\n\n px = x * this.m[0] + y * this.m[2] + this.m[4];\n py = x * this.m[1] + y * this.m[3] + this.m[5];\n\n return {\n x: px,\n y: py\n };\n }\n}\n", "import { Transform } from './transform.js';\nimport getDisplayedArea from './getDisplayedArea.js';\n\n/**\n * Calculate the transform for a Cornerstone enabled element\n *\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element\n * @param {Number} [scale] The viewport scale\n * @return {Transform} The current transform\n * @memberof Internal\n */\nexport default function (enabledElement, scale) {\n\n const transform = new Transform();\n\n // Move to center of canvas\n transform.translate(enabledElement.canvas.width / 2, enabledElement.canvas.height / 2);\n\n // Apply the rotation before scaling for non square pixels\n const angle = enabledElement.viewport.rotation;\n\n if (angle !== 0) {\n transform.rotate(angle * Math.PI / 180);\n }\n\n // Apply the scale\n let widthScale = enabledElement.viewport.scale;\n let heightScale = enabledElement.viewport.scale;\n const imageDisplayedArea = getDisplayedArea(enabledElement.image, enabledElement.viewport);\n\n const offsetX = imageDisplayedArea.tlhc.x - 1;\n const offsetY = imageDisplayedArea.tlhc.y - 1;\n\n const width = imageDisplayedArea.brhc.x - offsetX;\n const height = imageDisplayedArea.brhc.y - offsetY;\n\n if (imageDisplayedArea.presentationSizeMode === 'NONE') {\n if (enabledElement.image.rowPixelSpacing < enabledElement.image.columnPixelSpacing) {\n widthScale *= (enabledElement.image.columnPixelSpacing / enabledElement.image.rowPixelSpacing);\n } else if (enabledElement.image.columnPixelSpacing < enabledElement.image.rowPixelSpacing) {\n heightScale *= (enabledElement.image.rowPixelSpacing / enabledElement.image.columnPixelSpacing);\n }\n } else {\n // These should be good for \"TRUE SIZE\" and \"MAGNIFY\"\n widthScale = imageDisplayedArea.columnPixelSpacing;\n heightScale = imageDisplayedArea.rowPixelSpacing;\n\n if (imageDisplayedArea.presentationSizeMode === 'SCALE TO FIT') {\n // Fit TRUE IMAGE image (width/height) to window\n const verticalScale = enabledElement.canvas.height / (height * heightScale);\n const horizontalScale = enabledElement.canvas.width / (width * widthScale);\n\n // Apply new scale\n widthScale = heightScale = Math.min(horizontalScale, verticalScale);\n\n if (imageDisplayedArea.rowPixelSpacing < imageDisplayedArea.columnPixelSpacing) {\n widthScale *= (imageDisplayedArea.columnPixelSpacing / imageDisplayedArea.rowPixelSpacing);\n } else if (imageDisplayedArea.columnPixelSpacing < imageDisplayedArea.rowPixelSpacing) {\n heightScale *= (imageDisplayedArea.rowPixelSpacing / imageDisplayedArea.columnPixelSpacing);\n }\n }\n }\n\n transform.scale(widthScale, heightScale);\n\n // Unrotate to so we can translate unrotated\n if (angle !== 0) {\n transform.rotate(-angle * Math.PI / 180);\n }\n\n // Apply the pan offset\n transform.translate(enabledElement.viewport.translation.x, enabledElement.viewport.translation.y);\n\n // Rotate again so we can apply general scale\n if (angle !== 0) {\n transform.rotate(angle * Math.PI / 180);\n }\n\n if (scale !== undefined) {\n // Apply the font scale\n transform.scale(scale, scale);\n }\n\n // Apply Flip if required\n if (enabledElement.viewport.hflip) {\n transform.scale(-1, 1);\n }\n\n if (enabledElement.viewport.vflip) {\n transform.scale(1, -1);\n }\n\n // Move back from center of image\n transform.translate(-width / 2, -height / 2);\n\n // Move to displayedArea\n transform.translate(-offsetX, -offsetY);\n\n return transform;\n}\n", "import calculateTransform from './calculateTransform.js';\n\nexport default function (enabledElement) {\n // For now we will calculate it every time it is requested.\n // In the future, we may want to cache it in the enabled element to speed things up.\n return calculateTransform(enabledElement);\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport getTransform from './internal/getTransform.js';\n\n/**\n * Converts a point in the canvas coordinate system to the pixel coordinate system\n * system. This can be used to reset tools' image coordinates after modifications\n * have been made in canvas space (e.g. moving a tool by a few cm, independent of\n * image resolution).\n *\n * @param {HTMLElement} element The Cornerstone element within which the input point lies\n * @param {{x: Number, y: Number}} pt The input point in the canvas coordinate system\n *\n * @returns {{x: Number, y: Number}} The transformed point in the pixel coordinate system\n * @memberof PixelCoordinateSystem\n */\nexport default function (element, pt) {\n const enabledElement = getEnabledElement(element);\n const transform = getTransform(enabledElement);\n\n transform.invert();\n\n return transform.transformPoint(pt.x, pt.y);\n}\n", "import { getEnabledElements } from './enabledElements.js';\r\nimport triggerEvent from './triggerEvent.js';\r\nimport EVENTS, { events } from './events.js';\r\n\r\n/**\r\n * Disable an HTML element for further use in Cornerstone\r\n *\r\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\r\n * @returns {void}\r\n * @memberof Enable\r\n */\r\nexport default function (element) {\r\n if (element === undefined) {\r\n throw new Error('disable: element must not be undefined');\r\n }\r\n\r\n // Search for this element in this list of enabled elements\r\n const enabledElements = getEnabledElements();\r\n\r\n for (let i = 0; i < enabledElements.length; i++) {\r\n if (enabledElements[i].element === element) {\r\n // We found it!\r\n\r\n // Fire an event so dependencies can cleanup\r\n const eventData = {\r\n element\r\n };\r\n\r\n triggerEvent(element, EVENTS.ELEMENT_DISABLED, eventData);\r\n triggerEvent(events, EVENTS.ELEMENT_DISABLED, eventData);\r\n\r\n // Remove the child DOM elements that we created (e.g.canvas)\r\n enabledElements[i].element.removeChild(enabledElements[i].canvas);\r\n enabledElements[i].canvas = undefined;\r\n\r\n // Remove this element from the list of enabled elements\r\n enabledElements.splice(i, 1);\r\n\r\n break;\r\n }\r\n }\r\n}\r\n", "/**\n * @module Polyfills\n */\n\n/**\n * Use the performance.now() method if possible, and if not, use Date.now()\n *\n * @return {number} Time elapsed since the time origin\n * @memberof Polyfills\n */\nexport default function () {\n if (window.performance) {\n return performance.now();\n }\n\n return Date.now();\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport getDefaultViewport from './internal/getDefaultViewport.js';\nimport updateImage from './updateImage.js';\nimport now from './internal/now.js';\nimport { setLayerImage } from './layers.js';\nimport triggerEvent from './triggerEvent.js';\nimport EVENTS from './events.js';\n\n/**\n * Sets a new image object for a given element.\n *\n * Will also apply an optional viewport setting.\n *\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\n * @param {Object} image An Image loaded by a Cornerstone Image Loader\n * @param {Object} [viewport] A set of Cornerstone viewport parameters\n * @returns {void}\n * @memberof Drawing\n */\nexport default function (element, image, viewport) {\n if (element === undefined) {\n throw new Error('displayImage: parameter element must not be undefined');\n }\n if (image === undefined) {\n throw new Error('displayImage: parameter image must not be undefined');\n }\n\n const enabledElement = getEnabledElement(element);\n const oldImage = enabledElement.image;\n\n enabledElement.image = image;\n\n if (enabledElement.layers && enabledElement.layers.length) {\n setLayerImage(element, image);\n }\n\n if (enabledElement.viewport === undefined) {\n enabledElement.viewport = getDefaultViewport(enabledElement.canvas, image);\n }\n\n // Merge viewport\n if (viewport) {\n for (const attrname in viewport) {\n if (viewport[attrname] !== null) {\n enabledElement.viewport[attrname] = viewport[attrname];\n }\n }\n }\n\n let frameRate;\n\n if (enabledElement.lastImageTimeStamp !== undefined) {\n const timeSinceLastImage = now() - enabledElement.lastImageTimeStamp;\n\n frameRate = (1000 / timeSinceLastImage).toFixed();\n }\n\n enabledElement.lastImageTimeStamp = now();\n\n const newImageEventData = {\n viewport: enabledElement.viewport,\n element: enabledElement.element,\n image: enabledElement.image,\n oldImage,\n enabledElement,\n frameRate\n };\n\n triggerEvent(enabledElement.element, EVENTS.NEW_IMAGE, newImageEventData);\n\n updateImage(element);\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport drawImage from './internal/drawImage.js';\n\n/**\n * Immediately draws the enabled element\n *\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\n * @returns {void}\n * @memberof Drawing\n */\nexport default function (element) {\n const enabledElement = getEnabledElement(element);\n\n drawImage(enabledElement);\n}\n", "/**\n * This module is responsible for drawing invalidated enabled elements\n */\n\nimport { getEnabledElements } from './enabledElements.js';\nimport drawImage from './internal/drawImage.js';\n\n/**\n * Draws all invalidated enabled elements and clears the invalid flag after drawing it\n *\n * @returns {void}\n * @memberof Drawing\n */\nexport default function () {\n const enabledElements = getEnabledElements();\n\n for (let i = 0; i < enabledElements.length; i++) {\n const ee = enabledElements[i];\n\n if (ee.invalid === true) {\n drawImage(ee, true);\n }\n }\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport updateImage from './updateImage.js';\nimport getImageFitScale from './internal/getImageFitScale.js';\n\n/**\n * Adjusts an image's scale and translation so the image is centered and all pixels\n * in the image are viewable.\n *\n * @param {HTMLElement} element The Cornerstone element to update\n * @returns {void}\n */\nexport default function (element) {\n const enabledElement = getEnabledElement(element);\n const { image } = enabledElement;\n\n // The new scale is the minimum of the horizontal and vertical scale values\n enabledElement.viewport.scale = getImageFitScale(enabledElement.canvas, image, enabledElement.viewport.rotation).scaleFactor;\n\n enabledElement.viewport.translation.x = 0;\n enabledElement.viewport.translation.y = 0;\n updateImage(element);\n}\n", "import { getEnabledElement } from './enabledElements.js';\r\nimport fitToWindow from './fitToWindow.js';\r\nimport updateImage from './updateImage.js';\r\nimport triggerEvent from './triggerEvent.js';\r\nimport getImageSize from './internal/getImageSize.js';\r\nimport EVENTS from './events.js';\r\n\r\n/**\r\n * This module is responsible for enabling an element to display images with cornerstone\r\n *\r\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\r\n * @param {HTMLElement} canvas The Canvas DOM element within the DOM element enabled for Cornerstone\r\n * @returns {void}\r\n */\r\nfunction setCanvasSize (element, canvas) {\r\n // The device pixel ratio is 1.0 for normal displays and > 1.0\r\n // For high DPI displays like Retina\r\n /*\r\n\r\n This functionality is disabled due to buggy behavior on systems with mixed DPI's. If the canvas\r\n is created on a display with high DPI (e.g. 2.0) and then the browser window is dragged to\r\n a different display with a different DPI (e.g. 1.0), the canvas is not recreated so the pageToPixel\r\n produces incorrect results. I couldn't find any way to determine when the DPI changed other than\r\n by polling which is not very clean. If anyone has any ideas here, please let me know, but for now\r\n we will disable this functionality. We may want\r\n to add a mechanism to optionally enable this functionality if we can determine it is safe to do\r\n so (e.g. iPad or iPhone or perhaps enumerate the displays on the system. I am choosing\r\n to be cautious here since I would rather not have bug reports or safety issues related to this\r\n scenario.\r\n\r\n var devicePixelRatio = window.devicePixelRatio;\r\n if(devicePixelRatio === undefined) {\r\n devicePixelRatio = 1.0;\r\n }\r\n */\r\n\r\n // Avoid setting the same value because it flashes the canvas with IE and Edge\r\n if (canvas.width !== element.clientWidth) {\r\n canvas.width = element.clientWidth;\r\n canvas.style.width = `${element.clientWidth}px`;\r\n }\r\n // Avoid setting the same value because it flashes the canvas with IE and Edge\r\n if (canvas.height !== element.clientHeight) {\r\n canvas.height = element.clientHeight;\r\n canvas.style.height = `${element.clientHeight}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Checks if the image of a given enabled element fitted the window\r\n * before the resize\r\n *\r\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element\r\n * @param {number} oldCanvasWidth The width of the canvas before the resize\r\n * @param {number} oldCanvasHeight The height of the canvas before the resize\r\n * @return {Boolean} true if it fitted the windows, false otherwise\r\n */\r\nfunction wasFitToWindow (enabledElement, oldCanvasWidth, oldCanvasHeight) {\r\n const scale = enabledElement.viewport.scale;\r\n const imageSize = getImageSize(enabledElement.image, enabledElement.viewport.rotation);\r\n const imageWidth = Math.round(imageSize.width * scale);\r\n const imageHeight = Math.round(imageSize.height * scale);\r\n const x = enabledElement.viewport.translation.x;\r\n const y = enabledElement.viewport.translation.y;\r\n\r\n return (imageWidth === oldCanvasWidth && imageHeight <= oldCanvasHeight) ||\r\n (imageWidth <= oldCanvasWidth && imageHeight === oldCanvasHeight) &&\r\n (x === 0 && y === 0);\r\n}\r\n\r\n/**\r\n * Rescale the image relative to the changed size of the canvas\r\n *\r\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element\r\n * @param {number} oldCanvasWidth The width of the canvas before the resize\r\n * @param {number} oldCanvasHeight The height of the canvas before the resize\r\n * @return {void}\r\n */\r\nfunction relativeRescale (enabledElement, oldCanvasWidth, oldCanvasHeight) {\r\n const scale = enabledElement.viewport.scale;\r\n const canvasWidth = enabledElement.canvas.width;\r\n const canvasHeight = enabledElement.canvas.height;\r\n const relWidthChange = canvasWidth / oldCanvasWidth;\r\n const relHeightChange = canvasHeight / oldCanvasHeight;\r\n const relChange = Math.sqrt(relWidthChange * relHeightChange);\r\n\r\n enabledElement.viewport.scale = relChange * scale;\r\n}\r\n\r\n/**\r\n * Resizes an enabled element and optionally fits the image to window\r\n *\r\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\r\n * @param {Boolean} forceFitToWindow true to to force a refit, false to rescale accordingly\r\n * @returns {void}\r\n */\r\nexport default function (element, forceFitToWindow) {\r\n const enabledElement = getEnabledElement(element);\r\n\r\n const oldCanvasWidth = enabledElement.canvas.width;\r\n const oldCanvasHeight = enabledElement.canvas.height;\r\n\r\n setCanvasSize(element, enabledElement.canvas);\r\n\r\n const eventData = { element };\r\n\r\n triggerEvent(element, EVENTS.ELEMENT_RESIZED, eventData);\r\n\r\n if (enabledElement.image === undefined) {\r\n return;\r\n }\r\n\r\n if (forceFitToWindow || wasFitToWindow(enabledElement, oldCanvasWidth, oldCanvasHeight)) {\r\n // Fit the image to the window again if it fitted before the resize\r\n fitToWindow(element);\r\n } else {\r\n // Adapt the scale of a zoomed or panned image relative to the size change\r\n relativeRescale(enabledElement, oldCanvasWidth, oldCanvasHeight);\r\n\r\n updateImage(element);\r\n }\r\n}\r\n", "/**\n * Get current fillStyle for enabled element\n *\n * @param {Object} enabledElement Enabled element\n * @returns {String} Current fillStyle of enabled element\n */\nexport default function (enabledElement) {\n const { invert } = enabledElement.viewport || {};\n const { fillStyle } = enabledElement.options || {};\n\n if (['black', 'white'].indexOf(fillStyle) !== -1) {\n return invert ? 'white' : 'black';\n }\n\n return 'black';\n}\n", "import now from './now.js';\n\n/**\n * This function transforms stored pixel values into a canvas image data buffer\n * by using a LUT. This is the most performance sensitive code in cornerstone and\n * we use a special trick to make this go as fast as possible. Specifically we\n * use the alpha channel only to control the luminance rather than the red, green and\n * blue channels which makes it over 3x faster. The canvasImageDataData buffer needs\n * to be previously filled with white pixels.\n *\n * NOTE: Attribution would be appreciated if you use this technique!\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {Array} lut Lookup table array\n * @param {Uint8ClampedArray} canvasImageDataData canvasImageData.data buffer filled with white pixels\n *\n * @returns {void}\n * @memberof Internal\n */\nexport default function (image, lut, canvasImageDataData) {\n let start = now();\n const pixelData = image.getPixelData();\n\n image.stats.lastGetPixelDataTime = now() - start;\n\n const numPixels = pixelData.length;\n const minPixelValue = image.minPixelValue;\n let canvasImageDataIndex = 3;\n let storedPixelDataIndex = 0;\n\n\n // NOTE: As of Nov 2014, most javascript engines have lower performance when indexing negative indexes.\n // We have a special code path for this case that improves performance. Thanks to @jpambrun for this enhancement\n\n // Added two paths (Int16Array, Uint16Array) to avoid polymorphic deoptimization in chrome.\n start = now();\n if (pixelData instanceof Int16Array) {\n if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex] = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)]; // Alpha\n canvasImageDataIndex += 4;\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex] = lut[pixelData[storedPixelDataIndex++]]; // Alpha\n canvasImageDataIndex += 4;\n }\n }\n } else if (pixelData instanceof Uint16Array) {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex] = lut[pixelData[storedPixelDataIndex++]]; // Alpha\n canvasImageDataIndex += 4;\n }\n } else if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex] = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)]; // Alpha\n canvasImageDataIndex += 4;\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex] = lut[pixelData[storedPixelDataIndex++]]; // Alpha\n canvasImageDataIndex += 4;\n }\n }\n\n image.stats.lastStoredPixelDataToCanvasImageDataTime = now() - start;\n}\n", "import now from './now.js';\n\n/**\n * This function transforms stored pixel values into a canvas image data buffer\n * by using a LUT.\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {Array} lut Lookup table array\n * @param {Uint8ClampedArray} canvasImageDataData canvasImageData.data buffer filled with white pixels\n *\n * @returns {void}\n * @memberof Internal\n */\nexport default function (image, lut, canvasImageDataData) {\n let start = now();\n const pixelData = image.getPixelData();\n\n image.stats.lastGetPixelDataTime = now() - start;\n\n const numPixels = pixelData.length;\n const minPixelValue = image.minPixelValue;\n let canvasImageDataIndex = 0;\n let storedPixelDataIndex = 0;\n let pixelValue;\n\n // NOTE: As of Nov 2014, most javascript engines have lower performance when indexing negative indexes.\n // We have a special code path for this case that improves performance. Thanks to @jpambrun for this enhancement\n\n // Added two paths (Int16Array, Uint16Array) to avoid polymorphic deoptimization in chrome.\n start = now();\n if (pixelData instanceof Int16Array) {\n if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n pixelValue = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)];\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = 255; // Alpha\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n pixelValue = lut[pixelData[storedPixelDataIndex++]];\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = 255; // Alpha\n }\n }\n } else if (pixelData instanceof Uint16Array) {\n while (storedPixelDataIndex < numPixels) {\n pixelValue = lut[pixelData[storedPixelDataIndex++]];\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = 255; // Alpha\n }\n } else if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n pixelValue = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)];\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = 255; // Alpha\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n pixelValue = lut[pixelData[storedPixelDataIndex++]];\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = pixelValue;\n canvasImageDataData[canvasImageDataIndex++] = 255; // Alpha\n }\n }\n\n image.stats.lastStoredPixelDataToCanvasImageDataTime = now() - start;\n}\n", "import calculateTransform from './internal/calculateTransform.js';\n\n/**\n * Sets the canvas context transformation matrix to the pixel coordinate system. This allows\n * geometry to be driven using the canvas context using coordinates in the pixel coordinate system\n * @param {EnabledElement} enabledElement The\n * @param {CanvasRenderingContext2D} context The CanvasRenderingContext2D for the enabledElement's Canvas\n * @param {Number} [scale] Optional scale to apply\n * @returns {void}\n */\nexport default function (enabledElement, context, scale) {\n if (enabledElement === undefined) {\n throw new Error('setToPixelCoordinateSystem: parameter enabledElement must not be undefined');\n }\n if (context === undefined) {\n throw new Error('setToPixelCoordinateSystem: parameter context must not be undefined');\n }\n\n const transform = calculateTransform(enabledElement, scale);\n\n context.setTransform(transform.m[0], transform.m[1], transform.m[2], transform.m[3], transform.m[4], transform.m[5]);\n}\n", "/* eslint no-bitwise: 0 */\n\nconst int16Shader = {};\n\n/**\n * Convert stored pixel data to image data.\n *\n * Pack int16 into three uint8 channels (r, g, b)\n *\n * @param {Image} image A Cornerstone Image Object\n * @returns {Uint8Array} The image data for use by the WebGL shader\n * @memberof WebGLRendering\n */\nfunction storedPixelDataToImageData (image) {\n\n // Transfer image data to alpha and luminance channels of WebGL texture\n // Credit to @jpambrun and @fernandojsg\n\n // Pack int16 into three uint8 channels (r, g, b)\n const pixelData = image.getPixelData();\n const numberOfChannels = 3;\n const data = new Uint8Array(image.width * image.height * numberOfChannels);\n let offset = 0;\n\n for (let i = 0; i < pixelData.length; i++) {\n const val = Math.abs(pixelData[i]);\n\n data[offset++] = val & 0xFF;\n data[offset++] = val >> 8;\n data[offset++] = pixelData[i] < 0 ? 0 : 1; // 0 For negative, 1 for positive\n }\n\n return data;\n}\n\nexport const int16DataUtilities = {\n storedPixelDataToImageData\n};\n\nint16Shader.frag = 'precision mediump float;' +\n 'uniform sampler2D u_image;' +\n 'uniform float ww;' +\n 'uniform float wc;' +\n 'uniform float slope;' +\n 'uniform float intercept;' +\n 'uniform int invert;' +\n 'varying vec2 v_texCoord;' +\n\n 'void main() {' +\n // Get texture\n 'vec4 color = texture2D(u_image, v_texCoord);' +\n\n // Calculate luminance from packed texture\n 'float intensity = color.r*256.0 + color.g*65536.0;' +\n\n 'if (color.b == 0.0)' +\n 'intensity = -intensity;' +\n\n // Rescale based on slope and window settings\n 'intensity = intensity * slope + intercept;' +\n 'float center0 = wc - 0.5;' +\n 'float width0 = max(ww, 1.0);' +\n 'intensity = (intensity - center0) / width0 + 0.5;' +\n\n // Clamp intensity\n 'intensity = clamp(intensity, 0.0, 1.0);' +\n\n // RGBA output\n 'gl_FragColor = vec4(intensity, intensity, intensity, 1.0);' +\n\n // Apply any inversion necessary\n 'if (invert == 1)' +\n 'gl_FragColor.rgb = 1.0 - gl_FragColor.rgb;' +\n '}';\n\nexport { int16Shader };\n", "const int8Shader = {};\n\n/**\n * Convert stored pixel data to image data.\n *\n * Store data in Uint8Array\n *\n * @param {Image} image A Cornerstone Image Object\n * @returns {Uint8Array} The image data for use by the WebGL shader\n * @memberof WebGLRendering\n */\nfunction storedPixelDataToImageData (image) {\n // Transfer image data to alpha channel of WebGL texture\n // Store data in Uint8Array\n const pixelData = image.getPixelData();\n const numberOfChannels = 2;\n const data = new Uint8Array(image.width * image.height * numberOfChannels);\n let offset = 0;\n\n for (let i = 0; i < pixelData.length; i++) {\n data[offset++] = pixelData[i];\n data[offset++] = pixelData[i] < 0 ? 0 : 1; // 0 For negative, 1 for positive\n }\n\n return data;\n}\n\nexport const int8DataUtilities = {\n storedPixelDataToImageData\n};\n\nint8Shader.frag = 'precision mediump float;' +\n 'uniform sampler2D u_image;' +\n 'uniform float ww;' +\n 'uniform float wc;' +\n 'uniform float slope;' +\n 'uniform float intercept;' +\n 'uniform int invert;' +\n 'varying vec2 v_texCoord;' +\n\n 'void main() {' +\n // Get texture\n 'vec4 color = texture2D(u_image, v_texCoord);' +\n\n // Calculate luminance from packed texture\n 'float intensity = color.r*256.;' +\n\n 'if (color.a == 0.0)' +\n 'intensity = -intensity;' +\n\n // Rescale based on slope and window settings\n 'intensity = intensity * slope + intercept;' +\n 'float center0 = wc - 0.5;' +\n 'float width0 = max(ww, 1.0);' +\n 'intensity = (intensity - center0) / width0 + 0.5;' +\n\n // Clamp intensity\n 'intensity = clamp(intensity, 0.0, 1.0);' +\n\n // RGBA output\n 'gl_FragColor = vec4(intensity, intensity, intensity, 1.0);' +\n\n // Apply any inversion necessary\n 'if (invert == 1)' +\n 'gl_FragColor.rgb = 1.0 - gl_FragColor.rgb;' +\n '}';\n\nexport { int8Shader };\n", "const rgbShader = {};\n\n/**\n * Convert stored pixel data to image data.\n *\n * Pack RGB images into a 3-channel RGB texture\n *\n * @param {Image} image A Cornerstone Image Object\n * @returns {Uint8Array} The image data for use by the WebGL shader\n * @memberof WebGLRendering\n */\nfunction storedPixelDataToImageData (image) {\n const minPixelValue = image.minPixelValue;\n let canvasImageDataIndex = 0;\n let storedPixelDataIndex = 0;\n // Only 3 channels, since we use WebGL's RGB texture format\n const numStoredPixels = image.width * image.height * 4;\n const numOutputPixels = image.width * image.height * 3;\n const storedPixelData = image.getPixelData();\n const data = new Uint8Array(numOutputPixels);\n\n // NOTE: As of Nov 2014, most javascript engines have lower performance when indexing negative indexes.\n // We have a special code path for this case that improves performance. Thanks to @jpambrun for this enhancement\n if (minPixelValue < 0) {\n while (storedPixelDataIndex < numStoredPixels) {\n data[canvasImageDataIndex++] = storedPixelData[storedPixelDataIndex++] + (-minPixelValue); // Red\n data[canvasImageDataIndex++] = storedPixelData[storedPixelDataIndex++] + (-minPixelValue); // Green\n data[canvasImageDataIndex++] = storedPixelData[storedPixelDataIndex++] + (-minPixelValue); // Blue\n storedPixelDataIndex += 1; // The stored pixel data has 4 channels\n }\n } else {\n while (storedPixelDataIndex < numStoredPixels) {\n data[canvasImageDataIndex++] = storedPixelData[storedPixelDataIndex++]; // Red\n data[canvasImageDataIndex++] = storedPixelData[storedPixelDataIndex++]; // Green\n data[canvasImageDataIndex++] = storedPixelData[storedPixelDataIndex++]; // Blue\n storedPixelDataIndex += 1; // The stored pixel data has 4 channels\n }\n }\n\n return data;\n}\n\nexport const rgbDataUtilities = {\n storedPixelDataToImageData\n};\n\nrgbShader.frag = 'precision mediump float;' +\n 'uniform sampler2D u_image;' +\n 'uniform float ww;' +\n 'uniform float wc;' +\n 'uniform float slope;' +\n 'uniform float intercept;' +\n 'uniform float minPixelValue;' +\n 'uniform int invert;' +\n 'varying vec2 v_texCoord;' +\n\n 'void main() {' +\n\n // Get texture\n 'vec3 color = texture2D(u_image, v_texCoord).xyz;' +\n\n // Rescale based on slope and intercept\n 'color = color * 256.0 * slope + intercept;' +\n\n // Apply window settings\n 'float center0 = wc - 0.5 - minPixelValue;' +\n 'float width0 = max(ww, 1.0);' +\n 'color = (color - center0) / width0 + 0.5;' +\n\n // RGBA output\n 'gl_FragColor = vec4(color, 1);' +\n\n // Apply any inversion necessary\n 'if (invert == 1)' +\n 'gl_FragColor.rgb = 1. - gl_FragColor.rgb;' +\n '}';\n\nexport { rgbShader };\n", "/* eslint no-bitwise: 0 */\n\nconst uint16Shader = {};\n\n/**\n * Convert stored pixel data to image data.\n *\n * For uint16 pack uint16 into two uint8 channels (r and a).\n *\n * @param {Image} image A Cornerstone Image Object\n * @returns {Uint8Array} The image data for use by the WebGL shader\n * @memberof WebGLRendering\n */\nfunction storedPixelDataToImageData (image) {\n\n // Transfer image data to alpha and luminance channels of WebGL texture\n // Credit to @jpambrun and @fernandojsg\n\n // Pack uint16 into two uint8 channels (r and a)\n const pixelData = image.getPixelData();\n const numberOfChannels = 2;\n const data = new Uint8Array(image.width * image.height * numberOfChannels);\n let offset = 0;\n\n for (let i = 0; i < pixelData.length; i++) {\n const val = pixelData[i];\n\n data[offset++] = val & 0xFF;\n data[offset++] = val >> 8;\n }\n\n return data;\n}\n\nexport const uint16DataUtilities = {\n storedPixelDataToImageData\n};\n\nuint16Shader.frag = 'precision mediump float;' +\n 'uniform sampler2D u_image;' +\n 'uniform float ww;' +\n 'uniform float wc;' +\n 'uniform float slope;' +\n 'uniform float intercept;' +\n 'uniform int invert;' +\n 'varying vec2 v_texCoord;' +\n\n 'void main() {' +\n // Get texture\n 'vec4 color = texture2D(u_image, v_texCoord);' +\n\n // Calculate luminance from packed texture\n 'float intensity = color.r*256.0 + color.a*65536.0;' +\n\n // Rescale based on slope and window settings\n 'intensity = intensity * slope + intercept;' +\n 'float center0 = wc - 0.5;' +\n 'float width0 = max(ww, 1.0);' +\n 'intensity = (intensity - center0) / width0 + 0.5;' +\n\n // Clamp intensity\n 'intensity = clamp(intensity, 0.0, 1.0);' +\n\n // RGBA output\n 'gl_FragColor = vec4(intensity, intensity, intensity, 1.0);' +\n\n // Apply any inversion necessary\n 'if (invert == 1)' +\n 'gl_FragColor.rgb = 1.0 - gl_FragColor.rgb;' +\n '}';\n\nexport { uint16Shader };\n", "const uint8Shader = {};\n\n/**\n * Convert stored pixel data to image data. Here we will store\n * all data in the alpha channel.\n *\n * @param {Image} image A Cornerstone Image Object\n * @returns {Uint8Array} The image data for use by the WebGL shader\n * @memberof WebGLRendering\n */\nfunction storedPixelDataToImageData (image) {\n // Transfer image data to alpha channel of WebGL texture\n return image.getPixelData();\n}\n\nexport const uint8DataUtilities = {\n storedPixelDataToImageData\n};\n\nuint8Shader.frag = 'precision mediump float;' +\n 'uniform sampler2D u_image;' +\n 'uniform float ww;' +\n 'uniform float wc;' +\n 'uniform float slope;' +\n 'uniform float intercept;' +\n 'uniform int invert;' +\n 'varying vec2 v_texCoord;' +\n\n 'void main() {' +\n // Get texture\n 'vec4 color = texture2D(u_image, v_texCoord);' +\n\n // Calculate luminance from packed texture\n 'float intensity = color.r*256.0;' +\n\n // Rescale based on slope and window settings\n 'intensity = intensity * slope + intercept;' +\n 'float center0 = wc - 0.5;' +\n 'float width0 = max(ww, 1.0);' +\n 'intensity = (intensity - center0) / width0 + 0.5;' +\n\n // Clamp intensity\n 'intensity = clamp(intensity, 0.0, 1.0);' +\n\n // RGBA output\n 'gl_FragColor = vec4(intensity, intensity, intensity, 1.0);' +\n\n // Apply any inversion necessary\n 'if (invert == 1)' +\n 'gl_FragColor.rgb = 1.0 - gl_FragColor.rgb;' +\n '}';\n\nexport { uint8Shader };\n", "import { int16Shader, int16DataUtilities } from './int16.js';\nimport { int8Shader, int8DataUtilities } from './int8.js';\nimport { rgbShader, rgbDataUtilities } from './rgb.js';\nimport { uint16Shader, uint16DataUtilities } from './uint16.js';\nimport { uint8Shader, uint8DataUtilities } from './uint8.js';\n\nconst shaders = {\n int16: int16Shader,\n int8: int8Shader,\n rgb: rgbShader,\n uint16: uint16Shader,\n uint8: uint8Shader\n};\n\nconst dataUtilities = {\n int16: int16DataUtilities,\n int8: int8DataUtilities,\n rgb: rgbDataUtilities,\n uint16: uint16DataUtilities,\n uint8: uint8DataUtilities\n};\n\nexport { shaders, dataUtilities };\n", "export const vertexShader = 'attribute vec2 a_position;' +\n 'attribute vec2 a_texCoord;' +\n 'uniform vec2 u_resolution;' +\n 'varying vec2 v_texCoord;' +\n 'void main() {' +\n 'vec2 zeroToOne = a_position / u_resolution;' +\n 'vec2 zeroToTwo = zeroToOne * 2.0;' +\n 'vec2 clipSpace = zeroToTwo - 1.0;' +\n 'gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);' +\n 'v_texCoord = a_texCoord;' +\n '}';\n", "import EVENTS, { events } from '../events.js';\r\nimport triggerEvent from '../triggerEvent.js';\r\n\r\n/**\r\n * This module deals with caching image textures in VRAM for WebGL\r\n * @module WebGLTextureCache\r\n */\r\n\r\nconst imageCache = {};\r\n\r\nconst cachedImages = [];\r\n\r\nlet maximumSizeInBytes = 1024 * 1024 * 256; // 256 MB\r\nlet cacheSizeInBytes = 0;\r\n\r\nfunction getCacheInfo () {\r\n return {\r\n maximumSizeInBytes,\r\n cacheSizeInBytes,\r\n numberOfImagesCached: cachedImages.length\r\n };\r\n}\r\n\r\nfunction purgeCacheIfNecessary () {\r\n // If max cache size has not been exceeded, do nothing\r\n if (cacheSizeInBytes <= maximumSizeInBytes) {\r\n return;\r\n }\r\n\r\n // Cache size has been exceeded, create list of images sorted by timeStamp\r\n // So we can purge the least recently used image\r\n function compare (a, b) {\r\n if (a.timeStamp > b.timeStamp) {\r\n return -1;\r\n }\r\n if (a.timeStamp < b.timeStamp) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n }\r\n cachedImages.sort(compare);\r\n\r\n // Remove images as necessary\r\n while (cacheSizeInBytes > maximumSizeInBytes) {\r\n const lastCachedImage = cachedImages[cachedImages.length - 1];\r\n\r\n cacheSizeInBytes -= lastCachedImage.sizeInBytes;\r\n delete imageCache[lastCachedImage.imageId];\r\n cachedImages.pop();\r\n\r\n triggerEvent(events, EVENTS.WEBGL_TEXTURE_REMOVED, { imageId: lastCachedImage.imageId });\r\n }\r\n\r\n const cacheInfo = getCacheInfo();\r\n\r\n triggerEvent(events, EVENTS.WEBGL_TEXTURE_CACHE_FULL, cacheInfo);\r\n}\r\n\r\nfunction setMaximumSizeBytes (numBytes) {\r\n if (numBytes === undefined) {\r\n throw new Error('setMaximumSizeBytes: parameter numBytes must not be undefined');\r\n }\r\n if (numBytes.toFixed === undefined) {\r\n throw new Error('setMaximumSizeBytes: parameter numBytes must be a number');\r\n }\r\n\r\n maximumSizeInBytes = numBytes;\r\n purgeCacheIfNecessary();\r\n}\r\n\r\nfunction putImageTexture (image, imageTexture) {\r\n const imageId = image.imageId;\r\n\r\n if (image === undefined) {\r\n throw new Error('putImageTexture: image must not be undefined');\r\n }\r\n\r\n if (imageId === undefined) {\r\n throw new Error('putImageTexture: imageId must not be undefined');\r\n }\r\n\r\n if (imageTexture === undefined) {\r\n throw new Error('putImageTexture: imageTexture must not be undefined');\r\n }\r\n\r\n if (Object.prototype.hasOwnProperty.call(imageCache, imageId) === true) {\r\n throw new Error('putImageTexture: imageId already in cache');\r\n }\r\n\r\n const cachedImage = {\r\n imageId,\r\n imageTexture,\r\n timeStamp: new Date(),\r\n sizeInBytes: imageTexture.sizeInBytes\r\n };\r\n\r\n imageCache[imageId] = cachedImage;\r\n cachedImages.push(cachedImage);\r\n\r\n if (imageTexture.sizeInBytes === undefined) {\r\n throw new Error('putImageTexture: imageTexture.sizeInBytes must not be undefined');\r\n }\r\n if (imageTexture.sizeInBytes.toFixed === undefined) {\r\n throw new Error('putImageTexture: imageTexture.sizeInBytes is not a number');\r\n }\r\n cacheSizeInBytes += cachedImage.sizeInBytes;\r\n purgeCacheIfNecessary();\r\n}\r\n\r\nfunction getImageTexture (imageId) {\r\n if (imageId === undefined) {\r\n throw new Error('getImageTexture: imageId must not be undefined');\r\n }\r\n const cachedImage = imageCache[imageId];\r\n\r\n if (cachedImage === undefined) {\r\n return;\r\n }\r\n\r\n // Bump time stamp for cached image\r\n cachedImage.timeStamp = new Date();\r\n\r\n return cachedImage.imageTexture;\r\n}\r\n\r\nfunction removeImageTexture (imageId) {\r\n if (imageId === undefined) {\r\n throw new Error('removeImageTexture: imageId must not be undefined');\r\n }\r\n const cachedImage = imageCache[imageId];\r\n\r\n if (cachedImage === undefined) {\r\n throw new Error('removeImageTexture: imageId must not be undefined');\r\n }\r\n cachedImages.splice(cachedImages.indexOf(cachedImage), 1);\r\n cacheSizeInBytes -= cachedImage.sizeInBytes;\r\n delete imageCache[imageId];\r\n\r\n return cachedImage.imageTexture;\r\n}\r\n\r\nfunction purgeCache () {\r\n while (cachedImages.length > 0) {\r\n const removedCachedImage = cachedImages.pop();\r\n\r\n delete imageCache[removedCachedImage.imageId];\r\n }\r\n cacheSizeInBytes = 0;\r\n}\r\n\r\nexport default {\r\n purgeCache,\r\n getImageTexture,\r\n putImageTexture,\r\n removeImageTexture,\r\n setMaximumSizeBytes\r\n};\r\n", "/**\n * Creates and compiles a shader.\n *\n * @param {!WebGLRenderingContext} gl The WebGL Context.\n * @param {string} shaderSource The GLSL source code for the shader.\n * @param {number} shaderType The type of shader, VERTEX_SHADER or FRAGMENT_SHADER.\n *\n * @return {!WebGLShader} The shader.\n * @memberof WebGLRendering\n */\nfunction compileShader (gl, shaderSource, shaderType) {\n\n // Create the shader object\n const shader = gl.createShader(shaderType);\n\n // Set the shader source code.\n gl.shaderSource(shader, shaderSource);\n\n // Compile the shader\n gl.compileShader(shader);\n\n // Check if it compiled\n const success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);\n\n if (!success && !gl.isContextLost()) {\n // Something went wrong during compilation; get the error\n const infoLog = gl.getShaderInfoLog(shader);\n\n console.error(`Could not compile shader:\\n${infoLog}`);\n }\n\n return shader;\n}\n\n/**\n * Creates a program from 2 shaders.\n *\n * @param {!WebGLRenderingContext} gl The WebGL context.\n * @param {!WebGLShader} vertexShader A vertex shader.\n * @param {!WebGLShader} fragmentShader A fragment shader.\n * @return {!WebGLProgram} A program.\n * @memberof WebGLRendering\n */\nfunction createProgram (gl, vertexShader, fragmentShader) {\n\n // Create a program.\n const program = gl.createProgram();\n\n // Attach the shaders.\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n\n // Link the program.\n gl.linkProgram(program);\n\n // Check if it linked.\n const success = gl.getProgramParameter(program, gl.LINK_STATUS);\n\n if (!success && !gl.isContextLost()) {\n // Something went wrong with the link\n const infoLog = gl.getProgramInfoLog(program);\n\n console.error(`WebGL program filed to link:\\n${infoLog}`);\n }\n\n return program;\n}\n\n/**\n * Creates a program from 2 shaders source (Strings)\n * @param {!WebGLRenderingContext} gl The WebGL context.\n * @param {!WebGLShader} vertexShaderSrc Vertex shader string\n * @param {!WebGLShader} fragShaderSrc Fragment shader string\n * @return {!WebGLProgram} A program\n * @memberof WebGLRendering\n */\nexport default function (gl, vertexShaderSrc, fragShaderSrc) {\n const vertexShader = compileShader(gl, vertexShaderSrc, gl.VERTEX_SHADER);\n const fragShader = compileShader(gl, fragShaderSrc, gl.FRAGMENT_SHADER);\n\n\n return createProgram(gl, vertexShader, fragShader);\n}\n", "/* eslint no-bitwise: 0 */\n\nimport { shaders, dataUtilities } from './shaders/index.js';\nimport { vertexShader } from './vertexShader.js';\nimport textureCache from './textureCache.js';\nimport createProgramFromString from './createProgramFromString.js';\n\nconst renderCanvas = document.createElement('canvas');\nlet gl;\nlet texCoordBuffer;\nlet positionBuffer;\nlet isWebGLInitialized = false;\n\nexport { isWebGLInitialized };\n\nexport function getRenderCanvas () {\n return renderCanvas;\n}\n\nfunction initShaders () {\n for (const id in shaders) {\n // Console.log(\"WEBGL: Loading shader\", id);\n const shader = shaders[id];\n\n shader.attributes = {};\n shader.uniforms = {};\n shader.vert = vertexShader;\n\n shader.program = createProgramFromString(gl, shader.vert, shader.frag);\n\n shader.attributes.texCoordLocation = gl.getAttribLocation(shader.program, 'a_texCoord');\n gl.enableVertexAttribArray(shader.attributes.texCoordLocation);\n\n shader.attributes.positionLocation = gl.getAttribLocation(shader.program, 'a_position');\n gl.enableVertexAttribArray(shader.attributes.positionLocation);\n\n shader.uniforms.resolutionLocation = gl.getUniformLocation(shader.program, 'u_resolution');\n }\n}\n\nexport function initRenderer () {\n if (isWebGLInitialized === true) {\n // Console.log(\"WEBGL Renderer already initialized\");\n return;\n }\n\n if (initWebGL(renderCanvas)) {\n initBuffers();\n initShaders();\n // Console.log(\"WEBGL Renderer initialized!\");\n isWebGLInitialized = true;\n }\n}\n\nfunction updateRectangle (gl, width, height) {\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([\n width, height,\n 0, height,\n width, 0,\n 0, 0]), gl.STATIC_DRAW);\n}\n\nfunction handleLostContext (event) {\n event.preventDefault();\n console.warn('WebGL Context Lost!');\n}\n\nfunction handleRestoredContext (event) {\n event.preventDefault();\n isWebGLInitialized = false;\n textureCache.purgeCache();\n initRenderer();\n // Console.log('WebGL Context Restored.');\n}\n\nfunction initWebGL (canvas) {\n\n gl = null;\n try {\n // Try to grab the standard context. If it fails, fallback to experimental.\n const options = {\n desynchronized: true,\n preserveDrawingBuffer: true // Preserve buffer so we can copy to display canvas element\n };\n\n // ---------------- Testing purposes -------------\n // If (debug === true && WebGLDebugUtils) {\n // RenderCanvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(renderCanvas);\n // }\n // ---------------- Testing purposes -------------\n\n gl = canvas.getContext('webgl', options) || canvas.getContext('experimental-webgl', options);\n\n // Set up event listeners for context lost / context restored\n canvas.removeEventListener('webglcontextlost', handleLostContext, false);\n canvas.addEventListener('webglcontextlost', handleLostContext, false);\n\n canvas.removeEventListener('webglcontextrestored', handleRestoredContext, false);\n canvas.addEventListener('webglcontextrestored', handleRestoredContext, false);\n\n } catch (error) {\n throw new Error('Error creating WebGL context');\n }\n\n // If we don't have a GL context, give up now\n if (!gl) {\n console.error('Unable to initialize WebGL. Your browser may not support it.');\n gl = null;\n }\n\n return gl;\n}\n\n/**\n * Returns the image data type as a string representation.\n * @param {any} image The cornerstone image object\n * @returns {string} image data type (rgb, iint16, uint16, int8 and uint8)\n * @memberof WebGLRendering\n */\nfunction getImageDataType (image) {\n if (image.color) {\n return 'rgb';\n }\n\n const pixelData = image.getPixelData();\n\n if (pixelData instanceof Int16Array) {\n return 'int16';\n }\n\n if (pixelData instanceof Uint16Array) {\n return 'uint16';\n }\n\n if (pixelData instanceof Int8Array) {\n return 'int8';\n }\n\n return 'uint8';\n}\n\nfunction getShaderProgram (image) {\n\n const datatype = getImageDataType(image);\n // We need a mechanism for\n // Choosing the shader based on the image datatype\n // Console.log(\"Datatype: \" + datatype);\n\n if (shaders.hasOwnProperty(datatype)) {\n return shaders[datatype];\n }\n\n return shaders.rgb;\n}\n\nfunction generateTexture (image) {\n const TEXTURE_FORMAT = {\n uint8: gl.LUMINANCE,\n int8: gl.LUMINANCE_ALPHA,\n uint16: gl.LUMINANCE_ALPHA,\n int16: gl.RGB,\n rgb: gl.RGB\n };\n\n const TEXTURE_BYTES = {\n int8: 1, // Luminance\n uint16: 2, // Luminance + Alpha\n int16: 3, // RGB\n rgb: 3 // RGB\n };\n\n const imageDataType = getImageDataType(image);\n const format = TEXTURE_FORMAT[imageDataType];\n\n // GL texture configuration\n const texture = gl.createTexture();\n\n gl.bindTexture(gl.TEXTURE_2D, texture);\n\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n\n const imageData = dataUtilities[imageDataType].storedPixelDataToImageData(image, image.width, image.height);\n\n gl.texImage2D(gl.TEXTURE_2D, 0, format, image.width, image.height, 0, format, gl.UNSIGNED_BYTE, imageData);\n\n // Calculate the size in bytes of this image in memory\n const sizeInBytes = image.width * image.height * TEXTURE_BYTES[imageDataType];\n\n return {\n texture,\n sizeInBytes\n };\n}\n\nfunction getImageTexture (image) {\n let imageTexture = textureCache.getImageTexture(image.imageId);\n\n if (!imageTexture) {\n // Console.log(\"Generating texture for imageid: \", image.imageId);\n imageTexture = generateTexture(image);\n textureCache.putImageTexture(image, imageTexture);\n }\n\n return imageTexture.texture;\n}\n\nfunction initBuffers () {\n positionBuffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([\n 1, 1,\n 0, 1,\n 1, 0,\n 0, 0\n ]), gl.STATIC_DRAW);\n\n\n texCoordBuffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([\n 1.0, 1.0,\n 0.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0\n ]), gl.STATIC_DRAW);\n}\n\nfunction renderQuad (shader, parameters, texture, width, height) {\n gl.clearColor(1.0, 0.0, 0.0, 1.0);\n gl.viewport(0, 0, width, height);\n\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n gl.useProgram(shader.program);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);\n gl.vertexAttribPointer(shader.attributes.texCoordLocation, 2, gl.FLOAT, false, 0, 0);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);\n gl.vertexAttribPointer(shader.attributes.positionLocation, 2, gl.FLOAT, false, 0, 0);\n\n for (const key in parameters) {\n const uniformLocation = gl.getUniformLocation(shader.program, key);\n\n if (!uniformLocation) {\n continue;\n\n // Disabling this error for now since RGB requires minPixelValue\n // but the other shaders do not.\n // throw `Could not access location for uniform: ${key}`;\n }\n\n const uniform = parameters[key];\n\n const type = uniform.type;\n const value = uniform.value;\n\n if (type === 'i') {\n gl.uniform1i(uniformLocation, value);\n } else if (type === 'f') {\n gl.uniform1f(uniformLocation, value);\n } else if (type === '2f') {\n gl.uniform2f(uniformLocation, value[0], value[1]);\n }\n }\n\n updateRectangle(gl, width, height);\n\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n\n}\n\nexport function render (enabledElement) {\n // Resize the canvas\n const image = enabledElement.image;\n\n renderCanvas.width = image.width;\n renderCanvas.height = image.height;\n\n const viewport = enabledElement.viewport;\n\n // Render the current image\n const shader = getShaderProgram(image);\n const texture = getImageTexture(image);\n const parameters = {\n u_resolution: { type: '2f',\n value: [image.width, image.height] },\n wc: { type: 'f',\n value: viewport.voi.windowCenter },\n ww: { type: 'f',\n value: viewport.voi.windowWidth },\n slope: { type: 'f',\n value: image.slope },\n intercept: { type: 'f',\n value: image.intercept },\n minPixelValue: { type: 'f',\n value: image.minPixelValue },\n invert: { type: 'i',\n value: viewport.invert ? 1 : 0 }\n };\n\n renderQuad(shader, parameters, texture, image.width, image.height);\n\n return renderCanvas;\n}\n\nexport function isWebGLAvailable () {\n // Adapted from\n // http://stackoverflow.com/questions/9899807/three-js-detect-webgl-support-and-fallback-to-regular-canvas\n\n const options = {\n failIfMajorPerformanceCaveat: true\n };\n\n try {\n const canvas = document.createElement('canvas');\n\n\n return Boolean(window.WebGLRenderingContext) &&\n (canvas.getContext('webgl', options) || canvas.getContext('experimental-webgl', options));\n } catch (e) {\n return false;\n }\n}\n", "import { render, initRenderer, getRenderCanvas, isWebGLAvailable, isWebGLInitialized } from './renderer.js';\nimport createProgramFromString from './createProgramFromString.js';\nimport textureCache from './textureCache.js';\n\n/**\n * @module WebGLRendering\n */\n\nconst mod = {\n createProgramFromString,\n renderer: {\n render,\n initRenderer,\n getRenderCanvas,\n isWebGLAvailable\n },\n textureCache\n};\n\nObject.defineProperty(mod, 'isWebGLInitialized', {\n enumerable: true,\n configurable: false,\n get: () => isWebGLInitialized\n});\n\nexport default mod;\n", "/**\n * Computes the VOI to display all the pixels if no VOI LUT data (Window Width/Window Center or voiLUT) exists on the viewport object.\n *\n * @param {Viewport} viewport - Object containing the viewport properties\n * @param {Object} image An Image loaded by a Cornerstone Image Loader\n * @returns {void}\n * @memberof Internal\n */\nexport default function computeAutoVoi (viewport, image) {\n if (hasVoi(viewport)) {\n return;\n }\n\n const maxVoi = image.maxPixelValue * image.slope + image.intercept;\n const minVoi = image.minPixelValue * image.slope + image.intercept;\n const ww = maxVoi - minVoi;\n const wc = (maxVoi + minVoi) / 2;\n\n if (viewport.voi === undefined) {\n viewport.voi = {\n windowWidth: ww,\n windowCenter: wc\n };\n } else {\n viewport.voi.windowWidth = ww;\n viewport.voi.windowCenter = wc;\n }\n}\n\n/**\n * Check if viewport has voi LUT data\n * @param {any} viewport The viewport to check for voi LUT data\n * @returns {Boolean} true viewport has LUT data (Window Width/Window Center or voiLUT). Otherwise, false.\n * @memberof Internal\n */\nfunction hasVoi (viewport) {\n const hasLut = viewport.voiLUT && viewport.voiLUT.lut && viewport.voiLUT.lut.length > 0;\n\n return hasLut || (viewport.voi.windowWidth !== undefined && viewport.voi.windowCenter !== undefined);\n}\n", "/**\n * Check if two lookup tables match\n *\n * @param {LUT} a A lookup table function\n * @param {LUT} b Another lookup table function\n * @return {boolean} Whether or not they match\n * @memberof rendering\n */\nexport default function (a, b) {\n // If undefined, they are equal\n if (!a && !b) {\n return true;\n }\n // If one is undefined, not equal\n if (!a || !b) {\n return false;\n }\n\n // Check the unique ids\n return (a.id === b.id);\n}\n", "/**\n * Generates a linear modality transformation function\n *\n * See DICOM PS3.3 C.11.1 Modality LUT Module\n *\n * http://dicom.nema.org/medical/Dicom/current/output/chtml/part03/sect_C.11.html\n *\n * @param {Number} slope m in the equation specified by Rescale Intercept (0028,1052).\n * @param {Number} intercept The value b in relationship between stored values (SV) and the output units specified in Rescale Type (0028,1054).\n\n Output units = m*SV + b.\n * @return {function(*): *} A linear modality LUT function. Given a stored pixel it returns the modality pixel value\n * @memberof Internal\n */\nfunction generateLinearModalityLUT (slope, intercept) {\n return (storedPixelValue) => storedPixelValue * slope + intercept;\n}\n\nfunction generateNonLinearModalityLUT (modalityLUT) {\n const minValue = modalityLUT.lut[0];\n const maxValue = modalityLUT.lut[modalityLUT.lut.length - 1];\n const maxValueMapped = modalityLUT.firstValueMapped + modalityLUT.lut.length;\n\n return (storedPixelValue) => {\n if (storedPixelValue < modalityLUT.firstValueMapped) {\n return minValue;\n } else if (storedPixelValue >= maxValueMapped) {\n return maxValue;\n }\n\n return modalityLUT.lut[storedPixelValue];\n };\n}\n\n/**\n * Get the appropriate Modality LUT for the current situation.\n *\n * @param {Number} [slope] m in the equation specified by Rescale Intercept (0028,1052).\n * @param {Number} [intercept] The value b in relationship between stored values (SV) and the output units specified in Rescale Type (0028,1054).\n * @param {Function} [modalityLUT] A modality LUT function. Given a stored pixel it returns the modality pixel value.\n *\n * @return {function(*): *} A modality LUT function. Given a stored pixel it returns the modality pixel value.\n * @memberof Internal\n */\nexport default function (slope, intercept, modalityLUT) {\n if (modalityLUT) {\n return generateNonLinearModalityLUT(modalityLUT);\n }\n\n return generateLinearModalityLUT(slope, intercept);\n}\n", "/* eslint no-bitwise: 0 */\n\n/**\n * Volume of Interest Lookup Table Function\n *\n * @typedef {Function} VOILUTFunction\n *\n * @param {Number} modalityLutValue\n * @returns {Number} transformed value\n * @memberof Objects\n */\n\n/**\n * @module: VOILUT\n */\n\n/**\n *\n * @param {Number} windowWidth Window Width\n * @param {Number} windowCenter Window Center\n * @returns {VOILUTFunction} VOI LUT mapping function\n * @memberof VOILUT\n */\nfunction generateLinearVOILUT (windowWidth, windowCenter) {\n return function (modalityLutValue) {\n return ((modalityLutValue - windowCenter) / windowWidth + 0.5) * 255.0;\n };\n}\n\n/**\n * Generate a non-linear volume of interest lookup table\n *\n * @param {LUT} voiLUT Volume of Interest Lookup Table Object\n * @param {Boolean} roundModalityLUTValues Do a Math.round of modality lut to compute non linear voilut\n\n *\n * @returns {VOILUTFunction} VOI LUT mapping function\n * @memberof VOILUT\n */\nfunction generateNonLinearVOILUT (voiLUT, roundModalityLUTValues) {\n // We don't trust the voiLUT.numBitsPerEntry, mainly thanks to Agfa!\n const bitsPerEntry = Math.max(...voiLUT.lut).toString(2).length;\n const shift = bitsPerEntry - 8;\n const minValue = voiLUT.lut[0] >> shift;\n const maxValue = voiLUT.lut[voiLUT.lut.length - 1] >> shift;\n const maxValueMapped = voiLUT.firstValueMapped + voiLUT.lut.length - 1;\n\n return function (modalityLutValue) {\n if (modalityLutValue < voiLUT.firstValueMapped) {\n return minValue;\n } else if (modalityLutValue >= maxValueMapped) {\n return maxValue;\n }\n if (roundModalityLUTValues) {\n return voiLUT.lut[Math.round(modalityLutValue) - voiLUT.firstValueMapped] >> shift;\n }\n\n return voiLUT.lut[modalityLutValue - voiLUT.firstValueMapped] >> shift;\n };\n}\n\n/**\n * Retrieve a VOI LUT mapping function given the current windowing settings\n * and the VOI LUT for the image\n *\n * @param {Number} windowWidth Window Width\n * @param {Number} windowCenter Window Center\n * @param {LUT} [voiLUT] Volume of Interest Lookup Table Object\n * @param {Boolean} roundModalityLUTValues Do a Math.round of modality lut to compute non linear voilut\n *\n * @return {VOILUTFunction} VOI LUT mapping function\n * @memberof VOILUT\n */\nexport default function (windowWidth, windowCenter, voiLUT, roundModalityLUTValues) {\n if (voiLUT) {\n return generateNonLinearVOILUT(voiLUT, roundModalityLUTValues);\n }\n\n return generateLinearVOILUT(windowWidth, windowCenter);\n}\n", "import getModalityLUT from './getModalityLUT.js';\r\nimport getVOILUT from './getVOILut.js';\r\n\r\n/**\r\n * Creates a LUT used while rendering to convert stored pixel values to\r\n * display pixels\r\n *\r\n * @param {Image} image A Cornerstone Image Object\r\n * @param {Number} windowWidth The Window Width\r\n * @param {Number} windowCenter The Window Center\r\n * @param {Boolean} invert A boolean describing whether or not the image has been inverted\r\n * @param {Array} [modalityLUT] A modality Lookup Table\r\n * @param {Array} [voiLUT] A Volume of Interest Lookup Table\r\n *\r\n * @returns {Uint8ClampedArray} A lookup table to apply to the image\r\n * @memberof Internal\r\n */\r\nexport default function (image, windowWidth, windowCenter, invert, modalityLUT, voiLUT) {\r\n const maxPixelValue = image.maxPixelValue;\r\n const minPixelValue = image.minPixelValue;\r\n const offset = Math.min(minPixelValue, 0);\r\n\r\n if (image.cachedLut === undefined) {\r\n const length = maxPixelValue - offset + 1;\r\n\r\n image.cachedLut = {};\r\n image.cachedLut.lutArray = new Uint8ClampedArray(length);\r\n }\r\n\r\n const lut = image.cachedLut.lutArray;\r\n const slopeOrInterceptAreFloat = Boolean(image.slope % 1) || Boolean(image.intercept % 1);\r\n const mlutfn = getModalityLUT(image.slope, image.intercept, modalityLUT);\r\n const vlutfn = getVOILUT(windowWidth, windowCenter, voiLUT, slopeOrInterceptAreFloat);\r\n\r\n if (invert === true) {\r\n for (let storedValue = minPixelValue; storedValue <= maxPixelValue; storedValue++) {\r\n lut[storedValue + (-offset)] = 255 - vlutfn(mlutfn(storedValue));\r\n }\r\n } else {\r\n for (let storedValue = minPixelValue; storedValue <= maxPixelValue; storedValue++) {\r\n lut[storedValue + (-offset)] = vlutfn(mlutfn(storedValue));\r\n }\r\n }\r\n\r\n return lut;\r\n}\r\n", "import computeAutoVoi from '../internal/computeAutoVoi.js';\nimport lutMatches from './lutMatches.js';\nimport generateLut from '../internal/generateLut.js';\n\n/**\n * Retrieve or generate a LUT Array for an Image and Viewport\n *\n * @param {Image} image An Image Object\n * @param {Viewport} viewport An Viewport Object\n * @param {Boolean} invalidated Whether or not the LUT data has been invalidated\n * (e.g. by a change to the windowWidth, windowCenter, or invert viewport parameters).\n * @return {Uint8ClampedArray} LUT Array\n * @memberof rendering\n */\nexport default function (image, viewport, invalidated) {\n // If we have a cached lut and it has the right values, return it immediately\n if (image.cachedLut !== undefined &&\n image.cachedLut.windowCenter === viewport.voi.windowCenter &&\n image.cachedLut.windowWidth === viewport.voi.windowWidth &&\n lutMatches(image.cachedLut.modalityLUT, viewport.modalityLUT) &&\n lutMatches(image.cachedLut.voiLUT, viewport.voiLUT) &&\n image.cachedLut.invert === viewport.invert &&\n invalidated !== true) {\n return image.cachedLut.lutArray;\n }\n\n computeAutoVoi(viewport, image);\n\n // Lut is invalid or not present, regenerate it and cache it\n generateLut(image, viewport.voi.windowWidth, viewport.voi.windowCenter, viewport.invert, viewport.modalityLUT, viewport.voiLUT);\n\n image.cachedLut.windowWidth = viewport.voi.windowWidth;\n image.cachedLut.windowCenter = viewport.voi.windowCenter;\n image.cachedLut.invert = viewport.invert;\n image.cachedLut.voiLUT = viewport.voiLUT;\n image.cachedLut.modalityLUT = viewport.modalityLUT;\n\n return image.cachedLut.lutArray;\n}\n", "/**\n * Determine whether or not an Enabled Element needs to be re-rendered.\n *\n * If the imageId has changed, or if any of the last rendered viewport\n * parameters have changed, this function will return true.\n *\n * @param {EnabledElement} enabledElement An Enabled Element\n * @param {Image} image An Image\n * @return {boolean} Whether or not the Enabled Element needs to re-render its image\n * @memberof rendering\n */\nexport default function (enabledElement, image) {\n const lastRenderedImageId = enabledElement.renderingTools.lastRenderedImageId;\n const lastRenderedViewport = enabledElement.renderingTools.lastRenderedViewport;\n\n return (\n image.imageId !== lastRenderedImageId ||\n !lastRenderedViewport ||\n lastRenderedViewport.windowCenter !== enabledElement.viewport.voi.windowCenter ||\n lastRenderedViewport.windowWidth !== enabledElement.viewport.voi.windowWidth ||\n lastRenderedViewport.invert !== enabledElement.viewport.invert ||\n lastRenderedViewport.rotation !== enabledElement.viewport.rotation ||\n lastRenderedViewport.hflip !== enabledElement.viewport.hflip ||\n lastRenderedViewport.vflip !== enabledElement.viewport.vflip ||\n lastRenderedViewport.modalityLUT !== enabledElement.viewport.modalityLUT ||\n lastRenderedViewport.voiLUT !== enabledElement.viewport.voiLUT ||\n lastRenderedViewport.colormap !== enabledElement.viewport.colormap\n );\n}\n", "/**\n * Sets size and clears canvas\n *\n * @param {Object} enabledElement Cornerstone Enabled Element\n * @param {Object} image Image to be rendered\n * @returns {void}\n * @memberof rendering\n */\nexport default function (enabledElement, image) {\n const renderCanvas = enabledElement.renderingTools.renderCanvas;\n\n // Resize the canvas\n renderCanvas.width = image.width;\n renderCanvas.height = image.height;\n\n const canvasContext = renderCanvas.getContext('2d', {\n desynchronized: true\n });\n\n // NOTE - we need to fill the render canvas with white pixels since we\n // control the luminance using the alpha channel to improve rendering performance.\n canvasContext.fillStyle = 'white';\n canvasContext.fillRect(0, 0, renderCanvas.width, renderCanvas.height);\n\n const renderCanvasData = canvasContext.getImageData(0, 0, image.width, image.height);\n\n enabledElement.renderingTools.renderCanvasContext = canvasContext;\n enabledElement.renderingTools.renderCanvasData = renderCanvasData;\n}\n", "/**\n * Saves the parameters of the last render into renderingTools, used later to decide if data can be reused.\n *\n * @param {Object} enabledElement Cornerstone EnabledElement\n * @returns {Object} enabledElement.renderingTools\n * @memberof rendering\n */\n\nexport default function (enabledElement) {\n const imageId = enabledElement.image.imageId;\n const viewport = enabledElement.viewport;\n const isColor = enabledElement.image.color;\n\n enabledElement.renderingTools.lastRenderedImageId = imageId;\n enabledElement.renderingTools.lastRenderedIsColor = isColor;\n enabledElement.renderingTools.lastRenderedViewport = {\n windowCenter: viewport.voi.windowCenter,\n windowWidth: viewport.voi.windowWidth,\n invert: viewport.invert,\n rotation: viewport.rotation,\n hflip: viewport.hflip,\n vflip: viewport.vflip,\n modalityLUT: viewport.modalityLUT,\n voiLUT: viewport.voiLUT,\n colormap: viewport.colormap\n };\n\n return enabledElement.renderingTools;\n}\n", "import getFillStyle from '../internal/getFillStyle.js';\nimport storedPixelDataToCanvasImageData from '../internal/storedPixelDataToCanvasImageData.js';\nimport storedPixelDataToCanvasImageDataRGBA from '../internal/storedPixelDataToCanvasImageDataRGBA.js';\nimport setToPixelCoordinateSystem from '../setToPixelCoordinateSystem.js';\nimport now from '../internal/now.js';\nimport webGL from '../webgl/index.js';\nimport getLut from './getLut.js';\nimport doesImageNeedToBeRendered from './doesImageNeedToBeRendered.js';\nimport initializeRenderCanvas from './initializeRenderCanvas.js';\nimport saveLastRendered from './saveLastRendered.js';\nimport getDisplayedArea from '../internal/getDisplayedArea.js';\n\n/**\n * Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate\n * it is returned, otherwise adjustments are made. It also sets the color transfer functions.\n *\n * @param {Object} enabledElement The cornerstone enabled element\n * @param {Object} image The image to be rendered\n * @param {Boolean} invalidated Is pixel data valid\n * @param {Boolean} [useAlphaChannel = true] Will an alpha channel be used\n * @returns {HTMLCanvasElement} An appropriate canvas for rendering the image\n * @memberof rendering\n */\nfunction getRenderCanvas (enabledElement, image, invalidated, useAlphaChannel = true) {\n const canvasWasColor = enabledElement.renderingTools.lastRenderedIsColor === true;\n\n if (!enabledElement.renderingTools.renderCanvas || canvasWasColor) {\n enabledElement.renderingTools.renderCanvas = document.createElement('canvas');\n initializeRenderCanvas(enabledElement, image);\n }\n\n const renderCanvas = enabledElement.renderingTools.renderCanvas;\n\n if (doesImageNeedToBeRendered(enabledElement, image) === false && invalidated !== true) {\n return renderCanvas;\n }\n\n // If our render canvas does not match the size of this image reset it\n // NOTE: This might be inefficient if we are updating multiple images of different\n // Sizes frequently.\n if (renderCanvas.width !== image.width || renderCanvas.height !== image.height) {\n initializeRenderCanvas(enabledElement, image);\n }\n\n // Get the lut to use\n let start = now();\n const lut = getLut(image, enabledElement.viewport, invalidated);\n\n image.stats = image.stats || {};\n image.stats.lastLutGenerateTime = now() - start;\n\n const renderCanvasData = enabledElement.renderingTools.renderCanvasData;\n const renderCanvasContext = enabledElement.renderingTools.renderCanvasContext;\n\n // Gray scale image - apply the lut and put the resulting image onto the render canvas\n if (useAlphaChannel) {\n storedPixelDataToCanvasImageData(image, lut, renderCanvasData.data);\n } else {\n storedPixelDataToCanvasImageDataRGBA(image, lut, renderCanvasData.data);\n }\n\n start = now();\n renderCanvasContext.putImageData(renderCanvasData, 0, 0);\n image.stats.lastPutImageDataTime = now() - start;\n\n return renderCanvas;\n}\n\n/**\n * API function to draw a grayscale image to a given enabledElement\n *\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element to redraw\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n * @memberof rendering\n */\nexport function renderGrayscaleImage (enabledElement, invalidated) {\n if (enabledElement === undefined) {\n throw new Error('drawImage: enabledElement parameter must not be undefined');\n }\n\n const image = enabledElement.image;\n\n if (image === undefined) {\n throw new Error('drawImage: image must be loaded before it can be drawn');\n }\n\n // Get the canvas context and reset the transform\n const context = enabledElement.canvas.getContext('2d', {\n desynchronized: true\n });\n\n context.setTransform(1, 0, 0, 1, 0, 0);\n\n // Clear the canvas\n context.fillStyle = getFillStyle(enabledElement);\n context.fillRect(0, 0, enabledElement.canvas.width, enabledElement.canvas.height);\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !enabledElement.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n // Save the canvas context state and apply the viewport properties\n setToPixelCoordinateSystem(enabledElement, context);\n\n let renderCanvas;\n\n if (enabledElement.options && enabledElement.options.renderer &&\n enabledElement.options.renderer.toLowerCase() === 'webgl') {\n // If this enabled element has the option set for WebGL, we should\n // User it as our renderer.\n renderCanvas = webGL.renderer.render(enabledElement);\n } else {\n // If no options are set we will retrieve the renderCanvas through the\n // Normal Canvas rendering path\n renderCanvas = getRenderCanvas(enabledElement, image, invalidated);\n }\n\n const imageDisplayedArea = getDisplayedArea(enabledElement.image, enabledElement.viewport);\n const sx = imageDisplayedArea.tlhc.x - 1;\n const sy = imageDisplayedArea.tlhc.y - 1;\n const width = imageDisplayedArea.brhc.x - sx;\n const height = imageDisplayedArea.brhc.y - sy;\n\n context.drawImage(renderCanvas, sx, sy, width, height, sx, sy, width, height);\n\n enabledElement.renderingTools = saveLastRendered(enabledElement);\n}\n\n/**\n * API function to draw a grayscale image to a given layer\n *\n * @param {EnabledElementLayer} layer The layer that the image will be added to\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @param {Boolean} [useAlphaChannel] - Whether or not to render the grayscale image using only the alpha channel.\n This does not work if this layer is not the first layer in the enabledElement.\n * @returns {void}\n */\nexport function addGrayscaleLayer (layer, invalidated, useAlphaChannel = false) {\n if (layer === undefined) {\n throw new Error('addGrayscaleLayer: layer parameter must not be undefined');\n }\n\n const image = layer.image;\n\n if (image === undefined) {\n throw new Error('addGrayscaleLayer: image must be loaded before it can be drawn');\n }\n\n layer.canvas = getRenderCanvas(layer, image, invalidated, useAlphaChannel);\n\n const context = layer.canvas.getContext('2d', {\n desynchronized: true\n });\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !layer.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n layer.renderingTools = saveLastRendered(layer);\n}\n", "import getVOILUT from './getVOILut.js';\n\n/**\n * Creates a LUT used while rendering to convert stored pixel values to\n * display pixels\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {Number} windowWidth The Window Width\n * @param {Number} windowCenter The Window Center\n * @param {Boolean} invert A boolean describing whether or not the image has been inverted\n * @param {Array} [voiLUT] A Volume of Interest Lookup Table\n *\n * @returns {Uint8ClampedArray} A lookup table to apply to the image\n * @memberof Internal\n */\nexport default function (image, windowWidth, windowCenter, invert, voiLUT) {\n const maxPixelValue = image.maxPixelValue;\n const minPixelValue = image.minPixelValue;\n const offset = Math.min(minPixelValue, 0);\n\n if (image.cachedLut === undefined) {\n const length = maxPixelValue - offset + 1;\n\n image.cachedLut = {};\n image.cachedLut.lutArray = new Uint8ClampedArray(length);\n }\n\n const lut = image.cachedLut.lutArray;\n const vlutfn = getVOILUT(windowWidth, windowCenter, voiLUT);\n\n if (invert === true) {\n for (let storedValue = minPixelValue; storedValue <= maxPixelValue; storedValue++) {\n lut[storedValue + (-offset)] = 255 - vlutfn(storedValue);\n }\n } else {\n for (let storedValue = minPixelValue; storedValue <= maxPixelValue; storedValue++) {\n lut[storedValue + (-offset)] = vlutfn(storedValue);\n }\n }\n\n return lut;\n}\n", "import now from './now.js';\n\n/**\n * Converts stored color pixel values to display pixel values using a LUT.\n *\n * Note: Skips alpha value for any input image pixel data.\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {Array} lut Lookup table array\n * @param {Uint8ClampedArray} canvasImageDataData canvasImageData.data buffer filled with white pixels\n *\n * @returns {void}\n * @memberof Internal\n */\nexport default function (image, lut, canvasImageDataData) {\n\n let start = now();\n const pixelData = image.getPixelData();\n\n image.stats.lastGetPixelDataTime = now() - start;\n\n const minPixelValue = image.minPixelValue;\n let canvasImageDataIndex = 0;\n let storedPixelDataIndex = 0;\n const numPixels = pixelData.length;\n\n // NOTE: As of Nov 2014, most javascript engines have lower performance when indexing negative indexes.\n // We have a special code path for this case that improves performance. Thanks to @jpambrun for this enhancement\n start = now();\n if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)]; // Red\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)]; // Green\n canvasImageDataData[canvasImageDataIndex] = lut[pixelData[storedPixelDataIndex] + (-minPixelValue)]; // Blue\n storedPixelDataIndex += 2;\n canvasImageDataIndex += 2;\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++]]; // Red\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++]]; // Green\n canvasImageDataData[canvasImageDataIndex] = lut[pixelData[storedPixelDataIndex]]; // Blue\n storedPixelDataIndex += 2;\n canvasImageDataIndex += 2;\n }\n }\n image.stats.lastStoredPixelDataToCanvasImageDataTime = now() - start;\n}\n", "import now from './now.js';\n\n/**\n * Converts stored RGBA color pixel values to display pixel values using a LUT.\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {Array} lut Lookup table array\n * @param {Uint8ClampedArray} canvasImageDataData canvasImageData.data buffer filled with white pixels\n *\n * @returns {void}\n * @memberof Internal\n */\nexport default function (image, lut, canvasImageDataData) {\n\n let start = now();\n const pixelData = image.getPixelData();\n\n image.stats.lastGetPixelDataTime = now() - start;\n\n const minPixelValue = image.minPixelValue;\n let canvasImageDataIndex = 0;\n let storedPixelDataIndex = 0;\n const numPixels = pixelData.length;\n\n // NOTE: As of Nov 2014, most javascript engines have lower performance when indexing negative indexes.\n // We have a special code path for this case that improves performance. Thanks to @jpambrun for this enhancement\n start = now();\n if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)]; // Red\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)]; // Green\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++] + (-minPixelValue)]; // Blue\n canvasImageDataData[canvasImageDataIndex++] = pixelData[storedPixelDataIndex++];\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++]]; // Red\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++]]; // Green\n canvasImageDataData[canvasImageDataIndex++] = lut[pixelData[storedPixelDataIndex++]]; // Blue\n canvasImageDataData[canvasImageDataIndex++] = pixelData[storedPixelDataIndex++];\n }\n }\n image.stats.lastStoredPixelDataToCanvasImageDataTime = now() - start;\n}\n", "import now from '../internal/now.js';\nimport getFillStyle from '../internal/getFillStyle.js';\nimport generateColorLut from '../internal/generateColorLut.js';\nimport storedColorPixelDataToCanvasImageData from '../internal/storedColorPixelDataToCanvasImageData.js';\nimport storedRGBAPixelDataToCanvasImageData from '../internal/storedRGBAPixelDataToCanvasImageData.js';\nimport setToPixelCoordinateSystem from '../setToPixelCoordinateSystem.js';\nimport webGL from '../webgl/index.js';\nimport doesImageNeedToBeRendered from './doesImageNeedToBeRendered.js';\nimport initializeRenderCanvas from './initializeRenderCanvas.js';\nimport saveLastRendered from './saveLastRendered.js';\nimport getDisplayedArea from '../internal/getDisplayedArea.js';\n\n\n/**\n * Generates an appropriate Look Up Table to render the given image with the given window width and level (specified in the viewport)\n * Uses an internal cache for performance\n *\n * @param {Object} image The image to be rendered\n * @param {Object} viewport The viewport values used for rendering\n * @returns {Uint8ClampedArray} Look Up Table array.\n * @memberof rendering\n */\nfunction getLut (image, viewport) {\n // If we have a cached lut and it has the right values, return it immediately\n if (image.cachedLut !== undefined &&\n image.cachedLut.windowCenter === viewport.voi.windowCenter &&\n image.cachedLut.windowWidth === viewport.voi.windowWidth &&\n image.cachedLut.invert === viewport.invert) {\n return image.cachedLut.lutArray;\n }\n\n // Lut is invalid or not present, regenerate it and cache it\n generateColorLut(image, viewport.voi.windowWidth, viewport.voi.windowCenter, viewport.invert);\n image.cachedLut.windowWidth = viewport.voi.windowWidth;\n image.cachedLut.windowCenter = viewport.voi.windowCenter;\n image.cachedLut.invert = viewport.invert;\n\n return image.cachedLut.lutArray;\n}\n\n/**\n * Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate\n * it is returned, otherwise adjustments are made. It also sets the color transfer functions.\n *\n * @param {Object} enabledElement The cornerstone enabled element\n * @param {Object} image The image to be rendered\n * @param {Boolean} invalidated Is pixel data valid\n * @returns {HTMLCanvasElement} An appropriate canvas for rendering the image\n * @memberof rendering\n */\nfunction getRenderCanvas (enabledElement, image, invalidated) {\n const canvasWasColor = enabledElement.renderingTools.lastRenderedIsColor === true;\n\n if (!enabledElement.renderingTools.renderCanvas || !canvasWasColor) {\n enabledElement.renderingTools.renderCanvas = document.createElement('canvas');\n }\n\n const renderCanvas = enabledElement.renderingTools.renderCanvas;\n\n // The ww/wc is identity and not inverted - get a canvas with the image rendered into it for\n // Fast drawing\n if (enabledElement.viewport.voi.windowWidth === 255 &&\n enabledElement.viewport.voi.windowCenter === 128 &&\n enabledElement.viewport.invert === false &&\n image.getCanvas &&\n image.getCanvas()\n ) {\n return image.getCanvas();\n }\n\n // Apply the lut to the stored pixel data onto the render canvas\n if (doesImageNeedToBeRendered(enabledElement, image) === false && invalidated !== true) {\n return renderCanvas;\n }\n\n // If our render canvas does not match the size of this image reset it\n // NOTE: This might be inefficient if we are updating multiple images of different\n // Sizes frequently.\n if (renderCanvas.width !== image.width || renderCanvas.height !== image.height) {\n initializeRenderCanvas(enabledElement, image);\n }\n\n // Get the lut to use\n let start = now();\n const colorLut = getLut(image, enabledElement.viewport);\n\n image.stats = image.stats || {};\n image.stats.lastLutGenerateTime = now() - start;\n\n const renderCanvasData = enabledElement.renderingTools.renderCanvasData;\n const renderCanvasContext = enabledElement.renderingTools.renderCanvasContext;\n\n // The color image voi/invert has been modified - apply the lut to the underlying\n // Pixel data and put it into the renderCanvas\n if (image.rgba) {\n storedRGBAPixelDataToCanvasImageData(image, colorLut, renderCanvasData.data);\n } else {\n storedColorPixelDataToCanvasImageData(image, colorLut, renderCanvasData.data);\n }\n\n start = now();\n renderCanvasContext.putImageData(renderCanvasData, 0, 0);\n image.stats.lastPutImageDataTime = now() - start;\n\n return renderCanvas;\n}\n\n/**\n * API function to render a color image to an enabled element\n *\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element to redraw\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n * @memberof rendering\n */\nexport function renderColorImage (enabledElement, invalidated) {\n if (enabledElement === undefined) {\n throw new Error('renderColorImage: enabledElement parameter must not be undefined');\n }\n\n const image = enabledElement.image;\n\n if (image === undefined) {\n throw new Error('renderColorImage: image must be loaded before it can be drawn');\n }\n\n // Get the canvas context and reset the transform\n const context = enabledElement.canvas.getContext('2d', {\n desynchronized: true\n });\n\n context.setTransform(1, 0, 0, 1, 0, 0);\n\n // Clear the canvas\n context.fillStyle = getFillStyle(enabledElement);\n context.fillRect(0, 0, enabledElement.canvas.width, enabledElement.canvas.height);\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !enabledElement.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n // Save the canvas context state and apply the viewport properties\n setToPixelCoordinateSystem(enabledElement, context);\n\n let renderCanvas;\n\n if (enabledElement.options && enabledElement.options.renderer &&\n enabledElement.options.renderer.toLowerCase() === 'webgl') {\n // If this enabled element has the option set for WebGL, we should\n // User it as our renderer.\n renderCanvas = webGL.renderer.render(enabledElement);\n } else {\n // If no options are set we will retrieve the renderCanvas through the\n // Normal Canvas rendering path\n renderCanvas = getRenderCanvas(enabledElement, image, invalidated);\n }\n\n const imageDisplayedArea = getDisplayedArea(enabledElement.image, enabledElement.viewport);\n const sx = imageDisplayedArea.tlhc.x - 1;\n const sy = imageDisplayedArea.tlhc.y - 1;\n const width = imageDisplayedArea.brhc.x - sx;\n const height = imageDisplayedArea.brhc.y - sy;\n\n context.drawImage(renderCanvas, sx, sy, width, height, sx, sy, width, height);\n\n enabledElement.renderingTools = saveLastRendered(enabledElement);\n}\n\nexport function addColorLayer (layer, invalidated) {\n if (layer === undefined) {\n throw new Error('addColorLayer: layer parameter must not be undefined');\n }\n\n const image = layer.image;\n\n if (image === undefined) {\n throw new Error('addColorLayer: image must be loaded before it can be drawn');\n }\n\n // All multi-layer images should include the alpha value\n image.rgba = true;\n layer.canvas = getRenderCanvas(layer, image, invalidated);\n\n const context = layer.canvas.getContext('2d', {\n desynchronized: true\n });\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !layer.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n layer.renderingTools = saveLastRendered(layer);\n}\n", "import colors from '../colors/index.js';\nimport now from './now.js';\n\n/**\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {Array} grayscaleLut Lookup table array\n * @param {LookupTable|Array} colorLut Lookup table array\n * @param {Uint8ClampedArray} canvasImageDataData canvasImageData.data buffer filled with white pixels\n *\n * @returns {void}\n * @memberof Internal\n */\nfunction storedPixelDataToCanvasImageDataPseudocolorLUT (image, grayscaleLut, colorLut, canvasImageDataData) {\n let start = now();\n const pixelData = image.getPixelData();\n\n image.stats.lastGetPixelDataTime = now() - start;\n\n const numPixels = pixelData.length;\n const minPixelValue = image.minPixelValue;\n let canvasImageDataIndex = 0;\n let storedPixelDataIndex = 0;\n let grayscale;\n let rgba;\n let clut;\n\n start = now();\n\n if (colorLut instanceof colors.LookupTable) {\n clut = colorLut.Table;\n } else {\n clut = colorLut;\n }\n\n if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n grayscale = grayscaleLut[pixelData[storedPixelDataIndex++] + (-minPixelValue)];\n rgba = clut[grayscale];\n canvasImageDataData[canvasImageDataIndex++] = rgba[0];\n canvasImageDataData[canvasImageDataIndex++] = rgba[1];\n canvasImageDataData[canvasImageDataIndex++] = rgba[2];\n canvasImageDataData[canvasImageDataIndex++] = rgba[3];\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n grayscale = grayscaleLut[pixelData[storedPixelDataIndex++]];\n rgba = clut[grayscale];\n canvasImageDataData[canvasImageDataIndex++] = rgba[0];\n canvasImageDataData[canvasImageDataIndex++] = rgba[1];\n canvasImageDataData[canvasImageDataIndex++] = rgba[2];\n canvasImageDataData[canvasImageDataIndex++] = rgba[3];\n }\n }\n\n image.stats.lastStoredPixelDataToCanvasImageDataTime = now() - start;\n}\n\nexport default storedPixelDataToCanvasImageDataPseudocolorLUT;\n", "import setToPixelCoordinateSystem from '../setToPixelCoordinateSystem.js';\nimport now from '../internal/now.js';\nimport getFillStyle from '../internal/getFillStyle.js';\nimport initializeRenderCanvas from './initializeRenderCanvas.js';\nimport getLut from './getLut.js';\nimport saveLastRendered from './saveLastRendered.js';\nimport doesImageNeedToBeRendered from './doesImageNeedToBeRendered.js';\nimport storedPixelDataToCanvasImageDataPseudocolorLUT from '../internal/storedPixelDataToCanvasImageDataPseudocolorLUT.js';\nimport colors from '../colors/index.js';\nimport getDisplayedArea from '../internal/getDisplayedArea.js';\n\n/**\n * Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate\n * it is returned, otherwise adjustments are made. It also sets the color transfer functions.\n *\n * @param {Object} enabledElement The cornerstone enabled element\n * @param {Object} image The image to be rendered\n * @param {Boolean} invalidated Is pixel data valid\n * @returns {HTMLCanvasElement} An appropriate canvas for rendering the image\n * @memberof rendering\n */\nfunction getRenderCanvas (enabledElement, image, invalidated) {\n if (!enabledElement.renderingTools.renderCanvas) {\n enabledElement.renderingTools.renderCanvas = document.createElement('canvas');\n }\n\n const renderCanvas = enabledElement.renderingTools.renderCanvas;\n\n let colormap = enabledElement.viewport.colormap || enabledElement.options.colormap;\n\n if (enabledElement.options && enabledElement.options.colormap) {\n console.warn('enabledElement.options.colormap is deprecated. Use enabledElement.viewport.colormap instead');\n }\n if (colormap && (typeof colormap === 'string')) {\n colormap = colors.getColormap(colormap);\n }\n\n if (!colormap) {\n throw new Error('renderPseudoColorImage: colormap not found.');\n }\n\n const colormapId = colormap.getId();\n\n if (doesImageNeedToBeRendered(enabledElement, image) === false && invalidated !== true &&\n enabledElement.renderingTools.colormapId === colormapId) {\n return renderCanvas;\n }\n\n // If our render canvas does not match the size of this image reset it\n // NOTE: This might be inefficient if we are updating multiple images of different\n // Sizes frequently.\n if (renderCanvas.width !== image.width || renderCanvas.height !== image.height) {\n initializeRenderCanvas(enabledElement, image);\n }\n\n // Get the lut to use\n let start = now();\n\n if (!enabledElement.renderingTools.colorLut || invalidated ||\n enabledElement.renderingTools.colormapId !== colormapId) {\n colormap.setNumberOfColors(256);\n enabledElement.renderingTools.colorLut = colormap.createLookupTable();\n enabledElement.renderingTools.colormapId = colormapId;\n }\n\n const lut = getLut(image, enabledElement.viewport, invalidated);\n\n image.stats = image.stats || {};\n image.stats.lastLutGenerateTime = now() - start;\n\n const colorLut = enabledElement.renderingTools.colorLut;\n const renderCanvasData = enabledElement.renderingTools.renderCanvasData;\n const renderCanvasContext = enabledElement.renderingTools.renderCanvasContext;\n\n storedPixelDataToCanvasImageDataPseudocolorLUT(image, lut, colorLut, renderCanvasData.data);\n\n start = now();\n renderCanvasContext.putImageData(renderCanvasData, 0, 0);\n image.stats.lastPutImageDataTime = now() - start;\n\n return renderCanvas;\n}\n\n/**\n * API function to draw a pseudo-color image to a given enabledElement\n *\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element to redraw\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n * @memberof rendering\n */\nexport function renderPseudoColorImage (enabledElement, invalidated) {\n if (enabledElement === undefined) {\n throw new Error('drawImage: enabledElement parameter must not be undefined');\n }\n\n const image = enabledElement.image;\n\n if (image === undefined) {\n throw new Error('drawImage: image must be loaded before it can be drawn');\n }\n\n // Get the canvas context and reset the transform\n const context = enabledElement.canvas.getContext('2d', {\n desynchronized: true\n });\n\n context.setTransform(1, 0, 0, 1, 0, 0);\n\n // Clear the canvas\n context.fillStyle = getFillStyle(enabledElement);\n context.fillRect(0, 0, enabledElement.canvas.width, enabledElement.canvas.height);\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !enabledElement.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n // Save the canvas context state and apply the viewport properties\n setToPixelCoordinateSystem(enabledElement, context);\n\n\n // If no options are set we will retrieve the renderCanvas through the\n // Normal Canvas rendering path\n // TODO: Add WebGL support for pseudocolor pipeline\n const renderCanvas = getRenderCanvas(enabledElement, image, invalidated);\n const imageDisplayedArea = getDisplayedArea(enabledElement.image, enabledElement.viewport);\n const sx = imageDisplayedArea.tlhc.x - 1;\n const sy = imageDisplayedArea.tlhc.y - 1;\n const width = imageDisplayedArea.brhc.x - sx;\n const height = imageDisplayedArea.brhc.y - sy;\n\n context.drawImage(renderCanvas, sx, sy, width, height, sx, sy, width, height);\n\n enabledElement.renderingTools = saveLastRendered(enabledElement);\n}\n\n/**\n * API function to draw a pseudo-color image to a given layer\n *\n * @param {EnabledElementLayer} layer The layer that the image will be added to\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n */\nexport function addPseudoColorLayer (layer, invalidated) {\n if (layer === undefined) {\n throw new Error('addPseudoColorLayer: layer parameter must not be undefined');\n }\n\n const image = layer.image;\n\n if (image === undefined) {\n throw new Error('addPseudoColorLayer: image must be loaded before it can be drawn');\n }\n\n layer.canvas = getRenderCanvas(layer, image, invalidated);\n\n const context = layer.canvas.getContext('2d', {\n desynchronized: true\n });\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !layer.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n layer.renderingTools = saveLastRendered(layer);\n}\n", "import colors from '../colors/index.js';\nimport now from './now.js';\n\n/**\n *\n * @param {Image} image A Cornerstone Image Object\n * @param {LookupTable|Array} colorLut Lookup table array\n * @param {Uint8ClampedArray} canvasImageDataData canvasImageData.data buffer filled with white pixels\n *\n * @returns {void}\n * @memberof Internal\n */\nfunction storedPixelDataToCanvasImageDataColorLUT (image, colorLut, canvasImageDataData) {\n let start = now();\n const pixelData = image.getPixelData();\n\n image.stats.lastGetPixelDataTime = now() - start;\n\n const numPixels = pixelData.length;\n const minPixelValue = image.minPixelValue;\n let canvasImageDataIndex = 0;\n let storedPixelDataIndex = 0;\n let rgba;\n let clut;\n\n start = now();\n\n if (colorLut instanceof colors.LookupTable) {\n clut = colorLut.Table;\n } else {\n clut = colorLut;\n }\n\n if (minPixelValue < 0) {\n while (storedPixelDataIndex < numPixels) {\n rgba = clut[pixelData[storedPixelDataIndex++] + (-minPixelValue)];\n canvasImageDataData[canvasImageDataIndex++] = rgba[0];\n canvasImageDataData[canvasImageDataIndex++] = rgba[1];\n canvasImageDataData[canvasImageDataIndex++] = rgba[2];\n canvasImageDataData[canvasImageDataIndex++] = rgba[3];\n }\n } else {\n while (storedPixelDataIndex < numPixels) {\n rgba = clut[pixelData[storedPixelDataIndex++]];\n canvasImageDataData[canvasImageDataIndex++] = rgba[0];\n canvasImageDataData[canvasImageDataIndex++] = rgba[1];\n canvasImageDataData[canvasImageDataIndex++] = rgba[2];\n canvasImageDataData[canvasImageDataIndex++] = rgba[3];\n }\n }\n\n image.stats.lastStoredPixelDataToCanvasImageDataTime = now() - start;\n}\n\nexport default storedPixelDataToCanvasImageDataColorLUT;\n", "import setToPixelCoordinateSystem from '../setToPixelCoordinateSystem.js';\nimport now from '../internal/now.js';\nimport getFillStyle from '../internal/getFillStyle.js';\nimport initializeRenderCanvas from './initializeRenderCanvas.js';\nimport saveLastRendered from './saveLastRendered.js';\nimport doesImageNeedToBeRendered from './doesImageNeedToBeRendered.js';\nimport storedPixelDataToCanvasImageDataColorLUT from '../internal/storedPixelDataToCanvasImageDataColorLUT.js';\nimport colors from '../colors/index.js';\nimport getDisplayedArea from '../internal/getDisplayedArea.js';\n\n/**\n * Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate\n * it is returned, otherwise adjustments are made. It also sets the color transfer functions.\n *\n * @param {Object} enabledElement The cornerstone enabled element\n * @param {Object} image The image to be rendered\n * @param {Boolean} invalidated Is pixel data valid\n * @returns {HTMLCanvasElement} An appropriate canvas for rendering the image\n * @memberof rendering\n */\nfunction getRenderCanvas (enabledElement, image, invalidated) {\n if (!enabledElement.renderingTools.renderCanvas) {\n enabledElement.renderingTools.renderCanvas = document.createElement('canvas');\n }\n\n const renderCanvas = enabledElement.renderingTools.renderCanvas;\n\n let colormap = enabledElement.viewport.colormap || enabledElement.options.colormap;\n\n if (enabledElement.options.colormap) {\n console.warn('enabledElement.options.colormap is deprecated. Use enabledElement.viewport.colormap instead');\n }\n\n if (colormap && (typeof colormap === 'string')) {\n colormap = colors.getColormap(colormap);\n }\n\n if (!colormap) {\n throw new Error('renderLabelMapImage: colormap not found.');\n }\n\n const colormapId = colormap.getId();\n\n if (doesImageNeedToBeRendered(enabledElement, image) === false && invalidated !== true &&\n enabledElement.renderingTools.colormapId === colormapId) {\n return renderCanvas;\n }\n\n // If our render canvas does not match the size of this image reset it\n // NOTE: This might be inefficient if we are updating multiple images of different\n // Sizes frequently.\n if (renderCanvas.width !== image.width || renderCanvas.height !== image.height) {\n initializeRenderCanvas(enabledElement, image);\n }\n\n // Get the lut to use\n let start = now();\n\n if (!enabledElement.renderingTools.colorLut || invalidated ||\n enabledElement.renderingTools.colormapId !== colormapId) {\n enabledElement.renderingTools.colorLut = colormap.createLookupTable();\n enabledElement.renderingTools.colormapId = colormapId;\n }\n\n image.stats = image.stats || {};\n image.stats.lastLutGenerateTime = now() - start;\n\n const colorLut = enabledElement.renderingTools.colorLut;\n const renderCanvasData = enabledElement.renderingTools.renderCanvasData;\n const renderCanvasContext = enabledElement.renderingTools.renderCanvasContext;\n\n storedPixelDataToCanvasImageDataColorLUT(image, colorLut, renderCanvasData.data);\n\n start = now();\n renderCanvasContext.putImageData(renderCanvasData, 0, 0);\n image.stats.lastPutImageDataTime = now() - start;\n\n return renderCanvas;\n}\n\n/**\n * API function to draw a label map image to a given enabledElement\n *\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element to redraw\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n * @memberof rendering\n */\nexport function renderLabelMapImage (enabledElement, invalidated) {\n if (enabledElement === undefined) {\n throw new Error('renderLabelMapImage: enabledElement parameter must not be undefined');\n }\n\n const image = enabledElement.image;\n\n if (image === undefined) {\n throw new Error('renderLabelMapImage: image must be loaded before it can be drawn');\n }\n\n // Get the canvas context and reset the transform\n const context = enabledElement.canvas.getContext('2d', {\n desynchronized: true\n });\n\n context.setTransform(1, 0, 0, 1, 0, 0);\n\n // Clear the canvas\n context.fillStyle = getFillStyle(enabledElement);\n context.fillRect(0, 0, enabledElement.canvas.width, enabledElement.canvas.height);\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !enabledElement.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n // Save the canvas context state and apply the viewport properties\n setToPixelCoordinateSystem(enabledElement, context);\n\n // If no options are set we will retrieve the renderCanvas through the\n // Normal Canvas rendering path\n // TODO: Add WebGL support for label map pipeline\n const renderCanvas = getRenderCanvas(enabledElement, image, invalidated);\n const imageDisplayedArea = getDisplayedArea(enabledElement.image, enabledElement.viewport);\n const sx = imageDisplayedArea.tlhc.x - 1;\n const sy = imageDisplayedArea.tlhc.y - 1;\n const width = imageDisplayedArea.brhc.x - sx;\n const height = imageDisplayedArea.brhc.y - sy;\n\n context.drawImage(renderCanvas, sx, sy, width, height, sx, sy, width, height);\n\n enabledElement.renderingTools = saveLastRendered(enabledElement);\n}\n\n/**\n * API function to draw a pseudo-color image to a given layer\n *\n * @param {EnabledElementLayer} layer The layer that the image will be added to\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n */\nexport function addLabelMapLayer (layer, invalidated) {\n if (layer === undefined) {\n throw new Error('addLabelMapLayer: layer parameter must not be undefined');\n }\n\n const image = layer.image;\n\n if (image === undefined) {\n throw new Error('addLabelMapLayer: image must be loaded before it can be drawn');\n }\n\n layer.canvas = getRenderCanvas(layer, image, invalidated);\n\n const context = layer.canvas.getContext('2d', {\n desynchronized: true\n });\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !layer.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n layer.renderingTools = saveLastRendered(layer);\n}\n", "import { getLayers, getActiveLayer, getVisibleLayers } from '../layers.js';\nimport { addGrayscaleLayer } from '../rendering/renderGrayscaleImage.js';\nimport { addColorLayer } from '../rendering/renderColorImage.js';\nimport { addPseudoColorLayer } from '../rendering/renderPseudoColorImage.js';\nimport { addLabelMapLayer } from '../rendering/renderLabelMapImage.js';\nimport setToPixelCoordinateSystem from '../setToPixelCoordinateSystem.js';\nimport getDisplayedArea from './getDisplayedArea.js';\n\nfunction getViewportRatio (baseLayer, targetLayer) {\n if (!baseLayer.syncProps) {\n updateLayerSyncProps(baseLayer);\n }\n\n if (!targetLayer.syncProps) {\n updateLayerSyncProps(targetLayer);\n }\n\n return targetLayer.syncProps.originalScale / baseLayer.syncProps.originalScale;\n}\n\nfunction updateLayerSyncProps (layer) {\n const syncProps = layer.syncProps || {};\n\n // This is used to keep each of the layers' viewports in sync with the active layer\n syncProps.originalScale = layer.viewport.scale;\n\n layer.syncProps = syncProps;\n}\n\n// Sync all viewports based on active layer's viewport\nfunction syncViewports (layers, activeLayer) {\n // If we intend to keep the viewport's scale, translation and rotation in sync,\n // loop through the layers\n layers.forEach((layer) => {\n // Don't do anything to the active layer\n // Don't do anything if this layer has no viewport\n if (layer === activeLayer ||\n !layer.viewport ||\n !activeLayer.viewport) {\n return;\n }\n\n if (!layer.syncProps) {\n updateLayerSyncProps(layer);\n }\n\n const viewportRatio = getViewportRatio(activeLayer, layer);\n\n // Update the layer's translation and scale to keep them in sync with the first image\n // based on the ratios between the images\n layer.viewport.scale = activeLayer.viewport.scale * viewportRatio;\n layer.viewport.rotation = activeLayer.viewport.rotation;\n layer.viewport.translation = {\n x: (activeLayer.viewport.translation.x / viewportRatio),\n y: (activeLayer.viewport.translation.y / viewportRatio)\n };\n layer.viewport.hflip = activeLayer.viewport.hflip;\n layer.viewport.vflip = activeLayer.viewport.vflip;\n });\n}\n\n/**\n * Internal function to render all layers for a Cornerstone enabled element\n *\n * @param {CanvasRenderingContext2D} context Canvas context to draw upon\n * @param {EnabledElementLayer[]} layers The array of all layers for this enabled element\n * @param {Boolean} invalidated A boolean whether or not this image has been invalidated and must be redrawn\n * @returns {void}\n * @memberof Internal\n */\nfunction renderLayers (context, layers, invalidated) {\n // Loop through each layer and draw it to the canvas\n layers.forEach((layer, index) => {\n if (!layer.image) {\n return;\n }\n\n context.save();\n\n // Set the layer's canvas to the pixel coordinate system\n layer.canvas = context.canvas;\n setToPixelCoordinateSystem(layer, context);\n\n // Render into the layer's canvas\n const colormap = layer.viewport.colormap || layer.options.colormap;\n const labelmap = layer.viewport.labelmap;\n const isInvalid = layer.invalid || invalidated;\n\n if (colormap && colormap !== '' && labelmap === true) {\n addLabelMapLayer(layer, isInvalid);\n } else if (colormap && colormap !== '') {\n addPseudoColorLayer(layer, isInvalid);\n } else if (layer.image.color === true) {\n addColorLayer(layer, isInvalid);\n } else {\n // If this is the base layer, use the alpha channel for rendering of the grayscale image\n const useAlphaChannel = (index === 0);\n\n addGrayscaleLayer(layer, isInvalid, useAlphaChannel);\n }\n\n // Apply any global opacity settings that have been defined for this layer\n if (layer.options && layer.options.opacity) {\n context.globalAlpha = layer.options.opacity;\n } else {\n context.globalAlpha = 1;\n }\n\n if (layer.options && layer.options.fillStyle) {\n context.fillStyle = layer.options.fillStyle;\n }\n\n // Set the pixelReplication property before drawing from the layer into the\n // composite canvas\n context.imageSmoothingEnabled = !layer.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n // Draw from the current layer's canvas onto the enabled element's canvas\n const layerDisplayedArea = getDisplayedArea(layer.image, layer.viewport);\n const sx = layerDisplayedArea.tlhc.x - 1;\n const sy = layerDisplayedArea.tlhc.y - 1;\n const width = layerDisplayedArea.brhc.x - sx;\n const height = layerDisplayedArea.brhc.y - sy;\n\n context.drawImage(layer.canvas, sx, sy, width, height, sx, sy, width, height);\n context.restore();\n\n layer.invalid = false;\n });\n}\n\n/**\n * Internal API function to draw a composite image to a given enabled element\n *\n * @param {EnabledElement} enabledElement An enabled element to draw into\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n */\nexport default function (enabledElement, invalidated) {\n const element = enabledElement.element;\n const allLayers = getLayers(element);\n const activeLayer = getActiveLayer(element);\n const visibleLayers = getVisibleLayers(element);\n const resynced = !enabledElement.lastSyncViewportsState && enabledElement.syncViewports;\n\n // This state will help us to determine if the user has re-synced the\n // layers allowing us to make a new copy of the viewports\n enabledElement.lastSyncViewportsState = enabledElement.syncViewports;\n\n // Stores a copy of all viewports if the user has just synced them then we can use the\n // copies to calculate anything later (ratio, translation offset, rotation offset, etc)\n if (resynced) {\n allLayers.forEach(function (layer) {\n if (layer.viewport) {\n updateLayerSyncProps(layer);\n }\n });\n }\n\n // Sync all viewports in case it's activated\n if (enabledElement.syncViewports === true) {\n syncViewports(visibleLayers, activeLayer);\n }\n\n // Get the enabled element's canvas so we can draw to it\n const context = enabledElement.canvas.getContext('2d', {\n desynchronized: true\n });\n\n context.setTransform(1, 0, 0, 1, 0, 0);\n\n // Clear the canvas\n context.fillStyle = 'black';\n context.fillRect(0, 0, enabledElement.canvas.width, enabledElement.canvas.height);\n\n // Render all visible layers\n renderLayers(context, visibleLayers, invalidated);\n}\n", "import now from './now.js';\r\nimport drawCompositeImage from './drawCompositeImage.js';\r\nimport { renderColorImage } from '../rendering/renderColorImage.js';\r\nimport { renderGrayscaleImage } from '../rendering/renderGrayscaleImage.js';\r\nimport { renderPseudoColorImage } from '../rendering/renderPseudoColorImage.js';\r\nimport { renderLabelMapImage } from '../rendering/renderLabelMapImage.js';\r\nimport triggerEvent from '../triggerEvent.js';\r\nimport EVENTS from '../events.js';\r\n\r\n/**\r\n * Draw an image to a given enabled element synchronously\r\n *\r\n * @param {EnabledElement} enabledElement An enabled element to draw into\r\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\r\n * @returns {void}\r\n * @memberof Internal\r\n */\r\nexport default function (enabledElement, invalidated) {\r\n const image = enabledElement.image;\r\n const element = enabledElement.element;\r\n const layers = enabledElement.layers || [];\r\n\r\n // Check if enabledElement can be redrawn\r\n if (!enabledElement.canvas || !enabledElement.image) {\r\n return;\r\n }\r\n\r\n // Start measuring the time needed to draw the image/layers\r\n const start = now();\r\n\r\n image.stats = {\r\n lastGetPixelDataTime: -1.0,\r\n lastStoredPixelDataToCanvasImageDataTime: -1.0,\r\n lastPutImageDataTime: -1.0,\r\n lastRenderTime: -1.0,\r\n lastLutGenerateTime: -1.0\r\n };\r\n\r\n if (layers && layers.length) {\r\n drawCompositeImage(enabledElement, invalidated);\r\n } else if (image) {\r\n let render = image.render;\r\n\r\n if (!render) {\r\n if (enabledElement.viewport.colormap &&\r\n enabledElement.viewport.colormap !== '' &&\r\n enabledElement.image.labelmap === true) {\r\n render = renderLabelMapImage;\r\n } else if (enabledElement.viewport.colormap && enabledElement.viewport.colormap !== '') {\r\n render = renderPseudoColorImage;\r\n } else if (image.color) {\r\n render = renderColorImage;\r\n } else {\r\n render = renderGrayscaleImage;\r\n }\r\n }\r\n\r\n render(enabledElement, invalidated);\r\n }\r\n\r\n // Calculate how long it took to draw the image/layers\r\n const renderTimeInMs = now() - start;\r\n\r\n const eventData = {\r\n viewport: enabledElement.viewport,\r\n element,\r\n image,\r\n enabledElement,\r\n canvasContext: enabledElement.canvas.getContext('2d', {\r\n desynchronized: true\r\n }),\r\n renderTimeInMs\r\n };\r\n\r\n image.stats.lastRenderTime = renderTimeInMs;\r\n\r\n enabledElement.invalid = false;\r\n enabledElement.needsRedraw = false;\r\n\r\n triggerEvent(element, EVENTS.IMAGE_RENDERED, eventData);\r\n}\r\n", "function requestFrame (callback) {\n window.setTimeout(callback, 1000 / 60);\n}\n\n/**\n * Polyfills requestAnimationFrame for older browsers.\n *\n * @param {Function} callback A parameter specifying a function to call when it's time to update your animation for the next repaint. The callback has one single argument, a DOMHighResTimeStamp, which indicates the current time (the time returned from performance.now() ) for when requestAnimationFrame starts to fire callbacks.\n *\n * @return {Number} A long integer value, the request id, that uniquely identifies the entry in the callback list. This is a non-zero value, but you may not make any other assumptions about its value. You can pass this value to window.cancelAnimationFrame() to cancel the refresh callback request.\n * @memberof Polyfills\n */\nexport default function (callback) {\n return window.requestAnimationFrame(callback) ||\n window.webkitRequestAnimationFrame(callback) ||\n window.mozRequestAnimationFrame(callback) ||\n window.oRequestAnimationFrame(callback) ||\n window.msRequestAnimationFrame(callback) ||\n requestFrame(callback);\n}\n", "import webGL from '../webgl/index.js';\n\n/**\n * Checks if webGL is supported and initializes the rendering engine.\n * @param {any} options Options to check if webgl rendering is requested (e.g. enable webgl by passing {renderer: 'webgl'})\n * @returns {Boolean} true if webgl rendering has been successfully initialized. Otherwise, false.\n */\nexport default function (options) {\n if (webGL.renderer.isWebGLAvailable()) {\n // If WebGL is available on the device, initialize the renderer\n // And return the renderCanvas from the WebGL rendering path\n webGL.renderer.initRenderer();\n options.renderer = 'webgl';\n options.desynchronized = true;\n options.preserveDrawingBuffer = true;\n\n return true;\n }\n\n // If WebGL is not available on this device, we will fall back\n // To using the Canvas renderer\n console.error('WebGL not available, falling back to Canvas renderer');\n\n delete options.renderer;\n delete options.preserveDrawingBuffer;\n\n return false;\n}\n", "const CANVAS_CSS_CLASS = 'cornerstone-canvas';\n\n/**\n * Create a canvas and append it to the element\n *\n * @param {HTMLElement} element An HTML Element\n * @return {HTMLElement} canvas A Canvas DOM element\n */\nfunction createCanvas (element) {\n const canvas = document.createElement('canvas');\n\n canvas.style.display = 'block';\n canvas.classList.add(CANVAS_CSS_CLASS);\n element.appendChild(canvas);\n\n return canvas;\n}\n\n/**\n * Create a canvas or returns the one that already exists for a given element\n *\n * @param {HTMLElement} element An HTML Element\n * @return {HTMLElement} canvas A Canvas DOM element\n */\nexport default function getCanvas (element) {\n const selector = `canvas.${CANVAS_CSS_CLASS}`;\n\n return element.querySelector(selector) || createCanvas(element);\n}\n", "import { addEnabledElement } from './enabledElements.js';\r\nimport resize from './resize.js';\r\nimport drawImageSync from './internal/drawImageSync.js';\r\nimport requestAnimationFrame from './internal/requestAnimationFrame.js';\r\nimport tryEnableWebgl from './internal/tryEnableWebgl.js';\r\nimport triggerEvent from './triggerEvent.js';\r\nimport generateUUID from './generateUUID.js';\r\nimport EVENTS, { events } from './events.js';\r\nimport getCanvas from './internal/getCanvas.js';\r\n\r\n/**\r\n * @module Enable\r\n * This module is responsible for enabling an element to display images with cornerstone\r\n */\r\n\r\n/**\r\n * Returns whether or not an Enabled Element has either a currently active image or\r\n * a non-empty Array of Enabled Element Layers.\r\n *\r\n * @param {EnabledElement} enabledElement An Enabled Element\r\n * @return {Boolean} Whether or not the Enabled Element has an active image or valid set of layers\r\n * @memberof Enable\r\n */\r\nfunction hasImageOrLayers (enabledElement) {\r\n return enabledElement.image !== undefined || enabledElement.layers.length > 0;\r\n}\r\n\r\n/**\r\n * Enable an HTML Element for use in Cornerstone\r\n *\r\n * - If there is a Canvas already present within the HTMLElement, and it has the class\r\n * 'cornerstone-canvas', this function will use this existing Canvas instead of creating\r\n * a new one. This may be helpful when using libraries (e.g. React, Vue) which don't\r\n * want third parties to change the DOM.\r\n *\r\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\r\n * @param {Object} options Options for the enabledElement\r\n *\r\n * @return {void}\r\n * @memberof Enable\r\n */\r\nexport default function (element, options) {\r\n if (element === undefined) {\r\n throw new Error('enable: parameter element cannot be undefined');\r\n }\r\n\r\n // If this enabled element has the option set for WebGL, we should\r\n // Check if this device actually supports it\r\n if (\r\n options &&\r\n options.renderer &&\r\n options.renderer.toLowerCase() === 'webgl'\r\n ) {\r\n tryEnableWebgl(options);\r\n }\r\n\r\n const canvas = getCanvas(element);\r\n\r\n const enabledElement = {\r\n element,\r\n canvas,\r\n image: undefined, // Will be set once image is loaded\r\n invalid: false, // True if image needs to be drawn, false if not\r\n needsRedraw: true,\r\n options: Object.assign({}, options),\r\n layers: [],\r\n data: {},\r\n renderingTools: {},\r\n uuid: generateUUID()\r\n };\r\n\r\n addEnabledElement(enabledElement);\r\n\r\n triggerEvent(events, EVENTS.ELEMENT_ENABLED, enabledElement);\r\n\r\n resize(element, true);\r\n\r\n /**\r\n * Draw the image immediately\r\n *\r\n * @param {DOMHighResTimeStamp} timestamp The current time for when requestAnimationFrame starts to fire callbacks\r\n * @returns {void}\r\n * @memberof Drawing\r\n */\r\n function draw (timestamp) {\r\n if (enabledElement.canvas === undefined) {\r\n return;\r\n }\r\n\r\n const eventDetails = {\r\n enabledElement,\r\n timestamp\r\n };\r\n\r\n triggerEvent(enabledElement.element, EVENTS.PRE_RENDER, eventDetails);\r\n\r\n if (enabledElement.needsRedraw && hasImageOrLayers(enabledElement)) {\r\n drawImageSync(enabledElement, enabledElement.invalid);\r\n }\r\n\r\n requestAnimationFrame(draw);\r\n }\r\n\r\n draw();\r\n}\r\n", "/**\n* Generates a UUID for the enabledElement.\n*\n* @return {String} the UUID.\n*/\nexport default function () { // https://stackoverflow.com/a/8809472/9208320 Public Domain/MIT\n /* eslint no-bitwise: [\"error\", { \"allow\": [\"&\",\"|\"] }] */\n let d = new Date().getTime();\n\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n d += performance.now(); // Use high-precision timer if available\n }\n\n return 'x.x.x.x.x.x.xxxx.xxx.x.x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n const r = (d + Math.random() * 16) % 16 | 0;\n\n d = Math.floor(d / 16);\n\n return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);\n });\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport getDefaultViewport from './internal/getDefaultViewport.js';\n\n/**\n * Returns a default viewport for display the specified image on the specified\n * enabled element. The default viewport is fit to window\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @param {Image} image A Cornerstone Image Object\n *\n * @returns {Viewport} The default viewport for the image\n */\nexport default function (element, image) {\n const enabledElement = getEnabledElement(element);\n\n return getDefaultViewport(enabledElement.canvas, image);\n}\n", "import { getEnabledElement } from './enabledElements.js';\n\n/**\n * Returns the currently displayed image for an element or undefined if no image has\n * been displayed yet\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @returns {Image} The Cornerstone Image Object displayed in this element\n */\nexport default function (element) {\n const enabledElement = getEnabledElement(element);\n\n return enabledElement.image;\n}\n", "import { getEnabledElement } from './enabledElements.js';\n\n/**\n * Retrieves an array of stored pixel values from a rectangular region of an image\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @param {Number} x The x coordinate of the top left corner of the sampling rectangle in image coordinates\n * @param {Number} y The y coordinate of the top left corner of the sampling rectangle in image coordinates\n * @param {Number} width The width of the of the sampling rectangle in image coordinates\n * @param {Number} height The height of the of the sampling rectangle in image coordinates\n * @returns {Array} The stored pixel value of the pixels in the sampling rectangle\n */\nexport default function (element, x, y, width, height) {\n if (element === undefined) {\n throw new Error('getStoredPixels: parameter element must not be undefined');\n }\n\n x = Math.round(x);\n y = Math.round(y);\n const enabledElement = getEnabledElement(element);\n const storedPixels = [];\n let index = 0;\n const pixelData = enabledElement.image.getPixelData();\n\n for (let row = 0; row < height; row++) {\n for (let column = 0; column < width; column++) {\n const spIndex = ((row + y) * enabledElement.image.columns) + (column + x);\n\n storedPixels[index++] = pixelData[spIndex];\n }\n }\n\n return storedPixels;\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport getStoredPixels from './getStoredPixels.js';\nimport getModalityLUT from './internal/getModalityLUT.js';\n\n/**\n * Retrieves an array of pixels from a rectangular region with modality LUT transformation applied\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @param {Number} x The x coordinate of the top left corner of the sampling rectangle in image coordinates\n * @param {Number} y The y coordinate of the top left corner of the sampling rectangle in image coordinates\n * @param {Number} width The width of the of the sampling rectangle in image coordinates\n * @param {Number} height The height of the of the sampling rectangle in image coordinates\n * @returns {Array} The modality pixel value of the pixels in the sampling rectangle\n */\nexport default function (element, x, y, width, height) {\n const storedPixels = getStoredPixels(element, x, y, width, height);\n const ee = getEnabledElement(element);\n const mlutfn = getModalityLUT(ee.image.slope, ee.image.intercept, ee.viewport.modalityLUT);\n\n return storedPixels.map(mlutfn);\n}\n", "import { getEnabledElement } from './enabledElements.js';\n\n/**\n * Retrieves the viewport for the specified enabled element\n *\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\n * @returns {Viewport|undefined} The Cornerstone Viewport settings for this element, if they exist. Otherwise, undefined\n * @memberof ViewportSettings\n */\nexport default function (element) {\n const enabledElement = getEnabledElement(element);\n const viewport = enabledElement.viewport;\n\n if (viewport === undefined) {\n return;\n }\n\n // Return a copy of the viewport\n return Object.assign({}, viewport);\n}\n", "import { Transform } from './transform.js';\r\nimport calculateTransform from './calculateTransform.js';\r\nimport drawImage from './drawImage.js';\r\nimport generateLut from './generateLut.js';\r\nimport getDefaultViewport from './getDefaultViewport.js';\r\nimport getTransform from './getTransform.js';\r\nimport requestAnimationFrame from './requestAnimationFrame.js';\r\nimport setDefaultViewport from './setDefaultViewport.js';\r\nimport storedColorPixelDataToCanvasImageData from './storedColorPixelDataToCanvasImageData.js';\r\nimport storedPixelDataToCanvasImageData from './storedPixelDataToCanvasImageData.js';\r\nimport storedPixelDataToCanvasImageDataColorLUT from './storedPixelDataToCanvasImageDataColorLUT.js';\r\nimport storedPixelDataToCanvasImageDataPseudocolorLUT from './storedPixelDataToCanvasImageDataPseudocolorLUT.js';\r\nimport storedPixelDataToCanvasImageDataRGBA from './storedPixelDataToCanvasImageDataRGBA.js';\r\n\r\n/**\r\n * @module Internal\r\n */\r\nexport default {\r\n drawImage,\r\n generateLut,\r\n getDefaultViewport,\r\n requestAnimationFrame,\r\n setDefaultViewport,\r\n storedPixelDataToCanvasImageData,\r\n storedPixelDataToCanvasImageDataRGBA,\r\n storedPixelDataToCanvasImageDataColorLUT,\r\n storedPixelDataToCanvasImageDataPseudocolorLUT,\r\n storedColorPixelDataToCanvasImageData,\r\n getTransform,\r\n calculateTransform,\r\n Transform\r\n};\r\n", "import { getEnabledElement } from './enabledElements.js';\r\nimport triggerEvent from './triggerEvent.js';\r\nimport EVENTS from './events.js';\r\n\r\n/**\r\n * Sets the invalid flag on the enabled element and fires an event\r\n * @param {HTMLElement} element The DOM element enabled for Cornerstone\r\n * @returns {void}\r\n * @memberof Drawing\r\n */\r\nexport default function (element) {\r\n const enabledElement = getEnabledElement(element);\r\n\r\n enabledElement.invalid = true;\r\n enabledElement.needsRedraw = true;\r\n const eventData = {\r\n element\r\n };\r\n\r\n triggerEvent(element, EVENTS.INVALIDATED, eventData);\r\n}\r\n", "import { getEnabledElementsByImageId } from './enabledElements.js';\nimport drawImage from './internal/drawImage.js';\n\n/**\n * Forces the image to be updated/redrawn for all enabled elements\n * displaying the specified imageId\n *\n * @param {string} imageId The imageId of the Cornerstone Image Object to redraw\n * @returns {void}\n * @memberof Drawing\n */\nexport default function (imageId) {\n const enabledElements = getEnabledElementsByImageId(imageId);\n\n enabledElements.forEach(function (enabledElement) {\n drawImage(enabledElement, true);\n });\n}\n", "// This module defines a way to access various metadata about an imageId. This layer of abstraction exists\n// So metadata can be provided in different ways (e.g. by parsing DICOM P10 or by a WADO-RS document)\n\nconst providers = [];\n\n/**\n * @module Metadata\n */\n\n/**\n * Adds a metadata provider with the specified priority\n * @param {Function} provider Metadata provider function\n * @param {Number} [priority=0] - 0 is default/normal, > 0 is high, < 0 is low\n *\n * @returns {void}\n * @memberof Metadata\n */\nexport function addProvider (provider, priority = 0) {\n let i;\n\n // Find the right spot to insert this provider based on priority\n for (i = 0; i < providers.length; i++) {\n if (providers[i].priority <= priority) {\n break;\n }\n }\n\n // Insert the decode task at position i\n providers.splice(i, 0, {\n priority,\n provider\n });\n}\n\n/**\n * Removes the specified provider\n *\n * @param {Function} provider Metadata provider function\n *\n * @returns {void}\n * @memberof Metadata\n */\nexport function removeProvider (provider) {\n for (let i = 0; i < providers.length; i++) {\n if (providers[i].provider === provider) {\n providers.splice(i, 1);\n\n break;\n }\n }\n}\n\n/**\n * Gets metadata from the registered metadata providers. Will call each one from highest priority to lowest\n * until one responds\n *\n * @param {String} type The type of metadata requested from the metadata store\n * @param {String} imageId The Cornerstone Image Object's imageId\n *\n * @returns {*} The metadata retrieved from the metadata store\n * @memberof Metadata\n */\nfunction getMetaData (type, imageId) {\n // Invoke each provider in priority order until one returns something\n for (let i = 0; i < providers.length; i++) {\n const result = providers[i].provider(type, imageId);\n\n if (result !== undefined) {\n return result;\n }\n }\n}\n\nexport default {\n addProvider,\n removeProvider,\n get: getMetaData\n};\n", "import { getEnabledElement } from './enabledElements.js';\nimport getTransform from './internal/getTransform.js';\n\n/**\n * Converts a point in the page coordinate system to the pixel coordinate\n * system\n *\n * @param {HTMLElement} element The Cornerstone element within which the input point lies\n * @param {Number} pageX The x value in the page coordinate system\n * @param {Number} pageY The y value in the page coordinate system\n *\n * @returns {{x: Number, y: Number}} The transformed point in the pixel coordinate system\n */\nexport default function (element, pageX, pageY) {\n const enabledElement = getEnabledElement(element);\n\n if (enabledElement.image === undefined) {\n throw new Error('image has not been loaded yet');\n }\n\n // Convert the pageX and pageY to the canvas client coordinates\n const rect = element.getBoundingClientRect();\n const clientX = pageX - rect.left - window.pageXOffset;\n const clientY = pageY - rect.top - window.pageYOffset;\n\n const pt = { x: clientX,\n y: clientY };\n const transform = getTransform(enabledElement);\n\n transform.invert();\n\n return transform.transformPoint(pt.x, pt.y);\n}\n", "import { getEnabledElement } from './enabledElements.js';\nimport getTransform from './internal/getTransform.js';\n\n/**\n * Converts a point in the pixel coordinate system to the canvas coordinate system\n * system. This can be used to render using canvas context without having the weird\n * side effects that come from scaling and non square pixels\n *\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\n * @param {{x: Number, y: Number}} pt The transformed point in the pixel coordinate system\n *\n * @returns {{x: Number, y: Number}} The input point in the canvas coordinate system\n * @memberof PixelCoordinateSystem\n */\nexport default function (element, pt) {\n const enabledElement = getEnabledElement(element);\n const transform = getTransform(enabledElement);\n\n\n return transform.transformPoint(pt.x, pt.y);\n}\n", "import triggerEvent from '../triggerEvent.js';\r\nimport EVENTS from '../events.js';\r\nimport drawImageSync from '../internal/drawImageSync.js';\r\nimport getDefaultViewport from '../internal/getDefaultViewport.js';\r\nimport tryEnableWebgl from '../internal/tryEnableWebgl.js';\r\n\r\n/**\r\n * @typedef {Object} EnabledElementStub\r\n * @property {HTMLElement} element The enabled element\r\n * @property {HTMLCanvasElement} canvas The current canvas\r\n * @property {Object} image Currently displayed image\r\n * @property {Boolean} invalid Whether or not the image pixel data has been changed\r\n * @property {Boolean} needsRedraw A flag for triggering a redraw of the canvas without re-retrieving the pixel data, since it remains valid\r\n * @property {Object} options Layer drawing options\r\n * @property {Object[]} layers Layers added to the EnabledElement\r\n * @property {Object} data\r\n * @property {Object} renderingTools\r\n * @property {Object} viewport The current viewport\r\n * @memberof rendering\r\n */\r\n\r\n/**\r\n * creates a dummy enabled element\r\n *\r\n * @param {HTMLCanvasElement} canvas the canvas that will be assigned to the enabled element.\r\n * @param {any} image An Image loaded by a Cornerstone Image Loader\r\n * @param { any } options Options for rendering the image (e.g.enable webgl by {renderer: 'webgl' })\r\n * @param { any } viewport A set of Cornerstone viewport parameters\r\n * @returns {EnabledElementStub} a dummy enabled element\r\n * @memberof rendering\r\n */\r\nfunction createEnabledElementStub (canvas, image, options, viewport) {\r\n return {\r\n element: canvas,\r\n canvas,\r\n image,\r\n invalid: true, // True if image needs to be drawn, false if not\r\n needsRedraw: true,\r\n options,\r\n layers: [],\r\n data: {},\r\n renderingTools: {},\r\n viewport\r\n };\r\n}\r\n\r\n/**\r\n * Render the image to the provided canvas immediately.\r\n * @param {any} canvas The HTML canvas where the image will be rendered.\r\n * @param {any} image An Image loaded by a Cornerstone Image Loader\r\n * @param {any} [viewport = null] A set of Cornerstone viewport parameters\r\n * @param {any} [options = null] Options for rendering the image (e.g. enable webgl by {renderer: 'webgl'})\r\n * @returns {void}\r\n * @memberof rendering\r\n */\r\nexport default function (canvas, image, viewport = null, options = null) {\r\n if (canvas === undefined) {\r\n throw new Error('renderToCanvas: parameter canvas cannot be undefined');\r\n }\r\n\r\n // If this enabled element has the option set for WebGL, we should\r\n // Check if this device actually supports it\r\n if (options && options.renderer && options.renderer.toLowerCase() === 'webgl') {\r\n tryEnableWebgl(options);\r\n }\r\n\r\n const defaultViewport = getDefaultViewport(canvas, image);\r\n\r\n if (viewport) {\r\n Object.assign(defaultViewport, viewport);\r\n }\r\n\r\n const enabledElementStub = createEnabledElementStub(canvas, image, options, defaultViewport);\r\n\r\n const eventDetails = {\r\n enabledElement: enabledElementStub,\r\n timestamp: Date.now()\r\n };\r\n\r\n triggerEvent(enabledElementStub.element, EVENTS.PRE_RENDER, eventDetails);\r\n\r\n drawImageSync(enabledElementStub, enabledElementStub.invalid);\r\n}\r\n", "import setToPixelCoordinateSystem from '../setToPixelCoordinateSystem.js';\nimport { renderColorImage } from './renderColorImage.js';\nimport getDisplayedArea from '../internal/getDisplayedArea.js';\n\n/**\n * API function to draw a standard web image (PNG, JPG) to an enabledImage\n *\n * @param {EnabledElement} enabledElement The Cornerstone Enabled Element to redraw\n * @param {Boolean} invalidated - true if pixel data has been invalidated and cached rendering should not be used\n * @returns {void}\n * @memberof rendering\n */\nexport function renderWebImage (enabledElement, invalidated) {\n if (enabledElement === undefined) {\n throw new Error('renderWebImage: enabledElement parameter must not be undefined');\n }\n\n const image = enabledElement.image;\n\n if (image === undefined) {\n throw new Error('renderWebImage: image must be loaded before it can be drawn');\n }\n\n // If the viewport ww/wc and invert all match the initial state of the image, we can draw the image\n // Directly. If any of those are changed, we call renderColorImage() to apply the lut\n if (enabledElement.viewport.voi.windowWidth === enabledElement.image.windowWidth &&\n enabledElement.viewport.voi.windowCenter === enabledElement.image.windowCenter &&\n enabledElement.viewport.invert === false) {\n\n // Get the canvas context and reset the transform\n const context = enabledElement.canvas.getContext('2d', {\n desynchronized: true\n });\n\n context.setTransform(1, 0, 0, 1, 0, 0);\n\n // Clear the canvas\n context.fillStyle = 'black';\n context.fillRect(0, 0, enabledElement.canvas.width, enabledElement.canvas.height);\n\n // Turn off image smooth/interpolation if pixelReplication is set in the viewport\n context.imageSmoothingEnabled = !enabledElement.viewport.pixelReplication;\n context.mozImageSmoothingEnabled = context.imageSmoothingEnabled;\n\n // Save the canvas context state and apply the viewport properties\n setToPixelCoordinateSystem(enabledElement, context);\n const imageDisplayedArea = getDisplayedArea(enabledElement.image, enabledElement.viewport);\n const sx = imageDisplayedArea.tlhc.x - 1;\n const sy = imageDisplayedArea.tlhc.y - 1;\n const width = imageDisplayedArea.brhc.x - sx;\n const height = imageDisplayedArea.brhc.y - sy;\n\n context.drawImage(image.getImage(), sx, sy, width, height, sx, sy, width, height);\n } else {\n renderColorImage(enabledElement, invalidated);\n }\n}\n", "import { renderColorImage } from './renderColorImage.js';\nimport { renderGrayscaleImage } from './renderGrayscaleImage.js';\nimport { renderWebImage } from './renderWebImage.js';\nimport { renderPseudoColorImage } from './renderPseudoColorImage.js';\nimport { renderLabelMapImage } from './renderLabelMapImage.js';\nimport renderToCanvas from './renderToCanvas.js';\n\n/**\n * @module rendering\n */\nexport default {\n colorImage: renderColorImage,\n grayscaleImage: renderGrayscaleImage,\n webImage: renderWebImage,\n pseudoColorImage: renderPseudoColorImage,\n labelMapImage: renderLabelMapImage,\n toCanvas: renderToCanvas\n};\n", "import getDefaultViewport from './internal/getDefaultViewport.js';\nimport { getEnabledElement } from './enabledElements.js';\nimport updateImage from './updateImage.js';\n\n/**\n * Resets the viewport to the default settings\n *\n * @param {HTMLElement} element An HTML Element enabled for Cornerstone\n * @returns {void}\n */\nexport default function (element) {\n const enabledElement = getEnabledElement(element);\n\n enabledElement.viewport = getDefaultViewport(enabledElement.canvas, enabledElement.image);\n updateImage(element);\n}\n", "import getDefaultViewport from './internal/getDefaultViewport.js';\nimport { getEnabledElement } from './enabledElements.js';\nimport updateImage from './updateImage.js';\n\nconst MIN_WINDOW_WIDTH = 0.000001;\nconst MIN_VIEWPORT_SCALE = 0.0001;\n\n/**\n * Sets/updates viewport of a given enabled element\n *\n * @param {HTMLElement} element - DOM element of the enabled element\n * @param {Viewport} [viewport] - Object containing the viewport properties\n * @returns {void}\n * @memberof ViewportSettings\n */\nexport default function (element, viewport) {\n const enabledElement = getEnabledElement(element);\n\n // If viewport is not already set, start with default and merge new\n // viewport options later\n if (enabledElement.viewport === undefined) {\n enabledElement.viewport = getDefaultViewport(enabledElement.canvas);\n }\n\n // Merge viewport\n if (viewport) {\n for (const attrname in viewport) {\n if (viewport[attrname] !== null) {\n enabledElement.viewport[attrname] = viewport[attrname];\n }\n }\n }\n\n\n // Prevent window width from being too small (note that values close to zero are valid and can occur with\n // PET images in particular)\n if (enabledElement.viewport.voi.windowWidth) {\n enabledElement.viewport.voi.windowWidth = Math.max(enabledElement.viewport.voi.windowWidth, MIN_WINDOW_WIDTH);\n }\n\n // Prevent scale from getting too small\n if (enabledElement.viewport.scale) {\n enabledElement.viewport.scale = Math.max(enabledElement.viewport.scale, MIN_VIEWPORT_SCALE);\n }\n\n // Normalize the rotation value to a positive rotation in degrees\n enabledElement.viewport.rotation %= 360;\n if (enabledElement.viewport.rotation < 0) {\n enabledElement.viewport.rotation += 360;\n }\n\n if (enabledElement.image) {\n // Force the image to be updated since the viewport has been modified\n updateImage(element);\n }\n}\n", "// Internal (some of these are from old internal/legacy expose)\n\nimport { default as EVENTS, events } from './events.js';\nimport {\n addEnabledElement,\n getEnabledElement,\n getEnabledElements,\n getEnabledElementsByImageId\n} from './enabledElements.js';\nimport {\n addLayer,\n getActiveLayer,\n getLayer,\n getLayers,\n getVisibleLayers,\n purgeLayers,\n removeLayer,\n setActiveLayer,\n setLayerImage\n} from './layers.js';\nimport {\n convertImageToFalseColorImage,\n convertToFalseColorImage,\n restoreImage\n} from './falseColorMapping.js';\nimport { getElementData, removeElementData } from './enabledElementData.js';\nimport {\n loadAndCacheImage,\n loadImage,\n registerImageLoader,\n registerUnknownImageLoader\n} from './imageLoader.js';\n\nimport imageLoadPoolManager from './requestPool/imageLoadPoolManager.ts';\nimport imageRetrievalPoolManager from './requestPool/imageRetrievalPoolManager.ts';\nimport { RequestPoolManager } from './requestPool/RequestPoolManager.ts';\n\nimport { default as canvasToPixel } from './canvasToPixel.js';\nimport { default as colors } from './colors/index.js';\nimport { default as disable } from './disable.js';\nimport { default as displayImage } from './displayImage.js';\nimport { default as draw } from './draw.js';\nimport { default as drawImage } from './internal/drawImage.js';\nimport { default as drawInvalidated } from './drawInvalidated.js';\nimport { default as enable } from './enable.js';\nimport { default as fitToWindow } from './fitToWindow.js';\nimport { default as generateLut } from './internal/generateLut.js';\nimport { default as getDefaultViewport } from './internal/getDefaultViewport.js';\nimport { default as getDefaultViewportForImage } from './getDefaultViewportForImage.js';\nimport { default as getDisplayedArea } from './internal/getDisplayedArea.js';\nimport { default as getImage } from './getImage.js';\nimport { default as getPixels } from './getPixels.js';\nimport { default as getStoredPixels } from './getStoredPixels.js';\nimport { default as getViewport } from './getViewport.js';\nimport { default as imageCache } from './imageCache.js';\nimport { default as internal } from './internal/index.js';\nimport { default as invalidate } from './invalidate.js';\nimport { default as invalidateImageId } from './invalidateImageId.js';\nimport { default as metaData } from './metaData.js';\nimport { default as pageToPixel } from './pageToPixel.js';\nimport { default as pixelDataToFalseColorData } from './pixelDataToFalseColorData.js';\nimport { default as pixelToCanvas } from './pixelToCanvas.js';\nimport { renderColorImage } from './rendering/renderColorImage.js';\nimport { renderGrayscaleImage } from './rendering/renderGrayscaleImage.js';\nimport { renderLabelMapImage } from './rendering/renderLabelMapImage.js';\nimport { renderPseudoColorImage } from './rendering/renderPseudoColorImage.js';\nimport { default as renderToCanvas } from './rendering/renderToCanvas.js';\nimport { renderWebImage } from './rendering/renderWebImage.js';\nimport { default as rendering } from './rendering/index.js';\nimport { default as requestAnimationFrame } from './internal/requestAnimationFrame.js';\nimport { default as reset } from './reset.js';\nimport { default as resize } from './resize.js';\nimport { default as setDefaultViewport } from './internal/setDefaultViewport.js';\nimport { default as setToPixelCoordinateSystem } from './setToPixelCoordinateSystem.js';\nimport { default as setViewport } from './setViewport.js';\nimport { default as storedColorPixelDataToCanvasImageData } from './internal/storedColorPixelDataToCanvasImageData.js';\nimport { default as storedPixelDataToCanvasImageData } from './internal/storedPixelDataToCanvasImageData.js';\nimport { default as storedPixelDataToCanvasImageDataColorLUT } from './internal/storedPixelDataToCanvasImageDataColorLUT.js';\nimport { default as storedPixelDataToCanvasImageDataPseudocolorLUT } from './internal/storedPixelDataToCanvasImageDataPseudocolorLUT.js';\nimport { default as triggerEvent } from './triggerEvent.js';\nimport { default as updateImage } from './updateImage.js';\nimport { default as webGL } from './webgl/index.js';\n\n// Rendering\n/**\n * @module PixelCoordinateSystem\n */\n\n/**\n * @module ViewportSettings\n */\n\n\nconst cornerstone = {\n drawImage,\n generateLut,\n getDefaultViewport,\n requestAnimationFrame,\n storedPixelDataToCanvasImageData,\n storedColorPixelDataToCanvasImageData,\n storedPixelDataToCanvasImageDataColorLUT,\n storedPixelDataToCanvasImageDataPseudocolorLUT,\n internal,\n renderLabelMapImage,\n renderPseudoColorImage,\n renderColorImage,\n renderGrayscaleImage,\n renderWebImage,\n renderToCanvas,\n canvasToPixel,\n disable,\n displayImage,\n draw,\n drawInvalidated,\n enable,\n getElementData,\n removeElementData,\n getEnabledElement,\n addEnabledElement,\n getEnabledElementsByImageId,\n getEnabledElements,\n addLayer,\n removeLayer,\n getLayer,\n getLayers,\n getVisibleLayers,\n setActiveLayer,\n getActiveLayer,\n purgeLayers,\n setLayerImage,\n fitToWindow,\n getDefaultViewportForImage,\n getDisplayedArea,\n setDefaultViewport,\n getImage,\n getPixels,\n getStoredPixels,\n getViewport,\n loadImage,\n loadAndCacheImage,\n registerImageLoader,\n registerUnknownImageLoader,\n invalidate,\n invalidateImageId,\n pageToPixel,\n pixelToCanvas,\n reset,\n resize,\n setToPixelCoordinateSystem,\n setViewport,\n updateImage,\n pixelDataToFalseColorData,\n rendering,\n imageCache,\n metaData,\n webGL,\n colors,\n convertImageToFalseColorImage,\n convertToFalseColorImage,\n restoreImage,\n EVENTS,\n events,\n triggerEvent,\n imageLoadPoolManager,\n imageRetrievalPoolManager,\n RequestPoolManager\n};\n\nexport {\n drawImage,\n generateLut,\n getDefaultViewport,\n setDefaultViewport,\n requestAnimationFrame,\n storedPixelDataToCanvasImageData,\n storedColorPixelDataToCanvasImageData,\n storedPixelDataToCanvasImageDataColorLUT,\n storedPixelDataToCanvasImageDataPseudocolorLUT,\n internal,\n renderLabelMapImage,\n renderPseudoColorImage,\n renderColorImage,\n renderGrayscaleImage,\n renderWebImage,\n renderToCanvas,\n canvasToPixel,\n disable,\n displayImage,\n draw,\n drawInvalidated,\n enable,\n getElementData,\n removeElementData,\n getEnabledElement,\n addEnabledElement,\n getEnabledElementsByImageId,\n getEnabledElements,\n addLayer,\n removeLayer,\n getLayer,\n getLayers,\n getVisibleLayers,\n setActiveLayer,\n getActiveLayer,\n purgeLayers,\n setLayerImage,\n fitToWindow,\n getDefaultViewportForImage,\n getDisplayedArea,\n getImage,\n getPixels,\n getStoredPixels,\n getViewport,\n loadImage,\n loadAndCacheImage,\n registerImageLoader,\n registerUnknownImageLoader,\n invalidate,\n invalidateImageId,\n pageToPixel,\n pixelToCanvas,\n reset,\n resize,\n setToPixelCoordinateSystem,\n setViewport,\n updateImage,\n pixelDataToFalseColorData,\n rendering,\n imageCache,\n metaData,\n webGL,\n colors,\n convertImageToFalseColorImage,\n convertToFalseColorImage,\n restoreImage,\n EVENTS,\n events,\n triggerEvent,\n imageLoadPoolManager,\n imageRetrievalPoolManager,\n RequestPoolManager\n};\n\nexport default cornerstone;\n" ], "sourceRoot": "" }