@vitessce/utils 3.3.3 → 3.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  export declare const DEFAULT_DARK_COLOR: number[];
2
2
  export declare const DEFAULT_LIGHT_COLOR: number[];
3
- export declare function getDefaultColor(theme: 'dark' | 'light'): number[];
3
+ export declare function getDefaultColor(theme: 'dark' | 'light' | 'light2'): number[];
4
4
  export declare const PALETTE: number[][];
5
5
  export declare const VIEWER_PALETTE: number[][];
6
6
  export declare const PATHOLOGY_PALETTE: number[][];
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,kBAAkB,UAAe,CAAC;AAC/C,eAAO,MAAM,mBAAmB,UAAkB,CAAC;AAEnD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,YAEtD;AAGD,eAAO,MAAM,OAAO,YAUnB,CAAC;AAEF,eAAO,MAAM,cAAc,YAS1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAS7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,YAiBnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAW5B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;CAAmB,CAAC;AAEnD,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,aAC5C,MAAM,UACxB;AAED,wBAAgB,iCAAiC,CAAC,aAAa,EAAE,MAAM,oBAC7C,GAAG,UAC5B;AAED,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,MAAM,eAC9C;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,UACtC;AAED,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,MAAM,eAC9C;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,UACtC;AAED,wBAAgB,8BAA8B,CAAC,aAAa,EAAE,MAAM,eAC/C,GAAG,UACvB;AAED,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GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,cAK7C;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,GAAG;;;EAKxC;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,UAWtD"}
@@ -1,6 +1,5 @@
1
- export { fromEntries, commaNumber, capitalize, pluralize, getLongestString, getNextScope, getNextScopeNumeric, createPrefixedGetNextScopeNumeric, getInitialCoordinationScopePrefix, getInitialCoordinationScopeName, } from './root.js';
1
+ export { commaNumber, capitalize, pluralize, getLongestString, getNextScope, getNextScopeNumeric, createPrefixedGetNextScopeNumeric, getInitialCoordinationScopePrefix, getInitialCoordinationScopeName, } from './root.js';
2
2
  export { DEFAULT_DARK_COLOR, DEFAULT_LIGHT_COLOR, getDefaultColor, PALETTE, VIEWER_PALETTE, PATHOLOGY_PALETTE, LARGE_PATHOLOGY_PALETTE, COLORMAP_OPTIONS, DEFAULT_GL_OPTIONS, createDefaultUpdateStatus, createDefaultUpdateCellsSelection, createDefaultUpdateCellsHover, createDefaultUpdateGenesHover, createDefaultUpdateTracksHover, createDefaultUpdateViewInfo, createDefaultClearPleaseWait, copyUint8Array, asEsModule, formatBytes, } from './components.js';
3
3
  export { getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from './gating.js';
4
- export { getCellColors, } from './interpolate-colors.js';
5
4
  export { default as Pool } from './Pool.js';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,cAAc,EACd,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,cAAc,EACd,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC"}
package/dist-tsc/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // eslint-disable-next-line react-refresh/only-export-components
2
- export { fromEntries, commaNumber, capitalize, pluralize, getLongestString, getNextScope, getNextScopeNumeric, createPrefixedGetNextScopeNumeric, getInitialCoordinationScopePrefix, getInitialCoordinationScopeName, } from './root.js';
2
+ export { commaNumber, capitalize, pluralize, getLongestString, getNextScope, getNextScopeNumeric, createPrefixedGetNextScopeNumeric, getInitialCoordinationScopePrefix, getInitialCoordinationScopeName, } from './root.js';
3
3
  // eslint-disable-next-line react-refresh/only-export-components
4
4
  export { DEFAULT_DARK_COLOR, DEFAULT_LIGHT_COLOR, getDefaultColor, PALETTE, VIEWER_PALETTE, PATHOLOGY_PALETTE, LARGE_PATHOLOGY_PALETTE, COLORMAP_OPTIONS, DEFAULT_GL_OPTIONS, createDefaultUpdateStatus, createDefaultUpdateCellsSelection, createDefaultUpdateCellsHover, createDefaultUpdateGenesHover, createDefaultUpdateTracksHover, createDefaultUpdateViewInfo, createDefaultClearPleaseWait, copyUint8Array, asEsModule, formatBytes, } from './components.js';
5
5
  export { getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from './gating.js';
6
- export { getCellColors, } from './interpolate-colors.js';
7
6
  export { default as Pool } from './Pool.js';
@@ -1,6 +1,3 @@
1
- export declare function fromEntries(iterable: [string, any][]): {
2
- [key: string]: any;
3
- };
4
1
  export declare function commaNumber(n: number): string;
5
2
  /**
6
3
  * Capitalize a the first letter of a string.
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAQA,wBAAgB,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAG7E;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,UAGpC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,UAE7C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,IAAW,OAElE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE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CAC7C,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAE,MAAM,GAAG,IAAW,UAI9D"}
package/dist-tsc/root.js CHANGED
@@ -3,11 +3,6 @@
3
3
  import plur from 'pluralize';
4
4
  plur.addPluralRule('glomerulus', 'glomeruli');
5
5
  plur.addPluralRule('interstitium', 'interstitia');
6
- // Adapted from https://github.com/feross/fromentries/blob/29b52a850bb3a47c390937631c2638edf3443942/index.js
7
- export function fromEntries(iterable) {
8
- return [...iterable]
9
- .reduce((obj, { 0: key, 1: val }) => Object.assign(obj, { [key]: val }), {});
10
- }
11
6
  export function commaNumber(n) {
12
7
  const nf = new Intl.NumberFormat('en-US');
13
8
  return nf.format(n);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/utils",
3
- "version": "3.3.3",
3
+ "version": "3.3.5",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -19,8 +19,7 @@
19
19
  "bowser": "^2.11.0",
20
20
  "lodash-es": "^4.17.21",
21
21
  "lz-string": "^1.4.4",
22
- "pluralize": "^8.0.0",
23
- "@vitessce/sets-utils": "3.3.3"
22
+ "pluralize": "^8.0.0"
24
23
  },
25
24
  "scripts": {
26
25
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
package/src/components.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  export const DEFAULT_DARK_COLOR = [50, 50, 50];
3
3
  export const DEFAULT_LIGHT_COLOR = [200, 200, 200];
4
4
 
5
- export function getDefaultColor(theme: 'dark' | 'light') {
5
+ export function getDefaultColor(theme: 'dark' | 'light' | 'light2') {
6
6
  return theme === 'dark' ? DEFAULT_DARK_COLOR : DEFAULT_LIGHT_COLOR;
7
7
  }
8
8
 
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  // eslint-disable-next-line react-refresh/only-export-components
2
2
  export {
3
- fromEntries,
4
3
  commaNumber,
5
4
  capitalize,
6
5
  pluralize,
@@ -37,7 +36,4 @@ export {
37
36
  getValueTransformFunction,
38
37
  VALUE_TRANSFORM_OPTIONS,
39
38
  } from './gating.js';
40
- export {
41
- getCellColors,
42
- } from './interpolate-colors.js';
43
39
  export { default as Pool } from './Pool.js';
package/src/root.ts CHANGED
@@ -5,12 +5,6 @@ import plur from 'pluralize';
5
5
  plur.addPluralRule('glomerulus', 'glomeruli');
6
6
  plur.addPluralRule('interstitium', 'interstitia');
7
7
 
8
- // Adapted from https://github.com/feross/fromentries/blob/29b52a850bb3a47c390937631c2638edf3443942/index.js
9
- export function fromEntries(iterable: [string, any][]): { [key: string]: any } {
10
- return [...iterable]
11
- .reduce((obj, { 0: key, 1: val }) => Object.assign(obj, { [key]: val }), {});
12
- }
13
-
14
8
  export function commaNumber(n: number) {
15
9
  const nf = new Intl.NumberFormat('en-US');
16
10
  return nf.format(n);
@@ -1,28 +0,0 @@
1
- export declare const interpolateRdBu: (t: number) => number[];
2
- export declare const interpolatePlasma: (t: number) => number[];
3
- declare type GetCellColorsParams = {
4
- cellSetSelection: string[][] | null;
5
- cellSetColor: {
6
- path: string[];
7
- color: [number, number, number];
8
- }[] | null;
9
- cellSets: object;
10
- obsIndex: string[] | null;
11
- theme: 'light' | 'dark' | null;
12
- };
13
- /**
14
- * Get a mapping of cell IDs to cell colors based on
15
- * gene / cell set selection coordination state.
16
- * @param {object} params
17
- * @param {array[]} params.cellSetSelection Selected cell sets.
18
- * @param {object[]} params.cellSetColor Array of cell set color
19
- * objects, each containing a path and color [r, g, b].
20
- * @param {string[]} params.obsIndex Array of cell IDs,
21
- * in order to initialize all cells to the default color.
22
- * @param {string} params.theme The current theme,
23
- * in order to get the theme-based default color.
24
- * @returns {Map} Mapping from cell IDs to [r, g, b] color arrays.
25
- */
26
- export declare function getCellColors(params: GetCellColorsParams): Map<string, number[]>;
27
- export {};
28
- //# sourceMappingURL=interpolate-colors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interpolate-colors.d.ts","sourceRoot":"","sources":["../src/interpolate-colors.ts"],"names":[],"mappings":"AAuEA,eAAO,MAAM,eAAe,MAnCb,MAAM,aAmCyC,CAAC;AAC/D,eAAO,MAAM,iBAAiB,MAJjB,MAAM,aAIsD,CAAC;AAE1E,aAAK,mBAAmB,GAAG;IACzB,gBAAgB,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC;IACpC,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,EAAE,GAAG,IAAI,CAAC;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;CAChC,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAkBhF"}
@@ -1,88 +0,0 @@
1
- /* eslint-disable no-nested-ternary */
2
- /* eslint-disable no-param-reassign */
3
- import { treeToCellColorsBySetNames } from '@vitessce/sets-utils';
4
- import { getDefaultColor } from './components.js';
5
- // The functions defined here have been adapted from d3-interpolate,
6
- // d3-color, and d3-scale-chromatic.
7
- // Color string "rgb(r,g,b)" representations are replaced by color array [r, g, b]
8
- // representations, to allow them to work nicely with deck.gl,
9
- // without the need to converting back and forth between string and array formats.
10
- // Reference: https://github.com/d3/d3-scale-chromatic/blob/431d21da776f97c632f53a855bd822edfbbcd56e/src/diverging/RdBu.js
11
- // eslint-disable-next-line max-len
12
- const schemeRdBu = [[103, 0, 31], [178, 24, 43], [214, 96, 77], [244, 165, 130], [253, 219, 199], [247, 247, 247], [209, 229, 240], [146, 197, 222], [67, 147, 195], [33, 102, 172], [5, 48, 97]];
13
- // eslint-disable-next-line max-len
14
- const schemePlasma = [[13, 8, 135], [16, 7, 136], [19, 7, 137], [22, 7, 138], [25, 6, 140], [27, 6, 141], [29, 6, 142], [32, 6, 143], [34, 6, 144], [36, 6, 145], [38, 5, 145], [40, 5, 146], [42, 5, 147], [44, 5, 148], [46, 5, 149], [47, 5, 150], [49, 5, 151], [51, 5, 151], [53, 4, 152], [55, 4, 153], [56, 4, 154], [58, 4, 154], [60, 4, 155], [62, 4, 156], [63, 4, 156], [65, 4, 157], [67, 3, 158], [68, 3, 158], [70, 3, 159], [72, 3, 159], [73, 3, 160], [75, 3, 161], [76, 2, 161], [78, 2, 162], [80, 2, 162], [81, 2, 163], [83, 2, 163], [85, 2, 164], [86, 1, 164], [88, 1, 164], [89, 1, 165], [91, 1, 165], [92, 1, 166], [94, 1, 166], [96, 1, 166], [97, 0, 167], [99, 0, 167], [100, 0, 167], [102, 0, 167], [103, 0, 168], [105, 0, 168], [106, 0, 168], [108, 0, 168], [110, 0, 168], [111, 0, 168], [113, 0, 168], [114, 1, 168], [116, 1, 168], [117, 1, 168], [119, 1, 168], [120, 1, 168], [122, 2, 168], [123, 2, 168], [125, 3, 168], [126, 3, 168], [128, 4, 168], [129, 4, 167], [131, 5, 167], [132, 5, 167], [134, 6, 166], [135, 7, 166], [136, 8, 166], [138, 9, 165], [139, 10, 165], [141, 11, 165], [142, 12, 164], [143, 13, 164], [145, 14, 163], [146, 15, 163], [148, 16, 162], [149, 17, 161], [150, 19, 161], [152, 20, 160], [153, 21, 159], [154, 22, 159], [156, 23, 158], [157, 24, 157], [158, 25, 157], [160, 26, 156], [161, 27, 155], [162, 29, 154], [163, 30, 154], [165, 31, 153], [166, 32, 152], [167, 33, 151], [168, 34, 150], [170, 35, 149], [171, 36, 148], [172, 38, 148], [173, 39, 147], [174, 40, 146], [176, 41, 145], [177, 42, 144], [178, 43, 143], [179, 44, 142], [180, 46, 141], [181, 47, 140], [182, 48, 139], [183, 49, 138], [184, 50, 137], [186, 51, 136], [187, 52, 136], [188, 53, 135], [189, 55, 134], [190, 56, 133], [191, 57, 132], [192, 58, 131], [193, 59, 130], [194, 60, 129], [195, 61, 128], [196, 62, 127], [197, 64, 126], [198, 65, 125], [199, 66, 124], [200, 67, 123], [201, 68, 122], [202, 69, 122], [203, 70, 121], [204, 71, 120], [204, 73, 119], [205, 74, 118], [206, 75, 117], [207, 76, 116], [208, 77, 115], [209, 78, 114], [210, 79, 113], [211, 81, 113], [212, 82, 112], [213, 83, 111], [213, 84, 110], [214, 85, 109], [215, 86, 108], [216, 87, 107], [217, 88, 106], [218, 90, 106], [218, 91, 105], [219, 92, 104], [220, 93, 103], [221, 94, 102], [222, 95, 101], [222, 97, 100], [223, 98, 99], [224, 99, 99], [225, 100, 98], [226, 101, 97], [226, 102, 96], [227, 104, 95], [228, 105, 94], [229, 106, 93], [229, 107, 93], [230, 108, 92], [231, 110, 91], [231, 111, 90], [232, 112, 89], [233, 113, 88], [233, 114, 87], [234, 116, 87], [235, 117, 86], [235, 118, 85], [236, 119, 84], [237, 121, 83], [237, 122, 82], [238, 123, 81], [239, 124, 81], [239, 126, 80], [240, 127, 79], [240, 128, 78], [241, 129, 77], [241, 131, 76], [242, 132, 75], [243, 133, 75], [243, 135, 74], [244, 136, 73], [244, 137, 72], [245, 139, 71], [245, 140, 70], [246, 141, 69], [246, 143, 68], [247, 144, 68], [247, 145, 67], [247, 147, 66], [248, 148, 65], [248, 149, 64], [249, 151, 63], [249, 152, 62], [249, 154, 62], [250, 155, 61], [250, 156, 60], [250, 158, 59], [251, 159, 58], [251, 161, 57], [251, 162, 56], [252, 163, 56], [252, 165, 55], [252, 166, 54], [252, 168, 53], [252, 169, 52], [253, 171, 51], [253, 172, 51], [253, 174, 50], [253, 175, 49], [253, 177, 48], [253, 178, 47], [253, 180, 47], [253, 181, 46], [254, 183, 45], [254, 184, 44], [254, 186, 44], [254, 187, 43], [254, 189, 42], [254, 190, 42], [254, 192, 41], [253, 194, 41], [253, 195, 40], [253, 197, 39], [253, 198, 39], [253, 200, 39], [253, 202, 38], [253, 203, 38], [252, 205, 37], [252, 206, 37], [252, 208, 37], [252, 210, 37], [251, 211, 36], [251, 213, 36], [251, 215, 36], [250, 216, 36], [250, 218, 36], [249, 220, 36], [249, 221, 37], [248, 223, 37], [248, 225, 37], [247, 226, 37], [247, 228, 37], [246, 230, 38], [246, 232, 38], [245, 233, 38], [245, 235, 39], [244, 237, 39], [243, 238, 39], [243, 240, 39], [242, 242, 39], [241, 244, 38], [241, 245, 37], [240, 247, 36], [240, 249, 33]];
15
- // Reference: https://github.com/d3/d3-interpolate/blob/96d54051d1c2fec55f240edd0ec5401715b10390/src/rgb.js
16
- function rgbSpline(spline) {
17
- return (colors) => {
18
- const n = colors.length;
19
- const r = new Array(n);
20
- const g = new Array(n);
21
- const b = new Array(n);
22
- let i;
23
- let color;
24
- // eslint-disable-next-line no-plusplus
25
- for (i = 0; i < n; ++i) {
26
- color = [colors[i][0], colors[i][1], colors[i][2]];
27
- r[i] = color[0] || 0;
28
- g[i] = color[1] || 0;
29
- b[i] = color[2] || 0;
30
- }
31
- const rFunc = spline(r);
32
- const gFunc = spline(g);
33
- const bFunc = spline(b);
34
- return (t) => [rFunc(t), gFunc(t), bFunc(t)];
35
- };
36
- }
37
- // Reference: https://github.com/d3/d3-interpolate/blob/594a32af1fe1118812b439012c2cb742e907c0c0/src/basis.js
38
- function basis(values) {
39
- function innerBasis(t1, v0, v1, v2, v3) {
40
- const t2 = t1 * t1;
41
- const t3 = t2 * t1;
42
- return ((1 - 3 * t1 + 3 * t2 - t3) * v0
43
- + (4 - 6 * t2 + 3 * t3) * v1
44
- + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2
45
- + t3 * v3) / 6;
46
- }
47
- const n = values.length - 1;
48
- return (t) => {
49
- const i = t <= 0 ? (t = 0) : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n);
50
- const v1 = values[i];
51
- const v2 = values[i + 1];
52
- const v0 = i > 0 ? values[i - 1] : 2 * v1 - v2;
53
- const v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
54
- return innerBasis((t - i / n) * n, v0, v1, v2, v3);
55
- };
56
- }
57
- // Reference: https://github.com/d3/d3-scale-chromatic/blob/ade54c13e8dfdb9807801a794eaec1a37f926b8a/src/ramp.js
58
- const interpolateRgbBasis = rgbSpline(basis);
59
- function interpolateSequentialMulti(range) {
60
- const n = range.length;
61
- return (t) => range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
62
- }
63
- export const interpolateRdBu = interpolateRgbBasis(schemeRdBu);
64
- export const interpolatePlasma = interpolateSequentialMulti(schemePlasma);
65
- /**
66
- * Get a mapping of cell IDs to cell colors based on
67
- * gene / cell set selection coordination state.
68
- * @param {object} params
69
- * @param {array[]} params.cellSetSelection Selected cell sets.
70
- * @param {object[]} params.cellSetColor Array of cell set color
71
- * objects, each containing a path and color [r, g, b].
72
- * @param {string[]} params.obsIndex Array of cell IDs,
73
- * in order to initialize all cells to the default color.
74
- * @param {string} params.theme The current theme,
75
- * in order to get the theme-based default color.
76
- * @returns {Map} Mapping from cell IDs to [r, g, b] color arrays.
77
- */
78
- export function getCellColors(params) {
79
- const { cellSets, cellSetSelection, cellSetColor, obsIndex, theme, } = params;
80
- if (cellSetSelection && cellSets) {
81
- // TODO(ts): fix typing here once better typing in sets-utils.
82
- return treeToCellColorsBySetNames(cellSets, cellSetSelection, cellSetColor, theme);
83
- }
84
- if (obsIndex && theme) {
85
- return new Map(obsIndex.map(o => ([o, getDefaultColor(theme)])));
86
- }
87
- return new Map();
88
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=interpolate-colors.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interpolate-colors.test.d.ts","sourceRoot":"","sources":["../src/interpolate-colors.test.ts"],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { interpolateRdBu, interpolatePlasma } from './interpolate-colors.js';
3
- const expectRgb = ([testR, testG, testB], [r, g, b]) => ([
4
- expect(testR).toBeCloseTo(r),
5
- expect(testG).toBeCloseTo(g),
6
- expect(testB).toBeCloseTo(b),
7
- ]);
8
- describe('components/interpolate-colors', () => {
9
- describe('interpolateRdBu()', () => {
10
- it('maps 0 to a red color', () => {
11
- expectRgb(interpolateRdBu(0), [103, 0, 31]);
12
- });
13
- it('maps 1 to a blue color', () => {
14
- expectRgb(interpolateRdBu(1), [5, 48, 97]);
15
- });
16
- });
17
- describe('interpolatePlasma()', () => {
18
- it('maps 0 to dark cool color', () => {
19
- expectRgb(interpolatePlasma(0), [13, 8, 135]);
20
- });
21
- it('maps 1 to bright warm color', () => {
22
- expectRgb(interpolatePlasma(1), [240, 249, 33]);
23
- });
24
- });
25
- });
@@ -1,30 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { interpolateRdBu, interpolatePlasma } from './interpolate-colors.js';
3
-
4
- const expectRgb = ([testR, testG, testB]: number[], [r, g, b]: number[]) => ([
5
- expect(testR).toBeCloseTo(r),
6
- expect(testG).toBeCloseTo(g),
7
- expect(testB).toBeCloseTo(b),
8
- ]);
9
-
10
- describe('components/interpolate-colors', () => {
11
- describe('interpolateRdBu()', () => {
12
- it('maps 0 to a red color', () => {
13
- expectRgb(interpolateRdBu(0), [103, 0, 31]);
14
- });
15
-
16
- it('maps 1 to a blue color', () => {
17
- expectRgb(interpolateRdBu(1), [5, 48, 97]);
18
- });
19
- });
20
-
21
- describe('interpolatePlasma()', () => {
22
- it('maps 0 to dark cool color', () => {
23
- expectRgb(interpolatePlasma(0), [13, 8, 135]);
24
- });
25
-
26
- it('maps 1 to bright warm color', () => {
27
- expectRgb(interpolatePlasma(1), [240, 249, 33]);
28
- });
29
- });
30
- });
@@ -1,114 +0,0 @@
1
- /* eslint-disable no-nested-ternary */
2
- /* eslint-disable no-param-reassign */
3
- import { treeToCellColorsBySetNames } from '@vitessce/sets-utils';
4
- import { getDefaultColor } from './components.js';
5
-
6
- // The functions defined here have been adapted from d3-interpolate,
7
- // d3-color, and d3-scale-chromatic.
8
- // Color string "rgb(r,g,b)" representations are replaced by color array [r, g, b]
9
- // representations, to allow them to work nicely with deck.gl,
10
- // without the need to converting back and forth between string and array formats.
11
-
12
- // Reference: https://github.com/d3/d3-scale-chromatic/blob/431d21da776f97c632f53a855bd822edfbbcd56e/src/diverging/RdBu.js
13
- // eslint-disable-next-line max-len
14
- const schemeRdBu = [[103, 0, 31], [178, 24, 43], [214, 96, 77], [244, 165, 130], [253, 219, 199], [247, 247, 247], [209, 229, 240], [146, 197, 222], [67, 147, 195], [33, 102, 172], [5, 48, 97]];
15
- // eslint-disable-next-line max-len
16
- const schemePlasma = [[13, 8, 135], [16, 7, 136], [19, 7, 137], [22, 7, 138], [25, 6, 140], [27, 6, 141], [29, 6, 142], [32, 6, 143], [34, 6, 144], [36, 6, 145], [38, 5, 145], [40, 5, 146], [42, 5, 147], [44, 5, 148], [46, 5, 149], [47, 5, 150], [49, 5, 151], [51, 5, 151], [53, 4, 152], [55, 4, 153], [56, 4, 154], [58, 4, 154], [60, 4, 155], [62, 4, 156], [63, 4, 156], [65, 4, 157], [67, 3, 158], [68, 3, 158], [70, 3, 159], [72, 3, 159], [73, 3, 160], [75, 3, 161], [76, 2, 161], [78, 2, 162], [80, 2, 162], [81, 2, 163], [83, 2, 163], [85, 2, 164], [86, 1, 164], [88, 1, 164], [89, 1, 165], [91, 1, 165], [92, 1, 166], [94, 1, 166], [96, 1, 166], [97, 0, 167], [99, 0, 167], [100, 0, 167], [102, 0, 167], [103, 0, 168], [105, 0, 168], [106, 0, 168], [108, 0, 168], [110, 0, 168], [111, 0, 168], [113, 0, 168], [114, 1, 168], [116, 1, 168], [117, 1, 168], [119, 1, 168], [120, 1, 168], [122, 2, 168], [123, 2, 168], [125, 3, 168], [126, 3, 168], [128, 4, 168], [129, 4, 167], [131, 5, 167], [132, 5, 167], [134, 6, 166], [135, 7, 166], [136, 8, 166], [138, 9, 165], [139, 10, 165], [141, 11, 165], [142, 12, 164], [143, 13, 164], [145, 14, 163], [146, 15, 163], [148, 16, 162], [149, 17, 161], [150, 19, 161], [152, 20, 160], [153, 21, 159], [154, 22, 159], [156, 23, 158], [157, 24, 157], [158, 25, 157], [160, 26, 156], [161, 27, 155], [162, 29, 154], [163, 30, 154], [165, 31, 153], [166, 32, 152], [167, 33, 151], [168, 34, 150], [170, 35, 149], [171, 36, 148], [172, 38, 148], [173, 39, 147], [174, 40, 146], [176, 41, 145], [177, 42, 144], [178, 43, 143], [179, 44, 142], [180, 46, 141], [181, 47, 140], [182, 48, 139], [183, 49, 138], [184, 50, 137], [186, 51, 136], [187, 52, 136], [188, 53, 135], [189, 55, 134], [190, 56, 133], [191, 57, 132], [192, 58, 131], [193, 59, 130], [194, 60, 129], [195, 61, 128], [196, 62, 127], [197, 64, 126], [198, 65, 125], [199, 66, 124], [200, 67, 123], [201, 68, 122], [202, 69, 122], [203, 70, 121], [204, 71, 120], [204, 73, 119], [205, 74, 118], [206, 75, 117], [207, 76, 116], [208, 77, 115], [209, 78, 114], [210, 79, 113], [211, 81, 113], [212, 82, 112], [213, 83, 111], [213, 84, 110], [214, 85, 109], [215, 86, 108], [216, 87, 107], [217, 88, 106], [218, 90, 106], [218, 91, 105], [219, 92, 104], [220, 93, 103], [221, 94, 102], [222, 95, 101], [222, 97, 100], [223, 98, 99], [224, 99, 99], [225, 100, 98], [226, 101, 97], [226, 102, 96], [227, 104, 95], [228, 105, 94], [229, 106, 93], [229, 107, 93], [230, 108, 92], [231, 110, 91], [231, 111, 90], [232, 112, 89], [233, 113, 88], [233, 114, 87], [234, 116, 87], [235, 117, 86], [235, 118, 85], [236, 119, 84], [237, 121, 83], [237, 122, 82], [238, 123, 81], [239, 124, 81], [239, 126, 80], [240, 127, 79], [240, 128, 78], [241, 129, 77], [241, 131, 76], [242, 132, 75], [243, 133, 75], [243, 135, 74], [244, 136, 73], [244, 137, 72], [245, 139, 71], [245, 140, 70], [246, 141, 69], [246, 143, 68], [247, 144, 68], [247, 145, 67], [247, 147, 66], [248, 148, 65], [248, 149, 64], [249, 151, 63], [249, 152, 62], [249, 154, 62], [250, 155, 61], [250, 156, 60], [250, 158, 59], [251, 159, 58], [251, 161, 57], [251, 162, 56], [252, 163, 56], [252, 165, 55], [252, 166, 54], [252, 168, 53], [252, 169, 52], [253, 171, 51], [253, 172, 51], [253, 174, 50], [253, 175, 49], [253, 177, 48], [253, 178, 47], [253, 180, 47], [253, 181, 46], [254, 183, 45], [254, 184, 44], [254, 186, 44], [254, 187, 43], [254, 189, 42], [254, 190, 42], [254, 192, 41], [253, 194, 41], [253, 195, 40], [253, 197, 39], [253, 198, 39], [253, 200, 39], [253, 202, 38], [253, 203, 38], [252, 205, 37], [252, 206, 37], [252, 208, 37], [252, 210, 37], [251, 211, 36], [251, 213, 36], [251, 215, 36], [250, 216, 36], [250, 218, 36], [249, 220, 36], [249, 221, 37], [248, 223, 37], [248, 225, 37], [247, 226, 37], [247, 228, 37], [246, 230, 38], [246, 232, 38], [245, 233, 38], [245, 235, 39], [244, 237, 39], [243, 238, 39], [243, 240, 39], [242, 242, 39], [241, 244, 38], [241, 245, 37], [240, 247, 36], [240, 249, 33]];
17
-
18
- // Reference: https://github.com/d3/d3-interpolate/blob/96d54051d1c2fec55f240edd0ec5401715b10390/src/rgb.js
19
- function rgbSpline(spline: (values: number[]) => ((t: number) => number)) {
20
- return (colors: number[][]) => {
21
- const n = colors.length;
22
- const r: number[] = new Array(n);
23
- const g: number[] = new Array(n);
24
- const b: number[] = new Array(n);
25
- let i; let
26
- color;
27
- // eslint-disable-next-line no-plusplus
28
- for (i = 0; i < n; ++i) {
29
- color = [colors[i][0], colors[i][1], colors[i][2]];
30
- r[i] = color[0] || 0;
31
- g[i] = color[1] || 0;
32
- b[i] = color[2] || 0;
33
- }
34
- const rFunc: (t: number) => number = spline(r);
35
- const gFunc: (t: number) => number = spline(g);
36
- const bFunc: (t: number) => number = spline(b);
37
- return (t: number) => [rFunc(t), gFunc(t), bFunc(t)];
38
- };
39
- }
40
-
41
- // Reference: https://github.com/d3/d3-interpolate/blob/594a32af1fe1118812b439012c2cb742e907c0c0/src/basis.js
42
- function basis(values: number[]) {
43
- function innerBasis(t1: number, v0: number, v1: number, v2: number, v3: number) {
44
- const t2 = t1 * t1; const
45
- t3 = t2 * t1;
46
- return ((1 - 3 * t1 + 3 * t2 - t3) * v0
47
- + (4 - 6 * t2 + 3 * t3) * v1
48
- + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2
49
- + t3 * v3) / 6;
50
- }
51
-
52
- const n = values.length - 1;
53
- return (t: number) => {
54
- const i = t <= 0 ? (t = 0) : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n);
55
- const v1 = values[i];
56
- const v2 = values[i + 1];
57
- const v0 = i > 0 ? values[i - 1] : 2 * v1 - v2;
58
- const v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
59
- return innerBasis((t - i / n) * n, v0, v1, v2, v3);
60
- };
61
- }
62
-
63
-
64
- // Reference: https://github.com/d3/d3-scale-chromatic/blob/ade54c13e8dfdb9807801a794eaec1a37f926b8a/src/ramp.js
65
- const interpolateRgbBasis = rgbSpline(basis);
66
-
67
- function interpolateSequentialMulti(range: number[][]) {
68
- const n = range.length;
69
- return (t: number) => range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
70
- }
71
-
72
- export const interpolateRdBu = interpolateRgbBasis(schemeRdBu);
73
- export const interpolatePlasma = interpolateSequentialMulti(schemePlasma);
74
-
75
- type GetCellColorsParams = {
76
- cellSetSelection: string[][] | null;
77
- cellSetColor: { path: string[]; color: [number, number, number] }[] | null;
78
- cellSets: object; // TODO(ts): more strict typing here
79
- obsIndex: string[] | null;
80
- theme: 'light' | 'dark' | null;
81
- }
82
-
83
- /**
84
- * Get a mapping of cell IDs to cell colors based on
85
- * gene / cell set selection coordination state.
86
- * @param {object} params
87
- * @param {array[]} params.cellSetSelection Selected cell sets.
88
- * @param {object[]} params.cellSetColor Array of cell set color
89
- * objects, each containing a path and color [r, g, b].
90
- * @param {string[]} params.obsIndex Array of cell IDs,
91
- * in order to initialize all cells to the default color.
92
- * @param {string} params.theme The current theme,
93
- * in order to get the theme-based default color.
94
- * @returns {Map} Mapping from cell IDs to [r, g, b] color arrays.
95
- */
96
- export function getCellColors(params: GetCellColorsParams): Map<string, number[]> {
97
- const {
98
- cellSets,
99
- cellSetSelection,
100
- cellSetColor,
101
- obsIndex,
102
- theme,
103
- } = params;
104
- if (cellSetSelection && cellSets) {
105
- // TODO(ts): fix typing here once better typing in sets-utils.
106
- return treeToCellColorsBySetNames(
107
- cellSets, cellSetSelection, cellSetColor as object[], theme as string,
108
- );
109
- }
110
- if (obsIndex && theme) {
111
- return new Map(obsIndex.map(o => ([o, getDefaultColor(theme)])));
112
- }
113
- return new Map();
114
- }