@lewismoten/gamemaker-sandbox-tools 0.0.0-stage → 3.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 +24 -0
- package/NOTICE.md +19 -0
- package/README.md +76 -2
- package/dist/audio.js +140 -0
- package/dist/binary-D7wuaC5g.js +120 -0
- package/dist/drawing.js +871 -0
- package/dist/formats/blocks.js +103 -0
- package/dist/formats/character.js +83 -0
- package/dist/formats/cmf.js +37 -0
- package/dist/formats/fli.js +296 -0
- package/dist/formats/fliLimits.js +54 -0
- package/dist/formats/game.js +193 -0
- package/dist/formats/gif.js +125 -0
- package/dist/formats/graphicScripts.js +44 -0
- package/dist/formats/map.js +38 -0
- package/dist/formats/monster.js +69 -0
- package/dist/formats/palette.js +58 -0
- package/dist/formats/recording.js +17 -0
- package/dist/formats/sound.js +44 -0
- package/dist/formats/voc.js +303 -0
- package/dist/images.js +50 -0
- package/dist/pixels-DzfIIUOl.js +76 -0
- package/dist/simulation.js +2776 -0
- package/dist/types/games/kit/blit.d.ts +10 -0
- package/dist/types/games/kit/clips.d.ts +36 -0
- package/dist/types/games/kit/gameSim.d.ts +108 -0
- package/dist/types/games/kit/music.d.ts +1 -0
- package/dist/types/games/kit/palette.d.ts +16 -0
- package/dist/types/games/kit/pcText.d.ts +8 -0
- package/dist/types/games/kit/pixels.d.ts +26 -0
- package/dist/types/games/kit/reel.d.ts +34 -0
- package/dist/types/games/kit/sceneSim.d.ts +84 -0
- package/dist/types/games/kit/shading.d.ts +11 -0
- package/dist/types/games/kit/sound.d.ts +29 -0
- package/dist/types/games/kit/textBounds.d.ts +51 -0
- package/dist/types/games/kit/tune.d.ts +6 -0
- package/dist/types/web/packages/tools/src/audio.d.ts +3 -0
- package/dist/types/web/packages/tools/src/colors.d.ts +20 -0
- package/dist/types/web/packages/tools/src/drawing.d.ts +10 -0
- package/dist/types/web/packages/tools/src/images.d.ts +2 -0
- package/dist/types/web/packages/tools/src/microFont.d.ts +1 -0
- package/dist/types/web/packages/tools/src/simulation.d.ts +3 -0
- package/dist/types/web/packages/tools/src/text.d.ts +41 -0
- package/dist/types/web/scripts/cdGames.d.ts +103 -0
- package/dist/types/web/scripts/gameShots.d.ts +12 -0
- package/dist/types/web/scripts/ogImage.d.ts +21 -0
- package/dist/types/web/src/assistant/png.d.ts +10 -0
- package/dist/types/web/src/audio/cmfLoad.d.ts +7 -0
- package/dist/types/web/src/audio/cmfPlayer.d.ts +69 -0
- package/dist/types/web/src/audio/compose.d.ts +51 -0
- package/dist/types/web/src/audio/context.d.ts +12 -0
- package/dist/types/web/src/audio/engine.d.ts +39 -0
- package/dist/types/web/src/audio/music.worklet.d.ts +14 -0
- package/dist/types/web/src/audio/opl.d.ts +37 -0
- package/dist/types/web/src/audio/output.d.ts +13 -0
- package/dist/types/web/src/desk/boxes/boxFacts.d.ts +85 -0
- package/dist/types/web/src/dosPlayer/fileExtensions.d.ts +44 -0
- package/dist/types/web/src/dosPlayer/patchRules.d.ts +24 -0
- package/dist/types/web/src/dosPlayer/patchTable.d.ts +80 -0
- package/dist/types/web/src/edition.d.ts +6 -0
- package/dist/types/web/src/eggs/eggState.d.ts +26 -0
- package/dist/types/web/src/eggs/eggs.d.ts +31 -0
- package/dist/types/web/src/engine/character.d.ts +30 -0
- package/dist/types/web/src/engine/funcKeys.d.ts +33 -0
- package/dist/types/web/src/engine/game.d.ts +52 -0
- package/dist/types/web/src/engine/keys.d.ts +17 -0
- package/dist/types/web/src/engine/machine.d.ts +99 -0
- package/dist/types/web/src/engine/menus.d.ts +46 -0
- package/dist/types/web/src/engine/monsters.d.ts +19 -0
- package/dist/types/web/src/engine/playGain.d.ts +11 -0
- package/dist/types/web/src/engine/playerLook.d.ts +26 -0
- package/dist/types/web/src/engine/recorder.d.ts +60 -0
- package/dist/types/web/src/engine/render.d.ts +8 -0
- package/dist/types/web/src/engine/scene.d.ts +156 -0
- package/dist/types/web/src/engine/scroll.d.ts +16 -0
- package/dist/types/web/src/engine/showGraphic.d.ts +39 -0
- package/dist/types/web/src/engine/slowPc.d.ts +62 -0
- package/dist/types/web/src/engine/touch.d.ts +33 -0
- package/dist/types/web/src/engine/world.d.ts +215 -0
- package/dist/types/web/src/export/gameAbout.d.ts +15 -0
- package/dist/types/web/src/formats/binary.d.ts +44 -0
- package/dist/types/web/src/formats/blocks.d.ts +52 -0
- package/dist/types/web/src/formats/character.d.ts +65 -0
- package/dist/types/web/src/formats/cmf.d.ts +33 -0
- package/dist/types/web/src/formats/fli.d.ts +45 -0
- package/dist/types/web/src/formats/fliLimits.d.ts +13 -0
- package/dist/types/web/src/formats/game.d.ts +72 -0
- package/dist/types/web/src/formats/gif.d.ts +15 -0
- package/dist/types/web/src/formats/graphicScripts.d.ts +18 -0
- package/dist/types/web/src/formats/highscore.d.ts +10 -0
- package/dist/types/web/src/formats/map.d.ts +24 -0
- package/dist/types/web/src/formats/monster.d.ts +48 -0
- package/dist/types/web/src/formats/palette.d.ts +15 -0
- package/dist/types/web/src/formats/recording.d.ts +7 -0
- package/dist/types/web/src/formats/sound.d.ts +13 -0
- package/dist/types/web/src/formats/voc.d.ts +13 -0
- package/dist/types/web/src/gfx/cp437Glyphs.d.ts +2 -0
- package/dist/types/web/src/gfx/font8x8.d.ts +2 -0
- package/dist/types/web/src/gfx/levelPicture.d.ts +81 -0
- package/dist/types/web/src/gfx/screen.d.ts +46 -0
- package/dist/types/web/src/gfx/titlePicture.d.ts +21 -0
- package/dist/types/web/src/input/chords.d.ts +22 -0
- package/dist/types/web/src/input/deskMouse.d.ts +14 -0
- package/dist/types/web/src/input/keyboard.d.ts +39 -0
- package/dist/types/web/src/input/scancodes.d.ts +3 -0
- package/dist/types/web/src/manual/printables/types.d.ts +277 -0
- package/dist/types/web/src/project/bizarre.d.ts +28 -0
- package/dist/types/web/src/project/companion.d.ts +35 -0
- package/dist/types/web/src/project/diskFacts.d.ts +30 -0
- package/dist/types/web/src/project/files.d.ts +124 -0
- package/dist/types/web/src/project/gameFiles.d.ts +49 -0
- package/dist/types/web/src/project/gamePack.d.ts +17 -0
- package/dist/types/web/src/project/health.d.ts +30 -0
- package/dist/types/web/src/project/secretGames.d.ts +19 -0
- package/dist/types/web/src/project/storage.d.ts +46 -0
- package/dist/types/web/src/project/streamGame.d.ts +38 -0
- package/dist/types/web/src/project/zip.d.ts +33 -0
- package/dist/types/web/src/retro/dos/disks.d.ts +33 -0
- package/dist/types/web/src/retro/text/cp437.d.ts +4 -0
- package/dist/types/web/src/seededRandom.d.ts +6 -0
- package/dist/types/web/src/tinHearts/deskHearts.d.ts +33 -0
- package/dist/types/web/src/tinHearts/manifest.d.ts +30 -0
- package/dist/types/web/src/tinHearts/tinHearts.d.ts +84 -0
- package/dist/types/web/src/walkthrough/format.d.ts +92 -0
- package/dist/types/web/src/walkthrough/madeUpScores.d.ts +6 -0
- package/dist/types/web/src/walkthrough/runtime.d.ts +134 -0
- package/package.json +60 -4
package/dist/drawing.js
ADDED
|
@@ -0,0 +1,871 @@
|
|
|
1
|
+
import { P as g, d as K, r as V } from "./pixels-DzfIIUOl.js";
|
|
2
|
+
import { writeFileSync as q, existsSync as Q, readFileSync as Z } from "node:fs";
|
|
3
|
+
import { encodeFli as t0 } from "./formats/fli.js";
|
|
4
|
+
import { vga8 as P } from "./formats/palette.js";
|
|
5
|
+
class E0 {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.pal = new Uint8Array(768), this.next = 0, this.ramps = /* @__PURE__ */ new Map();
|
|
8
|
+
}
|
|
9
|
+
/** One color from 8-bit RGB; returns its index. */
|
|
10
|
+
color(f, c, e) {
|
|
11
|
+
const n = this.next++;
|
|
12
|
+
if (n > 254) throw new Error('Palette full (255 is "clear")');
|
|
13
|
+
return this.pal.set([f >> 2, c >> 2, e >> 2], n * 3), n;
|
|
14
|
+
}
|
|
15
|
+
/** A ramp of n shades from dark to light (8-bit RGB stops); returns the indexes. */
|
|
16
|
+
ramp(f, c, e, n, s) {
|
|
17
|
+
const r = [];
|
|
18
|
+
for (let o = 0; o < c; o++) {
|
|
19
|
+
const i = c === 1 ? 0 : o / (c - 1), [a, h, l] = s ? i < 0.5 ? [e, s, i * 2] : [s, n, (i - 0.5) * 2] : [e, n, i];
|
|
20
|
+
r.push(this.color(...a.map((u, d) => Math.round(u + (h[d] - u) * l))));
|
|
21
|
+
}
|
|
22
|
+
return this.ramps.set(f, r), r;
|
|
23
|
+
}
|
|
24
|
+
get(f) {
|
|
25
|
+
const c = this.ramps.get(f);
|
|
26
|
+
if (!c) throw new Error(`No ramp ${f}`);
|
|
27
|
+
return c;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Game-Maker's designers look for these grays, reds, black and LCD green; keep them. Black
|
|
31
|
+
* comes first: PLAYGAME clears the screen to color 0 before the high score prompt.
|
|
32
|
+
*/
|
|
33
|
+
designerColors() {
|
|
34
|
+
for (const [f, c, e] of [
|
|
35
|
+
[0, 0, 0],
|
|
36
|
+
[33, 33, 33],
|
|
37
|
+
[43, 0, 0],
|
|
38
|
+
[28, 0, 0],
|
|
39
|
+
[28, 28, 28],
|
|
40
|
+
[23, 23, 23],
|
|
41
|
+
[18, 18, 18],
|
|
42
|
+
[53, 0, 0],
|
|
43
|
+
[8, 48, 24]
|
|
44
|
+
])
|
|
45
|
+
this.color(f * 4, c * 4, e * 4);
|
|
46
|
+
}
|
|
47
|
+
get used() {
|
|
48
|
+
return this.next;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const e0 = (t) => /[\x20-\x7e\u25cf\u2022]/.test(t), O = typeof process < "u" ? process.env.TEXT_BOUNDS : void 0, U = [], A = /* @__PURE__ */ new Map(), _ = (t, f, c, e) => `${t}x${f} ${c} ${e}`, c0 = /\/art\/(font|draw|canvas)\.ts|screens\/(draw|screen)\.ts/;
|
|
52
|
+
function f0() {
|
|
53
|
+
const t = (new Error().stack ?? "").split(`
|
|
54
|
+
`).slice(1).map((e) => /\(?((?:\/|file:)[^():]+):(\d+):\d+\)?\s*$/.exec(e)).filter((e) => !!e).map((e) => ({ path: e[1].replace(/^file:\/\//, "").replace(/^.*\/games\//, ""), line: e[2] })).filter((e) => !/node_modules|kit\/textBounds\.ts/.test(e.path)).map((e) => ({ ...e, helper: c0.test(e.path), name: `${e.path}:${e.line}` })), f = t.findIndex((e) => !e.helper);
|
|
55
|
+
return {
|
|
56
|
+
at: t.filter((e) => !e.helper).slice(0, 2).map((e) => e.name).join(" < "),
|
|
57
|
+
via: t.slice(0, f + 1).map((e) => e.name).join(" > ")
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
O && process.on("exit", () => {
|
|
61
|
+
const t = {
|
|
62
|
+
overflows: U,
|
|
63
|
+
shown: Object.fromEntries([...A].map(([f, c]) => [f, [...c].map((e) => e.split(",").map(Number))]))
|
|
64
|
+
};
|
|
65
|
+
q(O, JSON.stringify(t));
|
|
66
|
+
});
|
|
67
|
+
class n0 {
|
|
68
|
+
constructor(f, c, e, n, s) {
|
|
69
|
+
this.w = f, this.h = c, this.s = e, this.area = n, this.has = s, this.x0 = 1 / 0, this.y0 = 1 / 0, this.x1 = -1 / 0, this.y1 = -1 / 0;
|
|
70
|
+
}
|
|
71
|
+
/** A lit rectangle of the string (a font pixel, scaled). */
|
|
72
|
+
add(f, c, e = 1, n = 1) {
|
|
73
|
+
f < this.x0 && (this.x0 = f), c < this.y0 && (this.y0 = c), f + e > this.x1 && (this.x1 = f + e), c + n > this.y1 && (this.y1 = c + n);
|
|
74
|
+
}
|
|
75
|
+
end() {
|
|
76
|
+
if (this.x1 < this.x0) return;
|
|
77
|
+
const [f, c, e, n] = this.area, s = this.x0 < f - 0.5 || this.y0 < c - 0.5 || this.x1 > e + 0.5 || this.y1 > n + 0.5, { at: r, via: o } = f0(), i = [...new Set(this.s)].filter((a) => !this.has(a)).join("");
|
|
78
|
+
if (i)
|
|
79
|
+
U.push({
|
|
80
|
+
s: this.s,
|
|
81
|
+
w: this.w,
|
|
82
|
+
h: this.h,
|
|
83
|
+
ink: [this.x0, this.y0, this.x1, this.y1].map((a) => Math.round(a)),
|
|
84
|
+
area: this.area,
|
|
85
|
+
at: r,
|
|
86
|
+
via: o,
|
|
87
|
+
missing: i
|
|
88
|
+
});
|
|
89
|
+
else if (s)
|
|
90
|
+
U.push({ s: this.s, w: this.w, h: this.h, ink: [this.x0, this.y0, this.x1, this.y1].map((a) => Math.round(a)), area: this.area, at: r, via: o });
|
|
91
|
+
else {
|
|
92
|
+
const a = _(this.w, this.h, o, this.s);
|
|
93
|
+
A.has(a) || A.set(a, /* @__PURE__ */ new Set()), A.get(a).add(`${Math.round(this.x0)},${Math.round(this.y0)}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function r0(t, f, c, e = e0) {
|
|
98
|
+
if (!(!O || !f.trim()))
|
|
99
|
+
return new n0(t.w, t.h, f, c ?? [0, 0, t.w, t.h], e);
|
|
100
|
+
}
|
|
101
|
+
function s0(t) {
|
|
102
|
+
const f = (n) => (t.shown[_(n.w, n.h, n.via, n.s)] ?? []).some(([s, r]) => Math.abs(s - n.ink[0]) > 2 || Math.abs(r - n.ink[1]) > 2), c = /* @__PURE__ */ new Map(), e = [];
|
|
103
|
+
for (const n of t.overflows) {
|
|
104
|
+
const s = _(n.w, n.h, n.via, n.s);
|
|
105
|
+
if (!n.missing && f(n)) {
|
|
106
|
+
e.push(n);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const r = c.get(s);
|
|
110
|
+
r ? r.ink = [Math.min(r.ink[0], n.ink[0]), Math.min(r.ink[1], n.ink[1]), Math.max(r.ink[2], n.ink[2]), Math.max(r.ink[3], n.ink[3])] : c.set(s, { ...n, ink: [...n.ink] });
|
|
111
|
+
}
|
|
112
|
+
return { cut: [...c.values()], moving: e };
|
|
113
|
+
}
|
|
114
|
+
function I0(t) {
|
|
115
|
+
return t.missing ? `"${t.s}" has ${[...t.missing].map((f) => `U+${f.charCodeAt(0).toString(16).toUpperCase()}`).join(" ")}, a box in the PC font (${t.w}x${t.h}) at ${t.at}` : `"${t.s}" ink ${t.ink.join(",")} outside ${t.area.join(",")} (${t.w}x${t.h}) at ${t.at}`;
|
|
116
|
+
}
|
|
117
|
+
function $0(t) {
|
|
118
|
+
if (!Q(t)) throw new Error(`${t}: the build wrote no text-bounds report`);
|
|
119
|
+
return s0(JSON.parse(Z(t, "utf8")));
|
|
120
|
+
}
|
|
121
|
+
const o0 = "0000000000000000 183c3c1818001800 3636000000000000 36367f367f363600 0c3e031e301f0c00 006333180c666300 1c361c6e3b336e00 0606030000000000 180c0606060c1800 060c1818180c0600 00663cff3c660000 000c0c3f0c0c0000 00000000000c0c06 0000003f00000000 00000000000c0c00 6030180c06030100 3e63737b6f673e00 0c0e0c0c0c0c3f00 1e33301c06333f00 1e33301c30331e00 383c36337f307800 3f031f3030331e00 1c06031f33331e00 3f3330180c0c0c00 1e33331e33331e00 1e33333e30180e00 000c0c00000c0c00 000c0c00000c0c06 180c0603060c1800 00003f00003f0000 060c1830180c0600 1e3330180c000c00 3e637b7b7b031e00 0c1e33333f333300 3f66663e66663f00 3c66030303663c00 1f36666666361f00 7f46161e16467f00 7f46161e16060f00 3c66030373667c00 3333333f33333300 1e0c0c0c0c0c1e00 7830303033331e00 6766361e36666700 0f06060646667f00 63777f7f6b636300 63676f7b73636300 1c36636363361c00 3f66663e06060f00 1e3333333b1e3800 3f66663e36666700 1e33070e38331e00 3f2d0c0c0c0c1e00 3333333333333f00 33333333331e0c00 6363636b7f776300 6363361c1c366300 3333331e0c0c1e00 7f6331184c667f00 1e06060606061e00 03060c1830604000 1e18181818181e00 081c366300000000 00000000000000ff 0c0c180000000000 00001e303e336e00 0706063e66663b00 00001e3303331e00 3830303e33336e00 00001e333f031e00 1c36060f06060f00 00006e33333e301f 0706366e66666700 0c000e0c0c0c1e00 300030303033331e 070666361e366700 0e0c0c0c0c0c1e00 0000337f7f6b6300 00001f3333333300 00001e3333331e00 00003b66663e060f 00006e33333e3078 00003b6e66060f00 00003e031e301f00 080c3e0c0c2c1800 0000333333336e00 00003333331e0c00 0000636b7f7f3600 000063361c366300 00003333333e301f 00003f190c263f00 380c0c070c0c3800 1818180018181800 070c0c380c0c0700 6e3b000000000000", B = (() => {
|
|
122
|
+
const t = new Uint8Array(2048), f = [126, 66, 66, 66, 66, 66, 126, 0];
|
|
123
|
+
for (let c = 0; c < 256; c++) (c >= 128 || c > 0 && c < 32 && c !== 10) && t.set(f, c * 8);
|
|
124
|
+
return o0.split(" ").forEach((c, e) => {
|
|
125
|
+
for (let n = 0; n < 8; n++) t[(32 + e) * 8 + n] = parseInt(c.slice(n * 2, n * 2 + 2), 16);
|
|
126
|
+
}), t;
|
|
127
|
+
})();
|
|
128
|
+
function N(t, f, c, e, n, s = 1) {
|
|
129
|
+
const r = r0(t, e), o = (i, a, h, l) => {
|
|
130
|
+
t.rect(i, a, h, l, n), r?.add(i, a, h, l);
|
|
131
|
+
};
|
|
132
|
+
return [...e].forEach((i, a) => {
|
|
133
|
+
const h = i.charCodeAt(0) & 255;
|
|
134
|
+
for (let l = 0; l < 8; l++) {
|
|
135
|
+
const u = B[h * 8 + l];
|
|
136
|
+
for (let d = 0; d < 8; d++) u & 1 << d && o(f + (a * 8 + d) * s, c + l * s, s, s);
|
|
137
|
+
}
|
|
138
|
+
}), r?.end(), e.length * 8 * s;
|
|
139
|
+
}
|
|
140
|
+
const i0 = (t, f = 1) => t.length * 8 * f;
|
|
141
|
+
function a0(t, f, c, e, n, s, r = 1, o) {
|
|
142
|
+
if (o !== void 0)
|
|
143
|
+
for (const [i, a] of [
|
|
144
|
+
[2, 2],
|
|
145
|
+
[1, 2],
|
|
146
|
+
[2, 1]
|
|
147
|
+
])
|
|
148
|
+
N(t, f + i * r, c + a * r, e, o, r);
|
|
149
|
+
for (const [i, a] of [
|
|
150
|
+
[-1, 0],
|
|
151
|
+
[1, 0],
|
|
152
|
+
[0, -1],
|
|
153
|
+
[0, 1],
|
|
154
|
+
[-1, -1],
|
|
155
|
+
[1, 1],
|
|
156
|
+
[1, -1],
|
|
157
|
+
[-1, 1]
|
|
158
|
+
])
|
|
159
|
+
N(t, f + i, c + a, e, s, r);
|
|
160
|
+
N(t, f, c, e, n, r);
|
|
161
|
+
}
|
|
162
|
+
function S0(t, f, c, e, n = 1, s, r = t.w / 2, o) {
|
|
163
|
+
const i = Math.round(r - i0(c, n) / 2);
|
|
164
|
+
s === void 0 ? N(t, i, f, c, e, n) : a0(t, i, f, c, e, s, n, o);
|
|
165
|
+
}
|
|
166
|
+
const E = 255;
|
|
167
|
+
function C0(t, f, c = 0, e = 0) {
|
|
168
|
+
return t.blit(f, c, e, E);
|
|
169
|
+
}
|
|
170
|
+
function v0(t, f) {
|
|
171
|
+
const c = new g(t.w, t.h);
|
|
172
|
+
return c.px.set(t.px.map(f)), c;
|
|
173
|
+
}
|
|
174
|
+
function A0(t, f, c, e, n, s = !1) {
|
|
175
|
+
for (let r = 0; r < f.h; r++)
|
|
176
|
+
for (let o = 0; o < f.w; o++) {
|
|
177
|
+
const i = f.get(s ? f.w - 1 - o : o, r);
|
|
178
|
+
i !== E && i >= 0 && t.rect(c + o * n, e + r * n, n, n, i);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function N0(t, f) {
|
|
182
|
+
const c = new g(t.w, t.h, E);
|
|
183
|
+
c.px.set(t.px);
|
|
184
|
+
for (let e = 0; e < t.h; e++)
|
|
185
|
+
for (let n = 0; n < t.w; n++) {
|
|
186
|
+
if (t.get(n, e) !== E) continue;
|
|
187
|
+
[t.get(n - 1, e), t.get(n + 1, e), t.get(n, e - 1), t.get(n, e + 1)].some((r) => r !== E && r !== -1) && c.set(n, e, f);
|
|
188
|
+
}
|
|
189
|
+
return c;
|
|
190
|
+
}
|
|
191
|
+
function G(t, f, c, e, n, s) {
|
|
192
|
+
const r = f + Math.max(0, Math.min(1, e)) * (c - f), o = Math.floor(r), i = K(n, s, r - o) ? o + 1 : o;
|
|
193
|
+
return t[Math.max(0, Math.min(t.length - 1, i))];
|
|
194
|
+
}
|
|
195
|
+
function R0(t, f, c, e, n, s, r, o) {
|
|
196
|
+
for (let i = c; i < c + n; i++) for (let a = f; a < f + e; a++) t.set(a, i, G(s, r, o, (i - c) / Math.max(1, n - 1), a, i));
|
|
197
|
+
return t;
|
|
198
|
+
}
|
|
199
|
+
function P0(t, f, c, e, n, s, r, o, i = 1) {
|
|
200
|
+
for (let a = Math.floor(c - n); a <= c + n; a++)
|
|
201
|
+
for (let h = Math.floor(f - e); h <= f + e; h++) {
|
|
202
|
+
const l = (h + 0.5 - f) / e, u = (a + 0.5 - c) / n, d = l * l + u * u;
|
|
203
|
+
if (d > 1) continue;
|
|
204
|
+
const m = (0.62 * Math.sqrt(1 - d) - 0.42 * l - 0.52 * u) * i;
|
|
205
|
+
t.set(h, a, G(s, r, o, (m + 0.35) / 1.2, h, a));
|
|
206
|
+
}
|
|
207
|
+
return t;
|
|
208
|
+
}
|
|
209
|
+
function O0(t, f, c, e, n, s, r, o = 1) {
|
|
210
|
+
t.rect(f, c, e, n, s[r]);
|
|
211
|
+
const i = s[Math.min(s.length - 1, r + 1)], a = s[Math.max(0, r - 2)];
|
|
212
|
+
for (let h = 0; h < o; h++)
|
|
213
|
+
t.rect(f + h, c + h, e - 2 * h, 1, i).rect(f + h, c + h, 1, n - 2 * h, i), t.rect(f + h, c + n - 1 - h, e - 2 * h, 1, a).rect(f + e - 1 - h, c + h, 1, n - 2 * h, a);
|
|
214
|
+
return t;
|
|
215
|
+
}
|
|
216
|
+
function U0(t, f, c, e, n, s, r, o, i, a = 0.25) {
|
|
217
|
+
const h = V(i);
|
|
218
|
+
for (let l = c; l < c + n; l++)
|
|
219
|
+
for (let u = f; u < f + e; u++) {
|
|
220
|
+
let d = r;
|
|
221
|
+
h() < a && (d += h() < 0.5 ? -o : o), t.set(u, l, s[Math.max(0, Math.min(s.length - 1, d))]);
|
|
222
|
+
}
|
|
223
|
+
return t;
|
|
224
|
+
}
|
|
225
|
+
function T(t, f) {
|
|
226
|
+
return t.map((c) => Math.round(c * Math.max(0, Math.min(1, f))));
|
|
227
|
+
}
|
|
228
|
+
class _0 {
|
|
229
|
+
constructor(f, c = 320, e = 200) {
|
|
230
|
+
this.pal = f, this.w = c, this.h = e, this.frames = [], this.palettes = [], this.frames.push(new Uint8Array(c * e)), this.palettes.push(new Uint8Array(768));
|
|
231
|
+
}
|
|
232
|
+
/** Adds a picture for `hold` frames, its palette faded to `light`. */
|
|
233
|
+
add(f, c = 1, e = 1, n = this.pal) {
|
|
234
|
+
const s = Uint8Array.from(f.px), r = e >= 1 ? n : T(n, e);
|
|
235
|
+
for (let o = 0; o < c; o++)
|
|
236
|
+
this.frames.push(s), this.palettes.push(r);
|
|
237
|
+
return this.last = { px: s, pal: n }, this;
|
|
238
|
+
}
|
|
239
|
+
/** A picture drawn over a copy of `bg` (the actors over the scenery), for `hold` frames. */
|
|
240
|
+
frame(f, c, e = 1, n = 1, s = this.pal) {
|
|
241
|
+
const r = new g(f.w, f.h);
|
|
242
|
+
return r.px.set(f.px), c(r), this.add(r, e, n, s);
|
|
243
|
+
}
|
|
244
|
+
/** The picture fading in from black over `n` frames (the last at full light). */
|
|
245
|
+
fadeIn(f, c, e = this.pal) {
|
|
246
|
+
for (let n = 1; n <= c; n++) this.add(f, 1, n / c, e);
|
|
247
|
+
return this;
|
|
248
|
+
}
|
|
249
|
+
/** The last picture fading out to black over `n` frames. */
|
|
250
|
+
fadeOut(f) {
|
|
251
|
+
const c = this.last;
|
|
252
|
+
if (!c) return this;
|
|
253
|
+
for (let e = f - 1; e >= 0; e--)
|
|
254
|
+
this.frames.push(c.px), this.palettes.push(T(c.pal, e / f));
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* A cartoon's closing iris: black closes in on (cx, cy) over `n` frames from the last picture
|
|
259
|
+
* down to a circle `end` pixels across (round on a 4:3 screen: VGA's pixels are taller than
|
|
260
|
+
* wide), and holds there `hold` frames. Follow it with fadeOut. Gives an intro whose pictures
|
|
261
|
+
* are the title's art a last view that isn't the title.
|
|
262
|
+
*/
|
|
263
|
+
irisOut(f, c, e, n = 64, s = 6) {
|
|
264
|
+
const r = this.last;
|
|
265
|
+
if (!r) return this;
|
|
266
|
+
let o = 0;
|
|
267
|
+
const i = (l) => r.pal[l * 3] + r.pal[l * 3 + 1] + r.pal[l * 3 + 2];
|
|
268
|
+
for (let l = 1; l < r.pal.length / 3; l++) i(l) < i(o) && (o = l);
|
|
269
|
+
const a = Math.hypot(Math.max(f, this.w - f), Math.max(c, this.h - c) * 1.2), h = new g(this.w, this.h);
|
|
270
|
+
for (let l = 1; l <= e; l++) {
|
|
271
|
+
const u = l / e, d = a + (n / 2 - a) * (1 - (1 - u) * (1 - u));
|
|
272
|
+
for (let p = 0; p < this.h; p++)
|
|
273
|
+
for (let m = 0; m < this.w; m++) {
|
|
274
|
+
const b = p * this.w + m;
|
|
275
|
+
h.px[b] = Math.hypot(m - f, (p - c) * 1.2) <= d ? r.px[b] : o;
|
|
276
|
+
}
|
|
277
|
+
this.add(h, l === e ? s : 1, 1, r.pal);
|
|
278
|
+
}
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
/** The .FLI: `speed` is the wait after each frame in 1/70 s (5 = 14 frames a second). */
|
|
282
|
+
fli(f) {
|
|
283
|
+
return t0(this.frames, this.pal, { width: this.w, height: this.h, speed: f, palettes: this.palettes, runs: !0 });
|
|
284
|
+
}
|
|
285
|
+
/** How long it plays, in seconds. */
|
|
286
|
+
seconds(f) {
|
|
287
|
+
return this.frames.length * f / 70;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const h0 = {
|
|
291
|
+
1: "3c42a581a599423c",
|
|
292
|
+
// ☺
|
|
293
|
+
2: "3c7edbffdbe77e3c",
|
|
294
|
+
// ☻
|
|
295
|
+
3: "6cfefefe7c381000",
|
|
296
|
+
// ♥
|
|
297
|
+
4: "10387cfe7c381000",
|
|
298
|
+
// ♦
|
|
299
|
+
5: "387c38fefed61038",
|
|
300
|
+
// ♣
|
|
301
|
+
6: "10387cfefe543800",
|
|
302
|
+
// ♠
|
|
303
|
+
7: "0000183c3c180000",
|
|
304
|
+
// •
|
|
305
|
+
8: "ffffe7c3c3e7ffff",
|
|
306
|
+
// ◘
|
|
307
|
+
9: "003c424242423c00",
|
|
308
|
+
// ○
|
|
309
|
+
10: "ffc3bdbdbdbdc3ff",
|
|
310
|
+
// ◙
|
|
311
|
+
11: "0f03057988888870",
|
|
312
|
+
// ♂
|
|
313
|
+
12: "3844444438107c10",
|
|
314
|
+
// ♀
|
|
315
|
+
13: "181c16121070f060",
|
|
316
|
+
// ♪
|
|
317
|
+
14: "3f21212163e7c600",
|
|
318
|
+
// ♫
|
|
319
|
+
15: "925438ee38549200",
|
|
320
|
+
// ☼
|
|
321
|
+
16: "80e0f8fef8e08000",
|
|
322
|
+
// ►
|
|
323
|
+
17: "020e3efe3e0e0200",
|
|
324
|
+
// ◄
|
|
325
|
+
18: "183c7e18187e3c18",
|
|
326
|
+
// ↕
|
|
327
|
+
19: "6c6c6c6c6c006c00",
|
|
328
|
+
// ‼
|
|
329
|
+
20: "7fdbdb7b1b1b1b00",
|
|
330
|
+
// ¶ (ext_latin)
|
|
331
|
+
21: "3e63386c6c38cc78",
|
|
332
|
+
// § (ext_latin)
|
|
333
|
+
22: "00000000fefefe00",
|
|
334
|
+
// ▬
|
|
335
|
+
23: "183c7e187e3c18ff",
|
|
336
|
+
// ↨
|
|
337
|
+
24: "183c7e1818181800",
|
|
338
|
+
// ↑
|
|
339
|
+
25: "181818187e3c1800",
|
|
340
|
+
// ↓
|
|
341
|
+
26: "00180cfe0c180000",
|
|
342
|
+
// →
|
|
343
|
+
27: "003060fe60300000",
|
|
344
|
+
// ←
|
|
345
|
+
28: "0000c0c0c0fefe00",
|
|
346
|
+
// ∟
|
|
347
|
+
29: "002466ff66240000",
|
|
348
|
+
// ↔
|
|
349
|
+
30: "0018183c7eff0000",
|
|
350
|
+
// ▲
|
|
351
|
+
31: "00ff7e3c18180000",
|
|
352
|
+
// ▼
|
|
353
|
+
127: "102844828282fe00",
|
|
354
|
+
// ⌂
|
|
355
|
+
128: "78ccc0cc78180c78",
|
|
356
|
+
// Ç (ext_latin)
|
|
357
|
+
129: "00cc00cccccc7e00",
|
|
358
|
+
// ü (ext_latin)
|
|
359
|
+
130: "1c0078ccfcc07800",
|
|
360
|
+
// é (ext_latin)
|
|
361
|
+
131: "7ec33c063e663f00",
|
|
362
|
+
// â (ext_latin)
|
|
363
|
+
132: "cc00780c7ccc7e00",
|
|
364
|
+
// ä (ext_latin)
|
|
365
|
+
133: "e000780c7ccc7e00",
|
|
366
|
+
// à (ext_latin)
|
|
367
|
+
134: "3030780c7ccc7e00",
|
|
368
|
+
// å (ext_latin)
|
|
369
|
+
135: "000078c0c0780c38",
|
|
370
|
+
// ç (ext_latin)
|
|
371
|
+
136: "7ec33c667e603c00",
|
|
372
|
+
// ê (ext_latin)
|
|
373
|
+
137: "cc0078ccfcc07800",
|
|
374
|
+
// ë (ext_latin)
|
|
375
|
+
138: "e00078ccfcc07800",
|
|
376
|
+
// è (ext_latin)
|
|
377
|
+
139: "cc00703030307800",
|
|
378
|
+
// ï (ext_latin)
|
|
379
|
+
140: "7cc6381818183c00",
|
|
380
|
+
// î (ext_latin)
|
|
381
|
+
141: "e000703030307800",
|
|
382
|
+
// ì (ext_latin)
|
|
383
|
+
142: "c6386cc6fec6c600",
|
|
384
|
+
// Ä (ext_latin)
|
|
385
|
+
143: "30300078ccfccc00",
|
|
386
|
+
// Å (ext_latin)
|
|
387
|
+
144: "1c00fc607860fc00",
|
|
388
|
+
// É (ext_latin)
|
|
389
|
+
145: "00007f0c7fcc7f00",
|
|
390
|
+
// æ (ext_latin)
|
|
391
|
+
146: "3e6cccfeccccce00",
|
|
392
|
+
// Æ (ext_latin)
|
|
393
|
+
147: "78cc0078cccc7800",
|
|
394
|
+
// ô (ext_latin)
|
|
395
|
+
148: "00cc0078cccc7800",
|
|
396
|
+
// ö (ext_latin)
|
|
397
|
+
149: "00e00078cccc7800",
|
|
398
|
+
// ò (ext_latin)
|
|
399
|
+
150: "78cc00cccccc7e00",
|
|
400
|
+
// û (ext_latin)
|
|
401
|
+
151: "00e000cccccc7e00",
|
|
402
|
+
// ù (ext_latin)
|
|
403
|
+
152: "00cc00cccc7c0cf8",
|
|
404
|
+
// ÿ (ext_latin)
|
|
405
|
+
153: "c3183c66663c1800",
|
|
406
|
+
// Ö (ext_latin)
|
|
407
|
+
154: "cc00cccccccc7800",
|
|
408
|
+
// Ü (ext_latin)
|
|
409
|
+
155: "18187ec0c07e1818",
|
|
410
|
+
// ¢ (ext_latin)
|
|
411
|
+
156: "386c64f060e6fc00",
|
|
412
|
+
// £ (ext_latin)
|
|
413
|
+
157: "cccc78fc30fc3030",
|
|
414
|
+
// ¥ (ext_latin)
|
|
415
|
+
158: "f8ccccfac6cfc6c7",
|
|
416
|
+
// ₧ (misc)
|
|
417
|
+
159: "0e1b183c1818d870",
|
|
418
|
+
// ƒ (misc)
|
|
419
|
+
160: "1c00780c7ccc7e00",
|
|
420
|
+
// á (ext_latin)
|
|
421
|
+
161: "3800703030307800",
|
|
422
|
+
// í (ext_latin)
|
|
423
|
+
162: "001c0078cccc7800",
|
|
424
|
+
// ó (ext_latin)
|
|
425
|
+
163: "001c00cccccc7e00",
|
|
426
|
+
// ú (ext_latin)
|
|
427
|
+
164: "00f800f8cccccc00",
|
|
428
|
+
// ñ (ext_latin)
|
|
429
|
+
165: "fc00ccecfcdccc00",
|
|
430
|
+
// Ñ (ext_latin)
|
|
431
|
+
166: "3c6c6c3e007e0000",
|
|
432
|
+
// ª (misc)
|
|
433
|
+
167: "386c6c38007c0000",
|
|
434
|
+
// º (misc)
|
|
435
|
+
168: "30003060c0cc7800",
|
|
436
|
+
// ¿ (ext_latin)
|
|
437
|
+
169: "000000fcc0c00000",
|
|
438
|
+
// ⌐ (misc)
|
|
439
|
+
170: "000000fc0c0c0000",
|
|
440
|
+
// ¬ (ext_latin)
|
|
441
|
+
171: "c3c6ccde3366cc0f",
|
|
442
|
+
// ½ (ext_latin)
|
|
443
|
+
172: "c3c6ccbd376fcfc0",
|
|
444
|
+
// ¼ (ext_latin)
|
|
445
|
+
173: "1818001818181800",
|
|
446
|
+
// ¡ (ext_latin)
|
|
447
|
+
174: "003366cc66330000",
|
|
448
|
+
// « (ext_latin)
|
|
449
|
+
175: "00cc663366cc0000",
|
|
450
|
+
// » (ext_latin)
|
|
451
|
+
176: "2288228822882288",
|
|
452
|
+
// ░
|
|
453
|
+
177: "55aa55aa55aa55aa",
|
|
454
|
+
// ▒
|
|
455
|
+
178: "dd77dd77dd77dd77",
|
|
456
|
+
// ▓
|
|
457
|
+
179: "1818181818181818",
|
|
458
|
+
// │
|
|
459
|
+
180: "181818f818181818",
|
|
460
|
+
// ┤
|
|
461
|
+
181: "1818f818f8181818",
|
|
462
|
+
// ╡
|
|
463
|
+
182: "363636f636363636",
|
|
464
|
+
// ╢
|
|
465
|
+
183: "000000fe36363636",
|
|
466
|
+
// ╖
|
|
467
|
+
184: "0000f818f8181818",
|
|
468
|
+
// ╕
|
|
469
|
+
185: "3636f606f6363636",
|
|
470
|
+
// ╣
|
|
471
|
+
186: "3636363636363636",
|
|
472
|
+
// ║
|
|
473
|
+
187: "0000fe06f6363636",
|
|
474
|
+
// ╗
|
|
475
|
+
188: "3636f606fe000000",
|
|
476
|
+
// ╝
|
|
477
|
+
189: "363636fe00000000",
|
|
478
|
+
// ╜
|
|
479
|
+
190: "1818f818f8000000",
|
|
480
|
+
// ╛
|
|
481
|
+
191: "000000f818181818",
|
|
482
|
+
// ┐
|
|
483
|
+
192: "1818181f00000000",
|
|
484
|
+
// └
|
|
485
|
+
193: "181818ff00000000",
|
|
486
|
+
// ┴
|
|
487
|
+
194: "000000ff18181818",
|
|
488
|
+
// ┬
|
|
489
|
+
195: "1818181f18181818",
|
|
490
|
+
// ├
|
|
491
|
+
196: "000000ff00000000",
|
|
492
|
+
// ─
|
|
493
|
+
197: "181818ff18181818",
|
|
494
|
+
// ┼
|
|
495
|
+
198: "18181f181f181818",
|
|
496
|
+
// ╞
|
|
497
|
+
199: "3636363736363636",
|
|
498
|
+
// ╟
|
|
499
|
+
200: "363637303f000000",
|
|
500
|
+
// ╚
|
|
501
|
+
201: "00003f3037363636",
|
|
502
|
+
// ╔
|
|
503
|
+
202: "3636f700ff000000",
|
|
504
|
+
// ╩
|
|
505
|
+
203: "0000ff00f7363636",
|
|
506
|
+
// ╦
|
|
507
|
+
204: "3636373037363636",
|
|
508
|
+
// ╠
|
|
509
|
+
205: "0000ff00ff000000",
|
|
510
|
+
// ═
|
|
511
|
+
206: "3636f700f7363636",
|
|
512
|
+
// ╬
|
|
513
|
+
207: "1818ff00ff000000",
|
|
514
|
+
// ╧
|
|
515
|
+
208: "363636ff00000000",
|
|
516
|
+
// ╨
|
|
517
|
+
209: "0000ff00ff181818",
|
|
518
|
+
// ╤
|
|
519
|
+
210: "000000ff36363636",
|
|
520
|
+
// ╥
|
|
521
|
+
211: "3636363f00000000",
|
|
522
|
+
// ╙
|
|
523
|
+
212: "18181f181f000000",
|
|
524
|
+
// ╘
|
|
525
|
+
213: "00001f181f181818",
|
|
526
|
+
// ╒
|
|
527
|
+
214: "0000003f36363636",
|
|
528
|
+
// ╓
|
|
529
|
+
215: "363636ff36363636",
|
|
530
|
+
// ╫
|
|
531
|
+
216: "1818ff18ff181818",
|
|
532
|
+
// ╪
|
|
533
|
+
217: "181818f800000000",
|
|
534
|
+
// ┘
|
|
535
|
+
218: "0000001f18181818",
|
|
536
|
+
// ┌
|
|
537
|
+
219: "ffffffffffffffff",
|
|
538
|
+
// █
|
|
539
|
+
220: "00000000ffffffff",
|
|
540
|
+
// ▄
|
|
541
|
+
221: "f0f0f0f0f0f0f0f0",
|
|
542
|
+
// ▌
|
|
543
|
+
222: "0f0f0f0f0f0f0f0f",
|
|
544
|
+
// ▐
|
|
545
|
+
223: "ffffffff00000000",
|
|
546
|
+
// ▀
|
|
547
|
+
224: "000076dcc8dc7600",
|
|
548
|
+
// α (greek)
|
|
549
|
+
225: "0078ccf8ccf8c0c0",
|
|
550
|
+
// ß (ext_latin)
|
|
551
|
+
226: "fcccc0c0c0c0c000",
|
|
552
|
+
// Γ (greek)
|
|
553
|
+
227: "0000fe6c6c6c6c00",
|
|
554
|
+
// π (greek)
|
|
555
|
+
228: "fec6603060c6fe00",
|
|
556
|
+
// Σ (greek)
|
|
557
|
+
229: "00007ed8d8d87000",
|
|
558
|
+
// σ (greek)
|
|
559
|
+
230: "00006666667c60c0",
|
|
560
|
+
// µ (ext_latin)
|
|
561
|
+
231: "00007e18181a0c00",
|
|
562
|
+
// τ (greek)
|
|
563
|
+
232: "187edbdbdb7e1800",
|
|
564
|
+
// Φ (greek)
|
|
565
|
+
233: "386cc6fec66c3800",
|
|
566
|
+
// Θ (greek)
|
|
567
|
+
234: "7cc6c6c66c6cee00",
|
|
568
|
+
// Ω (greek)
|
|
569
|
+
235: "1c30187ccccc7800",
|
|
570
|
+
// δ (greek)
|
|
571
|
+
236: "00006c92926c0000",
|
|
572
|
+
// ∞
|
|
573
|
+
237: "00006edbdb7e1800",
|
|
574
|
+
// φ (greek)
|
|
575
|
+
238: "000078c070c07800",
|
|
576
|
+
// ε (greek)
|
|
577
|
+
239: "003c666666666600",
|
|
578
|
+
// ∩
|
|
579
|
+
240: "007e007e007e0000",
|
|
580
|
+
// ≡
|
|
581
|
+
241: "18187e1818007e00",
|
|
582
|
+
// ± (ext_latin)
|
|
583
|
+
242: "30180c1830007e00",
|
|
584
|
+
// ≥ (misc)
|
|
585
|
+
243: "0c1830180c007e00",
|
|
586
|
+
// ≤ (misc)
|
|
587
|
+
244: "0e1b1b1818181818",
|
|
588
|
+
// ⌠
|
|
589
|
+
245: "18181818d8d87000",
|
|
590
|
+
// ⌡
|
|
591
|
+
246: "1818007e00181800",
|
|
592
|
+
// ÷ (ext_latin)
|
|
593
|
+
247: "0076dc0076dc0000",
|
|
594
|
+
// ≈
|
|
595
|
+
248: "386c6c3800000000",
|
|
596
|
+
// ° (ext_latin)
|
|
597
|
+
249: "0000001818000000",
|
|
598
|
+
// ∙
|
|
599
|
+
250: "0000000018000000",
|
|
600
|
+
// ·
|
|
601
|
+
251: "0f08080888482818",
|
|
602
|
+
// √
|
|
603
|
+
252: "f8cccccc00000000",
|
|
604
|
+
// ⁿ
|
|
605
|
+
253: "380c18303c000000",
|
|
606
|
+
// ² (ext_latin)
|
|
607
|
+
254: "00003c3c3c3c0000",
|
|
608
|
+
// ■
|
|
609
|
+
255: "0000000000000000"
|
|
610
|
+
// NBSP (ext_latin)
|
|
611
|
+
};
|
|
612
|
+
function l0(t) {
|
|
613
|
+
let f = 0;
|
|
614
|
+
for (let c = 0; c < 8; c++) t & 1 << c && (f |= 1 << 7 - c);
|
|
615
|
+
return f;
|
|
616
|
+
}
|
|
617
|
+
const u0 = (() => {
|
|
618
|
+
const t = B.slice();
|
|
619
|
+
for (const [f, c] of Object.entries(h0))
|
|
620
|
+
for (let e = 0; e < 8; e++) t[Number(f) * 8 + e] = l0(parseInt(c.slice(e * 2, e * 2 + 2), 16));
|
|
621
|
+
return t.fill(0, 0, 8), t;
|
|
622
|
+
})(), H = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ", j = /* @__PURE__ */ new Map();
|
|
623
|
+
for (let t = 1; t < 256; t++) (t < 32 || t > 126) && j.set(H[t], t);
|
|
624
|
+
for (const [t, f] of [
|
|
625
|
+
["β", 225],
|
|
626
|
+
// β beta for ß
|
|
627
|
+
["μ", 230],
|
|
628
|
+
// μ mu for µ
|
|
629
|
+
["Ω", 234],
|
|
630
|
+
// Ω ohm for Ω
|
|
631
|
+
["∑", 228],
|
|
632
|
+
// ∑ sum for Σ
|
|
633
|
+
["ϕ", 237],
|
|
634
|
+
// ϕ for φ
|
|
635
|
+
["∈", 238]
|
|
636
|
+
// ∈ for ε
|
|
637
|
+
])
|
|
638
|
+
j.set(t, f);
|
|
639
|
+
const d0 = { "–": "-", "—": "--", "‘": "'", "’": "'", "“": '"', "”": '"', "…": "...", "×": "x" };
|
|
640
|
+
function F(t) {
|
|
641
|
+
let f = "";
|
|
642
|
+
for (const c of t) {
|
|
643
|
+
const e = j.get(c);
|
|
644
|
+
f += e !== void 0 ? String.fromCharCode(e) : d0[c] ?? c;
|
|
645
|
+
}
|
|
646
|
+
return f;
|
|
647
|
+
}
|
|
648
|
+
function L(t) {
|
|
649
|
+
let f = "";
|
|
650
|
+
for (let c = 0; c < t.length; c++) {
|
|
651
|
+
const e = t.charCodeAt(c);
|
|
652
|
+
f += e < 256 ? H[e] : t[c];
|
|
653
|
+
}
|
|
654
|
+
return f;
|
|
655
|
+
}
|
|
656
|
+
const Y = Object.freeze({
|
|
657
|
+
A: "010101111101101",
|
|
658
|
+
B: "110101110101110",
|
|
659
|
+
C: "011100100100011",
|
|
660
|
+
D: "110101101101110",
|
|
661
|
+
E: "111100110100111",
|
|
662
|
+
F: "111100110100100",
|
|
663
|
+
G: "011100101101011",
|
|
664
|
+
H: "101101111101101",
|
|
665
|
+
I: "111010010010111",
|
|
666
|
+
J: "001001001101010",
|
|
667
|
+
K: "101101110101101",
|
|
668
|
+
L: "100100100100111",
|
|
669
|
+
M: "101111111101101",
|
|
670
|
+
N: "110101101101101",
|
|
671
|
+
O: "010101101101010",
|
|
672
|
+
P: "110101110100100",
|
|
673
|
+
Q: "010101101110011",
|
|
674
|
+
R: "110101110101101",
|
|
675
|
+
S: "011100010001110",
|
|
676
|
+
T: "111010010010010",
|
|
677
|
+
U: "101101101101111",
|
|
678
|
+
V: "101101101101010",
|
|
679
|
+
W: "101101111111101",
|
|
680
|
+
X: "101101010101101",
|
|
681
|
+
Y: "101101010010010",
|
|
682
|
+
Z: "111001010100111",
|
|
683
|
+
0: "111101101101111",
|
|
684
|
+
1: "010110010010111",
|
|
685
|
+
2: "110001010100111",
|
|
686
|
+
3: "110001010001110",
|
|
687
|
+
4: "101101111001001",
|
|
688
|
+
5: "111100110001110",
|
|
689
|
+
6: "011100111101111",
|
|
690
|
+
7: "111001010010010",
|
|
691
|
+
8: "111101111101111",
|
|
692
|
+
9: "111101111001110",
|
|
693
|
+
$: "011110010011110",
|
|
694
|
+
"&": "010101010101011",
|
|
695
|
+
"-": "000000111000000",
|
|
696
|
+
"!": "010010010000010",
|
|
697
|
+
".": "000000000000010",
|
|
698
|
+
"'": "010010000000000",
|
|
699
|
+
" ": "000000000000000",
|
|
700
|
+
":": "000010000010000",
|
|
701
|
+
"/": "001001010100100",
|
|
702
|
+
",": "000000000010100",
|
|
703
|
+
"?": "110001010000010",
|
|
704
|
+
"+": "000010111010000",
|
|
705
|
+
">": "100010001010100",
|
|
706
|
+
"<": "001010100010001",
|
|
707
|
+
"(": "010100100100010",
|
|
708
|
+
")": "010001001001010"
|
|
709
|
+
});
|
|
710
|
+
function p0(t) {
|
|
711
|
+
for (const e of t)
|
|
712
|
+
if (e.charCodeAt(0) >= 128 && F(e) === e && L(e) !== e) throw new RangeError(`No CP437 glyph for ${e}`);
|
|
713
|
+
const f = F(t), c = new Uint8Array(f.length);
|
|
714
|
+
for (let e = 0; e < f.length; e++) {
|
|
715
|
+
const n = f.charCodeAt(e);
|
|
716
|
+
if (n > 255) throw new RangeError(`No CP437 glyph for ${f[e]}`);
|
|
717
|
+
c[e] = n;
|
|
718
|
+
}
|
|
719
|
+
return c;
|
|
720
|
+
}
|
|
721
|
+
function m0(t, f = "cp437") {
|
|
722
|
+
if (!Number.isInteger(t) || t < 0 || t > 255) throw new RangeError("Glyph code must be 0..255");
|
|
723
|
+
if (f === "cp437") return u0.slice(t * 8, t * 8 + 8);
|
|
724
|
+
const c = Y[L(String.fromCharCode(t)).toUpperCase()] ?? Y["?"];
|
|
725
|
+
return Uint8Array.from({ length: 5 }, (e, n) => {
|
|
726
|
+
let s = 0;
|
|
727
|
+
for (let r = 0; r < 3; r++) c[n * 3 + r] === "1" && (s |= 1 << r);
|
|
728
|
+
return s;
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
function w0(t, f, c = 1, e = 2) {
|
|
732
|
+
if (R(f), !Number.isInteger(c) || !Number.isInteger(e)) throw new RangeError("Shadow offsets must be integers");
|
|
733
|
+
const n = new g(t.w, t.h, 255);
|
|
734
|
+
for (let s = 0; s < t.h; s++) for (let r = 0; r < t.w; r++) t.get(r, s) !== 255 && n.set(r + c, s + e, f);
|
|
735
|
+
return n.blit(t, 0, 0, 255);
|
|
736
|
+
}
|
|
737
|
+
function R(t) {
|
|
738
|
+
if (!Number.isInteger(t) || t < 0 || t > 254) throw new RangeError("Ink must be a palette index 0..254");
|
|
739
|
+
}
|
|
740
|
+
function j0(t, f = {}) {
|
|
741
|
+
const { font: c = "cp437", color: e = 0, scale: n = 1, outline: s, shadow: r } = f;
|
|
742
|
+
if (R(e), s !== void 0 && R(s), r && R(r.color), !Number.isSafeInteger(n) || n < 1) throw new RangeError("Scale must be a positive integer");
|
|
743
|
+
const o = r?.dx ?? 1, i = r?.dy ?? 2;
|
|
744
|
+
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(i)) throw new RangeError("Shadow offsets must be integers");
|
|
745
|
+
const a = typeof t == "string" ? t.replaceAll(`\r
|
|
746
|
+
`, `
|
|
747
|
+
`).split(`
|
|
748
|
+
`).map(p0) : [t], h = Math.max(...a.map((w) => w.length));
|
|
749
|
+
if (!h) return { width: 0, height: 0, pixels: new Uint8Array(), originX: 0, originY: 0 };
|
|
750
|
+
const l = c === "cp437" ? 8 : 3, u = c === "cp437" ? 8 : 5, d = c === "cp437" ? 8 : 4, p = s === void 0 ? 0 : 1, m = Math.min(-p, r ? o : 0), b = Math.min(-p, r ? i : 0), X = Math.max(p, r ? o : 0), z = Math.max(p, r ? i : 0), I = ((h - 1) * d + l) * n + X - m, $ = ((a.length - 1) * (u + 1) + u) * n + z - b, S = new g(I, $, 255);
|
|
751
|
+
a.forEach(
|
|
752
|
+
(w, x) => w.forEach((y, k) => {
|
|
753
|
+
m0(y, c).forEach((J, W) => {
|
|
754
|
+
for (let v = 0; v < l; v++)
|
|
755
|
+
J & 1 << v && S.rect((k * d + v) * n - m, (x * (u + 1) + W) * n - b, n, n, e);
|
|
756
|
+
});
|
|
757
|
+
})
|
|
758
|
+
);
|
|
759
|
+
const C = new g(I, $, 255);
|
|
760
|
+
if (r && C.blit(w0(S, r.color, o, i), 0, 0, 255), s !== void 0) {
|
|
761
|
+
for (let w = 0; w < $; w++)
|
|
762
|
+
for (let x = 0; x < I; x++)
|
|
763
|
+
if (S.get(x, w) !== 255) for (let y = -1; y <= 1; y++) for (let k = -1; k <= 1; k++) C.set(x + k, w + y, s);
|
|
764
|
+
}
|
|
765
|
+
return C.blit(S, 0, 0, 255), { width: I, height: $, pixels: C.px, originX: -m, originY: -b };
|
|
766
|
+
}
|
|
767
|
+
const g0 = {
|
|
768
|
+
morning: { mul: [1, 0.94, 0.94], add: [14, 4, 10] },
|
|
769
|
+
noon: { mul: [1, 1, 1], add: [0, 0, 0] },
|
|
770
|
+
afternoon: { mul: [1.02, 0.96, 0.86], add: [8, 4, 0] },
|
|
771
|
+
sunset: { mul: [0.9, 0.7, 0.74], add: [30, 10, 16] },
|
|
772
|
+
night: { mul: [0.46, 0.5, 0.78], add: [8, 8, 30] },
|
|
773
|
+
// Under the big top at night: warm show lights on everything.
|
|
774
|
+
show: { mul: [1, 0.9, 0.86], add: [12, 4, 6] }
|
|
775
|
+
}, T0 = {
|
|
776
|
+
morning: [
|
|
777
|
+
[120, 150, 230],
|
|
778
|
+
[255, 214, 200],
|
|
779
|
+
[200, 190, 240]
|
|
780
|
+
],
|
|
781
|
+
noon: [
|
|
782
|
+
[70, 130, 230],
|
|
783
|
+
[200, 232, 255]
|
|
784
|
+
],
|
|
785
|
+
afternoon: [
|
|
786
|
+
[90, 140, 220],
|
|
787
|
+
[250, 236, 200],
|
|
788
|
+
[170, 200, 240]
|
|
789
|
+
],
|
|
790
|
+
sunset: [
|
|
791
|
+
[60, 40, 120],
|
|
792
|
+
[255, 170, 90],
|
|
793
|
+
[210, 90, 120]
|
|
794
|
+
],
|
|
795
|
+
night: [
|
|
796
|
+
[8, 8, 30],
|
|
797
|
+
[40, 40, 96]
|
|
798
|
+
],
|
|
799
|
+
show: [
|
|
800
|
+
[6, 6, 28],
|
|
801
|
+
[60, 40, 110]
|
|
802
|
+
]
|
|
803
|
+
}, D = (t) => Math.max(0, Math.min(255, Math.round(t)));
|
|
804
|
+
function M(t) {
|
|
805
|
+
if (t.length !== 3 || t.some((f) => !Number.isFinite(f))) throw new RangeError("RGB must contain three finite components");
|
|
806
|
+
}
|
|
807
|
+
function b0(t, f) {
|
|
808
|
+
M(t);
|
|
809
|
+
const c = typeof f == "string" ? g0[f] : f;
|
|
810
|
+
return M(c.mul), M(c.add), t.map((e, n) => D(e * c.mul[n] + c.add[n]));
|
|
811
|
+
}
|
|
812
|
+
function F0(t, f, c, e) {
|
|
813
|
+
if (!Number.isSafeInteger(t) || t < 1 || t > 256) throw new RangeError("Ramp size must be 1..256");
|
|
814
|
+
return M(f), M(c), e && M(e), Array.from({ length: t }, (n, s) => {
|
|
815
|
+
const r = t === 1 ? 0 : s / (t - 1), [o, i, a] = e ? r < 0.5 ? [f, e, r * 2] : [e, c, (r - 0.5) * 2] : [f, c, r];
|
|
816
|
+
return o.map((h, l) => D(h + (i[l] - h) * a));
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
function Y0(t, f, c = [0, 255]) {
|
|
820
|
+
if (t.length !== 768 || t.some((s) => s > 63)) throw new RangeError("Expected a 768-byte six-bit VGA palette");
|
|
821
|
+
if (c.some((s) => !Number.isInteger(s) || s < 0 || s > 255)) throw new RangeError("Preserved palette indexes must be 0..255");
|
|
822
|
+
const e = new Set(c), n = t.slice();
|
|
823
|
+
for (let s = 0; s < 256; s++) {
|
|
824
|
+
if (e.has(s)) continue;
|
|
825
|
+
const r = [P(t[s * 3]), P(t[s * 3 + 1]), P(t[s * 3 + 2])];
|
|
826
|
+
n.set(
|
|
827
|
+
b0(r, f).map((o) => o >> 2),
|
|
828
|
+
s * 3
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
return n;
|
|
832
|
+
}
|
|
833
|
+
export {
|
|
834
|
+
E as CLEAR,
|
|
835
|
+
B as FONT8X8,
|
|
836
|
+
u0 as FONT_CP437,
|
|
837
|
+
Y as MICRO_GLYPHS,
|
|
838
|
+
E0 as PaletteBuilder,
|
|
839
|
+
g as Pixels,
|
|
840
|
+
_0 as Reel,
|
|
841
|
+
g0 as TIME_OF_DAY_LIGHT,
|
|
842
|
+
T0 as TIME_OF_DAY_SKY,
|
|
843
|
+
Y0 as adjustPalette,
|
|
844
|
+
O0 as bevel,
|
|
845
|
+
P0 as blob,
|
|
846
|
+
S0 as centered,
|
|
847
|
+
F0 as colorRamp,
|
|
848
|
+
I0 as describe,
|
|
849
|
+
T as dimmed,
|
|
850
|
+
K as dither,
|
|
851
|
+
w0 as dropShadow,
|
|
852
|
+
p0 as encodeText,
|
|
853
|
+
L as fromCp437,
|
|
854
|
+
m0 as glyphRows,
|
|
855
|
+
R0 as gradient,
|
|
856
|
+
b0 as lightColor,
|
|
857
|
+
N0 as outline,
|
|
858
|
+
a0 as outlined,
|
|
859
|
+
C0 as over,
|
|
860
|
+
$0 as readBounds,
|
|
861
|
+
v0 as recolor,
|
|
862
|
+
j0 as renderText,
|
|
863
|
+
V as rng,
|
|
864
|
+
A0 as scaleBlit,
|
|
865
|
+
G as shadeAt,
|
|
866
|
+
U0 as speckle,
|
|
867
|
+
N as text,
|
|
868
|
+
r0 as textInk,
|
|
869
|
+
i0 as textWidth,
|
|
870
|
+
F as toCp437
|
|
871
|
+
};
|