chromonym 1.4.1 → 3.0.0
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/NOTICE.md +64 -4
- package/README.md +290 -83
- package/dist/conversions/hex.d.ts +1 -1
- package/dist/conversions/hex.d.ts.map +1 -1
- package/dist/conversions/hex.js +2 -2
- package/dist/conversions/hex.js.map +1 -1
- package/dist/conversions/hsl.d.ts +1 -1
- package/dist/conversions/hsl.d.ts.map +1 -1
- package/dist/conversions/hsl.js +2 -2
- package/dist/conversions/hsl.js.map +1 -1
- package/dist/conversions/hsv.d.ts +1 -1
- package/dist/conversions/hsv.d.ts.map +1 -1
- package/dist/conversions/hsv.js +2 -2
- package/dist/conversions/hsv.js.map +1 -1
- package/dist/conversions/index.d.ts +5 -5
- package/dist/conversions/index.d.ts.map +1 -1
- package/dist/conversions/index.js +5 -5
- package/dist/conversions/index.js.map +1 -1
- package/dist/conversions/pantone.d.ts +9 -7
- package/dist/conversions/pantone.d.ts.map +1 -1
- package/dist/conversions/pantone.js +11 -10
- package/dist/conversions/pantone.js.map +1 -1
- package/dist/conversions/rgb.d.ts +1 -1
- package/dist/conversions/rgb.d.ts.map +1 -1
- package/dist/conversions/rgb.js +1 -1
- package/dist/conversions/rgb.js.map +1 -1
- package/dist/convert.d.ts +45 -5
- package/dist/convert.d.ts.map +1 -1
- package/dist/convert.js +68 -17
- package/dist/convert.js.map +1 -1
- package/dist/detectFormat.d.ts +1 -1
- package/dist/detectFormat.d.ts.map +1 -1
- package/dist/detectFormat.js +2 -6
- package/dist/detectFormat.js.map +1 -1
- package/dist/identify.d.ts +41 -19
- package/dist/identify.d.ts.map +1 -1
- package/dist/identify.js +37 -22
- package/dist/identify.js.map +1 -1
- package/dist/index.d.ts +15 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/dist/indexing.d.ts +48 -24
- package/dist/indexing.d.ts.map +1 -1
- package/dist/indexing.js +111 -22
- package/dist/indexing.js.map +1 -1
- package/dist/math/clamp.d.ts.map +1 -1
- package/dist/math/clamp.js.map +1 -1
- package/dist/math/colorSpace.d.ts +1 -1
- package/dist/math/colorSpace.d.ts.map +1 -1
- package/dist/math/colorSpace.js.map +1 -1
- package/dist/math/deltaE.d.ts.map +1 -1
- package/dist/math/deltaE.js.map +1 -1
- package/dist/math/editDistance.d.ts +17 -0
- package/dist/math/editDistance.d.ts.map +1 -0
- package/dist/math/editDistance.js +48 -0
- package/dist/math/editDistance.js.map +1 -0
- package/dist/math/euclideanDistance.d.ts +1 -1
- package/dist/math/euclideanDistance.d.ts.map +1 -1
- package/dist/math/euclideanDistance.js.map +1 -1
- package/dist/math/hueSector.d.ts.map +1 -1
- package/dist/math/hueSector.js.map +1 -1
- package/dist/palettes/crayola.d.ts +200 -0
- package/dist/palettes/crayola.d.ts.map +1 -0
- package/dist/palettes/crayola.js +121 -0
- package/dist/palettes/crayola.js.map +1 -0
- package/dist/palettes/index.d.ts +5 -0
- package/dist/palettes/index.d.ts.map +1 -0
- package/dist/palettes/index.js +5 -0
- package/dist/palettes/index.js.map +1 -0
- package/dist/palettes/normalize.d.ts +17 -0
- package/dist/palettes/normalize.d.ts.map +1 -0
- package/dist/palettes/normalize.js +19 -0
- package/dist/palettes/normalize.js.map +1 -0
- package/dist/palettes/pantone.d.ts +1834 -0
- package/dist/palettes/pantone.d.ts.map +1 -0
- package/dist/palettes/pantone.js +925 -0
- package/dist/palettes/pantone.js.map +1 -0
- package/dist/palettes/web.d.ts +320 -0
- package/dist/palettes/web.d.ts.map +1 -0
- package/dist/{colorspaces → palettes}/web.js +18 -3
- package/dist/palettes/web.js.map +1 -0
- package/dist/palettes/x11.d.ts +1346 -0
- package/dist/palettes/x11.d.ts.map +1 -0
- package/dist/palettes/x11.js +686 -0
- package/dist/palettes/x11.js.map +1 -0
- package/dist/resolve.d.ts +42 -7
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +48 -20
- package/dist/resolve.js.map +1 -1
- package/dist/types.d.ts +10 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/package.json +38 -18
- package/dist/colorspaces/index.d.ts +0 -4
- package/dist/colorspaces/index.d.ts.map +0 -1
- package/dist/colorspaces/index.js +0 -4
- package/dist/colorspaces/index.js.map +0 -1
- package/dist/colorspaces/pantone.d.ts +0 -919
- package/dist/colorspaces/pantone.d.ts.map +0 -1
- package/dist/colorspaces/pantone.js +0 -918
- package/dist/colorspaces/pantone.js.map +0 -1
- package/dist/colorspaces/registry.d.ts +0 -26
- package/dist/colorspaces/registry.d.ts.map +0 -1
- package/dist/colorspaces/registry.js +0 -36
- package/dist/colorspaces/registry.js.map +0 -1
- package/dist/colorspaces/web.d.ts +0 -156
- package/dist/colorspaces/web.d.ts.map +0 -1
- package/dist/colorspaces/web.js.map +0 -1
- package/dist/colorspaces/x11.d.ts +0 -667
- package/dist/colorspaces/x11.d.ts.map +0 -1
- package/dist/colorspaces/x11.js +0 -666
- package/dist/colorspaces/x11.js.map +0 -1
package/dist/indexing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexing.js","sourceRoot":"","sources":["../src/indexing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAgB9D,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAE/F;;;GAGG;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C,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9E,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { hexToRgba } from './conversions/hex.js';\nimport { rgbaToLab, rgbaToLinearRgb, rgbaToOklab } from './math/colorSpace.js';\nimport { deltaE76Squared, deltaE94, deltaE2000, deltaEokSquared } from './math/deltaE.js';\nimport { squaredDistanceRgb } from './math/euclideanDistance.js';\nimport type { DistanceMetric, HexColor, NormalizeFn, Palette, Rgba } from './types.js';\n\n/**\n * Per-palette lookup indexes for name resolution and nearest-match.\n *\n * Caches are keyed by the Palette wrapper (WeakMap), so each palette's\n * indexes are built once per process and reused by every caller —\n * including BYO palettes the user supplies.\n */\n\n// Re-export normalizers from their own module for backward compat with any\n// caller that expected them here. The functions live in ./palettes/normalize\n// so palette modules can import them without pulling this file's math graph.\nexport { pantoneNormalize, standardNormalize } from './palettes/normalize.js';\nexport type { NormalizeFn };\n\ntype AnyPalette = Palette<string>;\n\nconst nameIndexCache = new WeakMap<AnyPalette, Map<string, string>>();\nconst rgbaIndexCache = new WeakMap<AnyPalette, Array<readonly [string, Rgba]>>();\n\n/**\n * Normalized-name → canonical-key map for a given palette. Built once\n * per palette using its own `normalize` function.\n */\nexport function getNameIndex(space: AnyPalette): Map<string, string> {\n let idx = nameIndexCache.get(space);\n if (idx === undefined) {\n idx = new Map();\n const { normalize } = space;\n for (const key of Object.keys(space.colors)) {\n idx.set(normalize(key), key);\n }\n nameIndexCache.set(space, idx);\n }\n return idx;\n}\n\nconst reverseIndexCache = new WeakMap<AnyPalette, Map<string, string>>();\n\n/**\n * Hex → canonical-key map (reverse of `palette.colors`). Built once per\n * palette. Used by `convert(color, { palette, format: 'NAME' })` for\n * O(1) exact reverse lookup. Returns `undefined` on miss — the caller\n * decides whether that's an error (convert throws; use `identify` for\n * nearest-match semantics).\n *\n * Hex values are lowercased for the key so callers can normalize their\n * input with `rgbaToHex(...).toLowerCase()` before lookup.\n */\nexport function getReverseNameIndex(space: AnyPalette): Map<string, string> {\n let idx = reverseIndexCache.get(space);\n if (idx === undefined) {\n idx = new Map();\n for (const [name, hex] of Object.entries(space.colors)) {\n idx.set((hex as string).toLowerCase(), name);\n }\n reverseIndexCache.set(space, idx);\n }\n return idx;\n}\n\n/**\n * Canonical-key → Rgba entries for a given palette, built by parsing\n * each hex value once. Used by nearest-match lookups (identify, rgbaToPantone).\n */\nexport function getRgbaIndex(space: AnyPalette): Array<readonly [string, Rgba]> {\n let idx = rgbaIndexCache.get(space);\n if (idx === undefined) {\n idx = Object.entries(space.colors).map(\n ([name, hex]) => [name, hexToRgba(hex as HexColor)] as const,\n );\n rgbaIndexCache.set(space, idx);\n }\n return idx;\n}\n\n/**\n * Find the nearest-named entry in a palette to the given Rgba, using\n * squared Euclidean distance in sRGB (alpha ignored). Used by `identify`\n * and `rgbaToPantone` when metric === 'euclidean-srgb'.\n */\nexport function nearestByRgb(target: Rgba, space: AnyPalette): string {\n const entries = getRgbaIndex(space);\n let bestName = entries[0]?.[0] ?? '';\n let bestDistance = Number.POSITIVE_INFINITY;\n for (const [name, candidate] of entries) {\n const d = squaredDistanceRgb(target, candidate);\n if (d < bestDistance) {\n bestDistance = d;\n bestName = name;\n }\n }\n return bestName;\n}\n\n// Precomputed Lab entries for delta-E metrics. Same shape as rgba index.\ntype LabTriple = readonly [number, number, number];\nconst labIndexCache = new WeakMap<AnyPalette, Array<readonly [string, LabTriple]>>();\n\nfunction getLabIndex(space: AnyPalette): Array<readonly [string, LabTriple]> {\n let idx = labIndexCache.get(space);\n if (idx === undefined) {\n idx = getRgbaIndex(space).map(([name, rgba]) => [name, rgbaToLab(rgba)] as const);\n labIndexCache.set(space, idx);\n }\n return idx;\n}\n\n// Precomputed linear-RGB entries for euclidean-linear metric.\nconst linearIndexCache = new WeakMap<AnyPalette, Array<readonly [string, LabTriple]>>();\n\nfunction getLinearIndex(space: AnyPalette): Array<readonly [string, LabTriple]> {\n let idx = linearIndexCache.get(space);\n if (idx === undefined) {\n idx = getRgbaIndex(space).map(([name, rgba]) => [name, rgbaToLinearRgb(rgba)] as const);\n linearIndexCache.set(space, idx);\n }\n return idx;\n}\n\n// Precomputed OKLAB entries for deltaEok metric.\nconst oklabIndexCache = new WeakMap<AnyPalette, Array<readonly [string, LabTriple]>>();\n\nfunction getOklabIndex(space: AnyPalette): Array<readonly [string, LabTriple]> {\n let idx = oklabIndexCache.get(space);\n if (idx === undefined) {\n idx = getRgbaIndex(space).map(([name, rgba]) => [name, rgbaToOklab(rgba)] as const);\n oklabIndexCache.set(space, idx);\n }\n return idx;\n}\n\n/**\n * Generic argmin over an `[name, value]` entries array with a custom\n * distance function. Factored so the three metric branches in `nearest`\n * share one loop body instead of duplicating it three times.\n */\nfunction argminBy<T>(\n entries: Array<readonly [string, T]>,\n target: T,\n dist: (a: T, b: T) => number,\n): string {\n let bestName = entries[0]?.[0] ?? '';\n let bestDistance = Number.POSITIVE_INFINITY;\n for (const [name, candidate] of entries) {\n const d = dist(target, candidate);\n if (d < bestDistance) {\n bestDistance = d;\n bestName = name;\n }\n }\n return bestName;\n}\n\n// Squared Euclidean on a [number, number, number] triple. Used for the\n// linear-RGB metric (sharing shape with Lab but different meaning).\nfunction squaredDistanceTriple(a: LabTriple, b: LabTriple): number {\n const d0 = a[0] - b[0];\n const d1 = a[1] - b[1];\n const d2 = a[2] - b[2];\n return d0 * d0 + d1 * d1 + d2 * d2;\n}\n\n/**\n * Find the nearest-named entry in a palette under the specified distance\n * metric. Dispatches to the right index (rgba / linear-rgb / Lab) and\n * the right distance function. See `DistanceMetric` in types.ts for how\n * to pick a metric.\n *\n * `metric` is required — callers should pass `space.defaultMetric` if\n * they want the palette's declared preference. A silent default would\n * hide the distance-metric choice from the hot path.\n */\nexport function nearest(target: Rgba, space: AnyPalette, metric: DistanceMetric): string {\n if (metric === 'euclidean-srgb') return nearestByRgb(target, space);\n if (metric === 'euclidean-linear') {\n return argminBy(getLinearIndex(space), rgbaToLinearRgb(target), squaredDistanceTriple);\n }\n if (metric === 'deltaEok') {\n return argminBy(getOklabIndex(space), rgbaToOklab(target), deltaEokSquared);\n }\n const labTarget = rgbaToLab(target);\n const labIndex = getLabIndex(space);\n if (metric === 'deltaE76') return argminBy(labIndex, labTarget, deltaE76Squared);\n if (metric === 'deltaE94') return argminBy(labIndex, labTarget, deltaE94);\n return argminBy(labIndex, labTarget, deltaE2000);\n}\n\n/**\n * Rank every palette entry by distance to `target`. Returns an array of\n * `{ name, distance }` sorted ascending (nearest first). Optional `k`\n * truncates to the top-k matches.\n *\n * Distances are **real** metric values (not squared) — ΔE76 / ΔE94 /\n * ΔE2000 / ΔE-OK are in standard ΔE units (≈1 = just-noticeable for\n * most of the gamut on ΔE76/2000); `euclidean-srgb` / `euclidean-linear`\n * are in their respective channel-unit Euclidean distances.\n *\n * Cost: O(n log n) for the sort vs O(n) for `nearest` — acceptable for\n * top-K queries. For strict \"what's the single nearest?\" stay on\n * `nearest` / `identify`.\n */\nexport function nearestAll(\n target: Rgba,\n space: AnyPalette,\n metric: DistanceMetric,\n k?: number,\n): Array<{ name: string; distance: number }> {\n const ranked: Array<[string, number]> = [];\n\n if (metric === 'euclidean-srgb') {\n for (const [name, candidate] of getRgbaIndex(space)) {\n ranked.push([name, Math.sqrt(squaredDistanceRgb(target, candidate))]);\n }\n } else if (metric === 'euclidean-linear') {\n const tgt = rgbaToLinearRgb(target);\n for (const [name, candidate] of getLinearIndex(space)) {\n ranked.push([name, Math.sqrt(squaredDistanceTriple(tgt, candidate))]);\n }\n } else if (metric === 'deltaEok') {\n const tgt = rgbaToOklab(target);\n for (const [name, candidate] of getOklabIndex(space)) {\n ranked.push([name, Math.sqrt(deltaEokSquared(tgt, candidate))]);\n }\n } else {\n const tgt = rgbaToLab(target);\n const labIndex = getLabIndex(space);\n if (metric === 'deltaE76') {\n for (const [name, candidate] of labIndex) {\n ranked.push([name, Math.sqrt(deltaE76Squared(tgt, candidate))]);\n }\n } else if (metric === 'deltaE94') {\n for (const [name, candidate] of labIndex) {\n ranked.push([name, deltaE94(tgt, candidate)]);\n }\n } else {\n for (const [name, candidate] of labIndex) {\n ranked.push([name, deltaE2000(tgt, candidate)]);\n }\n }\n }\n\n ranked.sort((a, b) => a[1] - b[1]);\n const limit = k === undefined ? ranked.length : Math.min(Math.max(k, 0), ranked.length);\n const result: Array<{ name: string; distance: number }> = new Array(limit);\n for (let i = 0; i < limit; i++) {\n const entry = ranked[i];\n if (entry !== undefined) result[i] = { name: entry[0], distance: entry[1] };\n }\n return result;\n}\n"]}
|
package/dist/math/clamp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clamp.d.ts","sourceRoot":"","sources":["../../src/math/clamp.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK/D"}
|
|
1
|
+
{"version":3,"file":"clamp.d.ts","sourceRoot":"","sources":["../../src/math/clamp.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK/D","sourcesContent":["/**\n * Clamp n to [lo, hi]. Caller must ensure n is a finite number.\n */\nexport function clamp(n: number, lo: number, hi: number): number {\n return Math.max(lo, Math.min(hi, n));\n}\n\n/**\n * Require a finite number at an API boundary; throws otherwise.\n * Used by converter entry points to reject NaN, Infinity, and non-numeric\n * values before they propagate through color math.\n */\nexport function requireFinite(n: unknown, label: string): number {\n if (typeof n !== 'number' || !Number.isFinite(n)) {\n throw new Error(`Expected finite number for ${label}, got ${typeof n}: ${String(n)}`);\n }\n return n;\n}\n"]}
|
package/dist/math/clamp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../src/math/clamp.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,CAAU,EAAE,KAAa;IACrD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,SAAS,OAAO,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
1
|
+
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../src/math/clamp.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,CAAU,EAAE,KAAa;IACrD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,SAAS,OAAO,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * Clamp n to [lo, hi]. Caller must ensure n is a finite number.\n */\nexport function clamp(n: number, lo: number, hi: number): number {\n return Math.max(lo, Math.min(hi, n));\n}\n\n/**\n * Require a finite number at an API boundary; throws otherwise.\n * Used by converter entry points to reject NaN, Infinity, and non-numeric\n * values before they propagate through color math.\n */\nexport function requireFinite(n: unknown, label: string): number {\n if (typeof n !== 'number' || !Number.isFinite(n)) {\n throw new Error(`Expected finite number for ${label}, got ${typeof n}: ${String(n)}`);\n }\n return n;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorSpace.d.ts","sourceRoot":"","sources":["../../src/math/colorSpace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"colorSpace.d.ts","sourceRoot":"","sources":["../../src/math/colorSpace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;GAYG;AAEH,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED,6FAA6F;AAC7F,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAEpE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAKxF;AAaD,6FAA6F;AAC7F,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAQlF;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAI9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAa1F;AAED,mCAAmC;AACnC,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAGhE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAItF;AAED,gDAAgD;AAChD,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAGtF;AAED,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAGhE","sourcesContent":["import type { Rgba } from '../types.js';\n\n/**\n * Color-space conversions needed by the perceptual distance metrics.\n *\n * Two pipelines:\n * CIELAB: sRGB (0..255) → linear RGB → XYZ (D65) → Lab\n * OKLAB: sRGB (0..255) → linear RGB → LMS (cbrt) → OKLAB\n *\n * References:\n * sRGB EOTF / companding: IEC 61966-2-1\n * sRGB → XYZ (D65): Bruce Lindbloom, http://www.brucelindbloom.com/\n * XYZ → Lab: CIE 15:2004\n * OKLAB: Ottosson, https://bottosson.github.io/posts/oklab/\n */\n\n/** sRGB → linear for a single channel in [0, 255]. Returns [0, 1]. */\nexport function srgbToLinear(channel: number): number {\n const s = channel / 255;\n return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n}\n\n/** Linear → sRGB for a single channel in [0, 1]. Returns [0, 1] (scale by 255 if needed). */\nexport function linearToSrgb(linear: number): number {\n return linear <= 0.0031308 ? 12.92 * linear : 1.055 * linear ** (1 / 2.4) - 0.055;\n}\n\n/** Rgba → linear RGB triple in [0, 1] (alpha dropped). */\nexport function rgbaToLinearRgb(rgba: Rgba): [number, number, number] {\n return [srgbToLinear(rgba.r), srgbToLinear(rgba.g), srgbToLinear(rgba.b)];\n}\n\n/**\n * Linear RGB (D65) → CIE XYZ (D65), using the standard sRGB matrix.\n * Input and output both in [0, 1] on each axis (approximately; Y = 1 is white).\n */\nexport function linearRgbToXyz(r: number, g: number, b: number): [number, number, number] {\n const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;\n const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;\n const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;\n return [x, y, z];\n}\n\n// D65 white reference (CIE 1931 2° observer).\nconst XN = 0.95047;\nconst YN = 1.0;\nconst ZN = 1.08883;\n\n// f(t) in the CIE Lab formula; cube-root with a linear toe near origin.\nfunction labF(t: number): number {\n const DELTA = 6 / 29;\n return t > DELTA ** 3 ? Math.cbrt(t) : t / (3 * DELTA ** 2) + 4 / 29;\n}\n\n/** CIE XYZ (D65) → CIE Lab. L ∈ [0, 100] approx; a,b unbounded but typically [-128, 127]. */\nexport function xyzToLab(x: number, y: number, z: number): [number, number, number] {\n const fx = labF(x / XN);\n const fy = labF(y / YN);\n const fz = labF(z / ZN);\n const l = 116 * fy - 16;\n const a = 500 * (fx - fy);\n const b = 200 * (fy - fz);\n return [l, a, b];\n}\n\n/** Rgba (sRGB, 0..255) → CIE Lab. Canonical pipeline for perceptual distance. */\nexport function rgbaToLab(rgba: Rgba): [number, number, number] {\n const [r, g, b] = rgbaToLinearRgb(rgba);\n const [x, y, z] = linearRgbToXyz(r, g, b);\n return xyzToLab(x, y, z);\n}\n\n/**\n * Linear sRGB → OKLAB (Björn Ottosson, 2020). OKLAB is strictly more\n * perceptually uniform than CIELAB, especially in the blue/purple region\n * where even CIEDE2000 has residual error. Distance in OKLAB is plain\n * Euclidean — no weighting formula needed, because the space itself is\n * designed around uniformity.\n *\n * Reference: https://bottosson.github.io/posts/oklab/\n */\nexport function linearRgbToOklab(r: number, g: number, b: number): [number, number, number] {\n const l = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b;\n const m = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b;\n const s = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b;\n\n const l_ = Math.cbrt(l);\n const m_ = Math.cbrt(m);\n const s_ = Math.cbrt(s);\n\n const L = 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_;\n const a = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;\n const b2 = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;\n return [L, a, b2];\n}\n\n/** Rgba (sRGB, 0..255) → OKLAB. */\nexport function rgbaToOklab(rgba: Rgba): [number, number, number] {\n const [r, g, b] = rgbaToLinearRgb(rgba);\n return linearRgbToOklab(r, g, b);\n}\n\n/**\n * OKLAB → OKLCh (polar form of OKLAB). L stays the same; a,b become\n * chroma and hue. Useful for hue-aware manipulation and naming strategies\n * that want to reason about hue distance independently of lightness.\n *\n * Returns [L, C, h] where C >= 0 and h is in degrees [0, 360).\n * Achromatic colors (C ≈ 0) return h = 0 by convention.\n */\nexport function oklabToOklch(L: number, a: number, b: number): [number, number, number] {\n const C = Math.sqrt(a * a + b * b);\n const h = C === 0 ? 0 : ((Math.atan2(b, a) * 180) / Math.PI + 360) % 360;\n return [L, C, h];\n}\n\n/** OKLCh → OKLAB. Inverse of `oklabToOklch`. */\nexport function oklchToOklab(L: number, C: number, h: number): [number, number, number] {\n const rad = (h * Math.PI) / 180;\n return [L, C * Math.cos(rad), C * Math.sin(rad)];\n}\n\n/** Rgba (sRGB, 0..255) → OKLCh. Composition shortcut. */\nexport function rgbaToOklch(rgba: Rgba): [number, number, number] {\n const [L, a, b] = rgbaToOklab(rgba);\n return oklabToOklch(L, a, b);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorSpace.js","sourceRoot":"","sources":["../../src/math/colorSpace.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,sEAAsE;AACtE,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,CAAC,GAAG,OAAO,GAAG,GAAG,CAAC;IACxB,OAAO,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC;AACjE,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;AACpF,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,eAAe,CAAC,IAAU;IACxC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,UAA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gba } from '../types.js';\n\n/**\n * Color-space conversions needed by the perceptual distance metrics.\n *\n * Two pipelines:\n * CIELAB: sRGB (0..255) → linear RGB → XYZ (D65) → Lab\n * OKLAB: sRGB (0..255) → linear RGB → LMS (cbrt) → OKLAB\n *\n * References:\n * sRGB EOTF / companding: IEC 61966-2-1\n * sRGB → XYZ (D65): Bruce Lindbloom, http://www.brucelindbloom.com/\n * XYZ → Lab: CIE 15:2004\n * OKLAB: Ottosson, https://bottosson.github.io/posts/oklab/\n */\n\n/** sRGB → linear for a single channel in [0, 255]. Returns [0, 1]. */\nexport function srgbToLinear(channel: number): number {\n const s = channel / 255;\n return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n}\n\n/** Linear → sRGB for a single channel in [0, 1]. Returns [0, 1] (scale by 255 if needed). */\nexport function linearToSrgb(linear: number): number {\n return linear <= 0.0031308 ? 12.92 * linear : 1.055 * linear ** (1 / 2.4) - 0.055;\n}\n\n/** Rgba → linear RGB triple in [0, 1] (alpha dropped). */\nexport function rgbaToLinearRgb(rgba: Rgba): [number, number, number] {\n return [srgbToLinear(rgba.r), srgbToLinear(rgba.g), srgbToLinear(rgba.b)];\n}\n\n/**\n * Linear RGB (D65) → CIE XYZ (D65), using the standard sRGB matrix.\n * Input and output both in [0, 1] on each axis (approximately; Y = 1 is white).\n */\nexport function linearRgbToXyz(r: number, g: number, b: number): [number, number, number] {\n const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;\n const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;\n const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;\n return [x, y, z];\n}\n\n// D65 white reference (CIE 1931 2° observer).\nconst XN = 0.95047;\nconst YN = 1.0;\nconst ZN = 1.08883;\n\n// f(t) in the CIE Lab formula; cube-root with a linear toe near origin.\nfunction labF(t: number): number {\n const DELTA = 6 / 29;\n return t > DELTA ** 3 ? Math.cbrt(t) : t / (3 * DELTA ** 2) + 4 / 29;\n}\n\n/** CIE XYZ (D65) → CIE Lab. L ∈ [0, 100] approx; a,b unbounded but typically [-128, 127]. */\nexport function xyzToLab(x: number, y: number, z: number): [number, number, number] {\n const fx = labF(x / XN);\n const fy = labF(y / YN);\n const fz = labF(z / ZN);\n const l = 116 * fy - 16;\n const a = 500 * (fx - fy);\n const b = 200 * (fy - fz);\n return [l, a, b];\n}\n\n/** Rgba (sRGB, 0..255) → CIE Lab. Canonical pipeline for perceptual distance. */\nexport function rgbaToLab(rgba: Rgba): [number, number, number] {\n const [r, g, b] = rgbaToLinearRgb(rgba);\n const [x, y, z] = linearRgbToXyz(r, g, b);\n return xyzToLab(x, y, z);\n}\n\n/**\n * Linear sRGB → OKLAB (Björn Ottosson, 2020). OKLAB is strictly more\n * perceptually uniform than CIELAB, especially in the blue/purple region\n * where even CIEDE2000 has residual error. Distance in OKLAB is plain\n * Euclidean — no weighting formula needed, because the space itself is\n * designed around uniformity.\n *\n * Reference: https://bottosson.github.io/posts/oklab/\n */\nexport function linearRgbToOklab(r: number, g: number, b: number): [number, number, number] {\n const l = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b;\n const m = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b;\n const s = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b;\n\n const l_ = Math.cbrt(l);\n const m_ = Math.cbrt(m);\n const s_ = Math.cbrt(s);\n\n const L = 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_;\n const a = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;\n const b2 = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;\n return [L, a, b2];\n}\n\n/** Rgba (sRGB, 0..255) → OKLAB. */\nexport function rgbaToOklab(rgba: Rgba): [number, number, number] {\n const [r, g, b] = rgbaToLinearRgb(rgba);\n return linearRgbToOklab(r, g, b);\n}\n\n/**\n * OKLAB → OKLCh (polar form of OKLAB). L stays the same; a,b become\n * chroma and hue. Useful for hue-aware manipulation and naming strategies\n * that want to reason about hue distance independently of lightness.\n *\n * Returns [L, C, h] where C >= 0 and h is in degrees [0, 360).\n * Achromatic colors (C ≈ 0) return h = 0 by convention.\n */\nexport function oklabToOklch(L: number, a: number, b: number): [number, number, number] {\n const C = Math.sqrt(a * a + b * b);\n const h = C === 0 ? 0 : ((Math.atan2(b, a) * 180) / Math.PI + 360) % 360;\n return [L, C, h];\n}\n\n/** OKLCh → OKLAB. Inverse of `oklabToOklch`. */\nexport function oklchToOklab(L: number, C: number, h: number): [number, number, number] {\n const rad = (h * Math.PI) / 180;\n return [L, C * Math.cos(rad), C * Math.sin(rad)];\n}\n\n/** Rgba (sRGB, 0..255) → OKLCh. Composition shortcut. */\nexport function rgbaToOklch(rgba: Rgba): [number, number, number] {\n const [L, a, b] = rgbaToOklab(rgba);\n return oklabToOklch(L, a, b);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaE.d.ts","sourceRoot":"","sources":["../../src/math/deltaE.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAKtD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAE/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAwB/C;AAgCD,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,SAAI,EAAE,EAAE,SAAI,EAAE,EAAE,SAAI,GAAG,MAAM,CAoFzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAKtD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAE/C"}
|
|
1
|
+
{"version":3,"file":"deltaE.d.ts","sourceRoot":"","sources":["../../src/math/deltaE.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAKtD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAE/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAwB/C;AAgCD,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,SAAI,EAAE,EAAE,SAAI,EAAE,EAAE,SAAI,GAAG,MAAM,CAoFzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAKtD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAE/C","sourcesContent":["/**\n * Color-difference metrics. Inputs are `Lab` triples (L, a, b). The\n * CIELAB family (ΔE*76 / ΔE*94 / ΔE*00) takes coordinates from\n * `rgbaToLab`; ΔE*ok takes coordinates from `rgbaToOklab`. Both spaces\n * share the `Lab` tuple shape but are not interchangeable — see\n * `deltaEokSquared` below.\n *\n * Within the CIELAB family, the metrics differ in how each region of\n * Lab space is weighted:\n * ΔE*76 — simple Euclidean in Lab (CIE 1976). Fast, decent.\n * ΔE*94 — adds chroma/hue weighting (CIE 1994). Better saturation handling.\n * ΔE00 — also adjusts L/C/h + rotation correction in blue-purple region\n * (CIE 2000, aka CIEDE2000). Current industry standard.\n *\n * References:\n * CIE 15:2004 (Colorimetry), CIE TC1-29 (ΔE2000).\n * G. Sharma, W. Wu, E.N. Dalal, \"The CIEDE2000 Color-Difference Formula\"\n * (Color Research & Application, 2005) — canonical test vectors.\n */\n\nexport type Lab = readonly [l: number, a: number, b: number];\n\n/**\n * ΔE*ab (CIE 1976). Simple Euclidean distance in Lab.\n * Returns the *square* for speed — identify loops only need argmin, and\n * sqrt is monotonic. Use `deltaE76` if you need the actual distance.\n */\nexport function deltaE76Squared(p: Lab, q: Lab): number {\n const dl = p[0] - q[0];\n const da = p[1] - q[1];\n const db = p[2] - q[2];\n return dl * dl + da * da + db * db;\n}\n\nexport function deltaE76(p: Lab, q: Lab): number {\n return Math.sqrt(deltaE76Squared(p, q));\n}\n\n/**\n * ΔE*94 (CIE 1994). Weights the chroma and hue contributions relative to\n * Lab Euclidean distance — fixes the \"saturated colors feel too far apart\"\n * problem of ΔE*76. Uses graphic-arts constants (kL=1, K1=0.045, K2=0.015).\n *\n * Not symmetric in the strict sense (reference vs sample), but we treat\n * both inputs as graphic-arts samples — the formula reduces to a\n * symmetric form below.\n */\nexport function deltaE94(p: Lab, q: Lab): number {\n const [l1, a1, b1] = p;\n const [l2, a2, b2] = q;\n const dL = l1 - l2;\n const c1 = Math.hypot(a1, b1);\n const c2 = Math.hypot(a2, b2);\n const dC = c1 - c2;\n const da = a1 - a2;\n const db = b1 - b2;\n const dH2 = da * da + db * db - dC * dC;\n // dH² can go slightly negative due to floating-point — clamp.\n const dH2Safe = dH2 < 0 ? 0 : dH2;\n\n const K1 = 0.045;\n const K2 = 0.015;\n const sL = 1;\n const sC = 1 + K1 * c1;\n const sH = 1 + K2 * c1;\n\n const termL = dL / sL;\n const termC = dC / sC;\n const termH = Math.sqrt(dH2Safe) / sH;\n\n return Math.sqrt(termL * termL + termC * termC + termH * termH);\n}\n\n// ---- ΔE00 helpers --------------------------------------------------------\n\nconst DEG = Math.PI / 180;\nconst RAD = 180 / Math.PI;\n\nfunction hueDeg(b: number, a: number): number {\n if (b === 0 && a === 0) return 0;\n return (Math.atan2(b, a) * RAD + 360) % 360;\n}\n\n/**\n * ΔE*00 (CIE 2000 / CIEDE2000). Current industry-standard perceptual\n * color-difference formula. Fixes the saturated-blue failure of ΔE76/94\n * with a rotation term in the blue-purple region (h ≈ 275°).\n *\n * kL / kC / kH are parametric factors (default 1/1/1 = graphic arts).\n * Reference: G. Sharma, W. Wu, E.N. Dalal, \"The CIEDE2000 Color-Difference\n * Formula\" (Color Research & Application, 2005).\n */\n// Precomputed constant: 25^7 = 6,103,515,625. Appears twice in the formula.\nconst POW_25_7 = 6103515625;\n\n// Inline pow(x, 7) — Math.pow with non-integer exponent is slower in V8\n// than three multiplies. x² → x⁴ → x⁶·x.\nfunction pow7(x: number): number {\n const x2 = x * x;\n const x4 = x2 * x2;\n return x4 * x2 * x;\n}\n\nexport function deltaE2000(p: Lab, q: Lab, kL = 1, kC = 1, kH = 1): number {\n const l1 = p[0];\n const a1 = p[1];\n const b1 = p[2];\n const l2 = q[0];\n const a2 = q[1];\n const b2 = q[2];\n\n // Chromas and mean chroma. Lab values stay within ±150 so overflow\n // protection in Math.hypot is unnecessary — plain sqrt(a²+b²) is ~3×\n // faster in V8 and more than precise enough for our range.\n const c1 = Math.sqrt(a1 * a1 + b1 * b1);\n const c2 = Math.sqrt(a2 * a2 + b2 * b2);\n const cBar = (c1 + c2) / 2;\n const cBar7 = pow7(cBar);\n\n // G-factor boost for a* in low-chroma regions.\n const g = 0.5 * (1 - Math.sqrt(cBar7 / (cBar7 + POW_25_7)));\n const a1p = (1 + g) * a1;\n const a2p = (1 + g) * a2;\n\n // Primed chroma and hue.\n const c1p = Math.sqrt(a1p * a1p + b1 * b1);\n const c2p = Math.sqrt(a2p * a2p + b2 * b2);\n const h1p = hueDeg(b1, a1p);\n const h2p = hueDeg(b2, a2p);\n\n // Differences.\n const dLp = l2 - l1;\n const dCp = c2p - c1p;\n\n let dhp: number;\n if (c1p * c2p === 0) {\n dhp = 0;\n } else {\n const raw = h2p - h1p;\n if (Math.abs(raw) <= 180) dhp = raw;\n else if (raw > 180) dhp = raw - 360;\n else dhp = raw + 360;\n }\n const dHp = 2 * Math.sqrt(c1p * c2p) * Math.sin((dhp * DEG) / 2);\n\n // Means.\n const lBarP = (l1 + l2) / 2;\n const cBarP = (c1p + c2p) / 2;\n\n let hBarP: number;\n if (c1p * c2p === 0) {\n hBarP = h1p + h2p;\n } else if (Math.abs(h1p - h2p) <= 180) {\n hBarP = (h1p + h2p) / 2;\n } else if (h1p + h2p < 360) {\n hBarP = (h1p + h2p + 360) / 2;\n } else {\n hBarP = (h1p + h2p - 360) / 2;\n }\n\n // Weighting function T.\n const hBarRad = hBarP * DEG;\n const t =\n 1 -\n 0.17 * Math.cos(hBarRad - 30 * DEG) +\n 0.24 * Math.cos(2 * hBarRad) +\n 0.32 * Math.cos(3 * hBarRad + 6 * DEG) -\n 0.2 * Math.cos(4 * hBarRad - 63 * DEG);\n\n // Lightness, chroma, hue weighting factors.\n const lBarMinus50Sq = (lBarP - 50) ** 2;\n const sL = 1 + (0.015 * lBarMinus50Sq) / Math.sqrt(20 + lBarMinus50Sq);\n const sC = 1 + 0.045 * cBarP;\n const sH = 1 + 0.015 * cBarP * t;\n\n // Rotation term — the blue-purple correction that ΔE94 lacks.\n const hShift = (hBarP - 275) / 25;\n const dTheta = 30 * Math.exp(-(hShift * hShift));\n const cBarP7 = pow7(cBarP);\n const rC = 2 * Math.sqrt(cBarP7 / (cBarP7 + POW_25_7));\n const rT = -Math.sin(2 * dTheta * DEG) * rC;\n\n const termL = dLp / (kL * sL);\n const termC = dCp / (kC * sC);\n const termH = dHp / (kH * sH);\n\n return Math.sqrt(termL * termL + termC * termC + termH * termH + rT * termC * termH);\n}\n\n/**\n * Squared Euclidean distance in OKLAB space (Björn Ottosson, 2020).\n * OKLAB is perceptually uniform by construction — plain Euclidean IS the\n * perceptual distance, no weighting needed. Returns the square for\n * argmin speed; `deltaEok` returns the actual distance.\n *\n * Often gives more visually-accurate nearest-matches than CIEDE2000 in\n * the saturated blue/purple region.\n *\n * NOTE: the body is byte-identical to `deltaE76Squared` — both compute\n * `dl² + da² + db²`. The semantic difference is entirely in *which* space\n * the caller passes coordinates from: CIELAB (for ΔE*76) vs OKLAB (for this).\n * Kept separate so callers and tests can't cross-wire the indexes.\n */\nexport function deltaEokSquared(p: Lab, q: Lab): number {\n const dl = p[0] - q[0];\n const da = p[1] - q[1];\n const db = p[2] - q[2];\n return dl * dl + da * da + db * db;\n}\n\nexport function deltaEok(p: Lab, q: Lab): number {\n return Math.sqrt(deltaEokSquared(p, q));\n}\n"]}
|
package/dist/math/deltaE.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaE.js","sourceRoot":"","sources":["../../src/math/deltaE.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,CAAM,EAAE,CAAM;IAC5C,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACrC,CAA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M;IACrC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/**\n * Color-difference metrics. Inputs are `Lab` triples (L, a, b). The\n * CIELAB family (ΔE*76 / ΔE*94 / ΔE*00) takes coordinates from\n * `rgbaToLab`; ΔE*ok takes coordinates from `rgbaToOklab`. Both spaces\n * share the `Lab` tuple shape but are not interchangeable — see\n * `deltaEokSquared` below.\n *\n * Within the CIELAB family, the metrics differ in how each region of\n * Lab space is weighted:\n * ΔE*76 — simple Euclidean in Lab (CIE 1976). Fast, decent.\n * ΔE*94 — adds chroma/hue weighting (CIE 1994). Better saturation handling.\n * ΔE00 — also adjusts L/C/h + rotation correction in blue-purple region\n * (CIE 2000, aka CIEDE2000). Current industry standard.\n *\n * References:\n * CIE 15:2004 (Colorimetry), CIE TC1-29 (ΔE2000).\n * G. Sharma, W. Wu, E.N. Dalal, \"The CIEDE2000 Color-Difference Formula\"\n * (Color Research & Application, 2005) — canonical test vectors.\n */\n\nexport type Lab = readonly [l: number, a: number, b: number];\n\n/**\n * ΔE*ab (CIE 1976). Simple Euclidean distance in Lab.\n * Returns the *square* for speed — identify loops only need argmin, and\n * sqrt is monotonic. Use `deltaE76` if you need the actual distance.\n */\nexport function deltaE76Squared(p: Lab, q: Lab): number {\n const dl = p[0] - q[0];\n const da = p[1] - q[1];\n const db = p[2] - q[2];\n return dl * dl + da * da + db * db;\n}\n\nexport function deltaE76(p: Lab, q: Lab): number {\n return Math.sqrt(deltaE76Squared(p, q));\n}\n\n/**\n * ΔE*94 (CIE 1994). Weights the chroma and hue contributions relative to\n * Lab Euclidean distance — fixes the \"saturated colors feel too far apart\"\n * problem of ΔE*76. Uses graphic-arts constants (kL=1, K1=0.045, K2=0.015).\n *\n * Not symmetric in the strict sense (reference vs sample), but we treat\n * both inputs as graphic-arts samples — the formula reduces to a\n * symmetric form below.\n */\nexport function deltaE94(p: Lab, q: Lab): number {\n const [l1, a1, b1] = p;\n const [l2, a2, b2] = q;\n const dL = l1 - l2;\n const c1 = Math.hypot(a1, b1);\n const c2 = Math.hypot(a2, b2);\n const dC = c1 - c2;\n const da = a1 - a2;\n const db = b1 - b2;\n const dH2 = da * da + db * db - dC * dC;\n // dH² can go slightly negative due to floating-point — clamp.\n const dH2Safe = dH2 < 0 ? 0 : dH2;\n\n const K1 = 0.045;\n const K2 = 0.015;\n const sL = 1;\n const sC = 1 + K1 * c1;\n const sH = 1 + K2 * c1;\n\n const termL = dL / sL;\n const termC = dC / sC;\n const termH = Math.sqrt(dH2Safe) / sH;\n\n return Math.sqrt(termL * termL + termC * termC + termH * termH);\n}\n\n// ---- ΔE00 helpers --------------------------------------------------------\n\nconst DEG = Math.PI / 180;\nconst RAD = 180 / Math.PI;\n\nfunction hueDeg(b: number, a: number): number {\n if (b === 0 && a === 0) return 0;\n return (Math.atan2(b, a) * RAD + 360) % 360;\n}\n\n/**\n * ΔE*00 (CIE 2000 / CIEDE2000). Current industry-standard perceptual\n * color-difference formula. Fixes the saturated-blue failure of ΔE76/94\n * with a rotation term in the blue-purple region (h ≈ 275°).\n *\n * kL / kC / kH are parametric factors (default 1/1/1 = graphic arts).\n * Reference: G. Sharma, W. Wu, E.N. Dalal, \"The CIEDE2000 Color-Difference\n * Formula\" (Color Research & Application, 2005).\n */\n// Precomputed constant: 25^7 = 6,103,515,625. Appears twice in the formula.\nconst POW_25_7 = 6103515625;\n\n// Inline pow(x, 7) — Math.pow with non-integer exponent is slower in V8\n// than three multiplies. x² → x⁴ → x⁶·x.\nfunction pow7(x: number): number {\n const x2 = x * x;\n const x4 = x2 * x2;\n return x4 * x2 * x;\n}\n\nexport function deltaE2000(p: Lab, q: Lab, kL = 1, kC = 1, kH = 1): number {\n const l1 = p[0];\n const a1 = p[1];\n const b1 = p[2];\n const l2 = q[0];\n const a2 = q[1];\n const b2 = q[2];\n\n // Chromas and mean chroma. Lab values stay within ±150 so overflow\n // protection in Math.hypot is unnecessary — plain sqrt(a²+b²) is ~3×\n // faster in V8 and more than precise enough for our range.\n const c1 = Math.sqrt(a1 * a1 + b1 * b1);\n const c2 = Math.sqrt(a2 * a2 + b2 * b2);\n const cBar = (c1 + c2) / 2;\n const cBar7 = pow7(cBar);\n\n // G-factor boost for a* in low-chroma regions.\n const g = 0.5 * (1 - Math.sqrt(cBar7 / (cBar7 + POW_25_7)));\n const a1p = (1 + g) * a1;\n const a2p = (1 + g) * a2;\n\n // Primed chroma and hue.\n const c1p = Math.sqrt(a1p * a1p + b1 * b1);\n const c2p = Math.sqrt(a2p * a2p + b2 * b2);\n const h1p = hueDeg(b1, a1p);\n const h2p = hueDeg(b2, a2p);\n\n // Differences.\n const dLp = l2 - l1;\n const dCp = c2p - c1p;\n\n let dhp: number;\n if (c1p * c2p === 0) {\n dhp = 0;\n } else {\n const raw = h2p - h1p;\n if (Math.abs(raw) <= 180) dhp = raw;\n else if (raw > 180) dhp = raw - 360;\n else dhp = raw + 360;\n }\n const dHp = 2 * Math.sqrt(c1p * c2p) * Math.sin((dhp * DEG) / 2);\n\n // Means.\n const lBarP = (l1 + l2) / 2;\n const cBarP = (c1p + c2p) / 2;\n\n let hBarP: number;\n if (c1p * c2p === 0) {\n hBarP = h1p + h2p;\n } else if (Math.abs(h1p - h2p) <= 180) {\n hBarP = (h1p + h2p) / 2;\n } else if (h1p + h2p < 360) {\n hBarP = (h1p + h2p + 360) / 2;\n } else {\n hBarP = (h1p + h2p - 360) / 2;\n }\n\n // Weighting function T.\n const hBarRad = hBarP * DEG;\n const t =\n 1 -\n 0.17 * Math.cos(hBarRad - 30 * DEG) +\n 0.24 * Math.cos(2 * hBarRad) +\n 0.32 * Math.cos(3 * hBarRad + 6 * DEG) -\n 0.2 * Math.cos(4 * hBarRad - 63 * DEG);\n\n // Lightness, chroma, hue weighting factors.\n const lBarMinus50Sq = (lBarP - 50) ** 2;\n const sL = 1 + (0.015 * lBarMinus50Sq) / Math.sqrt(20 + lBarMinus50Sq);\n const sC = 1 + 0.045 * cBarP;\n const sH = 1 + 0.015 * cBarP * t;\n\n // Rotation term — the blue-purple correction that ΔE94 lacks.\n const hShift = (hBarP - 275) / 25;\n const dTheta = 30 * Math.exp(-(hShift * hShift));\n const cBarP7 = pow7(cBarP);\n const rC = 2 * Math.sqrt(cBarP7 / (cBarP7 + POW_25_7));\n const rT = -Math.sin(2 * dTheta * DEG) * rC;\n\n const termL = dLp / (kL * sL);\n const termC = dCp / (kC * sC);\n const termH = dHp / (kH * sH);\n\n return Math.sqrt(termL * termL + termC * termC + termH * termH + rT * termC * termH);\n}\n\n/**\n * Squared Euclidean distance in OKLAB space (Björn Ottosson, 2020).\n * OKLAB is perceptually uniform by construction — plain Euclidean IS the\n * perceptual distance, no weighting needed. Returns the square for\n * argmin speed; `deltaEok` returns the actual distance.\n *\n * Often gives more visually-accurate nearest-matches than CIEDE2000 in\n * the saturated blue/purple region.\n *\n * NOTE: the body is byte-identical to `deltaE76Squared` — both compute\n * `dl² + da² + db²`. The semantic difference is entirely in *which* space\n * the caller passes coordinates from: CIELAB (for ΔE*76) vs OKLAB (for this).\n * Kept separate so callers and tests can't cross-wire the indexes.\n */\nexport function deltaEokSquared(p: Lab, q: Lab): number {\n const dl = p[0] - q[0];\n const da = p[1] - q[1];\n const db = p[2] - q[2];\n return dl * dl + da * da + db * db;\n}\n\nexport function deltaEok(p: Lab, q: Lab): number {\n return Math.sqrt(deltaEokSquared(p, q));\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Levenshtein edit distance between two strings. Classic dynamic-programming
|
|
3
|
+
* implementation; returns the minimum number of single-character insertions,
|
|
4
|
+
* deletions, or substitutions required to transform `a` into `b`.
|
|
5
|
+
*
|
|
6
|
+
* Used by `resolve(_, { k })` for fuzzy-name matching — operating on the
|
|
7
|
+
* palette's already-normalized keys (lowercase, alphanumeric) so typos,
|
|
8
|
+
* casing, and punctuation all reduce to the same canonical forms before
|
|
9
|
+
* the edit distance is measured.
|
|
10
|
+
*
|
|
11
|
+
* Space-optimized: uses two rolling rows instead of a full n×m matrix
|
|
12
|
+
* (O(min(n,m)) space, O(n·m) time). For palette keys (< 20 chars each)
|
|
13
|
+
* this runs sub-microsecond per pair, so a full scan over 907 Pantone
|
|
14
|
+
* entries fits well inside a millisecond.
|
|
15
|
+
*/
|
|
16
|
+
export declare function levenshtein(a: string, b: string): number;
|
|
17
|
+
//# sourceMappingURL=editDistance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editDistance.d.ts","sourceRoot":"","sources":["../../src/math/editDistance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BxD","sourcesContent":["/**\n * Levenshtein edit distance between two strings. Classic dynamic-programming\n * implementation; returns the minimum number of single-character insertions,\n * deletions, or substitutions required to transform `a` into `b`.\n *\n * Used by `resolve(_, { k })` for fuzzy-name matching — operating on the\n * palette's already-normalized keys (lowercase, alphanumeric) so typos,\n * casing, and punctuation all reduce to the same canonical forms before\n * the edit distance is measured.\n *\n * Space-optimized: uses two rolling rows instead of a full n×m matrix\n * (O(min(n,m)) space, O(n·m) time). For palette keys (< 20 chars each)\n * this runs sub-microsecond per pair, so a full scan over 907 Pantone\n * entries fits well inside a millisecond.\n */\nexport function levenshtein(a: string, b: string): number {\n if (a === b) return 0;\n if (a.length === 0) return b.length;\n if (b.length === 0) return a.length;\n\n // Ensure `a` is the shorter string so the rolling row is minimal.\n if (a.length > b.length) [a, b] = [b, a];\n\n const aLen = a.length;\n const bLen = b.length;\n\n // `prev[i]` = edit distance between a[0..i] and b[0..j-1] (previous row).\n // `curr[i]` = edit distance between a[0..i] and b[0..j] (current row).\n let prev = new Array<number>(aLen + 1);\n let curr = new Array<number>(aLen + 1);\n for (let i = 0; i <= aLen; i++) prev[i] = i;\n\n for (let j = 1; j <= bLen; j++) {\n curr[0] = j;\n const bj = b.charCodeAt(j - 1);\n for (let i = 1; i <= aLen; i++) {\n const cost = a.charCodeAt(i - 1) === bj ? 0 : 1;\n const deletion = (prev[i] ?? 0) + 1;\n const insertion = (curr[i - 1] ?? 0) + 1;\n const substitution = (prev[i - 1] ?? 0) + cost;\n curr[i] = Math.min(deletion, insertion, substitution);\n }\n [prev, curr] = [curr, prev];\n }\n return prev[aLen] ?? 0;\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Levenshtein edit distance between two strings. Classic dynamic-programming
|
|
3
|
+
* implementation; returns the minimum number of single-character insertions,
|
|
4
|
+
* deletions, or substitutions required to transform `a` into `b`.
|
|
5
|
+
*
|
|
6
|
+
* Used by `resolve(_, { k })` for fuzzy-name matching — operating on the
|
|
7
|
+
* palette's already-normalized keys (lowercase, alphanumeric) so typos,
|
|
8
|
+
* casing, and punctuation all reduce to the same canonical forms before
|
|
9
|
+
* the edit distance is measured.
|
|
10
|
+
*
|
|
11
|
+
* Space-optimized: uses two rolling rows instead of a full n×m matrix
|
|
12
|
+
* (O(min(n,m)) space, O(n·m) time). For palette keys (< 20 chars each)
|
|
13
|
+
* this runs sub-microsecond per pair, so a full scan over 907 Pantone
|
|
14
|
+
* entries fits well inside a millisecond.
|
|
15
|
+
*/
|
|
16
|
+
export function levenshtein(a, b) {
|
|
17
|
+
if (a === b)
|
|
18
|
+
return 0;
|
|
19
|
+
if (a.length === 0)
|
|
20
|
+
return b.length;
|
|
21
|
+
if (b.length === 0)
|
|
22
|
+
return a.length;
|
|
23
|
+
// Ensure `a` is the shorter string so the rolling row is minimal.
|
|
24
|
+
if (a.length > b.length)
|
|
25
|
+
[a, b] = [b, a];
|
|
26
|
+
const aLen = a.length;
|
|
27
|
+
const bLen = b.length;
|
|
28
|
+
// `prev[i]` = edit distance between a[0..i] and b[0..j-1] (previous row).
|
|
29
|
+
// `curr[i]` = edit distance between a[0..i] and b[0..j] (current row).
|
|
30
|
+
let prev = new Array(aLen + 1);
|
|
31
|
+
let curr = new Array(aLen + 1);
|
|
32
|
+
for (let i = 0; i <= aLen; i++)
|
|
33
|
+
prev[i] = i;
|
|
34
|
+
for (let j = 1; j <= bLen; j++) {
|
|
35
|
+
curr[0] = j;
|
|
36
|
+
const bj = b.charCodeAt(j - 1);
|
|
37
|
+
for (let i = 1; i <= aLen; i++) {
|
|
38
|
+
const cost = a.charCodeAt(i - 1) === bj ? 0 : 1;
|
|
39
|
+
const deletion = (prev[i] ?? 0) + 1;
|
|
40
|
+
const insertion = (curr[i - 1] ?? 0) + 1;
|
|
41
|
+
const substitution = (prev[i - 1] ?? 0) + cost;
|
|
42
|
+
curr[i] = Math.min(deletion, insertion, substitution);
|
|
43
|
+
}
|
|
44
|
+
[prev, curr] = [curr, prev];
|
|
45
|
+
}
|
|
46
|
+
return prev[aLen] ?? 0;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=editDistance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editDistance.js","sourceRoot":"","sources":["../../src/math/editDistance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAC,CAAS,EAAE,CAAS;IAC9C,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,MAAM,CAAC;IAEpC,kEAAkE;IAClE,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM;QAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEzC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,MAAM,IAAI,GAAG,CAAC,C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I,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Levenshtein edit distance between two strings. Classic dynamic-programming\n * implementation; returns the minimum number of single-character insertions,\n * deletions, or substitutions required to transform `a` into `b`.\n *\n * Used by `resolve(_, { k })` for fuzzy-name matching — operating on the\n * palette's already-normalized keys (lowercase, alphanumeric) so typos,\n * casing, and punctuation all reduce to the same canonical forms before\n * the edit distance is measured.\n *\n * Space-optimized: uses two rolling rows instead of a full n×m matrix\n * (O(min(n,m)) space, O(n·m) time). For palette keys (< 20 chars each)\n * this runs sub-microsecond per pair, so a full scan over 907 Pantone\n * entries fits well inside a millisecond.\n */\nexport function levenshtein(a: string, b: string): number {\n if (a === b) return 0;\n if (a.length === 0) return b.length;\n if (b.length === 0) return a.length;\n\n // Ensure `a` is the shorter string so the rolling row is minimal.\n if (a.length > b.length) [a, b] = [b, a];\n\n const aLen = a.length;\n const bLen = b.length;\n\n // `prev[i]` = edit distance between a[0..i] and b[0..j-1] (previous row).\n // `curr[i]` = edit distance between a[0..i] and b[0..j] (current row).\n let prev = new Array<number>(aLen + 1);\n let curr = new Array<number>(aLen + 1);\n for (let i = 0; i <= aLen; i++) prev[i] = i;\n\n for (let j = 1; j <= bLen; j++) {\n curr[0] = j;\n const bj = b.charCodeAt(j - 1);\n for (let i = 1; i <= aLen; i++) {\n const cost = a.charCodeAt(i - 1) === bj ? 0 : 1;\n const deletion = (prev[i] ?? 0) + 1;\n const insertion = (curr[i - 1] ?? 0) + 1;\n const substitution = (prev[i - 1] ?? 0) + cost;\n curr[i] = Math.min(deletion, insertion, substitution);\n }\n [prev, curr] = [curr, prev];\n }\n return prev[aLen] ?? 0;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"euclideanDistance.d.ts","sourceRoot":"","sources":["../../src/math/euclideanDistance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"euclideanDistance.d.ts","sourceRoot":"","sources":["../../src/math/euclideanDistance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAK3D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAE1D","sourcesContent":["import type { Rgba } from '../types.js';\n\n/**\n * Squared Euclidean distance between two colors in RGB space.\n * Alpha channel is ignored. Faster than `euclideanDistance` — use this\n * when you only need to compare or minimize (sqrt is monotonic, so\n * argmin(d) === argmin(d²)).\n */\nexport function squaredDistanceRgb(a: Rgba, b: Rgba): number {\n const dr = a.r - b.r;\n const dg = a.g - b.g;\n const db = a.b - b.b;\n return dr * dr + dg * dg + db * db;\n}\n\n/**\n * Euclidean distance between two colors in RGB space.\n * Alpha channel is ignored (matches classic `detect-color` behavior).\n * Not perceptually accurate — use deltaE (CIE Lab) for color matching\n * where perceptual uniformity matters.\n */\nexport function euclideanDistance(a: Rgba, b: Rgba): number {\n return Math.sqrt(squaredDistanceRgb(a, b));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"euclideanDistance.js","sourceRoot":"","sources":["../../src/math/euclideanDistance.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAO,EAAE,CAAO;IACjD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAO,EAAE,CAAO;IAChD,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
1
|
+
{"version":3,"file":"euclideanDistance.js","sourceRoot":"","sources":["../../src/math/euclideanDistance.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAO,EAAE,CAAO;IACjD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAO,EAAE,CAAO;IAChD,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { Rgba } from '../types.js';\n\n/**\n * Squared Euclidean distance between two colors in RGB space.\n * Alpha channel is ignored. Faster than `euclideanDistance` — use this\n * when you only need to compare or minimize (sqrt is monotonic, so\n * argmin(d) === argmin(d²)).\n */\nexport function squaredDistanceRgb(a: Rgba, b: Rgba): number {\n const dr = a.r - b.r;\n const dg = a.g - b.g;\n const db = a.b - b.b;\n return dr * dr + dg * dg + db * db;\n}\n\n/**\n * Euclidean distance between two colors in RGB space.\n * Alpha channel is ignored (matches classic `detect-color` behavior).\n * Not perceptually accurate — use deltaE (CIE Lab) for color matching\n * where perceptual uniformity matters.\n */\nexport function euclideanDistance(a: Rgba, b: Rgba): number {\n return Math.sqrt(squaredDistanceRgb(a, b));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hueSector.d.ts","sourceRoot":"","sources":["../../src/math/hueSector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAO1B"}
|
|
1
|
+
{"version":3,"file":"hueSector.d.ts","sourceRoot":"","sources":["../../src/math/hueSector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAO1B","sourcesContent":["/**\n * Map a normalized hue sector value (range [0, 6)) plus chroma and its\n * secondary into the primary-color tuple `[r', g', b']` used by the\n * standard HSL→RGB and HSV→RGB algorithms. Each component is in [0, chroma].\n *\n * Shared by `hslToRgba` and `hsvToRgba`: same six-sector table, different\n * formulas for chroma and the offset. The caller adds the offset and\n * scales by 255.\n *\n * hueSector = h / 60 (h wrapped to [0, 360))\n * chroma = HSL: (1 − |2l − 1|)·s ; HSV: v·s\n * secondary = chroma · (1 − |hueSector mod 2 − 1|)\n */\nexport function hueSectorToPrime(\n hueSector: number,\n chroma: number,\n secondary: number,\n): [number, number, number] {\n if (hueSector < 1) return [chroma, secondary, 0];\n if (hueSector < 2) return [secondary, chroma, 0];\n if (hueSector < 3) return [0, chroma, secondary];\n if (hueSector < 4) return [0, secondary, chroma];\n if (hueSector < 5) return [secondary, 0, chroma];\n return [chroma, 0, secondary];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hueSector.js","sourceRoot":"","sources":["../../src/math/hueSector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAiB,EACjB,MAAc,EACd,SAAiB;IAEjB,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACjD,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACjD,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACjD,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACjD,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;AAChC,CAAC"}
|
|
1
|
+
{"version":3,"file":"hueSector.js","sourceRoot":"","sources":["../../src/math/hueSector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAiB,EACjB,MAAc,EACd,SAAiB;IAEjB,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACjD,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACjD,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACjD,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACjD,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/**\n * Map a normalized hue sector value (range [0, 6)) plus chroma and its\n * secondary into the primary-color tuple `[r', g', b']` used by the\n * standard HSL→RGB and HSV→RGB algorithms. Each component is in [0, chroma].\n *\n * Shared by `hslToRgba` and `hsvToRgba`: same six-sector table, different\n * formulas for chroma and the offset. The caller adds the offset and\n * scales by 255.\n *\n * hueSector = h / 60 (h wrapped to [0, 360))\n * chroma = HSL: (1 − |2l − 1|)·s ; HSV: v·s\n * secondary = chroma · (1 − |hueSector mod 2 − 1|)\n */\nexport function hueSectorToPrime(\n hueSector: number,\n chroma: number,\n secondary: number,\n): [number, number, number] {\n if (hueSector < 1) return [chroma, secondary, 0];\n if (hueSector < 2) return [secondary, chroma, 0];\n if (hueSector < 3) return [0, chroma, secondary];\n if (hueSector < 4) return [0, secondary, chroma];\n if (hueSector < 5) return [secondary, 0, chroma];\n return [chroma, 0, secondary];\n}\n"]}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crayola crayon colors — canonical subset. ~85 entries covering the
|
|
3
|
+
* current 64-standard box, iconic fluorescents, and widely-recognized
|
|
4
|
+
* modern additions.
|
|
5
|
+
*
|
|
6
|
+
* Keys are Title Case with spaces (`'Granny Smith Apple'`,
|
|
7
|
+
* `'Razzmatazz'`) — how the names are printed on the crayon wrapper.
|
|
8
|
+
* `standardNormalize` strips spaces + case + punctuation on input, so
|
|
9
|
+
* `resolve('granny-smith-apple')` and `resolve('Granny Smith Apple')`
|
|
10
|
+
* both hit the same entry.
|
|
11
|
+
*
|
|
12
|
+
* sRGB values are community-sourced approximations (Wikipedia's
|
|
13
|
+
* well-cited list of Crayola crayon colors). They do not represent
|
|
14
|
+
* a licensed Crayola reference. See NOTICE.md for trademark note.
|
|
15
|
+
*
|
|
16
|
+
* Default metric: `deltaEok`. The Crayola set spans a wide gamut with
|
|
17
|
+
* many saturated brights (fluorescents especially) where CIELAB-based
|
|
18
|
+
* metrics are less perceptually uniform than OKLAB. Same cost profile
|
|
19
|
+
* as deltaE76, better neighbor selection in saturated regions.
|
|
20
|
+
*/
|
|
21
|
+
declare const crayolaColors: {
|
|
22
|
+
readonly Red: '#ee204d';
|
|
23
|
+
readonly 'Red Orange': '#ff5349';
|
|
24
|
+
readonly Orange: '#ff7538';
|
|
25
|
+
readonly 'Yellow Orange': '#ffae42';
|
|
26
|
+
readonly Yellow: '#fce883';
|
|
27
|
+
readonly 'Yellow Green': '#c5e384';
|
|
28
|
+
readonly Green: '#1cac78';
|
|
29
|
+
readonly 'Blue Green': '#0d98ba';
|
|
30
|
+
readonly Blue: '#1f75fe';
|
|
31
|
+
readonly 'Blue Violet': '#7366bd';
|
|
32
|
+
readonly Violet: '#926eae';
|
|
33
|
+
readonly 'Red Violet': '#c0448f';
|
|
34
|
+
readonly Black: '#232323';
|
|
35
|
+
readonly Brown: '#b4674d';
|
|
36
|
+
readonly White: '#ededed';
|
|
37
|
+
readonly Gray: '#95918c';
|
|
38
|
+
readonly 'Carnation Pink': '#ffaacc';
|
|
39
|
+
readonly 'Sky Blue': '#80daeb';
|
|
40
|
+
readonly Tan: '#faa76c';
|
|
41
|
+
readonly Apricot: '#fdd9b5';
|
|
42
|
+
readonly Peach: '#ffcfab';
|
|
43
|
+
readonly 'Cadet Blue': '#b0b7c6';
|
|
44
|
+
readonly Salmon: '#ff9baa';
|
|
45
|
+
readonly 'Forest Green': '#6dae81';
|
|
46
|
+
readonly 'Lemon Yellow': '#fff44f';
|
|
47
|
+
readonly Mahogany: '#cd4a4c';
|
|
48
|
+
readonly Maroon: '#c8385a';
|
|
49
|
+
readonly Bittersweet: '#fd7c6e';
|
|
50
|
+
readonly Sepia: '#a5694f';
|
|
51
|
+
readonly 'Burnt Sienna': '#ea7e5d';
|
|
52
|
+
readonly 'Burnt Orange': '#ff7f49';
|
|
53
|
+
readonly 'Raw Sienna': '#d68a59';
|
|
54
|
+
readonly Silver: '#cdc5c2';
|
|
55
|
+
readonly Gold: '#e7c697';
|
|
56
|
+
readonly Copper: '#dd9475';
|
|
57
|
+
readonly 'Green Yellow': '#f0e891';
|
|
58
|
+
readonly 'Pine Green': '#158078';
|
|
59
|
+
readonly 'Olive Green': '#bab86c';
|
|
60
|
+
readonly Indigo: '#5d76cb';
|
|
61
|
+
readonly Periwinkle: '#c5d0e6';
|
|
62
|
+
readonly Cerulean: '#1dacd6';
|
|
63
|
+
readonly 'Sea Green': '#9fe2bf';
|
|
64
|
+
readonly 'Turquoise Blue': '#77dde7';
|
|
65
|
+
readonly 'Atomic Tangerine': '#ff9966';
|
|
66
|
+
readonly 'Blizzard Blue': '#ace5ee';
|
|
67
|
+
readonly 'Hot Magenta': '#ff1dce';
|
|
68
|
+
readonly 'Laser Lemon': '#fdfc74';
|
|
69
|
+
readonly 'Neon Carrot': '#ffa343';
|
|
70
|
+
readonly 'Purple Pizzazz': '#fe4eda';
|
|
71
|
+
readonly 'Razzle Dazzle Rose': '#ff48d0';
|
|
72
|
+
readonly Razzmatazz: '#e3256b';
|
|
73
|
+
readonly "Screamin' Green": '#76ff7a';
|
|
74
|
+
readonly 'Shocking Pink': '#fb7efd';
|
|
75
|
+
readonly 'Tickle Me Pink': '#fc89ac';
|
|
76
|
+
readonly 'Unmellow Yellow': '#ffff66';
|
|
77
|
+
readonly 'Wild Watermelon': '#fc6c85';
|
|
78
|
+
readonly 'Outrageous Orange': '#ff6e4a';
|
|
79
|
+
readonly 'Electric Lime': '#ceff1d';
|
|
80
|
+
readonly 'Granny Smith Apple': '#a8e4a0';
|
|
81
|
+
readonly 'Macaroni and Cheese': '#ffbd88';
|
|
82
|
+
readonly 'Banana Mania': '#fae7b5';
|
|
83
|
+
readonly 'Caribbean Green': '#1cd3a2';
|
|
84
|
+
readonly Cerise: '#dd4492';
|
|
85
|
+
readonly 'Cotton Candy': '#ffbcd9';
|
|
86
|
+
readonly 'Fuzzy Wuzzy': '#cc6666';
|
|
87
|
+
readonly Inchworm: '#b2ec5d';
|
|
88
|
+
readonly 'Jazzberry Jam': '#ca3767';
|
|
89
|
+
readonly Manatee: '#979aaa';
|
|
90
|
+
readonly 'Mango Tango': '#ff8243';
|
|
91
|
+
readonly Mauvelous: '#ef98aa';
|
|
92
|
+
readonly 'Midnight Blue': '#1a4876';
|
|
93
|
+
readonly 'Navy Blue': '#1974d2';
|
|
94
|
+
readonly 'Pacific Blue': '#1ca9c9';
|
|
95
|
+
readonly 'Piggy Pink': '#fddde6';
|
|
96
|
+
readonly Plum: '#8e4585';
|
|
97
|
+
readonly 'Purple Heart': '#7442c8';
|
|
98
|
+
readonly "Robin's Egg Blue": '#1fcecb';
|
|
99
|
+
readonly 'Royal Purple': '#7851a9';
|
|
100
|
+
readonly Scarlet: '#fc2847';
|
|
101
|
+
readonly Timberwolf: '#dbd7d2';
|
|
102
|
+
readonly Tumbleweed: '#deaa88';
|
|
103
|
+
readonly 'Violet Red': '#f75394';
|
|
104
|
+
readonly 'Vivid Violet': '#8f509d';
|
|
105
|
+
readonly Wisteria: '#cda4de';
|
|
106
|
+
};
|
|
107
|
+
export type CrayolaColorName = keyof typeof crayolaColors;
|
|
108
|
+
export declare const crayola: {
|
|
109
|
+
readonly name: 'crayola';
|
|
110
|
+
readonly colors: {
|
|
111
|
+
readonly Red: '#ee204d';
|
|
112
|
+
readonly 'Red Orange': '#ff5349';
|
|
113
|
+
readonly Orange: '#ff7538';
|
|
114
|
+
readonly 'Yellow Orange': '#ffae42';
|
|
115
|
+
readonly Yellow: '#fce883';
|
|
116
|
+
readonly 'Yellow Green': '#c5e384';
|
|
117
|
+
readonly Green: '#1cac78';
|
|
118
|
+
readonly 'Blue Green': '#0d98ba';
|
|
119
|
+
readonly Blue: '#1f75fe';
|
|
120
|
+
readonly 'Blue Violet': '#7366bd';
|
|
121
|
+
readonly Violet: '#926eae';
|
|
122
|
+
readonly 'Red Violet': '#c0448f';
|
|
123
|
+
readonly Black: '#232323';
|
|
124
|
+
readonly Brown: '#b4674d';
|
|
125
|
+
readonly White: '#ededed';
|
|
126
|
+
readonly Gray: '#95918c';
|
|
127
|
+
readonly 'Carnation Pink': '#ffaacc';
|
|
128
|
+
readonly 'Sky Blue': '#80daeb';
|
|
129
|
+
readonly Tan: '#faa76c';
|
|
130
|
+
readonly Apricot: '#fdd9b5';
|
|
131
|
+
readonly Peach: '#ffcfab';
|
|
132
|
+
readonly 'Cadet Blue': '#b0b7c6';
|
|
133
|
+
readonly Salmon: '#ff9baa';
|
|
134
|
+
readonly 'Forest Green': '#6dae81';
|
|
135
|
+
readonly 'Lemon Yellow': '#fff44f';
|
|
136
|
+
readonly Mahogany: '#cd4a4c';
|
|
137
|
+
readonly Maroon: '#c8385a';
|
|
138
|
+
readonly Bittersweet: '#fd7c6e';
|
|
139
|
+
readonly Sepia: '#a5694f';
|
|
140
|
+
readonly 'Burnt Sienna': '#ea7e5d';
|
|
141
|
+
readonly 'Burnt Orange': '#ff7f49';
|
|
142
|
+
readonly 'Raw Sienna': '#d68a59';
|
|
143
|
+
readonly Silver: '#cdc5c2';
|
|
144
|
+
readonly Gold: '#e7c697';
|
|
145
|
+
readonly Copper: '#dd9475';
|
|
146
|
+
readonly 'Green Yellow': '#f0e891';
|
|
147
|
+
readonly 'Pine Green': '#158078';
|
|
148
|
+
readonly 'Olive Green': '#bab86c';
|
|
149
|
+
readonly Indigo: '#5d76cb';
|
|
150
|
+
readonly Periwinkle: '#c5d0e6';
|
|
151
|
+
readonly Cerulean: '#1dacd6';
|
|
152
|
+
readonly 'Sea Green': '#9fe2bf';
|
|
153
|
+
readonly 'Turquoise Blue': '#77dde7';
|
|
154
|
+
readonly 'Atomic Tangerine': '#ff9966';
|
|
155
|
+
readonly 'Blizzard Blue': '#ace5ee';
|
|
156
|
+
readonly 'Hot Magenta': '#ff1dce';
|
|
157
|
+
readonly 'Laser Lemon': '#fdfc74';
|
|
158
|
+
readonly 'Neon Carrot': '#ffa343';
|
|
159
|
+
readonly 'Purple Pizzazz': '#fe4eda';
|
|
160
|
+
readonly 'Razzle Dazzle Rose': '#ff48d0';
|
|
161
|
+
readonly Razzmatazz: '#e3256b';
|
|
162
|
+
readonly "Screamin' Green": '#76ff7a';
|
|
163
|
+
readonly 'Shocking Pink': '#fb7efd';
|
|
164
|
+
readonly 'Tickle Me Pink': '#fc89ac';
|
|
165
|
+
readonly 'Unmellow Yellow': '#ffff66';
|
|
166
|
+
readonly 'Wild Watermelon': '#fc6c85';
|
|
167
|
+
readonly 'Outrageous Orange': '#ff6e4a';
|
|
168
|
+
readonly 'Electric Lime': '#ceff1d';
|
|
169
|
+
readonly 'Granny Smith Apple': '#a8e4a0';
|
|
170
|
+
readonly 'Macaroni and Cheese': '#ffbd88';
|
|
171
|
+
readonly 'Banana Mania': '#fae7b5';
|
|
172
|
+
readonly 'Caribbean Green': '#1cd3a2';
|
|
173
|
+
readonly Cerise: '#dd4492';
|
|
174
|
+
readonly 'Cotton Candy': '#ffbcd9';
|
|
175
|
+
readonly 'Fuzzy Wuzzy': '#cc6666';
|
|
176
|
+
readonly Inchworm: '#b2ec5d';
|
|
177
|
+
readonly 'Jazzberry Jam': '#ca3767';
|
|
178
|
+
readonly Manatee: '#979aaa';
|
|
179
|
+
readonly 'Mango Tango': '#ff8243';
|
|
180
|
+
readonly Mauvelous: '#ef98aa';
|
|
181
|
+
readonly 'Midnight Blue': '#1a4876';
|
|
182
|
+
readonly 'Navy Blue': '#1974d2';
|
|
183
|
+
readonly 'Pacific Blue': '#1ca9c9';
|
|
184
|
+
readonly 'Piggy Pink': '#fddde6';
|
|
185
|
+
readonly Plum: '#8e4585';
|
|
186
|
+
readonly 'Purple Heart': '#7442c8';
|
|
187
|
+
readonly "Robin's Egg Blue": '#1fcecb';
|
|
188
|
+
readonly 'Royal Purple': '#7851a9';
|
|
189
|
+
readonly Scarlet: '#fc2847';
|
|
190
|
+
readonly Timberwolf: '#dbd7d2';
|
|
191
|
+
readonly Tumbleweed: '#deaa88';
|
|
192
|
+
readonly 'Violet Red': '#f75394';
|
|
193
|
+
readonly 'Vivid Violet': '#8f509d';
|
|
194
|
+
readonly Wisteria: '#cda4de';
|
|
195
|
+
};
|
|
196
|
+
readonly normalize: import("../types.js").NormalizeFn;
|
|
197
|
+
readonly defaultMetric: 'deltaEok';
|
|
198
|
+
};
|
|
199
|
+
export {};
|
|
200
|
+
//# sourceMappingURL=crayola.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crayola.d.ts","sourceRoot":"","sources":["../../src/palettes/crayola.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,aAAa;aAEjB,GAAG,EAAE,SAAS;aACd,YAAY,EAAE,SAAS;aACvB,MAAM,EAAE,SAAS;aACjB,eAAe,EAAE,SAAS;aAC1B,MAAM,EAAE,SAAS;aACjB,cAAc,EAAE,SAAS;aACzB,KAAK,EAAE,SAAS;aAChB,YAAY,EAAE,SAAS;aACvB,IAAI,EAAE,SAAS;aACf,aAAa,EAAE,SAAS;aACxB,MAAM,EAAE,SAAS;aACjB,YAAY,EAAE,SAAS;aAGvB,KAAK,EAAE,SAAS;aAChB,KAAK,EAAE,SAAS;aAChB,KAAK,EAAE,SAAS;aAChB,IAAI,EAAE,SAAS;aAGf,gBAAgB,EAAE,SAAS;aAC3B,UAAU,EAAE,SAAS;aACrB,GAAG,EAAE,SAAS;aACd,OAAO,EAAE,SAAS;aAClB,KAAK,EAAE,SAAS;aAChB,YAAY,EAAE,SAAS;aACvB,MAAM,EAAE,SAAS;aACjB,cAAc,EAAE,SAAS;aACzB,cAAc,EAAE,SAAS;aACzB,QAAQ,EAAE,SAAS;aACnB,MAAM,EAAE,SAAS;aACjB,WAAW,EAAE,SAAS;aACtB,KA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AS;0BAChB,SAAS;6BACN,SAAS;6BACT,SAAS;+BACP,SAAS;iCACP,SAAS;2BACf,SAAS;;;4BASJ,UAAU;CACmB,CAAC","sourcesContent":["import type { Palette } from '../types.js';\nimport { standardNormalize } from './normalize.js';\n\n/**\n * Crayola crayon colors — canonical subset. ~85 entries covering the\n * current 64-standard box, iconic fluorescents, and widely-recognized\n * modern additions.\n *\n * Keys are Title Case with spaces (`'Granny Smith Apple'`,\n * `'Razzmatazz'`) — how the names are printed on the crayon wrapper.\n * `standardNormalize` strips spaces + case + punctuation on input, so\n * `resolve('granny-smith-apple')` and `resolve('Granny Smith Apple')`\n * both hit the same entry.\n *\n * sRGB values are community-sourced approximations (Wikipedia's\n * well-cited list of Crayola crayon colors). They do not represent\n * a licensed Crayola reference. See NOTICE.md for trademark note.\n *\n * Default metric: `deltaEok`. The Crayola set spans a wide gamut with\n * many saturated brights (fluorescents especially) where CIELAB-based\n * metrics are less perceptually uniform than OKLAB. Same cost profile\n * as deltaE76, better neighbor selection in saturated regions.\n */\nconst crayolaColors = {\n // --- Current standard box: the 12 primary/secondary hue wheel ---\n Red: '#ee204d',\n 'Red Orange': '#ff5349',\n Orange: '#ff7538',\n 'Yellow Orange': '#ffae42',\n Yellow: '#fce883',\n 'Yellow Green': '#c5e384',\n Green: '#1cac78',\n 'Blue Green': '#0d98ba',\n Blue: '#1f75fe',\n 'Blue Violet': '#7366bd',\n Violet: '#926eae',\n 'Red Violet': '#c0448f',\n\n // --- Achromatics ---\n Black: '#232323',\n Brown: '#b4674d',\n White: '#ededed',\n Gray: '#95918c',\n\n // --- 64-box additions (pre-1990 core set) ---\n 'Carnation Pink': '#ffaacc',\n 'Sky Blue': '#80daeb',\n Tan: '#faa76c',\n Apricot: '#fdd9b5',\n Peach: '#ffcfab',\n 'Cadet Blue': '#b0b7c6',\n Salmon: '#ff9baa',\n 'Forest Green': '#6dae81',\n 'Lemon Yellow': '#fff44f',\n Mahogany: '#cd4a4c',\n Maroon: '#c8385a',\n Bittersweet: '#fd7c6e',\n Sepia: '#a5694f',\n 'Burnt Sienna': '#ea7e5d',\n 'Burnt Orange': '#ff7f49',\n 'Raw Sienna': '#d68a59',\n\n // --- Metallics ---\n Silver: '#cdc5c2',\n Gold: '#e7c697',\n Copper: '#dd9475',\n\n // --- Earth / nature tones ---\n 'Green Yellow': '#f0e891',\n 'Pine Green': '#158078',\n 'Olive Green': '#bab86c',\n Indigo: '#5d76cb',\n Periwinkle: '#c5d0e6',\n Cerulean: '#1dacd6',\n 'Sea Green': '#9fe2bf',\n 'Turquoise Blue': '#77dde7',\n\n // --- Fluorescents (the iconic \"Neon 24\" era) ---\n 'Atomic Tangerine': '#ff9966',\n 'Blizzard Blue': '#ace5ee',\n 'Hot Magenta': '#ff1dce',\n 'Laser Lemon': '#fdfc74',\n 'Neon Carrot': '#ffa343',\n 'Purple Pizzazz': '#fe4eda',\n 'Razzle Dazzle Rose': '#ff48d0',\n Razzmatazz: '#e3256b',\n \"Screamin' Green\": '#76ff7a',\n 'Shocking Pink': '#fb7efd',\n 'Tickle Me Pink': '#fc89ac',\n 'Unmellow Yellow': '#ffff66',\n 'Wild Watermelon': '#fc6c85',\n 'Outrageous Orange': '#ff6e4a',\n 'Electric Lime': '#ceff1d',\n\n // --- Modern / whimsical additions ---\n 'Granny Smith Apple': '#a8e4a0',\n 'Macaroni and Cheese': '#ffbd88',\n 'Banana Mania': '#fae7b5',\n 'Caribbean Green': '#1cd3a2',\n Cerise: '#dd4492',\n 'Cotton Candy': '#ffbcd9',\n 'Fuzzy Wuzzy': '#cc6666',\n Inchworm: '#b2ec5d',\n 'Jazzberry Jam': '#ca3767',\n Manatee: '#979aaa',\n 'Mango Tango': '#ff8243',\n Mauvelous: '#ef98aa',\n 'Midnight Blue': '#1a4876',\n 'Navy Blue': '#1974d2',\n 'Pacific Blue': '#1ca9c9',\n 'Piggy Pink': '#fddde6',\n Plum: '#8e4585',\n 'Purple Heart': '#7442c8',\n \"Robin's Egg Blue\": '#1fcecb',\n 'Royal Purple': '#7851a9',\n Scarlet: '#fc2847',\n Timberwolf: '#dbd7d2',\n Tumbleweed: '#deaa88',\n 'Violet Red': '#f75394',\n 'Vivid Violet': '#8f509d',\n Wisteria: '#cda4de',\n} as const;\n\nexport type CrayolaColorName = keyof typeof crayolaColors;\n\nexport const crayola = {\n name: 'crayola',\n colors: crayolaColors,\n normalize: standardNormalize,\n defaultMetric: 'deltaEok',\n} as const satisfies Palette<CrayolaColorName>;\n"]}
|