@zag-js/color-utils 1.34.1 → 1.35.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/area-gradient.d.mts +15 -0
- package/dist/area-gradient.d.ts +15 -0
- package/dist/area-gradient.js +87 -0
- package/dist/area-gradient.mjs +74 -0
- package/dist/chunk-QZ7TP4HQ.mjs +7 -0
- package/dist/color-format-gradient.d.mts +68 -0
- package/dist/color-format-gradient.d.ts +68 -0
- package/dist/color-format-gradient.js +164 -0
- package/dist/color-format-gradient.mjs +133 -0
- package/dist/color.d.mts +23 -0
- package/dist/color.d.ts +23 -0
- package/dist/color.js +87 -0
- package/dist/color.mjs +64 -0
- package/dist/hsb-color.d.mts +35 -0
- package/dist/hsb-color.d.ts +35 -0
- package/dist/hsb-color.js +165 -0
- package/dist/hsb-color.mjs +142 -0
- package/dist/hsl-color.d.mts +36 -0
- package/dist/hsl-color.d.ts +36 -0
- package/dist/hsl-color.js +167 -0
- package/dist/hsl-color.mjs +143 -0
- package/dist/index.d.mts +4 -121
- package/dist/index.d.ts +4 -121
- package/dist/index.js +37 -721
- package/dist/index.mjs +11 -716
- package/dist/native-color.d.mts +3 -0
- package/dist/native-color.d.ts +3 -0
- package/dist/native-color.js +41 -0
- package/dist/native-color.mjs +18 -0
- package/dist/parse-color.d.mts +6 -0
- package/dist/parse-color.d.ts +6 -0
- package/dist/parse-color.js +50 -0
- package/dist/parse-color.mjs +26 -0
- package/dist/rgb-color.d.mts +36 -0
- package/dist/rgb-color.d.ts +36 -0
- package/dist/rgb-color.js +213 -0
- package/dist/rgb-color.mjs +190 -0
- package/dist/types.d.mts +87 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.js +18 -0
- package/dist/types.mjs +0 -0
- package/package.json +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Color } from './color.mjs';
|
|
2
|
+
import { ColorChannel } from './types.mjs';
|
|
3
|
+
|
|
4
|
+
interface GradientOptions {
|
|
5
|
+
xChannel: ColorChannel;
|
|
6
|
+
yChannel: ColorChannel;
|
|
7
|
+
dir?: "rtl" | "ltr" | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface GradientStyles {
|
|
10
|
+
areaStyles: Record<string, string>;
|
|
11
|
+
areaGradientStyles: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
declare function getColorAreaGradient(color: Color, options: GradientOptions): GradientStyles;
|
|
14
|
+
|
|
15
|
+
export { getColorAreaGradient };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Color } from './color.js';
|
|
2
|
+
import { ColorChannel } from './types.js';
|
|
3
|
+
|
|
4
|
+
interface GradientOptions {
|
|
5
|
+
xChannel: ColorChannel;
|
|
6
|
+
yChannel: ColorChannel;
|
|
7
|
+
dir?: "rtl" | "ltr" | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface GradientStyles {
|
|
10
|
+
areaStyles: Record<string, string>;
|
|
11
|
+
areaGradientStyles: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
declare function getColorAreaGradient(color: Color, options: GradientOptions): GradientStyles;
|
|
14
|
+
|
|
15
|
+
export { getColorAreaGradient };
|
|
@@ -0,0 +1,87 @@
|
|
|
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/area-gradient.ts
|
|
21
|
+
var area_gradient_exports = {};
|
|
22
|
+
__export(area_gradient_exports, {
|
|
23
|
+
getColorAreaGradient: () => getColorAreaGradient
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(area_gradient_exports);
|
|
26
|
+
var import_color_format_gradient = require("./color-format-gradient.cjs");
|
|
27
|
+
function getColorAreaGradient(color, options) {
|
|
28
|
+
const { xChannel, yChannel, dir: dirProp = "ltr" } = options;
|
|
29
|
+
const { zChannel } = color.getColorAxes({ xChannel, yChannel });
|
|
30
|
+
const zValue = color.getChannelValue(zChannel);
|
|
31
|
+
const { minValue: zMin, maxValue: zMax } = color.getChannelRange(zChannel);
|
|
32
|
+
const orientation = ["top", dirProp === "rtl" ? "left" : "right"];
|
|
33
|
+
let dir = false;
|
|
34
|
+
let background = { areaStyles: {}, areaGradientStyles: {} };
|
|
35
|
+
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
36
|
+
let isHSL = color.getFormat() === "hsla";
|
|
37
|
+
switch (zChannel) {
|
|
38
|
+
case "red": {
|
|
39
|
+
dir = xChannel === "green";
|
|
40
|
+
background = (0, import_color_format_gradient.generateRGB_R)(orientation, dir, zValue);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case "green": {
|
|
44
|
+
dir = xChannel === "red";
|
|
45
|
+
background = (0, import_color_format_gradient.generateRGB_G)(orientation, dir, zValue);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "blue": {
|
|
49
|
+
dir = xChannel === "red";
|
|
50
|
+
background = (0, import_color_format_gradient.generateRGB_B)(orientation, dir, zValue);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case "hue": {
|
|
54
|
+
dir = xChannel !== "saturation";
|
|
55
|
+
if (isHSL) {
|
|
56
|
+
background = (0, import_color_format_gradient.generateHSL_H)(orientation, dir, zValue);
|
|
57
|
+
} else {
|
|
58
|
+
background = (0, import_color_format_gradient.generateHSB_H)(orientation, dir, zValue);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case "saturation": {
|
|
63
|
+
dir = xChannel === "hue";
|
|
64
|
+
if (isHSL) {
|
|
65
|
+
background = (0, import_color_format_gradient.generateHSL_S)(orientation, dir, alphaValue);
|
|
66
|
+
} else {
|
|
67
|
+
background = (0, import_color_format_gradient.generateHSB_S)(orientation, dir, alphaValue);
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case "brightness": {
|
|
72
|
+
dir = xChannel === "hue";
|
|
73
|
+
background = (0, import_color_format_gradient.generateHSB_B)(orientation, dir, alphaValue);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "lightness": {
|
|
77
|
+
dir = xChannel === "hue";
|
|
78
|
+
background = (0, import_color_format_gradient.generateHSL_L)(orientation, dir, zValue);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return background;
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
getColorAreaGradient
|
|
87
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
+
|
|
3
|
+
// src/area-gradient.ts
|
|
4
|
+
import {
|
|
5
|
+
generateRGB_R,
|
|
6
|
+
generateRGB_G,
|
|
7
|
+
generateRGB_B,
|
|
8
|
+
generateHSL_H,
|
|
9
|
+
generateHSB_H,
|
|
10
|
+
generateHSL_S,
|
|
11
|
+
generateHSB_S,
|
|
12
|
+
generateHSB_B,
|
|
13
|
+
generateHSL_L
|
|
14
|
+
} from "./color-format-gradient.mjs";
|
|
15
|
+
function getColorAreaGradient(color, options) {
|
|
16
|
+
const { xChannel, yChannel, dir: dirProp = "ltr" } = options;
|
|
17
|
+
const { zChannel } = color.getColorAxes({ xChannel, yChannel });
|
|
18
|
+
const zValue = color.getChannelValue(zChannel);
|
|
19
|
+
const { minValue: zMin, maxValue: zMax } = color.getChannelRange(zChannel);
|
|
20
|
+
const orientation = ["top", dirProp === "rtl" ? "left" : "right"];
|
|
21
|
+
let dir = false;
|
|
22
|
+
let background = { areaStyles: {}, areaGradientStyles: {} };
|
|
23
|
+
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
24
|
+
let isHSL = color.getFormat() === "hsla";
|
|
25
|
+
switch (zChannel) {
|
|
26
|
+
case "red": {
|
|
27
|
+
dir = xChannel === "green";
|
|
28
|
+
background = generateRGB_R(orientation, dir, zValue);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case "green": {
|
|
32
|
+
dir = xChannel === "red";
|
|
33
|
+
background = generateRGB_G(orientation, dir, zValue);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case "blue": {
|
|
37
|
+
dir = xChannel === "red";
|
|
38
|
+
background = generateRGB_B(orientation, dir, zValue);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "hue": {
|
|
42
|
+
dir = xChannel !== "saturation";
|
|
43
|
+
if (isHSL) {
|
|
44
|
+
background = generateHSL_H(orientation, dir, zValue);
|
|
45
|
+
} else {
|
|
46
|
+
background = generateHSB_H(orientation, dir, zValue);
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case "saturation": {
|
|
51
|
+
dir = xChannel === "hue";
|
|
52
|
+
if (isHSL) {
|
|
53
|
+
background = generateHSL_S(orientation, dir, alphaValue);
|
|
54
|
+
} else {
|
|
55
|
+
background = generateHSB_S(orientation, dir, alphaValue);
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case "brightness": {
|
|
60
|
+
dir = xChannel === "hue";
|
|
61
|
+
background = generateHSB_B(orientation, dir, alphaValue);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "lightness": {
|
|
65
|
+
dir = xChannel === "hue";
|
|
66
|
+
background = generateHSL_L(orientation, dir, zValue);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return background;
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
getColorAreaGradient
|
|
74
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
__publicField
|
|
7
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
declare const generateRGB_R: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
2
|
+
areaStyles: {
|
|
3
|
+
backgroundImage: string;
|
|
4
|
+
};
|
|
5
|
+
areaGradientStyles: {
|
|
6
|
+
backgroundImage: string;
|
|
7
|
+
WebkitMaskImage: string;
|
|
8
|
+
maskImage: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
declare const generateRGB_G: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
12
|
+
areaStyles: {
|
|
13
|
+
backgroundImage: string;
|
|
14
|
+
};
|
|
15
|
+
areaGradientStyles: {
|
|
16
|
+
backgroundImage: string;
|
|
17
|
+
WebkitMaskImage: string;
|
|
18
|
+
maskImage: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
declare const generateRGB_B: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
22
|
+
areaStyles: {
|
|
23
|
+
backgroundImage: string;
|
|
24
|
+
};
|
|
25
|
+
areaGradientStyles: {
|
|
26
|
+
backgroundImage: string;
|
|
27
|
+
WebkitMaskImage: string;
|
|
28
|
+
maskImage: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
declare const generateHSL_H: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
32
|
+
areaStyles: {};
|
|
33
|
+
areaGradientStyles: {
|
|
34
|
+
background: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
declare const generateHSL_S: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
38
|
+
areaStyles: {};
|
|
39
|
+
areaGradientStyles: {
|
|
40
|
+
background: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
declare const generateHSL_L: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
44
|
+
areaStyles: {};
|
|
45
|
+
areaGradientStyles: {
|
|
46
|
+
backgroundImage: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
declare const generateHSB_H: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
50
|
+
areaStyles: {};
|
|
51
|
+
areaGradientStyles: {
|
|
52
|
+
background: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
declare const generateHSB_S: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
56
|
+
areaStyles: {};
|
|
57
|
+
areaGradientStyles: {
|
|
58
|
+
background: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
declare const generateHSB_B: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
62
|
+
areaStyles: {};
|
|
63
|
+
areaGradientStyles: {
|
|
64
|
+
background: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { generateHSB_B, generateHSB_H, generateHSB_S, generateHSL_H, generateHSL_L, generateHSL_S, generateRGB_B, generateRGB_G, generateRGB_R };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
declare const generateRGB_R: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
2
|
+
areaStyles: {
|
|
3
|
+
backgroundImage: string;
|
|
4
|
+
};
|
|
5
|
+
areaGradientStyles: {
|
|
6
|
+
backgroundImage: string;
|
|
7
|
+
WebkitMaskImage: string;
|
|
8
|
+
maskImage: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
declare const generateRGB_G: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
12
|
+
areaStyles: {
|
|
13
|
+
backgroundImage: string;
|
|
14
|
+
};
|
|
15
|
+
areaGradientStyles: {
|
|
16
|
+
backgroundImage: string;
|
|
17
|
+
WebkitMaskImage: string;
|
|
18
|
+
maskImage: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
declare const generateRGB_B: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
22
|
+
areaStyles: {
|
|
23
|
+
backgroundImage: string;
|
|
24
|
+
};
|
|
25
|
+
areaGradientStyles: {
|
|
26
|
+
backgroundImage: string;
|
|
27
|
+
WebkitMaskImage: string;
|
|
28
|
+
maskImage: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
declare const generateHSL_H: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
32
|
+
areaStyles: {};
|
|
33
|
+
areaGradientStyles: {
|
|
34
|
+
background: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
declare const generateHSL_S: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
38
|
+
areaStyles: {};
|
|
39
|
+
areaGradientStyles: {
|
|
40
|
+
background: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
declare const generateHSL_L: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
44
|
+
areaStyles: {};
|
|
45
|
+
areaGradientStyles: {
|
|
46
|
+
backgroundImage: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
declare const generateHSB_H: (orientation: [string, string], dir: boolean, zValue: number) => {
|
|
50
|
+
areaStyles: {};
|
|
51
|
+
areaGradientStyles: {
|
|
52
|
+
background: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
declare const generateHSB_S: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
56
|
+
areaStyles: {};
|
|
57
|
+
areaGradientStyles: {
|
|
58
|
+
background: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
declare const generateHSB_B: (orientation: [string, string], dir: boolean, alphaValue: number) => {
|
|
62
|
+
areaStyles: {};
|
|
63
|
+
areaGradientStyles: {
|
|
64
|
+
background: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { generateHSB_B, generateHSB_H, generateHSB_S, generateHSL_H, generateHSL_L, generateHSL_S, generateRGB_B, generateRGB_G, generateRGB_R };
|
|
@@ -0,0 +1,164 @@
|
|
|
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/color-format-gradient.ts
|
|
21
|
+
var color_format_gradient_exports = {};
|
|
22
|
+
__export(color_format_gradient_exports, {
|
|
23
|
+
generateHSB_B: () => generateHSB_B,
|
|
24
|
+
generateHSB_H: () => generateHSB_H,
|
|
25
|
+
generateHSB_S: () => generateHSB_S,
|
|
26
|
+
generateHSL_H: () => generateHSL_H,
|
|
27
|
+
generateHSL_L: () => generateHSL_L,
|
|
28
|
+
generateHSL_S: () => generateHSL_S,
|
|
29
|
+
generateRGB_B: () => generateRGB_B,
|
|
30
|
+
generateRGB_G: () => generateRGB_G,
|
|
31
|
+
generateRGB_R: () => generateRGB_R
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(color_format_gradient_exports);
|
|
34
|
+
var generateRGB_R = (orientation, dir, zValue) => {
|
|
35
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
36
|
+
const result = {
|
|
37
|
+
areaStyles: {
|
|
38
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
39
|
+
},
|
|
40
|
+
areaGradientStyles: {
|
|
41
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
42
|
+
WebkitMaskImage: maskImage,
|
|
43
|
+
maskImage
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
var generateRGB_G = (orientation, dir, zValue) => {
|
|
49
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
50
|
+
const result = {
|
|
51
|
+
areaStyles: {
|
|
52
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
53
|
+
},
|
|
54
|
+
areaGradientStyles: {
|
|
55
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
56
|
+
WebkitMaskImage: maskImage,
|
|
57
|
+
maskImage
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
var generateRGB_B = (orientation, dir, zValue) => {
|
|
63
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
64
|
+
const result = {
|
|
65
|
+
areaStyles: {
|
|
66
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
67
|
+
},
|
|
68
|
+
areaGradientStyles: {
|
|
69
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
70
|
+
WebkitMaskImage: maskImage,
|
|
71
|
+
maskImage
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
76
|
+
var generateHSL_H = (orientation, dir, zValue) => {
|
|
77
|
+
const result = {
|
|
78
|
+
areaStyles: {},
|
|
79
|
+
areaGradientStyles: {
|
|
80
|
+
background: [
|
|
81
|
+
`linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
|
|
82
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
83
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
84
|
+
].join(",")
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
var generateHSL_S = (orientation, dir, alphaValue) => {
|
|
90
|
+
const result = {
|
|
91
|
+
areaStyles: {},
|
|
92
|
+
areaGradientStyles: {
|
|
93
|
+
background: [
|
|
94
|
+
`linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
|
|
95
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
96
|
+
"hsl(0, 0%, 50%)"
|
|
97
|
+
].join(",")
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return result;
|
|
101
|
+
};
|
|
102
|
+
var generateHSL_L = (orientation, dir, zValue) => {
|
|
103
|
+
const result = {
|
|
104
|
+
areaStyles: {},
|
|
105
|
+
areaGradientStyles: {
|
|
106
|
+
backgroundImage: [
|
|
107
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
108
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
|
|
109
|
+
].join(",")
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return result;
|
|
113
|
+
};
|
|
114
|
+
var generateHSB_H = (orientation, dir, zValue) => {
|
|
115
|
+
const result = {
|
|
116
|
+
areaStyles: {},
|
|
117
|
+
areaGradientStyles: {
|
|
118
|
+
background: [
|
|
119
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
120
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
121
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
122
|
+
].join(",")
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return result;
|
|
126
|
+
};
|
|
127
|
+
var generateHSB_S = (orientation, dir, alphaValue) => {
|
|
128
|
+
const result = {
|
|
129
|
+
areaStyles: {},
|
|
130
|
+
areaGradientStyles: {
|
|
131
|
+
background: [
|
|
132
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
133
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
134
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
135
|
+
].join(",")
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return result;
|
|
139
|
+
};
|
|
140
|
+
var generateHSB_B = (orientation, dir, alphaValue) => {
|
|
141
|
+
const result = {
|
|
142
|
+
areaStyles: {},
|
|
143
|
+
areaGradientStyles: {
|
|
144
|
+
background: [
|
|
145
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
146
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
147
|
+
"#000"
|
|
148
|
+
].join(",")
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
return result;
|
|
152
|
+
};
|
|
153
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
+
0 && (module.exports = {
|
|
155
|
+
generateHSB_B,
|
|
156
|
+
generateHSB_H,
|
|
157
|
+
generateHSB_S,
|
|
158
|
+
generateHSL_H,
|
|
159
|
+
generateHSL_L,
|
|
160
|
+
generateHSL_S,
|
|
161
|
+
generateRGB_B,
|
|
162
|
+
generateRGB_G,
|
|
163
|
+
generateRGB_R
|
|
164
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import "./chunk-QZ7TP4HQ.mjs";
|
|
2
|
+
|
|
3
|
+
// src/color-format-gradient.ts
|
|
4
|
+
var generateRGB_R = (orientation, dir, zValue) => {
|
|
5
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
6
|
+
const result = {
|
|
7
|
+
areaStyles: {
|
|
8
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
9
|
+
},
|
|
10
|
+
areaGradientStyles: {
|
|
11
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
12
|
+
WebkitMaskImage: maskImage,
|
|
13
|
+
maskImage
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
var generateRGB_G = (orientation, dir, zValue) => {
|
|
19
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
20
|
+
const result = {
|
|
21
|
+
areaStyles: {
|
|
22
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
23
|
+
},
|
|
24
|
+
areaGradientStyles: {
|
|
25
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
26
|
+
WebkitMaskImage: maskImage,
|
|
27
|
+
maskImage
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var generateRGB_B = (orientation, dir, zValue) => {
|
|
33
|
+
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
34
|
+
const result = {
|
|
35
|
+
areaStyles: {
|
|
36
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
37
|
+
},
|
|
38
|
+
areaGradientStyles: {
|
|
39
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
40
|
+
WebkitMaskImage: maskImage,
|
|
41
|
+
maskImage
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
var generateHSL_H = (orientation, dir, zValue) => {
|
|
47
|
+
const result = {
|
|
48
|
+
areaStyles: {},
|
|
49
|
+
areaGradientStyles: {
|
|
50
|
+
background: [
|
|
51
|
+
`linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
|
|
52
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
53
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
54
|
+
].join(",")
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
var generateHSL_S = (orientation, dir, alphaValue) => {
|
|
60
|
+
const result = {
|
|
61
|
+
areaStyles: {},
|
|
62
|
+
areaGradientStyles: {
|
|
63
|
+
background: [
|
|
64
|
+
`linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
|
|
65
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
66
|
+
"hsl(0, 0%, 50%)"
|
|
67
|
+
].join(",")
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
var generateHSL_L = (orientation, dir, zValue) => {
|
|
73
|
+
const result = {
|
|
74
|
+
areaStyles: {},
|
|
75
|
+
areaGradientStyles: {
|
|
76
|
+
backgroundImage: [
|
|
77
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
78
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
|
|
79
|
+
].join(",")
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return result;
|
|
83
|
+
};
|
|
84
|
+
var generateHSB_H = (orientation, dir, zValue) => {
|
|
85
|
+
const result = {
|
|
86
|
+
areaStyles: {},
|
|
87
|
+
areaGradientStyles: {
|
|
88
|
+
background: [
|
|
89
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
90
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
91
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
92
|
+
].join(",")
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return result;
|
|
96
|
+
};
|
|
97
|
+
var generateHSB_S = (orientation, dir, alphaValue) => {
|
|
98
|
+
const result = {
|
|
99
|
+
areaStyles: {},
|
|
100
|
+
areaGradientStyles: {
|
|
101
|
+
background: [
|
|
102
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
103
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
104
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
105
|
+
].join(",")
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
var generateHSB_B = (orientation, dir, alphaValue) => {
|
|
111
|
+
const result = {
|
|
112
|
+
areaStyles: {},
|
|
113
|
+
areaGradientStyles: {
|
|
114
|
+
background: [
|
|
115
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
116
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
117
|
+
"#000"
|
|
118
|
+
].join(",")
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
return result;
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
generateHSB_B,
|
|
125
|
+
generateHSB_H,
|
|
126
|
+
generateHSB_S,
|
|
127
|
+
generateHSL_H,
|
|
128
|
+
generateHSL_L,
|
|
129
|
+
generateHSL_S,
|
|
130
|
+
generateRGB_B,
|
|
131
|
+
generateRGB_G,
|
|
132
|
+
generateRGB_R
|
|
133
|
+
};
|
package/dist/color.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ColorType, ColorFormat, ColorStringFormat, ColorChannel, ColorChannelRange, Color2DAxes, ColorAxes } from './types.mjs';
|
|
2
|
+
|
|
3
|
+
declare abstract class Color implements ColorType {
|
|
4
|
+
abstract toFormat(format: ColorFormat): ColorType;
|
|
5
|
+
abstract toJSON(): Record<string, number>;
|
|
6
|
+
abstract toString(format?: ColorStringFormat): string;
|
|
7
|
+
abstract clone(): ColorType;
|
|
8
|
+
abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
9
|
+
abstract getFormat(): ColorFormat;
|
|
10
|
+
abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
11
|
+
abstract formatChannelValue(channel: ColorChannel, locale: string): string;
|
|
12
|
+
toHexInt(): number;
|
|
13
|
+
getChannelValue(channel: ColorChannel): number;
|
|
14
|
+
getChannelValuePercent(channel: ColorChannel, valueToCheck?: number): number;
|
|
15
|
+
getChannelPercentValue(channel: ColorChannel, percentToCheck: number): number;
|
|
16
|
+
withChannelValue(channel: ColorChannel, value: number): ColorType;
|
|
17
|
+
getColorAxes(xyChannels: Color2DAxes): ColorAxes;
|
|
18
|
+
incrementChannel(channel: ColorChannel, stepSize: number): ColorType;
|
|
19
|
+
decrementChannel(channel: ColorChannel, stepSize: number): ColorType;
|
|
20
|
+
isEqual(color: ColorType): boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { Color };
|
package/dist/color.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ColorType, ColorFormat, ColorStringFormat, ColorChannel, ColorChannelRange, Color2DAxes, ColorAxes } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare abstract class Color implements ColorType {
|
|
4
|
+
abstract toFormat(format: ColorFormat): ColorType;
|
|
5
|
+
abstract toJSON(): Record<string, number>;
|
|
6
|
+
abstract toString(format?: ColorStringFormat): string;
|
|
7
|
+
abstract clone(): ColorType;
|
|
8
|
+
abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
9
|
+
abstract getFormat(): ColorFormat;
|
|
10
|
+
abstract getChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
11
|
+
abstract formatChannelValue(channel: ColorChannel, locale: string): string;
|
|
12
|
+
toHexInt(): number;
|
|
13
|
+
getChannelValue(channel: ColorChannel): number;
|
|
14
|
+
getChannelValuePercent(channel: ColorChannel, valueToCheck?: number): number;
|
|
15
|
+
getChannelPercentValue(channel: ColorChannel, percentToCheck: number): number;
|
|
16
|
+
withChannelValue(channel: ColorChannel, value: number): ColorType;
|
|
17
|
+
getColorAxes(xyChannels: Color2DAxes): ColorAxes;
|
|
18
|
+
incrementChannel(channel: ColorChannel, stepSize: number): ColorType;
|
|
19
|
+
decrementChannel(channel: ColorChannel, stepSize: number): ColorType;
|
|
20
|
+
isEqual(color: ColorType): boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { Color };
|