@thi.ng/color 3.2.6 → 4.0.3

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 (189) hide show
  1. package/CHANGELOG.md +162 -230
  2. package/README.md +31 -15
  3. package/{ops/alpha.d.ts → alpha.d.ts} +1 -1
  4. package/{ops/alpha.js → alpha.js} +1 -1
  5. package/{ops/analog.d.ts → analog.d.ts} +3 -3
  6. package/{ops/analog.js → analog.js} +10 -10
  7. package/api/constants.js +18 -73
  8. package/api/gradients.d.ts +1 -1
  9. package/api/ranges.d.ts +2 -2
  10. package/api.d.ts +7 -2
  11. package/{ops/clamp.d.ts → clamp.d.ts} +1 -1
  12. package/{ops/clamp.js → clamp.js} +6 -5
  13. package/{ops/closest-hue.d.ts → closest-hue.d.ts} +1 -1
  14. package/{ops/closest-hue.js → closest-hue.js} +1 -1
  15. package/{ops/color-range.d.ts → color-range.d.ts} +2 -2
  16. package/{ops/color-range.js → color-range.js} +25 -18
  17. package/color.d.ts +1 -1
  18. package/color.js +16 -16
  19. package/convert.d.ts +1 -1
  20. package/convert.js +4 -4
  21. package/{ops/cosine-gradients.d.ts → cosine-gradients.d.ts} +2 -2
  22. package/{ops/cosine-gradients.js → cosine-gradients.js} +13 -5
  23. package/css/css.d.ts +1 -1
  24. package/css/css.js +12 -11
  25. package/css/parse-css.d.ts +1 -1
  26. package/css/parse-css.js +12 -9
  27. package/defcolor.d.ts +1 -1
  28. package/defcolor.js +24 -11
  29. package/{ops/distance.d.ts → distance.d.ts} +2 -2
  30. package/{ops/distance.js → distance.js} +7 -5
  31. package/{ops/gradients.d.ts → gradients.d.ts} +2 -2
  32. package/{ops/gradients.js → gradients.js} +3 -3
  33. package/hcy/hcy-rgb.d.ts +1 -1
  34. package/hcy/hcy-rgb.js +6 -6
  35. package/hcy/hcy.d.ts +1 -1
  36. package/hcy/hcy.js +4 -2
  37. package/hsi/hsi-rgb.d.ts +1 -1
  38. package/hsi/hsi-rgb.js +2 -2
  39. package/hsi/hsi.d.ts +1 -1
  40. package/hsi/hsi.js +4 -2
  41. package/hsl/hsl-css.d.ts +1 -1
  42. package/hsl/hsl-css.js +5 -4
  43. package/hsl/hsl-hsv.d.ts +1 -1
  44. package/hsl/hsl-hsv.js +1 -1
  45. package/hsl/hsl-rgb.d.ts +1 -1
  46. package/hsl/hsl-rgb.js +5 -5
  47. package/hsl/hsl.d.ts +1 -1
  48. package/hsl/hsl.js +5 -3
  49. package/hsv/hsv-css.d.ts +1 -1
  50. package/hsv/hsv-css.js +2 -2
  51. package/hsv/hsv-hsl.d.ts +1 -1
  52. package/hsv/hsv-hsl.js +1 -1
  53. package/hsv/hsv-rgb.d.ts +1 -1
  54. package/hsv/hsv-rgb.js +3 -3
  55. package/hsv/hsv.d.ts +1 -1
  56. package/hsv/hsv.js +5 -3
  57. package/index.d.ts +87 -87
  58. package/index.js +87 -87
  59. package/int/int-css.js +2 -2
  60. package/int/int-int.js +1 -1
  61. package/int/int-rgb.d.ts +1 -1
  62. package/int/int-rgb.js +2 -2
  63. package/int/int-srgb.d.ts +1 -1
  64. package/int/int-srgb.js +2 -2
  65. package/int/int.d.ts +24 -11
  66. package/int/int.js +59 -19
  67. package/internal/ensure.d.ts +5 -0
  68. package/internal/{ensure-args.js → ensure.js} +4 -1
  69. package/internal/matrix-ops.d.ts +8 -5
  70. package/internal/matrix-ops.js +12 -8
  71. package/internal/scale.d.ts +3 -0
  72. package/internal/scale.js +2 -0
  73. package/{ops/invert.d.ts → invert.d.ts} +1 -1
  74. package/{ops/invert.js → invert.js} +3 -2
  75. package/is-black.d.ts +3 -0
  76. package/{ops/is-black.js → is-black.js} +5 -6
  77. package/is-gray.d.ts +3 -0
  78. package/{ops/is-gray.js → is-gray.js} +6 -7
  79. package/is-white.d.ts +3 -0
  80. package/{ops/is-white.js → is-white.js} +5 -6
  81. package/lab/lab-css.d.ts +1 -1
  82. package/lab/lab-css.js +4 -4
  83. package/lab/lab-lab.d.ts +1 -1
  84. package/lab/lab-lab.js +3 -3
  85. package/lab/lab-lch.d.ts +1 -1
  86. package/lab/lab-lch.js +6 -5
  87. package/lab/lab-rgb.d.ts +1 -1
  88. package/lab/lab-rgb.js +2 -2
  89. package/lab/lab-xyz.d.ts +1 -1
  90. package/lab/lab-xyz.js +4 -4
  91. package/lab/lab50.d.ts +1 -1
  92. package/lab/lab50.js +8 -6
  93. package/lab/lab65.d.ts +1 -1
  94. package/lab/lab65.js +8 -6
  95. package/lch/lch-css.d.ts +1 -1
  96. package/lch/lch-css.js +5 -4
  97. package/lch/lch.d.ts +1 -1
  98. package/lch/lch.js +8 -6
  99. package/{ops/linear.d.ts → linear.d.ts} +0 -0
  100. package/{ops/linear.js → linear.js} +0 -0
  101. package/{ops/luminance-rgb.d.ts → luminance-rgb.d.ts} +1 -1
  102. package/{ops/luminance-rgb.js → luminance-rgb.js} +2 -2
  103. package/{ops/luminance.d.ts → luminance.d.ts} +2 -3
  104. package/{ops/luminance.js → luminance.js} +5 -10
  105. package/{ops/mix.d.ts → mix.d.ts} +2 -2
  106. package/{ops/mix.js → mix.js} +7 -6
  107. package/oklab/oklab-rgb.d.ts +1 -1
  108. package/oklab/oklab-rgb.js +4 -11
  109. package/oklab/oklab-xyz.d.ts +1 -1
  110. package/oklab/oklab-xyz.js +9 -21
  111. package/oklab/oklab.d.ts +1 -1
  112. package/oklab/oklab.js +8 -6
  113. package/package.json +323 -52
  114. package/rgb/hue-rgb.d.ts +1 -1
  115. package/rgb/hue-rgb.js +3 -2
  116. package/rgb/kelvin-rgba.d.ts +1 -1
  117. package/rgb/kelvin-rgba.js +3 -3
  118. package/rgb/rgb-css.d.ts +1 -1
  119. package/rgb/rgb-css.js +2 -2
  120. package/rgb/rgb-hcv.d.ts +1 -1
  121. package/rgb/rgb-hcv.js +4 -3
  122. package/rgb/rgb-hcy.d.ts +1 -1
  123. package/rgb/rgb-hcy.js +4 -4
  124. package/rgb/rgb-hsi.d.ts +1 -1
  125. package/rgb/rgb-hsi.js +4 -3
  126. package/rgb/rgb-hsl.d.ts +1 -1
  127. package/rgb/rgb-hsl.js +2 -2
  128. package/rgb/rgb-hsv.d.ts +1 -1
  129. package/rgb/rgb-hsv.js +2 -2
  130. package/rgb/rgb-lab.d.ts +1 -1
  131. package/rgb/rgb-lab.js +2 -2
  132. package/rgb/rgb-oklab.d.ts +1 -1
  133. package/rgb/rgb-oklab.js +6 -13
  134. package/rgb/rgb-srgb.d.ts +1 -1
  135. package/rgb/rgb-srgb.js +5 -5
  136. package/rgb/rgb-xyz.d.ts +1 -1
  137. package/rgb/rgb-xyz.js +4 -4
  138. package/rgb/rgb-ycc.d.ts +1 -1
  139. package/rgb/rgb-ycc.js +5 -4
  140. package/rgb/rgb.d.ts +1 -1
  141. package/rgb/rgb.js +15 -14
  142. package/{ops/sort.d.ts → sort.d.ts} +16 -5
  143. package/{ops/sort.js → sort.js} +21 -7
  144. package/srgb/srgb-css.d.ts +1 -1
  145. package/srgb/srgb-css.js +8 -8
  146. package/srgb/srgb-int.d.ts +1 -1
  147. package/srgb/srgb-int.js +4 -4
  148. package/srgb/srgb-rgb.d.ts +1 -1
  149. package/srgb/srgb-rgb.js +5 -5
  150. package/srgb/srgb.d.ts +1 -1
  151. package/srgb/srgb.js +9 -7
  152. package/{ops/swatches.d.ts → swatches.d.ts} +1 -1
  153. package/{ops/swatches.js → swatches.js} +0 -0
  154. package/{ops/transform.d.ts → transform.d.ts} +1 -1
  155. package/{ops/transform.js → transform.js} +5 -5
  156. package/xyy/xyy-xyz.d.ts +1 -1
  157. package/xyy/xyy-xyz.js +4 -4
  158. package/xyy/xyy.d.ts +1 -1
  159. package/xyy/xyy.js +6 -3
  160. package/xyz/wavelength-xyz.d.ts +1 -1
  161. package/xyz/wavelength-xyz.js +2 -2
  162. package/xyz/xyz-lab.d.ts +1 -1
  163. package/xyz/xyz-lab.js +5 -4
  164. package/xyz/xyz-oklab.d.ts +1 -1
  165. package/xyz/xyz-oklab.js +4 -4
  166. package/xyz/xyz-rgb.d.ts +1 -1
  167. package/xyz/xyz-rgb.js +3 -3
  168. package/xyz/xyz-xyy.d.ts +1 -1
  169. package/xyz/xyz-xyy.js +4 -4
  170. package/xyz/xyz-xyz.d.ts +1 -1
  171. package/xyz/xyz-xyz.js +4 -4
  172. package/xyz/xyz50.d.ts +1 -1
  173. package/xyz/xyz50.js +10 -8
  174. package/xyz/xyz65.d.ts +1 -1
  175. package/xyz/xyz65.js +10 -8
  176. package/ycc/ycc-rgb.d.ts +1 -1
  177. package/ycc/ycc-rgb.js +4 -4
  178. package/ycc/ycc.d.ts +1 -1
  179. package/ycc/ycc.js +4 -2
  180. package/internal/ensure-alpha.d.ts +0 -2
  181. package/internal/ensure-alpha.js +0 -2
  182. package/internal/ensure-args.d.ts +0 -3
  183. package/lib/index.js +0 -2236
  184. package/lib/index.js.map +0 -1
  185. package/lib/index.umd.js +0 -1
  186. package/lib/index.umd.js.map +0 -1
  187. package/ops/is-black.d.ts +0 -3
  188. package/ops/is-gray.d.ts +0 -3
  189. package/ops/is-white.d.ts +0 -3
package/css/css.js CHANGED
@@ -1,14 +1,15 @@
1
- import { isNumber, isString } from "@thi.ng/checks";
2
- import { convert } from "../convert";
3
- import { hslCss } from "../hsl/hsl-css";
4
- import { hsvCss } from "../hsv/hsv-css";
5
- import { intArgb32Css } from "../int/int-css";
6
- import { intAbgr32Argb32 } from "../int/int-int";
7
- import { lchLab } from "../lab/lab-lch";
8
- import { labRgb, labRgbD65 } from "../lab/lab-rgb";
9
- import { rgbCss } from "../rgb/rgb-css";
10
- import { rgbSrgb } from "../rgb/rgb-srgb";
11
- import { srgbCss } from "../srgb/srgb-css";
1
+ import { isNumber } from "@thi.ng/checks/is-number";
2
+ import { isString } from "@thi.ng/checks/is-string";
3
+ import { convert } from "../convert.js";
4
+ import { hslCss } from "../hsl/hsl-css.js";
5
+ import { hsvCss } from "../hsv/hsv-css.js";
6
+ import { intArgb32Css } from "../int/int-css.js";
7
+ import { intAbgr32Argb32 } from "../int/int-int.js";
8
+ import { lchLab } from "../lab/lab-lch.js";
9
+ import { labRgb, labRgbD65 } from "../lab/lab-rgb.js";
10
+ import { rgbCss } from "../rgb/rgb-css.js";
11
+ import { rgbSrgb } from "../rgb/rgb-srgb.js";
12
+ import { srgbCss } from "../srgb/srgb-css.js";
12
13
  /** @internal */
13
14
  const CSS_CONVERSIONS = {
14
15
  abgr32: (x) => intArgb32Css(intAbgr32Argb32(x[0])),
@@ -1,5 +1,5 @@
1
1
  import type { IDeref } from "@thi.ng/api";
2
- import { IParsedColor } from "../api";
2
+ import { IParsedColor } from "../api.js";
3
3
  /**
4
4
  * Attempts to parse given CSS color into an interim {@link ParsedColor} type
5
5
  * with {@link srgb}, {@link hsl}, {@link labD50} or {@link lch} color modes.
package/css/parse-css.js CHANGED
@@ -1,12 +1,15 @@
1
- import { assert } from "@thi.ng/api";
2
- import { interleave4_12_24, interleave4_16_32 } from "@thi.ng/binary";
3
- import { isString } from "@thi.ng/checks";
4
- import { illegalArgs, unsupported } from "@thi.ng/errors";
5
- import { clamp01, fract, TAU } from "@thi.ng/math";
6
- import { ParsedColor } from "../api";
7
- import { CSS_NAMES } from "../api/names";
8
- import { CSS_SYSTEM_COLORS } from "../api/system";
9
- import { intArgb32Srgb } from "../int/int-srgb";
1
+ import { interleave4_12_24, interleave4_16_32 } from "@thi.ng/binary/splat";
2
+ import { isString } from "@thi.ng/checks/is-string";
3
+ import { assert } from "@thi.ng/errors/assert";
4
+ import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
5
+ import { unsupported } from "@thi.ng/errors/unsupported";
6
+ import { TAU } from "@thi.ng/math/api";
7
+ import { clamp01 } from "@thi.ng/math/interval";
8
+ import { fract } from "@thi.ng/math/prec";
9
+ import { ParsedColor } from "../api.js";
10
+ import { CSS_NAMES } from "../api/names.js";
11
+ import { CSS_SYSTEM_COLORS } from "../api/system.js";
12
+ import { intArgb32Srgb } from "../int/int-srgb.js";
10
13
  /**
11
14
  * Attempts to parse given CSS color into an interim {@link ParsedColor} type
12
15
  * with {@link srgb}, {@link hsl}, {@link labD50} or {@link lch} color modes.
package/defcolor.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { IRandom } from "@thi.ng/random";
2
- import type { ColorFactory, ColorMode, ColorSpec, ReadonlyColor, TypedColor } from "./api";
2
+ import type { ColorFactory, ColorMode, ColorSpec, ReadonlyColor, TypedColor } from "./api.js";
3
3
  declare type $DefColor<M extends ColorMode, K extends string> = {
4
4
  [k in K]: number;
5
5
  } & {
package/defcolor.js CHANGED
@@ -1,18 +1,30 @@
1
- import { implementsFunction, isArrayLike, isNumber, isString, } from "@thi.ng/checks";
2
- import { illegalArgs } from "@thi.ng/errors";
3
- import { EPS } from "@thi.ng/math";
4
- import { vector } from "@thi.ng/strings";
5
- import { clamp4, declareIndices, eqDelta4, mapStridedBuffer, randMinMax, set4, stridedValues, } from "@thi.ng/vectors";
6
- import { convert, defConversions } from "./convert";
7
- import { parseCss } from "./css/parse-css";
8
- import { intArgb32Rgb } from "./int/int-rgb";
9
- import { ensureArgs } from "./internal/ensure-args";
1
+ import { implementsFunction } from "@thi.ng/checks/implements-function";
2
+ import { isArrayLike } from "@thi.ng/checks/is-arraylike";
3
+ import { isNumber } from "@thi.ng/checks/is-number";
4
+ import { isString } from "@thi.ng/checks/is-string";
5
+ import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
6
+ import { EPS } from "@thi.ng/math/api";
7
+ import { vector } from "@thi.ng/strings/vector";
8
+ import { mapStridedBuffer } from "@thi.ng/vectors/buffer";
9
+ import { clamp4 } from "@thi.ng/vectors/clamp";
10
+ import { declareIndices } from "@thi.ng/vectors/compile/accessors";
11
+ import { eqDelta4 } from "@thi.ng/vectors/eqdelta";
12
+ import { stridedValues } from "@thi.ng/vectors/iterator";
13
+ import { randMinMax } from "@thi.ng/vectors/random";
14
+ import { set4 } from "@thi.ng/vectors/set";
15
+ import { convert, defConversions } from "./convert.js";
16
+ import { parseCss } from "./css/parse-css.js";
17
+ import { intArgb32Rgb } from "./int/int-rgb.js";
18
+ import { __ensureArgs } from "./internal/ensure.js";
10
19
  export const defColor = (spec) => {
11
20
  const channels = spec.channels || {};
12
21
  const order = spec.order;
13
22
  const numChannels = order.length;
14
23
  order.reduce((acc, id) => {
15
- acc[id] = Object.assign({ range: [0, 1] }, channels[id]);
24
+ acc[id] = {
25
+ range: [0, 1],
26
+ ...channels[id],
27
+ };
16
28
  return acc;
17
29
  }, channels);
18
30
  const min = order.map((id) => channels[id].range[0]);
@@ -77,6 +89,7 @@ export const defColor = (spec) => {
77
89
  };
78
90
  declareIndices($Color.prototype, order);
79
91
  defConversions(spec.mode, spec.from);
92
+ defConversions("rgb", { [spec.mode]: spec.toRgb });
80
93
  const fromColor = (src, mode, xs) => {
81
94
  const res = new $Color(...xs);
82
95
  return mode !== spec.mode
@@ -95,7 +108,7 @@ export const defColor = (spec) => {
95
108
  ? fromColor(src.deref(), src.mode, xs)
96
109
  : isNumber(src)
97
110
  ? xs.length && xs.every(isNumber)
98
- ? new $Color(...ensureArgs([src, ...xs]))
111
+ ? new $Color(...__ensureArgs([src, ...xs]))
99
112
  : fromColor(intArgb32Rgb([], src), "rgb", xs)
100
113
  : illegalArgs(`can't create a ${spec.mode} color from: ${src}`);
101
114
  factory.class = $Color;
@@ -1,5 +1,5 @@
1
- import { ReadonlyVec } from "@thi.ng/vectors";
2
- import type { ColorDistance } from "../api";
1
+ import { ReadonlyVec } from "@thi.ng/vectors/api";
2
+ import type { ColorDistance } from "./api.js";
3
3
  /**
4
4
  * Higher order function. Returns {@link ColorDistance} function for given color
5
5
  * channel ID.
@@ -1,8 +1,10 @@
1
- import { atan2Abs, cossin, DEG2RAD, PI, SIXTH_PI, TAU, THIRD_PI, } from "@thi.ng/math";
2
- import { dist3, dist4, ONE3 } from "@thi.ng/vectors";
3
- import { labD50 } from "../lab/lab50";
4
- import { labD65 } from "../lab/lab65";
5
- import { luminanceRgb, luminanceSrgb } from "./luminance-rgb";
1
+ import { atan2Abs, cossin } from "@thi.ng/math/angle";
2
+ import { DEG2RAD, PI, SIXTH_PI, TAU, THIRD_PI } from "@thi.ng/math/api";
3
+ import { ONE3 } from "@thi.ng/vectors/api";
4
+ import { dist3, dist4 } from "@thi.ng/vectors/dist";
5
+ import { labD50 } from "./lab/lab50.js";
6
+ import { labD65 } from "./lab/lab65.js";
7
+ import { luminanceRgb, luminanceSrgb } from "./luminance-rgb.js";
6
8
  const { abs, cos, hypot, sin, sqrt } = Math;
7
9
  /**
8
10
  * Higher order function. Returns {@link ColorDistance} function for given color
@@ -1,6 +1,6 @@
1
1
  import type { NumericArray } from "@thi.ng/api";
2
- import type { TypedColor } from "../api";
3
- import type { GradientOpts } from "../api/gradients";
2
+ import type { TypedColor } from "./api.js";
3
+ import type { GradientOpts } from "./api/gradients.js";
4
4
  /**
5
5
  * Similar to {@link multiCosineGradient}, but using any number of gradient
6
6
  * color stops and isn't limited to RGB, but for arbitrary color types.
@@ -1,6 +1,6 @@
1
- import { tween } from "@thi.ng/transducers";
2
- import { setS4 } from "@thi.ng/vectors";
3
- import { mix as $mix } from "../ops/mix";
1
+ import { tween } from "@thi.ng/transducers/tween";
2
+ import { setS4 } from "@thi.ng/vectors/sets";
3
+ import { mix as $mix } from "./mix.js";
4
4
  /**
5
5
  * Similar to {@link multiCosineGradient}, but using any number of gradient
6
6
  * color stops and isn't limited to RGB, but for arbitrary color types.
package/hcy/hcy-rgb.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ColorOp } from "../api";
1
+ import type { ColorOp } from "../api.js";
2
2
  export declare const hcyRgb: ColorOp;
3
3
  //# sourceMappingURL=hcy-rgb.d.ts.map
package/hcy/hcy-rgb.js CHANGED
@@ -1,13 +1,13 @@
1
- import { clamp01 } from "@thi.ng/math";
2
- import { setC3 } from "@thi.ng/vectors";
3
- import { hueRgb } from "../rgb/hue-rgb";
4
- import { ensureAlpha } from "../internal/ensure-alpha";
5
- import { luminanceRgb } from "../ops/luminance-rgb";
1
+ import { clamp01 } from "@thi.ng/math/interval";
2
+ import { setC3 } from "@thi.ng/vectors/setc";
3
+ import { __ensureAlpha } from "../internal/ensure.js";
4
+ import { luminanceRgb } from "../luminance-rgb.js";
5
+ import { hueRgb } from "../rgb/hue-rgb.js";
6
6
  export const hcyRgb = (out, src) => {
7
7
  const h = src[0];
8
8
  let c = src[1];
9
9
  const y = src[2];
10
- const rgb = hueRgb(out || src, h, ensureAlpha(src[3]));
10
+ const rgb = hueRgb(out || src, h, __ensureAlpha(src[3]));
11
11
  const lum = luminanceRgb(rgb);
12
12
  if (y < lum) {
13
13
  c *= y / lum;
package/hcy/hcy.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { NumericArray } from "@thi.ng/api";
2
2
  import type { IRandom } from "@thi.ng/random";
3
- import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api";
3
+ import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
4
4
  export declare class HCY implements TypedColor<HCY> {
5
5
  buf: NumericArray;
6
6
  offset: number;
package/hcy/hcy.js CHANGED
@@ -1,7 +1,9 @@
1
- import { defColor } from "../defcolor";
2
- import { rgbHcy } from "../rgb/rgb-hcy";
1
+ import { defColor } from "../defcolor.js";
2
+ import { rgbHcy } from "../rgb/rgb-hcy.js";
3
+ import { hcyRgb } from "./hcy-rgb.js";
3
4
  export const hcy = defColor({
4
5
  mode: "hcy",
5
6
  order: ["h", "c", "y", "alpha"],
6
7
  from: { rgb: rgbHcy, srgb: rgbHcy },
8
+ toRgb: hcyRgb,
7
9
  });
package/hsi/hsi-rgb.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ColorOp } from "../api";
1
+ import type { ColorOp } from "../api.js";
2
2
  export declare const hsiRgb: ColorOp;
3
3
  //# sourceMappingURL=hsi-rgb.d.ts.map
package/hsi/hsi-rgb.js CHANGED
@@ -1,5 +1,5 @@
1
- import { setC3 } from "@thi.ng/vectors";
2
- import { clampH } from "../ops/clamp";
1
+ import { setC3 } from "@thi.ng/vectors/setc";
2
+ import { clampH } from "../clamp.js";
3
3
  // https://en.wikipedia.org/wiki/HSL_and_HSV#From_HSI
4
4
  export const hsiRgb = (out, src) => {
5
5
  out = clampH(out || src, src);
package/hsi/hsi.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { NumericArray } from "@thi.ng/api";
2
2
  import type { IRandom } from "@thi.ng/random";
3
- import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api";
3
+ import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
4
4
  export declare class HSI implements TypedColor<HSI> {
5
5
  buf: NumericArray;
6
6
  offset: number;
package/hsi/hsi.js CHANGED
@@ -1,7 +1,9 @@
1
- import { defColor } from "../defcolor";
2
- import { rgbHsi } from "../rgb/rgb-hsi";
1
+ import { defColor } from "../defcolor.js";
2
+ import { rgbHsi } from "../rgb/rgb-hsi.js";
3
+ import { hsiRgb } from "./hsi-rgb.js";
3
4
  export const hsi = defColor({
4
5
  mode: "hsi",
5
6
  order: ["h", "s", "i", "alpha"],
6
7
  from: { rgb: rgbHsi, srgb: rgbHsi },
8
+ toRgb: hsiRgb,
7
9
  });
package/hsl/hsl-css.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ReadonlyColor } from "../api";
1
+ import type { ReadonlyColor } from "../api.js";
2
2
  export declare const hslCss: (src: ReadonlyColor) => string;
3
3
  //# sourceMappingURL=hsl-css.d.ts.map
package/hsl/hsl-css.js CHANGED
@@ -1,11 +1,12 @@
1
- import { clamp01, fract } from "@thi.ng/math";
2
- import { FF, PC } from "../api/constants";
3
- import { ensureAlpha } from "../internal/ensure-alpha";
1
+ import { clamp01 } from "@thi.ng/math/interval";
2
+ import { fract } from "@thi.ng/math/prec";
3
+ import { FF, PC } from "../api/constants.js";
4
+ import { __ensureAlpha } from "../internal/ensure.js";
4
5
  export const hslCss = (src) => {
5
6
  const h = FF(fract(src[0]) * 360);
6
7
  const s = PC(clamp01(src[1]));
7
8
  const l = PC(clamp01(src[2]));
8
- const a = ensureAlpha(src[3]);
9
+ const a = __ensureAlpha(src[3]);
9
10
  // TODO update to new syntax once CSS Color L4 is more widely supported
10
11
  // https://www.w3.org/TR/css-color-4/#serializing-lab-lch
11
12
  // https://test.csswg.org/harness/results/css-color-4_dev/grouped/ (test reports)
package/hsl/hsl-hsv.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ColorOp } from "../api";
1
+ import type { ColorOp } from "../api.js";
2
2
  export declare const hslHsv: ColorOp;
3
3
  //# sourceMappingURL=hsl-hsv.d.ts.map
package/hsl/hsl-hsv.js CHANGED
@@ -1,4 +1,4 @@
1
- import { clampH } from "../ops/clamp";
1
+ import { clampH } from "../clamp.js";
2
2
  export const hslHsv = (out, src) => {
3
3
  out = clampH(out || src, src);
4
4
  const s = out[1];
package/hsl/hsl-rgb.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ColorOp } from "../api";
1
+ import type { ColorOp } from "../api.js";
2
2
  export declare const hslRgb: ColorOp;
3
3
  //# sourceMappingURL=hsl-rgb.d.ts.map
package/hsl/hsl-rgb.js CHANGED
@@ -1,11 +1,11 @@
1
- import { clamp01 } from "@thi.ng/math";
2
- import { setC3 } from "@thi.ng/vectors";
3
- import { hueRgb } from "../rgb/hue-rgb";
4
- import { ensureAlpha } from "../internal/ensure-alpha";
1
+ import { clamp01 } from "@thi.ng/math/interval";
2
+ import { setC3 } from "@thi.ng/vectors/setc";
3
+ import { hueRgb } from "../rgb/hue-rgb.js";
4
+ import { __ensureAlpha } from "../internal/ensure.js";
5
5
  export const hslRgb = (out, src) => {
6
6
  const s = clamp01(src[1]);
7
7
  const l = clamp01(src[2]);
8
- out = hueRgb(out || src, src[0], ensureAlpha(src[3]));
8
+ out = hueRgb(out || src, src[0], __ensureAlpha(src[3]));
9
9
  const c = (1 - Math.abs(2 * l - 1)) * s;
10
10
  return setC3(out, (out[0] - 0.5) * c + l, (out[1] - 0.5) * c + l, (out[2] - 0.5) * c + l);
11
11
  };
package/hsl/hsl.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { NumericArray } from "@thi.ng/api";
2
2
  import type { IRandom } from "@thi.ng/random";
3
- import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api";
3
+ import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
4
4
  export declare class HSL implements TypedColor<HSL> {
5
5
  buf: NumericArray;
6
6
  offset: number;
package/hsl/hsl.js CHANGED
@@ -1,8 +1,10 @@
1
- import { defColor } from "../defcolor";
2
- import { hsvHsl } from "../hsv/hsv-hsl";
3
- import { rgbHsl } from "../rgb/rgb-hsl";
1
+ import { defColor } from "../defcolor.js";
2
+ import { hsvHsl } from "../hsv/hsv-hsl.js";
3
+ import { rgbHsl } from "../rgb/rgb-hsl.js";
4
+ import { hslRgb } from "./hsl-rgb.js";
4
5
  export const hsl = defColor({
5
6
  mode: "hsl",
6
7
  order: ["h", "s", "l", "alpha"],
7
8
  from: { rgb: rgbHsl, srgb: rgbHsl, hsv: hsvHsl },
9
+ toRgb: hslRgb,
8
10
  });
package/hsv/hsv-css.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ReadonlyColor } from "../api";
1
+ import type { ReadonlyColor } from "../api.js";
2
2
  export declare const hsvCss: (src: ReadonlyColor) => string;
3
3
  //# sourceMappingURL=hsv-css.d.ts.map
package/hsv/hsv-css.js CHANGED
@@ -1,3 +1,3 @@
1
- import { hslCss } from "../hsl/hsl-css";
2
- import { hsvHsl } from "./hsv-hsl";
1
+ import { hslCss } from "../hsl/hsl-css.js";
2
+ import { hsvHsl } from "./hsv-hsl.js";
3
3
  export const hsvCss = (src) => hslCss(hsvHsl([], src));
package/hsv/hsv-hsl.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ColorOp } from "../api";
1
+ import type { ColorOp } from "../api.js";
2
2
  export declare const hsvHsl: ColorOp;
3
3
  //# sourceMappingURL=hsv-hsl.d.ts.map
package/hsv/hsv-hsl.js CHANGED
@@ -1,4 +1,4 @@
1
- import { clampH } from "../ops/clamp";
1
+ import { clampH } from "../clamp.js";
2
2
  export const hsvHsl = (out, src) => {
3
3
  out = clampH(out || src, src);
4
4
  const s = out[1];
package/hsv/hsv-rgb.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ColorOp } from "../api";
1
+ import type { ColorOp } from "../api.js";
2
2
  export declare const hsvRgb: ColorOp;
3
3
  //# sourceMappingURL=hsv-rgb.d.ts.map
package/hsv/hsv-rgb.js CHANGED
@@ -1,6 +1,6 @@
1
- import { setC3 } from "@thi.ng/vectors";
2
- import { clampH } from "../ops/clamp";
3
- import { hueRgb } from "../rgb/hue-rgb";
1
+ import { setC3 } from "@thi.ng/vectors/setc";
2
+ import { clampH } from "../clamp.js";
3
+ import { hueRgb } from "../rgb/hue-rgb.js";
4
4
  export const hsvRgb = (out, src) => {
5
5
  out = clampH(out || src, src);
6
6
  const s = out[1];
package/hsv/hsv.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { NumericArray } from "@thi.ng/api";
2
2
  import type { IRandom } from "@thi.ng/random";
3
- import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api";
3
+ import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
4
4
  export declare class HSV implements TypedColor<HSV> {
5
5
  buf: NumericArray;
6
6
  offset: number;
package/hsv/hsv.js CHANGED
@@ -1,8 +1,10 @@
1
- import { defColor } from "../defcolor";
2
- import { hslHsv } from "../hsl/hsl-hsv";
3
- import { rgbHsv } from "../rgb/rgb-hsv";
1
+ import { defColor } from "../defcolor.js";
2
+ import { hslHsv } from "../hsl/hsl-hsv.js";
3
+ import { rgbHsv } from "../rgb/rgb-hsv.js";
4
+ import { hsvRgb } from "./hsv-rgb.js";
4
5
  export const hsv = defColor({
5
6
  mode: "hsv",
6
7
  order: ["h", "s", "v", "alpha"],
7
8
  from: { rgb: rgbHsv, srgb: rgbHsv, hsl: hslHsv },
9
+ toRgb: hsvRgb,
8
10
  });
package/index.d.ts CHANGED
@@ -1,88 +1,88 @@
1
- export * from "./api";
2
- export * from "./api/constants";
3
- export * from "./api/gradients";
4
- export * from "./api/names";
5
- export * from "./api/ranges";
6
- export * from "./api/system";
7
- export * from "./color";
8
- export * from "./convert";
9
- export * from "./defcolor";
10
- export * from "./css/css";
11
- export * from "./css/parse-css";
12
- export * from "./hcy/hcy-rgb";
13
- export * from "./hcy/hcy";
14
- export * from "./hsi/hsi-rgb";
15
- export * from "./hsi/hsi";
16
- export * from "./hsl/hsl-css";
17
- export * from "./hsl/hsl-hsv";
18
- export * from "./hsl/hsl-rgb";
19
- export * from "./hsl/hsl";
20
- export * from "./hsv/hsv-css";
21
- export * from "./hsv/hsv-hsl";
22
- export * from "./hsv/hsv-rgb";
23
- export * from "./hsv/hsv";
24
- export * from "./int/int-css";
25
- export * from "./int/int-int";
26
- export * from "./int/int-rgb";
27
- export * from "./int/int-srgb";
28
- export * from "./int/int";
29
- export * from "./lab/lab-css";
30
- export * from "./lab/lab-lab";
31
- export * from "./lab/lab-lch";
32
- export * from "./lab/lab-rgb";
33
- export * from "./lab/lab-xyz";
34
- export * from "./lab/lab50";
35
- export * from "./lab/lab65";
36
- export * from "./lch/lch-css";
37
- export * from "./lch/lch";
38
- export * from "./oklab/oklab-rgb";
39
- export * from "./oklab/oklab-xyz";
40
- export * from "./oklab/oklab";
41
- export * from "./ops/alpha";
42
- export * from "./ops/analog";
43
- export * from "./ops/clamp";
44
- export * from "./ops/closest-hue";
45
- export * from "./ops/color-range";
46
- export * from "./ops/cosine-gradients";
47
- export * from "./ops/distance";
48
- export * from "./ops/gradients";
49
- export * from "./ops/invert";
50
- export * from "./ops/is-gray";
51
- export * from "./ops/linear";
52
- export * from "./ops/luminance-rgb";
53
- export * from "./ops/luminance";
54
- export * from "./ops/mix";
55
- export * from "./ops/sort";
56
- export * from "./ops/swatches";
57
- export * from "./ops/transform";
58
- export * from "./rgb/hue-rgb";
59
- export * from "./rgb/kelvin-rgba";
60
- export * from "./rgb/rgb-css";
61
- export * from "./rgb/rgb-hcv";
62
- export * from "./rgb/rgb-hcy";
63
- export * from "./rgb/rgb-hsi";
64
- export * from "./rgb/rgb-hsl";
65
- export * from "./rgb/rgb-hsv";
66
- export * from "./rgb/rgb-lab";
67
- export * from "./rgb/rgb-oklab";
68
- export * from "./rgb/rgb-srgb";
69
- export * from "./rgb/rgb-xyz";
70
- export * from "./rgb/rgb-ycc";
71
- export * from "./rgb/rgb";
72
- export * from "./srgb/srgb-css";
73
- export * from "./srgb/srgb-int";
74
- export * from "./srgb/srgb-rgb";
75
- export * from "./srgb/srgb";
76
- export * from "./xyy/xyy-xyz";
77
- export * from "./xyy/xyy";
78
- export * from "./xyz/wavelength-xyz";
79
- export * from "./xyz/xyz-lab";
80
- export * from "./xyz/xyz-oklab";
81
- export * from "./xyz/xyz-rgb";
82
- export * from "./xyz/xyz-xyy";
83
- export * from "./xyz/xyz-xyz";
84
- export * from "./xyz/xyz50";
85
- export * from "./xyz/xyz65";
86
- export * from "./ycc/ycc-rgb";
87
- export * from "./ycc/ycc";
1
+ export * from "./api.js";
2
+ export * from "./api/constants.js";
3
+ export * from "./api/gradients.js";
4
+ export * from "./api/names.js";
5
+ export * from "./api/ranges.js";
6
+ export * from "./api/system.js";
7
+ export * from "./color.js";
8
+ export * from "./convert.js";
9
+ export * from "./defcolor.js";
10
+ export * from "./css/css.js";
11
+ export * from "./css/parse-css.js";
12
+ export * from "./hcy/hcy-rgb.js";
13
+ export * from "./hcy/hcy.js";
14
+ export * from "./hsi/hsi-rgb.js";
15
+ export * from "./hsi/hsi.js";
16
+ export * from "./hsl/hsl-css.js";
17
+ export * from "./hsl/hsl-hsv.js";
18
+ export * from "./hsl/hsl-rgb.js";
19
+ export * from "./hsl/hsl.js";
20
+ export * from "./hsv/hsv-css.js";
21
+ export * from "./hsv/hsv-hsl.js";
22
+ export * from "./hsv/hsv-rgb.js";
23
+ export * from "./hsv/hsv.js";
24
+ export * from "./int/int-css.js";
25
+ export * from "./int/int-int.js";
26
+ export * from "./int/int-rgb.js";
27
+ export * from "./int/int-srgb.js";
28
+ export * from "./int/int.js";
29
+ export * from "./lab/lab-css.js";
30
+ export * from "./lab/lab-lab.js";
31
+ export * from "./lab/lab-lch.js";
32
+ export * from "./lab/lab-rgb.js";
33
+ export * from "./lab/lab-xyz.js";
34
+ export * from "./lab/lab50.js";
35
+ export * from "./lab/lab65.js";
36
+ export * from "./lch/lch-css.js";
37
+ export * from "./lch/lch.js";
38
+ export * from "./oklab/oklab-rgb.js";
39
+ export * from "./oklab/oklab-xyz.js";
40
+ export * from "./oklab/oklab.js";
41
+ export * from "./alpha.js";
42
+ export * from "./analog.js";
43
+ export * from "./clamp.js";
44
+ export * from "./closest-hue.js";
45
+ export * from "./color-range.js";
46
+ export * from "./cosine-gradients.js";
47
+ export * from "./distance.js";
48
+ export * from "./gradients.js";
49
+ export * from "./invert.js";
50
+ export * from "./is-gray.js";
51
+ export * from "./linear.js";
52
+ export * from "./luminance-rgb.js";
53
+ export * from "./luminance.js";
54
+ export * from "./mix.js";
55
+ export * from "./sort.js";
56
+ export * from "./swatches.js";
57
+ export * from "./transform.js";
58
+ export * from "./rgb/hue-rgb.js";
59
+ export * from "./rgb/kelvin-rgba.js";
60
+ export * from "./rgb/rgb-css.js";
61
+ export * from "./rgb/rgb-hcv.js";
62
+ export * from "./rgb/rgb-hcy.js";
63
+ export * from "./rgb/rgb-hsi.js";
64
+ export * from "./rgb/rgb-hsl.js";
65
+ export * from "./rgb/rgb-hsv.js";
66
+ export * from "./rgb/rgb-lab.js";
67
+ export * from "./rgb/rgb-oklab.js";
68
+ export * from "./rgb/rgb-srgb.js";
69
+ export * from "./rgb/rgb-xyz.js";
70
+ export * from "./rgb/rgb-ycc.js";
71
+ export * from "./rgb/rgb.js";
72
+ export * from "./srgb/srgb-css.js";
73
+ export * from "./srgb/srgb-int.js";
74
+ export * from "./srgb/srgb-rgb.js";
75
+ export * from "./srgb/srgb.js";
76
+ export * from "./xyy/xyy-xyz.js";
77
+ export * from "./xyy/xyy.js";
78
+ export * from "./xyz/wavelength-xyz.js";
79
+ export * from "./xyz/xyz-lab.js";
80
+ export * from "./xyz/xyz-oklab.js";
81
+ export * from "./xyz/xyz-rgb.js";
82
+ export * from "./xyz/xyz-xyy.js";
83
+ export * from "./xyz/xyz-xyz.js";
84
+ export * from "./xyz/xyz50.js";
85
+ export * from "./xyz/xyz65.js";
86
+ export * from "./ycc/ycc-rgb.js";
87
+ export * from "./ycc/ycc.js";
88
88
  //# sourceMappingURL=index.d.ts.map