@xivdyetools/core 2.6.0 → 4.0.1
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.
- package/README.md +85 -67
- package/dist/blending/blending.d.ts +22 -0
- package/dist/blending/blending.d.ts.map +1 -0
- package/dist/blending/blending.js +129 -0
- package/dist/blending/blending.js.map +1 -0
- package/dist/blending/conversions.d.ts +53 -0
- package/dist/blending/conversions.d.ts.map +1 -0
- package/dist/blending/conversions.js +256 -0
- package/dist/blending/conversions.js.map +1 -0
- package/dist/blending/index.d.ts +8 -0
- package/dist/blending/index.d.ts.map +1 -0
- package/dist/blending/index.js +3 -0
- package/dist/blending/index.js.map +1 -0
- package/dist/blending/types.d.ts +36 -0
- package/dist/blending/types.d.ts.map +1 -0
- package/dist/blending/types.js +21 -0
- package/dist/blending/types.js.map +1 -0
- package/dist/config/band-calibration.d.ts +68 -0
- package/dist/config/band-calibration.d.ts.map +1 -0
- package/dist/config/band-calibration.js +196 -0
- package/dist/config/band-calibration.js.map +1 -0
- package/dist/config/band-vocabulary.d.ts +82 -0
- package/dist/config/band-vocabulary.d.ts.map +1 -0
- package/dist/config/band-vocabulary.js +117 -0
- package/dist/config/band-vocabulary.js.map +1 -0
- package/dist/config/consolidated-ids.js +2 -2
- package/dist/config/consolidated-ids.js.map +1 -1
- package/dist/config/dye-vocabulary.d.ts +45 -0
- package/dist/config/dye-vocabulary.d.ts.map +1 -0
- package/dist/config/dye-vocabulary.js +58 -0
- package/dist/config/dye-vocabulary.js.map +1 -0
- package/dist/config/facewear.d.ts +24 -0
- package/dist/config/facewear.d.ts.map +1 -0
- package/dist/config/facewear.js +35 -0
- package/dist/config/facewear.js.map +1 -0
- package/dist/config/learn-links.d.ts +70 -0
- package/dist/config/learn-links.d.ts.map +1 -0
- package/dist/config/learn-links.js +171 -0
- package/dist/config/learn-links.js.map +1 -0
- package/dist/config/product-links.d.ts +44 -0
- package/dist/config/product-links.d.ts.map +1 -0
- package/dist/config/product-links.js +44 -0
- package/dist/config/product-links.js.map +1 -0
- package/dist/constants/index.d.ts +14 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +38 -22
- package/dist/constants/index.js.map +1 -1
- package/dist/data/character_colors/race_specific/hair_colors.json +1 -1
- package/dist/data/character_colors/race_specific/skin_colors.json +1 -1
- package/dist/data/dyes.json +1127 -0
- package/dist/data/facewear_colors.json +57 -0
- package/dist/data/locales/de.json +4 -50
- package/dist/data/locales/en.json +4 -50
- package/dist/data/locales/fr.json +4 -50
- package/dist/data/locales/ja.json +4 -50
- package/dist/data/locales/ko.json +4 -50
- package/dist/data/locales/zh.json +4 -50
- package/dist/data/presets.json +59 -301
- package/dist/index.d.ts +156 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -10
- package/dist/index.js.map +1 -1
- package/dist/services/APIService.d.ts +39 -62
- package/dist/services/APIService.d.ts.map +1 -1
- package/dist/services/APIService.js +156 -150
- package/dist/services/APIService.js.map +1 -1
- package/dist/services/CharacterColorService.d.ts +4 -36
- package/dist/services/CharacterColorService.d.ts.map +1 -1
- package/dist/services/CharacterColorService.js +57 -79
- package/dist/services/CharacterColorService.js.map +1 -1
- package/dist/services/ColorService.d.ts +57 -68
- package/dist/services/ColorService.d.ts.map +1 -1
- package/dist/services/ColorService.js +86 -94
- package/dist/services/ColorService.js.map +1 -1
- package/dist/services/DyeService.d.ts +11 -104
- package/dist/services/DyeService.d.ts.map +1 -1
- package/dist/services/DyeService.js +19 -157
- package/dist/services/DyeService.js.map +1 -1
- package/dist/services/LocalizationService.d.ts +48 -59
- package/dist/services/LocalizationService.d.ts.map +1 -1
- package/dist/services/LocalizationService.js +86 -95
- package/dist/services/LocalizationService.js.map +1 -1
- package/dist/services/PaletteService.d.ts +8 -9
- package/dist/services/PaletteService.d.ts.map +1 -1
- package/dist/services/PaletteService.js +10 -22
- package/dist/services/PaletteService.js.map +1 -1
- package/dist/services/PresetService.d.ts +2 -34
- package/dist/services/PresetService.d.ts.map +1 -1
- package/dist/services/PresetService.js +12 -59
- package/dist/services/PresetService.js.map +1 -1
- package/dist/services/chara/chara-models.d.ts +68 -0
- package/dist/services/chara/chara-models.d.ts.map +1 -0
- package/dist/services/chara/chara-models.js +87 -0
- package/dist/services/chara/chara-models.js.map +1 -0
- package/dist/services/chara/chara-parser.d.ts +95 -0
- package/dist/services/chara/chara-parser.d.ts.map +1 -0
- package/dist/services/chara/chara-parser.js +299 -0
- package/dist/services/chara/chara-parser.js.map +1 -0
- package/dist/services/chara/chara-resolver.d.ts +103 -0
- package/dist/services/chara/chara-resolver.d.ts.map +1 -0
- package/dist/services/chara/chara-resolver.js +233 -0
- package/dist/services/chara/chara-resolver.js.map +1 -0
- package/dist/services/color/ColorConverter.d.ts +112 -35
- package/dist/services/color/ColorConverter.d.ts.map +1 -1
- package/dist/services/color/ColorConverter.js +205 -89
- package/dist/services/color/ColorConverter.js.map +1 -1
- package/dist/services/color/ColorManipulator.d.ts +11 -0
- package/dist/services/color/ColorManipulator.d.ts.map +1 -1
- package/dist/services/color/ColorManipulator.js +24 -9
- package/dist/services/color/ColorManipulator.js.map +1 -1
- package/dist/services/color/ColorblindnessSimulator.d.ts +17 -0
- package/dist/services/color/ColorblindnessSimulator.d.ts.map +1 -1
- package/dist/services/color/ColorblindnessSimulator.js +57 -3
- package/dist/services/color/ColorblindnessSimulator.js.map +1 -1
- package/dist/services/color/SpectralMixer.d.ts +0 -34
- package/dist/services/color/SpectralMixer.d.ts.map +1 -1
- package/dist/services/color/SpectralMixer.js +0 -73
- package/dist/services/color/SpectralMixer.js.map +1 -1
- package/dist/services/dye/DyeDatabase.d.ts +5 -21
- package/dist/services/dye/DyeDatabase.d.ts.map +1 -1
- package/dist/services/dye/DyeDatabase.js +98 -130
- package/dist/services/dye/DyeDatabase.js.map +1 -1
- package/dist/services/dye/DyeSearch.d.ts +17 -31
- package/dist/services/dye/DyeSearch.d.ts.map +1 -1
- package/dist/services/dye/DyeSearch.js +45 -141
- package/dist/services/dye/DyeSearch.js.map +1 -1
- package/dist/services/dye/HarmonyGenerator.d.ts +11 -18
- package/dist/services/dye/HarmonyGenerator.d.ts.map +1 -1
- package/dist/services/dye/HarmonyGenerator.js +33 -38
- package/dist/services/dye/HarmonyGenerator.js.map +1 -1
- package/dist/services/localization/LocaleLoader.d.ts.map +1 -1
- package/dist/services/localization/LocaleLoader.js +0 -1
- package/dist/services/localization/LocaleLoader.js.map +1 -1
- package/dist/services/localization/TranslationProvider.d.ts +1 -42
- package/dist/services/localization/TranslationProvider.d.ts.map +1 -1
- package/dist/services/localization/TranslationProvider.js +4 -82
- package/dist/services/localization/TranslationProvider.js.map +1 -1
- package/dist/types/index.d.ts +39 -52
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +50 -10
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +36 -123
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +54 -413
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/kd-tree.d.ts +0 -4
- package/dist/utils/kd-tree.d.ts.map +1 -1
- package/dist/utils/kd-tree.js +0 -6
- package/dist/utils/kd-tree.js.map +1 -1
- package/package.json +24 -15
- package/dist/data/character_colors/index.json +0 -40
- package/dist/data/colors_xiv.json +0 -3538
- package/dist/version.d.ts +0 -11
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -11
- package/dist/version.js.map +0 -1
|
@@ -15,28 +15,43 @@ export class ColorManipulator {
|
|
|
15
15
|
* @param amount -100 to 100 (negative = darker, positive = lighter)
|
|
16
16
|
*/
|
|
17
17
|
static adjustBrightness(hex, amount) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
// BUG-005 (2026-07-18 audit): never mutate the conversion result — the
|
|
19
|
+
// converter caches these objects, and in-place edits poisoned the cache
|
|
20
|
+
const { h, s, v } = ColorConverter.hexToHsv(hex);
|
|
21
|
+
return ColorConverter.hsvToHex(h, s, clamp(v + amount, 0, 100));
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Adjust saturation of a color
|
|
24
25
|
* @param amount -100 to 100 (negative = less saturated, positive = more saturated)
|
|
25
26
|
*/
|
|
26
27
|
static adjustSaturation(hex, amount) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return ColorConverter.hsvToHex(
|
|
28
|
+
// BUG-005: build new values instead of mutating the cached object
|
|
29
|
+
const { h, s, v } = ColorConverter.hexToHsv(hex);
|
|
30
|
+
return ColorConverter.hsvToHex(h, clamp(s + amount, 0, 100), v);
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Rotate hue of a color
|
|
33
34
|
* @param degrees Amount to rotate hue (can be negative or positive)
|
|
34
35
|
*/
|
|
35
36
|
static rotateHue(hex, degrees) {
|
|
36
|
-
|
|
37
|
+
// BUG-005: build new values instead of mutating the cached object
|
|
38
|
+
const { h, s, v } = ColorConverter.hexToHsv(hex);
|
|
37
39
|
// Normalize to 0-360 to handle negative values properly
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
return ColorConverter.hsvToHex((((h + degrees) % 360) + 360) % 360, s, v);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Rotate hue of a color in CIE LCh space (perceptual hue rotation).
|
|
44
|
+
*
|
|
45
|
+
* Unlike {@link rotateHue} (HSV), rotating in LCh preserves perceived
|
|
46
|
+
* lightness and chroma, so the "ideal" hue offsets used by harmony math
|
|
47
|
+
* (e.g. a tetradic +90°) stay perceptually meaningful. Out-of-gamut results
|
|
48
|
+
* are clamped by the LCh→RGB conversion.
|
|
49
|
+
*
|
|
50
|
+
* @param degrees Amount to rotate hue (can be negative or positive)
|
|
51
|
+
*/
|
|
52
|
+
static rotateHueLch(hex, degrees) {
|
|
53
|
+
const { L, C, h } = ColorConverter.hexToLch(hex);
|
|
54
|
+
return ColorConverter.lchToHex(L, C, (((h + degrees) % 360) + 360) % 360);
|
|
40
55
|
}
|
|
41
56
|
/**
|
|
42
57
|
* Invert a color (create complementary color)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorManipulator.js","sourceRoot":"","sources":["../../../src/services/color/ColorManipulator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAW,EAAE,MAAc;QACjD,
|
|
1
|
+
{"version":3,"file":"ColorManipulator.js","sourceRoot":"","sources":["../../../src/services/color/ColorManipulator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAW,EAAE,MAAc;QACjD,uEAAuE;QACvE,wEAAwE;QACxE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACjD,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAW,EAAE,MAAc;QACjD,kEAAkE;QAClE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACjD,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,GA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AAG,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -31,5 +31,22 @@ export declare class ColorblindnessSimulator {
|
|
|
31
31
|
* Simulate colorblindness on a hex color
|
|
32
32
|
*/
|
|
33
33
|
static simulateColorblindnessHex(hex: string, visionType: VisionType): HexColor;
|
|
34
|
+
/** sRGB electro-optical transfer (gamma expansion), 0-1 domain */
|
|
35
|
+
private static srgbToLinear;
|
|
36
|
+
/** Inverse sRGB transfer (gamma compression), 0-1 domain */
|
|
37
|
+
private static linearToSrgb;
|
|
38
|
+
/**
|
|
39
|
+
* Simulate colorblindness using the Machado et al. (2009) severity-1.0
|
|
40
|
+
* matrices, applied in **linear RGB** as the model requires.
|
|
41
|
+
*
|
|
42
|
+
* This is the simulation path the 5.0 band calibration (SEPARATION cuts)
|
|
43
|
+
* was computed against; the legacy Brettel path operates on gamma-encoded
|
|
44
|
+
* values and produces different (less physiologically grounded) results.
|
|
45
|
+
*/
|
|
46
|
+
static simulateColorblindnessMachado(rgb: RGB, visionType: VisionType): RGB;
|
|
47
|
+
/**
|
|
48
|
+
* Simulate colorblindness on a hex color via the Machado (2009) model
|
|
49
|
+
*/
|
|
50
|
+
static simulateColorblindnessMachadoHex(hex: string, visionType: VisionType): HexColor;
|
|
34
51
|
}
|
|
35
52
|
//# sourceMappingURL=ColorblindnessSimulator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorblindnessSimulator.d.ts","sourceRoot":"","sources":["../../../src/services/color/ColorblindnessSimulator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMpE;;;GAGG;AACH,qBAAa,uBAAuB;IAElC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAmC;IAE1E;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,IAAI;IAIzB;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;IAM9C;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,GAAG,GAAG;
|
|
1
|
+
{"version":3,"file":"ColorblindnessSimulator.d.ts","sourceRoot":"","sources":["../../../src/services/color/ColorblindnessSimulator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMpE;;;GAGG;AACH,qBAAa,uBAAuB;IAElC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAmC;IAE1E;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,IAAI;IAIzB;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;IAM9C;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,GAAG,GAAG;IAiDpE;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,QAAQ;IAM/E,kEAAkE;IAClE,OAAO,CAAC,MAAM,CAAC,YAAY;IAI3B,4DAA4D;IAC5D,OAAO,CAAC,MAAM,CAAC,YAAY;IAI3B;;;;;;;OAOG;IACH,MAAM,CAAC,6BAA6B,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,GAAG,GAAG;IAuC3E;;OAEG;IACH,MAAM,CAAC,gCAAgC,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,QAAQ;CAKvF"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Uses Brettel 1997 transformation matrices
|
|
5
5
|
*/
|
|
6
6
|
import { ErrorCode, AppError } from '@xivdyetools/types';
|
|
7
|
-
import { BRETTEL_MATRICES } from '../../constants/index.js';
|
|
7
|
+
import { BRETTEL_MATRICES, MACHADO_MATRICES } from '../../constants/index.js';
|
|
8
8
|
import { clamp, round, isValidRGB, LRUCache } from '../../utils/index.js';
|
|
9
9
|
import { ColorConverter } from './ColorConverter.js';
|
|
10
10
|
/**
|
|
@@ -46,7 +46,9 @@ export class ColorblindnessSimulator {
|
|
|
46
46
|
// Check cache
|
|
47
47
|
const cached = this.colorblindCache.get(cacheKey);
|
|
48
48
|
if (cached) {
|
|
49
|
-
|
|
49
|
+
// BUG-005 (2026-07-18 audit): defensive copy — protects the cache from
|
|
50
|
+
// caller mutation
|
|
51
|
+
return { ...cached };
|
|
50
52
|
}
|
|
51
53
|
// Per P-1: BRETTEL_MATRICES are already pre-computed constants (no recalculation needed)
|
|
52
54
|
const matrix = BRETTEL_MATRICES[visionType];
|
|
@@ -61,7 +63,7 @@ export class ColorblindnessSimulator {
|
|
|
61
63
|
const result = { r: transformedR, g: transformedG, b: transformedB };
|
|
62
64
|
// Cache result
|
|
63
65
|
this.colorblindCache.set(cacheKey, result);
|
|
64
|
-
return result;
|
|
66
|
+
return { ...result };
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
67
69
|
* Simulate colorblindness on a hex color
|
|
@@ -71,5 +73,57 @@ export class ColorblindnessSimulator {
|
|
|
71
73
|
const simulated = this.simulateColorblindness(rgb, visionType);
|
|
72
74
|
return ColorConverter.rgbToHex(simulated.r, simulated.g, simulated.b);
|
|
73
75
|
}
|
|
76
|
+
/** sRGB electro-optical transfer (gamma expansion), 0-1 domain */
|
|
77
|
+
static srgbToLinear(c) {
|
|
78
|
+
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
79
|
+
}
|
|
80
|
+
/** Inverse sRGB transfer (gamma compression), 0-1 domain */
|
|
81
|
+
static linearToSrgb(c) {
|
|
82
|
+
return c <= 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Simulate colorblindness using the Machado et al. (2009) severity-1.0
|
|
86
|
+
* matrices, applied in **linear RGB** as the model requires.
|
|
87
|
+
*
|
|
88
|
+
* This is the simulation path the 5.0 band calibration (SEPARATION cuts)
|
|
89
|
+
* was computed against; the legacy Brettel path operates on gamma-encoded
|
|
90
|
+
* values and produces different (less physiologically grounded) results.
|
|
91
|
+
*/
|
|
92
|
+
static simulateColorblindnessMachado(rgb, visionType) {
|
|
93
|
+
if (visionType === 'normal') {
|
|
94
|
+
return { ...rgb };
|
|
95
|
+
}
|
|
96
|
+
if (!isValidRGB(rgb.r, rgb.g, rgb.b)) {
|
|
97
|
+
throw new AppError(ErrorCode.INVALID_RGB_VALUE, 'Invalid RGB values for colorblindness simulation', 'error');
|
|
98
|
+
}
|
|
99
|
+
const cacheKey = `m:${rgb.r},${rgb.g},${rgb.b}_${visionType}`;
|
|
100
|
+
const cached = this.colorblindCache.get(cacheKey);
|
|
101
|
+
if (cached) {
|
|
102
|
+
return { ...cached };
|
|
103
|
+
}
|
|
104
|
+
const matrix = MACHADO_MATRICES[visionType];
|
|
105
|
+
const rLin = this.srgbToLinear(rgb.r / 255);
|
|
106
|
+
const gLin = this.srgbToLinear(rgb.g / 255);
|
|
107
|
+
const bLin = this.srgbToLinear(rgb.b / 255);
|
|
108
|
+
const toChannel = (row) => {
|
|
109
|
+
const lin = clamp(row[0] * rLin + row[1] * gLin + row[2] * bLin, 0, 1);
|
|
110
|
+
return round(clamp(this.linearToSrgb(lin) * 255, 0, 255));
|
|
111
|
+
};
|
|
112
|
+
const result = {
|
|
113
|
+
r: toChannel(matrix[0]),
|
|
114
|
+
g: toChannel(matrix[1]),
|
|
115
|
+
b: toChannel(matrix[2]),
|
|
116
|
+
};
|
|
117
|
+
this.colorblindCache.set(cacheKey, result);
|
|
118
|
+
return { ...result };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Simulate colorblindness on a hex color via the Machado (2009) model
|
|
122
|
+
*/
|
|
123
|
+
static simulateColorblindnessMachadoHex(hex, visionType) {
|
|
124
|
+
const rgb = ColorConverter.hexToRgb(hex);
|
|
125
|
+
const simulated = this.simulateColorblindnessMachado(rgb, visionType);
|
|
126
|
+
return ColorConverter.rgbToHex(simulated.r, simulated.g, simulated.b);
|
|
127
|
+
}
|
|
74
128
|
}
|
|
75
129
|
//# sourceMappingURL=ColorblindnessSimulator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorblindnessSimulator.js","sourceRoot":"","sources":["../../../src/services/color/ColorblindnessSimulator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ColorblindnessSimulator.js","sourceRoot":"","sources":["../../../src/services/color/ColorblindnessSimulator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAClC,mDAAmD;IAC3C,MAAM,CAAU,eAAe,GAAG,IAAI,QAAQ,CAAc,IAAI,CAAC,CAAC;IAE1E;;OAEG;IACH,MAAM,CAAC,UAAU;QACf,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa;QAClB,OAAO;YACL,UAAU,EAAE,IAAI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tE,OAAO,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC"}
|
|
@@ -39,39 +39,5 @@ export declare class SpectralMixer {
|
|
|
39
39
|
* SpectralMixer.mixColors('#0000FF', '#FFFF00') // Returns green-ish color
|
|
40
40
|
*/
|
|
41
41
|
static mixColors(hex1: string, hex2: string, ratio?: number): HexColor;
|
|
42
|
-
/**
|
|
43
|
-
* Mix multiple colors using Kubelka-Munk spectral mixing
|
|
44
|
-
*
|
|
45
|
-
* @param colors Array of hex colors to mix
|
|
46
|
-
* @param weights Optional array of weights (defaults to equal weights)
|
|
47
|
-
* @returns Mixed color as hex
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* // Mix three colors
|
|
51
|
-
* SpectralMixer.mixMultiple(['#FF0000', '#00FF00', '#0000FF'])
|
|
52
|
-
*/
|
|
53
|
-
static mixMultiple(colors: string[], weights?: number[]): HexColor;
|
|
54
|
-
/**
|
|
55
|
-
* Generate a gradient palette using spectral mixing
|
|
56
|
-
*
|
|
57
|
-
* Creates a series of colors that transition smoothly between
|
|
58
|
-
* two colors using Kubelka-Munk theory for realistic blending.
|
|
59
|
-
*
|
|
60
|
-
* @param hex1 Starting color
|
|
61
|
-
* @param hex2 Ending color
|
|
62
|
-
* @param steps Number of colors in the gradient (including start and end)
|
|
63
|
-
* @returns Array of hex colors
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* // Generate a 5-step gradient from red to blue
|
|
67
|
-
* SpectralMixer.gradient('#FF0000', '#0000FF', 5)
|
|
68
|
-
*/
|
|
69
|
-
static gradient(hex1: string, hex2: string, steps: number): HexColor[];
|
|
70
|
-
/**
|
|
71
|
-
* Check if the spectral.js library is available
|
|
72
|
-
*
|
|
73
|
-
* @returns true if spectral.js is loaded and functional
|
|
74
|
-
*/
|
|
75
|
-
static isAvailable(): boolean;
|
|
76
42
|
}
|
|
77
43
|
//# sourceMappingURL=SpectralMixer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpectralMixer.d.ts","sourceRoot":"","sources":["../../../src/services/color/SpectralMixer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY,GAAG,QAAQ;
|
|
1
|
+
{"version":3,"file":"SpectralMixer.d.ts","sourceRoot":"","sources":["../../../src/services/color/SpectralMixer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY,GAAG,QAAQ;CAoB5E"}
|
|
@@ -55,78 +55,5 @@ export class SpectralMixer {
|
|
|
55
55
|
// Normalize to our HexColor format
|
|
56
56
|
return ColorConverter.normalizeHex(hexResult);
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Mix multiple colors using Kubelka-Munk spectral mixing
|
|
60
|
-
*
|
|
61
|
-
* @param colors Array of hex colors to mix
|
|
62
|
-
* @param weights Optional array of weights (defaults to equal weights)
|
|
63
|
-
* @returns Mixed color as hex
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* // Mix three colors
|
|
67
|
-
* SpectralMixer.mixMultiple(['#FF0000', '#00FF00', '#0000FF'])
|
|
68
|
-
*/
|
|
69
|
-
static mixMultiple(colors, weights) {
|
|
70
|
-
if (colors.length === 0) {
|
|
71
|
-
throw new Error('At least one color is required');
|
|
72
|
-
}
|
|
73
|
-
if (colors.length === 1) {
|
|
74
|
-
return ColorConverter.normalizeHex(colors[0]);
|
|
75
|
-
}
|
|
76
|
-
// Use equal weights if not provided
|
|
77
|
-
const effectiveWeights = weights ?? colors.map(() => 1 / colors.length);
|
|
78
|
-
// Normalize weights to sum to 1
|
|
79
|
-
const totalWeight = effectiveWeights.reduce((sum, w) => sum + w, 0);
|
|
80
|
-
const normalizedWeights = effectiveWeights.map((w) => w / totalWeight);
|
|
81
|
-
// Create spectral Color objects with weights
|
|
82
|
-
const colorPairs = colors.map((hex, i) => [
|
|
83
|
-
new spectral.Color(hex),
|
|
84
|
-
normalizedWeights[i],
|
|
85
|
-
]);
|
|
86
|
-
// Mix using Kubelka-Munk theory
|
|
87
|
-
const mixed = spectral.mix(...colorPairs);
|
|
88
|
-
// Convert to hex string
|
|
89
|
-
const hexResult = mixed.toString({ format: 'hex', method: 'map' });
|
|
90
|
-
return ColorConverter.normalizeHex(hexResult);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Generate a gradient palette using spectral mixing
|
|
94
|
-
*
|
|
95
|
-
* Creates a series of colors that transition smoothly between
|
|
96
|
-
* two colors using Kubelka-Munk theory for realistic blending.
|
|
97
|
-
*
|
|
98
|
-
* @param hex1 Starting color
|
|
99
|
-
* @param hex2 Ending color
|
|
100
|
-
* @param steps Number of colors in the gradient (including start and end)
|
|
101
|
-
* @returns Array of hex colors
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* // Generate a 5-step gradient from red to blue
|
|
105
|
-
* SpectralMixer.gradient('#FF0000', '#0000FF', 5)
|
|
106
|
-
*/
|
|
107
|
-
static gradient(hex1, hex2, steps) {
|
|
108
|
-
if (steps < 2) {
|
|
109
|
-
throw new Error('Gradient requires at least 2 steps');
|
|
110
|
-
}
|
|
111
|
-
const result = [];
|
|
112
|
-
for (let i = 0; i < steps; i++) {
|
|
113
|
-
const ratio = i / (steps - 1);
|
|
114
|
-
result.push(this.mixColors(hex1, hex2, ratio));
|
|
115
|
-
}
|
|
116
|
-
return result;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Check if the spectral.js library is available
|
|
120
|
-
*
|
|
121
|
-
* @returns true if spectral.js is loaded and functional
|
|
122
|
-
*/
|
|
123
|
-
static isAvailable() {
|
|
124
|
-
try {
|
|
125
|
-
return typeof spectral.Color === 'function' && typeof spectral.mix === 'function';
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
58
|
}
|
|
132
59
|
//# sourceMappingURL=SpectralMixer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpectralMixer.js","sourceRoot":"","sources":["../../../src/services/color/SpectralMixer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACxB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,SAAS,CAAC,IAAY,EAAE,IAAY,EAAE,QAAgB,GAAG;QAC9D,6BAA6B;QAC7B,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QAExC,gCAAgC;QAChC,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAExC,gCAAgC;QAChC,sDAAsD;QACtD,qDAAqD;QACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,MA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AE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAEnE,mCAAmC;QACnC,OAAO,cAAc,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -26,7 +26,6 @@ export declare class DyeDatabase {
|
|
|
26
26
|
private dyesByHueBucket;
|
|
27
27
|
private kdTree;
|
|
28
28
|
private isLoaded;
|
|
29
|
-
private lastLoaded;
|
|
30
29
|
private readonly logger;
|
|
31
30
|
private static readonly HUE_BUCKET_SIZE;
|
|
32
31
|
private static readonly HUE_BUCKET_COUNT;
|
|
@@ -51,6 +50,11 @@ export declare class DyeDatabase {
|
|
|
51
50
|
* @param dye - Object to validate as a Dye
|
|
52
51
|
* @returns true if valid, false otherwise
|
|
53
52
|
*/
|
|
53
|
+
/**
|
|
54
|
+
* REFACTOR-013 (2026-07-18 audit): shared log-identifier derivation —
|
|
55
|
+
* previously copy-pasted (with drift) six times inside isValidDye.
|
|
56
|
+
*/
|
|
57
|
+
private dyeIdForLog;
|
|
54
58
|
private isValidDye;
|
|
55
59
|
/**
|
|
56
60
|
* Initialize dye database from data
|
|
@@ -91,30 +95,10 @@ export declare class DyeDatabase {
|
|
|
91
95
|
* @since 2.1.0
|
|
92
96
|
*/
|
|
93
97
|
getByStainId(stainId: number): Dye | null;
|
|
94
|
-
/**
|
|
95
|
-
* Get multiple dyes by IDs
|
|
96
|
-
*/
|
|
97
|
-
getDyesByIds(ids: number[]): Dye[];
|
|
98
|
-
/**
|
|
99
|
-
* Get multiple dyes by stainIDs
|
|
100
|
-
*
|
|
101
|
-
* Batch equivalent of `getByStainId()`. Returns only the dyes that match;
|
|
102
|
-
* unknown stainIDs are silently skipped (consistent with `getDyesByIds()`).
|
|
103
|
-
*
|
|
104
|
-
* @param stainIds - Array of stain table IDs
|
|
105
|
-
* @returns Array of matching dyes (order matches input, gaps removed)
|
|
106
|
-
*
|
|
107
|
-
* @since 2.2.0
|
|
108
|
-
*/
|
|
109
|
-
getDyesByStainIds(stainIds: number[]): Dye[];
|
|
110
98
|
/**
|
|
111
99
|
* Check if database is loaded
|
|
112
100
|
*/
|
|
113
101
|
isLoadedStatus(): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Get timestamp of last load
|
|
116
|
-
*/
|
|
117
|
-
getLastLoadedTime(): number;
|
|
118
102
|
/**
|
|
119
103
|
* Get total dye count
|
|
120
104
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DyeDatabase.d.ts","sourceRoot":"","sources":["../../../src/services/dye/DyeDatabase.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAO,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAgB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"DyeDatabase.d.ts","sourceRoot":"","sources":["../../../src/services/dye/DyeDatabase.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAO,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAgB,MAAM,wBAAwB,CAAC;AAuB9D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,WAAW;IAEtB,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,WAAW,CAAuC;IAE1D,OAAO,CAAC,gBAAgB,CAAuC;IAG/D,OAAO,CAAC,eAAe,CAAyC;IAEhE,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAGhC,OAAO,CAAC,MAAM,CAAC,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