@zag-js/color-utils 0.10.5 → 0.11.1
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/{types.d.ts → index.d.mts} +27 -5
- package/dist/index.d.ts +84 -3
- package/dist/index.js +456 -7
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +434 -2
- package/dist/index.mjs.map +1 -0
- package/package.json +2 -2
- package/src/hsb-color.ts +6 -1
- package/src/hsl-color.ts +6 -1
- package/src/rgb-color.ts +6 -1
- package/dist/color.d.ts +0 -17
- package/dist/color.js +0 -35
- package/dist/color.mjs +0 -31
- package/dist/hsb-color.d.ts +0 -29
- package/dist/hsb-color.js +0 -111
- package/dist/hsb-color.mjs +0 -107
- package/dist/hsl-color.d.ts +0 -30
- package/dist/hsl-color.js +0 -112
- package/dist/hsl-color.mjs +0 -107
- package/dist/parse-color.d.ts +0 -3
- package/dist/parse-color.js +0 -25
- package/dist/parse-color.mjs +0 -20
- package/dist/rgb-color.d.ts +0 -30
- package/dist/rgb-color.js +0 -166
- package/dist/rgb-color.mjs +0 -162
- package/dist/utils.d.ts +0 -3
- package/dist/utils.js +0 -17
- package/dist/utils.mjs +0 -11
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type ColorFormat = "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "hsb" | "hsba";
|
|
2
|
+
type ColorChannel = "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha";
|
|
3
|
+
type ColorAxes = {
|
|
4
4
|
xChannel: ColorChannel;
|
|
5
5
|
yChannel: ColorChannel;
|
|
6
6
|
zChannel: ColorChannel;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
interface ColorChannelRange {
|
|
9
9
|
/** The minimum value of the color channel. */
|
|
10
10
|
minValue: number;
|
|
11
11
|
/** The maximum value of the color channel. */
|
|
@@ -15,7 +15,7 @@ export interface ColorChannelRange {
|
|
|
15
15
|
/** The page step value of the color channel, used when incrementing and decrementing. */
|
|
16
16
|
pageSize: number;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
interface ColorType {
|
|
19
19
|
/** Converts the color to the given color format, and returns a new Color object. */
|
|
20
20
|
toFormat(format: ColorFormat): ColorType;
|
|
21
21
|
/** Converts the color to a string in the given format. */
|
|
@@ -60,3 +60,25 @@ export interface ColorType {
|
|
|
60
60
|
*/
|
|
61
61
|
isEqual(color: ColorType): boolean;
|
|
62
62
|
}
|
|
63
|
+
|
|
64
|
+
declare abstract class Color implements ColorType {
|
|
65
|
+
abstract toFormat(format: ColorFormat): ColorType;
|
|
66
|
+
abstract toString(format: ColorFormat | "css"): string;
|
|
67
|
+
abstract clone(): ColorType;
|
|
68
|
+
abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
69
|
+
abstract getColorSpace(): ColorFormat;
|
|
70
|
+
abstract getColorChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
71
|
+
toHexInt(): number;
|
|
72
|
+
getChannelValue(channel: ColorChannel): number;
|
|
73
|
+
withChannelValue(channel: ColorChannel, value: number): ColorType;
|
|
74
|
+
getColorSpaceAxes(xyChannels: {
|
|
75
|
+
xChannel?: ColorChannel;
|
|
76
|
+
yChannel?: ColorChannel;
|
|
77
|
+
}): ColorAxes;
|
|
78
|
+
isEqual(color: ColorType): boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare function parseColor(value: string): ColorType;
|
|
82
|
+
declare function normalizeColor(v: string | ColorType): ColorType;
|
|
83
|
+
|
|
84
|
+
export { Color, ColorAxes, ColorChannel, ColorFormat, normalizeColor, parseColor };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type ColorFormat = "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "hsb" | "hsba";
|
|
2
|
+
type ColorChannel = "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha";
|
|
3
|
+
type ColorAxes = {
|
|
4
|
+
xChannel: ColorChannel;
|
|
5
|
+
yChannel: ColorChannel;
|
|
6
|
+
zChannel: ColorChannel;
|
|
7
|
+
};
|
|
8
|
+
interface ColorChannelRange {
|
|
9
|
+
/** The minimum value of the color channel. */
|
|
10
|
+
minValue: number;
|
|
11
|
+
/** The maximum value of the color channel. */
|
|
12
|
+
maxValue: number;
|
|
13
|
+
/** The step value of the color channel, used when incrementing and decrementing. */
|
|
14
|
+
step: number;
|
|
15
|
+
/** The page step value of the color channel, used when incrementing and decrementing. */
|
|
16
|
+
pageSize: number;
|
|
17
|
+
}
|
|
18
|
+
interface ColorType {
|
|
19
|
+
/** Converts the color to the given color format, and returns a new Color object. */
|
|
20
|
+
toFormat(format: ColorFormat): ColorType;
|
|
21
|
+
/** Converts the color to a string in the given format. */
|
|
22
|
+
toString(format: ColorFormat | "css"): string;
|
|
23
|
+
/** Converts the color to hex, and returns an integer representation. */
|
|
24
|
+
toHexInt(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the numeric value for a given channel.
|
|
27
|
+
* Throws an error if the channel is unsupported in the current color format.
|
|
28
|
+
*/
|
|
29
|
+
getChannelValue(channel: ColorChannel): number;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the numeric value for a given channel, and returns a new Color object.
|
|
32
|
+
* Throws an error if the channel is unsupported in the current color format.
|
|
33
|
+
*/
|
|
34
|
+
withChannelValue(channel: ColorChannel, value: number): ColorType;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the minimum, maximum, and step values for a given channel.
|
|
37
|
+
*/
|
|
38
|
+
getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the color space, 'rgb', 'hsb' or 'hsl', for the current color.
|
|
41
|
+
*/
|
|
42
|
+
getColorSpace(): ColorFormat;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the color space axes, xChannel, yChannel, zChannel.
|
|
45
|
+
*/
|
|
46
|
+
getColorSpaceAxes(xyChannels: {
|
|
47
|
+
xChannel?: ColorChannel;
|
|
48
|
+
yChannel?: ColorChannel;
|
|
49
|
+
}): ColorAxes;
|
|
50
|
+
/**
|
|
51
|
+
* Returns an array of the color channels within the current color space space.
|
|
52
|
+
*/
|
|
53
|
+
getColorChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
54
|
+
/**
|
|
55
|
+
* Returns a new Color object with the same values as the current color.
|
|
56
|
+
*/
|
|
57
|
+
clone(): ColorType;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the color is equal to another color.
|
|
60
|
+
*/
|
|
61
|
+
isEqual(color: ColorType): boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare abstract class Color implements ColorType {
|
|
65
|
+
abstract toFormat(format: ColorFormat): ColorType;
|
|
66
|
+
abstract toString(format: ColorFormat | "css"): string;
|
|
67
|
+
abstract clone(): ColorType;
|
|
68
|
+
abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
69
|
+
abstract getColorSpace(): ColorFormat;
|
|
70
|
+
abstract getColorChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
71
|
+
toHexInt(): number;
|
|
72
|
+
getChannelValue(channel: ColorChannel): number;
|
|
73
|
+
withChannelValue(channel: ColorChannel, value: number): ColorType;
|
|
74
|
+
getColorSpaceAxes(xyChannels: {
|
|
75
|
+
xChannel?: ColorChannel;
|
|
76
|
+
yChannel?: ColorChannel;
|
|
77
|
+
}): ColorAxes;
|
|
78
|
+
isEqual(color: ColorType): boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare function parseColor(value: string): ColorType;
|
|
82
|
+
declare function normalizeColor(v: string | ColorType): ColorType;
|
|
83
|
+
|
|
84
|
+
export { Color, ColorAxes, ColorChannel, ColorFormat, normalizeColor, parseColor };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,461 @@
|
|
|
1
|
-
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
2
24
|
|
|
3
|
-
|
|
25
|
+
// src/index.ts
|
|
26
|
+
var src_exports = {};
|
|
27
|
+
__export(src_exports, {
|
|
28
|
+
Color: () => Color,
|
|
29
|
+
normalizeColor: () => normalizeColor,
|
|
30
|
+
parseColor: () => parseColor
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
4
33
|
|
|
5
|
-
|
|
6
|
-
|
|
34
|
+
// src/color.ts
|
|
35
|
+
var Color = class {
|
|
36
|
+
toHexInt() {
|
|
37
|
+
return this.toFormat("rgb").toHexInt();
|
|
38
|
+
}
|
|
39
|
+
getChannelValue(channel) {
|
|
40
|
+
if (channel in this) {
|
|
41
|
+
return this[channel];
|
|
42
|
+
}
|
|
43
|
+
throw new Error("Unsupported color channel: " + channel);
|
|
44
|
+
}
|
|
45
|
+
withChannelValue(channel, value) {
|
|
46
|
+
if (channel in this) {
|
|
47
|
+
let clone = this.clone();
|
|
48
|
+
clone[channel] = value;
|
|
49
|
+
return clone;
|
|
50
|
+
}
|
|
51
|
+
throw new Error("Unsupported color channel: " + channel);
|
|
52
|
+
}
|
|
53
|
+
getColorSpaceAxes(xyChannels) {
|
|
54
|
+
let { xChannel, yChannel } = xyChannels;
|
|
55
|
+
let xCh = xChannel || this.getColorChannels().find((c) => c !== yChannel);
|
|
56
|
+
let yCh = yChannel || this.getColorChannels().find((c) => c !== xCh);
|
|
57
|
+
let zCh = this.getColorChannels().find((c) => c !== xCh && c !== yCh);
|
|
58
|
+
return { xChannel: xCh, yChannel: yCh, zChannel: zCh };
|
|
59
|
+
}
|
|
60
|
+
isEqual(color) {
|
|
61
|
+
return this.toHexInt() === color.toHexInt();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
7
64
|
|
|
65
|
+
// src/utils.ts
|
|
66
|
+
function mod(n, m) {
|
|
67
|
+
return (n % m + m) % m;
|
|
68
|
+
}
|
|
69
|
+
function toFixedNumber(num, digits) {
|
|
70
|
+
return Math.round(Math.pow(10, digits) * num) / Math.pow(10, digits);
|
|
71
|
+
}
|
|
72
|
+
function clampValue(value, min, max) {
|
|
73
|
+
return Math.min(Math.max(value, min), max);
|
|
74
|
+
}
|
|
8
75
|
|
|
76
|
+
// src/rgb-color.ts
|
|
77
|
+
var _RGBColor = class _RGBColor extends Color {
|
|
78
|
+
constructor(red, green, blue, alpha) {
|
|
79
|
+
super();
|
|
80
|
+
this.red = red;
|
|
81
|
+
this.green = green;
|
|
82
|
+
this.blue = blue;
|
|
83
|
+
this.alpha = alpha;
|
|
84
|
+
}
|
|
85
|
+
static parse(value) {
|
|
86
|
+
let colors = [];
|
|
87
|
+
if (/^#[\da-f]+$/i.test(value) && [4, 5, 7, 9].includes(value.length)) {
|
|
88
|
+
const values = (value.length < 6 ? value.replace(/[^#]/gi, "$&$&") : value).slice(1).split("");
|
|
89
|
+
while (values.length > 0) {
|
|
90
|
+
colors.push(parseInt(values.splice(0, 2).join(""), 16));
|
|
91
|
+
}
|
|
92
|
+
colors[3] = colors[3] !== void 0 ? colors[3] / 255 : void 0;
|
|
93
|
+
}
|
|
94
|
+
const match = value.match(/^rgba?\((.*)\)$/);
|
|
95
|
+
if (match?.[1]) {
|
|
96
|
+
colors = match[1].split(",").map((value2) => Number(value2.trim())).map((num, i) => clampValue(num, 0, i < 3 ? 255 : 1));
|
|
97
|
+
}
|
|
98
|
+
return colors.length < 3 ? void 0 : new _RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1);
|
|
99
|
+
}
|
|
100
|
+
toString(format) {
|
|
101
|
+
switch (format) {
|
|
102
|
+
case "hex":
|
|
103
|
+
return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0")).toUpperCase();
|
|
104
|
+
case "hexa":
|
|
105
|
+
return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0") + Math.round(this.alpha * 255).toString(16).padStart(2, "0")).toUpperCase();
|
|
106
|
+
case "rgb":
|
|
107
|
+
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
108
|
+
case "css":
|
|
109
|
+
case "rgba":
|
|
110
|
+
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
|
|
111
|
+
default:
|
|
112
|
+
return this.toFormat(format).toString(format);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
toFormat(format) {
|
|
116
|
+
switch (format) {
|
|
117
|
+
case "hex":
|
|
118
|
+
case "hexa":
|
|
119
|
+
case "rgb":
|
|
120
|
+
case "rgba":
|
|
121
|
+
return this;
|
|
122
|
+
case "hsb":
|
|
123
|
+
case "hsba":
|
|
124
|
+
return this.toHSB();
|
|
125
|
+
case "hsl":
|
|
126
|
+
case "hsla":
|
|
127
|
+
return this.toHSL();
|
|
128
|
+
default:
|
|
129
|
+
throw new Error("Unsupported color conversion: rgb -> " + format);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
toHexInt() {
|
|
133
|
+
return this.red << 16 | this.green << 8 | this.blue;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Converts an RGB color value to HSB.
|
|
137
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
138
|
+
* @returns An HSBColor object.
|
|
139
|
+
*/
|
|
140
|
+
toHSB() {
|
|
141
|
+
const red = this.red / 255;
|
|
142
|
+
const green = this.green / 255;
|
|
143
|
+
const blue = this.blue / 255;
|
|
144
|
+
const min = Math.min(red, green, blue);
|
|
145
|
+
const brightness = Math.max(red, green, blue);
|
|
146
|
+
const chroma = brightness - min;
|
|
147
|
+
const saturation = brightness === 0 ? 0 : chroma / brightness;
|
|
148
|
+
let hue = 0;
|
|
149
|
+
if (chroma !== 0) {
|
|
150
|
+
switch (brightness) {
|
|
151
|
+
case red:
|
|
152
|
+
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
153
|
+
break;
|
|
154
|
+
case green:
|
|
155
|
+
hue = (blue - red) / chroma + 2;
|
|
156
|
+
break;
|
|
157
|
+
case blue:
|
|
158
|
+
hue = (red - green) / chroma + 4;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
hue /= 6;
|
|
162
|
+
}
|
|
163
|
+
return new HSBColor(
|
|
164
|
+
toFixedNumber(hue * 360, 2),
|
|
165
|
+
toFixedNumber(saturation * 100, 2),
|
|
166
|
+
toFixedNumber(brightness * 100, 2),
|
|
167
|
+
this.alpha
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Converts an RGB color value to HSL.
|
|
172
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
173
|
+
* @returns An HSLColor object.
|
|
174
|
+
*/
|
|
175
|
+
toHSL() {
|
|
176
|
+
const red = this.red / 255;
|
|
177
|
+
const green = this.green / 255;
|
|
178
|
+
const blue = this.blue / 255;
|
|
179
|
+
const min = Math.min(red, green, blue);
|
|
180
|
+
const max = Math.max(red, green, blue);
|
|
181
|
+
const lightness = (max + min) / 2;
|
|
182
|
+
const chroma = max - min;
|
|
183
|
+
let hue = -1;
|
|
184
|
+
let saturation = -1;
|
|
185
|
+
if (chroma === 0) {
|
|
186
|
+
hue = saturation = 0;
|
|
187
|
+
} else {
|
|
188
|
+
saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min);
|
|
189
|
+
switch (max) {
|
|
190
|
+
case red:
|
|
191
|
+
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
192
|
+
break;
|
|
193
|
+
case green:
|
|
194
|
+
hue = (blue - red) / chroma + 2;
|
|
195
|
+
break;
|
|
196
|
+
case blue:
|
|
197
|
+
hue = (red - green) / chroma + 4;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
hue /= 6;
|
|
201
|
+
}
|
|
202
|
+
return new HSLColor(
|
|
203
|
+
toFixedNumber(hue * 360, 2),
|
|
204
|
+
toFixedNumber(saturation * 100, 2),
|
|
205
|
+
toFixedNumber(lightness * 100, 2),
|
|
206
|
+
this.alpha
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
clone() {
|
|
210
|
+
return new _RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
211
|
+
}
|
|
212
|
+
getChannelRange(channel) {
|
|
213
|
+
switch (channel) {
|
|
214
|
+
case "red":
|
|
215
|
+
case "green":
|
|
216
|
+
case "blue":
|
|
217
|
+
return { minValue: 0, maxValue: 255, step: 1, pageSize: 17 };
|
|
218
|
+
case "alpha":
|
|
219
|
+
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
220
|
+
default:
|
|
221
|
+
throw new Error("Unknown color channel: " + channel);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
getColorSpace() {
|
|
225
|
+
return "rgb";
|
|
226
|
+
}
|
|
227
|
+
getColorChannels() {
|
|
228
|
+
return _RGBColor.colorChannels;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
__publicField(_RGBColor, "colorChannels", ["red", "green", "blue"]);
|
|
232
|
+
var RGBColor = _RGBColor;
|
|
9
233
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
234
|
+
// src/hsl-color.ts
|
|
235
|
+
var HSL_REGEX = /hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
236
|
+
var _HSLColor = class _HSLColor extends Color {
|
|
237
|
+
constructor(hue, saturation, lightness, alpha) {
|
|
238
|
+
super();
|
|
239
|
+
this.hue = hue;
|
|
240
|
+
this.saturation = saturation;
|
|
241
|
+
this.lightness = lightness;
|
|
242
|
+
this.alpha = alpha;
|
|
243
|
+
}
|
|
244
|
+
static parse(value) {
|
|
245
|
+
let m;
|
|
246
|
+
if (m = value.match(HSL_REGEX)) {
|
|
247
|
+
const [h, s, l, a] = (m[1] ?? m[2]).split(",").map((n) => Number(n.trim().replace("%", "")));
|
|
248
|
+
return new _HSLColor(mod(h, 360), clampValue(s, 0, 100), clampValue(l, 0, 100), clampValue(a ?? 1, 0, 1));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
toString(format) {
|
|
252
|
+
switch (format) {
|
|
253
|
+
case "hex":
|
|
254
|
+
return this.toRGB().toString("hex");
|
|
255
|
+
case "hexa":
|
|
256
|
+
return this.toRGB().toString("hexa");
|
|
257
|
+
case "hsl":
|
|
258
|
+
return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`;
|
|
259
|
+
case "css":
|
|
260
|
+
case "hsla":
|
|
261
|
+
return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;
|
|
262
|
+
default:
|
|
263
|
+
return this.toFormat(format).toString(format);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
toFormat(format) {
|
|
267
|
+
switch (format) {
|
|
268
|
+
case "hsl":
|
|
269
|
+
case "hsla":
|
|
270
|
+
return this;
|
|
271
|
+
case "hsb":
|
|
272
|
+
case "hsba":
|
|
273
|
+
return this.toHSB();
|
|
274
|
+
case "rgb":
|
|
275
|
+
case "rgba":
|
|
276
|
+
return this.toRGB();
|
|
277
|
+
default:
|
|
278
|
+
throw new Error("Unsupported color conversion: hsl -> " + format);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Converts a HSL color to HSB.
|
|
283
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.
|
|
284
|
+
* @returns An HSBColor object.
|
|
285
|
+
*/
|
|
286
|
+
toHSB() {
|
|
287
|
+
let saturation = this.saturation / 100;
|
|
288
|
+
let lightness = this.lightness / 100;
|
|
289
|
+
let brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
290
|
+
saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
291
|
+
return new HSBColor(
|
|
292
|
+
toFixedNumber(this.hue, 2),
|
|
293
|
+
toFixedNumber(saturation * 100, 2),
|
|
294
|
+
toFixedNumber(brightness * 100, 2),
|
|
295
|
+
this.alpha
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Converts a HSL color to RGB.
|
|
300
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
|
|
301
|
+
* @returns An RGBColor object.
|
|
302
|
+
*/
|
|
303
|
+
toRGB() {
|
|
304
|
+
let hue = this.hue;
|
|
305
|
+
let saturation = this.saturation / 100;
|
|
306
|
+
let lightness = this.lightness / 100;
|
|
307
|
+
let a = saturation * Math.min(lightness, 1 - lightness);
|
|
308
|
+
let fn = (n, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
309
|
+
return new RGBColor(Math.round(fn(0) * 255), Math.round(fn(8) * 255), Math.round(fn(4) * 255), this.alpha);
|
|
310
|
+
}
|
|
311
|
+
clone() {
|
|
312
|
+
return new _HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
313
|
+
}
|
|
314
|
+
getChannelRange(channel) {
|
|
315
|
+
switch (channel) {
|
|
316
|
+
case "hue":
|
|
317
|
+
return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 };
|
|
318
|
+
case "saturation":
|
|
319
|
+
case "lightness":
|
|
320
|
+
return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 };
|
|
321
|
+
case "alpha":
|
|
322
|
+
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
323
|
+
default:
|
|
324
|
+
throw new Error("Unknown color channel: " + channel);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
getColorSpace() {
|
|
328
|
+
return "hsl";
|
|
329
|
+
}
|
|
330
|
+
getColorChannels() {
|
|
331
|
+
return _HSLColor.colorChannels;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
__publicField(_HSLColor, "colorChannels", ["hue", "saturation", "lightness"]);
|
|
335
|
+
var HSLColor = _HSLColor;
|
|
336
|
+
|
|
337
|
+
// src/hsb-color.ts
|
|
338
|
+
var HSB_REGEX = /hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
339
|
+
var _HSBColor = class _HSBColor extends Color {
|
|
340
|
+
constructor(hue, saturation, brightness, alpha) {
|
|
341
|
+
super();
|
|
342
|
+
this.hue = hue;
|
|
343
|
+
this.saturation = saturation;
|
|
344
|
+
this.brightness = brightness;
|
|
345
|
+
this.alpha = alpha;
|
|
346
|
+
}
|
|
347
|
+
static parse(value) {
|
|
348
|
+
let m;
|
|
349
|
+
if (m = value.match(HSB_REGEX)) {
|
|
350
|
+
const [h, s, b, a] = (m[1] ?? m[2]).split(",").map((n) => Number(n.trim().replace("%", "")));
|
|
351
|
+
return new _HSBColor(mod(h, 360), clampValue(s, 0, 100), clampValue(b, 0, 100), clampValue(a ?? 1, 0, 1));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
toString(format) {
|
|
355
|
+
switch (format) {
|
|
356
|
+
case "css":
|
|
357
|
+
return this.toHSL().toString("css");
|
|
358
|
+
case "hex":
|
|
359
|
+
return this.toRGB().toString("hex");
|
|
360
|
+
case "hexa":
|
|
361
|
+
return this.toRGB().toString("hexa");
|
|
362
|
+
case "hsb":
|
|
363
|
+
return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`;
|
|
364
|
+
case "hsba":
|
|
365
|
+
return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${this.alpha})`;
|
|
366
|
+
default:
|
|
367
|
+
return this.toFormat(format).toString(format);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
toFormat(format) {
|
|
371
|
+
switch (format) {
|
|
372
|
+
case "hsb":
|
|
373
|
+
case "hsba":
|
|
374
|
+
return this;
|
|
375
|
+
case "hsl":
|
|
376
|
+
case "hsla":
|
|
377
|
+
return this.toHSL();
|
|
378
|
+
case "rgb":
|
|
379
|
+
case "rgba":
|
|
380
|
+
return this.toRGB();
|
|
381
|
+
default:
|
|
382
|
+
throw new Error("Unsupported color conversion: hsb -> " + format);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Converts a HSB color to HSL.
|
|
387
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.
|
|
388
|
+
* @returns An HSLColor object.
|
|
389
|
+
*/
|
|
390
|
+
toHSL() {
|
|
391
|
+
let saturation = this.saturation / 100;
|
|
392
|
+
let brightness = this.brightness / 100;
|
|
393
|
+
let lightness = brightness * (1 - saturation / 2);
|
|
394
|
+
saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness);
|
|
395
|
+
return new HSLColor(
|
|
396
|
+
toFixedNumber(this.hue, 2),
|
|
397
|
+
toFixedNumber(saturation * 100, 2),
|
|
398
|
+
toFixedNumber(lightness * 100, 2),
|
|
399
|
+
this.alpha
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Converts a HSV color value to RGB.
|
|
404
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.
|
|
405
|
+
* @returns An RGBColor object.
|
|
406
|
+
*/
|
|
407
|
+
toRGB() {
|
|
408
|
+
let hue = this.hue;
|
|
409
|
+
let saturation = this.saturation / 100;
|
|
410
|
+
let brightness = this.brightness / 100;
|
|
411
|
+
let fn = (n, k = (n + hue / 60) % 6) => brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0);
|
|
412
|
+
return new RGBColor(Math.round(fn(5) * 255), Math.round(fn(3) * 255), Math.round(fn(1) * 255), this.alpha);
|
|
413
|
+
}
|
|
414
|
+
clone() {
|
|
415
|
+
return new _HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
|
|
416
|
+
}
|
|
417
|
+
getChannelRange(channel) {
|
|
418
|
+
switch (channel) {
|
|
419
|
+
case "hue":
|
|
420
|
+
return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 };
|
|
421
|
+
case "saturation":
|
|
422
|
+
case "brightness":
|
|
423
|
+
return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 };
|
|
424
|
+
case "alpha":
|
|
425
|
+
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
426
|
+
default:
|
|
427
|
+
throw new Error("Unknown color channel: " + channel);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
getColorSpace() {
|
|
431
|
+
return "hsb";
|
|
432
|
+
}
|
|
433
|
+
getColorChannels() {
|
|
434
|
+
return _HSBColor.colorChannels;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
__publicField(_HSBColor, "colorChannels", ["hue", "saturation", "brightness"]);
|
|
438
|
+
var HSBColor = _HSBColor;
|
|
439
|
+
|
|
440
|
+
// src/parse-color.ts
|
|
441
|
+
function parseColor(value) {
|
|
442
|
+
let result = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value);
|
|
443
|
+
if (!result) {
|
|
444
|
+
throw new Error("Invalid color value: " + value);
|
|
445
|
+
}
|
|
446
|
+
return result;
|
|
447
|
+
}
|
|
448
|
+
function normalizeColor(v) {
|
|
449
|
+
if (typeof v === "string") {
|
|
450
|
+
return parseColor(v);
|
|
451
|
+
} else {
|
|
452
|
+
return v;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
456
|
+
0 && (module.exports = {
|
|
457
|
+
Color,
|
|
458
|
+
normalizeColor,
|
|
459
|
+
parseColor
|
|
460
|
+
});
|
|
461
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/color.ts","../src/utils.ts","../src/rgb-color.ts","../src/hsl-color.ts","../src/hsb-color.ts","../src/parse-color.ts"],"sourcesContent":["export { Color } from \"./color\"\nexport { parseColor, normalizeColor } from \"./parse-color\"\nexport type { ColorChannel, ColorFormat, ColorAxes } from \"./types\"\n","import type { ColorType, ColorFormat, ColorChannel, ColorChannelRange, ColorAxes } from \"./types\"\n\nexport abstract class Color implements ColorType {\n abstract toFormat(format: ColorFormat): ColorType\n abstract toString(format: ColorFormat | \"css\"): string\n abstract clone(): ColorType\n abstract getChannelRange(channel: ColorChannel): ColorChannelRange\n abstract getColorSpace(): ColorFormat\n abstract getColorChannels(): [ColorChannel, ColorChannel, ColorChannel]\n\n toHexInt(): number {\n return this.toFormat(\"rgb\").toHexInt()\n }\n\n getChannelValue(channel: ColorChannel): number {\n if (channel in this) {\n return this[channel]\n }\n\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n withChannelValue(channel: ColorChannel, value: number): ColorType {\n if (channel in this) {\n let clone = this.clone()\n clone[channel] = value\n return clone\n }\n\n throw new Error(\"Unsupported color channel: \" + channel)\n }\n\n getColorSpaceAxes(xyChannels: { xChannel?: ColorChannel; yChannel?: ColorChannel }): ColorAxes {\n let { xChannel, yChannel } = xyChannels\n let xCh = xChannel || this.getColorChannels().find((c) => c !== yChannel)\n let yCh = yChannel || this.getColorChannels().find((c) => c !== xCh)\n let zCh = this.getColorChannels().find((c) => c !== xCh && c !== yCh)\n return { xChannel: xCh!, yChannel: yCh!, zChannel: zCh! }\n }\n\n isEqual(color: ColorType): boolean {\n return this.toHexInt() === color.toHexInt()\n }\n}\n","export function mod(n: number, m: number) {\n return ((n % m) + m) % m\n}\n\nexport function toFixedNumber(num: number, digits: number) {\n return Math.round(Math.pow(10, digits) * num) / Math.pow(10, digits)\n}\n\nexport function clampValue(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max)\n}\n","import { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { ColorChannel, ColorChannelRange, ColorFormat, ColorType } from \"./types\"\nimport { clampValue, toFixedNumber } from \"./utils\"\n\nexport class RGBColor extends Color {\n constructor(\n private red: number,\n private green: number,\n private blue: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string) {\n let colors: (number | undefined)[] = []\n\n // matching #rgb, #rgba, #rrggbb, #rrggbbaa\n if (/^#[\\da-f]+$/i.test(value) && [4, 5, 7, 9].includes(value.length)) {\n const values = (value.length < 6 ? value.replace(/[^#]/gi, \"$&$&\") : value).slice(1).split(\"\")\n while (values.length > 0) {\n colors.push(parseInt(values.splice(0, 2).join(\"\"), 16))\n }\n colors[3] = colors[3] !== undefined ? colors[3] / 255 : undefined\n }\n\n // matching rgb(rrr, ggg, bbb), rgba(rrr, ggg, bbb, 0.a)\n const match = value.match(/^rgba?\\((.*)\\)$/)\n\n if (match?.[1]) {\n colors = match[1]\n .split(\",\")\n .map((value) => Number(value.trim()))\n .map((num, i) => clampValue(num, 0, i < 3 ? 255 : 1))\n }\n\n //@ts-expect-error\n return colors.length < 3 ? undefined : new RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1)\n }\n\n toString(format: ColorFormat | \"css\") {\n switch (format) {\n case \"hex\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"hexa\":\n return (\n \"#\" +\n (\n this.red.toString(16).padStart(2, \"0\") +\n this.green.toString(16).padStart(2, \"0\") +\n this.blue.toString(16).padStart(2, \"0\") +\n Math.round(this.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n ).toUpperCase()\n )\n case \"rgb\":\n return `rgb(${this.red}, ${this.green}, ${this.blue})`\n case \"css\":\n case \"rgba\":\n return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hex\":\n case \"hexa\":\n case \"rgb\":\n case \"rgba\":\n return this\n case \"hsb\":\n case \"hsba\":\n return this.toHSB()\n case \"hsl\":\n case \"hsla\":\n return this.toHSL()\n default:\n throw new Error(\"Unsupported color conversion: rgb -> \" + format)\n }\n }\n\n toHexInt(): number {\n return (this.red << 16) | (this.green << 8) | this.blue\n }\n\n /**\n * Converts an RGB color value to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const brightness = Math.max(red, green, blue)\n const chroma = brightness - min\n const saturation = brightness === 0 ? 0 : chroma / brightness\n let hue = 0 // achromatic\n\n if (chroma !== 0) {\n switch (brightness) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSBColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n this.alpha,\n )\n }\n\n /**\n * Converts an RGB color value to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n const red = this.red / 255\n const green = this.green / 255\n const blue = this.blue / 255\n const min = Math.min(red, green, blue)\n const max = Math.max(red, green, blue)\n const lightness = (max + min) / 2\n const chroma = max - min\n\n let hue = -1\n let saturation = -1\n\n if (chroma === 0) {\n hue = saturation = 0 // achromatic\n } else {\n saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min)\n\n switch (max) {\n case red:\n hue = (green - blue) / chroma + (green < blue ? 6 : 0)\n break\n case green:\n hue = (blue - red) / chroma + 2\n break\n case blue:\n hue = (red - green) / chroma + 4\n break\n }\n\n hue /= 6\n }\n\n return new HSLColor(\n toFixedNumber(hue * 360, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n this.alpha,\n )\n }\n\n clone(): ColorType {\n return new RGBColor(this.red, this.green, this.blue, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return { minValue: 0x0, maxValue: 0xff, step: 0x1, pageSize: 0x11 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n getColorSpace(): ColorFormat {\n return \"rgb\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"red\", \"green\", \"blue\"]\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return RGBColor.colorChannels\n }\n}\n","import { Color } from \"./color\"\nimport { HSBColor } from \"./hsb-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport { ColorChannel, ColorChannelRange, ColorFormat, ColorType } from \"./types\"\nimport { clampValue, mod, toFixedNumber } from \"./utils\"\n\nexport const HSL_REGEX =\n /hsl\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%)\\)|hsla\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d(.\\d+)?)\\)/\n\nexport class HSLColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private lightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSLColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSL_REGEX))) {\n const [h, s, l, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSLColor(mod(h, 360), clampValue(s, 0, 100), clampValue(l, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorFormat | \"css\") {\n switch (format) {\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsl\":\n return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`\n case \"css\":\n case \"hsla\":\n return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${\n this.alpha\n })`\n default:\n return this.toFormat(format).toString(format)\n }\n }\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsl\":\n case \"hsla\":\n return this\n case \"hsb\":\n case \"hsba\":\n return this.toHSB()\n case \"rgb\":\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsl -> \" + format)\n }\n }\n\n /**\n * Converts a HSL color to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.\n * @returns An HSBColor object.\n */\n private toHSB(): ColorType {\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let brightness = lightness + saturation * Math.min(lightness, 1 - lightness)\n saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness)\n return new HSBColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n this.alpha,\n )\n }\n\n /**\n * Converts a HSL color to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let lightness = this.lightness / 100\n let a = saturation * Math.min(lightness, 1 - lightness)\n let fn = (n: number, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)\n return new RGBColor(Math.round(fn(0) * 255), Math.round(fn(8) * 255), Math.round(fn(4) * 255), this.alpha)\n }\n\n clone(): ColorType {\n return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"lightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n getColorSpace(): ColorFormat {\n return \"hsl\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"lightness\"]\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSLColor.colorChannels\n }\n}\n","import { Color } from \"./color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport { ColorChannel, ColorChannelRange, ColorFormat, ColorType } from \"./types\"\nimport { clampValue, mod, toFixedNumber } from \"./utils\"\n\nconst HSB_REGEX =\n /hsb\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%)\\)|hsba\\(([-+]?\\d+(?:.\\d+)?\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d+(?:.\\d+)?%\\s*,\\s*[-+]?\\d(.\\d+)?)\\)/\n\nexport class HSBColor extends Color {\n constructor(\n private hue: number,\n private saturation: number,\n private brightness: number,\n private alpha: number,\n ) {\n super()\n }\n\n static parse(value: string): HSBColor | void {\n let m: RegExpMatchArray | null\n if ((m = value.match(HSB_REGEX))) {\n const [h, s, b, a] = (m[1] ?? m[2]).split(\",\").map((n) => Number(n.trim().replace(\"%\", \"\")))\n return new HSBColor(mod(h, 360), clampValue(s, 0, 100), clampValue(b, 0, 100), clampValue(a ?? 1, 0, 1))\n }\n }\n\n toString(format: ColorFormat | \"css\") {\n switch (format) {\n case \"css\":\n return this.toHSL().toString(\"css\")\n case \"hex\":\n return this.toRGB().toString(\"hex\")\n case \"hexa\":\n return this.toRGB().toString(\"hexa\")\n case \"hsb\":\n return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`\n case \"hsba\":\n return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${\n this.alpha\n })`\n default:\n return this.toFormat(format).toString(format)\n }\n }\n\n toFormat(format: ColorFormat): ColorType {\n switch (format) {\n case \"hsb\":\n case \"hsba\":\n return this\n case \"hsl\":\n case \"hsla\":\n return this.toHSL()\n case \"rgb\":\n case \"rgba\":\n return this.toRGB()\n default:\n throw new Error(\"Unsupported color conversion: hsb -> \" + format)\n }\n }\n\n /**\n * Converts a HSB color to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.\n * @returns An HSLColor object.\n */\n private toHSL(): ColorType {\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n let lightness = brightness * (1 - saturation / 2)\n saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness)\n\n return new HSLColor(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n this.alpha,\n )\n }\n\n /**\n * Converts a HSV color value to RGB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.\n * @returns An RGBColor object.\n */\n private toRGB(): ColorType {\n let hue = this.hue\n let saturation = this.saturation / 100\n let brightness = this.brightness / 100\n\n let fn = (n: number, k = (n + hue / 60) % 6) =>\n brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0)\n\n return new RGBColor(Math.round(fn(5) * 255), Math.round(fn(3) * 255), Math.round(fn(1) * 255), this.alpha)\n }\n\n clone(): ColorType {\n return new HSBColor(this.hue, this.saturation, this.brightness, this.alpha)\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }\n case \"saturation\":\n case \"brightness\":\n return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }\n case \"alpha\":\n return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n }\n\n getColorSpace(): ColorFormat {\n return \"hsb\"\n }\n\n private static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\"hue\", \"saturation\", \"brightness\"]\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return HSBColor.colorChannels\n }\n}\n","import { HSBColor } from \"./hsb-color\"\nimport { HSLColor } from \"./hsl-color\"\nimport { RGBColor } from \"./rgb-color\"\nimport { ColorType } from \"./types\"\n\nexport function parseColor(value: string): ColorType {\n let result = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value)\n if (!result) {\n throw new Error(\"Invalid color value: \" + value)\n }\n return result\n}\n\nexport function normalizeColor(v: string | ColorType) {\n if (typeof v === \"string\") {\n return parseColor(v)\n } else {\n return v\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAe,QAAf,MAA0C;AAAA,EAQ/C,WAAmB;AACjB,WAAO,KAAK,SAAS,KAAK,EAAE,SAAS;AAAA,EACvC;AAAA,EAEA,gBAAgB,SAA+B;AAC7C,QAAI,WAAW,MAAM;AACnB,aAAO,KAAK,OAAO;AAAA,IACrB;AAEA,UAAM,IAAI,MAAM,gCAAgC,OAAO;AAAA,EACzD;AAAA,EAEA,iBAAiB,SAAuB,OAA0B;AAChE,QAAI,WAAW,MAAM;AACnB,UAAI,QAAQ,KAAK,MAAM;AACvB,YAAM,OAAO,IAAI;AACjB,aAAO;AAAA,IACT;AAEA,UAAM,IAAI,MAAM,gCAAgC,OAAO;AAAA,EACzD;AAAA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