@oh-my-pi/pi-utils 18.8.8 → 18.8.9

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [18.8.9] - 2026-10-10
6
+
7
+ ### Added
8
+
9
+ - Added `hueDistance`, the angular distance between two OKLCH hues
10
+
5
11
  ## [18.8.8] - 2026-10-10
6
12
 
7
13
  ### Fixed
@@ -111,6 +111,8 @@ export declare function oklchCusp(h: number): {
111
111
  l: number;
112
112
  c: number;
113
113
  };
114
+ /** Angular distance between two hues in degrees (0–180), wrapping at 360. */
115
+ export declare function hueDistance(a: number, b: number): number;
114
116
  /**
115
117
  * Convert OKLCH to a CSS hex string, gamut-mapping by chroma reduction.
116
118
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-utils",
3
- "version": "18.8.8",
3
+ "version": "18.8.9",
4
4
  "description": "Shared utilities for pi packages",
5
5
  "keywords": [
6
6
  "cli",
@@ -57,7 +57,7 @@
57
57
  "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
58
58
  },
59
59
  "dependencies": {
60
- "@oh-my-pi/pi-natives": "18.8.8"
60
+ "@oh-my-pi/pi-natives": "18.8.9"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/bun": "^1.3.14"
package/src/color.ts CHANGED
@@ -399,6 +399,12 @@ export function oklchCusp(h: number): { l: number; c: number } {
399
399
  return { l: lCusp, c: lCusp * sCusp };
400
400
  }
401
401
 
402
+ /** Angular distance between two hues in degrees (0–180), wrapping at 360. */
403
+ export function hueDistance(a: number, b: number): number {
404
+ const d = Math.abs(a - b) % 360;
405
+ return Math.min(d, 360 - d);
406
+ }
407
+
402
408
  /** Slack allowed on linear channels before a color counts as out of sRGB gamut. */
403
409
  const GAMUT_EPSILON = 1e-4;
404
410