@h-rig/cli 0.0.6-alpha.8 → 0.0.6-alpha.81
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/README.md +1 -1
- package/dist/bin/build-rig-binaries.d.ts +2 -0
- package/dist/bin/rig.d.ts +2 -0
- package/dist/bin/rig.js +18374 -8205
- package/dist/src/app/board.d.ts +23 -0
- package/dist/src/app/board.js +1815 -0
- package/dist/src/app/drone-ui.d.ts +37 -0
- package/dist/src/app/drone-ui.js +294 -0
- package/dist/src/app/theme.d.ts +47 -0
- package/dist/src/app/theme.js +151 -0
- package/dist/src/app-opentui/adapters/common.d.ts +53 -0
- package/dist/src/app-opentui/adapters/common.js +149 -0
- package/dist/src/app-opentui/adapters/doctor.d.ts +11 -0
- package/dist/src/app-opentui/adapters/doctor.js +780 -0
- package/dist/src/app-opentui/adapters/fleet.d.ts +16 -0
- package/dist/src/app-opentui/adapters/fleet.js +874 -0
- package/dist/src/app-opentui/adapters/inbox.d.ts +33 -0
- package/dist/src/app-opentui/adapters/inbox.js +1454 -0
- package/dist/src/app-opentui/adapters/init.d.ts +13 -0
- package/dist/src/app-opentui/adapters/init.js +2357 -0
- package/dist/src/app-opentui/adapters/pi-attach.d.ts +16 -0
- package/dist/src/app-opentui/adapters/pi-attach.js +1295 -0
- package/dist/src/app-opentui/adapters/run-detail.d.ts +20 -0
- package/dist/src/app-opentui/adapters/run-detail.js +893 -0
- package/dist/src/app-opentui/adapters/server.d.ts +14 -0
- package/dist/src/app-opentui/adapters/server.js +798 -0
- package/dist/src/app-opentui/adapters/tasks.d.ts +55 -0
- package/dist/src/app-opentui/adapters/tasks.js +3472 -0
- package/dist/src/app-opentui/bootstrap.d.ts +16 -0
- package/dist/src/app-opentui/bootstrap.js +19509 -0
- package/dist/src/app-opentui/drone.d.ts +12 -0
- package/dist/src/app-opentui/drone.js +227 -0
- package/dist/src/app-opentui/events.d.ts +7 -0
- package/dist/src/app-opentui/events.js +28 -0
- package/dist/src/app-opentui/index.d.ts +8 -0
- package/dist/src/app-opentui/index.js +3477 -0
- package/dist/src/app-opentui/intent.d.ts +3 -0
- package/dist/src/app-opentui/intent.js +211 -0
- package/dist/src/app-opentui/layout.d.ts +15 -0
- package/dist/src/app-opentui/layout.js +44 -0
- package/dist/src/app-opentui/list-search.d.ts +8 -0
- package/dist/src/app-opentui/list-search.js +43 -0
- package/dist/src/app-opentui/pi-host-child.d.ts +2 -0
- package/dist/src/app-opentui/pi-host-child.js +778 -0
- package/dist/src/app-opentui/pi-pty-host.d.ts +64 -0
- package/dist/src/app-opentui/pi-pty-host.js +384 -0
- package/dist/src/app-opentui/registry.d.ts +4 -0
- package/dist/src/app-opentui/registry.js +6835 -0
- package/dist/src/app-opentui/render/graphics.d.ts +39 -0
- package/dist/src/app-opentui/render/graphics.js +537 -0
- package/dist/src/app-opentui/render/image-visual-layer-native-canvas.d.ts +2 -0
- package/dist/src/app-opentui/render/image-visual-layer-native-canvas.js +1480 -0
- package/dist/src/app-opentui/render/image-visual-layer-worker.d.ts +1 -0
- package/dist/src/app-opentui/render/image-visual-layer-worker.js +1541 -0
- package/dist/src/app-opentui/render/image-visual-layer.d.ts +93 -0
- package/dist/src/app-opentui/render/image-visual-layer.js +945 -0
- package/dist/src/app-opentui/render/panels.d.ts +10 -0
- package/dist/src/app-opentui/render/panels.js +201 -0
- package/dist/src/app-opentui/render/scene.d.ts +16 -0
- package/dist/src/app-opentui/render/scene.js +110 -0
- package/dist/src/app-opentui/render/text.d.ts +10 -0
- package/dist/src/app-opentui/render/text.js +121 -0
- package/dist/src/app-opentui/render/type-bar.d.ts +14 -0
- package/dist/src/app-opentui/render/type-bar.js +137 -0
- package/dist/src/app-opentui/runtime.d.ts +2 -0
- package/dist/src/app-opentui/runtime.js +3406 -0
- package/dist/src/app-opentui/scenes/doctor.d.ts +2 -0
- package/dist/src/app-opentui/scenes/doctor.js +91 -0
- package/dist/src/app-opentui/scenes/error.d.ts +2 -0
- package/dist/src/app-opentui/scenes/error.js +190 -0
- package/dist/src/app-opentui/scenes/fleet.d.ts +3 -0
- package/dist/src/app-opentui/scenes/fleet.js +207 -0
- package/dist/src/app-opentui/scenes/handoff.d.ts +2 -0
- package/dist/src/app-opentui/scenes/handoff.js +147 -0
- package/dist/src/app-opentui/scenes/help.d.ts +3 -0
- package/dist/src/app-opentui/scenes/help.js +138 -0
- package/dist/src/app-opentui/scenes/inbox.d.ts +2 -0
- package/dist/src/app-opentui/scenes/inbox.js +118 -0
- package/dist/src/app-opentui/scenes/init.d.ts +2 -0
- package/dist/src/app-opentui/scenes/init.js +94 -0
- package/dist/src/app-opentui/scenes/main.d.ts +2 -0
- package/dist/src/app-opentui/scenes/main.js +96 -0
- package/dist/src/app-opentui/scenes/run-detail.d.ts +2 -0
- package/dist/src/app-opentui/scenes/run-detail.js +139 -0
- package/dist/src/app-opentui/scenes/server.d.ts +2 -0
- package/dist/src/app-opentui/scenes/server.js +88 -0
- package/dist/src/app-opentui/scenes/tasks.d.ts +3 -0
- package/dist/src/app-opentui/scenes/tasks.js +230 -0
- package/dist/src/app-opentui/state.d.ts +4 -0
- package/dist/src/app-opentui/state.js +286 -0
- package/dist/src/app-opentui/theme.d.ts +36 -0
- package/dist/src/app-opentui/theme.js +88 -0
- package/dist/src/app-opentui/types.d.ts +188 -0
- package/dist/src/app-opentui/types.js +1 -0
- package/dist/src/commands/_async-ui.d.ts +13 -0
- package/dist/src/commands/_async-ui.js +223 -0
- package/dist/src/commands/_authority-runs.d.ts +22 -0
- package/dist/src/commands/_authority-runs.js +2 -3
- package/dist/src/commands/_cli-format.d.ts +49 -0
- package/dist/src/commands/_cli-format.js +447 -0
- package/dist/src/commands/_connection-state.d.ts +44 -0
- package/dist/src/commands/_connection-state.js +30 -11
- package/dist/src/commands/_doctor-checks.d.ts +52 -0
- package/dist/src/commands/_doctor-checks.js +180 -44
- package/dist/src/commands/_help-catalog.d.ts +51 -0
- package/dist/src/commands/_help-catalog.js +442 -0
- package/dist/src/commands/_json-output.d.ts +11 -0
- package/dist/src/commands/_json-output.js +56 -0
- package/dist/src/commands/_operator-surface.d.ts +34 -0
- package/dist/src/commands/_operator-surface.js +220 -0
- package/dist/src/commands/_operator-view.d.ts +30 -0
- package/dist/src/commands/_operator-view.js +803 -73
- package/dist/src/commands/_parsers.d.ts +15 -0
- package/dist/src/commands/_parsers.js +18 -11
- package/dist/src/commands/_paths.d.ts +11 -0
- package/dist/src/commands/_pi-frontend.d.ts +27 -0
- package/dist/src/commands/_pi-frontend.js +742 -0
- package/dist/src/commands/_pi-install.d.ts +42 -0
- package/dist/src/commands/_pi-install.js +5 -4
- package/dist/src/commands/_policy.d.ts +8 -0
- package/dist/src/commands/_policy.js +12 -5
- package/dist/src/commands/_preflight.d.ts +22 -0
- package/dist/src/commands/_preflight.js +190 -128
- package/dist/src/commands/_probes.d.ts +1 -0
- package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
- package/dist/src/commands/_run-driver-helpers.js +75 -22
- package/dist/src/commands/_run-replay.d.ts +24 -0
- package/dist/src/commands/_run-replay.js +142 -0
- package/dist/src/commands/_server-client.d.ts +186 -0
- package/dist/src/commands/_server-client.js +360 -61
- package/dist/src/commands/_snapshot-upload.d.ts +39 -0
- package/dist/src/commands/_snapshot-upload.js +163 -39
- package/dist/src/commands/_spinner.d.ts +25 -0
- package/dist/src/commands/_spinner.js +65 -0
- package/dist/src/commands/_task-picker.d.ts +9 -0
- package/dist/src/commands/_task-picker.js +172 -19
- package/dist/src/commands/agent.d.ts +3 -0
- package/dist/src/commands/agent.js +39 -20
- package/dist/src/commands/browser.d.ts +65 -0
- package/dist/src/commands/browser.js +334 -51
- package/dist/src/commands/connect.d.ts +7 -0
- package/dist/src/commands/connect.js +272 -33
- package/dist/src/commands/dist.d.ts +28 -0
- package/dist/src/commands/dist.js +19 -12
- package/dist/src/commands/doctor.d.ts +3 -0
- package/dist/src/commands/doctor.js +378 -45
- package/dist/src/commands/github.d.ts +3 -0
- package/dist/src/commands/github.js +375 -53
- package/dist/src/commands/inbox.d.ts +30 -0
- package/dist/src/commands/inbox.js +760 -70
- package/dist/src/commands/init.d.ts +74 -0
- package/dist/src/commands/init.js +963 -119
- package/dist/src/commands/inspect.d.ts +3 -0
- package/dist/src/commands/inspect.js +588 -32
- package/dist/src/commands/inspector.d.ts +3 -0
- package/dist/src/commands/inspector.js +20 -13
- package/dist/src/commands/pi.d.ts +3 -0
- package/dist/src/commands/pi.js +177 -0
- package/dist/src/commands/plugin.d.ts +16 -0
- package/dist/src/commands/plugin.js +95 -27
- package/dist/src/commands/profile-and-review.d.ts +4 -0
- package/dist/src/commands/profile-and-review.js +26 -19
- package/dist/src/commands/queue.d.ts +3 -0
- package/dist/src/commands/queue.js +32 -12
- package/dist/src/commands/remote.d.ts +3 -0
- package/dist/src/commands/remote.js +43 -36
- package/dist/src/commands/repo-git-harness.d.ts +5 -0
- package/dist/src/commands/repo-git-harness.js +22 -15
- package/dist/src/commands/run.d.ts +3 -0
- package/dist/src/commands/run.js +1379 -159
- package/dist/src/commands/server.d.ts +7 -0
- package/dist/src/commands/server.js +502 -57
- package/dist/src/commands/setup.d.ts +16 -0
- package/dist/src/commands/setup.js +390 -63
- package/dist/src/commands/stats.d.ts +12 -0
- package/dist/src/commands/stats.js +1051 -0
- package/dist/src/commands/task-report-bug.d.ts +19 -0
- package/dist/src/commands/task-report-bug.js +260 -62
- package/dist/src/commands/task-run-driver.d.ts +132 -0
- package/dist/src/commands/task-run-driver.js +886 -130
- package/dist/src/commands/task.d.ts +14 -0
- package/dist/src/commands/task.js +1644 -314
- package/dist/src/commands/test.d.ts +3 -0
- package/dist/src/commands/test.js +15 -8
- package/dist/src/commands/workspace.d.ts +3 -0
- package/dist/src/commands/workspace.js +18 -11
- package/dist/src/commands.d.ts +29 -0
- package/dist/src/commands.js +10996 -6637
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +10197 -5787
- package/dist/src/launcher.d.ts +61 -0
- package/dist/src/launcher.js +77 -13
- package/dist/src/report-bug.d.ts +44 -0
- package/dist/src/report-bug.js +3 -3
- package/dist/src/runner.d.ts +47 -0
- package/dist/src/runner.js +16 -22
- package/dist/src/withMutedConsole.d.ts +2 -0
- package/package.json +16 -6
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FrameBufferRenderable, RGBA, type CliRenderer } from "@opentui/core";
|
|
2
|
+
import type { StageLayout } from "../layout";
|
|
3
|
+
import type { AppSceneId, AppScenePanel } from "../types";
|
|
4
|
+
export type RigGraphicsLayer = FrameBufferRenderable & {
|
|
5
|
+
__rigMarketingCanvas?: MarketingGlyphCanvas;
|
|
6
|
+
};
|
|
7
|
+
declare class MarketingGlyphCanvas {
|
|
8
|
+
private rand;
|
|
9
|
+
private canvas;
|
|
10
|
+
private layout;
|
|
11
|
+
private activeKind;
|
|
12
|
+
private lanes;
|
|
13
|
+
private motes;
|
|
14
|
+
private packets;
|
|
15
|
+
constructor(layout: StageLayout);
|
|
16
|
+
resize(layout: StageLayout): void;
|
|
17
|
+
render(layer: RigGraphicsLayer, scene: AppSceneId, tick: number): void;
|
|
18
|
+
private reset;
|
|
19
|
+
private setupDispatch;
|
|
20
|
+
private setupLoop;
|
|
21
|
+
private setupCarrier;
|
|
22
|
+
private packet;
|
|
23
|
+
private core;
|
|
24
|
+
private lanePoint;
|
|
25
|
+
private drawMotes;
|
|
26
|
+
private drawMarketingRails;
|
|
27
|
+
private drawDispatch;
|
|
28
|
+
private drawLoop;
|
|
29
|
+
private drawCarrier;
|
|
30
|
+
private drawDrone;
|
|
31
|
+
private blit;
|
|
32
|
+
}
|
|
33
|
+
export declare function createGraphicsLayer(renderer: CliRenderer, layout: StageLayout): RigGraphicsLayer;
|
|
34
|
+
export declare function resizeGraphicsLayer(layer: RigGraphicsLayer, layout: StageLayout): void;
|
|
35
|
+
export declare function clearGraphicsLayer(layer: RigGraphicsLayer): void;
|
|
36
|
+
export declare function drawPanelChrome(layer: RigGraphicsLayer, layout: StageLayout, panels: readonly AppScenePanel[]): void;
|
|
37
|
+
export declare function drawAmbientField(layer: RigGraphicsLayer, layout: StageLayout, tick: number, scene?: AppSceneId): void;
|
|
38
|
+
export declare function drawSparkline(layer: RigGraphicsLayer, x: number, y: number, values: readonly number[], color?: RGBA): void;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/cli/src/app-opentui/render/graphics.ts
|
|
3
|
+
import { FrameBufferRenderable, RGBA } from "@opentui/core";
|
|
4
|
+
|
|
5
|
+
// packages/cli/src/app-opentui/theme.ts
|
|
6
|
+
import {
|
|
7
|
+
bold as otuiBold,
|
|
8
|
+
dim as otuiDim,
|
|
9
|
+
fg as otuiFg,
|
|
10
|
+
t,
|
|
11
|
+
TextAttributes
|
|
12
|
+
} from "@opentui/core";
|
|
13
|
+
var RIG_UI = {
|
|
14
|
+
bg: "#070809",
|
|
15
|
+
bg2: "#0b0c0e",
|
|
16
|
+
panel: "#101115",
|
|
17
|
+
panel2: "#101115",
|
|
18
|
+
glass: "#14161b",
|
|
19
|
+
ink: "#f2f3f6",
|
|
20
|
+
ink2: "#aeb0ba",
|
|
21
|
+
ink3: "#6c6e79",
|
|
22
|
+
ink4: "#44464f",
|
|
23
|
+
lime: "#ccff4d",
|
|
24
|
+
limeDim: "#a9d63f",
|
|
25
|
+
cyan: "#56d8ff",
|
|
26
|
+
red: "#ff5d5d",
|
|
27
|
+
yellow: "#ffd24d",
|
|
28
|
+
magenta: "#ff79b0"
|
|
29
|
+
};
|
|
30
|
+
var styles = {
|
|
31
|
+
ink: otuiFg(RIG_UI.ink),
|
|
32
|
+
ink2: otuiFg(RIG_UI.ink2),
|
|
33
|
+
ink3: otuiFg(RIG_UI.ink3),
|
|
34
|
+
ink4: otuiFg(RIG_UI.ink4),
|
|
35
|
+
lime: otuiFg(RIG_UI.lime),
|
|
36
|
+
limeDim: otuiFg(RIG_UI.limeDim),
|
|
37
|
+
cyan: otuiFg(RIG_UI.cyan),
|
|
38
|
+
red: otuiFg(RIG_UI.red),
|
|
39
|
+
yellow: otuiFg(RIG_UI.yellow),
|
|
40
|
+
magenta: otuiFg(RIG_UI.magenta)
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// packages/cli/src/app-opentui/render/graphics.ts
|
|
44
|
+
var TRANSPARENT = RGBA.fromValues(0, 0, 0, 0);
|
|
45
|
+
var BACKDROP = RGBA.fromHex(RIG_UI.bg);
|
|
46
|
+
var PANEL_BG = RGBA.fromInts(16, 17, 21, 184);
|
|
47
|
+
var PANEL_HEADER_BG = RGBA.fromInts(16, 17, 21, 188);
|
|
48
|
+
var PANEL_LINE = RGBA.fromInts(255, 255, 255, 20);
|
|
49
|
+
var PANEL_LINE_DIM = RGBA.fromInts(255, 255, 255, 8);
|
|
50
|
+
var PANEL_TEXT_DIM = RGBA.fromInts(108, 110, 121, 255);
|
|
51
|
+
var AC_RGB = [204, 255, 77];
|
|
52
|
+
var C2_RGB = [86, 216, 255];
|
|
53
|
+
var MG_RGB = [255, 121, 176];
|
|
54
|
+
var INK_RGB = [108, 110, 121];
|
|
55
|
+
var BRAILLE_BITS = [
|
|
56
|
+
[1, 8],
|
|
57
|
+
[2, 16],
|
|
58
|
+
[4, 32],
|
|
59
|
+
[64, 128]
|
|
60
|
+
];
|
|
61
|
+
function sceneKind(scene) {
|
|
62
|
+
if (scene === "tasks")
|
|
63
|
+
return "loop";
|
|
64
|
+
if (scene === "help")
|
|
65
|
+
return "carrier";
|
|
66
|
+
return "dispatch";
|
|
67
|
+
}
|
|
68
|
+
function seeded(seed) {
|
|
69
|
+
let value = seed >>> 0;
|
|
70
|
+
return () => {
|
|
71
|
+
value = value * 1664525 + 1013904223 >>> 0;
|
|
72
|
+
return value / 4294967295;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function channelBuffer(canvas, channel) {
|
|
76
|
+
switch (channel) {
|
|
77
|
+
case 0:
|
|
78
|
+
return canvas.ac;
|
|
79
|
+
case 1:
|
|
80
|
+
return canvas.c2;
|
|
81
|
+
case 2:
|
|
82
|
+
return canvas.mg;
|
|
83
|
+
case 3:
|
|
84
|
+
return canvas.ink;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function addSample(canvas, channel, x, y, value) {
|
|
88
|
+
const ix = Math.trunc(x);
|
|
89
|
+
const iy = Math.trunc(y);
|
|
90
|
+
if (ix < 0 || iy < 0 || ix >= canvas.width || iy >= canvas.height)
|
|
91
|
+
return;
|
|
92
|
+
const buffer = channelBuffer(canvas, channel);
|
|
93
|
+
const index = iy * canvas.width + ix;
|
|
94
|
+
buffer[index] = Math.min(1, buffer[index] + value);
|
|
95
|
+
}
|
|
96
|
+
function drawDot(canvas, channel, cx, cy, radius, value) {
|
|
97
|
+
const minX = Math.floor(cx - radius);
|
|
98
|
+
const maxX = Math.ceil(cx + radius);
|
|
99
|
+
const minY = Math.floor(cy - radius);
|
|
100
|
+
const maxY = Math.ceil(cy + radius);
|
|
101
|
+
for (let y = minY;y <= maxY; y += 1) {
|
|
102
|
+
for (let x = minX;x <= maxX; x += 1) {
|
|
103
|
+
const dx = x - cx;
|
|
104
|
+
const dy = y - cy;
|
|
105
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
106
|
+
if (distance > radius)
|
|
107
|
+
continue;
|
|
108
|
+
const falloff = 1 - distance / Math.max(0.001, radius);
|
|
109
|
+
addSample(canvas, channel, x, y, value * (0.28 + falloff * 0.72));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function drawGlow(canvas, channel, cx, cy, radius, value) {
|
|
114
|
+
const minX = Math.floor(cx - radius);
|
|
115
|
+
const maxX = Math.ceil(cx + radius);
|
|
116
|
+
const minY = Math.floor(cy - radius);
|
|
117
|
+
const maxY = Math.ceil(cy + radius);
|
|
118
|
+
for (let y = minY;y <= maxY; y += 1) {
|
|
119
|
+
for (let x = minX;x <= maxX; x += 1) {
|
|
120
|
+
const dx = x - cx;
|
|
121
|
+
const dy = y - cy;
|
|
122
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
123
|
+
if (distance > radius)
|
|
124
|
+
continue;
|
|
125
|
+
const falloff = Math.pow(1 - distance / Math.max(0.001, radius), 2.2);
|
|
126
|
+
addSample(canvas, channel, x, y, value * falloff);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function drawLine(canvas, channel, x0, y0, x1, y1, value, width = 0.8) {
|
|
131
|
+
const dx = x1 - x0;
|
|
132
|
+
const dy = y1 - y0;
|
|
133
|
+
const steps = Math.max(1, Math.ceil(Math.hypot(dx, dy) * 1.7));
|
|
134
|
+
for (let step = 0;step <= steps; step += 1) {
|
|
135
|
+
const t2 = step / steps;
|
|
136
|
+
const x = x0 + dx * t2;
|
|
137
|
+
const y = y0 + dy * t2;
|
|
138
|
+
drawDot(canvas, channel, x, y, width, value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function drawCircleStroke(canvas, channel, cx, cy, radius, value) {
|
|
142
|
+
const steps = Math.max(18, Math.ceil(radius * 8));
|
|
143
|
+
for (let step = 0;step < steps; step += 1) {
|
|
144
|
+
const a = step / steps * Math.PI * 2;
|
|
145
|
+
drawDot(canvas, channel, cx + Math.cos(a) * radius, cy + Math.sin(a) * radius, 0.72, value);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function paletteColor(ac, c2, mg, ink) {
|
|
149
|
+
const total = Math.max(0.001, ac + c2 + mg + ink);
|
|
150
|
+
const r = (AC_RGB[0] * ac + C2_RGB[0] * c2 + MG_RGB[0] * mg + INK_RGB[0] * ink) / total;
|
|
151
|
+
const g = (AC_RGB[1] * ac + C2_RGB[1] * c2 + MG_RGB[1] * mg + INK_RGB[1] * ink) / total;
|
|
152
|
+
const b = (AC_RGB[2] * ac + C2_RGB[2] * c2 + MG_RGB[2] * mg + INK_RGB[2] * ink) / total;
|
|
153
|
+
const intensity = Math.min(1, total / 4);
|
|
154
|
+
const lift = 0.34 + intensity * 0.66;
|
|
155
|
+
return RGBA.fromInts(Math.round(r * lift), Math.round(g * lift), Math.round(b * lift), 255);
|
|
156
|
+
}
|
|
157
|
+
function clearCanvas(canvas) {
|
|
158
|
+
canvas.ac.fill(0);
|
|
159
|
+
canvas.c2.fill(0);
|
|
160
|
+
canvas.mg.fill(0);
|
|
161
|
+
canvas.ink.fill(0);
|
|
162
|
+
}
|
|
163
|
+
function makeCanvas(layout) {
|
|
164
|
+
const width = Math.max(1, layout.width * 2);
|
|
165
|
+
const height = Math.max(1, layout.height * 4);
|
|
166
|
+
const size = width * height;
|
|
167
|
+
return {
|
|
168
|
+
width,
|
|
169
|
+
height,
|
|
170
|
+
ac: new Float32Array(size),
|
|
171
|
+
c2: new Float32Array(size),
|
|
172
|
+
mg: new Float32Array(size),
|
|
173
|
+
ink: new Float32Array(size)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
class MarketingGlyphCanvas {
|
|
178
|
+
rand = seeded(6221137);
|
|
179
|
+
canvas;
|
|
180
|
+
layout;
|
|
181
|
+
activeKind = null;
|
|
182
|
+
lanes = [];
|
|
183
|
+
motes = [];
|
|
184
|
+
packets = [];
|
|
185
|
+
constructor(layout) {
|
|
186
|
+
this.layout = layout;
|
|
187
|
+
this.canvas = makeCanvas(layout);
|
|
188
|
+
this.reset("dispatch");
|
|
189
|
+
}
|
|
190
|
+
resize(layout) {
|
|
191
|
+
if (layout.width === this.layout.width && layout.height === this.layout.height)
|
|
192
|
+
return;
|
|
193
|
+
this.layout = layout;
|
|
194
|
+
this.canvas = makeCanvas(layout);
|
|
195
|
+
this.reset(this.activeKind ?? "dispatch");
|
|
196
|
+
}
|
|
197
|
+
render(layer, scene, tick) {
|
|
198
|
+
const kind = sceneKind(scene);
|
|
199
|
+
if (kind !== this.activeKind)
|
|
200
|
+
this.reset(kind);
|
|
201
|
+
clearCanvas(this.canvas);
|
|
202
|
+
this.drawMarketingRails(kind, tick);
|
|
203
|
+
if (kind === "loop")
|
|
204
|
+
this.drawLoop(tick);
|
|
205
|
+
else if (kind === "carrier")
|
|
206
|
+
this.drawCarrier(tick);
|
|
207
|
+
else
|
|
208
|
+
this.drawDispatch(tick);
|
|
209
|
+
this.blit(layer);
|
|
210
|
+
}
|
|
211
|
+
reset(kind) {
|
|
212
|
+
this.activeKind = kind;
|
|
213
|
+
this.lanes = [];
|
|
214
|
+
this.motes = [];
|
|
215
|
+
this.packets = [];
|
|
216
|
+
if (kind === "dispatch")
|
|
217
|
+
this.setupDispatch();
|
|
218
|
+
else if (kind === "loop")
|
|
219
|
+
this.setupLoop();
|
|
220
|
+
else
|
|
221
|
+
this.setupCarrier();
|
|
222
|
+
}
|
|
223
|
+
setupDispatch() {
|
|
224
|
+
const count = this.layout.compact ? 7 : 12;
|
|
225
|
+
for (let i = 0;i < count; i += 1) {
|
|
226
|
+
const ang = (-0.9 + 1.8 * (i / Math.max(1, count - 1))) * (Math.PI * 0.5);
|
|
227
|
+
this.lanes.push({ ang, len: this.canvas.width * (0.32 + this.rand() * 0.42), curve: (this.rand() - 0.5) * 0.7, phase: this.rand() * Math.PI * 2 });
|
|
228
|
+
}
|
|
229
|
+
const packets = this.layout.compact ? 70 : 150;
|
|
230
|
+
for (let i = 0;i < packets; i += 1)
|
|
231
|
+
this.packets.push(this.packet(true));
|
|
232
|
+
}
|
|
233
|
+
setupLoop() {
|
|
234
|
+
const lanes = this.layout.compact ? 4 : 7;
|
|
235
|
+
for (let i = 0;i < lanes; i += 1)
|
|
236
|
+
this.packets.push(this.packet(true));
|
|
237
|
+
}
|
|
238
|
+
setupCarrier() {
|
|
239
|
+
const nodes = this.layout.compact ? 5 : 7;
|
|
240
|
+
for (let i = 0;i < nodes * 6; i += 1)
|
|
241
|
+
this.packets.push(this.packet(true));
|
|
242
|
+
}
|
|
243
|
+
packet(random = false) {
|
|
244
|
+
return {
|
|
245
|
+
lane: Math.floor(this.rand() * Math.max(1, this.lanes.length || 7)),
|
|
246
|
+
p: random ? this.rand() : 0,
|
|
247
|
+
spd: 0.003 + this.rand() * 0.009,
|
|
248
|
+
channel: this.rand() < 0.22 ? 1 : 0,
|
|
249
|
+
wobble: (this.rand() - 0.5) * 7,
|
|
250
|
+
size: 0.8 + this.rand() * 1.3
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
core(kind) {
|
|
254
|
+
if (kind === "dispatch")
|
|
255
|
+
return { x: this.canvas.width * 0.3, y: this.canvas.height * 0.45 };
|
|
256
|
+
if (kind === "carrier")
|
|
257
|
+
return { x: this.canvas.width * 0.5, y: this.canvas.height * 0.54 };
|
|
258
|
+
return { x: this.canvas.width * 0.09, y: this.canvas.height * 0.56 };
|
|
259
|
+
}
|
|
260
|
+
lanePoint(lane, p, kind = "dispatch") {
|
|
261
|
+
const core = this.core(kind);
|
|
262
|
+
const dist = lane.len * p;
|
|
263
|
+
const bend = Math.sin(p * Math.PI) * lane.curve * 28;
|
|
264
|
+
const ux = Math.cos(lane.ang);
|
|
265
|
+
const uy = Math.sin(lane.ang);
|
|
266
|
+
return { x: core.x + ux * dist + -uy * bend, y: core.y + uy * dist + ux * bend };
|
|
267
|
+
}
|
|
268
|
+
drawMotes(tick) {
|
|
269
|
+
for (const mote of this.motes) {
|
|
270
|
+
mote.x += 0.1 * mote.z;
|
|
271
|
+
if (mote.x > this.canvas.width + 2)
|
|
272
|
+
mote.x = -2;
|
|
273
|
+
const alpha = (0.035 + 0.08 * mote.z) * (0.55 + 0.45 * Math.sin(tick * 0.03 + mote.tw));
|
|
274
|
+
drawDot(this.canvas, mote.channel, mote.x, mote.y, 0.45 * mote.z, alpha);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
drawMarketingRails(kind, tick) {
|
|
278
|
+
const ys = kind === "loop" ? [0.18, 0.5, 0.82] : kind === "carrier" ? [0.24, 0.54, 0.82] : [0.18, 0.58, 0.82];
|
|
279
|
+
ys.forEach((ratio, index) => {
|
|
280
|
+
const y = this.canvas.height * ratio + Math.sin(tick * 0.018 + index) * 1.8;
|
|
281
|
+
drawLine(this.canvas, index === 1 ? 0 : 1, this.canvas.width * 0.06, y, this.canvas.width * 0.94, y + Math.sin(index) * 2, index === 1 ? 0.11 : 0.07, 0.55);
|
|
282
|
+
for (let p = (tick * 0.004 + index * 0.21) % 1;p < 1; p += 0.18 + index * 0.02) {
|
|
283
|
+
const x = this.canvas.width * (0.06 + 0.88 * p);
|
|
284
|
+
drawDot(this.canvas, index === 2 ? 1 : 0, x, y, 1 + index * 0.25, 0.24);
|
|
285
|
+
drawGlow(this.canvas, index === 2 ? 1 : 0, x, y, 3.8, 0.035);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
drawDispatch(tick) {
|
|
290
|
+
const core = this.core("dispatch");
|
|
291
|
+
drawGlow(this.canvas, 0, core.x, core.y, 30, 0.12);
|
|
292
|
+
drawDot(this.canvas, 0, core.x, core.y, 2.2, 0.85);
|
|
293
|
+
for (const lane of this.lanes) {
|
|
294
|
+
let prev = this.lanePoint(lane, 0);
|
|
295
|
+
for (let i = 1;i <= 32; i += 1) {
|
|
296
|
+
const next = this.lanePoint(lane, i / 32);
|
|
297
|
+
drawLine(this.canvas, lane.phase > Math.PI ? 1 : 0, prev.x, prev.y, next.x, next.y, 0.045, 0.38);
|
|
298
|
+
prev = next;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
for (const packet of this.packets) {
|
|
302
|
+
packet.p += packet.spd;
|
|
303
|
+
if (packet.p > 1)
|
|
304
|
+
Object.assign(packet, this.packet(false));
|
|
305
|
+
const lane = this.lanes[packet.lane % Math.max(1, this.lanes.length)];
|
|
306
|
+
if (!lane)
|
|
307
|
+
continue;
|
|
308
|
+
const pt = this.lanePoint(lane, packet.p);
|
|
309
|
+
const fade = packet.p < 0.1 ? packet.p / 0.1 : packet.p > 0.88 ? (1 - packet.p) / 0.12 : 1;
|
|
310
|
+
const y = pt.y + packet.wobble * Math.sin(packet.p * Math.PI * 2);
|
|
311
|
+
drawLine(this.canvas, packet.channel, pt.x - 4, y - 1, pt.x, y, 0.08 * fade, 0.38);
|
|
312
|
+
drawDot(this.canvas, packet.channel, pt.x, y, packet.size, 0.5 * fade);
|
|
313
|
+
drawGlow(this.canvas, packet.channel, pt.x, y, packet.size * 4, 0.045 * fade);
|
|
314
|
+
}
|
|
315
|
+
for (let i = 0;i < (this.layout.compact ? 4 : 8); i += 1) {
|
|
316
|
+
const lane = this.lanes[i % Math.max(1, this.lanes.length)];
|
|
317
|
+
if (!lane)
|
|
318
|
+
continue;
|
|
319
|
+
const p = (tick * 0.002 + i * 0.13) % 1;
|
|
320
|
+
const pt = this.lanePoint(lane, p);
|
|
321
|
+
this.drawDrone(pt.x, pt.y + Math.sin(tick * 0.04 + i) * 2, 2.6 + i % 2 * 0.6, tick + i * 11, i % 3 === 0 ? 1 : 0);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
drawLoop(tick) {
|
|
325
|
+
const y = this.canvas.height * 0.56;
|
|
326
|
+
const x0 = this.canvas.width * 0.09;
|
|
327
|
+
const x1 = this.canvas.width * 0.91;
|
|
328
|
+
drawLine(this.canvas, 0, x0, y, x1, y, 0.12, 0.55);
|
|
329
|
+
const gates = this.layout.compact ? 4 : 5;
|
|
330
|
+
const active = Math.floor(tick / 16) % gates;
|
|
331
|
+
for (let i = 0;i < gates; i += 1) {
|
|
332
|
+
const x = x0 + (x1 - x0) * (i / Math.max(1, gates - 1));
|
|
333
|
+
drawLine(this.canvas, i === active ? 0 : 3, x, y - 22, x, y + 22, i === active ? 0.25 : 0.08, i === active ? 0.7 : 0.42);
|
|
334
|
+
drawDot(this.canvas, i <= active ? 0 : 3, x, y, i === active ? 2.2 : 1.2, i === active ? 0.72 : 0.25);
|
|
335
|
+
drawCircleStroke(this.canvas, i <= active ? 0 : 3, x, y, i === active ? 4.2 : 2.4, i === active ? 0.18 : 0.08);
|
|
336
|
+
}
|
|
337
|
+
for (const packet of this.packets) {
|
|
338
|
+
packet.p += packet.spd * 0.7;
|
|
339
|
+
if (packet.p > 1)
|
|
340
|
+
packet.p = 0;
|
|
341
|
+
const x = x0 + (x1 - x0) * packet.p;
|
|
342
|
+
const segment = Math.min(gates - 1, Math.floor(packet.p * gates));
|
|
343
|
+
const channel = segment < active ? 0 : segment === active ? 1 : 3;
|
|
344
|
+
const py = y + packet.wobble * Math.sin(packet.p * Math.PI * 2);
|
|
345
|
+
drawLine(this.canvas, channel, x - 6, py, x, py, 0.1, 0.42);
|
|
346
|
+
drawDot(this.canvas, channel, x, py, packet.size, channel === 3 ? 0.22 : 0.58);
|
|
347
|
+
drawGlow(this.canvas, channel, x, py, 3.8, channel === 3 ? 0.02 : 0.04);
|
|
348
|
+
}
|
|
349
|
+
this.drawDrone(x0 + (x1 - x0) * (tick * 0.003 % 1), y - 18, 2.7, tick, 0);
|
|
350
|
+
this.drawDrone(x0 + (x1 - x0) * ((tick * 0.002 + 0.5) % 1), y + 16, 2.2, tick + 40, 2);
|
|
351
|
+
}
|
|
352
|
+
drawCarrier(tick) {
|
|
353
|
+
const core = this.core("carrier");
|
|
354
|
+
drawGlow(this.canvas, 0, core.x, core.y, 26, 0.12);
|
|
355
|
+
drawDot(this.canvas, 0, core.x, core.y, 2.4, 0.92);
|
|
356
|
+
drawCircleStroke(this.canvas, 0, core.x, core.y, 8 + Math.sin(tick * 0.06) * 2, 0.14);
|
|
357
|
+
const nodes = this.layout.compact ? 5 : 7;
|
|
358
|
+
const rx = this.canvas.width * 0.36;
|
|
359
|
+
const ry = this.canvas.height * 0.22;
|
|
360
|
+
for (let i = 0;i < nodes; i += 1) {
|
|
361
|
+
const a = i / nodes * Math.PI * 2 - Math.PI / 2 + tick * 0.006;
|
|
362
|
+
const x = core.x + Math.cos(a) * rx;
|
|
363
|
+
const y = core.y + Math.sin(a) * ry;
|
|
364
|
+
drawLine(this.canvas, i % 2 ? 1 : 0, core.x, core.y, x, y, 0.055, 0.36);
|
|
365
|
+
drawCircleStroke(this.canvas, i % 2 ? 1 : 0, x, y, 4.2, 0.15);
|
|
366
|
+
drawDot(this.canvas, i % 2 ? 1 : 0, x, y, 1.7, 0.62);
|
|
367
|
+
this.drawDrone(x, y - 8, 2.1, tick + i * 9, i % 2 ? 1 : 0);
|
|
368
|
+
}
|
|
369
|
+
for (const packet of this.packets) {
|
|
370
|
+
packet.p += packet.spd;
|
|
371
|
+
if (packet.p > 1)
|
|
372
|
+
packet.p = 0;
|
|
373
|
+
const lane = packet.lane % nodes;
|
|
374
|
+
const a = lane / nodes * Math.PI * 2 - Math.PI / 2 + tick * 0.006;
|
|
375
|
+
const nx = core.x + Math.cos(a) * rx;
|
|
376
|
+
const ny = core.y + Math.sin(a) * ry;
|
|
377
|
+
const x = core.x + (nx - core.x) * packet.p;
|
|
378
|
+
const y = core.y + (ny - core.y) * packet.p;
|
|
379
|
+
drawDot(this.canvas, packet.channel, x, y, packet.size, 0.48);
|
|
380
|
+
drawGlow(this.canvas, packet.channel, x, y, 3.2, 0.035);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
drawDrone(x, y, scale, tick, channel) {
|
|
384
|
+
const wobble = Math.sin(tick * 0.08) * 0.7;
|
|
385
|
+
drawDot(this.canvas, channel, x, y + wobble, scale, 0.58);
|
|
386
|
+
drawDot(this.canvas, 3, x, y + wobble, Math.max(0.6, scale * 0.28), 0.42);
|
|
387
|
+
const rotor = scale * 1.75;
|
|
388
|
+
const arms = [
|
|
389
|
+
[-rotor, -rotor * 0.75],
|
|
390
|
+
[rotor, -rotor * 0.75],
|
|
391
|
+
[-rotor, rotor * 0.75],
|
|
392
|
+
[rotor, rotor * 0.75]
|
|
393
|
+
];
|
|
394
|
+
for (const [dx, dy] of arms) {
|
|
395
|
+
drawLine(this.canvas, channel, x, y + wobble, x + dx, y + dy + wobble, 0.11, 0.38);
|
|
396
|
+
drawCircleStroke(this.canvas, channel, x + dx, y + dy + wobble, scale * (0.65 + Math.abs(Math.sin(tick * 0.18)) * 0.25), 0.16);
|
|
397
|
+
drawDot(this.canvas, channel, x + dx, y + dy + wobble, 0.7, 0.25);
|
|
398
|
+
}
|
|
399
|
+
drawLine(this.canvas, channel === 1 ? 0 : 1, x - rotor * 2.4, y + wobble + 1.2, x - rotor * 1.2, y + wobble, 0.05, 0.35);
|
|
400
|
+
}
|
|
401
|
+
blit(layer) {
|
|
402
|
+
const fb = layer.frameBuffer;
|
|
403
|
+
fb.clear(BACKDROP);
|
|
404
|
+
const { width, height, ac, c2, mg, ink } = this.canvas;
|
|
405
|
+
for (let cy = 0;cy < this.layout.height; cy += 1) {
|
|
406
|
+
for (let cx = 0;cx < this.layout.width; cx += 1) {
|
|
407
|
+
let bits = 0;
|
|
408
|
+
let acSum = 0;
|
|
409
|
+
let c2Sum = 0;
|
|
410
|
+
let mgSum = 0;
|
|
411
|
+
let inkSum = 0;
|
|
412
|
+
for (let sy = 0;sy < 4; sy += 1) {
|
|
413
|
+
for (let sx = 0;sx < 2; sx += 1) {
|
|
414
|
+
const px = cx * 2 + sx;
|
|
415
|
+
const py = cy * 4 + sy;
|
|
416
|
+
if (px >= width || py >= height)
|
|
417
|
+
continue;
|
|
418
|
+
const index = py * width + px;
|
|
419
|
+
const a = ac[index];
|
|
420
|
+
const c = c2[index];
|
|
421
|
+
const m = mg[index];
|
|
422
|
+
const k = ink[index];
|
|
423
|
+
const total2 = a + c + m + k;
|
|
424
|
+
acSum += a;
|
|
425
|
+
c2Sum += c;
|
|
426
|
+
mgSum += m;
|
|
427
|
+
inkSum += k;
|
|
428
|
+
if (total2 > 0.11)
|
|
429
|
+
bits |= BRAILLE_BITS[sy][sx];
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const total = acSum + c2Sum + mgSum + inkSum;
|
|
433
|
+
if (bits === 0 || total <= 0.02)
|
|
434
|
+
continue;
|
|
435
|
+
const char = String.fromCharCode(10240 + bits);
|
|
436
|
+
fb.setCellWithAlphaBlending(cx, cy, char, paletteColor(acSum, c2Sum, mgSum, inkSum), TRANSPARENT);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
function createGraphicsLayer(renderer, layout) {
|
|
442
|
+
const layer = new FrameBufferRenderable(renderer, {
|
|
443
|
+
id: "rig-marketing-glyph-canvas",
|
|
444
|
+
width: layout.width,
|
|
445
|
+
height: layout.height,
|
|
446
|
+
position: "absolute",
|
|
447
|
+
left: 0,
|
|
448
|
+
top: 0,
|
|
449
|
+
respectAlpha: true
|
|
450
|
+
});
|
|
451
|
+
layer.__rigMarketingCanvas = new MarketingGlyphCanvas(layout);
|
|
452
|
+
return layer;
|
|
453
|
+
}
|
|
454
|
+
function resizeGraphicsLayer(layer, layout) {
|
|
455
|
+
if (layer.width !== layout.width)
|
|
456
|
+
layer.width = layout.width;
|
|
457
|
+
if (layer.height !== layout.height)
|
|
458
|
+
layer.height = layout.height;
|
|
459
|
+
layer.__rigMarketingCanvas?.resize(layout);
|
|
460
|
+
}
|
|
461
|
+
function clearGraphicsLayer(layer) {
|
|
462
|
+
layer.frameBuffer.clear(BACKDROP);
|
|
463
|
+
}
|
|
464
|
+
function panelRect(layout, panel) {
|
|
465
|
+
const left = Math.max(0, Math.min(layout.width - 1, layout.centerLeft + (panel.left ?? 0)));
|
|
466
|
+
const desiredWidth = panel.width ?? layout.centerWidth;
|
|
467
|
+
const width = Math.max(1, Math.min(layout.width - left, desiredWidth));
|
|
468
|
+
const top = Math.max(0, Math.min(layout.height - 1, layout.centerTop + panel.top));
|
|
469
|
+
const height = Math.max(1, Math.min(layout.height - top, panel.height));
|
|
470
|
+
return width > 3 && height > 3 ? { left, top, width, height } : null;
|
|
471
|
+
}
|
|
472
|
+
function writeCell(layer, x, y, char, fg, bg) {
|
|
473
|
+
layer.frameBuffer.setCellWithAlphaBlending(x, y, char, fg, bg);
|
|
474
|
+
}
|
|
475
|
+
function drawFullCell(layer, x, y, bg) {
|
|
476
|
+
writeCell(layer, x, y, " ", TRANSPARENT, bg);
|
|
477
|
+
}
|
|
478
|
+
function drawCornerCut(layer, x, y, char, fg) {
|
|
479
|
+
writeCell(layer, x, y, char, fg, BACKDROP);
|
|
480
|
+
}
|
|
481
|
+
function drawRoundedFill(layer, left, top, right, bottom, dividerY) {
|
|
482
|
+
const bgForY = (y) => y < dividerY ? PANEL_HEADER_BG : PANEL_BG;
|
|
483
|
+
for (let y = top;y <= bottom; y += 1) {
|
|
484
|
+
const bg = bgForY(y);
|
|
485
|
+
for (let x = left;x <= right; x += 1)
|
|
486
|
+
drawFullCell(layer, x, y, bg);
|
|
487
|
+
}
|
|
488
|
+
drawCornerCut(layer, left, top, "\u2597", PANEL_HEADER_BG);
|
|
489
|
+
drawCornerCut(layer, right, top, "\u2596", PANEL_HEADER_BG);
|
|
490
|
+
drawCornerCut(layer, left, bottom, "\u259D", PANEL_BG);
|
|
491
|
+
drawCornerCut(layer, right, bottom, "\u2598", PANEL_BG);
|
|
492
|
+
}
|
|
493
|
+
function drawAdTerminalPanel(layer, layout, panel) {
|
|
494
|
+
const rect = panelRect(layout, panel);
|
|
495
|
+
if (!rect)
|
|
496
|
+
return;
|
|
497
|
+
const { left, top, width, height } = rect;
|
|
498
|
+
const right = left + width - 1;
|
|
499
|
+
const bottom = top + height - 1;
|
|
500
|
+
const headerHeight = Math.max(3, Math.min(height - 2, panel.headerHeight ?? 3));
|
|
501
|
+
const dividerY = Math.min(bottom - 1, top + headerHeight);
|
|
502
|
+
drawRoundedFill(layer, left, top, right, bottom, dividerY);
|
|
503
|
+
if (dividerY > top && dividerY < bottom) {
|
|
504
|
+
for (let x = left + 2;x < right - 1; x += 1) {
|
|
505
|
+
writeCell(layer, x, dividerY, "\u2500", PANEL_LINE_DIM, PANEL_BG);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (panel.headerText) {
|
|
509
|
+
const x = left + Math.max(2, Math.min(5, panel.paddingX ?? 4));
|
|
510
|
+
const y = top + Math.max(1, Math.floor(headerHeight / 2));
|
|
511
|
+
layer.frameBuffer.drawText(panel.headerText.slice(0, Math.max(0, width - 8)), x, y, PANEL_TEXT_DIM, TRANSPARENT);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function drawPanelChrome(layer, layout, panels) {
|
|
515
|
+
for (const panel of panels) {
|
|
516
|
+
if (panel.chrome === "ad-terminal")
|
|
517
|
+
drawAdTerminalPanel(layer, layout, panel);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function drawAmbientField(layer, layout, tick, scene = "fleet") {
|
|
521
|
+
layer.__rigMarketingCanvas?.render(layer, scene, tick);
|
|
522
|
+
}
|
|
523
|
+
function drawSparkline(layer, x, y, values, color = RGBA.fromHex(RIG_UI.cyan)) {
|
|
524
|
+
const chars = ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
|
|
525
|
+
values.forEach((value, index) => {
|
|
526
|
+
const level = Math.max(0, Math.min(chars.length - 1, Math.round(value * (chars.length - 1))));
|
|
527
|
+
layer.frameBuffer.setCell(x + index, y, chars[level], color, TRANSPARENT);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
export {
|
|
531
|
+
resizeGraphicsLayer,
|
|
532
|
+
drawSparkline,
|
|
533
|
+
drawPanelChrome,
|
|
534
|
+
drawAmbientField,
|
|
535
|
+
createGraphicsLayer,
|
|
536
|
+
clearGraphicsLayer
|
|
537
|
+
};
|