- Source
Classes
Namespaces
Members
(static) d65
CIE Standard Illuminant D65, standard 2° observer.
- Source
Methods
(static) MultiProgressHandler(callback)
Multiple progresses handler. Stores a multi dimensional list of progresses to allow to calculate a global progress.
Name | Type | Description |
---|---|---|
callback | function | The function to pass the global progress to. |
- Source
(static) arrayEquals(arr0, arr1) → {boolean}
Check for array equality.
Name | Type | Description |
---|---|---|
arr0 | Array | First array. |
arr1 | * | Second array. |
- Source
True if both array are defined and contain same values.
- Type:
- boolean
(static) arraySortEquals(arr0, arr1) → {boolean}
Check for array equality after sorting.
Name | Type | Description |
---|---|---|
arr0 | Array | First array. |
arr1 | * | Second array. |
- Source
True if both array are defined and contain same values.
- Type:
- boolean
(static) buildMultipart(parts, boundary) → {Uint8Array}
Build a multipart message. See: https://en.wikipedia.org/wiki/MIME#Multipart_messages See: https://hg.orthanc-server.com/orthanc-dicomweb/file/tip/Resources/Samples/JavaScript/stow-rs.js
Name | Type | Description |
---|---|---|
parts | Array | The message parts as an array of object containing content headers and messages as the data property (as returned by parse). |
boundary | string | The message boundary. |
- Source
The full multipart message.
- Type:
- Uint8Array
(static) capitaliseFirstLetter(string) → {string}
Capitalise the first letter of a string.
Name | Type | Description |
---|---|---|
string | string | The string to capitalise the first letter. |
- Source
The new string.
- Type:
- string
(static) cielabToCiexyz(triplet) → {object}
Convert CIE LAB to CIE XYZ (standard illuminant D65, 2degree 1931).
Name | Type | Description |
---|---|---|
triplet | object | CIE LAB triplet as {l,a,b}. |
- Source
CIE XYZ triplet as {x,y,z}.
- Type:
- object
(static) cielabToSrgb(triplet) → {object}
Convert CIE LAB to sRGB (standard illuminant D65).
Name | Type | Description |
---|---|---|
triplet | object | CIE LAB triplet as {l,a,b}. |
- Source
sRGB triplet as {r,g,b}.
- Type:
- object
(static) ciexyzToCielab(triplet) → {object}
Convert CIE XYZ to CIE LAB (standard illuminant D65, 2degree 1931).
Name | Type | Description |
---|---|---|
triplet | object | CIE XYZ triplet as {x,y,z}. |
- Source
CIE LAB triplet as {l,a,b}.
- Type:
- object
(static) ciexyzToSrgb(triplet) → {object}
Convert CIE XYZ to sRGB.
Name | Type | Description |
---|---|---|
triplet | object | CIE XYZ triplet as {x,y,z}. |
- Source
sRGB triplet as {r,g,b}.
- Type:
- object
(static) colourNameToHex(name) → {string}
Get the hex code of a string colour for a colour used in pre dwv v0.17.
Name | Type | Description |
---|---|---|
name | string | The name of a colour. |
- Source
The hex representing the colour.
- Type:
- string
(static) decodeKeyValueUri(uri, replaceMode) → {Array}
Decode a Key/Value pair URI. If a key is repeated, the result be an array of base + each key.
Name | Type | Description |
---|---|---|
uri | string | The URI to decode. |
replaceMode | string | The key replace more. replaceMode can be:
|
- Source
The list of input file urls.
- Type:
- Array
(static) decodeManifest(manifest, nslices) → {Array}
Decode an XML manifest.
Name | Type | Description |
---|---|---|
manifest | object | The manifest to decode. |
nslices | number | The number of slices to load. |
- Source
The decoded manifest.
- Type:
- Array
(static) decodeQuery(query, callback, options)
Generic URI query decoder. Supports manifest: [dwv root]?input=encodeURIComponent('[manifest file]')&type=manifest or encoded URI with base and key value/pairs: [dwv root]?input=encodeURIComponent([root]?key0=value0&key1=value1)
Name | Type | Description |
---|---|---|
query | string | The query part to the input URI. |
callback | function | The function to call with the decoded file urls. |
options | object | Optional url request options. |
- Source
(static) endsWith(str, search) → {boolean}
Check if a string ends with the input element.
Name | Type | Description |
---|---|---|
str | string | The input string. |
search | string | The searched ending. |
- Source
True if the input string ends with the searched string.
- Type:
- boolean
(static) findInArraySubset(arr, callbackFn, start, end) → {number|undefined}
Array find in a subset of the input array. Equivalent to: arr.slice(start, end).find(callbackFn)
Name | Type | Description |
---|---|---|
arr | Array | The input array to search. |
callbackFn | function | The find function. |
start | number | The array start index. |
end | number | The array end index. |
- Source
The index where the element was found.
- Type:
- number |
undefined
(static) getBrightness(rgbTriplet) → {number}
Get the brightness of a RGB colour: calculates the luma (Y) of the YIQ colour space.
Name | Type | Description |
---|---|---|
rgbTriplet | object | RGB triplet. |
- Source
The brightness ([0,1]).
- Type:
- number
(static) getFileExtension(filePath) → {string}
Get a file extension: anything after the last dot. File name starting with a dot are discarded. Extensions are expected to contain at least one letter.
Name | Type | Description |
---|---|---|
filePath | string | The file path containing the file name. |
- Source
The lower case file extension or null for none.
- Type:
- string
(static) getFindArrayInArrayCallback(arr1) → {function}
Get a find in array callback.
Name | Type | Description |
---|---|---|
arr1 | Array | The array to find. |
- Source
The find callback function.
- Type:
- function
(static) getFlags(inputStr) → {Array}
Get flags from an input string. Flags are words surrounded with curly braces.
Name | Type | Description |
---|---|---|
inputStr | string | The input string. |
- Source
An array of found flags.
- Type:
- Array
(static) getRootPath(path) → {string}
Get the root of an input path. Splits using /
as separator.
Name | Type | Description |
---|---|---|
path | string | The input path |
- Source
The input path without its last part.
- Type:
- string
(static) getShadowColour(hexColour) → {string}
Get the shadow colour of an input colour.
Name | Type | Description |
---|---|---|
hexColour | string | The colour (as '#ab01ef'). |
- Source
The shadow colour (white or black).
- Type:
- string
(static) getUriQuery(uri) → {object}
Get the query part, split into an array, of an input URI. The URI scheme is: 'base?query#fragment'
Name | Type | Description |
---|---|---|
uri | string | The input URI. |
- Source
The query part, split into an array, of the input URI.
- Type:
- object
(static) getUrlFromUri(uri) → {URL}
Get an object URL from a string uri.
Name | Type | Description |
---|---|---|
uri | string | A string representing the url. |
- Source
A URL object (full or simple depending upon platform). WANRING: returns an official URL or a simple URL depending on platform, see https://caniuse.com/#feat=url
- Type:
- URL
(static) getUrlFromUriFull(uri) → {URL}
Get an full object URL from a string uri.
Name | Type | Description |
---|---|---|
uri | string | A string representing the url. |
- Source
A URL object. WARNING: platform support dependent, see https://caniuse.com/#feat=url
- Type:
- URL
(static) getUrlFromUriSimple(uri) → {URL}
Get an simple object URL from a string uri.
Name | Type | Description |
---|---|---|
uri | string | A string representing the url. |
- Source
A simple URL object that exposes 'pathname' and 'searchParams.get()' WARNING: limited functionality, simple nmock of the URL object.
- Type:
- URL
(static) hexToRgb(hexStr) → {object}
Convert a hex color into RGB.
Name | Type | Description |
---|---|---|
hexStr | string | The hex color as '#ab01ef'. |
- Source
The RGB values as {r,g,b}.
- Type:
- object
(static) isArray(unknown) → {boolean}
Check if the input is an array.
Name | Type | Description |
---|---|---|
unknown | * | The input to check. |
- Source
True if the input is an array. ref: https://github.com/jashkenas/underscore/blob/1.9.1/underscore.js#L1313-L1317
- Type:
- boolean
(static) isDarkColour(hexColour) → {boolean}
Check if a colour given in hexadecimal format is dark.
Name | Type | Description |
---|---|---|
hexColour | string | The colour (as '#ab01ef'). |
- Source
True if the colour is dark (brightness < 0.5).
- Type:
- boolean
(static) isEqualRgb(c1, c2) → {boolean}
Check if two rgb objects are equal.
Name | Type | Description |
---|---|---|
c1 | object | The first colour. |
c2 | object | The second colour. |
- Source
True if both colour are equal.
- Type:
- boolean
(static) isObject(unknown) → {boolean}
Check if the input is a generic object, including arrays.
Name | Type | Description |
---|---|---|
unknown | * | The input to check. |
- Source
True if the input is an object. ref: https://github.com/jashkenas/underscore/blob/1.9.1/underscore.js#L1319-L1323
- Type:
- boolean
(static) labToUintLab(triplet) → {object}
CIE LAB value (L: [0, 100], a: [-128, 127], b: [-128, 127]) to unsigned int CIE LAB ([0, 65535]).
Name | Type | Description |
---|---|---|
triplet | object | CIE XYZ triplet as {x,y,z} with CIE LAB range. |
- Source
CIE LAB triplet as {l,a,b} with unsigned range.
- Type:
- object
(static) loadFromQuery(query, app, options)
Load from an input query
Name | Type | Description |
---|---|---|
query | object | A query derived from an uri. |
app | object | The associated app that handles the load. |
options | object | Optional url request options. |
- Source
(static) loadFromUri(uri, app, options)
Load from an input uri
Name | Type | Description |
---|---|---|
uri | string | The input uri, for example: 'window.location.href'. |
app | dwv. | The associated app that handles the load. |
options | object | Optional url request options. |
- Source
(static) mergeObjects(obj1, obj2, idKey, valueKey) → {object}
Merge two similar objects. Objects need to be in the form of: { idKey: {valueKey: 0}, key0: {valueKey: "abc"}, key1: {valueKey: 33} }
Merged objects will be in the form of: { idKey: {valueKey: [0,1,2], merged: true}, key0: {valueKey: { 0: {valueKey: "abc"}, 1: {valueKey: "def"}, 2: {valueKey: "ghi"} }}, key1: {valueKey: { 0: {valueKey: 33}, 1: {valueKey: 44}, 2: {valueKey: 55} }} }
Name | Type | Description |
---|---|---|
obj1 | object | The first object, can be the result of a previous merge. |
obj2 | object | The second object. |
idKey | string | The key to use as index for duplicate values. |
valueKey | string | The key to use to access object values. |
- Source
The merged object.
- Type:
- object
(static) objectToArray(obj) → {Array}
Dump an object to an array.
Name | Type | Description |
---|---|---|
obj | object | The input object as: {key0: {}, key1: {}} |
- Source
The corresponding array: [{name: key0, {}}, {name: key1, {}}]
- Type:
- Array
(static) parseMultipart(arr) → {Array}
Extract each element of a multipart ArrayBuffer. https://en.wikipedia.org/wiki/MIME#Multipart_messages
Name | Type | Description |
---|---|---|
arr | ArrayBuffer | The multipart array. |
- Source
The multipart parts as an array of object as {'Content-Type', ..., data} (depending on header tags)
- Type:
- Array
(static) precisionRound(number, precision) → {number}
Round a float number to a given precision. Inspired from https://stackoverflow.com/a/49729715/3639892. Can be a solution to not have trailing zero as when using toFixed or toPrecision. '+number.toFixed(precision)' does not pass all the tests...
Name | Type | Description |
---|---|---|
number | number | The number to round. |
precision | number | The rounding precision. |
- Source
The rounded number.
- Type:
- number
(static) replaceFlags(inputStr, values) → {string}
Replace flags in a input string. Flags are keywords surrounded with curly braces.
Name | Type | Description |
---|---|---|
inputStr | string | The input string. |
values | object | A object of {value, unit}. |
- Source
The result string.
- Type:
- string
var values = {"length": { "value": 33, "unit": "cm" } };
var str = "The length is: {length}.";
var res = dwv.utils.replaceFlags(str, values); // "The length is: 33 cm."
(static) replaceFlags2(inputStr, values) → {string}
Replace flags in a input string. Flags are keywords surrounded with curly braces.
Name | Type | Description |
---|---|---|
inputStr | string | The input string. |
values | Array | An array of strings. |
- Source
The result string.
- Type:
- string
var values = ["a", "b"];
var str = "The length is: {v0}. The size is: {v1}";
var res = dwv.utils.replaceFlags2(str, values);
// "The length is: a. The size is: b"
(static) rgbToHex(rgb) → {string}
Convert RGB to its hex equivalent.
Name | Type | Description |
---|---|---|
rgb | object | The RGB object as {r,g,b}. |
- Source
A string representing the hex color as '#ab01ef'.
- Type:
- string
(static) splitKeyValueString(inputStr) → {object}
Split key/value string: key0=val00&key0=val01&key1=val10 returns { key0 : [val00, val01], key1 : val1 }
Name | Type | Description |
---|---|---|
inputStr | string | The string to split. |
- Source
The split string.
- Type:
- object
(static) splitUri(uri) → {object}
Split an input URI: 'root?key0=val00&key0=val01&key1=val10' returns { base : root, query : [ key0 : [val00, val01], key1 : val1 ] } Returns an empty object if the input string is not correct (null, empty...) or if it is not a query string (no question mark).
Name | Type | Description |
---|---|---|
uri | string | The string to split. |
- Source
The split string.
- Type:
- object
(static) srgbToCielab(triplet) → {object}
Convert sRGB to CIE LAB (standard illuminant D65).
Name | Type | Description |
---|---|---|
triplet | object | sRGB triplet as {r,g,b}. |
- Source
CIE LAB triplet as {l,a,b}.
- Type:
- object
(static) srgbToCiexyz(triplet) → {object}
Convert sRGB to CIE XYZ.
Name | Type | Description |
---|---|---|
triplet | object | sRGB triplet as {r,g,b}. |
- Source
CIE XYZ triplet as {x,y,z}.
- Type:
- object
(static) startsWith(str, search, rawPos) → {boolean}
Check if a string starts with the input element.
Name | Type | Description |
---|---|---|
str | string | The input string. |
search | string | The searched start. |
rawPos | number | The position in this string at which to begin searching for searchString. Defaults to 0. |
- Source
True if the input string starts with the searched string.
- Type:
- boolean
(static) stringToUint8Array(str) → {Uint8Array}
Convert a string to a Uint8Array.
Name | Type | Description |
---|---|---|
str | string | The string to convert. |
- Source
The Uint8Array.
- Type:
- Uint8Array
(static) uint8ArrayToString(arr) → {string}
Convert a Uint8Array to a string.
Name | Type | Description |
---|---|---|
arr | Uint8Array | The array to convert. |
- Source
The array as string.
- Type:
- string
(static) uintLabToLab(triplet) → {object}
Unsigned int CIE LAB value ([0, 65535]) to CIE LAB value (L: [0, 100], a: [-128, 127], b: [-128, 127]).
Name | Type | Description |
---|---|---|
triplet | object | CIE LAB triplet as {l,a,b} with unsigned range. |
- Source
CIE LAB triplet as {l,a,b} with CIE LAB range.
- Type:
- object
(static) ybrToRgb(y, cb, cr) → {object}
Convert YBR to RGB.
Name | Type | Description |
---|---|---|
y | number | The Y component. |
cb | number | The Cb component. |
cr | number | The Cr component. |
- Source
RGB equivalent as {r,g,b}.
- Type:
- object