@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
|
@@ -22,14 +22,13 @@
|
|
|
22
22
|
* const hairColors = await characterColors.getHairColors('Midlander', 'Male');
|
|
23
23
|
*
|
|
24
24
|
* // Find closest dyes to an eye color
|
|
25
|
-
* const matches = characterColors.findClosestDyes(eyeColors[47], dyeService, 3);
|
|
25
|
+
* const matches = characterColors.findClosestDyes(eyeColors[47], dyeService, { count: 3 });
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
import { ColorConverter } from './color/ColorConverter.js';
|
|
29
29
|
// =============================================================================
|
|
30
30
|
// Eager imports for shared colors (always needed, loaded at build time)
|
|
31
31
|
// =============================================================================
|
|
32
|
-
import colorMeta from '../data/character_colors/index.json';
|
|
33
32
|
import eyeColorsData from '../data/character_colors/shared/eye_colors.json';
|
|
34
33
|
import highlightColorsData from '../data/character_colors/shared/highlight_colors.json';
|
|
35
34
|
import lipColorsDarkData from '../data/character_colors/shared/lip_colors_dark.json';
|
|
@@ -126,10 +125,17 @@ export class CharacterColorService {
|
|
|
126
125
|
}
|
|
127
126
|
// Deduplicate concurrent loads
|
|
128
127
|
if (!this.hairColorsLoading) {
|
|
129
|
-
this.hairColorsLoading = import('../data/character_colors/race_specific/hair_colors.json')
|
|
128
|
+
this.hairColorsLoading = import('../data/character_colors/race_specific/hair_colors.json')
|
|
129
|
+
.then((module) => {
|
|
130
130
|
this.hairColorsData = module.default;
|
|
131
131
|
this.hairColorsLoading = null;
|
|
132
132
|
return this.hairColorsData;
|
|
133
|
+
})
|
|
134
|
+
.catch((err) => {
|
|
135
|
+
// BUG-013 (2026-07-18 audit): reset on failure so a later call can
|
|
136
|
+
// retry instead of rethrowing the cached rejection forever
|
|
137
|
+
this.hairColorsLoading = null;
|
|
138
|
+
throw err;
|
|
133
139
|
});
|
|
134
140
|
}
|
|
135
141
|
return this.hairColorsLoading;
|
|
@@ -143,10 +149,17 @@ export class CharacterColorService {
|
|
|
143
149
|
}
|
|
144
150
|
// Deduplicate concurrent loads
|
|
145
151
|
if (!this.skinColorsLoading) {
|
|
146
|
-
this.skinColorsLoading = import('../data/character_colors/race_specific/skin_colors.json')
|
|
152
|
+
this.skinColorsLoading = import('../data/character_colors/race_specific/skin_colors.json')
|
|
153
|
+
.then((module) => {
|
|
147
154
|
this.skinColorsData = module.default;
|
|
148
155
|
this.skinColorsLoading = null;
|
|
149
156
|
return this.skinColorsData;
|
|
157
|
+
})
|
|
158
|
+
.catch((err) => {
|
|
159
|
+
// BUG-013 (2026-07-18 audit): reset on failure so a later call can
|
|
160
|
+
// retry instead of rethrowing the cached rejection forever
|
|
161
|
+
this.skinColorsLoading = null;
|
|
162
|
+
throw err;
|
|
150
163
|
});
|
|
151
164
|
}
|
|
152
165
|
return this.skinColorsLoading;
|
|
@@ -189,14 +202,6 @@ export class CharacterColorService {
|
|
|
189
202
|
return this.getSkinColors(subrace, gender);
|
|
190
203
|
}
|
|
191
204
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Preload all race-specific data for faster subsequent access.
|
|
194
|
-
* Call this early (e.g., on app init) to avoid latency when
|
|
195
|
-
* the user first selects a race.
|
|
196
|
-
*/
|
|
197
|
-
async preloadRaceData() {
|
|
198
|
-
await Promise.all([this.loadHairColors(), this.loadSkinColors()]);
|
|
199
|
-
}
|
|
200
205
|
// ==========================================================================
|
|
201
206
|
// Color Matching
|
|
202
207
|
// ==========================================================================
|
|
@@ -204,7 +209,7 @@ export class CharacterColorService {
|
|
|
204
209
|
* Calculate color distance using the specified matching method.
|
|
205
210
|
* Converts RGB to hex for perceptual methods that require it.
|
|
206
211
|
*/
|
|
207
|
-
calculateDistanceWithMethod(rgb1, rgb2, method
|
|
212
|
+
calculateDistanceWithMethod(rgb1, rgb2, method) {
|
|
208
213
|
// For RGB method, use simple Euclidean distance
|
|
209
214
|
if (method === 'rgb') {
|
|
210
215
|
return this.calculateDistance(rgb1, rgb2);
|
|
@@ -213,18 +218,19 @@ export class CharacterColorService {
|
|
|
213
218
|
const hex1 = ColorConverter.rgbToHex(rgb1.r, rgb1.g, rgb1.b);
|
|
214
219
|
const hex2 = ColorConverter.rgbToHex(rgb2.r, rgb2.g, rgb2.b);
|
|
215
220
|
switch (method) {
|
|
221
|
+
// The three perceptual methods share their spelling with DeltaEFormula
|
|
222
|
+
// (DEAD-037, 2026-08-18 audit) — no translation switch needed.
|
|
216
223
|
case 'cie76':
|
|
217
|
-
return ColorConverter.getDeltaE(hex1, hex2, 'cie76');
|
|
218
224
|
case 'ciede2000':
|
|
219
|
-
return ColorConverter.getDeltaE(hex1, hex2, 'cie2000');
|
|
220
225
|
case 'oklab':
|
|
221
|
-
return ColorConverter.
|
|
222
|
-
case '
|
|
223
|
-
return ColorConverter.
|
|
224
|
-
case '
|
|
225
|
-
|
|
226
|
+
return ColorConverter.getDeltaE(hex1, hex2, method);
|
|
227
|
+
case 'redmean':
|
|
228
|
+
return ColorConverter.getRedmeanDistance(hex1, hex2);
|
|
229
|
+
case 'distinguish':
|
|
230
|
+
// Unrounded percent — identical ranks to RGB DIST, no ranking ties
|
|
231
|
+
return ColorConverter.getColorDistance(hex1, hex2) / 4.416729559;
|
|
226
232
|
default:
|
|
227
|
-
return ColorConverter.
|
|
233
|
+
return ColorConverter.getDeltaE(hex1, hex2, 'ciede2000');
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
/**
|
|
@@ -234,50 +240,60 @@ export class CharacterColorService {
|
|
|
234
240
|
*
|
|
235
241
|
* @param color - The character color to match
|
|
236
242
|
* @param dyeService - DyeService instance for dye lookup
|
|
237
|
-
* @param
|
|
243
|
+
* @param options - Options object (count, matchingMethod)
|
|
238
244
|
* @returns Array of matches sorted by distance (closest first)
|
|
239
245
|
*
|
|
240
246
|
* @example
|
|
241
247
|
* ```typescript
|
|
242
248
|
* const eyeColor = characterColors.getEyeColors()[47];
|
|
243
249
|
*
|
|
244
|
-
* // Legacy usage
|
|
245
|
-
* const matches = characterColors.findClosestDyes(eyeColor, dyeService, 3);
|
|
246
|
-
*
|
|
247
|
-
* // New usage with options
|
|
248
250
|
* const matches = characterColors.findClosestDyes(eyeColor, dyeService, {
|
|
249
251
|
* count: 3,
|
|
250
252
|
* matchingMethod: 'oklab'
|
|
251
253
|
* });
|
|
252
254
|
* ```
|
|
253
255
|
*/
|
|
254
|
-
findClosestDyes(color, dyeService,
|
|
255
|
-
|
|
256
|
-
const options = typeof countOrOptions === 'number' ? { count: countOrOptions } : countOrOptions;
|
|
257
|
-
const { count = 3, matchingMethod = 'oklab', weights } = options;
|
|
256
|
+
findClosestDyes(color, dyeService, options = {}) {
|
|
257
|
+
const { count = 3, matchingMethod = 'ciede2000' } = options;
|
|
258
258
|
const allDyes = dyeService.getAllDyes();
|
|
259
|
-
|
|
259
|
+
// OPT-015 (2026-07-18 audit): single-pass bounded top-k selection instead
|
|
260
|
+
// of allocating a match object for all ~130 dyes and full-sorting to take
|
|
261
|
+
// the top 3 — this method runs per color across whole 192-color sheets,
|
|
262
|
+
// so the score-all + sort-all pattern multiplied into ~25k transient
|
|
263
|
+
// allocations per sheet.
|
|
264
|
+
const best = [];
|
|
260
265
|
for (const dye of allDyes) {
|
|
261
266
|
// Skip Facewear dyes (not usable for regular glamour)
|
|
262
267
|
if (dye.category === 'Facewear') {
|
|
263
268
|
continue;
|
|
264
269
|
}
|
|
265
|
-
const distance = this.calculateDistanceWithMethod(color.rgb, dye.rgb, matchingMethod
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
270
|
+
const distance = this.calculateDistanceWithMethod(color.rgb, dye.rgb, matchingMethod);
|
|
271
|
+
if (best.length < count) {
|
|
272
|
+
best.push({ dye, distance });
|
|
273
|
+
best.sort((a, b) => a.distance - b.distance);
|
|
274
|
+
}
|
|
275
|
+
else if (distance < best[best.length - 1].distance) {
|
|
276
|
+
best[best.length - 1] = { dye, distance };
|
|
277
|
+
// Bubble the new entry into place (k is tiny, typically 3)
|
|
278
|
+
for (let i = best.length - 1; i > 0 && best[i].distance < best[i - 1].distance; i--) {
|
|
279
|
+
const tmp = best[i];
|
|
280
|
+
best[i] = best[i - 1];
|
|
281
|
+
best[i - 1] = tmp;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
271
284
|
}
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
|
|
285
|
+
// Allocate result objects only for the winners
|
|
286
|
+
return best.map(({ dye, distance }) => ({
|
|
287
|
+
characterColor: color,
|
|
288
|
+
dye,
|
|
289
|
+
distance,
|
|
290
|
+
}));
|
|
275
291
|
}
|
|
276
292
|
/**
|
|
277
293
|
* Find the single closest dye to a character color
|
|
278
294
|
*/
|
|
279
295
|
findClosestDye(color, dyeService) {
|
|
280
|
-
const matches = this.findClosestDyes(color, dyeService, 1);
|
|
296
|
+
const matches = this.findClosestDyes(color, dyeService, { count: 1 });
|
|
281
297
|
return matches[0] || null;
|
|
282
298
|
}
|
|
283
299
|
/**
|
|
@@ -303,44 +319,6 @@ export class CharacterColorService {
|
|
|
303
319
|
return results;
|
|
304
320
|
}
|
|
305
321
|
// ==========================================================================
|
|
306
|
-
// Color Lookup
|
|
307
|
-
// ==========================================================================
|
|
308
|
-
/**
|
|
309
|
-
* Get a specific color by index from a shared category
|
|
310
|
-
*/
|
|
311
|
-
getSharedColorByIndex(category, index) {
|
|
312
|
-
const colors = this.getSharedColors(category);
|
|
313
|
-
return colors.find((c) => c.index === index) || null;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Get a specific color by index from a race-specific category
|
|
317
|
-
*/
|
|
318
|
-
async getRaceSpecificColorByIndex(category, subrace, gender, index) {
|
|
319
|
-
const colors = await this.getRaceSpecificColors(category, subrace, gender);
|
|
320
|
-
return colors.find((c) => c.index === index) || null;
|
|
321
|
-
}
|
|
322
|
-
// ==========================================================================
|
|
323
|
-
// Metadata
|
|
324
|
-
// ==========================================================================
|
|
325
|
-
/**
|
|
326
|
-
* Get all available subraces
|
|
327
|
-
*/
|
|
328
|
-
getAvailableSubraces() {
|
|
329
|
-
return colorMeta.subraces;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Get the data version
|
|
333
|
-
*/
|
|
334
|
-
getVersion() {
|
|
335
|
-
return colorMeta.meta.version;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Get grid column count (always 8)
|
|
339
|
-
*/
|
|
340
|
-
getGridColumns() {
|
|
341
|
-
return colorMeta.meta.gridColumns;
|
|
342
|
-
}
|
|
343
|
-
// ==========================================================================
|
|
344
322
|
// Private Helpers
|
|
345
323
|
// ==========================================================================
|
|
346
324
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CharacterColorService.js","sourceRoot":"","sources":["../../src/services/CharacterColorService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAaH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"CharacterColorService.js","sourceRoot":"","sources":["../../src/services/CharacterColorService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAaH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAY3D,gFAAgF;AAChF,wEAAwE;AACxE,gFAAgF;AAChF,OAAO,aAAa,MAAM,iDAAiD,CAAC;AAC5E,OAAO,mBAAmB,MAAM,uDAAuD,CAAC;AACxF,OAAO,iBAAiB,MAAM,sDAAsD,CAAC;AACrF,OAAO,kBAAkB,MAAM,uDAAuD,CAAC;AACvF,OAAO,gBAAgB,MAAM,oDAAoD,CAAC;AAClF,OAAO,iBAAiB,MAAM,sDAAsD,CAAC;AACrF,OAAO,kBAAkB,MAAM,uDAAuD,CAAC;AAOvF;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAChC,2CAA2C;IACnC,UAAU,GAAqC;QACrD,SAAS,EAAE,aAAa;QACxB,eAAe,EAAE,mBAAmB;QACpC,aAAa,EAAE,iBAAiB;QAChC,cAAc,EAAE,kBAAkB;QAClC,YAAY,EAAE,gBAAgB;QAC9B,mBAAmB,EAAE,iBAAiB;QACtC,oBAAoB,EAAE,kBAAkB;KACzC,CAAC;IAEF,kDAAkD;IAC1C,cAAc,GAAyB,IAAI,CAAC;IAC5C,cAAc,GAAyB,IAAI,CAAC;IAEpD,qCAAqC;IAC7B,iBAAiB,GAAkC,IAAI,CAAC;IACxD,iBAAiB,GAAkC,IAAI,CAAC;IAEhE;QACE,6DAA6D;IAC/D,CAAC;IAED,6EAA6E;IAC7E,kDAAkD;IAClD,6EAA6E;IAE7E;;OAEG;IAC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1B,IAAI,GAAG,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;gBAChC,SAAS;YACX,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5D,IAAI,QAAQ,IAAI,WAAW,EAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC;oBACX,cAAc,EAAE,KAAK;oBACrB,GAAG;oBACH,QAAQ;iBACT,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;QAChD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,6EAA6E;IAC7E,kBAAkB;IAClB,6EAA6E;IAE7E;;OAEG;IACK,iBAAiB,CAAC,IAAS,EAAE,IAAS;QAC5C,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
* const distance = ColorService.getColorDistance('#FF0000', '#00FF00');
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
import type { RGB, HSV, HexColor, VisionType, LAB, OKLAB, OKLCH, LCH, HSL } from '@xivdyetools/types';
|
|
28
|
+
import type { RGB, HSV, HexColor, VisionType, LAB, OKLAB, OKLCH, LCH, HSL, CMYK } from '@xivdyetools/types';
|
|
29
29
|
import { type DeltaEFormula } from './color/ColorConverter.js';
|
|
30
|
+
import type { MatchingMethod } from '../types/index.js';
|
|
30
31
|
import { type RYB } from './color/RybColorMixer.js';
|
|
31
32
|
/**
|
|
32
33
|
* Color conversion and manipulation service (Facade)
|
|
@@ -47,6 +48,8 @@ export declare class ColorService {
|
|
|
47
48
|
rgbToHsv: number;
|
|
48
49
|
hsvToRgb: number;
|
|
49
50
|
hexToHsv: number;
|
|
51
|
+
rgbToLab: number;
|
|
52
|
+
rgbToOklab: number;
|
|
50
53
|
colorblind: number;
|
|
51
54
|
};
|
|
52
55
|
/**
|
|
@@ -86,6 +89,25 @@ export declare class ColorService {
|
|
|
86
89
|
* Returns 0 for identical colors, ~441.67 for white vs black
|
|
87
90
|
*/
|
|
88
91
|
static getColorDistance(hex1: string, hex2: string): number;
|
|
92
|
+
/**
|
|
93
|
+
* Calculate "redmean" weighted RGB distance between two colors.
|
|
94
|
+
* Low-cost perceptual approximation; 0 identical, ~765 white vs black.
|
|
95
|
+
*/
|
|
96
|
+
static getRedmeanDistance(hex1: string, hex2: string): number;
|
|
97
|
+
/**
|
|
98
|
+
* Distinguishability percentage: RGB distance rescaled to 0-100
|
|
99
|
+
* (`round(distance / 441.67 × 100)`). Identical ranks to RGB distance —
|
|
100
|
+
* a display unit, not a separate metric, and not a WCAG standard.
|
|
101
|
+
*/
|
|
102
|
+
static getDistinguishabilityPercent(hex1: string, hex2: string): number;
|
|
103
|
+
/**
|
|
104
|
+
* Distance between two colors in a 5.0 matching-vocabulary method's native
|
|
105
|
+
* unit — the one dispatch every surface shares (web readouts, bot cards,
|
|
106
|
+
* OG images). `distinguish` returns the display-rounded integer percent;
|
|
107
|
+
* for *ranking* use DyeSearch, which ranks distinguish by the unrounded
|
|
108
|
+
* value so display ties never scramble an ordering.
|
|
109
|
+
*/
|
|
110
|
+
static getDistanceForMethod(hex1: string, hex2: string, method: MatchingMethod): number;
|
|
89
111
|
/**
|
|
90
112
|
* Simulate colorblindness on an RGB color
|
|
91
113
|
* @example simulateColorblindness({ r: 255, g: 0, b: 0 }, 'deuteranopia')
|
|
@@ -95,6 +117,15 @@ export declare class ColorService {
|
|
|
95
117
|
* Simulate colorblindness on a hex color
|
|
96
118
|
*/
|
|
97
119
|
static simulateColorblindnessHex(hex: string, visionType: VisionType): HexColor;
|
|
120
|
+
/**
|
|
121
|
+
* Simulate colorblindness using the Machado (2009) severity-1.0 model
|
|
122
|
+
* (linear-RGB pipeline). The 5.0 SEPARATION band calibration uses this path.
|
|
123
|
+
*/
|
|
124
|
+
static simulateColorblindnessMachado(rgb: RGB, visionType: VisionType): RGB;
|
|
125
|
+
/**
|
|
126
|
+
* Simulate colorblindness on a hex color via the Machado (2009) model
|
|
127
|
+
*/
|
|
128
|
+
static simulateColorblindnessMachadoHex(hex: string, visionType: VisionType): HexColor;
|
|
98
129
|
/**
|
|
99
130
|
* Calculate perceived luminance of a color (0-1)
|
|
100
131
|
* Uses relative luminance formula from WCAG
|
|
@@ -136,6 +167,12 @@ export declare class ColorService {
|
|
|
136
167
|
* @param degrees 0-360 (amount to rotate hue)
|
|
137
168
|
*/
|
|
138
169
|
static rotateHue(hex: string, degrees: number): HexColor;
|
|
170
|
+
/**
|
|
171
|
+
* Rotate hue of a color in CIE LCh space (perceptual hue rotation).
|
|
172
|
+
* Preserves perceived lightness/chroma; use for harmony "ideal hue" math.
|
|
173
|
+
* @param degrees Amount to rotate hue (can be negative or positive)
|
|
174
|
+
*/
|
|
175
|
+
static rotateHueLch(hex: string, degrees: number): HexColor;
|
|
139
176
|
/**
|
|
140
177
|
* Invert a color (create complementary color)
|
|
141
178
|
*/
|
|
@@ -158,7 +195,8 @@ export declare class ColorService {
|
|
|
158
195
|
* Calculate DeltaE (color difference) between two hex colors
|
|
159
196
|
* @param hex1 First hex color
|
|
160
197
|
* @param hex2 Second hex color
|
|
161
|
-
* @param formula DeltaE formula to use ('cie76'
|
|
198
|
+
* @param formula DeltaE formula to use ('cie76', 'ciede2000' (alias: 'cie2000')
|
|
199
|
+
* or 'oklab'; default: 'cie76')
|
|
162
200
|
* @returns DeltaE value (0 = identical, <1 imperceptible, <3 barely noticeable, >5 clearly different)
|
|
163
201
|
*/
|
|
164
202
|
static getDeltaE(hex1: string, hex2: string, formula?: DeltaEFormula): number;
|
|
@@ -254,6 +292,23 @@ export declare class ColorService {
|
|
|
254
292
|
* Convert HSL to hex color
|
|
255
293
|
*/
|
|
256
294
|
static hslToHex(h: number, s: number, l: number): HexColor;
|
|
295
|
+
/**
|
|
296
|
+
* Convert RGB to CMYK (naive device-independent conversion)
|
|
297
|
+
* @example rgbToCmyk(255, 0, 0) -> { c: 0, m: 100, y: 100, k: 0 }
|
|
298
|
+
*/
|
|
299
|
+
static rgbToCmyk(r: number, g: number, b: number): CMYK;
|
|
300
|
+
/**
|
|
301
|
+
* Convert CMYK to RGB
|
|
302
|
+
*/
|
|
303
|
+
static cmykToRgb(c: number, m: number, y: number, k: number): RGB;
|
|
304
|
+
/**
|
|
305
|
+
* Convert hex color to CMYK
|
|
306
|
+
*/
|
|
307
|
+
static hexToCmyk(hex: string): CMYK;
|
|
308
|
+
/**
|
|
309
|
+
* Convert CMYK to hex color
|
|
310
|
+
*/
|
|
311
|
+
static cmykToHex(c: number, m: number, y: number, k: number): HexColor;
|
|
257
312
|
/**
|
|
258
313
|
* Mix two colors using RGB additive mixing (averaging)
|
|
259
314
|
*
|
|
@@ -343,33 +398,6 @@ export declare class ColorService {
|
|
|
343
398
|
* - 'decreasing': Always go counter-clockwise (decreasing hue values)
|
|
344
399
|
*/
|
|
345
400
|
static interpolateHue(h1: number, h2: number, ratio: number, method?: 'shorter' | 'longer' | 'increasing' | 'decreasing'): number;
|
|
346
|
-
/**
|
|
347
|
-
* Mix two colors using OKLCH cylindrical mixing
|
|
348
|
-
*
|
|
349
|
-
* OKLCH provides control over hue interpolation direction,
|
|
350
|
-
* useful for creating gradients that go "through" specific colors.
|
|
351
|
-
*
|
|
352
|
-
* @param hex1 First hex color
|
|
353
|
-
* @param hex2 Second hex color
|
|
354
|
-
* @param ratio Mix ratio (0 = all hex1, 0.5 = equal mix, 1 = all hex2). Default: 0.5
|
|
355
|
-
* @param hueMethod Hue interpolation method ('shorter' | 'longer' | 'increasing' | 'decreasing')
|
|
356
|
-
* @returns Mixed color as hex
|
|
357
|
-
*/
|
|
358
|
-
static mixColorsOklch(hex1: string, hex2: string, ratio?: number, hueMethod?: 'shorter' | 'longer' | 'increasing' | 'decreasing'): HexColor;
|
|
359
|
-
/**
|
|
360
|
-
* Mix two colors using LCH cylindrical mixing
|
|
361
|
-
*
|
|
362
|
-
* LCH is the cylindrical form of CIE LAB, providing hue control
|
|
363
|
-
* for perceptual mixing. Note: May produce unexpected hues for
|
|
364
|
-
* blue+yellow due to LAB's red bias (use OKLCH for better results).
|
|
365
|
-
*
|
|
366
|
-
* @param hex1 First hex color
|
|
367
|
-
* @param hex2 Second hex color
|
|
368
|
-
* @param ratio Mix ratio (0 = all hex1, 0.5 = equal mix, 1 = all hex2). Default: 0.5
|
|
369
|
-
* @param hueMethod Hue interpolation method ('shorter' | 'longer' | 'increasing' | 'decreasing')
|
|
370
|
-
* @returns Mixed color as hex
|
|
371
|
-
*/
|
|
372
|
-
static mixColorsLch(hex1: string, hex2: string, ratio?: number, hueMethod?: 'shorter' | 'longer' | 'increasing' | 'decreasing'): HexColor;
|
|
373
401
|
/**
|
|
374
402
|
* Mix two colors using HSL hue averaging
|
|
375
403
|
*
|
|
@@ -384,19 +412,6 @@ export declare class ColorService {
|
|
|
384
412
|
* @returns Mixed color as hex
|
|
385
413
|
*/
|
|
386
414
|
static mixColorsHsl(hex1: string, hex2: string, ratio?: number, hueMethod?: 'shorter' | 'longer' | 'increasing' | 'decreasing'): HexColor;
|
|
387
|
-
/**
|
|
388
|
-
* Mix two colors using HSV hue averaging
|
|
389
|
-
*
|
|
390
|
-
* Similar to HSL but uses Value instead of Lightness.
|
|
391
|
-
* Useful when working with existing HSV-based workflows.
|
|
392
|
-
*
|
|
393
|
-
* @param hex1 First hex color
|
|
394
|
-
* @param hex2 Second hex color
|
|
395
|
-
* @param ratio Mix ratio (0 = all hex1, 0.5 = equal mix, 1 = all hex2). Default: 0.5
|
|
396
|
-
* @param hueMethod Hue interpolation method ('shorter' | 'longer' | 'increasing' | 'decreasing')
|
|
397
|
-
* @returns Mixed color as hex
|
|
398
|
-
*/
|
|
399
|
-
static mixColorsHsv(hex1: string, hex2: string, ratio?: number, hueMethod?: 'shorter' | 'longer' | 'increasing' | 'decreasing'): HexColor;
|
|
400
415
|
/**
|
|
401
416
|
* Mix two colors using Kubelka-Munk spectral mixing
|
|
402
417
|
*
|
|
@@ -419,32 +434,6 @@ export declare class ColorService {
|
|
|
419
434
|
* ColorService.mixColorsSpectral('#0000FF', '#FFFF00')
|
|
420
435
|
*/
|
|
421
436
|
static mixColorsSpectral(hex1: string, hex2: string, ratio?: number): HexColor;
|
|
422
|
-
/**
|
|
423
|
-
* Mix multiple colors using Kubelka-Munk spectral mixing
|
|
424
|
-
*
|
|
425
|
-
* @param colors Array of hex colors to mix
|
|
426
|
-
* @param weights Optional array of weights (defaults to equal weights)
|
|
427
|
-
* @returns Mixed color as hex
|
|
428
|
-
*/
|
|
429
|
-
static mixMultipleSpectral(colors: string[], weights?: number[]): HexColor;
|
|
430
|
-
/**
|
|
431
|
-
* Generate a gradient using spectral mixing
|
|
432
|
-
*
|
|
433
|
-
* Creates a series of colors that transition smoothly using
|
|
434
|
-
* Kubelka-Munk theory for realistic blending.
|
|
435
|
-
*
|
|
436
|
-
* @param hex1 Starting color
|
|
437
|
-
* @param hex2 Ending color
|
|
438
|
-
* @param steps Number of colors in the gradient
|
|
439
|
-
* @returns Array of hex colors
|
|
440
|
-
*/
|
|
441
|
-
static gradientSpectral(hex1: string, hex2: string, steps: number): HexColor[];
|
|
442
|
-
/**
|
|
443
|
-
* Check if spectral mixing is available
|
|
444
|
-
*
|
|
445
|
-
* @returns true if spectral.js is loaded and functional
|
|
446
|
-
*/
|
|
447
|
-
static isSpectralAvailable(): boolean;
|
|
448
437
|
}
|
|
449
438
|
export type { RYB } from './color/RybColorMixer.js';
|
|
450
439
|
//# sourceMappingURL=ColorService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorService.d.ts","sourceRoot":"","sources":["../../src/services/ColorService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EACV,GAAG,EACH,GAAG,EACH,QAAQ,EACR,UAAU,EACV,GAAG,EACH,KAAK,EACL,KAAK,EACL,GAAG,EACH,GAAG,
|
|
1
|
+
{"version":3,"file":"ColorService.d.ts","sourceRoot":"","sources":["../../src/services/ColorService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EACV,GAAG,EACH,GAAG,EACH,QAAQ,EACR,UAAU,EACV,GAAG,EACH,KAAK,EACL,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAGnE;;;;GAIG;AACH,qBAAa,YAAY;IAKvB;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,IAAI;IAK1B;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI;QACtB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QAGjB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;K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