multi-gauge 0.1.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/LICENSE +21 -0
- package/README.md +124 -0
- package/docs/multigauge-demo.png +0 -0
- package/package.json +29 -0
- package/src/MultiGauge.js +358 -0
- package/src/assets/fonts/InterVariable.woff2 +0 -0
- package/src/assets/fonts/LICENSE.txt +92 -0
- package/src/errors.js +7 -0
- package/src/gpu/GpuRuntime.js +153 -0
- package/src/gpu/IconCache.js +69 -0
- package/src/gpu/Renderer.js +370 -0
- package/src/gpu/SceneBuilder.js +736 -0
- package/src/gpu/TextAtlas.js +304 -0
- package/src/gpu/shaders.js +212 -0
- package/src/index.js +2 -0
- package/src/interaction/GridEditor.js +446 -0
- package/src/layout/CellLayout.js +167 -0
- package/src/layout/GridLayout.js +405 -0
- package/src/layout/PanelLayout.js +70 -0
- package/src/model/GaugeModel.js +196 -0
- package/src/theme.js +41 -0
package/src/theme.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const DEFAULT_THEME = Object.freeze({
|
|
2
|
+
background: '#071014',
|
|
3
|
+
surface: '#0c171d',
|
|
4
|
+
surfaceRaised: '#102129',
|
|
5
|
+
grid: '#1b3540',
|
|
6
|
+
text: '#e7f7fa',
|
|
7
|
+
muted: '#78909a',
|
|
8
|
+
normal: '#41e6a1',
|
|
9
|
+
warning: '#ffc857',
|
|
10
|
+
critical: '#ff4d6d',
|
|
11
|
+
inactive: '#40515a',
|
|
12
|
+
target: '#f3f7a7',
|
|
13
|
+
cruise: '#6b8cff'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/** Parse #rgb, #rrggbb, #rrggbbaa or a numeric RGBA array. */
|
|
17
|
+
export function color(value, alpha = 1) {
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
return [value[0] ?? 0, value[1] ?? 0, value[2] ?? 0, (value[3] ?? 1) * alpha];
|
|
20
|
+
}
|
|
21
|
+
const hex = String(value ?? '#ffffff').replace('#', '');
|
|
22
|
+
const expanded = hex.length === 3 ? [...hex].map((part) => part + part).join('') : hex;
|
|
23
|
+
const parsed = Number.parseInt(expanded.slice(0, 8).padEnd(8, 'f'), 16);
|
|
24
|
+
if (!Number.isFinite(parsed)) {
|
|
25
|
+
return [1, 1, 1, alpha];
|
|
26
|
+
}
|
|
27
|
+
return [
|
|
28
|
+
((parsed >>> 24) & 255) / 255,
|
|
29
|
+
((parsed >>> 16) & 255) / 255,
|
|
30
|
+
((parsed >>> 8) & 255) / 255,
|
|
31
|
+
(parsed & 255) / 255 * alpha
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function resolveTheme(theme = {}, accent = '#00eaff') {
|
|
36
|
+
return { ...DEFAULT_THEME, ...theme, accent };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function semanticColor(theme, kind, fallback = 'accent') {
|
|
40
|
+
return color(theme[kind] ?? theme[fallback] ?? theme.accent);
|
|
41
|
+
}
|