aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/colormath.js
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-19 10:19:59 -0400
committerCraig Jennings <c@cjennings.net>2026-06-19 10:19:59 -0400
commit119968487f401fcb0d568ab4b6e16bd261d49e65 (patch)
treed02fa553ecd58b71fb7f6e080a9e21af18c2ec1a /scripts/theme-studio/colormath.js
parent8d07d04888fff226ff34674c0d0ef100e2fd012e (diff)
downloaddotemacs-119968487f401fcb0d568ab4b6e16bd261d49e65.tar.gz
dotemacs-119968487f401fcb0d568ab4b6e16bd261d49e65.zip
refactor(theme-studio): share oklchOf and isPureEndpointHex from colormath
oklchOf and isPureEndpointHex were each defined identically in app-core.js and palette-generator-core.js, and hueOfHex inlined oklchOf's body a third time. I moved both helpers into colormath.js, which already owns the primitives they call, and had the two consumers import them. hueOfHex now calls oklchOf instead of re-deriving it.
Diffstat (limited to 'scripts/theme-studio/colormath.js')
-rw-r--r--scripts/theme-studio/colormath.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/scripts/theme-studio/colormath.js b/scripts/theme-studio/colormath.js
index 2a7328e54..b57da9131 100644
--- a/scripts/theme-studio/colormath.js
+++ b/scripts/theme-studio/colormath.js
@@ -217,4 +217,9 @@ function reliefColors(bgHex) {
return { hl: one(1.2, 0x8000), sh: one(0.6, 0x4000) };
}
-export { srgb2oklab, oklab2oklch, oklch2oklab, oklch2hex, apca, deltaE, hex2rgb, lin, rl, contrast, rating, hsv2rgb, rgb2hsv, rgb2hex, oklab2lrgb, inGamut, lrgb2hex, planeCell, paletteWarnings, reliefColors };
+// OKLCH of a hex, and the pure black/white endpoint test. Shared by app-core
+// and palette-generator-core (both previously kept their own identical copies).
+function oklchOf(hex){return oklab2oklch(srgb2oklab(hex));}
+function isPureEndpointHex(hex){const h=(hex||'').toLowerCase();return h==='#ffffff'||h==='#000000';}
+
+export { srgb2oklab, oklab2oklch, oklch2oklab, oklch2hex, apca, deltaE, hex2rgb, lin, rl, contrast, rating, hsv2rgb, rgb2hsv, rgb2hex, oklab2lrgb, inGamut, lrgb2hex, planeCell, paletteWarnings, reliefColors, oklchOf, isPureEndpointHex };