@thi.ng/color 4.1.7 → 5.0.2

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +3 -3
  3. package/analog.d.ts +15 -15
  4. package/analog.js +16 -15
  5. package/api/constants.d.ts +1 -1
  6. package/api/constants.js +1 -1
  7. package/api/system.d.ts +1 -1
  8. package/api/system.js +1 -1
  9. package/api.d.ts +13 -6
  10. package/color-range.d.ts +6 -6
  11. package/color-range.js +6 -6
  12. package/convert.d.ts +1 -1
  13. package/convert.js +1 -1
  14. package/cosine-gradients.d.ts +5 -5
  15. package/cosine-gradients.js +5 -5
  16. package/css/parse-css.d.ts +1 -1
  17. package/css/parse-css.js +1 -1
  18. package/defcolor.js +5 -1
  19. package/distance.d.ts +17 -17
  20. package/distance.js +17 -17
  21. package/gradients.d.ts +2 -2
  22. package/gradients.js +2 -2
  23. package/hcy/hcy.js +5 -1
  24. package/hsi/hsi.js +5 -1
  25. package/hsl/hsl.js +10 -1
  26. package/hsv/hsv.js +10 -1
  27. package/index.d.ts +8 -0
  28. package/index.js +8 -0
  29. package/int/int-int.d.ts +1 -1
  30. package/int/int-int.js +1 -1
  31. package/internal/dispatch.d.ts +4 -0
  32. package/internal/dispatch.js +2 -0
  33. package/invert.d.ts +8 -1
  34. package/invert.js +34 -1
  35. package/is-black.d.ts +1 -1
  36. package/is-black.js +10 -7
  37. package/is-gamut.d.ts +9 -0
  38. package/is-gamut.js +16 -0
  39. package/is-gray.d.ts +1 -1
  40. package/is-gray.js +10 -8
  41. package/is-white.d.ts +1 -1
  42. package/is-white.js +9 -6
  43. package/lab/lab-css.d.ts +1 -1
  44. package/lab/lab-css.js +1 -1
  45. package/lab/lab-rgb.d.ts +4 -4
  46. package/lab/lab-rgb.js +4 -4
  47. package/lab/lab-xyz.d.ts +5 -5
  48. package/lab/lab-xyz.js +5 -5
  49. package/lch/lch-css.d.ts +1 -1
  50. package/lch/lch-css.js +1 -1
  51. package/lch/lch.js +1 -0
  52. package/lighten.d.ts +11 -0
  53. package/lighten.js +21 -0
  54. package/luminance-rgb.d.ts +2 -2
  55. package/luminance-rgb.js +2 -2
  56. package/luminance.d.ts +2 -2
  57. package/luminance.js +3 -2
  58. package/max-chroma.d.ts +8 -0
  59. package/max-chroma.js +240 -0
  60. package/mix.d.ts +8 -8
  61. package/mix.js +9 -8
  62. package/oklab/oklab-rgb.d.ts +2 -2
  63. package/oklab/oklab-rgb.js +2 -2
  64. package/package.json +131 -109
  65. package/rgb/rgb-lab.d.ts +4 -4
  66. package/rgb/rgb-lab.js +4 -4
  67. package/rgb/rgb-oklab.d.ts +2 -2
  68. package/rgb/rgb-oklab.js +2 -2
  69. package/rgb/rgb-xyz.d.ts +2 -2
  70. package/rgb/rgb-xyz.js +2 -2
  71. package/rgb/rgb-ycc.d.ts +3 -3
  72. package/rgb/rgb-ycc.js +3 -3
  73. package/rotate.d.ts +4 -0
  74. package/rotate.js +10 -0
  75. package/sort.d.ts +7 -7
  76. package/sort.js +7 -7
  77. package/strategies.d.ts +90 -0
  78. package/strategies.js +122 -0
  79. package/tint.d.ts +6 -0
  80. package/tint.js +11 -0
  81. package/transform.d.ts +11 -11
  82. package/transform.js +11 -11
  83. package/variations.d.ts +29 -0
  84. package/variations.js +14 -0
  85. package/xyy/xyy-xyz.d.ts +2 -2
  86. package/xyy/xyy-xyz.js +2 -2
  87. package/xyz/wavelength-xyz.d.ts +3 -3
  88. package/xyz/wavelength-xyz.js +3 -3
  89. package/xyz/xyz-lab.d.ts +5 -5
  90. package/xyz/xyz-lab.js +5 -5
  91. package/xyz/xyz-rgb.d.ts +2 -2
  92. package/xyz/xyz-rgb.js +2 -2
  93. package/xyz/xyz-xyy.d.ts +2 -2
  94. package/xyz/xyz-xyy.js +2 -2
  95. package/ycc/ycc-rgb.d.ts +3 -3
  96. package/ycc/ycc-rgb.js +3 -3
package/hcy/hcy.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { defColor } from "../defcolor.js";
2
+ import { lchLab } from "../lab/lab-lch.js";
3
+ import { labRgb } from "../lab/lab-rgb.js";
2
4
  import { rgbHcy } from "../rgb/rgb-hcy.js";
5
+ import { rgbSrgb } from "../rgb/rgb-srgb.js";
3
6
  import { hcyRgb } from "./hcy-rgb.js";
4
7
  export const hcy = defColor({
5
8
  mode: "hcy",
9
+ channels: { h: { hue: true } },
6
10
  order: ["h", "c", "y", "alpha"],
7
- from: { rgb: rgbHcy, srgb: rgbHcy },
11
+ from: { rgb: rgbHcy, srgb: rgbHcy, lch: [lchLab, labRgb, rgbSrgb, rgbHcy] },
8
12
  toRgb: hcyRgb,
9
13
  });
package/hsi/hsi.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { defColor } from "../defcolor.js";
2
+ import { lchLab } from "../lab/lab-lch.js";
3
+ import { labRgb } from "../lab/lab-rgb.js";
2
4
  import { rgbHsi } from "../rgb/rgb-hsi.js";
5
+ import { rgbSrgb } from "../rgb/rgb-srgb.js";
3
6
  import { hsiRgb } from "./hsi-rgb.js";
4
7
  export const hsi = defColor({
5
8
  mode: "hsi",
9
+ channels: { h: { hue: true } },
6
10
  order: ["h", "s", "i", "alpha"],
7
- from: { rgb: rgbHsi, srgb: rgbHsi },
11
+ from: { rgb: rgbHsi, srgb: rgbHsi, lch: [lchLab, labRgb, rgbSrgb, rgbHsi] },
8
12
  toRgb: hsiRgb,
9
13
  });
package/hsl/hsl.js CHANGED
@@ -1,10 +1,19 @@
1
1
  import { defColor } from "../defcolor.js";
2
2
  import { hsvHsl } from "../hsv/hsv-hsl.js";
3
+ import { lchLab } from "../lab/lab-lch.js";
4
+ import { labRgb } from "../lab/lab-rgb.js";
3
5
  import { rgbHsl } from "../rgb/rgb-hsl.js";
6
+ import { rgbSrgb } from "../rgb/rgb-srgb.js";
4
7
  import { hslRgb } from "./hsl-rgb.js";
5
8
  export const hsl = defColor({
6
9
  mode: "hsl",
10
+ channels: { h: { hue: true } },
7
11
  order: ["h", "s", "l", "alpha"],
8
- from: { rgb: rgbHsl, srgb: rgbHsl, hsv: hsvHsl },
12
+ from: {
13
+ rgb: rgbHsl,
14
+ srgb: rgbHsl,
15
+ hsv: hsvHsl,
16
+ lch: [lchLab, labRgb, rgbSrgb, rgbHsl],
17
+ },
9
18
  toRgb: hslRgb,
10
19
  });
package/hsv/hsv.js CHANGED
@@ -1,10 +1,19 @@
1
1
  import { defColor } from "../defcolor.js";
2
2
  import { hslHsv } from "../hsl/hsl-hsv.js";
3
+ import { lchLab } from "../lab/lab-lch.js";
4
+ import { labRgb } from "../lab/lab-rgb.js";
3
5
  import { rgbHsv } from "../rgb/rgb-hsv.js";
6
+ import { rgbSrgb } from "../rgb/rgb-srgb.js";
4
7
  import { hsvRgb } from "./hsv-rgb.js";
5
8
  export const hsv = defColor({
6
9
  mode: "hsv",
10
+ channels: { h: { hue: true } },
7
11
  order: ["h", "s", "v", "alpha"],
8
- from: { rgb: rgbHsv, srgb: rgbHsv, hsl: hslHsv },
12
+ from: {
13
+ rgb: rgbHsv,
14
+ srgb: rgbHsv,
15
+ hsl: hslHsv,
16
+ lch: [lchLab, labRgb, rgbSrgb, rgbHsv],
17
+ },
9
18
  toRgb: hsvRgb,
10
19
  });
package/index.d.ts CHANGED
@@ -47,14 +47,22 @@ export * from "./cosine-gradients.js";
47
47
  export * from "./distance.js";
48
48
  export * from "./gradients.js";
49
49
  export * from "./invert.js";
50
+ export * from "./is-black.js";
51
+ export * from "./is-gamut.js";
50
52
  export * from "./is-gray.js";
53
+ export * from "./is-white.js";
51
54
  export * from "./linear.js";
52
55
  export * from "./luminance-rgb.js";
53
56
  export * from "./luminance.js";
57
+ export * from "./max-chroma.js";
54
58
  export * from "./mix.js";
59
+ export * from "./rotate.js";
55
60
  export * from "./sort.js";
61
+ export * from "./strategies.js";
56
62
  export * from "./swatches.js";
63
+ export * from "./tint.js";
57
64
  export * from "./transform.js";
65
+ export * from "./variations.js";
58
66
  export * from "./rgb/hue-rgb.js";
59
67
  export * from "./rgb/kelvin-rgba.js";
60
68
  export * from "./rgb/rgb-css.js";
package/index.js CHANGED
@@ -47,14 +47,22 @@ export * from "./cosine-gradients.js";
47
47
  export * from "./distance.js";
48
48
  export * from "./gradients.js";
49
49
  export * from "./invert.js";
50
+ export * from "./is-black.js";
51
+ export * from "./is-gamut.js";
50
52
  export * from "./is-gray.js";
53
+ export * from "./is-white.js";
51
54
  export * from "./linear.js";
52
55
  export * from "./luminance-rgb.js";
53
56
  export * from "./luminance.js";
57
+ export * from "./max-chroma.js";
54
58
  export * from "./mix.js";
59
+ export * from "./rotate.js";
55
60
  export * from "./sort.js";
61
+ export * from "./strategies.js";
56
62
  export * from "./swatches.js";
63
+ export * from "./tint.js";
57
64
  export * from "./transform.js";
65
+ export * from "./variations.js";
58
66
  export * from "./rgb/hue-rgb.js";
59
67
  export * from "./rgb/kelvin-rgba.js";
60
68
  export * from "./rgb/rgb-css.js";
package/int/int-int.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Convert ARGB int to ABGR and vice versa.
3
3
  *
4
- * @param x
4
+ * @param x -
5
5
  */
6
6
  export declare const intArgb32Abgr32: import("@thi.ng/api").FnN;
7
7
  /**
package/int/int-int.js CHANGED
@@ -2,7 +2,7 @@ import { swapLane13 } from "@thi.ng/binary/swizzle";
2
2
  /**
3
3
  * Convert ARGB int to ABGR and vice versa.
4
4
  *
5
- * @param x
5
+ * @param x -
6
6
  */
7
7
  export const intArgb32Abgr32 = swapLane13;
8
8
  /**
@@ -0,0 +1,4 @@
1
+ import type { IColor } from "../api.js";
2
+ export declare const __dispatch0: (src: IColor) => import("../api.js").ColorMode;
3
+ export declare const __dispatch1: (_: any, src: IColor) => import("../api.js").ColorMode;
4
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const __dispatch0 = (src) => src.mode;
2
+ export const __dispatch1 = (_, src) => src.mode;
package/invert.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- import type { ColorOp } from "./api.js";
1
+ import type { ColorOp, TypedColor } from "./api.js";
2
2
  /**
3
3
  * Inverts the RGB channels of an RGBA color.
4
4
  *
5
+ * @remarks
6
+ * Also see {@link TypedColor.invert}.
7
+ *
5
8
  * @param out - result
6
9
  * @param src - source color
7
10
  */
@@ -9,7 +12,11 @@ export declare const invertRgb: ColorOp;
9
12
  /**
10
13
  * Inverts the lowest 24 bits of an ARGB int. Does not modify alpha.
11
14
  *
15
+ * @remarks
16
+ * Also see {@link TypedColor.invert}.
17
+ *
12
18
  * @param src - packed RGB int
13
19
  */
14
20
  export declare const invertInt: (src: number) => number;
21
+ export declare const invert: import("@thi.ng/defmulti").MultiFn2<import("@thi.ng/vectors/api").Vec | null, TypedColor<any>, import("@thi.ng/vectors/api").Vec>;
15
22
  //# sourceMappingURL=invert.d.ts.map
package/invert.js CHANGED
@@ -1,16 +1,49 @@
1
+ import { defmulti } from "@thi.ng/defmulti/defmulti";
2
+ import { fit } from "@thi.ng/math/fit";
3
+ import { fract } from "@thi.ng/math/prec";
1
4
  import { ONE3 } from "@thi.ng/vectors/api";
5
+ import { setC4 } from "@thi.ng/vectors/setc";
2
6
  import { sub3 } from "@thi.ng/vectors/sub";
3
7
  import { clamp } from "./clamp.js";
8
+ import { __dispatch1 } from "./internal/dispatch.js";
9
+ import { __ensureAlpha } from "./internal/ensure.js";
4
10
  /**
5
11
  * Inverts the RGB channels of an RGBA color.
6
12
  *
13
+ * @remarks
14
+ * Also see {@link TypedColor.invert}.
15
+ *
7
16
  * @param out - result
8
17
  * @param src - source color
9
18
  */
10
- export const invertRgb = (out, src) => ((out = clamp(out || src, src)), sub3(out, ONE3, out));
19
+ export const invertRgb = (out, src) => {
20
+ out = clamp(out || src, src);
21
+ return sub3(out, ONE3, out);
22
+ };
11
23
  /**
12
24
  * Inverts the lowest 24 bits of an ARGB int. Does not modify alpha.
13
25
  *
26
+ * @remarks
27
+ * Also see {@link TypedColor.invert}.
28
+ *
14
29
  * @param src - packed RGB int
15
30
  */
16
31
  export const invertInt = (src) => src ^ 0xffffff;
32
+ export const invert = defmulti(__dispatch1, {
33
+ hcy: "hsv",
34
+ hsi: "hsv",
35
+ hsl: "hsl",
36
+ labD65: "labD50",
37
+ oklab: "labD50",
38
+ srgb: "rgb",
39
+ }, {
40
+ hsv: (out, src) => setC4(out || src, fract(src[0] + 0.5), src[1], 1 - src[2], __ensureAlpha(src[3])),
41
+ labD50: (out, src) => {
42
+ const [min, max] = src.range;
43
+ return setC4(out || src, 1 - src[0], __invert1(src[1], min[1], max[1]), __invert1(src[2], min[2], max[2]), __ensureAlpha(src[3]));
44
+ },
45
+ lch: (out, src) => setC4(out || src, 1 - src[0], src[1], fract(src[2] + 0.5), __ensureAlpha(src[3])),
46
+ rgb: invertRgb,
47
+ ycc: (out, src) => setC4(out || src, 1 - src[0], __invert1(src[1], -0.5, 0.5), __invert1(src[2], -0.5, 0.5), __ensureAlpha(src[3])),
48
+ });
49
+ const __invert1 = (x, a, b) => fit(x, a, b, b, a);
package/is-black.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { TypedColor } from "./api.js";
2
- export declare const isBlack: import("@thi.ng/defmulti/api").MultiFn2<TypedColor<any>, number | undefined, boolean>;
2
+ export declare const isBlack: import("@thi.ng/defmulti").MultiFn2<TypedColor<any>, number | undefined, boolean>;
3
3
  //# sourceMappingURL=is-black.d.ts.map
package/is-black.js CHANGED
@@ -1,18 +1,21 @@
1
1
  import { DEFAULT, defmulti } from "@thi.ng/defmulti/defmulti";
2
2
  import { EPS } from "./api/constants.js";
3
+ import { __dispatch0 } from "./internal/dispatch.js";
3
4
  import { rgb } from "./rgb/rgb.js";
4
5
  const isBlackHsv = (x, eps = EPS) => x[2] <= eps;
5
6
  const isBlackRgb = (x, eps = EPS) => x[0] <= eps && x[1] <= eps && x[2] <= eps;
6
7
  const isBlackLch = (x, eps = EPS) => x[0] <= eps;
7
- export const isBlack = defmulti((x) => x.mode, {}, {
8
- hcy: isBlackHsv,
9
- hsi: isBlackHsv,
10
- hsl: isBlackHsv,
8
+ export const isBlack = defmulti(__dispatch0, {
9
+ hcy: "hsv",
10
+ hsi: "hsv",
11
+ hsl: "hsv",
12
+ labD50: "lch",
13
+ labD65: "lch",
14
+ srgb: "rgb",
15
+ ycc: "rgb",
16
+ }, {
11
17
  hsv: isBlackHsv,
12
- labD50: isBlackLch,
13
- labD65: isBlackLch,
14
18
  lch: isBlackLch,
15
19
  rgb: isBlackRgb,
16
- ycc: isBlackRgb,
17
20
  [DEFAULT]: (x) => isBlackRgb(rgb(x)),
18
21
  });
package/is-gamut.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { TypedColor } from "./api.js";
2
+ /**
3
+ * Returns true, if given color is within the RGB gamut (without clipping).
4
+ *
5
+ * @param src -
6
+ * @param eps -
7
+ */
8
+ export declare const isRgbGamut: (src: TypedColor<any>, eps?: number) => boolean;
9
+ //# sourceMappingURL=is-gamut.d.ts.map
package/is-gamut.js ADDED
@@ -0,0 +1,16 @@
1
+ import { inRange } from "@thi.ng/math/interval";
2
+ import { rgb } from "./rgb/rgb.js";
3
+ /**
4
+ * Returns true, if given color is within the RGB gamut (without clipping).
5
+ *
6
+ * @param src -
7
+ * @param eps -
8
+ */
9
+ export const isRgbGamut = (src, eps = 1e-3) => {
10
+ const min = -eps;
11
+ const max = 1 + eps;
12
+ const col = src.mode === "rgb" || src.mode === "srgb" ? src : rgb(src);
13
+ return (inRange(col[0], min, max) &&
14
+ inRange(col[1], min, max) &&
15
+ inRange(col[2], min, max));
16
+ };
package/is-gray.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { TypedColor } from "./api.js";
2
- export declare const isGray: import("@thi.ng/defmulti/api").MultiFn2<TypedColor<any>, number | undefined, boolean>;
2
+ export declare const isGray: import("@thi.ng/defmulti").MultiFn2<TypedColor<any>, number | undefined, boolean>;
3
3
  //# sourceMappingURL=is-gray.d.ts.map
package/is-gray.js CHANGED
@@ -1,20 +1,22 @@
1
1
  import { DEFAULT, defmulti } from "@thi.ng/defmulti/defmulti";
2
2
  import { eqDelta } from "@thi.ng/math/eqdelta";
3
3
  import { EPS } from "./api/constants.js";
4
+ import { __dispatch0 } from "./internal/dispatch.js";
4
5
  import { rgb } from "./rgb/rgb.js";
5
6
  const isGrayHsv = (x, eps = EPS) => x[1] <= eps;
6
7
  const isGrayRgb = (x, eps = EPS) => eqDelta(x[0], x[1], eps) && eqDelta(x[0], x[2], eps);
7
8
  const isGrayLab = (x, eps = EPS) => eqDelta(x[1], 0, eps) && eqDelta(x[2], 0, eps);
8
- export const isGray = defmulti((x) => x.mode, {}, {
9
- hcy: isGrayHsv,
10
- hsi: isGrayHsv,
11
- hsl: isGrayHsv,
9
+ export const isGray = defmulti(__dispatch0, {
10
+ hcy: "hsv",
11
+ hsi: "hsv",
12
+ hsl: "hsv",
13
+ lch: "hsv",
14
+ labD65: "labD50",
15
+ srgb: "rgb",
16
+ ycc: "labD50",
17
+ }, {
12
18
  hsv: isGrayHsv,
13
19
  labD50: isGrayLab,
14
- labD65: isGrayLab,
15
- lch: isGrayHsv,
16
20
  rgb: isGrayRgb,
17
- srgb: isGrayRgb,
18
- ycc: isGrayLab,
19
21
  [DEFAULT]: (x) => isGrayRgb(rgb(x)),
20
22
  });
package/is-white.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { TypedColor } from "./api.js";
2
- export declare const isWhite: import("@thi.ng/defmulti/api").MultiFn2<TypedColor<any>, number | undefined, boolean>;
2
+ export declare const isWhite: import("@thi.ng/defmulti").MultiFn2<TypedColor<any>, number | undefined, boolean>;
3
3
  //# sourceMappingURL=is-white.d.ts.map
package/is-white.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { DEFAULT, defmulti } from "@thi.ng/defmulti/defmulti";
2
2
  import { EPS } from "./api/constants.js";
3
+ import { __dispatch0 } from "./internal/dispatch.js";
3
4
  import { rgb } from "./rgb/rgb.js";
4
5
  const isWhiteHsv = (x, eps = EPS) => x[1] <= eps && x[2] >= 1 - eps;
5
6
  const isWhiteRgb = (x, eps = EPS) => {
@@ -7,15 +8,17 @@ const isWhiteRgb = (x, eps = EPS) => {
7
8
  return x[0] >= eps && x[1] >= eps && x[2] >= eps;
8
9
  };
9
10
  const isWhiteLch = (x, eps = EPS) => x[1] <= eps && x[0] >= 1 - eps;
10
- export const isWhite = defmulti((x) => x.mode, {}, {
11
+ export const isWhite = defmulti(__dispatch0, {
12
+ hsl: "hsv",
13
+ hsi: "hsv",
14
+ labD50: "lch",
15
+ labD65: "lch",
16
+ srgb: "rgb",
17
+ ycc: "lch",
18
+ }, {
11
19
  hcy: (x, eps = EPS) => x[1] <= eps && x[2] >= 1 - eps,
12
- hsi: isWhiteHsv,
13
- hsl: isWhiteHsv,
14
20
  hsv: isWhiteHsv,
15
- labD50: isWhiteLch,
16
- labD65: isWhiteLch,
17
21
  lch: isWhiteLch,
18
22
  rgb: isWhiteRgb,
19
- ycc: isWhiteLch,
20
23
  [DEFAULT]: (x) => isWhiteRgb(rgb(x)),
21
24
  });
package/lab/lab-css.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { ReadonlyColor } from "../api.js";
5
5
  * https://www.w3.org/TR/css-color-4/#specifying-lab-lch
6
6
  * https://test.csswg.org/harness/results/css-color-4_dev/grouped/ (test reports)
7
7
  *
8
- * @param src
8
+ * @param src -
9
9
  */
10
10
  export declare const labCss: (src: ReadonlyColor) => string;
11
11
  //# sourceMappingURL=lab-css.d.ts.map
package/lab/lab-css.js CHANGED
@@ -7,7 +7,7 @@ import { __ensureAlpha } from "../internal/ensure.js";
7
7
  * https://www.w3.org/TR/css-color-4/#specifying-lab-lch
8
8
  * https://test.csswg.org/harness/results/css-color-4_dev/grouped/ (test reports)
9
9
  *
10
- * @param src
10
+ * @param src -
11
11
  */
12
12
  export const labCss = (src) => {
13
13
  const l = PC(clamp0(src[0]));
package/lab/lab-rgb.d.ts CHANGED
@@ -2,15 +2,15 @@ import type { ColorOp } from "../api.js";
2
2
  /**
3
3
  * Converts Lab to linear RGB (via XYZ) using {@link D50} white point.
4
4
  *
5
- * @param out
6
- * @param src
5
+ * @param out -
6
+ * @param src -
7
7
  */
8
8
  export declare const labRgb: ColorOp;
9
9
  /**
10
10
  * Same as {@link labRgb}, but using {@link D65} white point.
11
11
  *
12
- * @param out
13
- * @param src
12
+ * @param out -
13
+ * @param src -
14
14
  */
15
15
  export declare const labRgbD65: ColorOp;
16
16
  //# sourceMappingURL=lab-rgb.d.ts.map
package/lab/lab-rgb.js CHANGED
@@ -3,14 +3,14 @@ import { xyzRgb, xyzRgbD65 } from "../xyz/xyz-rgb.js";
3
3
  /**
4
4
  * Converts Lab to linear RGB (via XYZ) using {@link D50} white point.
5
5
  *
6
- * @param out
7
- * @param src
6
+ * @param out -
7
+ * @param src -
8
8
  */
9
9
  export const labRgb = (out, src) => xyzRgb(null, labXyz(out, src));
10
10
  /**
11
11
  * Same as {@link labRgb}, but using {@link D65} white point.
12
12
  *
13
- * @param out
14
- * @param src
13
+ * @param out -
14
+ * @param src -
15
15
  */
16
16
  export const labRgbD65 = (out, src) => xyzRgbD65(null, labXyzD65(out, src));
package/lab/lab-xyz.d.ts CHANGED
@@ -3,16 +3,16 @@ import type { Color, ColorOp, ReadonlyColor } from "../api.js";
3
3
  * Converts Lab to XYZ using provided white point (default: {@link D50}). Also
4
4
  * see {@link labXyzD65}.
5
5
  *
6
- * @param out
7
- * @param src
8
- * @param white
6
+ * @param out -
7
+ * @param src -
8
+ * @param white -
9
9
  */
10
10
  export declare const labXyz: (out: Color | null, src: ReadonlyColor, white?: number[]) => import("@thi.ng/vectors").Vec;
11
11
  /**
12
12
  * Same as {@link labXyz}, but using hardcoded {@link D65} white point.
13
13
  *
14
- * @param out
15
- * @param src
14
+ * @param out -
15
+ * @param src -
16
16
  */
17
17
  export declare const labXyzD65: ColorOp;
18
18
  //# sourceMappingURL=lab-xyz.d.ts.map
package/lab/lab-xyz.js CHANGED
@@ -9,9 +9,9 @@ const transform = (x) => {
9
9
  * Converts Lab to XYZ using provided white point (default: {@link D50}). Also
10
10
  * see {@link labXyzD65}.
11
11
  *
12
- * @param out
13
- * @param src
14
- * @param white
12
+ * @param out -
13
+ * @param src -
14
+ * @param white -
15
15
  */
16
16
  export const labXyz = (out, src, white = D50) => {
17
17
  const y = (src[0] + 0.16) / 1.16;
@@ -20,7 +20,7 @@ export const labXyz = (out, src, white = D50) => {
20
20
  /**
21
21
  * Same as {@link labXyz}, but using hardcoded {@link D65} white point.
22
22
  *
23
- * @param out
24
- * @param src
23
+ * @param out -
24
+ * @param src -
25
25
  */
26
26
  export const labXyzD65 = (out, src) => labXyz(out, src, D65);
package/lch/lch-css.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { ReadonlyColor } from "../api.js";
5
5
  * https://www.w3.org/TR/css-color-4/#specifying-lab-lch
6
6
  * https://test.csswg.org/harness/results/css-color-4_dev/grouped/ (test reports)
7
7
  *
8
- * @param src
8
+ * @param src -
9
9
  */
10
10
  export declare const lchCss: (src: ReadonlyColor) => string;
11
11
  //# sourceMappingURL=lch-css.d.ts.map
package/lch/lch-css.js CHANGED
@@ -8,7 +8,7 @@ import { __ensureAlpha } from "../internal/ensure.js";
8
8
  * https://www.w3.org/TR/css-color-4/#specifying-lab-lch
9
9
  * https://test.csswg.org/harness/results/css-color-4_dev/grouped/ (test reports)
10
10
  *
11
- * @param src
11
+ * @param src -
12
12
  */
13
13
  export const lchCss = (src) => {
14
14
  const l = PC(clamp0(src[0]));
package/lch/lch.js CHANGED
@@ -13,6 +13,7 @@ export const lch = defColor({
13
13
  mode: "lch",
14
14
  channels: {
15
15
  c: { range: [0, 1.312] },
16
+ h: { hue: true },
16
17
  },
17
18
  order: ["l", "c", "h", "alpha"],
18
19
  from: {
package/lighten.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { TypedColor } from "./api.js";
2
+ /**
3
+ * Adjust the "lightness" (luma, brightness etc.) channel of given `src` color
4
+ * and `delta` offset. Writes result into `out` (or if null, back into `src`).
5
+ *
6
+ * @param out -
7
+ * @param src -
8
+ * @param delta -
9
+ */
10
+ export declare const lighten: import("@thi.ng/defmulti").MultiFn3<import("@thi.ng/vectors").Vec | null, TypedColor<any>, number, import("@thi.ng/vectors").Vec>;
11
+ //# sourceMappingURL=lighten.d.ts.map
package/lighten.js ADDED
@@ -0,0 +1,21 @@
1
+ import { defmulti } from "@thi.ng/defmulti/defmulti";
2
+ import { clamp01 } from "@thi.ng/math/interval";
3
+ import { set4 } from "@thi.ng/vectors/set";
4
+ import { __dispatch1 } from "./internal/dispatch.js";
5
+ const $ = (id) => (out, src, n) => {
6
+ out = set4(out || src, src);
7
+ out[id] = clamp01(out[id] + n);
8
+ return out;
9
+ };
10
+ /**
11
+ * Adjust the "lightness" (luma, brightness etc.) channel of given `src` color
12
+ * and `delta` offset. Writes result into `out` (or if null, back into `src`).
13
+ *
14
+ * @param out -
15
+ * @param src -
16
+ * @param delta -
17
+ */
18
+ export const lighten = defmulti(__dispatch1, { hsv: "hsl", hsi: "hsl", hcy: "hsl" }, {
19
+ hsl: $(2),
20
+ lch: $(0),
21
+ });
@@ -3,8 +3,8 @@ import type { ReadonlyColor } from "./api.js";
3
3
  * Computes RGB luminance, optionally using provided weights (by default:
4
4
  * {@link RGB_LUMINANCE_REC709}).
5
5
  *
6
- * @param rgb
7
- * @param weights
6
+ * @param rgb -
7
+ * @param weights -
8
8
  */
9
9
  export declare const luminanceRgb: (rgb: ReadonlyColor, weights?: number[]) => number;
10
10
  /**
package/luminance-rgb.js CHANGED
@@ -4,8 +4,8 @@ import { RGB_LUMINANCE_REC709, RGB_LUMINANCE_REC601 } from "./api/constants.js";
4
4
  * Computes RGB luminance, optionally using provided weights (by default:
5
5
  * {@link RGB_LUMINANCE_REC709}).
6
6
  *
7
- * @param rgb
8
- * @param weights
7
+ * @param rgb -
8
+ * @param weights -
9
9
  */
10
10
  export const luminanceRgb = (rgb, weights = RGB_LUMINANCE_REC709) => dot3(rgb, weights);
11
11
  /**
package/luminance.d.ts CHANGED
@@ -4,10 +4,10 @@ import type { MaybeColor } from "./api.js";
4
4
  * format.
5
5
  *
6
6
  * @remarks
7
- * For many color spaces, the luminance information is readily available and
7
+ * For many color spaces, luminance-related information is readily available and
8
8
  * will simply result in looking up the relevant channel value. For others,
9
9
  * unless a direct implementation is available, colors will first be converted
10
10
  * to linear RGB.
11
11
  */
12
- export declare const luminance: import("@thi.ng/defmulti/api").MultiFn1<MaybeColor, number>;
12
+ export declare const luminance: import("@thi.ng/defmulti").MultiFn1<MaybeColor, number>;
13
13
  //# sourceMappingURL=luminance.d.ts.map
package/luminance.js CHANGED
@@ -1,17 +1,18 @@
1
1
  import { DEFAULT, defmulti } from "@thi.ng/defmulti/defmulti";
2
2
  import { rgb } from "./rgb/rgb.js";
3
3
  import { luminanceAbgr32, luminanceArgb32, luminanceRgb, luminanceSrgb, } from "./luminance-rgb.js";
4
+ import { __dispatch0 } from "./internal/dispatch.js";
4
5
  /**
5
6
  * Multi-method to compute relative luminance from any supported input color
6
7
  * format.
7
8
  *
8
9
  * @remarks
9
- * For many color spaces, the luminance information is readily available and
10
+ * For many color spaces, luminance-related information is readily available and
10
11
  * will simply result in looking up the relevant channel value. For others,
11
12
  * unless a direct implementation is available, colors will first be converted
12
13
  * to linear RGB.
13
14
  */
14
- export const luminance = defmulti((col) => col.mode, { lch: "lab", oklab: "lab", ycc: "lab", xyy: "hcy" }, {
15
+ export const luminance = defmulti(__dispatch0, { lch: "lab", oklab: "lab", ycc: "lab", xyy: "hcy" }, {
15
16
  argb32: luminanceArgb32,
16
17
  abgr32: luminanceAbgr32,
17
18
  hcy: (x) => x[2],
@@ -0,0 +1,8 @@
1
+ export declare const maxChroma: (l: number, h: number) => number;
2
+ export declare const lchMaxChroma: (l: number, h: number, a?: number) => import("./lch/lch.js").LCH;
3
+ export declare const maxLumaChroma: (h: number) => {
4
+ l: number;
5
+ c: number;
6
+ };
7
+ export declare const lchMaxLumaChroma: (h: number, a?: number) => import("./lch/lch.js").LCH;
8
+ //# sourceMappingURL=max-chroma.d.ts.map