@zag-js/color-utils 1.47.0 → 1.48.0
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 +53 -84
- package/dist/area-gradient.mjs +49 -71
- package/dist/color-format-gradient.d.mts +58 -60
- package/dist/color-format-gradient.d.ts +58 -60
- package/dist/color-format-gradient.js +93 -154
- package/dist/color-format-gradient.mjs +81 -123
- 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/hsb-color.d.mts +32 -35
- package/dist/hsb-color.d.ts +32 -35
- package/dist/hsb-color.js +135 -163
- package/dist/hsb-color.mjs +129 -138
- package/dist/hsl-color.d.mts +33 -36
- package/dist/hsl-color.d.ts +33 -36
- package/dist/hsl-color.js +137 -165
- package/dist/hsl-color.mjs +130 -139
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +10 -37
- package/dist/index.mjs +1 -9
- 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/parse-color.d.mts +3 -6
- package/dist/parse-color.d.ts +3 -6
- package/dist/parse-color.js +21 -47
- 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 +174 -211
- package/dist/rgb-color.mjs +168 -186
- 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 +4 -4
- package/dist/chunk-QZ7TP4HQ.mjs +0 -7
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
|
+
}
|
package/dist/rgb-color.js
CHANGED
|
@@ -1,213 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
-
|
|
22
|
-
// src/rgb-color.ts
|
|
23
|
-
var rgb_color_exports = {};
|
|
24
|
-
__export(rgb_color_exports, {
|
|
25
|
-
RGBColor: () => RGBColor
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
26
4
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
case "alpha":
|
|
193
|
-
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
194
|
-
default:
|
|
195
|
-
throw new Error("Unknown color channel: " + channel);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
toJSON() {
|
|
199
|
-
return { r: this.red, g: this.green, b: this.blue, a: this.alpha };
|
|
200
|
-
}
|
|
201
|
-
getFormat() {
|
|
202
|
-
return "rgba";
|
|
203
|
-
}
|
|
204
|
-
getChannels() {
|
|
205
|
-
return _RGBColor.colorChannels;
|
|
206
|
-
}
|
|
5
|
+
const require_color = require("./color.js");
|
|
6
|
+
const require_hsb_color = require("./hsb-color.js");
|
|
7
|
+
const require_hsl_color = require("./hsl-color.js");
|
|
8
|
+
const require_defineProperty = require("./_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js");
|
|
9
|
+
let _zag_js_utils = require("@zag-js/utils");
|
|
10
|
+
// src/rgb-color.ts
|
|
11
|
+
const HEX_COLOR_REGEX = /^#[\da-f]+$/i;
|
|
12
|
+
const RGB_COLOR_REGEX = /^rgba?\((.*)\)$/;
|
|
13
|
+
const HEX_STARTING_REGEX = /[^#]/gi;
|
|
14
|
+
var RGBColor = class RGBColor extends require_color.Color {
|
|
15
|
+
constructor(red, green, blue, alpha) {
|
|
16
|
+
super();
|
|
17
|
+
this.red = red;
|
|
18
|
+
this.green = green;
|
|
19
|
+
this.blue = blue;
|
|
20
|
+
this.alpha = alpha;
|
|
21
|
+
}
|
|
22
|
+
static parse(value) {
|
|
23
|
+
let colors = [];
|
|
24
|
+
if (HEX_COLOR_REGEX.test(value) && [
|
|
25
|
+
4,
|
|
26
|
+
5,
|
|
27
|
+
7,
|
|
28
|
+
9
|
|
29
|
+
].includes(value.length)) {
|
|
30
|
+
const values = (value.length < 6 ? value.replace(HEX_STARTING_REGEX, "$&$&") : value).slice(1).split("");
|
|
31
|
+
while (values.length > 0) colors.push(parseInt(values.splice(0, 2).join(""), 16));
|
|
32
|
+
colors[3] = colors[3] !== void 0 ? colors[3] / 255 : void 0;
|
|
33
|
+
}
|
|
34
|
+
const match = value.match(RGB_COLOR_REGEX);
|
|
35
|
+
if (match?.[1]) colors = match[1].split(",").map((value) => Number(value.trim())).map((num, i) => (0, _zag_js_utils.clampValue)(num, 0, i < 3 ? 255 : 1));
|
|
36
|
+
return colors.length < 3 ? void 0 : new RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1);
|
|
37
|
+
}
|
|
38
|
+
toString(format = "css") {
|
|
39
|
+
switch (format) {
|
|
40
|
+
case "hex": return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0")).toUpperCase();
|
|
41
|
+
case "hexa": 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();
|
|
42
|
+
case "rgb": return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
43
|
+
case "css":
|
|
44
|
+
case "rgba": return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
|
|
45
|
+
case "hsl": return this.toHSL().toString("hsl");
|
|
46
|
+
case "hsb": return this.toHSB().toString("hsb");
|
|
47
|
+
default: return this.toFormat(format).toString(format);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
toFormat(format) {
|
|
51
|
+
switch (format) {
|
|
52
|
+
case "rgba": return this;
|
|
53
|
+
case "hsba": return this.toHSB();
|
|
54
|
+
case "hsla": return this.toHSL();
|
|
55
|
+
default: throw new Error("Unsupported color conversion: rgb -> " + format);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
toHexInt() {
|
|
59
|
+
return this.red << 16 | this.green << 8 | this.blue;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Converts an RGB color value to HSB.
|
|
63
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
64
|
+
* @returns An HSBColor object.
|
|
65
|
+
*/
|
|
66
|
+
toHSB() {
|
|
67
|
+
const red = this.red / 255;
|
|
68
|
+
const green = this.green / 255;
|
|
69
|
+
const blue = this.blue / 255;
|
|
70
|
+
const min = Math.min(red, green, blue);
|
|
71
|
+
const brightness = Math.max(red, green, blue);
|
|
72
|
+
const chroma = brightness - min;
|
|
73
|
+
const saturation = brightness === 0 ? 0 : chroma / brightness;
|
|
74
|
+
let hue = 0;
|
|
75
|
+
if (chroma !== 0) {
|
|
76
|
+
switch (brightness) {
|
|
77
|
+
case red:
|
|
78
|
+
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
79
|
+
break;
|
|
80
|
+
case green:
|
|
81
|
+
hue = (blue - red) / chroma + 2;
|
|
82
|
+
break;
|
|
83
|
+
case blue: hue = (red - green) / chroma + 4;
|
|
84
|
+
}
|
|
85
|
+
hue /= 6;
|
|
86
|
+
}
|
|
87
|
+
return new require_hsb_color.HSBColor((0, _zag_js_utils.toFixedNumber)(hue * 360, 2), (0, _zag_js_utils.toFixedNumber)(saturation * 100, 2), (0, _zag_js_utils.toFixedNumber)(brightness * 100, 2), (0, _zag_js_utils.toFixedNumber)(this.alpha, 2));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Converts an RGB color value to HSL.
|
|
91
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
92
|
+
* @returns An HSLColor object.
|
|
93
|
+
*/
|
|
94
|
+
toHSL() {
|
|
95
|
+
const red = this.red / 255;
|
|
96
|
+
const green = this.green / 255;
|
|
97
|
+
const blue = this.blue / 255;
|
|
98
|
+
const min = Math.min(red, green, blue);
|
|
99
|
+
const max = Math.max(red, green, blue);
|
|
100
|
+
const lightness = (max + min) / 2;
|
|
101
|
+
const chroma = max - min;
|
|
102
|
+
let hue = -1;
|
|
103
|
+
let saturation = -1;
|
|
104
|
+
if (chroma === 0) hue = saturation = 0;
|
|
105
|
+
else {
|
|
106
|
+
saturation = chroma / (lightness < .5 ? max + min : 2 - max - min);
|
|
107
|
+
switch (max) {
|
|
108
|
+
case red:
|
|
109
|
+
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
110
|
+
break;
|
|
111
|
+
case green:
|
|
112
|
+
hue = (blue - red) / chroma + 2;
|
|
113
|
+
break;
|
|
114
|
+
case blue: hue = (red - green) / chroma + 4;
|
|
115
|
+
}
|
|
116
|
+
hue /= 6;
|
|
117
|
+
}
|
|
118
|
+
return new require_hsl_color.HSLColor((0, _zag_js_utils.toFixedNumber)(hue * 360, 2), (0, _zag_js_utils.toFixedNumber)(saturation * 100, 2), (0, _zag_js_utils.toFixedNumber)(lightness * 100, 2), (0, _zag_js_utils.toFixedNumber)(this.alpha, 2));
|
|
119
|
+
}
|
|
120
|
+
clone() {
|
|
121
|
+
return new RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
122
|
+
}
|
|
123
|
+
getChannelFormatOptions(channel) {
|
|
124
|
+
switch (channel) {
|
|
125
|
+
case "red":
|
|
126
|
+
case "green":
|
|
127
|
+
case "blue": return { style: "decimal" };
|
|
128
|
+
case "alpha": return { style: "percent" };
|
|
129
|
+
default: throw new Error("Unknown color channel: " + channel);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
formatChannelValue(channel, locale) {
|
|
133
|
+
let options = this.getChannelFormatOptions(channel);
|
|
134
|
+
let value = this.getChannelValue(channel);
|
|
135
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
136
|
+
}
|
|
137
|
+
getChannelRange(channel) {
|
|
138
|
+
switch (channel) {
|
|
139
|
+
case "red":
|
|
140
|
+
case "green":
|
|
141
|
+
case "blue": return {
|
|
142
|
+
minValue: 0,
|
|
143
|
+
maxValue: 255,
|
|
144
|
+
step: 1,
|
|
145
|
+
pageSize: 17
|
|
146
|
+
};
|
|
147
|
+
case "alpha": return {
|
|
148
|
+
minValue: 0,
|
|
149
|
+
maxValue: 1,
|
|
150
|
+
step: .01,
|
|
151
|
+
pageSize: .1
|
|
152
|
+
};
|
|
153
|
+
default: throw new Error("Unknown color channel: " + channel);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
toJSON() {
|
|
157
|
+
return {
|
|
158
|
+
r: this.red,
|
|
159
|
+
g: this.green,
|
|
160
|
+
b: this.blue,
|
|
161
|
+
a: this.alpha
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
getFormat() {
|
|
165
|
+
return "rgba";
|
|
166
|
+
}
|
|
167
|
+
getChannels() {
|
|
168
|
+
return RGBColor.colorChannels;
|
|
169
|
+
}
|
|
207
170
|
};
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
171
|
+
require_defineProperty.default(RGBColor, "colorChannels", [
|
|
172
|
+
"red",
|
|
173
|
+
"green",
|
|
174
|
+
"blue"
|
|
175
|
+
]);
|
|
176
|
+
exports.RGBColor = RGBColor;
|