@zag-js/color-utils 2.0.0-next.3 → 2.0.0-next.4

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 (62) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
  9. package/dist/area-gradient.d.mts +9 -11
  10. package/dist/area-gradient.d.ts +9 -11
  11. package/dist/area-gradient.js +58 -89
  12. package/dist/area-gradient.mjs +54 -77
  13. package/dist/color-format-gradient.d.mts +76 -78
  14. package/dist/color-format-gradient.d.ts +76 -78
  15. package/dist/color-format-gradient.js +118 -185
  16. package/dist/color-format-gradient.mjs +104 -152
  17. package/dist/color.d.mts +20 -23
  18. package/dist/color.d.ts +20 -23
  19. package/dist/color.js +57 -83
  20. package/dist/color.mjs +53 -60
  21. package/dist/gamut.d.mts +2 -5
  22. package/dist/gamut.d.ts +2 -5
  23. package/dist/gamut.js +12 -34
  24. package/dist/gamut.mjs +8 -11
  25. package/dist/hsb-color.d.mts +37 -40
  26. package/dist/hsb-color.d.ts +37 -40
  27. package/dist/hsb-color.js +164 -200
  28. package/dist/hsb-color.mjs +158 -175
  29. package/dist/hsl-color.d.mts +33 -36
  30. package/dist/hsl-color.d.ts +33 -36
  31. package/dist/hsl-color.js +139 -168
  32. package/dist/hsl-color.mjs +132 -142
  33. package/dist/index.d.mts +8 -7
  34. package/dist/index.d.ts +8 -7
  35. package/dist/index.js +23 -60
  36. package/dist/index.mjs +2 -28
  37. package/dist/native-color.d.mts +1 -3
  38. package/dist/native-color.d.ts +1 -3
  39. package/dist/native-color.js +16 -39
  40. package/dist/native-color.mjs +12 -16
  41. package/dist/oklab-color.d.mts +57 -60
  42. package/dist/oklab-color.d.ts +57 -60
  43. package/dist/oklab-color.js +363 -379
  44. package/dist/oklab-color.mjs +353 -350
  45. package/dist/oklab-math.d.mts +26 -28
  46. package/dist/oklab-math.d.ts +26 -28
  47. package/dist/oklab-math.js +123 -142
  48. package/dist/oklab-math.mjs +108 -108
  49. package/dist/parse-color.d.mts +3 -6
  50. package/dist/parse-color.d.ts +3 -6
  51. package/dist/parse-color.js +22 -48
  52. package/dist/parse-color.mjs +13 -20
  53. package/dist/rgb-color.d.mts +33 -36
  54. package/dist/rgb-color.d.ts +33 -36
  55. package/dist/rgb-color.js +182 -220
  56. package/dist/rgb-color.mjs +174 -193
  57. package/dist/types.d.mts +82 -84
  58. package/dist/types.d.ts +82 -84
  59. package/dist/types.js +4 -18
  60. package/dist/types.mjs +1 -0
  61. package/package.json +3 -3
  62. package/dist/chunk-QZ7TP4HQ.mjs +0 -7
@@ -1,133 +1,133 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
1
  // src/oklab-math.ts
4
2
  function srgbChannelToLinear(c) {
5
- return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
3
+ return c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
6
4
  }
7
5
  function linearChannelToSrgb(c) {
8
- return c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
6
+ return c <= .0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - .055;
9
7
  }
10
8
  function srgbToLinearRgb(r255, g255, b255) {
11
- return {
12
- r: srgbChannelToLinear(r255 / 255),
13
- g: srgbChannelToLinear(g255 / 255),
14
- b: srgbChannelToLinear(b255 / 255)
15
- };
9
+ return {
10
+ r: srgbChannelToLinear(r255 / 255),
11
+ g: srgbChannelToLinear(g255 / 255),
12
+ b: srgbChannelToLinear(b255 / 255)
13
+ };
16
14
  }
17
15
  function linearRgbToSrgb({ r, g, b }) {
18
- return {
19
- r: Math.round(clamp01(linearChannelToSrgb(r)) * 255),
20
- g: Math.round(clamp01(linearChannelToSrgb(g)) * 255),
21
- b: Math.round(clamp01(linearChannelToSrgb(b)) * 255)
22
- };
16
+ return {
17
+ r: Math.round(clamp01(linearChannelToSrgb(r)) * 255),
18
+ g: Math.round(clamp01(linearChannelToSrgb(g)) * 255),
19
+ b: Math.round(clamp01(linearChannelToSrgb(b)) * 255)
20
+ };
23
21
  }
24
22
  function clamp01(x) {
25
- return x < 0 ? 0 : x > 1 ? 1 : x;
23
+ return x < 0 ? 0 : x > 1 ? 1 : x;
26
24
  }
27
25
  function linearRgbToOklab({ r, g, b }) {
28
- const l = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b;
29
- const m = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b;
30
- const s = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b;
31
- const l_ = Math.cbrt(l);
32
- const m_ = Math.cbrt(m);
33
- const s_ = Math.cbrt(s);
34
- return {
35
- L: 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_,
36
- a: 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_,
37
- b: 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_
38
- };
26
+ const l = .4122214708 * r + .5363325363 * g + .0514459929 * b;
27
+ const m = .2119034982 * r + .6806995451 * g + .1073969566 * b;
28
+ const s = .0883024619 * r + .2817188376 * g + .6299787005 * b;
29
+ const l_ = Math.cbrt(l);
30
+ const m_ = Math.cbrt(m);
31
+ const s_ = Math.cbrt(s);
32
+ return {
33
+ L: .2104542553 * l_ + .793617785 * m_ - .0040720468 * s_,
34
+ a: 1.9779984951 * l_ - 2.428592205 * m_ + .4505937099 * s_,
35
+ b: .0259040371 * l_ + .7827717662 * m_ - .808675766 * s_
36
+ };
39
37
  }
40
38
  function oklabToLinearRgb(L, a, b) {
41
- const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
42
- const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
43
- const s_ = L - 0.0894841775 * a - 1.291485548 * b;
44
- const l = l_ * l_ * l_;
45
- const m = m_ * m_ * m_;
46
- const s = s_ * s_ * s_;
47
- return {
48
- r: 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
49
- g: -1.2684380046 * l + 2.6097574011 * m - 0.341319396 * s,
50
- b: -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
51
- };
39
+ const l_ = L + .3963377774 * a + .2158037573 * b;
40
+ const m_ = L - .1055613458 * a - .0638541728 * b;
41
+ const s_ = L - .0894841775 * a - 1.291485548 * b;
42
+ const l = l_ * l_ * l_;
43
+ const m = m_ * m_ * m_;
44
+ const s = s_ * s_ * s_;
45
+ return {
46
+ r: 4.0767416621 * l - 3.3077115913 * m + .2309699292 * s,
47
+ g: -1.2684380046 * l + 2.6097574011 * m - .341319396 * s,
48
+ b: -.0041960863 * l - .7034186147 * m + 1.707614701 * s
49
+ };
52
50
  }
53
51
  function oklchToOklab(L, C, Hdeg) {
54
- const h = Hdeg * Math.PI / 180;
55
- return {
56
- L,
57
- a: C * Math.cos(h),
58
- b: C * Math.sin(h)
59
- };
52
+ const h = Hdeg * Math.PI / 180;
53
+ return {
54
+ L,
55
+ a: C * Math.cos(h),
56
+ b: C * Math.sin(h)
57
+ };
60
58
  }
61
59
  function oklabToOklch(L, a, b) {
62
- const C = Math.sqrt(a * a + b * b);
63
- let H = Math.atan2(b, a) * 180 / Math.PI;
64
- if (H < 0) H += 360;
65
- return { L, C, H };
60
+ const C = Math.sqrt(a * a + b * b);
61
+ let H = Math.atan2(b, a) * 180 / Math.PI;
62
+ if (H < 0) H += 360;
63
+ return {
64
+ L,
65
+ C,
66
+ H
67
+ };
66
68
  }
67
- function isLinearRgbInSrgbGamut({ r, g, b }, eps = 1e-3) {
68
- return r >= -eps && r <= 1 + eps && g >= -eps && g <= 1 + eps && b >= -eps && b <= 1 + eps;
69
+ function isLinearRgbInSrgbGamut({ r, g, b }, eps = .001) {
70
+ return r >= -eps && r <= 1 + eps && g >= -eps && g <= 1 + eps && b >= -eps && b <= 1 + eps;
69
71
  }
72
+ /** Convert Display P3 linear RGB to linear sRGB via XYZ D65. */
70
73
  function linearDisplayP3ToLinearSrgb(r, g, b) {
71
- const x = 0.4865709486482162 * r + 0.26566769316909306 * g + 0.1982172852343625 * b;
72
- const y = 0.2289745640697488 * r + 0.6917385218365064 * g + 0.079286914093745 * b;
73
- const z = 0 * r + 0.04511338185890264 * g + 1.043944368900976 * b;
74
- return {
75
- r: 3.2404541621141054 * x - 1.5371385940306088 * y - 0.4985314095560158 * z,
76
- g: -0.9692660305051868 * x + 1.8760108454466942 * y + 0.0415560175303498 * z,
77
- b: 0.0556434309591147 * x - 0.2039769598730574 * y + 1.0572251882231791 * z
78
- };
74
+ const x = .4865709486482162 * r + .26566769316909306 * g + .1982172852343625 * b;
75
+ const y = .2289745640697488 * r + .6917385218365064 * g + .079286914093745 * b;
76
+ const z = 0 * r + .04511338185890264 * g + 1.043944368900976 * b;
77
+ return {
78
+ r: 3.2404541621141054 * x - 1.5371385940306088 * y - .4985314095560158 * z,
79
+ g: -.9692660305051868 * x + 1.8760108454466942 * y + .0415560175303498 * z,
80
+ b: .0556434309591147 * x - .2039769598730574 * y + 1.0572251882231791 * z
81
+ };
79
82
  }
83
+ /**
84
+ * HSV (0-360, 0-1, 0-1) → RGB (0-1).
85
+ * Standard HSV-to-RGB conversion; the resulting RGB values are in whichever
86
+ * gamut the caller considers them to be (sRGB or Display P3).
87
+ */
80
88
  function hsvToRgb(h, s, v) {
81
- const c = v * s;
82
- const x = c * (1 - Math.abs(h / 60 % 2 - 1));
83
- const m = v - c;
84
- let r1 = 0, g1 = 0, b1 = 0;
85
- if (h < 60) {
86
- r1 = c;
87
- g1 = x;
88
- b1 = 0;
89
- } else if (h < 120) {
90
- r1 = x;
91
- g1 = c;
92
- b1 = 0;
93
- } else if (h < 180) {
94
- r1 = 0;
95
- g1 = c;
96
- b1 = x;
97
- } else if (h < 240) {
98
- r1 = 0;
99
- g1 = x;
100
- b1 = c;
101
- } else if (h < 300) {
102
- r1 = x;
103
- g1 = 0;
104
- b1 = c;
105
- } else {
106
- r1 = c;
107
- g1 = 0;
108
- b1 = x;
109
- }
110
- return [r1 + m, g1 + m, b1 + m];
89
+ const c = v * s;
90
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
91
+ const m = v - c;
92
+ let r1 = 0, g1 = 0, b1 = 0;
93
+ if (h < 60) {
94
+ r1 = c;
95
+ g1 = x;
96
+ b1 = 0;
97
+ } else if (h < 120) {
98
+ r1 = x;
99
+ g1 = c;
100
+ b1 = 0;
101
+ } else if (h < 180) {
102
+ r1 = 0;
103
+ g1 = c;
104
+ b1 = x;
105
+ } else if (h < 240) {
106
+ r1 = 0;
107
+ g1 = x;
108
+ b1 = c;
109
+ } else if (h < 300) {
110
+ r1 = x;
111
+ g1 = 0;
112
+ b1 = c;
113
+ } else {
114
+ r1 = c;
115
+ g1 = 0;
116
+ b1 = x;
117
+ }
118
+ return [
119
+ r1 + m,
120
+ g1 + m,
121
+ b1 + m
122
+ ];
111
123
  }
112
- function isDisplayP3HsvInSrgbGamut(h, s, v, eps = 1e-3) {
113
- const [r, g, b] = hsvToRgb(h, s, v);
114
- const lr = srgbChannelToLinear(r);
115
- const lg = srgbChannelToLinear(g);
116
- const lb = srgbChannelToLinear(b);
117
- const srgb = linearDisplayP3ToLinearSrgb(lr, lg, lb);
118
- return isLinearRgbInSrgbGamut(srgb, eps);
124
+ /**
125
+ * Check whether an HSV color (interpreted in the Display P3 gamut) falls
126
+ * inside the sRGB gamut. This is how Chrome DevTools draws the sRGB boundary
127
+ * on the color picker when in oklch/oklab mode.
128
+ */
129
+ function isDisplayP3HsvInSrgbGamut(h, s, v, eps = .001) {
130
+ const [r, g, b] = hsvToRgb(h, s, v);
131
+ return isLinearRgbInSrgbGamut(linearDisplayP3ToLinearSrgb(srgbChannelToLinear(r), srgbChannelToLinear(g), srgbChannelToLinear(b)), eps);
119
132
  }
120
- export {
121
- hsvToRgb,
122
- isDisplayP3HsvInSrgbGamut,
123
- isLinearRgbInSrgbGamut,
124
- linearChannelToSrgb,
125
- linearDisplayP3ToLinearSrgb,
126
- linearRgbToOklab,
127
- linearRgbToSrgb,
128
- oklabToLinearRgb,
129
- oklabToOklch,
130
- oklchToOklab,
131
- srgbChannelToLinear,
132
- srgbToLinearRgb
133
- };
133
+ export { hsvToRgb, isDisplayP3HsvInSrgbGamut, isLinearRgbInSrgbGamut, linearChannelToSrgb, linearDisplayP3ToLinearSrgb, linearRgbToOklab, linearRgbToSrgb, oklabToLinearRgb, oklabToOklch, oklchToOklab, srgbChannelToLinear, srgbToLinearRgb };
@@ -1,6 +1,3 @@
1
- import { ColorType } from './types.mjs';
2
-
3
- declare const parseColor: (value: string) => ColorType;
4
- declare const normalizeColor: (v: string | ColorType) => ColorType;
5
-
6
- export { normalizeColor, parseColor };
1
+ import { ColorType } from "./types.mjs";
2
+ export declare const parseColor: (value: string) => ColorType;
3
+ export declare const normalizeColor: (v: string | ColorType) => ColorType;
@@ -1,6 +1,3 @@
1
- import { ColorType } from './types.js';
2
-
3
- declare const parseColor: (value: string) => ColorType;
4
- declare const normalizeColor: (v: string | ColorType) => ColorType;
5
-
6
- export { normalizeColor, parseColor };
1
+ import { ColorType } from "./types.js";
2
+ export declare const parseColor: (value: string) => ColorType;
3
+ export declare const normalizeColor: (v: string | ColorType) => ColorType;
@@ -1,51 +1,25 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/parse-color.ts
21
- var parse_color_exports = {};
22
- __export(parse_color_exports, {
23
- normalizeColor: () => normalizeColor,
24
- parseColor: () => parseColor
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
25
4
  });
26
- module.exports = __toCommonJS(parse_color_exports);
27
- var import_hsb_color = require("./hsb-color.js");
28
- var import_hsl_color = require("./hsl-color.js");
29
- var import_oklab_color = require("./oklab-color.js");
30
- var import_native_color = require("./native-color.js");
31
- var import_rgb_color = require("./rgb-color.js");
32
- var parseColor = (value) => {
33
- if (import_native_color.nativeColorMap.has(value)) {
34
- return parseColor(import_native_color.nativeColorMap.get(value));
35
- }
36
- const result = import_oklab_color.OklabColor.parse(value) || import_oklab_color.OklchColor.parse(value) || import_rgb_color.RGBColor.parse(value) || import_hsb_color.HSBColor.parse(value) || import_hsl_color.HSLColor.parse(value);
37
- if (!result) {
38
- const error = new Error("Invalid color value: " + value);
39
- Error.captureStackTrace?.(error, parseColor);
40
- throw error;
41
- }
42
- return result;
5
+ const require_hsb_color = require("./hsb-color.js");
6
+ const require_hsl_color = require("./hsl-color.js");
7
+ const require_oklab_color = require("./oklab-color.js");
8
+ const require_native_color = require("./native-color.js");
9
+ const require_rgb_color = require("./rgb-color.js");
10
+ // src/parse-color.ts
11
+ const parseColor = (value) => {
12
+ if (require_native_color.nativeColorMap.has(value)) return parseColor(require_native_color.nativeColorMap.get(value));
13
+ const result = require_oklab_color.OklabColor.parse(value) || require_oklab_color.OklchColor.parse(value) || require_rgb_color.RGBColor.parse(value) || require_hsb_color.HSBColor.parse(value) || require_hsl_color.HSLColor.parse(value);
14
+ if (!result) {
15
+ const error = /* @__PURE__ */ new Error("Invalid color value: " + value);
16
+ Error.captureStackTrace?.(error, parseColor);
17
+ throw error;
18
+ }
19
+ return result;
43
20
  };
44
- var normalizeColor = (v) => {
45
- return typeof v === "string" ? parseColor(v) : v;
21
+ const normalizeColor = (v) => {
22
+ return typeof v === "string" ? parseColor(v) : v;
46
23
  };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- normalizeColor,
50
- parseColor
51
- });
24
+ exports.normalizeColor = normalizeColor;
25
+ exports.parseColor = parseColor;
@@ -1,27 +1,20 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/parse-color.ts
4
1
  import { HSBColor } from "./hsb-color.mjs";
5
2
  import { HSLColor } from "./hsl-color.mjs";
6
3
  import { OklabColor, OklchColor } from "./oklab-color.mjs";
7
4
  import { nativeColorMap } from "./native-color.mjs";
8
5
  import { RGBColor } from "./rgb-color.mjs";
9
- var parseColor = (value) => {
10
- if (nativeColorMap.has(value)) {
11
- return parseColor(nativeColorMap.get(value));
12
- }
13
- const result = OklabColor.parse(value) || OklchColor.parse(value) || RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value);
14
- if (!result) {
15
- const error = new Error("Invalid color value: " + value);
16
- Error.captureStackTrace?.(error, parseColor);
17
- throw error;
18
- }
19
- return result;
20
- };
21
- var normalizeColor = (v) => {
22
- return typeof v === "string" ? parseColor(v) : v;
6
+ // src/parse-color.ts
7
+ const parseColor = (value) => {
8
+ if (nativeColorMap.has(value)) return parseColor(nativeColorMap.get(value));
9
+ const result = OklabColor.parse(value) || OklchColor.parse(value) || RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value);
10
+ if (!result) {
11
+ const error = /* @__PURE__ */ new Error("Invalid color value: " + value);
12
+ Error.captureStackTrace?.(error, parseColor);
13
+ throw error;
14
+ }
15
+ return result;
23
16
  };
24
- export {
25
- normalizeColor,
26
- parseColor
17
+ const normalizeColor = (v) => {
18
+ return typeof v === "string" ? parseColor(v) : v;
27
19
  };
20
+ export { normalizeColor, parseColor };
@@ -1,36 +1,33 @@
1
- import { Color } from './color.mjs';
2
- import { ColorStringFormat, ColorFormat, ColorType, ColorChannel, ColorChannelRange } from './types.mjs';
3
-
4
- declare class RGBColor extends Color {
5
- private red;
6
- private green;
7
- private blue;
8
- private alpha;
9
- constructor(red: number, green: number, blue: number, alpha: number);
10
- static parse(value: string): RGBColor | undefined;
11
- toString(format?: ColorStringFormat): string;
12
- toFormat(format: ColorFormat): ColorType;
13
- toHexInt(): number;
14
- /**
15
- * Converts an RGB color value to HSB.
16
- * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
17
- * @returns An HSBColor object.
18
- */
19
- private toHSB;
20
- /**
21
- * Converts an RGB color value to HSL.
22
- * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
23
- * @returns An HSLColor object.
24
- */
25
- private toHSL;
26
- clone(): ColorType;
27
- getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions;
28
- formatChannelValue(channel: ColorChannel, locale: string): string;
29
- getChannelRange(channel: ColorChannel): ColorChannelRange;
30
- toJSON(): Record<"r" | "g" | "b" | "a", number>;
31
- getFormat(): ColorFormat;
32
- private static colorChannels;
33
- getChannels(): [ColorChannel, ColorChannel, ColorChannel];
34
- }
35
-
36
- export { RGBColor };
1
+ import { Color } from "./color.mjs";
2
+ import { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from "./types.mjs";
3
+ export declare class RGBColor extends Color {
4
+ private red;
5
+ private green;
6
+ private blue;
7
+ private alpha;
8
+ constructor(red: number, green: number, blue: number, alpha: number);
9
+ static parse(value: string): RGBColor | undefined;
10
+ toString(format?: ColorStringFormat): string;
11
+ toFormat(format: ColorFormat): ColorType;
12
+ toHexInt(): number;
13
+ /**
14
+ * Converts an RGB color value to HSB.
15
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
16
+ * @returns An HSBColor object.
17
+ */
18
+ private toHSB;
19
+ /**
20
+ * Converts an RGB color value to HSL.
21
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
22
+ * @returns An HSLColor object.
23
+ */
24
+ private toHSL;
25
+ clone(): ColorType;
26
+ getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions;
27
+ formatChannelValue(channel: ColorChannel, locale: string): string;
28
+ getChannelRange(channel: ColorChannel): ColorChannelRange;
29
+ toJSON(): Record<"r" | "g" | "b" | "a", number>;
30
+ getFormat(): ColorFormat;
31
+ private static colorChannels;
32
+ getChannels(): [ColorChannel, ColorChannel, ColorChannel];
33
+ }
@@ -1,36 +1,33 @@
1
- import { Color } from './color.js';
2
- import { ColorStringFormat, ColorFormat, ColorType, ColorChannel, ColorChannelRange } from './types.js';
3
-
4
- declare class RGBColor extends Color {
5
- private red;
6
- private green;
7
- private blue;
8
- private alpha;
9
- constructor(red: number, green: number, blue: number, alpha: number);
10
- static parse(value: string): RGBColor | undefined;
11
- toString(format?: ColorStringFormat): string;
12
- toFormat(format: ColorFormat): ColorType;
13
- toHexInt(): number;
14
- /**
15
- * Converts an RGB color value to HSB.
16
- * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
17
- * @returns An HSBColor object.
18
- */
19
- private toHSB;
20
- /**
21
- * Converts an RGB color value to HSL.
22
- * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
23
- * @returns An HSLColor object.
24
- */
25
- private toHSL;
26
- clone(): ColorType;
27
- getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions;
28
- formatChannelValue(channel: ColorChannel, locale: string): string;
29
- getChannelRange(channel: ColorChannel): ColorChannelRange;
30
- toJSON(): Record<"r" | "g" | "b" | "a", number>;
31
- getFormat(): ColorFormat;
32
- private static colorChannels;
33
- getChannels(): [ColorChannel, ColorChannel, ColorChannel];
34
- }
35
-
36
- export { RGBColor };
1
+ import { Color } from "./color.js";
2
+ import { ColorChannel, ColorChannelRange, ColorFormat, ColorStringFormat, ColorType } from "./types.js";
3
+ export declare class RGBColor extends Color {
4
+ private red;
5
+ private green;
6
+ private blue;
7
+ private alpha;
8
+ constructor(red: number, green: number, blue: number, alpha: number);
9
+ static parse(value: string): RGBColor | undefined;
10
+ toString(format?: ColorStringFormat): string;
11
+ toFormat(format: ColorFormat): ColorType;
12
+ toHexInt(): number;
13
+ /**
14
+ * Converts an RGB color value to HSB.
15
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
16
+ * @returns An HSBColor object.
17
+ */
18
+ private toHSB;
19
+ /**
20
+ * Converts an RGB color value to HSL.
21
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
22
+ * @returns An HSLColor object.
23
+ */
24
+ private toHSL;
25
+ clone(): ColorType;
26
+ getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions;
27
+ formatChannelValue(channel: ColorChannel, locale: string): string;
28
+ getChannelRange(channel: ColorChannel): ColorChannelRange;
29
+ toJSON(): Record<"r" | "g" | "b" | "a", number>;
30
+ getFormat(): ColorFormat;
31
+ private static colorChannels;
32
+ getChannels(): [ColorChannel, ColorChannel, ColorChannel];
33
+ }