@zag-js/color-utils 2.0.0-next.2 → 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.
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
- package/dist/area-gradient.d.mts +9 -11
- package/dist/area-gradient.d.ts +9 -11
- package/dist/area-gradient.js +58 -89
- package/dist/area-gradient.mjs +54 -77
- package/dist/color-format-gradient.d.mts +76 -78
- package/dist/color-format-gradient.d.ts +76 -78
- package/dist/color-format-gradient.js +118 -185
- package/dist/color-format-gradient.mjs +104 -152
- package/dist/color.d.mts +20 -23
- package/dist/color.d.ts +20 -23
- package/dist/color.js +57 -83
- package/dist/color.mjs +53 -60
- package/dist/gamut.d.mts +2 -5
- package/dist/gamut.d.ts +2 -5
- package/dist/gamut.js +12 -34
- package/dist/gamut.mjs +8 -11
- package/dist/hsb-color.d.mts +37 -40
- package/dist/hsb-color.d.ts +37 -40
- package/dist/hsb-color.js +164 -200
- package/dist/hsb-color.mjs +158 -175
- package/dist/hsl-color.d.mts +33 -36
- package/dist/hsl-color.d.ts +33 -36
- package/dist/hsl-color.js +139 -168
- package/dist/hsl-color.mjs +132 -142
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +23 -60
- package/dist/index.mjs +2 -28
- package/dist/native-color.d.mts +1 -3
- package/dist/native-color.d.ts +1 -3
- package/dist/native-color.js +16 -39
- package/dist/native-color.mjs +12 -16
- package/dist/oklab-color.d.mts +57 -60
- package/dist/oklab-color.d.ts +57 -60
- package/dist/oklab-color.js +363 -379
- package/dist/oklab-color.mjs +353 -350
- package/dist/oklab-math.d.mts +26 -28
- package/dist/oklab-math.d.ts +26 -28
- package/dist/oklab-math.js +123 -142
- package/dist/oklab-math.mjs +108 -108
- package/dist/parse-color.d.mts +3 -6
- package/dist/parse-color.d.ts +3 -6
- package/dist/parse-color.js +22 -48
- package/dist/parse-color.mjs +13 -20
- package/dist/rgb-color.d.mts +33 -36
- package/dist/rgb-color.d.ts +33 -36
- package/dist/rgb-color.js +182 -220
- package/dist/rgb-color.mjs +174 -193
- package/dist/types.d.mts +82 -84
- package/dist/types.d.ts +82 -84
- package/dist/types.js +4 -18
- package/dist/types.mjs +1 -0
- package/package.json +3 -3
- package/dist/chunk-QZ7TP4HQ.mjs +0 -7
package/dist/oklab-math.mjs
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
-
|
|
3
1
|
// src/oklab-math.ts
|
|
4
2
|
function srgbChannelToLinear(c) {
|
|
5
|
-
|
|
3
|
+
return c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
|
|
6
4
|
}
|
|
7
5
|
function linearChannelToSrgb(c) {
|
|
8
|
-
|
|
6
|
+
return c <= .0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - .055;
|
|
9
7
|
}
|
|
10
8
|
function srgbToLinearRgb(r255, g255, b255) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
23
|
+
return x < 0 ? 0 : x > 1 ? 1 : x;
|
|
26
24
|
}
|
|
27
25
|
function linearRgbToOklab({ r, g, b }) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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 =
|
|
68
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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 };
|
package/dist/parse-color.d.mts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { ColorType } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
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;
|
package/dist/parse-color.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { ColorType } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
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;
|
package/dist/parse-color.js
CHANGED
|
@@ -1,51 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
45
|
-
|
|
21
|
+
const normalizeColor = (v) => {
|
|
22
|
+
return typeof v === "string" ? parseColor(v) : v;
|
|
46
23
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
normalizeColor,
|
|
50
|
-
parseColor
|
|
51
|
-
});
|
|
24
|
+
exports.normalizeColor = normalizeColor;
|
|
25
|
+
exports.parseColor = parseColor;
|
package/dist/parse-color.mjs
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
parseColor
|
|
17
|
+
const normalizeColor = (v) => {
|
|
18
|
+
return typeof v === "string" ? parseColor(v) : v;
|
|
27
19
|
};
|
|
20
|
+
export { normalizeColor, parseColor };
|
package/dist/rgb-color.d.mts
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
import { Color } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
package/dist/rgb-color.d.ts
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
import { Color } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|