@seelen-ui/lib 2.2.6-next.20250601053421 → 2.2.6-next.20250601063856
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/esm/system_state/ui_colors.d.ts +3 -1
- package/esm/system_state/ui_colors.d.ts.map +1 -1
- package/esm/system_state/ui_colors.js +14 -3
- package/package.json +1 -1
- package/script/system_state/ui_colors.d.ts +3 -1
- package/script/system_state/ui_colors.d.ts.map +1 -1
- package/script/system_state/ui_colors.js +14 -3
|
@@ -11,7 +11,9 @@ export declare class UIColors {
|
|
|
11
11
|
export declare class Color {
|
|
12
12
|
inner: IColor;
|
|
13
13
|
constructor(inner: IColor);
|
|
14
|
-
|
|
14
|
+
/** generates a random solid color */
|
|
15
|
+
random(): Color;
|
|
16
|
+
private getRuntimeStyleSheet;
|
|
15
17
|
private insertIntoStyleSheet;
|
|
16
18
|
asHex(): string;
|
|
17
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui_colors.d.ts","sourceRoot":"","sources":["../../src/system_state/ui_colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9E,qBAAa,QAAQ;IACA,KAAK,EAAE,SAAS;gBAAhB,KAAK,EAAE,SAAS;IAEnC,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAIpE,MAAM,CAAC,OAAO,IAAI,QAAQ;IAe1B,iBAAiB,IAAI,IAAI;CAgB1B;AAED,qBAAa,KAAK;IACG,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;IAEhC,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,oBAAoB;IAkB5B,KAAK,IAAI,MAAM;IAUf;;;;;;;OAOG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAapC;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"ui_colors.d.ts","sourceRoot":"","sources":["../../src/system_state/ui_colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9E,qBAAa,QAAQ;IACA,KAAK,EAAE,SAAS;gBAAhB,KAAK,EAAE,SAAS;IAEnC,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAIpE,MAAM,CAAC,OAAO,IAAI,QAAQ;IAe1B,iBAAiB,IAAI,IAAI;CAgB1B;AAED,qBAAa,KAAK;IACG,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;IAEhC,qCAAqC;IACrC,MAAM,IAAI,KAAK;IASf,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,oBAAoB;IAkB5B,KAAK,IAAI,MAAM;IAUf;;;;;;;OAOG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAapC;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM;CAY1C"}
|
|
@@ -47,8 +47,17 @@ export class Color {
|
|
|
47
47
|
constructor(inner) {
|
|
48
48
|
this.inner = inner;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
/** generates a random solid color */
|
|
51
|
+
random() {
|
|
52
|
+
return new Color({
|
|
53
|
+
r: Math.floor(Math.random() * 255),
|
|
54
|
+
g: Math.floor(Math.random() * 255),
|
|
55
|
+
b: Math.floor(Math.random() * 255),
|
|
56
|
+
a: 255,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getRuntimeStyleSheet() {
|
|
60
|
+
const styleId = 'slu-lib-runtime-color-variables';
|
|
52
61
|
let styleElement = document.getElementById(styleId);
|
|
53
62
|
if (!styleElement) {
|
|
54
63
|
styleElement = document.createElement('style');
|
|
@@ -59,7 +68,7 @@ export class Color {
|
|
|
59
68
|
return styleElement;
|
|
60
69
|
}
|
|
61
70
|
insertIntoStyleSheet(obj) {
|
|
62
|
-
const sheet = this.
|
|
71
|
+
const sheet = this.getRuntimeStyleSheet();
|
|
63
72
|
const lines = sheet.textContent.split('\n');
|
|
64
73
|
lines.pop(); // remove the closing brace
|
|
65
74
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -109,11 +118,13 @@ export class Color {
|
|
|
109
118
|
calcLuminance(accuracy) {
|
|
110
119
|
const { r, g, b } = this.inner;
|
|
111
120
|
if (accuracy) {
|
|
121
|
+
// gamma correction
|
|
112
122
|
const gR = r ** 2.2;
|
|
113
123
|
const gG = g ** 2.2;
|
|
114
124
|
const gB = b ** 2.2;
|
|
115
125
|
return (0.299 * gR + 0.587 * gG + 0.114 * gB) ** (1 / 2.2);
|
|
116
126
|
}
|
|
127
|
+
// standard algorithm
|
|
117
128
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
118
129
|
}
|
|
119
130
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,9 @@ export declare class UIColors {
|
|
|
11
11
|
export declare class Color {
|
|
12
12
|
inner: IColor;
|
|
13
13
|
constructor(inner: IColor);
|
|
14
|
-
|
|
14
|
+
/** generates a random solid color */
|
|
15
|
+
random(): Color;
|
|
16
|
+
private getRuntimeStyleSheet;
|
|
15
17
|
private insertIntoStyleSheet;
|
|
16
18
|
asHex(): string;
|
|
17
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui_colors.d.ts","sourceRoot":"","sources":["../../src/system_state/ui_colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9E,qBAAa,QAAQ;IACA,KAAK,EAAE,SAAS;gBAAhB,KAAK,EAAE,SAAS;IAEnC,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAIpE,MAAM,CAAC,OAAO,IAAI,QAAQ;IAe1B,iBAAiB,IAAI,IAAI;CAgB1B;AAED,qBAAa,KAAK;IACG,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;IAEhC,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,oBAAoB;IAkB5B,KAAK,IAAI,MAAM;IAUf;;;;;;;OAOG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAapC;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"ui_colors.d.ts","sourceRoot":"","sources":["../../src/system_state/ui_colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9E,qBAAa,QAAQ;IACA,KAAK,EAAE,SAAS;gBAAhB,KAAK,EAAE,SAAS;IAEnC,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAIpE,MAAM,CAAC,OAAO,IAAI,QAAQ;IAe1B,iBAAiB,IAAI,IAAI;CAgB1B;AAED,qBAAa,KAAK;IACG,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;IAEhC,qCAAqC;IACrC,MAAM,IAAI,KAAK;IASf,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,oBAAoB;IAkB5B,KAAK,IAAI,MAAM;IAUf;;;;;;;OAOG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAapC;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM;CAY1C"}
|
|
@@ -51,8 +51,17 @@ class Color {
|
|
|
51
51
|
constructor(inner) {
|
|
52
52
|
this.inner = inner;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
/** generates a random solid color */
|
|
55
|
+
random() {
|
|
56
|
+
return new Color({
|
|
57
|
+
r: Math.floor(Math.random() * 255),
|
|
58
|
+
g: Math.floor(Math.random() * 255),
|
|
59
|
+
b: Math.floor(Math.random() * 255),
|
|
60
|
+
a: 255,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getRuntimeStyleSheet() {
|
|
64
|
+
const styleId = 'slu-lib-runtime-color-variables';
|
|
56
65
|
let styleElement = document.getElementById(styleId);
|
|
57
66
|
if (!styleElement) {
|
|
58
67
|
styleElement = document.createElement('style');
|
|
@@ -63,7 +72,7 @@ class Color {
|
|
|
63
72
|
return styleElement;
|
|
64
73
|
}
|
|
65
74
|
insertIntoStyleSheet(obj) {
|
|
66
|
-
const sheet = this.
|
|
75
|
+
const sheet = this.getRuntimeStyleSheet();
|
|
67
76
|
const lines = sheet.textContent.split('\n');
|
|
68
77
|
lines.pop(); // remove the closing brace
|
|
69
78
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -113,11 +122,13 @@ class Color {
|
|
|
113
122
|
calcLuminance(accuracy) {
|
|
114
123
|
const { r, g, b } = this.inner;
|
|
115
124
|
if (accuracy) {
|
|
125
|
+
// gamma correction
|
|
116
126
|
const gR = r ** 2.2;
|
|
117
127
|
const gG = g ** 2.2;
|
|
118
128
|
const gB = b ** 2.2;
|
|
119
129
|
return (0.299 * gR + 0.587 * gG + 0.114 * gB) ** (1 / 2.2);
|
|
120
130
|
}
|
|
131
|
+
// standard algorithm
|
|
121
132
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
122
133
|
}
|
|
123
134
|
}
|