textmode.js 0.3.1 → 0.3.2-beta.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/README.md +1 -1
- package/dist/textmode.esm.js +1201 -1556
- package/dist/textmode.esm.min.js +1230 -1585
- package/dist/textmode.umd.js +7 -9
- package/dist/textmode.umd.min.js +7 -9
- package/dist/types/rendering/webgl/Framebuffer.d.ts +1 -2
- package/dist/types/textmode/Textmodifier.d.ts +49 -2
- package/package.json +1 -1
package/dist/textmode.esm.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (a, t, e) =>
|
|
4
|
-
class
|
|
1
|
+
var ht = Object.defineProperty;
|
|
2
|
+
var at = (a, t, e) => t in a ? ht(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var h = (a, t, e) => at(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
class C extends Error {
|
|
5
5
|
constructor(t, e = {}) {
|
|
6
|
-
super(
|
|
6
|
+
super(C.i(t, e)), this.name = "TextmodeError";
|
|
7
7
|
}
|
|
8
8
|
static i(t, e) {
|
|
9
9
|
return `${t}${e && Object.keys(e).length > 0 ? `
|
|
10
10
|
|
|
11
11
|
📋 Context:` + Object.entries(e).map(([i, s]) => `
|
|
12
|
-
- ${i}: ${
|
|
12
|
+
- ${i}: ${C.o(s)}`).join("") : ""}
|
|
13
13
|
|
|
14
14
|
${"↓".repeat(24)}
|
|
15
15
|
`;
|
|
@@ -19,106 +19,106 @@ ${"↓".repeat(24)}
|
|
|
19
19
|
if (t === void 0) return "undefined";
|
|
20
20
|
if (typeof t == "string") return `"${t}"`;
|
|
21
21
|
if (typeof t == "number" || typeof t == "boolean") return t + "";
|
|
22
|
-
if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) =>
|
|
22
|
+
if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => C.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => C.o(e)).join(", ")}, ... +${t.length - 3} more]`;
|
|
23
23
|
if (typeof t == "object") {
|
|
24
24
|
const e = Object.keys(t);
|
|
25
|
-
return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${
|
|
25
|
+
return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${C.o(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${C.o(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
|
|
26
26
|
}
|
|
27
27
|
return t + "";
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
var
|
|
31
|
-
const
|
|
30
|
+
var ct = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(ct || {});
|
|
31
|
+
const _ = class _ {
|
|
32
32
|
constructor() {
|
|
33
33
|
h(this, "u", { globalLevel: 3 });
|
|
34
34
|
}
|
|
35
35
|
static _() {
|
|
36
|
-
return
|
|
36
|
+
return _.l || (_.l = new _()), _.l;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
v(t, e) {
|
|
39
39
|
const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", s = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
|
|
40
40
|
switch (this.u.globalLevel) {
|
|
41
41
|
case 0:
|
|
42
42
|
return !1;
|
|
43
43
|
case 1:
|
|
44
|
-
return console.group(i, s), console.warn(
|
|
44
|
+
return console.group(i, s), console.warn(C.i(t, e)), console.groupEnd(), !1;
|
|
45
45
|
case 2:
|
|
46
|
-
return console.group(i, s), console.error(
|
|
46
|
+
return console.group(i, s), console.error(C.i(t, e)), console.groupEnd(), !1;
|
|
47
47
|
default:
|
|
48
|
-
throw new
|
|
48
|
+
throw new C(t, e);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
return !!t || (this.
|
|
51
|
+
m(t, e, i) {
|
|
52
|
+
return !!t || (this.v(e, i), !1);
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
A(t) {
|
|
55
55
|
this.u.globalLevel = t;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
h(
|
|
59
|
-
let
|
|
60
|
-
const N =
|
|
61
|
-
function
|
|
62
|
-
|
|
58
|
+
h(_, "l", null);
|
|
59
|
+
let q = _;
|
|
60
|
+
const N = q._(), et = /* @__PURE__ */ new WeakMap();
|
|
61
|
+
function W(a, t) {
|
|
62
|
+
et.set(a, t);
|
|
63
63
|
}
|
|
64
64
|
function H(a) {
|
|
65
|
-
return
|
|
65
|
+
return et.get(a);
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class it {
|
|
68
68
|
constructor() {
|
|
69
|
-
h(this, "
|
|
69
|
+
h(this, "C", 1);
|
|
70
70
|
h(this, "M", 0);
|
|
71
|
-
h(this, "$", 0);
|
|
72
71
|
h(this, "U", 0);
|
|
73
|
-
h(this, "F",
|
|
74
|
-
h(this, "R", [
|
|
75
|
-
h(this, "P", [
|
|
76
|
-
h(this, "S",
|
|
72
|
+
h(this, "F", 0);
|
|
73
|
+
h(this, "R", [0, 0, 0]);
|
|
74
|
+
h(this, "P", [1, 1, 1, 1]);
|
|
75
|
+
h(this, "S", [0, 0, 0, 1]);
|
|
76
|
+
h(this, "$", !1);
|
|
77
77
|
h(this, "D", !1);
|
|
78
78
|
h(this, "k", !1);
|
|
79
|
-
h(this, "
|
|
80
|
-
h(this, "
|
|
81
|
-
h(this, "
|
|
79
|
+
h(this, "L", [0, 0]);
|
|
80
|
+
h(this, "O", [0, 0, 0, 1]);
|
|
81
|
+
h(this, "G", []);
|
|
82
82
|
}
|
|
83
83
|
H() {
|
|
84
|
-
this.
|
|
84
|
+
this.G.push({ I: this.C, N: this.M, X: this.U, W: this.F, L: [...this.L], K: this.$, Y: this.D, k: this.k, j: [...this.R], V: [...this.P], q: [...this.S] });
|
|
85
85
|
}
|
|
86
86
|
Z() {
|
|
87
|
-
const t = this.
|
|
88
|
-
t ? (this.
|
|
87
|
+
const t = this.G.pop();
|
|
88
|
+
t ? (this.C = t.I, this.M = t.N, this.U = t.X, this.F = t.W, this.L = t.L, this.$ = t.K, this.D = t.Y, this.k = t.k, this.R = t.j, this.P = t.V, this.S = t.q) : console.warn("pop() called without matching push()");
|
|
89
89
|
}
|
|
90
90
|
J(t) {
|
|
91
|
-
t.I = this.
|
|
91
|
+
t.I = this.C, t.N = this.M, t.X = this.U, t.W = this.F, t.j[0] = this.R[0], t.j[1] = this.R[1], t.j[2] = this.R[2], t.V[0] = this.P[0], t.V[1] = this.P[1], t.V[2] = this.P[2], t.V[3] = this.P[3], t.q[0] = this.S[0], t.q[1] = this.S[1], t.q[2] = this.S[2], t.q[3] = this.S[3], t.K = this.$, t.Y = this.D, t.k = this.k, t.L[0] = this.L[0], t.L[1] = this.L[1];
|
|
92
92
|
}
|
|
93
93
|
get lineWeight() {
|
|
94
|
-
return this.
|
|
94
|
+
return this.C;
|
|
95
95
|
}
|
|
96
96
|
get canvasBackgroundColor() {
|
|
97
|
-
return this.
|
|
97
|
+
return this.O;
|
|
98
98
|
}
|
|
99
99
|
tt(t) {
|
|
100
|
-
this.
|
|
100
|
+
this.C = Math.abs(t);
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
st(t) {
|
|
103
103
|
this.M = t;
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
this
|
|
105
|
+
et(t) {
|
|
106
|
+
this.U = t;
|
|
107
107
|
}
|
|
108
108
|
it(t) {
|
|
109
|
-
this.
|
|
109
|
+
this.F = t;
|
|
110
110
|
}
|
|
111
111
|
rt(t) {
|
|
112
|
-
this.
|
|
112
|
+
this.R = t;
|
|
113
113
|
}
|
|
114
114
|
nt(t, e, i, s = 255) {
|
|
115
|
-
this.
|
|
115
|
+
this.P = [t / 255, e / 255, i / 255, s / 255];
|
|
116
116
|
}
|
|
117
117
|
ot(t, e, i, s = 255) {
|
|
118
|
-
this.
|
|
118
|
+
this.S = [t / 255, e / 255, i / 255, s / 255];
|
|
119
119
|
}
|
|
120
120
|
ht(t) {
|
|
121
|
-
this
|
|
121
|
+
this.$ = t;
|
|
122
122
|
}
|
|
123
123
|
ct(t) {
|
|
124
124
|
this.D = t;
|
|
@@ -128,42 +128,42 @@ class ht {
|
|
|
128
128
|
}
|
|
129
129
|
ut(t) {
|
|
130
130
|
const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
|
|
131
|
-
this.
|
|
131
|
+
this.L = [i, s];
|
|
132
132
|
}
|
|
133
133
|
ft(t, e, i, s) {
|
|
134
|
-
this.
|
|
134
|
+
this.O = [t / 255, e / 255, i / 255, s / 255];
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
class
|
|
137
|
+
class K {
|
|
138
138
|
constructor(t, e, i = e, s = 1, r = {}, n = null, o = !1) {
|
|
139
139
|
h(this, "dt");
|
|
140
140
|
h(this, "_t");
|
|
141
141
|
h(this, "u");
|
|
142
|
-
h(this, "
|
|
143
|
-
h(this, "
|
|
144
|
-
h(this, "
|
|
142
|
+
h(this, "vt", null);
|
|
143
|
+
h(this, "gt");
|
|
144
|
+
h(this, "At");
|
|
145
145
|
h(this, "yt", []);
|
|
146
146
|
h(this, "Ct");
|
|
147
|
-
h(this, "
|
|
147
|
+
h(this, "wt", null);
|
|
148
148
|
h(this, "bt", []);
|
|
149
149
|
h(this, "xt", null);
|
|
150
150
|
h(this, "Mt", !1);
|
|
151
|
-
h(this, "
|
|
152
|
-
this.dt = e, this._t = i, this.u = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.
|
|
151
|
+
h(this, "Ft", null);
|
|
152
|
+
this.dt = e, this._t = i, this.u = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.gt = t, this.Ct = Math.min(Math.max(1, s), 8), this.xt = n, this.Mt = !!o, this.Ft = this.Mt ? new it() : null;
|
|
153
153
|
const c = t.getParameter(t.MAX_DRAW_BUFFERS), l = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
|
|
154
|
-
this.Ct = Math.min(this.Ct, c, l), this.
|
|
154
|
+
this.Ct = Math.min(this.Ct, c, l), this.At = t.createFramebuffer(), this.zt(), this.Rt(), this.bt = Array(this.Ct).fill(null);
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
const t = this.
|
|
156
|
+
zt() {
|
|
157
|
+
const t = this.gt, e = this.u.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.u.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, s = this.u.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
|
|
158
158
|
for (let r = 0; r < this.Ct; r++) {
|
|
159
159
|
const n = t.createTexture();
|
|
160
160
|
t.bindTexture(t.TEXTURE_2D, n), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, i), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, i), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.dt, this._t, 0, t.RGBA, s, null), this.yt.push(n);
|
|
161
161
|
}
|
|
162
162
|
t.bindTexture(t.TEXTURE_2D, null);
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
const t = this.
|
|
166
|
-
if (t.bindFramebuffer(t.FRAMEBUFFER, this.
|
|
164
|
+
Rt() {
|
|
165
|
+
const t = this.gt;
|
|
166
|
+
if (t.bindFramebuffer(t.FRAMEBUFFER, this.At), this.Ct === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.yt[0], 0);
|
|
167
167
|
else {
|
|
168
168
|
const i = [];
|
|
169
169
|
for (let s = 0; s < this.Ct; s++) {
|
|
@@ -175,52 +175,52 @@ class q {
|
|
|
175
175
|
const e = t.checkFramebufferStatus(t.FRAMEBUFFER);
|
|
176
176
|
e !== t.FRAMEBUFFER_COMPLETE && console.error("GLFramebuffer is not complete:", e), t.bindFramebuffer(t.FRAMEBUFFER, null);
|
|
177
177
|
}
|
|
178
|
-
|
|
179
|
-
const e = this.
|
|
178
|
+
Tt(t) {
|
|
179
|
+
const e = this.gt;
|
|
180
180
|
e.bindTexture(e.TEXTURE_2D, this.yt[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
|
|
181
181
|
}
|
|
182
182
|
resize(t, e) {
|
|
183
|
-
this.dt = t, this._t = e, this.
|
|
184
|
-
const i = this.
|
|
183
|
+
this.dt = t, this._t = e, this.vt = null, this.bt = Array(this.Ct).fill(null);
|
|
184
|
+
const i = this.gt, s = this.u.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
|
|
185
185
|
for (const r of this.yt) i.bindTexture(i.TEXTURE_2D, r), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.dt, this._t, 0, i.RGBA, s, null);
|
|
186
186
|
i.bindTexture(i.TEXTURE_2D, null);
|
|
187
187
|
}
|
|
188
|
-
|
|
189
|
-
const e = this.
|
|
188
|
+
readPixels(t) {
|
|
189
|
+
const e = this.gt, i = this.bt[t];
|
|
190
190
|
if (i) return i;
|
|
191
191
|
const s = this.dt, r = this._t, n = new Uint8Array(s * r * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
|
|
192
|
-
e.bindFramebuffer(e.READ_FRAMEBUFFER, this.
|
|
192
|
+
e.bindFramebuffer(e.READ_FRAMEBUFFER, this.At), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, s, r, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
|
|
193
193
|
const c = 4 * s, l = new Uint8Array(n.length);
|
|
194
|
-
for (let
|
|
195
|
-
const
|
|
196
|
-
l.set(n.subarray(
|
|
194
|
+
for (let f = 0; f < r; f++) {
|
|
195
|
+
const u = (r - 1 - f) * c, m = f * c;
|
|
196
|
+
l.set(n.subarray(u, u + c), m);
|
|
197
197
|
}
|
|
198
198
|
return this.bt[t] = l, l;
|
|
199
199
|
}
|
|
200
200
|
begin() {
|
|
201
201
|
var e, i, s, r;
|
|
202
|
-
const t = this.
|
|
202
|
+
const t = this.gt;
|
|
203
203
|
if (this.xt) {
|
|
204
204
|
const n = ((i = (e = this.xt).Pt) == null ? void 0 : i.call(e)) ?? null;
|
|
205
|
-
n && this.xt.St(n), this.Mt && this
|
|
205
|
+
n && this.xt.St(n), this.Mt && this.Ft && ((r = (s = this.xt).Et) == null || r.call(s, this.Ft));
|
|
206
206
|
}
|
|
207
|
-
this.
|
|
207
|
+
this.wt = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.At), this.bt = Array(this.Ct).fill(null);
|
|
208
208
|
for (let n = 0; n < this.Ct; n++) t.clearBufferfv(t.COLOR, n, new Float32Array([0, 0, 0, 0]));
|
|
209
|
-
t.viewport(0, 0, this.dt, this._t),
|
|
209
|
+
t.viewport(0, 0, this.dt, this._t), W(t, [0, 0, this.dt, this._t]);
|
|
210
210
|
}
|
|
211
211
|
end() {
|
|
212
212
|
var e, i, s, r;
|
|
213
|
-
if (!this.
|
|
214
|
-
const t = this.
|
|
213
|
+
if (!this.wt) return;
|
|
214
|
+
const t = this.gt;
|
|
215
215
|
if (this.xt) {
|
|
216
216
|
const n = ((i = (e = this.xt).Pt) == null ? void 0 : i.call(e)) ?? null;
|
|
217
217
|
n && this.xt.St(n);
|
|
218
218
|
}
|
|
219
|
-
t.bindFramebuffer(t.FRAMEBUFFER, this.
|
|
219
|
+
t.bindFramebuffer(t.FRAMEBUFFER, this.wt.framebuffer), t.viewport(...this.wt.viewport), W(t, this.wt.viewport), this.wt = null, this.xt && this.Mt && this.Ft && ((r = (s = this.xt).$t) == null || r.call(s));
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
const t = this.
|
|
223
|
-
t.deleteFramebuffer(this.
|
|
221
|
+
Dt() {
|
|
222
|
+
const t = this.gt;
|
|
223
|
+
t.deleteFramebuffer(this.At);
|
|
224
224
|
for (const e of this.yt) t.deleteTexture(e);
|
|
225
225
|
}
|
|
226
226
|
get width() {
|
|
@@ -233,71 +233,71 @@ class q {
|
|
|
233
233
|
return [...this.yt];
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class O {
|
|
237
237
|
constructor(t, e, i) {
|
|
238
|
-
h(this, "
|
|
239
|
-
h(this, "
|
|
240
|
-
h(this, "
|
|
238
|
+
h(this, "gt");
|
|
239
|
+
h(this, "kt");
|
|
240
|
+
h(this, "Bt", /* @__PURE__ */ new Map());
|
|
241
241
|
h(this, "Lt", /* @__PURE__ */ new Map());
|
|
242
242
|
h(this, "Ot", 0);
|
|
243
|
-
this.
|
|
243
|
+
this.gt = t, this.kt = this.Gt(e, i), this.Ht();
|
|
244
244
|
}
|
|
245
|
-
|
|
246
|
-
const t = this.
|
|
245
|
+
Ht() {
|
|
246
|
+
const t = this.gt.getProgramParameter(this.kt, this.gt.ACTIVE_UNIFORMS);
|
|
247
247
|
for (let e = 0; e < t; e++) {
|
|
248
|
-
const i = this.
|
|
248
|
+
const i = this.gt.getActiveUniform(this.kt, e);
|
|
249
249
|
if (i) {
|
|
250
|
-
const s = this.
|
|
251
|
-
if (s && (this.
|
|
250
|
+
const s = this.gt.getUniformLocation(this.kt, i.name);
|
|
251
|
+
if (s && (this.Bt.set(i.name, s), this.Lt.set(i.name, { type: i.type, size: i.size }), i.size > 1)) {
|
|
252
252
|
const r = i.name.replace(/\[.*\]$/, "");
|
|
253
|
-
this.
|
|
253
|
+
this.Bt.has(r) || (this.Bt.set(r, s), this.Lt.set(r, { type: i.type, size: i.size }));
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
|
|
259
|
-
const i = this.
|
|
260
|
-
if (this.
|
|
261
|
-
const n = this.
|
|
258
|
+
Gt(t, e) {
|
|
259
|
+
const i = this.It(this.gt.VERTEX_SHADER, t), s = this.It(this.gt.FRAGMENT_SHADER, e), r = this.gt.createProgram();
|
|
260
|
+
if (this.gt.attachShader(r, i), this.gt.attachShader(r, s), this.gt.linkProgram(r), !this.gt.getProgramParameter(r, this.gt.LINK_STATUS)) {
|
|
261
|
+
const n = this.gt.getProgramInfoLog(r);
|
|
262
262
|
throw Error("Shader program link error: " + n);
|
|
263
263
|
}
|
|
264
|
-
return this.
|
|
264
|
+
return this.gt.deleteShader(i), this.gt.deleteShader(s), r;
|
|
265
265
|
}
|
|
266
|
-
|
|
267
|
-
const i = this.
|
|
268
|
-
if (this.
|
|
269
|
-
const s = this.
|
|
270
|
-
throw this.
|
|
266
|
+
It(t, e) {
|
|
267
|
+
const i = this.gt.createShader(t);
|
|
268
|
+
if (this.gt.shaderSource(i, e), this.gt.compileShader(i), !this.gt.getShaderParameter(i, this.gt.COMPILE_STATUS)) {
|
|
269
|
+
const s = this.gt.getShaderInfoLog(i);
|
|
270
|
+
throw this.gt.deleteShader(i), Error("Shader compilation error: " + s);
|
|
271
271
|
}
|
|
272
272
|
return i;
|
|
273
273
|
}
|
|
274
|
-
|
|
275
|
-
this.
|
|
274
|
+
Nt() {
|
|
275
|
+
this.gt.useProgram(this.kt), this.Xt();
|
|
276
276
|
}
|
|
277
|
-
|
|
277
|
+
Xt() {
|
|
278
278
|
this.Ot = 0;
|
|
279
279
|
}
|
|
280
|
-
|
|
281
|
-
for (const [e, i] of Object.entries(t)) this.
|
|
282
|
-
}
|
|
283
|
-
Kt(t) {
|
|
284
|
-
return this.Gt.has(t);
|
|
280
|
+
Wt(t) {
|
|
281
|
+
for (const [e, i] of Object.entries(t)) this.Kt(e, i);
|
|
285
282
|
}
|
|
286
283
|
Yt(t) {
|
|
284
|
+
return this.Bt.has(t);
|
|
285
|
+
}
|
|
286
|
+
jt(t) {
|
|
287
287
|
return this.Lt.get(t) || null;
|
|
288
288
|
}
|
|
289
|
-
|
|
289
|
+
Vt() {
|
|
290
290
|
const t = [];
|
|
291
291
|
for (const [e, i] of this.Lt.entries()) t.push({ name: e, ...i });
|
|
292
292
|
return t;
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
Kt(t, e) {
|
|
295
295
|
var c;
|
|
296
|
-
const i = this.
|
|
296
|
+
const i = this.Bt.get(t);
|
|
297
297
|
if (!i) return;
|
|
298
298
|
const s = this.Lt.get(t);
|
|
299
299
|
if (!s) return void console.warn(`No type information found for uniform '${t}'`);
|
|
300
|
-
const { type: r, size: n } = s, o = this.
|
|
300
|
+
const { type: r, size: n } = s, o = this.gt;
|
|
301
301
|
if (typeof e == "number") switch (r) {
|
|
302
302
|
case o.INT:
|
|
303
303
|
case o.BOOL:
|
|
@@ -311,16 +311,16 @@ class _ {
|
|
|
311
311
|
}
|
|
312
312
|
else if (typeof e == "boolean") o.uniform1i(i, e ? 1 : 0);
|
|
313
313
|
else if (Array.isArray(e)) if (Array.isArray(e[0])) {
|
|
314
|
-
const l = e,
|
|
314
|
+
const l = e, f = ((c = l[0]) == null ? void 0 : c.length) || 0, u = l.flat();
|
|
315
315
|
switch (r) {
|
|
316
316
|
case o.FLOAT_VEC2:
|
|
317
|
-
|
|
317
|
+
f === 2 ? o.uniform2fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 2, got ${f}`);
|
|
318
318
|
break;
|
|
319
319
|
case o.FLOAT_VEC3:
|
|
320
|
-
|
|
320
|
+
f === 3 ? o.uniform3fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 3, got ${f}`);
|
|
321
321
|
break;
|
|
322
322
|
case o.FLOAT_VEC4:
|
|
323
|
-
|
|
323
|
+
f === 4 ? o.uniform4fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 4, got ${f}`);
|
|
324
324
|
break;
|
|
325
325
|
default:
|
|
326
326
|
console.warn(`Unsupported uniform type for vector array '${t}': ${r}`);
|
|
@@ -345,563 +345,563 @@ class _ {
|
|
|
345
345
|
console.warn(`Unsupported uniform type for array '${t}': ${r}`);
|
|
346
346
|
}
|
|
347
347
|
else if (e instanceof WebGLTexture) {
|
|
348
|
-
const l = this.
|
|
348
|
+
const l = this.qt();
|
|
349
349
|
o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e);
|
|
350
|
-
} else if (e instanceof
|
|
351
|
-
const l = this.
|
|
350
|
+
} else if (e instanceof K) {
|
|
351
|
+
const l = this.qt();
|
|
352
352
|
o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e.textures[0]);
|
|
353
353
|
} else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
qt() {
|
|
356
356
|
return this.Ot++;
|
|
357
357
|
}
|
|
358
|
-
get
|
|
359
|
-
return this.
|
|
358
|
+
get Zt() {
|
|
359
|
+
return this.kt;
|
|
360
360
|
}
|
|
361
|
-
|
|
362
|
-
this.
|
|
361
|
+
Dt() {
|
|
362
|
+
this.gt.deleteProgram(this.kt);
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
const X = `#version 300 es
|
|
366
|
-
in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uw;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uw)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`,
|
|
367
|
-
class
|
|
366
|
+
in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uw;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uw)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, st = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
|
|
367
|
+
class lt {
|
|
368
368
|
constructor(t) {
|
|
369
|
-
h(this, "
|
|
369
|
+
h(this, "gt");
|
|
370
|
+
h(this, "Qt");
|
|
370
371
|
h(this, "Jt");
|
|
371
|
-
h(this, "
|
|
372
|
-
h(this, "
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
precision highp float;in vec2 v_uv;
|
|
376
|
-
precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ee = new _(this.vt, at, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.se = new _(this.vt, X, `#version 300 es
|
|
372
|
+
h(this, "ts");
|
|
373
|
+
h(this, "ss");
|
|
374
|
+
this.gt = t, this.Jt = new O(this.gt, X, `#version 300 es
|
|
375
|
+
precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Qt = new O(this.gt, X, `#version 300 es
|
|
376
|
+
precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ts = new O(this.gt, st, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.ss = new O(this.gt, X, `#version 300 es
|
|
377
377
|
precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec4 Uq;uniform bool Ur;uniform vec4 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.0f),0.0f,F-1.0f);int H=int(floor(G+0.5f));vec3 I=Uv[H];o_character=vec4(I,1.0f);}else{o_character=vec4(E,0.0f,0.0f,1.0f);}vec4 J=Up?Uq:D;vec4 K=Ur?Us:D;if(D.a<0.01f){J=Ut;K=Ut;}else{}o_primaryColor=vec4(J);o_secondaryColor=vec4(K);o_rotation=vec4(Uo.xy,0.0f,1.0f);o_transform=vec4(float(Ul),float(Um),float(Un),1.0f);}`);
|
|
378
378
|
}
|
|
379
|
-
|
|
380
|
-
return this.
|
|
379
|
+
es() {
|
|
380
|
+
return this.Qt;
|
|
381
381
|
}
|
|
382
382
|
Pt() {
|
|
383
|
-
return this.
|
|
383
|
+
return this.Jt;
|
|
384
384
|
}
|
|
385
|
-
|
|
386
|
-
return this.
|
|
385
|
+
rs() {
|
|
386
|
+
return this.ts;
|
|
387
387
|
}
|
|
388
|
-
|
|
389
|
-
return this.
|
|
388
|
+
ns() {
|
|
389
|
+
return this.ss;
|
|
390
390
|
}
|
|
391
|
-
|
|
392
|
-
return new
|
|
391
|
+
hs(t) {
|
|
392
|
+
return new O(this.gt, X, t);
|
|
393
393
|
}
|
|
394
|
-
|
|
395
|
-
return new
|
|
394
|
+
cs(t, e) {
|
|
395
|
+
return new O(this.gt, t, e);
|
|
396
396
|
}
|
|
397
|
-
|
|
398
|
-
this.
|
|
397
|
+
Dt() {
|
|
398
|
+
this.Qt.Dt(), this.Jt.Dt(), this.ts.Dt(), this.ss.Dt();
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
var E = ((a) => (a.RECTANGLE = "rectangle", a.LINE = "line", a.ELLIPSE = "ellipse", a.ARC = "arc", a.TRIANGLE = "triangle", a.BEZIER_CURVE = "bezier_curve", a.CUSTOM = "custom", a))(E || {});
|
|
402
|
-
class
|
|
402
|
+
class ut {
|
|
403
403
|
constructor(t) {
|
|
404
|
-
h(this, "
|
|
405
|
-
h(this, "
|
|
406
|
-
this.
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
const r = this.
|
|
410
|
-
let n = this.
|
|
411
|
-
n || (n = /* @__PURE__ */ new Map(), this.
|
|
404
|
+
h(this, "gt");
|
|
405
|
+
h(this, "ls", /* @__PURE__ */ new Map());
|
|
406
|
+
this.gt = t;
|
|
407
|
+
}
|
|
408
|
+
us(t, e, i, s) {
|
|
409
|
+
const r = this.gt;
|
|
410
|
+
let n = this.ls.get(t);
|
|
411
|
+
n || (n = /* @__PURE__ */ new Map(), this.ls.set(t, n));
|
|
412
412
|
let o = n.get(e) || null;
|
|
413
413
|
if (!o) {
|
|
414
414
|
o = r.createVertexArray(), n.set(e, o), r.bindVertexArray(o), r.bindBuffer(r.ARRAY_BUFFER, s);
|
|
415
415
|
const c = r.getAttribLocation(t, "a_position");
|
|
416
|
-
c !== -1 && (r.enableVertexAttribArray(c), r.vertexAttribPointer(c, i.
|
|
416
|
+
c !== -1 && (r.enableVertexAttribArray(c), r.vertexAttribPointer(c, i.ds.fs.size, r.FLOAT, !1, i._s, i.ds.fs.offset), r.vertexAttribDivisor(c, 0));
|
|
417
417
|
const l = r.getAttribLocation(t, "a_texCoord");
|
|
418
|
-
l !== -1 && (r.enableVertexAttribArray(l), r.vertexAttribPointer(l, i.
|
|
418
|
+
l !== -1 && (r.enableVertexAttribArray(l), r.vertexAttribPointer(l, i.ds.ps.size, r.FLOAT, !1, i._s, i.ds.ps.offset), r.vertexAttribDivisor(l, 0));
|
|
419
419
|
}
|
|
420
420
|
r.bindVertexArray(o);
|
|
421
421
|
}
|
|
422
|
-
|
|
423
|
-
this.
|
|
422
|
+
vs() {
|
|
423
|
+
this.gt.bindVertexArray(null);
|
|
424
424
|
}
|
|
425
|
-
|
|
426
|
-
for (const [, t] of this.
|
|
425
|
+
Dt() {
|
|
426
|
+
for (const [, t] of this.ls) for (const [, e] of t) e && this.gt.deleteVertexArray(e);
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
class
|
|
429
|
+
class ft {
|
|
430
430
|
constructor(t, e) {
|
|
431
|
-
h(this, "
|
|
432
|
-
h(this, "
|
|
431
|
+
h(this, "gs");
|
|
432
|
+
h(this, "gt");
|
|
433
433
|
h(this, "xt");
|
|
434
|
-
h(this, "
|
|
435
|
-
h(this, "
|
|
436
|
-
this.
|
|
434
|
+
h(this, "As", null);
|
|
435
|
+
h(this, "Cs", null);
|
|
436
|
+
this.gt = t, this.gs = new ut(t), this.xt = e;
|
|
437
437
|
}
|
|
438
|
-
|
|
439
|
-
const { shader: s } = t, r = H(this.
|
|
440
|
-
s.
|
|
438
|
+
ws(t, e, i) {
|
|
439
|
+
const { shader: s } = t, r = H(this.gt) || this.gt.getParameter(this.gt.VIEWPORT);
|
|
440
|
+
s.Wt({ U9: r[2] / r[3], Uw: [r[2], r[3]] });
|
|
441
441
|
const n = (l) => {
|
|
442
|
-
if (!l || !l.
|
|
443
|
-
const
|
|
442
|
+
if (!l || !l.bs()) return;
|
|
443
|
+
const f = l.unitGeometry, u = l.unitBuffer;
|
|
444
444
|
try {
|
|
445
|
-
this.
|
|
445
|
+
this.gs.us(s.Zt, l.type + "", f, u), l.batch.Ms(s), l.batch.Fs(f.zs, f.Rs);
|
|
446
446
|
} finally {
|
|
447
|
-
l.batch.
|
|
447
|
+
l.batch.Ts(s), this.gs.vs(), l.Ps();
|
|
448
448
|
}
|
|
449
449
|
};
|
|
450
450
|
let o = null, c = null;
|
|
451
451
|
for (const l of e) {
|
|
452
452
|
if (l.type === E.CUSTOM) {
|
|
453
|
-
c && (n(c), o = null, c = null), this
|
|
453
|
+
c && (n(c), o = null, c = null), this.Ss(t, l.params, l.state, i.get(E.RECTANGLE));
|
|
454
454
|
continue;
|
|
455
455
|
}
|
|
456
456
|
o !== null && l.type !== o && (n(c), o = null, c = null);
|
|
457
|
-
let
|
|
458
|
-
|
|
457
|
+
let f = c;
|
|
458
|
+
f && l.type === o || (f = i.get(l.type) || null, c = f, o = l.type), f && f.Es(l.params, l.state);
|
|
459
459
|
}
|
|
460
460
|
n(c);
|
|
461
461
|
}
|
|
462
|
-
|
|
463
|
-
const { x: r, y: n, width: o, height: c, shader: l, uniforms:
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
this.
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
e.
|
|
470
|
-
const l = this.
|
|
471
|
-
if (e.
|
|
472
|
-
const
|
|
462
|
+
Ss(t, e, i, s) {
|
|
463
|
+
const { x: r, y: n, width: o, height: c, shader: l, uniforms: f } = e, u = this.$s(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
|
|
464
|
+
u.begin(), this.Ds(s, l, f, 0, 0, u.width, u.height, {}), u.end();
|
|
465
|
+
const m = this.ks(), p = { Ue: u.textures[0], Uf: u.textures[1], Ug: u.textures[2], Uh: u.textures[3], Ui: u.textures[4], Uj: [u.width, u.height] };
|
|
466
|
+
this.Ds(s, m, p, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), t.shader.Nt();
|
|
467
|
+
}
|
|
468
|
+
Ds(t, e, i, s, r, n, o, c) {
|
|
469
|
+
e.Nt(), e.Wt(i);
|
|
470
|
+
const l = this.gt.getParameter(this.gt.VIEWPORT);
|
|
471
|
+
if (e.Wt({ U9: l[2] / l[3], Uw: [l[2], l[3]] }), t.Ps(), t.Es({ x: s, y: r, width: n, height: o }, c), t.bs()) {
|
|
472
|
+
const f = t.unitGeometry, u = t.unitBuffer;
|
|
473
473
|
try {
|
|
474
|
-
this.
|
|
474
|
+
this.gs.us(e.Zt, t.type + "", f, u), t.batch.Ms(e), t.batch.Fs(f.zs, f.Rs);
|
|
475
475
|
} finally {
|
|
476
|
-
t.batch.
|
|
476
|
+
t.batch.Ts(e), this.gs.vs(), t.Ps();
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
|
|
481
|
-
return this.xt.
|
|
480
|
+
ks() {
|
|
481
|
+
return this.xt.es();
|
|
482
482
|
}
|
|
483
|
-
|
|
484
|
-
return this.
|
|
483
|
+
$s(t, e) {
|
|
484
|
+
return this.As && this.Cs && this.Cs.w === t && this.Cs.h === e || (this.As && this.As.Dt(), this.As = new K(this.gt, t, e, 5), this.Cs = { w: t, h: e }), this.As;
|
|
485
485
|
}
|
|
486
|
-
|
|
487
|
-
this.
|
|
486
|
+
Dt() {
|
|
487
|
+
this.gs.Dt(), this.As && this.As.Dt();
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
|
-
class
|
|
490
|
+
class dt {
|
|
491
491
|
constructor() {
|
|
492
|
-
h(this, "
|
|
493
|
-
h(this, "
|
|
494
|
-
h(this, "
|
|
492
|
+
h(this, "Bs", []);
|
|
493
|
+
h(this, "Ls", 1);
|
|
494
|
+
h(this, "Os", 0);
|
|
495
495
|
}
|
|
496
|
-
|
|
497
|
-
if (this.
|
|
498
|
-
const i = { id: this.
|
|
499
|
-
this.
|
|
496
|
+
Gs(t) {
|
|
497
|
+
if (this.Os >= this.Bs.length) {
|
|
498
|
+
const i = { id: this.Ls++, type: t, params: {}, state: { I: 1, N: 0, X: 0, W: 0, j: [0, 0, 0], V: [1, 1, 1, 1], q: [0, 0, 0, 1], K: !1, Y: !1, k: !1, L: [0, 0] } };
|
|
499
|
+
this.Bs.push(i);
|
|
500
500
|
}
|
|
501
|
-
const e = this.
|
|
502
|
-
return e.id = this.
|
|
501
|
+
const e = this.Bs[this.Os];
|
|
502
|
+
return e.id = this.Ls++, e.type = t, this.Os++, e;
|
|
503
503
|
}
|
|
504
|
-
|
|
505
|
-
const n = this.
|
|
504
|
+
Hs(t, e, i, s, r) {
|
|
505
|
+
const n = this.Gs(E.RECTANGLE);
|
|
506
506
|
return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
|
|
507
507
|
}
|
|
508
|
-
|
|
509
|
-
const c = this.
|
|
508
|
+
Is(t, e, i, s, r, n, o) {
|
|
509
|
+
const c = this.Gs(E.CUSTOM);
|
|
510
510
|
return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.shader = r, c.params.uniforms = n, o.J(c.state), c.id;
|
|
511
511
|
}
|
|
512
|
-
|
|
513
|
-
const o = this.
|
|
512
|
+
Ns(t, e, i, s, r, n) {
|
|
513
|
+
const o = this.Gs(E.LINE);
|
|
514
514
|
return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = s, o.params.thickness = r, n.J(o.state), o.id;
|
|
515
515
|
}
|
|
516
|
-
|
|
517
|
-
const n = this.
|
|
516
|
+
Xs(t, e, i, s, r) {
|
|
517
|
+
const n = this.Gs(E.ELLIPSE);
|
|
518
518
|
return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
|
|
519
519
|
}
|
|
520
|
-
|
|
521
|
-
const c = this.
|
|
520
|
+
Ws(t, e, i, s, r, n, o) {
|
|
521
|
+
const c = this.Gs(E.ARC);
|
|
522
522
|
return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.start = r, c.params.stop = n, o.J(c.state), c.id;
|
|
523
523
|
}
|
|
524
|
-
|
|
525
|
-
const c = this.
|
|
524
|
+
Ks(t, e, i, s, r, n, o) {
|
|
525
|
+
const c = this.Gs(E.TRIANGLE);
|
|
526
526
|
return c.params.x1 = t, c.params.y1 = e, c.params.x2 = i, c.params.y2 = s, c.params.x3 = r, c.params.y3 = n, o.J(c.state), c.id;
|
|
527
527
|
}
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
return
|
|
528
|
+
Ys(t, e, i, s, r, n, o, c, l, f) {
|
|
529
|
+
const u = this.Gs(E.BEZIER_CURVE);
|
|
530
|
+
return u.params.x1 = t, u.params.y1 = e, u.params.cp1x = i, u.params.cp1y = s, u.params.cp2x = r, u.params.cp2y = n, u.params.x2 = o, u.params.y2 = c, u.params.thickness = l, f.J(u.state), u.id;
|
|
531
531
|
}
|
|
532
532
|
get length() {
|
|
533
|
-
return this.
|
|
533
|
+
return this.Os;
|
|
534
534
|
}
|
|
535
535
|
get isEmpty() {
|
|
536
|
-
return this.
|
|
536
|
+
return this.Os === 0;
|
|
537
537
|
}
|
|
538
|
-
|
|
539
|
-
this.
|
|
538
|
+
js() {
|
|
539
|
+
this.Os = 0;
|
|
540
540
|
}
|
|
541
541
|
[Symbol.iterator]() {
|
|
542
542
|
let t = 0;
|
|
543
|
-
const e = this.
|
|
543
|
+
const e = this.Os, i = this.Bs;
|
|
544
544
|
return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
const
|
|
548
|
-
static
|
|
549
|
-
var n, o, c, l,
|
|
550
|
-
const s = e || new Float32Array(
|
|
547
|
+
const L = class L {
|
|
548
|
+
static Vs(t, e, i = 0) {
|
|
549
|
+
var n, o, c, l, f, u, m, p, g, d;
|
|
550
|
+
const s = e || new Float32Array(L.FLOATS_PER_INSTANCE);
|
|
551
551
|
let r = i;
|
|
552
|
-
return s[r++] = t.
|
|
552
|
+
return s[r++] = t.fs[0], s[r++] = t.fs[1], s[r++] = t.Os[0], s[r++] = t.Os[1], s[r++] = t.j[0], s[r++] = t.j[1], s[r++] = t.j[2], s[r++] = t.V[0], s[r++] = t.V[1], s[r++] = t.V[2], s[r++] = t.V[3], s[r++] = t.q[0], s[r++] = t.q[1], s[r++] = t.q[2], s[r++] = t.q[3], s[r++] = t.L[0], s[r++] = t.L[1], s[r++] = t.qs[0], s[r++] = t.qs[1], s[r++] = t.qs[2], s[r++] = t.N, s[r++] = t.X, s[r++] = t.W, s[r++] = t.Zs[0], s[r++] = t.Zs[1], s[r++] = ((n = t.Qs) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.Qs) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.Js) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.Js) == null ? void 0 : l[1]) || 0, s[r++] = ((f = t.te) == null ? void 0 : f[0]) || 0, s[r++] = ((u = t.te) == null ? void 0 : u[1]) || 0, s[r++] = ((m = t.se) == null ? void 0 : m[0]) || 0, s[r++] = ((p = t.se) == null ? void 0 : p[1]) || 0, s[r++] = ((g = t.ee) == null ? void 0 : g[0]) || 0, s[r++] = ((d = t.ee) == null ? void 0 : d[1]) || 0, s;
|
|
553
553
|
}
|
|
554
|
-
static
|
|
555
|
-
const e = t.length *
|
|
554
|
+
static ie(t) {
|
|
555
|
+
const e = t.length * L.FLOATS_PER_INSTANCE, i = new Float32Array(e);
|
|
556
556
|
for (let s = 0; s < t.length; s++) {
|
|
557
|
-
const r = s *
|
|
558
|
-
|
|
557
|
+
const r = s * L.FLOATS_PER_INSTANCE;
|
|
558
|
+
L.Vs(t[s], i, r);
|
|
559
559
|
}
|
|
560
560
|
return i;
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
|
-
h(
|
|
564
|
-
let
|
|
565
|
-
const
|
|
563
|
+
h(L, "BYTES_PER_INSTANCE", 140), h(L, "FLOATS_PER_INSTANCE", 35);
|
|
564
|
+
let D = L;
|
|
565
|
+
const b = class b {
|
|
566
566
|
};
|
|
567
|
-
h(
|
|
568
|
-
let
|
|
569
|
-
class
|
|
567
|
+
h(b, "STRIDE", D.BYTES_PER_INSTANCE), h(b, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 132, divisor: 1 } });
|
|
568
|
+
let j = b;
|
|
569
|
+
class gt {
|
|
570
570
|
constructor(t, e = 1e3, i = 1.5) {
|
|
571
|
-
h(this, "
|
|
572
|
-
h(this, "
|
|
573
|
-
h(this, "
|
|
574
|
-
h(this, "
|
|
575
|
-
h(this, "
|
|
576
|
-
h(this, "
|
|
577
|
-
h(this, "
|
|
578
|
-
h(this, "
|
|
579
|
-
h(this, "
|
|
580
|
-
this.
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
const e = this.
|
|
584
|
-
return this.
|
|
571
|
+
h(this, "gt");
|
|
572
|
+
h(this, "re", []);
|
|
573
|
+
h(this, "ne");
|
|
574
|
+
h(this, "oe");
|
|
575
|
+
h(this, "he", null);
|
|
576
|
+
h(this, "ae", !0);
|
|
577
|
+
h(this, "ce", 0);
|
|
578
|
+
h(this, "le", /* @__PURE__ */ new Map());
|
|
579
|
+
h(this, "ue", null);
|
|
580
|
+
this.gt = t, this.ne = e, this.oe = i, this.fe();
|
|
581
|
+
}
|
|
582
|
+
Es(t) {
|
|
583
|
+
const e = this.re.length;
|
|
584
|
+
return this.re.push(t), this.ae = !0, e;
|
|
585
585
|
}
|
|
586
586
|
get count() {
|
|
587
|
-
return this.
|
|
587
|
+
return this.re.length;
|
|
588
588
|
}
|
|
589
589
|
get isEmpty() {
|
|
590
|
-
return this.
|
|
590
|
+
return this.re.length === 0;
|
|
591
591
|
}
|
|
592
592
|
clear() {
|
|
593
|
-
this.
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
if (t <= this.
|
|
597
|
-
const e = Math.ceil(t * this.
|
|
598
|
-
this.
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
const t = this.
|
|
602
|
-
this.
|
|
603
|
-
const e = this.
|
|
604
|
-
t.bindBuffer(t.ARRAY_BUFFER, this.
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
if (!this.
|
|
608
|
-
const t = this.
|
|
609
|
-
this.
|
|
610
|
-
const i =
|
|
611
|
-
t.bindBuffer(t.ARRAY_BUFFER, this.
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
let e = this.
|
|
593
|
+
this.re.length = 0, this.ae = !0;
|
|
594
|
+
}
|
|
595
|
+
de(t) {
|
|
596
|
+
if (t <= this.ne) return;
|
|
597
|
+
const e = Math.ceil(t * this.oe);
|
|
598
|
+
this.ne = e, this.fe();
|
|
599
|
+
}
|
|
600
|
+
fe() {
|
|
601
|
+
const t = this.gt;
|
|
602
|
+
this.he && t.deleteBuffer(this.he), this.he = t.createBuffer();
|
|
603
|
+
const e = this.ne * D.BYTES_PER_INSTANCE;
|
|
604
|
+
t.bindBuffer(t.ARRAY_BUFFER, this.he), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ae = !0, this.ce = 0;
|
|
605
|
+
}
|
|
606
|
+
_e() {
|
|
607
|
+
if (!this.ae || this.re.length === 0) return;
|
|
608
|
+
const t = this.gt, e = this.re.length;
|
|
609
|
+
this.de(e), (!this.ue || this.ue.length < e * D.FLOATS_PER_INSTANCE) && (this.ue = new Float32Array(e * D.FLOATS_PER_INSTANCE));
|
|
610
|
+
const i = D.ie(this.re);
|
|
611
|
+
t.bindBuffer(t.ARRAY_BUFFER, this.he), e <= this.ce ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ae = !1, this.ce = e;
|
|
612
|
+
}
|
|
613
|
+
pe(t) {
|
|
614
|
+
let e = this.le.get(t);
|
|
615
615
|
if (!e) {
|
|
616
616
|
e = /* @__PURE__ */ new Map();
|
|
617
|
-
const i = this.
|
|
618
|
-
for (const s in
|
|
617
|
+
const i = this.gt;
|
|
618
|
+
for (const s in j.ATTRIBUTES) {
|
|
619
619
|
const r = i.getAttribLocation(t, s);
|
|
620
620
|
r !== -1 && e.set(s, r);
|
|
621
621
|
}
|
|
622
|
-
this.
|
|
622
|
+
this.le.set(t, e);
|
|
623
623
|
}
|
|
624
624
|
return e;
|
|
625
625
|
}
|
|
626
|
-
|
|
627
|
-
if (!this.
|
|
628
|
-
const e = this.
|
|
629
|
-
this.
|
|
630
|
-
const s = this.
|
|
631
|
-
e.bindBuffer(e.ARRAY_BUFFER, this.
|
|
626
|
+
Ms(t) {
|
|
627
|
+
if (!this.he || this.re.length === 0) return;
|
|
628
|
+
const e = this.gt, i = t.Zt;
|
|
629
|
+
this._e();
|
|
630
|
+
const s = this.pe(i);
|
|
631
|
+
e.bindBuffer(e.ARRAY_BUFFER, this.he);
|
|
632
632
|
for (const [r, n] of s) {
|
|
633
|
-
const o =
|
|
633
|
+
const o = j.ATTRIBUTES[r];
|
|
634
634
|
o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
|
-
|
|
638
|
-
const e = this.
|
|
637
|
+
Ts(t) {
|
|
638
|
+
const e = this.gt, i = this.pe(t.Zt);
|
|
639
639
|
for (const [, s] of i) e.disableVertexAttribArray(s), e.vertexAttribDivisor(s, 0);
|
|
640
640
|
}
|
|
641
|
-
|
|
642
|
-
this.
|
|
641
|
+
Fs(t, e) {
|
|
642
|
+
this.re.length !== 0 && this.gt.drawArraysInstanced(t, 0, e, this.re.length);
|
|
643
643
|
}
|
|
644
|
-
|
|
645
|
-
this.
|
|
644
|
+
Dt() {
|
|
645
|
+
this.he && this.gt.deleteBuffer(this.he);
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
|
-
class
|
|
648
|
+
class S {
|
|
649
649
|
constructor(t, e, i, s) {
|
|
650
|
-
h(this, "
|
|
651
|
-
h(this, "
|
|
652
|
-
h(this, "
|
|
653
|
-
h(this, "
|
|
654
|
-
h(this, "
|
|
655
|
-
this.
|
|
656
|
-
const r = this.
|
|
650
|
+
h(this, "gt");
|
|
651
|
+
h(this, "ve");
|
|
652
|
+
h(this, "me");
|
|
653
|
+
h(this, "ge");
|
|
654
|
+
h(this, "Ae", null);
|
|
655
|
+
this.gt = t, this.ve = e, this.me = i, this.ge = s;
|
|
656
|
+
const r = this.gt.createBuffer();
|
|
657
657
|
if (!r) throw Error("Failed to create unit geometry buffer");
|
|
658
|
-
this.
|
|
658
|
+
this.gt.bindBuffer(this.gt.ARRAY_BUFFER, r), this.gt.bufferData(this.gt.ARRAY_BUFFER, this.ge.ye, this.gt.STATIC_DRAW), this.gt.bindBuffer(this.gt.ARRAY_BUFFER, null), this.Ae = r;
|
|
659
659
|
}
|
|
660
660
|
get type() {
|
|
661
|
-
return this.
|
|
661
|
+
return this.me;
|
|
662
662
|
}
|
|
663
663
|
get unitGeometry() {
|
|
664
|
-
return this.
|
|
664
|
+
return this.ge;
|
|
665
665
|
}
|
|
666
666
|
get unitBuffer() {
|
|
667
|
-
return this.
|
|
667
|
+
return this.Ae;
|
|
668
668
|
}
|
|
669
669
|
get batch() {
|
|
670
|
-
return this.
|
|
670
|
+
return this.ve;
|
|
671
671
|
}
|
|
672
|
-
|
|
673
|
-
this.
|
|
672
|
+
Ps() {
|
|
673
|
+
this.ve.clear();
|
|
674
674
|
}
|
|
675
|
-
|
|
676
|
-
return !this.
|
|
675
|
+
bs() {
|
|
676
|
+
return !this.ve.isEmpty;
|
|
677
677
|
}
|
|
678
|
-
|
|
679
|
-
this.
|
|
678
|
+
Dt() {
|
|
679
|
+
this.ve.Dt(), this.gt.deleteBuffer(this.Ae);
|
|
680
680
|
}
|
|
681
|
-
|
|
682
|
-
const n = this.
|
|
683
|
-
return {
|
|
681
|
+
Ce(t, e, i, s, r) {
|
|
682
|
+
const n = this.we(t, e, i, s, r.N || 0, r.X || 0, r.W || 0);
|
|
683
|
+
return { fs: [t, e], Os: [i, s], j: r.j || [0, 0, 0], V: r.V || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], L: r.L || [0, 0], qs: [r.k ? 1 : 0, r.K ? 1 : 0, r.Y ? 1 : 0], N: n.radiansX, X: n.radiansY, W: n.radiansZ, Zs: [n.centerX, n.centerY] };
|
|
684
684
|
}
|
|
685
|
-
|
|
686
|
-
const i = H(this.
|
|
685
|
+
be(t, e) {
|
|
686
|
+
const i = H(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height];
|
|
687
687
|
return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
|
|
688
688
|
}
|
|
689
|
-
|
|
690
|
-
const s = this.
|
|
691
|
-
t.
|
|
689
|
+
xe(t, e, i) {
|
|
690
|
+
const s = this.be(e, i);
|
|
691
|
+
t.Zs = [s.nx, s.ny];
|
|
692
692
|
}
|
|
693
|
-
|
|
694
|
-
const c = H(this.
|
|
695
|
-
return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + s / 2) /
|
|
693
|
+
we(t, e, i, s, r, n, o) {
|
|
694
|
+
const c = H(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height], l = c[2], f = c[3];
|
|
695
|
+
return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + s / 2) / f * 2, radiansX: -r * Math.PI / 180, radiansY: -n * Math.PI / 180, radiansZ: -o * Math.PI / 180, aspectRatio: l / f };
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
|
-
const
|
|
699
|
-
class
|
|
698
|
+
const mt = { ye: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), Rs: 6, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
|
|
699
|
+
class At extends S {
|
|
700
700
|
constructor(t, e) {
|
|
701
|
-
super(t, e, E.RECTANGLE,
|
|
701
|
+
super(t, e, E.RECTANGLE, mt);
|
|
702
702
|
}
|
|
703
|
-
|
|
704
|
-
const i = this.
|
|
705
|
-
return this.
|
|
703
|
+
Es(t, e) {
|
|
704
|
+
const i = this.Ce(t.x, t.y, t.width, t.height, e);
|
|
705
|
+
return this.ve.Es(i);
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
|
-
const
|
|
709
|
-
class
|
|
708
|
+
const pt = { ye: new Float32Array([0, -0.5, 0, 0, 1, -0.5, 1, 0, 0, 0.5, 0, 1, 0, 0.5, 0, 1, 1, -0.5, 1, 0, 1, 0.5, 1, 1]), Rs: 6, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
|
|
709
|
+
class vt extends S {
|
|
710
710
|
constructor(t, e) {
|
|
711
|
-
super(t, e, E.LINE,
|
|
711
|
+
super(t, e, E.LINE, pt);
|
|
712
712
|
}
|
|
713
|
-
|
|
714
|
-
const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = t.thickness || e.I || 1, o = t.x1 + i / 2, c = t.y1 + s / 2, l = o - r / 2,
|
|
715
|
-
return this.
|
|
713
|
+
Es(t, e) {
|
|
714
|
+
const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = t.thickness || e.I || 1, o = t.x1 + i / 2, c = t.y1 + s / 2, l = o - r / 2, f = c, u = this.Ce(l, f, r, n, e);
|
|
715
|
+
return this.xe(u, o, c), this.ve.Es(u);
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
const
|
|
718
|
+
const yt = { ye: function(a = 32) {
|
|
719
719
|
const t = [], e = 2 * Math.PI / a;
|
|
720
720
|
for (let i = 0; i < a; i++) {
|
|
721
|
-
const s = i * e, r = (i + 1) % a * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1),
|
|
722
|
-
t.push(0, 0, 0.5, 0.5, n, o, c, l,
|
|
721
|
+
const s = i * e, r = (i + 1) % a * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1), f = Math.cos(r), u = Math.sin(r), m = 0.5 * (f + 1), p = 0.5 * (u + 1);
|
|
722
|
+
t.push(0, 0, 0.5, 0.5, n, o, c, l, f, u, m, p);
|
|
723
723
|
}
|
|
724
724
|
return new Float32Array(t);
|
|
725
|
-
}(32),
|
|
726
|
-
class
|
|
725
|
+
}(32), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
|
|
726
|
+
class Et extends S {
|
|
727
727
|
constructor(t, e) {
|
|
728
|
-
super(t, e, E.ELLIPSE,
|
|
728
|
+
super(t, e, E.ELLIPSE, yt);
|
|
729
729
|
}
|
|
730
|
-
|
|
731
|
-
const i = this.
|
|
732
|
-
return this.
|
|
730
|
+
Es(t, e) {
|
|
731
|
+
const i = this.Ce(t.x, t.y, t.width, t.height, e);
|
|
732
|
+
return this.xe(i, t.x, t.y), this.ve.Es(i);
|
|
733
733
|
}
|
|
734
734
|
}
|
|
735
|
-
let
|
|
735
|
+
let xt = { ye: function(a) {
|
|
736
736
|
const t = [];
|
|
737
737
|
for (let e = 0; e < a; e++) {
|
|
738
738
|
const i = e / a, s = (e + 1) / a;
|
|
739
739
|
t.push(i, 0, i, 0, i, 1, i, 1, s, 1, s, 1);
|
|
740
740
|
}
|
|
741
741
|
return new Float32Array(t);
|
|
742
|
-
}(32),
|
|
743
|
-
class
|
|
742
|
+
}(32), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
|
|
743
|
+
class wt extends S {
|
|
744
744
|
constructor(t, e) {
|
|
745
|
-
super(t, e, E.ARC,
|
|
745
|
+
super(t, e, E.ARC, xt);
|
|
746
746
|
}
|
|
747
|
-
|
|
748
|
-
const i = t.x - t.width / 2, s = t.y - t.height / 2, r = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.
|
|
749
|
-
return this.
|
|
747
|
+
Es(t, e) {
|
|
748
|
+
const i = t.x - t.width / 2, s = t.y - t.height / 2, r = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.Ce(i, s, t.width, t.height, e);
|
|
749
|
+
return this.xe(o, t.x, t.y), o.Qs = [r, n], this.ve.Es(o);
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
|
-
const
|
|
753
|
-
class
|
|
752
|
+
const Tt = { ye: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Rs: 3, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
|
|
753
|
+
class Rt extends S {
|
|
754
754
|
constructor(t, e) {
|
|
755
|
-
super(t, e, E.TRIANGLE,
|
|
755
|
+
super(t, e, E.TRIANGLE, Tt);
|
|
756
756
|
}
|
|
757
|
-
|
|
758
|
-
const i = Math.min(t.x1, t.x2, t.x3), s = Math.max(t.x1, t.x2, t.x3), r = Math.min(t.y1, t.y2, t.y3), n = s - i, o = Math.max(t.y1, t.y2, t.y3) - r, c = this.
|
|
759
|
-
return this.
|
|
757
|
+
Es(t, e) {
|
|
758
|
+
const i = Math.min(t.x1, t.x2, t.x3), s = Math.max(t.x1, t.x2, t.x3), r = Math.min(t.y1, t.y2, t.y3), n = s - i, o = Math.max(t.y1, t.y2, t.y3) - r, c = this.Ce(i, r, n, o, e), l = i + 0.5 * n, f = r + o * (1 / 3);
|
|
759
|
+
return this.xe(c, l, f), this.ve.Es(c);
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
|
-
function
|
|
762
|
+
function $(a, t, e, i, s) {
|
|
763
763
|
const r = 1 - a, n = r * r, o = a * a;
|
|
764
764
|
return n * r * t + 3 * n * a * e + 3 * r * o * i + o * a * s;
|
|
765
765
|
}
|
|
766
|
-
const
|
|
766
|
+
const bt = { ye: function(a = 16) {
|
|
767
767
|
const t = [];
|
|
768
768
|
for (let e = 0; e < a; e++) {
|
|
769
769
|
const i = e / a, s = (e + 1) / a;
|
|
770
770
|
t.push(i, -0.5, i, 0), t.push(s, -0.5, s, 0), t.push(i, 0.5, i, 1), t.push(i, 0.5, i, 1), t.push(s, -0.5, s, 0), t.push(s, 0.5, s, 1);
|
|
771
771
|
}
|
|
772
772
|
return new Float32Array(t);
|
|
773
|
-
}(16),
|
|
774
|
-
class
|
|
773
|
+
}(16), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
|
|
774
|
+
class Ct extends S {
|
|
775
775
|
constructor(t, e) {
|
|
776
|
-
super(t, e, E.BEZIER_CURVE,
|
|
776
|
+
super(t, e, E.BEZIER_CURVE, bt);
|
|
777
777
|
}
|
|
778
|
-
|
|
779
|
-
const i = e.I || 1, s =
|
|
780
|
-
return this.
|
|
778
|
+
Es(t, e) {
|
|
779
|
+
const i = e.I || 1, s = $(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = $(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = this.Ce(0, 0, 1, i, e);
|
|
780
|
+
return this.xe(n, s, r), n.se = [t.x1, t.y1], n.Js = [t.cp1x, t.cp1y], n.te = [t.cp2x, t.cp2y], n.ee = [t.x2, t.y2], this.ve.Es(n);
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
|
-
class
|
|
783
|
+
class Ut {
|
|
784
784
|
constructor(t) {
|
|
785
|
-
h(this, "
|
|
786
|
-
h(this, "
|
|
787
|
-
h(this, "
|
|
788
|
-
h(this, "
|
|
789
|
-
h(this, "
|
|
790
|
-
h(this, "
|
|
791
|
-
h(this, "
|
|
792
|
-
h(this, "
|
|
793
|
-
h(this, "
|
|
794
|
-
h(this, "
|
|
795
|
-
h(this, "
|
|
796
|
-
this.
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
let e = this.
|
|
785
|
+
h(this, "gt");
|
|
786
|
+
h(this, "Me", null);
|
|
787
|
+
h(this, "Fe");
|
|
788
|
+
h(this, "ze", null);
|
|
789
|
+
h(this, "Re", {});
|
|
790
|
+
h(this, "Te", null);
|
|
791
|
+
h(this, "Pe", /* @__PURE__ */ new Map());
|
|
792
|
+
h(this, "Se");
|
|
793
|
+
h(this, "Ee");
|
|
794
|
+
h(this, "$e");
|
|
795
|
+
h(this, "G", []);
|
|
796
|
+
this.gt = t, this.Fe = new lt(t), this.$e = new it(), this.Se = new ft(t, this), this.Ee = new dt(), this.Te = t.createBuffer(), W(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
|
|
797
|
+
}
|
|
798
|
+
De(t) {
|
|
799
|
+
let e = this.Pe.get(t);
|
|
800
800
|
if (e) return e;
|
|
801
|
-
const i = new
|
|
802
|
-
return e = (0, { [E.RECTANGLE]: () => new
|
|
801
|
+
const i = new gt(this.gt);
|
|
802
|
+
return e = (0, { [E.RECTANGLE]: () => new At(this.gt, i), [E.LINE]: () => new vt(this.gt, i), [E.ELLIPSE]: () => new Et(this.gt, i), [E.ARC]: () => new wt(this.gt, i), [E.TRIANGLE]: () => new Rt(this.gt, i), [E.BEZIER_CURVE]: () => new Ct(this.gt, i) }[t])(), this.Pe.set(t, e), e;
|
|
803
803
|
}
|
|
804
|
-
|
|
805
|
-
this
|
|
804
|
+
ke(t) {
|
|
805
|
+
this.Me !== t && (this.Me = t, t.Nt());
|
|
806
806
|
}
|
|
807
|
-
|
|
808
|
-
return this.
|
|
807
|
+
cs(t, e) {
|
|
808
|
+
return this.Fe.cs(t, e);
|
|
809
809
|
}
|
|
810
|
-
|
|
811
|
-
return this.
|
|
810
|
+
es() {
|
|
811
|
+
return this.Fe.es();
|
|
812
812
|
}
|
|
813
813
|
Pt() {
|
|
814
|
-
return this.
|
|
814
|
+
return this.Fe.Pt();
|
|
815
815
|
}
|
|
816
|
-
|
|
817
|
-
return this.
|
|
816
|
+
rs() {
|
|
817
|
+
return this.Fe.rs();
|
|
818
818
|
}
|
|
819
|
-
|
|
820
|
-
return this.
|
|
819
|
+
ns() {
|
|
820
|
+
return this.Fe.ns();
|
|
821
821
|
}
|
|
822
|
-
|
|
823
|
-
this.
|
|
822
|
+
Be(t) {
|
|
823
|
+
this.ze = t, t && (this.Re = {});
|
|
824
824
|
}
|
|
825
|
-
|
|
826
|
-
this.
|
|
825
|
+
Kt(t, e) {
|
|
826
|
+
this.Re[t] = e;
|
|
827
827
|
}
|
|
828
|
-
|
|
829
|
-
Object.assign(this.
|
|
828
|
+
Le(t) {
|
|
829
|
+
Object.assign(this.Re, t);
|
|
830
830
|
}
|
|
831
|
-
|
|
832
|
-
return this.
|
|
831
|
+
hs(t) {
|
|
832
|
+
return this.Fe.hs(t);
|
|
833
833
|
}
|
|
834
|
-
|
|
835
|
-
const n = this.
|
|
836
|
-
this.
|
|
834
|
+
Oe(t, e, i, s, r) {
|
|
835
|
+
const n = this.es(), o = { Ue: t.textures[0], Uf: t.textures[1], Ug: t.textures[2], Uh: t.textures[3], Ui: t.textures[4], Uj: [t.width, t.height] };
|
|
836
|
+
this.Ee.Is(e, i, s, r, n, o, this.$e);
|
|
837
837
|
}
|
|
838
|
-
|
|
839
|
-
const n = this.
|
|
840
|
-
this.
|
|
838
|
+
Ge(t, e, i, s, r) {
|
|
839
|
+
const n = this.ns(), o = t.He(), c = { Uk: o.texture, Ul: !!o.invert, Um: !!o.flipX, Un: !!o.flipY, Uo: o.charRotation, Up: o.charColorFixed, Uq: o.charColor, Ur: o.cellColorFixed, Us: o.cellColor, Ut: o.backgroundColor, Uu: o.charCount, Uv: o.charList };
|
|
840
|
+
this.Ee.Is(e, i, s, r, n, c, this.$e);
|
|
841
841
|
}
|
|
842
|
-
|
|
842
|
+
Ie(t, e, i, s) {
|
|
843
843
|
var d;
|
|
844
|
-
const r = this.
|
|
845
|
-
r.bindBuffer(r.ARRAY_BUFFER, this.
|
|
846
|
-
const
|
|
847
|
-
|
|
844
|
+
const r = this.gt, n = r.canvas.width, o = r.canvas.height, c = t / n * 2 - 1, l = (t + i) / n * 2 - 1, f = 1 - e / o * 2, u = 1 - (e + s) / o * 2, m = new Float32Array([c, u, l, u, c, f, l, u, l, f, c, f]);
|
|
845
|
+
r.bindBuffer(r.ARRAY_BUFFER, this.Te), r.bufferData(r.ARRAY_BUFFER, m, r.DYNAMIC_DRAW);
|
|
846
|
+
const p = ((d = this.Me) == null ? void 0 : d.Zt) || r.getParameter(r.CURRENT_PROGRAM), g = p ? r.getAttribLocation(p, "a_position") : -1;
|
|
847
|
+
g !== -1 && (r.enableVertexAttribArray(g), r.vertexAttribPointer(g, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), g !== -1 && r.disableVertexAttribArray(g);
|
|
848
848
|
}
|
|
849
|
-
|
|
850
|
-
this.
|
|
849
|
+
Ne(t, e, i, s) {
|
|
850
|
+
this.ze ? (this.Ee.Is(t, e, i, s, this.ze, { ...this.Re }, this.$e), this.ze = null, this.Re = {}) : this.Ee.Hs(t, e, i, s, this.$e);
|
|
851
851
|
}
|
|
852
|
-
|
|
853
|
-
this.
|
|
852
|
+
Xe(t, e, i, s) {
|
|
853
|
+
this.Ee.Ns(t, e, i, s, this.$e.lineWeight, this.$e);
|
|
854
854
|
}
|
|
855
|
-
|
|
856
|
-
this.
|
|
855
|
+
We(t, e, i, s) {
|
|
856
|
+
this.Ee.Xs(t, e, i, s, this.$e);
|
|
857
857
|
}
|
|
858
|
-
|
|
859
|
-
this.
|
|
858
|
+
Ke(t, e, i, s, r, n) {
|
|
859
|
+
this.Ee.Ks(t, e, i, s, r, n, this.$e);
|
|
860
860
|
}
|
|
861
|
-
|
|
862
|
-
const l = this.
|
|
863
|
-
this.
|
|
861
|
+
Ye(t, e, i, s, r, n, o, c) {
|
|
862
|
+
const l = this.$e.lineWeight;
|
|
863
|
+
this.Ee.Ys(t, e, i, s, r, n, o, c, l, this.$e);
|
|
864
864
|
}
|
|
865
|
-
|
|
866
|
-
return new
|
|
865
|
+
je(t, e, i = 1, s = {}) {
|
|
866
|
+
return new K(this.gt, t, e, i, s, this, !0);
|
|
867
867
|
}
|
|
868
|
-
|
|
869
|
-
this.
|
|
868
|
+
Ve(t, e, i, s, r, n) {
|
|
869
|
+
this.Ee.Ws(t, e, i, s, r, n, this.$e);
|
|
870
870
|
}
|
|
871
|
-
|
|
872
|
-
this.
|
|
871
|
+
qe(t, e = t, i = t, s = 255) {
|
|
872
|
+
this.$e.ft(t, e, i, s), this.js(t / 255, e / 255, i / 255, s / 255);
|
|
873
873
|
}
|
|
874
|
-
|
|
875
|
-
this.
|
|
874
|
+
js(t = 0, e = 0, i = 0, s = 0) {
|
|
875
|
+
this.gt.clearColor(t, e, i, s), this.gt.clear(this.gt.COLOR_BUFFER_BIT);
|
|
876
876
|
}
|
|
877
|
-
|
|
878
|
-
this.
|
|
877
|
+
Ze() {
|
|
878
|
+
this.gt.viewport(0, 0, this.gt.canvas.width, this.gt.canvas.height), W(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
|
|
879
879
|
}
|
|
880
880
|
get context() {
|
|
881
|
-
return this.
|
|
881
|
+
return this.gt;
|
|
882
882
|
}
|
|
883
883
|
get state() {
|
|
884
|
-
return this
|
|
884
|
+
return this.$e;
|
|
885
885
|
}
|
|
886
886
|
Et(t) {
|
|
887
|
-
this.
|
|
887
|
+
this.G.push(this.$e), this.$e = t;
|
|
888
888
|
}
|
|
889
|
-
|
|
890
|
-
const t = this.
|
|
891
|
-
t && (this
|
|
889
|
+
$t() {
|
|
890
|
+
const t = this.G.pop();
|
|
891
|
+
t && (this.$e = t);
|
|
892
892
|
}
|
|
893
893
|
St(t) {
|
|
894
|
-
const e = t, i = H(this.
|
|
895
|
-
this.
|
|
894
|
+
const e = t, i = H(this.gt) ?? this.gt.getParameter(this.gt.VIEWPORT), s = { shader: e, gl: this.gt, viewport: i };
|
|
895
|
+
this.ke(e);
|
|
896
896
|
const r = /* @__PURE__ */ new Set();
|
|
897
|
-
for (const n of this.
|
|
898
|
-
for (const n of r) n !== E.CUSTOM && this.
|
|
899
|
-
this.
|
|
897
|
+
for (const n of this.Ee) n.type === E.CUSTOM ? r.add(E.RECTANGLE) : r.add(n.type);
|
|
898
|
+
for (const n of r) n !== E.CUSTOM && this.De(n);
|
|
899
|
+
this.Se.ws(s, this.Ee, this.Pe), this.Ee.js();
|
|
900
900
|
}
|
|
901
|
-
|
|
902
|
-
this.
|
|
903
|
-
for (const t of this.
|
|
904
|
-
this.
|
|
901
|
+
Dt() {
|
|
902
|
+
this.gt.deleteBuffer(this.Te), this.Ee.js();
|
|
903
|
+
for (const t of this.Pe.values()) t.Dt();
|
|
904
|
+
this.Fe.Dt(), this.Se.Dt();
|
|
905
905
|
}
|
|
906
906
|
}
|
|
907
907
|
const w = { readShort: (a, t) => (w.t.uint16[0] = a[t] << 8 | a[t + 1], w.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
|
|
@@ -928,14 +928,14 @@ const w = { readShort: (a, t) => (w.t.uint16[0] = a[t] << 8 | a[t + 1], w.t.int1
|
|
|
928
928
|
function Y(a) {
|
|
929
929
|
return a + 3 & -4;
|
|
930
930
|
}
|
|
931
|
-
function
|
|
931
|
+
function k(a, t, e) {
|
|
932
932
|
const i = t + e;
|
|
933
933
|
let s = 0;
|
|
934
934
|
const r = w.t;
|
|
935
935
|
for (let n = t; n < i; n += 4) r.uint8[3] = a[n] || 0, r.uint8[2] = a[n + 1] || 0, r.uint8[1] = a[n + 2] || 0, r.uint8[0] = a[n + 3] || 0, s = s + (r.uint32[0] >>> 0) >>> 0;
|
|
936
936
|
return s >>> 0;
|
|
937
937
|
}
|
|
938
|
-
class
|
|
938
|
+
class Bt {
|
|
939
939
|
constructor(t) {
|
|
940
940
|
h(this, "b");
|
|
941
941
|
h(this, "p", 0);
|
|
@@ -958,7 +958,7 @@ class Gt {
|
|
|
958
958
|
return this.p;
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
|
-
function
|
|
961
|
+
function z(a) {
|
|
962
962
|
let t = 32, e = 0;
|
|
963
963
|
for (const o of a) o && (o < t && (t = o), o > e && (e = o));
|
|
964
964
|
if (e === 0) return { min: 0, max: 0, table: /* @__PURE__ */ new Map() };
|
|
@@ -973,8 +973,8 @@ function I(a) {
|
|
|
973
973
|
const c = a[o];
|
|
974
974
|
if (!c) continue;
|
|
975
975
|
const l = s[c]++;
|
|
976
|
-
let
|
|
977
|
-
|
|
976
|
+
let f = n.get(c);
|
|
977
|
+
f || (f = [], n.set(c, f)), f[Ft(l, c)] = o;
|
|
978
978
|
}
|
|
979
979
|
return { min: t, max: e, table: n };
|
|
980
980
|
}
|
|
@@ -990,12 +990,12 @@ function V(a, t) {
|
|
|
990
990
|
}
|
|
991
991
|
throw Error("Invalid Huffman code");
|
|
992
992
|
}
|
|
993
|
-
function
|
|
993
|
+
function Ft(a, t) {
|
|
994
994
|
let e = 0;
|
|
995
995
|
for (let i = 0; i < t; i++) e = e << 1 | 1 & a, a >>>= 1;
|
|
996
996
|
return e >>> 0;
|
|
997
997
|
}
|
|
998
|
-
function
|
|
998
|
+
function Lt(a) {
|
|
999
999
|
if (a.length < 2) throw Error("ZLIB data too short");
|
|
1000
1000
|
const t = a[0], e = a[1];
|
|
1001
1001
|
if ((15 & t) != 8) throw Error("Unsupported ZLIB compression method");
|
|
@@ -1004,153 +1004,153 @@ function _t(a) {
|
|
|
1004
1004
|
32 & e && (i += 4);
|
|
1005
1005
|
const s = [];
|
|
1006
1006
|
return function(r, n) {
|
|
1007
|
-
const o = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258], c = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], l = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577],
|
|
1008
|
-
let
|
|
1009
|
-
for (; !
|
|
1010
|
-
|
|
1011
|
-
const
|
|
1012
|
-
if (
|
|
1007
|
+
const o = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258], c = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], l = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577], f = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
|
|
1008
|
+
let u = 0;
|
|
1009
|
+
for (; !u; ) {
|
|
1010
|
+
u = r.readBits(1);
|
|
1011
|
+
const m = r.readBits(2);
|
|
1012
|
+
if (m === 0) {
|
|
1013
1013
|
r.alignToByte();
|
|
1014
|
-
const
|
|
1015
|
-
if ((65535 & (65535 ^
|
|
1016
|
-
for (let
|
|
1014
|
+
const p = r.readBits(16);
|
|
1015
|
+
if ((65535 & (65535 ^ p)) !== r.readBits(16)) throw Error("DEFLATE uncompressed LEN/NLEN mismatch");
|
|
1016
|
+
for (let g = 0; g < p; g++) n.push(r.readBits(8));
|
|
1017
1017
|
} else {
|
|
1018
|
-
if (
|
|
1018
|
+
if (m !== 1 && m !== 2) throw Error("Unsupported DEFLATE type");
|
|
1019
1019
|
{
|
|
1020
|
-
let
|
|
1021
|
-
if (
|
|
1020
|
+
let p, g;
|
|
1021
|
+
if (m === 1) {
|
|
1022
1022
|
const d = Array(288).fill(0);
|
|
1023
|
-
for (let
|
|
1024
|
-
for (let
|
|
1025
|
-
for (let
|
|
1026
|
-
for (let
|
|
1027
|
-
|
|
1023
|
+
for (let v = 0; v <= 143; v++) d[v] = 8;
|
|
1024
|
+
for (let v = 144; v <= 255; v++) d[v] = 9;
|
|
1025
|
+
for (let v = 256; v <= 279; v++) d[v] = 7;
|
|
1026
|
+
for (let v = 280; v <= 287; v++) d[v] = 8;
|
|
1027
|
+
p = z(d), g = z(Array(32).fill(5));
|
|
1028
1028
|
} else {
|
|
1029
|
-
const d = r.readBits(5) + 257,
|
|
1030
|
-
for (let
|
|
1031
|
-
const
|
|
1032
|
-
for (; T.length < d +
|
|
1033
|
-
const
|
|
1034
|
-
if (
|
|
1035
|
-
else if (
|
|
1036
|
-
const
|
|
1037
|
-
for (let
|
|
1038
|
-
} else if (
|
|
1039
|
-
const
|
|
1040
|
-
for (let
|
|
1029
|
+
const d = r.readBits(5) + 257, v = r.readBits(5) + 1, A = r.readBits(4) + 4, x = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], y = Array(19).fill(0);
|
|
1030
|
+
for (let B = 0; B < A; B++) y[x[B]] = r.readBits(3);
|
|
1031
|
+
const U = z(y), T = [];
|
|
1032
|
+
for (; T.length < d + v; ) {
|
|
1033
|
+
const B = V(r, U);
|
|
1034
|
+
if (B <= 15) T.push(B);
|
|
1035
|
+
else if (B === 16) {
|
|
1036
|
+
const I = r.readBits(2) + 3, M = T[T.length - 1] || 0;
|
|
1037
|
+
for (let J = 0; J < I; J++) T.push(M);
|
|
1038
|
+
} else if (B === 17) {
|
|
1039
|
+
const I = r.readBits(3) + 3;
|
|
1040
|
+
for (let M = 0; M < I; M++) T.push(0);
|
|
1041
1041
|
} else {
|
|
1042
|
-
if (
|
|
1042
|
+
if (B !== 18) throw Error("Invalid code length symbol");
|
|
1043
1043
|
{
|
|
1044
|
-
const
|
|
1045
|
-
for (let
|
|
1044
|
+
const I = r.readBits(7) + 11;
|
|
1045
|
+
for (let M = 0; M < I; M++) T.push(0);
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
1048
|
}
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1049
|
+
const R = T.slice(0, d), F = T.slice(d, d + v);
|
|
1050
|
+
p = z(R), g = z(F);
|
|
1051
1051
|
}
|
|
1052
1052
|
for (; ; ) {
|
|
1053
|
-
const d = V(r,
|
|
1053
|
+
const d = V(r, p);
|
|
1054
1054
|
if (d < 256) n.push(d);
|
|
1055
1055
|
else {
|
|
1056
1056
|
if (d === 256) break;
|
|
1057
1057
|
if (d > 256 && d < 286) {
|
|
1058
|
-
const
|
|
1059
|
-
let
|
|
1060
|
-
const x = c[
|
|
1061
|
-
x && (
|
|
1062
|
-
const y = V(r,
|
|
1058
|
+
const v = d - 257;
|
|
1059
|
+
let A = o[v];
|
|
1060
|
+
const x = c[v];
|
|
1061
|
+
x && (A += r.readBits(x));
|
|
1062
|
+
const y = V(r, g);
|
|
1063
1063
|
if (y >= 30) throw Error("Invalid distance symbol");
|
|
1064
|
-
let
|
|
1065
|
-
const T =
|
|
1066
|
-
T && (
|
|
1067
|
-
const
|
|
1068
|
-
if (
|
|
1069
|
-
for (let
|
|
1064
|
+
let U = l[y];
|
|
1065
|
+
const T = f[y];
|
|
1066
|
+
T && (U += r.readBits(T));
|
|
1067
|
+
const R = n.length - U;
|
|
1068
|
+
if (R < 0) throw Error("Invalid distance");
|
|
1069
|
+
for (let F = 0; F < A; F++) n.push(n[R + F] || 0);
|
|
1070
1070
|
} else if (d === 286 || d === 287) throw Error("Reserved length symbol");
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
1075
1075
|
}
|
|
1076
|
-
}(new
|
|
1076
|
+
}(new Bt(a.subarray(i)), s), new Uint8Array(s);
|
|
1077
1077
|
}
|
|
1078
|
-
function
|
|
1078
|
+
function Pt(a) {
|
|
1079
1079
|
const t = w, e = new Uint8Array(a);
|
|
1080
1080
|
if (t.readASCII(e, 0, 4) !== "wOFF") throw Error("Invalid WOFF signature");
|
|
1081
1081
|
const i = t.readUint(e, 4), s = t.readUshort(e, 12), r = t.readUint(e, 16), n = [];
|
|
1082
1082
|
let o = 44;
|
|
1083
|
-
for (let
|
|
1084
|
-
const x = t.readASCII(e, o, 4), y = t.readUint(e, o + 4),
|
|
1085
|
-
n.push({ tag: x, offset: y, compLength:
|
|
1086
|
-
}
|
|
1087
|
-
for (const
|
|
1088
|
-
const x = new Uint8Array(e.buffer,
|
|
1089
|
-
if (
|
|
1090
|
-
else if (
|
|
1091
|
-
const y = new Uint8Array(
|
|
1092
|
-
y.set(
|
|
1093
|
-
} else
|
|
1083
|
+
for (let A = 0; A < s; A++) {
|
|
1084
|
+
const x = t.readASCII(e, o, 4), y = t.readUint(e, o + 4), U = t.readUint(e, o + 8), T = t.readUint(e, o + 12), R = t.readUint(e, o + 16);
|
|
1085
|
+
n.push({ tag: x, offset: y, compLength: U, origLength: T, checksum: R }), o += 20;
|
|
1086
|
+
}
|
|
1087
|
+
for (const A of n) {
|
|
1088
|
+
const x = new Uint8Array(e.buffer, A.offset, A.compLength);
|
|
1089
|
+
if (A.compLength === A.origLength) A.data = new Uint8Array(x);
|
|
1090
|
+
else if (A.data = Lt(x), A.data.length !== A.origLength) if (A.data.length < A.origLength) {
|
|
1091
|
+
const y = new Uint8Array(A.origLength);
|
|
1092
|
+
y.set(A.data), A.data = y;
|
|
1093
|
+
} else A.data = A.data.subarray(0, A.origLength);
|
|
1094
1094
|
}
|
|
1095
1095
|
const c = s;
|
|
1096
|
-
let l = 1,
|
|
1097
|
-
for (; l << 1 <= c; ) l <<= 1,
|
|
1098
|
-
const
|
|
1099
|
-
let
|
|
1100
|
-
const
|
|
1101
|
-
for (const
|
|
1102
|
-
const d = new Uint8Array(Math.max(r || 0,
|
|
1103
|
-
t.writeUint(d, 0, i), t.writeUshort(d, 4, c), t.writeUshort(d, 6,
|
|
1104
|
-
let
|
|
1105
|
-
for (const
|
|
1106
|
-
t.writeASCII(d,
|
|
1107
|
-
let x =
|
|
1108
|
-
if (
|
|
1096
|
+
let l = 1, f = 0;
|
|
1097
|
+
for (; l << 1 <= c; ) l <<= 1, f++;
|
|
1098
|
+
const u = 16 * l, m = 16 * c - u;
|
|
1099
|
+
let p = 12 + 16 * c;
|
|
1100
|
+
const g = {};
|
|
1101
|
+
for (const A of n) g[A.tag] = p, p = Y(p + A.data.length);
|
|
1102
|
+
const d = new Uint8Array(Math.max(r || 0, p));
|
|
1103
|
+
t.writeUint(d, 0, i), t.writeUshort(d, 4, c), t.writeUshort(d, 6, u), t.writeUshort(d, 8, f), t.writeUshort(d, 10, m);
|
|
1104
|
+
let v = 12;
|
|
1105
|
+
for (const A of n) {
|
|
1106
|
+
t.writeASCII(d, v, A.tag), v += 4;
|
|
1107
|
+
let x = A.data;
|
|
1108
|
+
if (A.tag === "head" && x.length >= 12) {
|
|
1109
1109
|
const y = new Uint8Array(x);
|
|
1110
1110
|
t.writeUint(y, 8, 0);
|
|
1111
|
-
const
|
|
1112
|
-
t.writeUint(d,
|
|
1111
|
+
const U = k(y, 0, Y(y.length));
|
|
1112
|
+
t.writeUint(d, v, U), v += 4;
|
|
1113
1113
|
} else {
|
|
1114
|
-
const y =
|
|
1115
|
-
t.writeUint(d,
|
|
1114
|
+
const y = k(x, 0, Y(x.length));
|
|
1115
|
+
t.writeUint(d, v, y), v += 4;
|
|
1116
1116
|
}
|
|
1117
|
-
t.writeUint(d,
|
|
1117
|
+
t.writeUint(d, v, g[A.tag]), v += 4, t.writeUint(d, v, A.data.length), v += 4;
|
|
1118
1118
|
}
|
|
1119
|
-
for (const
|
|
1120
|
-
const x =
|
|
1121
|
-
d.set(
|
|
1119
|
+
for (const A of n) {
|
|
1120
|
+
const x = g[A.tag];
|
|
1121
|
+
d.set(A.data, x);
|
|
1122
1122
|
}
|
|
1123
|
-
if (n.find((
|
|
1124
|
-
const
|
|
1125
|
-
const T = w,
|
|
1126
|
-
T.writeUint(y,
|
|
1127
|
-
const
|
|
1128
|
-
return y[
|
|
1129
|
-
}(d,
|
|
1130
|
-
t.writeUint(d,
|
|
1123
|
+
if (n.find((A) => A.tag === "head")) {
|
|
1124
|
+
const A = g.head, x = function(y, U) {
|
|
1125
|
+
const T = w, R = U + 8, F = [y[R], y[R + 1], y[R + 2], y[R + 3]];
|
|
1126
|
+
T.writeUint(y, R, 0);
|
|
1127
|
+
const B = 2981146554 - (k(y, 0, Y(y.length)) >>> 0) >>> 0;
|
|
1128
|
+
return y[R] = F[0], y[R + 1] = F[1], y[R + 2] = F[2], y[R + 3] = F[3], B >>> 0;
|
|
1129
|
+
}(d, A);
|
|
1130
|
+
t.writeUint(d, A + 8, x);
|
|
1131
1131
|
}
|
|
1132
1132
|
return d.buffer;
|
|
1133
1133
|
}
|
|
1134
|
-
const
|
|
1134
|
+
const Mt = { parseTab(a, t, e) {
|
|
1135
1135
|
const i = { tables: [], ids: {}, off: t };
|
|
1136
1136
|
a = new Uint8Array(a.buffer, t, e), t = 0;
|
|
1137
1137
|
const s = w, r = s.readUshort, n = r(a, t += 2);
|
|
1138
1138
|
t += 2;
|
|
1139
1139
|
const o = [];
|
|
1140
1140
|
for (let c = 0; c < n; c++) {
|
|
1141
|
-
const l = r(a, t),
|
|
1141
|
+
const l = r(a, t), f = r(a, t += 2);
|
|
1142
1142
|
t += 2;
|
|
1143
|
-
const
|
|
1143
|
+
const u = s.readUint(a, t);
|
|
1144
1144
|
t += 4;
|
|
1145
|
-
const
|
|
1146
|
-
let
|
|
1147
|
-
if (
|
|
1148
|
-
let
|
|
1149
|
-
|
|
1150
|
-
const d = r(a,
|
|
1151
|
-
|
|
1145
|
+
const m = `p${l}e${f}`;
|
|
1146
|
+
let p = o.indexOf(u);
|
|
1147
|
+
if (p === -1) {
|
|
1148
|
+
let g;
|
|
1149
|
+
p = i.tables.length, o.push(u);
|
|
1150
|
+
const d = r(a, u);
|
|
1151
|
+
g = d === 4 ? this.parse4(a, u) : d === 12 ? this.parse12(a, u) : { format: d }, i.tables.push(g);
|
|
1152
1152
|
}
|
|
1153
|
-
i.ids[
|
|
1153
|
+
i.ids[m] = p;
|
|
1154
1154
|
}
|
|
1155
1155
|
return i;
|
|
1156
1156
|
}, parse4(a, t) {
|
|
@@ -1168,7 +1168,7 @@ const Ot = { parseTab(a, t, e) {
|
|
|
1168
1168
|
const s = new Uint32Array(3 * i);
|
|
1169
1169
|
for (let r = 0; r < 3 * i; r += 3) s[r] = e(a, t + (r << 2)), s[r + 1] = e(a, t + (r << 2) + 4), s[r + 2] = e(a, t + (r << 2) + 8);
|
|
1170
1170
|
return { format: 12, groups: s };
|
|
1171
|
-
} },
|
|
1171
|
+
} }, _t = { parseTab(a, t, e) {
|
|
1172
1172
|
const i = w;
|
|
1173
1173
|
t += 18;
|
|
1174
1174
|
const s = i.readUshort(a, t);
|
|
@@ -1181,7 +1181,7 @@ const Ot = { parseTab(a, t, e) {
|
|
|
1181
1181
|
t += 2;
|
|
1182
1182
|
const c = i.readShort(a, t);
|
|
1183
1183
|
return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(a, t) };
|
|
1184
|
-
} },
|
|
1184
|
+
} }, Dt = { parseTab(a, t, e) {
|
|
1185
1185
|
const i = w;
|
|
1186
1186
|
t += 4;
|
|
1187
1187
|
const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], r = {};
|
|
@@ -1190,16 +1190,16 @@ const Ot = { parseTab(a, t, e) {
|
|
|
1190
1190
|
r[o] = c(a, t + 2 * n);
|
|
1191
1191
|
}
|
|
1192
1192
|
return r;
|
|
1193
|
-
} },
|
|
1193
|
+
} }, Ot = { parseTab(a, t, e, i) {
|
|
1194
1194
|
const s = w, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
|
|
1195
|
-
let l = 0,
|
|
1196
|
-
for (;
|
|
1197
|
-
for (;
|
|
1195
|
+
let l = 0, f = 0, u = 0;
|
|
1196
|
+
for (; u < c; ) l = s.readUshort(a, t + (u << 2)), f = s.readShort(a, t + (u << 2) + 2), r.push(l), n.push(f), u++;
|
|
1197
|
+
for (; u < o; ) r.push(l), n.push(f), u++;
|
|
1198
1198
|
return { aWidth: r, lsBearing: n };
|
|
1199
|
-
} },
|
|
1199
|
+
} }, tt = { cmap: Mt, head: _t, hhea: Dt, maxp: { parseTab(a, t, e) {
|
|
1200
1200
|
const i = w;
|
|
1201
1201
|
return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
|
|
1202
|
-
} }, hmtx:
|
|
1202
|
+
} }, hmtx: Ot, loca: { parseTab(a, t, e, i) {
|
|
1203
1203
|
const s = w, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
|
|
1204
1204
|
if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(a, t + (c << 1)) << 1);
|
|
1205
1205
|
else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(a, t + (c << 2)));
|
|
@@ -1208,56 +1208,56 @@ const Ot = { parseTab(a, t, e) {
|
|
|
1208
1208
|
const s = [], r = i.maxp.numGlyphs;
|
|
1209
1209
|
for (let n = 0; n < r; n++) s.push(null);
|
|
1210
1210
|
return s;
|
|
1211
|
-
},
|
|
1212
|
-
const e = w, i = a.
|
|
1211
|
+
}, Qe(a, t) {
|
|
1212
|
+
const e = w, i = a.Je, s = a.loca;
|
|
1213
1213
|
if (s[t] === s[t + 1]) return null;
|
|
1214
|
-
const r =
|
|
1214
|
+
const r = P.findTable(i, "glyf", a.ti);
|
|
1215
1215
|
if (!r) return null;
|
|
1216
1216
|
let n = r[0] + s[t];
|
|
1217
1217
|
const o = {};
|
|
1218
1218
|
if (o.noc = e.readShort(i, n), n += 2, o.xMin = e.readShort(i, n), n += 2, o.yMin = e.readShort(i, n), n += 2, o.xMax = e.readShort(i, n), n += 2, o.yMax = e.readShort(i, n), n += 2, o.xMin >= o.xMax || o.yMin >= o.yMax) return null;
|
|
1219
1219
|
if (o.noc > 0) {
|
|
1220
1220
|
o.endPts = [];
|
|
1221
|
-
for (let
|
|
1221
|
+
for (let m = 0; m < o.noc; m++) o.endPts.push(e.readUshort(i, n)), n += 2;
|
|
1222
1222
|
const c = e.readUshort(i, n);
|
|
1223
1223
|
if (n += 2, i.length - n < c) return null;
|
|
1224
1224
|
n += c;
|
|
1225
1225
|
const l = o.endPts[o.noc - 1] + 1;
|
|
1226
1226
|
o.flags = [];
|
|
1227
|
-
for (let
|
|
1228
|
-
const
|
|
1229
|
-
if (n++, o.flags.push(
|
|
1230
|
-
const
|
|
1227
|
+
for (let m = 0; m < l; m++) {
|
|
1228
|
+
const p = i[n];
|
|
1229
|
+
if (n++, o.flags.push(p), 8 & p) {
|
|
1230
|
+
const g = i[n];
|
|
1231
1231
|
n++;
|
|
1232
|
-
for (let d = 0; d <
|
|
1232
|
+
for (let d = 0; d < g; d++) o.flags.push(p), m++;
|
|
1233
1233
|
}
|
|
1234
1234
|
}
|
|
1235
1235
|
o.xs = [];
|
|
1236
|
-
for (let
|
|
1237
|
-
const
|
|
1238
|
-
2 &
|
|
1236
|
+
for (let m = 0; m < l; m++) {
|
|
1237
|
+
const p = o.flags[m], g = !!(16 & p);
|
|
1238
|
+
2 & p ? (o.xs.push(g ? i[n] : -i[n]), n++) : g ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
|
|
1239
1239
|
}
|
|
1240
1240
|
o.ys = [];
|
|
1241
|
-
for (let
|
|
1242
|
-
const
|
|
1243
|
-
4 &
|
|
1241
|
+
for (let m = 0; m < l; m++) {
|
|
1242
|
+
const p = o.flags[m], g = !!(32 & p);
|
|
1243
|
+
4 & p ? (o.ys.push(g ? i[n] : -i[n]), n++) : g ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
|
|
1244
1244
|
}
|
|
1245
|
-
let
|
|
1246
|
-
for (let
|
|
1245
|
+
let f = 0, u = 0;
|
|
1246
|
+
for (let m = 0; m < l; m++) f += o.xs[m], u += o.ys[m], o.xs[m] = f, o.ys[m] = u;
|
|
1247
1247
|
} else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
|
|
1248
1248
|
return o;
|
|
1249
|
-
} } },
|
|
1249
|
+
} } }, P = { parse(a) {
|
|
1250
1250
|
const t = new Uint8Array(a), e = w.readASCII(t, 0, 4);
|
|
1251
|
-
if (e === "wOFF") a =
|
|
1251
|
+
if (e === "wOFF") a = Pt(a);
|
|
1252
1252
|
else if (e === "wOF2") throw Error("WOFF2 is not supported in this build (Brotli + WOFF2 transforms required)");
|
|
1253
1253
|
return [((i, s, r, n) => {
|
|
1254
|
-
const o =
|
|
1254
|
+
const o = tt, c = { Je: i, si: s, ti: r };
|
|
1255
1255
|
for (const l in o) {
|
|
1256
|
-
const
|
|
1257
|
-
if (
|
|
1258
|
-
const [
|
|
1259
|
-
let
|
|
1260
|
-
|
|
1256
|
+
const f = l, u = P.findTable(i, f, r);
|
|
1257
|
+
if (u) {
|
|
1258
|
+
const [m, p] = u;
|
|
1259
|
+
let g = n[m];
|
|
1260
|
+
g == null && (g = o[f].parseTab(i, m, p, c), n[m] = g), c[f] = g;
|
|
1261
1261
|
}
|
|
1262
1262
|
}
|
|
1263
1263
|
return c;
|
|
@@ -1273,32 +1273,32 @@ const Ot = { parseTab(a, t, e) {
|
|
|
1273
1273
|
r += 16;
|
|
1274
1274
|
}
|
|
1275
1275
|
return null;
|
|
1276
|
-
}, T:
|
|
1277
|
-
class
|
|
1278
|
-
|
|
1276
|
+
}, T: tt, B: w };
|
|
1277
|
+
class St {
|
|
1278
|
+
ei(t) {
|
|
1279
1279
|
var i;
|
|
1280
1280
|
const e = [];
|
|
1281
1281
|
return (i = t.cmap) != null && i.tables ? (t.cmap.tables.forEach((s) => {
|
|
1282
1282
|
if (s.format === 4) {
|
|
1283
|
-
const r = this.
|
|
1283
|
+
const r = this.ii(s);
|
|
1284
1284
|
e.push(...r);
|
|
1285
1285
|
} else if (s.format === 12) {
|
|
1286
|
-
const r = this.
|
|
1286
|
+
const r = this.ri(s);
|
|
1287
1287
|
e.push(...r);
|
|
1288
1288
|
}
|
|
1289
1289
|
}), [...new Set(e)]) : [];
|
|
1290
1290
|
}
|
|
1291
|
-
|
|
1292
|
-
return t.filter((e) => this.
|
|
1291
|
+
ni(t) {
|
|
1292
|
+
return t.filter((e) => this.oi(e));
|
|
1293
1293
|
}
|
|
1294
|
-
|
|
1294
|
+
ii(t) {
|
|
1295
1295
|
const e = [];
|
|
1296
1296
|
if (!(t.startCount && t.endCount && t.idRangeOffset && t.idDelta)) return e;
|
|
1297
1297
|
for (let i = 0; i < t.startCount.length; i++) {
|
|
1298
1298
|
const s = t.startCount[i], r = t.endCount[i];
|
|
1299
1299
|
if (s !== 65535 || r !== 65535) {
|
|
1300
1300
|
for (let n = s; n <= r; n++)
|
|
1301
|
-
if (this.
|
|
1301
|
+
if (this.hi(t, n, i) > 0) try {
|
|
1302
1302
|
const o = String.fromCodePoint(n);
|
|
1303
1303
|
e.push(o);
|
|
1304
1304
|
} catch {
|
|
@@ -1307,7 +1307,7 @@ class Xt {
|
|
|
1307
1307
|
}
|
|
1308
1308
|
return e;
|
|
1309
1309
|
}
|
|
1310
|
-
|
|
1310
|
+
ri(t) {
|
|
1311
1311
|
const e = [];
|
|
1312
1312
|
if (!t.groups) return e;
|
|
1313
1313
|
for (let i = 0; i < t.groups.length; i += 3) {
|
|
@@ -1321,7 +1321,7 @@ class Xt {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
return e;
|
|
1323
1323
|
}
|
|
1324
|
-
|
|
1324
|
+
hi(t, e, i) {
|
|
1325
1325
|
if (t.idRangeOffset[i] === 0) return e + t.idDelta[i] & 65535;
|
|
1326
1326
|
{
|
|
1327
1327
|
const s = t.idRangeOffset[i] / 2 + (e - t.startCount[i]) - (t.startCount.length - i);
|
|
@@ -1332,44 +1332,44 @@ class Xt {
|
|
|
1332
1332
|
}
|
|
1333
1333
|
return 0;
|
|
1334
1334
|
}
|
|
1335
|
-
|
|
1335
|
+
oi(t) {
|
|
1336
1336
|
const e = t.codePointAt(0) || 0;
|
|
1337
1337
|
return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
|
|
1338
1338
|
}
|
|
1339
1339
|
}
|
|
1340
1340
|
class Z {
|
|
1341
1341
|
constructor() {
|
|
1342
|
+
h(this, "ai", /* @__PURE__ */ new Map());
|
|
1342
1343
|
h(this, "ci", /* @__PURE__ */ new Map());
|
|
1343
|
-
h(this, "li", /* @__PURE__ */ new Map());
|
|
1344
1344
|
}
|
|
1345
|
-
|
|
1346
|
-
const i = `${this.
|
|
1347
|
-
if (this.
|
|
1345
|
+
li(t, e) {
|
|
1346
|
+
const i = `${this.ui(t)}_${e}`;
|
|
1347
|
+
if (this.ai.has(i)) return this.ai.get(i);
|
|
1348
1348
|
const s = t.cmap;
|
|
1349
|
-
if (!s || !s.tables) return this.
|
|
1349
|
+
if (!s || !s.tables) return this.ai.set(i, 0), 0;
|
|
1350
1350
|
let r = 0;
|
|
1351
|
-
for (const n of s.tables) if (n.format === 4 ? r = this.
|
|
1352
|
-
return this.
|
|
1351
|
+
for (const n of s.tables) if (n.format === 4 ? r = this.fi(e, n) : n.format === 12 && (r = this.di(e, n)), r > 0) break;
|
|
1352
|
+
return this.ai.set(i, r), r;
|
|
1353
1353
|
}
|
|
1354
1354
|
_i(t, e) {
|
|
1355
1355
|
const i = e.codePointAt(0);
|
|
1356
|
-
return i === void 0 ? 0 : this.
|
|
1356
|
+
return i === void 0 ? 0 : this.li(t, i);
|
|
1357
1357
|
}
|
|
1358
|
-
|
|
1358
|
+
pi(t, e) {
|
|
1359
1359
|
const i = t.hmtx;
|
|
1360
1360
|
return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
|
|
1361
1361
|
}
|
|
1362
|
-
|
|
1362
|
+
mi(t, e) {
|
|
1363
1363
|
const i = e / t.head.unitsPerEm, s = t.hhea.ascender * i, r = t.hhea.descender * i, n = t.hhea.lineGap * i;
|
|
1364
1364
|
return { ascender: s, descender: r, lineGap: n, lineHeight: s - r + n, unitsPerEm: t.head.unitsPerEm, scale: i };
|
|
1365
1365
|
}
|
|
1366
|
-
|
|
1367
|
-
this.
|
|
1366
|
+
gi() {
|
|
1367
|
+
this.ai.clear(), this.ci.clear();
|
|
1368
1368
|
}
|
|
1369
|
-
|
|
1370
|
-
return `${t.
|
|
1369
|
+
ui(t) {
|
|
1370
|
+
return `${t.ti}_${t.Je.length}`;
|
|
1371
1371
|
}
|
|
1372
|
-
|
|
1372
|
+
fi(t, e) {
|
|
1373
1373
|
const i = e.endCount.length;
|
|
1374
1374
|
let s = -1;
|
|
1375
1375
|
for (let r = 0; r < i; r++) if (t <= e.endCount[r]) {
|
|
@@ -1387,7 +1387,7 @@ class Z {
|
|
|
1387
1387
|
}
|
|
1388
1388
|
return 0;
|
|
1389
1389
|
}
|
|
1390
|
-
|
|
1390
|
+
di(t, e) {
|
|
1391
1391
|
const i = e.groups.length / 3;
|
|
1392
1392
|
for (let s = 0; s < i; s++) {
|
|
1393
1393
|
const r = e.groups[3 * s], n = e.groups[3 * s + 1], o = e.groups[3 * s + 2];
|
|
@@ -1396,43 +1396,43 @@ class Z {
|
|
|
1396
1396
|
return 0;
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
class
|
|
1399
|
+
class It {
|
|
1400
1400
|
constructor(t) {
|
|
1401
|
+
h(this, "Ai");
|
|
1401
1402
|
h(this, "yi");
|
|
1402
|
-
h(this, "Ci");
|
|
1403
1403
|
h(this, "xt");
|
|
1404
|
-
h(this, "
|
|
1405
|
-
this.xt = t, this.
|
|
1404
|
+
h(this, "Ci");
|
|
1405
|
+
this.xt = t, this.Ci = new Z(), this.Ai = document.createElement("canvas"), this.yi = this.Ai.getContext("2d", { willReadFrequently: !0, alpha: !0 });
|
|
1406
1406
|
}
|
|
1407
1407
|
createTextureAtlas(t, e, i, s) {
|
|
1408
|
-
const r = t.length, n = Math.ceil(Math.sqrt(r)), o = Math.ceil(r / n), c = e.width * n, l = e.height * o,
|
|
1409
|
-
this.
|
|
1410
|
-
const
|
|
1411
|
-
return
|
|
1408
|
+
const r = t.length, n = Math.ceil(Math.sqrt(r)), o = Math.ceil(r / n), c = e.width * n, l = e.height * o, f = typeof s == "object" ? s : null;
|
|
1409
|
+
this.wi(c, l), this.bi(t, e, n, i, f);
|
|
1410
|
+
const u = this.xt.je(c, l, 1, { filter: "nearest" });
|
|
1411
|
+
return u.Tt(this.Ai), { framebuffer: u, columns: n, rows: o };
|
|
1412
1412
|
}
|
|
1413
|
-
|
|
1414
|
-
this.
|
|
1413
|
+
wi(t, e) {
|
|
1414
|
+
this.Ai.width = t, this.Ai.height = e, this.Ai.style.width = t + "px", this.Ai.style.height = e + "px", this.yi.imageSmoothingEnabled = !1, this.Ai.style.imageRendering = "pixelated", this.yi.clearRect(0, 0, t, e), this.yi.textBaseline = "top", this.yi.textAlign = "left", this.yi.fillStyle = "white";
|
|
1415
1415
|
}
|
|
1416
|
-
|
|
1416
|
+
bi(t, e, i, s, r) {
|
|
1417
1417
|
const n = s / r.head.unitsPerEm;
|
|
1418
1418
|
for (let o = 0; o < t.length; o++) {
|
|
1419
|
-
const c = o % i, l = Math.floor(o / i),
|
|
1420
|
-
if (!
|
|
1421
|
-
const
|
|
1422
|
-
this.Fi(
|
|
1419
|
+
const c = o % i, l = Math.floor(o / i), f = t[o].character, u = this.xi(r, f);
|
|
1420
|
+
if (!u) continue;
|
|
1421
|
+
const m = f.codePointAt(0) || 0, p = this.Ci.li(r, m), g = this.Mi(r, p) * n, d = c * e.width, v = l * e.height, A = d + 0.5 * e.width, x = v + 0.5 * e.height, y = Math.round(A - 0.5 * e.width), U = Math.round(x - 0.5 * s), T = y + 0.5 * (e.width - g), R = U + r.hhea.ascender * n;
|
|
1422
|
+
this.Fi(u, T, R, n);
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
|
-
|
|
1426
|
-
const i = e.codePointAt(0) || 0, s = this.
|
|
1425
|
+
xi(t, e) {
|
|
1426
|
+
const i = e.codePointAt(0) || 0, s = this.Ci.li(t, i);
|
|
1427
1427
|
if (s === 0) return null;
|
|
1428
1428
|
if (t.glyf && t.glyf[s] !== null) return t.glyf[s];
|
|
1429
|
-
if (
|
|
1430
|
-
const r =
|
|
1429
|
+
if (P && P.T && P.T.glyf) {
|
|
1430
|
+
const r = P.T.glyf.Qe(t, s);
|
|
1431
1431
|
return t.glyf && r && (t.glyf[s] = r), r;
|
|
1432
1432
|
}
|
|
1433
1433
|
return null;
|
|
1434
1434
|
}
|
|
1435
|
-
|
|
1435
|
+
Mi(t, e) {
|
|
1436
1436
|
const i = t.hmtx;
|
|
1437
1437
|
return i && i.aWidth ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
|
|
1438
1438
|
}
|
|
@@ -1440,158 +1440,158 @@ class Yt {
|
|
|
1440
1440
|
if (!t || !t.xs || t.noc === 0) return;
|
|
1441
1441
|
const { xs: r, ys: n, endPts: o, flags: c } = t;
|
|
1442
1442
|
if (!(r && n && o && c)) return;
|
|
1443
|
-
this.
|
|
1443
|
+
this.yi.beginPath();
|
|
1444
1444
|
let l = 0;
|
|
1445
|
-
for (let
|
|
1446
|
-
const
|
|
1447
|
-
if (!(
|
|
1448
|
-
if (
|
|
1449
|
-
const
|
|
1450
|
-
this.
|
|
1451
|
-
let
|
|
1452
|
-
for (;
|
|
1453
|
-
if (1 & c[
|
|
1454
|
-
const d = e + r[
|
|
1455
|
-
this.
|
|
1445
|
+
for (let f = 0; f < o.length; f++) {
|
|
1446
|
+
const u = o[f];
|
|
1447
|
+
if (!(u < l)) {
|
|
1448
|
+
if (u >= l) {
|
|
1449
|
+
const m = e + r[l] * s, p = i - n[l] * s;
|
|
1450
|
+
this.yi.moveTo(m, p);
|
|
1451
|
+
let g = l + 1;
|
|
1452
|
+
for (; g <= u; )
|
|
1453
|
+
if (1 & c[g]) {
|
|
1454
|
+
const d = e + r[g] * s, v = i - n[g] * s;
|
|
1455
|
+
this.yi.lineTo(d, v), g++;
|
|
1456
1456
|
} else {
|
|
1457
|
-
const d = e + r[
|
|
1458
|
-
let
|
|
1459
|
-
if (1 & c[
|
|
1460
|
-
const x = e + r[
|
|
1461
|
-
this.
|
|
1457
|
+
const d = e + r[g] * s, v = i - n[g] * s;
|
|
1458
|
+
let A = g + 1 > u ? l : g + 1;
|
|
1459
|
+
if (1 & c[A]) {
|
|
1460
|
+
const x = e + r[A] * s, y = i - n[A] * s;
|
|
1461
|
+
this.yi.quadraticCurveTo(d, v, x, y), g = A + 1;
|
|
1462
1462
|
} else {
|
|
1463
|
-
const x = (d + (e + r[
|
|
1464
|
-
this.
|
|
1463
|
+
const x = (d + (e + r[A] * s)) / 2, y = (v + (i - n[A] * s)) / 2;
|
|
1464
|
+
this.yi.quadraticCurveTo(d, v, x, y), g = A;
|
|
1465
1465
|
}
|
|
1466
1466
|
}
|
|
1467
|
-
this.
|
|
1467
|
+
this.yi.closePath();
|
|
1468
1468
|
}
|
|
1469
|
-
l =
|
|
1469
|
+
l = u + 1;
|
|
1470
1470
|
}
|
|
1471
1471
|
}
|
|
1472
|
-
this.
|
|
1472
|
+
this.yi.fill();
|
|
1473
1473
|
}
|
|
1474
1474
|
}
|
|
1475
|
-
class
|
|
1475
|
+
class zt {
|
|
1476
1476
|
constructor() {
|
|
1477
|
-
h(this, "
|
|
1478
|
-
this.
|
|
1477
|
+
h(this, "zi");
|
|
1478
|
+
this.zi = new Z();
|
|
1479
1479
|
}
|
|
1480
1480
|
Ri(t, e, i) {
|
|
1481
1481
|
let s = 0;
|
|
1482
|
-
const r = this.
|
|
1482
|
+
const r = this.zi.mi(i, e), n = r.lineHeight;
|
|
1483
1483
|
for (const o of t) {
|
|
1484
|
-
const c = this.
|
|
1484
|
+
const c = this.zi._i(i, o);
|
|
1485
1485
|
if (c === 0) continue;
|
|
1486
|
-
const l = this.
|
|
1486
|
+
const l = this.zi.pi(i, c) * r.scale;
|
|
1487
1487
|
s = Math.max(s, l);
|
|
1488
1488
|
}
|
|
1489
1489
|
return { width: Math.ceil(s), height: Math.ceil(n) };
|
|
1490
1490
|
}
|
|
1491
|
-
|
|
1492
|
-
this.
|
|
1491
|
+
gi() {
|
|
1492
|
+
this.zi.gi();
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
|
-
class
|
|
1495
|
+
class Nt {
|
|
1496
1496
|
constructor() {
|
|
1497
|
-
h(this, "
|
|
1498
|
-
this.
|
|
1497
|
+
h(this, "Ci");
|
|
1498
|
+
this.Ci = new Z();
|
|
1499
1499
|
}
|
|
1500
1500
|
createCharacterObjects(t, e) {
|
|
1501
1501
|
return t.map((i, s) => {
|
|
1502
|
-
const r = i.codePointAt(0) || 0, n = this.
|
|
1502
|
+
const r = i.codePointAt(0) || 0, n = this.Ti(s);
|
|
1503
1503
|
let o = 0;
|
|
1504
1504
|
if (e.hmtx && e.hmtx.aWidth) {
|
|
1505
|
-
const c = this.
|
|
1505
|
+
const c = this.Ci.li(e, r);
|
|
1506
1506
|
c > 0 && e.hmtx.aWidth[c] !== void 0 && (o = e.hmtx.aWidth[c]);
|
|
1507
1507
|
}
|
|
1508
1508
|
return { character: i, unicode: r, color: n, advanceWidth: o };
|
|
1509
1509
|
});
|
|
1510
1510
|
}
|
|
1511
|
-
|
|
1511
|
+
Ti(t) {
|
|
1512
1512
|
return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
|
|
1513
1513
|
}
|
|
1514
1514
|
Pi(t, e) {
|
|
1515
|
-
if (!N.
|
|
1515
|
+
if (!N.m(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
|
|
1516
1516
|
const i = e.find((s) => s.character === t);
|
|
1517
1517
|
return i ? i.color : [0, 0, 0];
|
|
1518
1518
|
}
|
|
1519
1519
|
Si(t, e) {
|
|
1520
|
-
return N.
|
|
1520
|
+
return N.m(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.Pi(i, e) || [0, 0, 0]) : [[0, 0, 0]];
|
|
1521
1521
|
}
|
|
1522
1522
|
}
|
|
1523
|
-
class
|
|
1523
|
+
class Gt {
|
|
1524
1524
|
constructor(t, e = 16) {
|
|
1525
1525
|
h(this, "Ei");
|
|
1526
|
-
h(this, "
|
|
1527
|
-
h(this, "
|
|
1528
|
-
h(this, "
|
|
1529
|
-
h(this, "
|
|
1526
|
+
h(this, "$i", []);
|
|
1527
|
+
h(this, "Di");
|
|
1528
|
+
h(this, "ki", 16);
|
|
1529
|
+
h(this, "Bi", 0);
|
|
1530
1530
|
h(this, "Li", 0);
|
|
1531
1531
|
h(this, "Oi", { width: 0, height: 0 });
|
|
1532
|
+
h(this, "Gi");
|
|
1532
1533
|
h(this, "Hi");
|
|
1533
1534
|
h(this, "Ii");
|
|
1534
1535
|
h(this, "Ni");
|
|
1535
1536
|
h(this, "Xi");
|
|
1536
|
-
|
|
1537
|
-
this.Bi = e, this.Ii = new Xt(), this.Ni = new Yt(t), this.Xi = new kt(), this.Wi = new Ht();
|
|
1537
|
+
this.ki = e, this.Hi = new St(), this.Ii = new It(t), this.Ni = new zt(), this.Xi = new Nt();
|
|
1538
1538
|
}
|
|
1539
|
-
async
|
|
1539
|
+
async Wi(t) {
|
|
1540
1540
|
let e;
|
|
1541
1541
|
if (t) {
|
|
1542
1542
|
const i = await fetch(t);
|
|
1543
|
-
if (!i.ok) throw new
|
|
1543
|
+
if (!i.ok) throw new C(`Failed to load font file: ${i.status} ${i.statusText}`);
|
|
1544
1544
|
e = await i.arrayBuffer();
|
|
1545
1545
|
} else
|
|
1546
1546
|
e = await (await fetch("data:font/woff;base64,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")).arrayBuffer();
|
|
1547
|
-
await this.
|
|
1547
|
+
await this.Ki(e), this.Ei = P.parse(e)[0], await this.Yi();
|
|
1548
1548
|
}
|
|
1549
|
-
|
|
1550
|
-
if (t === void 0) return this.
|
|
1551
|
-
this.
|
|
1552
|
-
const e = this.
|
|
1553
|
-
this.
|
|
1549
|
+
ji(t) {
|
|
1550
|
+
if (t === void 0) return this.ki;
|
|
1551
|
+
this.ki = t, this.Oi = this.Ni.Ri(this.$i.map((i) => i.character), this.ki, this.Ei);
|
|
1552
|
+
const e = this.Ii.createTextureAtlas(this.$i, this.Oi, this.ki, this.Ei);
|
|
1553
|
+
this.Di = e.framebuffer, this.Bi = e.columns, this.Li = e.rows;
|
|
1554
1554
|
}
|
|
1555
|
-
async
|
|
1555
|
+
async Vi(t) {
|
|
1556
1556
|
try {
|
|
1557
1557
|
const e = await fetch(t);
|
|
1558
|
-
if (!e.ok) throw new
|
|
1558
|
+
if (!e.ok) throw new C(`Failed to load font file: ${e.status} ${e.statusText}`);
|
|
1559
1559
|
const i = await e.arrayBuffer();
|
|
1560
|
-
await this.
|
|
1561
|
-
const s =
|
|
1560
|
+
await this.Ki(i);
|
|
1561
|
+
const s = P.parse(i);
|
|
1562
1562
|
if (!s || s.length === 0) throw Error("Failed to parse font file");
|
|
1563
|
-
this.Ei = s[0], await this.
|
|
1563
|
+
this.Ei = s[0], await this.Yi();
|
|
1564
1564
|
} catch (e) {
|
|
1565
|
-
throw new
|
|
1565
|
+
throw new C("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
|
-
async
|
|
1568
|
+
async Ki(t) {
|
|
1569
1569
|
const e = Date.now();
|
|
1570
|
-
this.
|
|
1570
|
+
this.Gi = new FontFace("CustomFont_" + e, t), await this.Gi.load(), document.fonts.add(this.Gi);
|
|
1571
1571
|
}
|
|
1572
|
-
async
|
|
1573
|
-
const t = this.
|
|
1574
|
-
this
|
|
1575
|
-
const i = this.
|
|
1576
|
-
this.
|
|
1572
|
+
async Yi() {
|
|
1573
|
+
const t = this.Hi.ei(this.Ei), e = this.Hi.ni(t);
|
|
1574
|
+
this.$i = this.Xi.createCharacterObjects(e, this.Ei), this.Oi = this.Ni.Ri(e, this.ki, this.Ei);
|
|
1575
|
+
const i = this.Ii.createTextureAtlas(this.$i, this.Oi, this.ki, this.Ei);
|
|
1576
|
+
this.Di = i.framebuffer, this.Bi = i.columns, this.Li = i.rows;
|
|
1577
1577
|
}
|
|
1578
1578
|
Pi(t) {
|
|
1579
|
-
return this.
|
|
1579
|
+
return this.Xi.Pi(t, this.$i);
|
|
1580
1580
|
}
|
|
1581
1581
|
Si(t) {
|
|
1582
|
-
return this.
|
|
1582
|
+
return this.Xi.Si(t, this.$i);
|
|
1583
1583
|
}
|
|
1584
|
-
|
|
1585
|
-
this.
|
|
1584
|
+
Dt() {
|
|
1585
|
+
this.Di.Dt(), document.fonts.delete(this.Gi);
|
|
1586
1586
|
}
|
|
1587
1587
|
get fontFramebuffer() {
|
|
1588
|
-
return this.
|
|
1588
|
+
return this.Di;
|
|
1589
1589
|
}
|
|
1590
1590
|
get characters() {
|
|
1591
|
-
return this
|
|
1591
|
+
return this.$i;
|
|
1592
1592
|
}
|
|
1593
1593
|
get textureColumns() {
|
|
1594
|
-
return this.
|
|
1594
|
+
return this.Bi;
|
|
1595
1595
|
}
|
|
1596
1596
|
get textureRows() {
|
|
1597
1597
|
return this.Li;
|
|
@@ -1600,42 +1600,42 @@ class Wt {
|
|
|
1600
1600
|
return this.Oi;
|
|
1601
1601
|
}
|
|
1602
1602
|
get fontSize() {
|
|
1603
|
-
return this.
|
|
1603
|
+
return this.ki;
|
|
1604
1604
|
}
|
|
1605
1605
|
get font() {
|
|
1606
1606
|
return this.Ei;
|
|
1607
1607
|
}
|
|
1608
1608
|
}
|
|
1609
|
-
class
|
|
1609
|
+
class Xt {
|
|
1610
1610
|
constructor(t, e, i) {
|
|
1611
|
+
h(this, "qi");
|
|
1611
1612
|
h(this, "Zi");
|
|
1612
|
-
h(this, "Qi");
|
|
1613
1613
|
h(this, "dt");
|
|
1614
1614
|
h(this, "_t");
|
|
1615
|
+
h(this, "Qi");
|
|
1615
1616
|
h(this, "Ji");
|
|
1616
1617
|
h(this, "tr");
|
|
1617
|
-
h(this, "er");
|
|
1618
1618
|
h(this, "sr");
|
|
1619
|
-
h(this, "
|
|
1620
|
-
this.
|
|
1619
|
+
h(this, "er");
|
|
1620
|
+
this.tr = t, this.sr = e, this.er = i, this.ir();
|
|
1621
1621
|
}
|
|
1622
|
-
|
|
1623
|
-
this.
|
|
1622
|
+
ir() {
|
|
1623
|
+
this.qi = Math.floor(this.tr.width / this.sr), this.Zi = Math.floor(this.tr.height / this.er), this.dt = this.qi * this.sr, this._t = this.Zi * this.er, this.Qi = Math.floor((this.tr.width - this.dt) / 2), this.Ji = Math.floor((this.tr.height - this._t) / 2);
|
|
1624
1624
|
}
|
|
1625
|
-
|
|
1626
|
-
this.sr = t, this.
|
|
1625
|
+
rr(t, e) {
|
|
1626
|
+
this.sr = t, this.er = e, this.ir();
|
|
1627
1627
|
}
|
|
1628
1628
|
get cellWidth() {
|
|
1629
1629
|
return this.sr;
|
|
1630
1630
|
}
|
|
1631
1631
|
get cellHeight() {
|
|
1632
|
-
return this.
|
|
1632
|
+
return this.er;
|
|
1633
1633
|
}
|
|
1634
1634
|
get cols() {
|
|
1635
|
-
return this.
|
|
1635
|
+
return this.qi;
|
|
1636
1636
|
}
|
|
1637
1637
|
get rows() {
|
|
1638
|
-
return this.
|
|
1638
|
+
return this.Zi;
|
|
1639
1639
|
}
|
|
1640
1640
|
get width() {
|
|
1641
1641
|
return this.dt;
|
|
@@ -1644,162 +1644,162 @@ class jt {
|
|
|
1644
1644
|
return this._t;
|
|
1645
1645
|
}
|
|
1646
1646
|
get offsetX() {
|
|
1647
|
-
return this.
|
|
1647
|
+
return this.Qi;
|
|
1648
1648
|
}
|
|
1649
1649
|
get offsetY() {
|
|
1650
|
-
return this.
|
|
1650
|
+
return this.Ji;
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
|
-
class
|
|
1653
|
+
class Yt {
|
|
1654
1654
|
constructor(t = {}) {
|
|
1655
|
-
h(this, "
|
|
1656
|
-
h(this, "
|
|
1657
|
-
h(this, "
|
|
1655
|
+
h(this, "tr");
|
|
1656
|
+
h(this, "nr", null);
|
|
1657
|
+
h(this, "hr", !1);
|
|
1658
|
+
h(this, "ar");
|
|
1658
1659
|
h(this, "cr");
|
|
1659
|
-
|
|
1660
|
-
this.ar = t.overlay ?? !1, this.ar && t.canvas ? (this.hr = t.canvas, this.er = this.ur(), this.lr = !0, this.dr()) : t.canvas ? (this.er = t.canvas, this.lr = !1) : (this.er = this.pr(t.width, t.height), this.lr = !0), this.er.style.imageRendering = "pixelated";
|
|
1660
|
+
this.hr = t.overlay ?? !1, this.hr && t.canvas ? (this.nr = t.canvas, this.tr = this.lr(), this.cr = !0, this.ur()) : t.canvas ? (this.tr = t.canvas, this.cr = !1) : (this.tr = this.dr(t.width, t.height), this.cr = !0), this.tr.style.imageRendering = "pixelated";
|
|
1661
1661
|
}
|
|
1662
|
-
|
|
1662
|
+
dr(t, e) {
|
|
1663
1663
|
const i = document.createElement("canvas");
|
|
1664
1664
|
return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
|
|
1665
1665
|
}
|
|
1666
|
-
|
|
1666
|
+
lr() {
|
|
1667
1667
|
const t = document.createElement("canvas");
|
|
1668
1668
|
t.className = "textmodeCanvas", t.style.imageRendering = "pixelated";
|
|
1669
|
-
const e = this.
|
|
1669
|
+
const e = this.nr.getBoundingClientRect();
|
|
1670
1670
|
let i = Math.round(e.width), s = Math.round(e.height);
|
|
1671
|
-
if (this.
|
|
1672
|
-
const o = this.
|
|
1671
|
+
if (this.nr instanceof HTMLVideoElement) {
|
|
1672
|
+
const o = this.nr;
|
|
1673
1673
|
(i === 0 || s === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (i = o.videoWidth, s = o.videoHeight);
|
|
1674
1674
|
}
|
|
1675
1675
|
t.width = i, t.height = s, t.style.position = "absolute", t.style.pointerEvents = "none";
|
|
1676
|
-
const r = window.getComputedStyle(this.
|
|
1676
|
+
const r = window.getComputedStyle(this.nr);
|
|
1677
1677
|
let n = parseInt(r.zIndex || "0", 10);
|
|
1678
1678
|
return isNaN(n) && (n = 0), t.style.zIndex = "" + (n + 1), t;
|
|
1679
1679
|
}
|
|
1680
|
-
|
|
1680
|
+
ur() {
|
|
1681
1681
|
var t;
|
|
1682
|
-
this._r(), (t = this.
|
|
1683
|
-
this.
|
|
1684
|
-
}), this.
|
|
1685
|
-
this.
|
|
1682
|
+
this._r(), (t = this.nr.parentNode) == null || t.insertBefore(this.tr, this.nr.nextSibling), window.ResizeObserver && (this.ar = new ResizeObserver(() => {
|
|
1683
|
+
this.pr();
|
|
1684
|
+
}), this.ar.observe(this.nr)), window.addEventListener("resize", () => {
|
|
1685
|
+
this.pr();
|
|
1686
1686
|
});
|
|
1687
1687
|
}
|
|
1688
1688
|
_r() {
|
|
1689
|
-
if (!this.
|
|
1690
|
-
const t = this.
|
|
1691
|
-
let e = this.
|
|
1689
|
+
if (!this.nr) return;
|
|
1690
|
+
const t = this.nr.getBoundingClientRect();
|
|
1691
|
+
let e = this.nr.offsetParent;
|
|
1692
1692
|
if (e && e !== document.body) {
|
|
1693
1693
|
const i = e.getBoundingClientRect();
|
|
1694
|
-
this.
|
|
1695
|
-
} else this.
|
|
1694
|
+
this.tr.style.top = t.top - i.top + "px", this.tr.style.left = t.left - i.left + "px";
|
|
1695
|
+
} else this.tr.style.top = t.top + window.scrollY + "px", this.tr.style.left = t.left + window.scrollX + "px";
|
|
1696
1696
|
}
|
|
1697
|
-
|
|
1698
|
-
if (this.
|
|
1699
|
-
const i = this.
|
|
1697
|
+
pr(t, e) {
|
|
1698
|
+
if (this.hr) {
|
|
1699
|
+
const i = this.nr.getBoundingClientRect();
|
|
1700
1700
|
let s = Math.round(i.width), r = Math.round(i.height);
|
|
1701
|
-
if (this.
|
|
1702
|
-
const n = this.
|
|
1701
|
+
if (this.nr instanceof HTMLVideoElement) {
|
|
1702
|
+
const n = this.nr;
|
|
1703
1703
|
(s === 0 || r === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (s = n.videoWidth, r = n.videoHeight);
|
|
1704
1704
|
}
|
|
1705
|
-
this.
|
|
1706
|
-
} else this.
|
|
1705
|
+
this.tr.width = s, this.tr.height = r, this._r();
|
|
1706
|
+
} else this.tr.width = t ?? this.tr.width, this.tr.height = e ?? this.tr.height;
|
|
1707
1707
|
}
|
|
1708
|
-
|
|
1709
|
-
const t = this.
|
|
1710
|
-
if (!t) throw new
|
|
1708
|
+
vr() {
|
|
1709
|
+
const t = this.tr.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
|
|
1710
|
+
if (!t) throw new C("`textmode.js` requires WebGL2 support.");
|
|
1711
1711
|
return t;
|
|
1712
1712
|
}
|
|
1713
|
-
|
|
1714
|
-
this.
|
|
1715
|
-
const t = this.
|
|
1713
|
+
Dt() {
|
|
1714
|
+
this.ar && this.ar.disconnect();
|
|
1715
|
+
const t = this.tr.getContext("webgl") || this.tr.getContext("webgl2");
|
|
1716
1716
|
if (t) {
|
|
1717
1717
|
const e = t.getExtension("WEBGL_lose_context");
|
|
1718
1718
|
e && e.loseContext();
|
|
1719
1719
|
}
|
|
1720
|
-
this.
|
|
1720
|
+
this.cr && this.tr.parentNode && this.tr.parentNode.removeChild(this.tr);
|
|
1721
1721
|
}
|
|
1722
1722
|
get canvas() {
|
|
1723
|
-
return this.
|
|
1723
|
+
return this.tr;
|
|
1724
1724
|
}
|
|
1725
1725
|
get targetCanvas() {
|
|
1726
|
-
return this.
|
|
1726
|
+
return this.nr;
|
|
1727
1727
|
}
|
|
1728
1728
|
get width() {
|
|
1729
|
-
return this.
|
|
1729
|
+
return this.tr.width;
|
|
1730
1730
|
}
|
|
1731
1731
|
get height() {
|
|
1732
|
-
return this.
|
|
1732
|
+
return this.tr.height;
|
|
1733
1733
|
}
|
|
1734
1734
|
}
|
|
1735
|
-
class
|
|
1735
|
+
class G {
|
|
1736
1736
|
constructor(t, e, i, s) {
|
|
1737
|
-
h(this, "
|
|
1737
|
+
h(this, "mr");
|
|
1738
1738
|
h(this, "dt");
|
|
1739
1739
|
h(this, "_t");
|
|
1740
|
-
h(this, "
|
|
1740
|
+
h(this, "gt");
|
|
1741
1741
|
h(this, "k", 0);
|
|
1742
|
-
h(this, "
|
|
1743
|
-
h(this, "
|
|
1744
|
-
h(this, "
|
|
1745
|
-
h(this, "
|
|
1746
|
-
h(this, "
|
|
1747
|
-
h(this, "
|
|
1742
|
+
h(this, "K", 0);
|
|
1743
|
+
h(this, "Y", 0);
|
|
1744
|
+
h(this, "L", [0, 0]);
|
|
1745
|
+
h(this, "gr", "sampled");
|
|
1746
|
+
h(this, "Ar", "fixed");
|
|
1747
|
+
h(this, "V", [1, 1, 1, 1]);
|
|
1748
1748
|
h(this, "q", [0, 0, 0, 1]);
|
|
1749
|
-
h(this, "
|
|
1750
|
-
h(this, "
|
|
1751
|
-
h(this, "
|
|
1752
|
-
this.
|
|
1749
|
+
h(this, "yr", [0, 0, 0, 1]);
|
|
1750
|
+
h(this, "Cr", [[0.1, 0, 0]]);
|
|
1751
|
+
h(this, "wr");
|
|
1752
|
+
this.gt = t, this.mr = e, this.dt = i, this._t = s;
|
|
1753
1753
|
}
|
|
1754
|
-
|
|
1755
|
-
this.
|
|
1754
|
+
Dt() {
|
|
1755
|
+
this.gt.deleteTexture(this.mr);
|
|
1756
1756
|
}
|
|
1757
|
-
|
|
1757
|
+
br(t) {
|
|
1758
1758
|
return typeof t == "boolean" ? t ? 1 : 0 : (t == null ? 0 : Number(t)) > 0 ? 1 : 0;
|
|
1759
1759
|
}
|
|
1760
1760
|
invert(t = !0) {
|
|
1761
|
-
return this.k = this.
|
|
1761
|
+
return this.k = this.br(t), this;
|
|
1762
1762
|
}
|
|
1763
1763
|
flipX(t = !0) {
|
|
1764
|
-
return this.
|
|
1764
|
+
return this.K = this.br(t), this;
|
|
1765
1765
|
}
|
|
1766
1766
|
flipY(t = !0) {
|
|
1767
|
-
return this.
|
|
1767
|
+
return this.Y = this.br(t), this;
|
|
1768
1768
|
}
|
|
1769
1769
|
charRotation(t) {
|
|
1770
1770
|
const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
|
|
1771
|
-
return this.
|
|
1771
|
+
return this.L = [i, s], this;
|
|
1772
1772
|
}
|
|
1773
|
-
|
|
1774
|
-
return { texture: this.
|
|
1773
|
+
He() {
|
|
1774
|
+
return { texture: this.mr, invert: this.k, flipX: this.K, flipY: this.Y, charRotation: this.L, charColorFixed: this.gr === "fixed", charColor: this.V, cellColorFixed: this.Ar === "fixed", cellColor: this.q, backgroundColor: this.yr, charCount: this.Cr.length, charList: this.Cr };
|
|
1775
1775
|
}
|
|
1776
1776
|
charColorMode(t) {
|
|
1777
|
-
return this.
|
|
1777
|
+
return this.gr = t, this;
|
|
1778
1778
|
}
|
|
1779
1779
|
cellColorMode(t) {
|
|
1780
|
-
return this.
|
|
1780
|
+
return this.Ar = t, this;
|
|
1781
1781
|
}
|
|
1782
1782
|
charColor(t, e, i, s) {
|
|
1783
|
-
return this.
|
|
1783
|
+
return this.V = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
|
|
1784
1784
|
}
|
|
1785
1785
|
cellColor(t, e, i, s) {
|
|
1786
1786
|
return this.q = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
|
|
1787
1787
|
}
|
|
1788
1788
|
background(t, e, i, s) {
|
|
1789
|
-
return this.
|
|
1789
|
+
return this.yr = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
|
|
1790
1790
|
}
|
|
1791
1791
|
characters(t) {
|
|
1792
|
-
const e = this.
|
|
1793
|
-
return this.
|
|
1792
|
+
const e = this.wr(t).filter((i) => Array.isArray(i)).slice(0, 64);
|
|
1793
|
+
return this.Cr = e, this;
|
|
1794
1794
|
}
|
|
1795
|
-
static
|
|
1795
|
+
static Mr(t, e, i) {
|
|
1796
1796
|
const s = t.context, r = s.createTexture();
|
|
1797
1797
|
s.bindTexture(s.TEXTURE_2D, r), s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, 1), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MIN_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MAG_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, s.RGBA, s.UNSIGNED_BYTE, e), s.bindTexture(s.TEXTURE_2D, null);
|
|
1798
|
-
const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new
|
|
1799
|
-
return c.
|
|
1798
|
+
const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new G(s, r, n, o);
|
|
1799
|
+
return c.wr = i, c;
|
|
1800
1800
|
}
|
|
1801
1801
|
get texture() {
|
|
1802
|
-
return this.
|
|
1802
|
+
return this.mr;
|
|
1803
1803
|
}
|
|
1804
1804
|
get width() {
|
|
1805
1805
|
return this.dt;
|
|
@@ -1808,27 +1808,27 @@ class z {
|
|
|
1808
1808
|
return this._t;
|
|
1809
1809
|
}
|
|
1810
1810
|
}
|
|
1811
|
-
class
|
|
1811
|
+
class Wt {
|
|
1812
1812
|
constructor(t = 60) {
|
|
1813
1813
|
h(this, "Fr");
|
|
1814
|
-
h(this, "
|
|
1814
|
+
h(this, "zr");
|
|
1815
1815
|
h(this, "Rr", null);
|
|
1816
|
-
h(this, "
|
|
1816
|
+
h(this, "Tr", 0);
|
|
1817
1817
|
h(this, "Pr", !0);
|
|
1818
1818
|
h(this, "Sr", 0);
|
|
1819
1819
|
h(this, "Er", 0);
|
|
1820
|
-
h(this, "
|
|
1821
|
-
h(this, "
|
|
1822
|
-
h(this, "
|
|
1823
|
-
this.Fr = t, this.
|
|
1820
|
+
h(this, "$r", []);
|
|
1821
|
+
h(this, "Dr", 10);
|
|
1822
|
+
h(this, "kr", 0);
|
|
1823
|
+
this.Fr = t, this.zr = 1e3 / t;
|
|
1824
1824
|
}
|
|
1825
1825
|
start(t) {
|
|
1826
1826
|
if (!this.Pr) return;
|
|
1827
|
-
this.
|
|
1827
|
+
this.Tr = performance.now();
|
|
1828
1828
|
const e = (i) => {
|
|
1829
1829
|
if (!this.Pr) return void (this.Rr = null);
|
|
1830
|
-
const s = i - this.
|
|
1831
|
-
s >= this.
|
|
1830
|
+
const s = i - this.Tr;
|
|
1831
|
+
s >= this.zr && (t(), this.Tr = i - s % this.zr), this.Pr && (this.Rr = requestAnimationFrame(e));
|
|
1832
1832
|
};
|
|
1833
1833
|
this.Rr = requestAnimationFrame(e);
|
|
1834
1834
|
}
|
|
@@ -1843,14 +1843,14 @@ class Kt {
|
|
|
1843
1843
|
}
|
|
1844
1844
|
frameRate(t, e) {
|
|
1845
1845
|
if (t === void 0) return this.Sr;
|
|
1846
|
-
this.Fr = t, this.
|
|
1846
|
+
this.Fr = t, this.zr = 1e3 / t, this.Pr && e && (this.stop(), this.start(e));
|
|
1847
1847
|
}
|
|
1848
1848
|
measureFrameRate() {
|
|
1849
1849
|
const t = performance.now();
|
|
1850
1850
|
if (this.Er > 0) {
|
|
1851
1851
|
const e = t - this.Er;
|
|
1852
|
-
this.
|
|
1853
|
-
const i = this.
|
|
1852
|
+
this.$r.push(e), this.$r.length > this.Dr && this.$r.shift();
|
|
1853
|
+
const i = this.$r.reduce((s, r) => s + r, 0) / this.$r.length;
|
|
1854
1854
|
this.Sr = 1e3 / i;
|
|
1855
1855
|
}
|
|
1856
1856
|
this.Er = t;
|
|
@@ -1865,108 +1865,114 @@ class Kt {
|
|
|
1865
1865
|
return this.Sr;
|
|
1866
1866
|
}
|
|
1867
1867
|
get frameCount() {
|
|
1868
|
-
return this.
|
|
1868
|
+
return this.kr;
|
|
1869
1869
|
}
|
|
1870
1870
|
set frameCount(t) {
|
|
1871
|
-
this.
|
|
1871
|
+
this.kr = t;
|
|
1872
1872
|
}
|
|
1873
1873
|
incrementFrame() {
|
|
1874
|
-
this.
|
|
1874
|
+
this.kr++;
|
|
1875
1875
|
}
|
|
1876
1876
|
resetFrameCount() {
|
|
1877
|
-
this.
|
|
1877
|
+
this.kr = 0;
|
|
1878
1878
|
}
|
|
1879
1879
|
}
|
|
1880
|
-
class
|
|
1880
|
+
class rt {
|
|
1881
1881
|
constructor(t) {
|
|
1882
|
-
h(this, "
|
|
1883
|
-
h(this, "
|
|
1882
|
+
h(this, "tr");
|
|
1883
|
+
h(this, "Br");
|
|
1884
1884
|
h(this, "Lr", { x: -1, y: -1 });
|
|
1885
1885
|
h(this, "Or", { x: -1, y: -1 });
|
|
1886
|
-
h(this, "
|
|
1887
|
-
h(this, "
|
|
1886
|
+
h(this, "Gr", null);
|
|
1887
|
+
h(this, "Hr", 0);
|
|
1888
|
+
h(this, "Ir");
|
|
1888
1889
|
h(this, "Nr");
|
|
1889
1890
|
h(this, "Xr");
|
|
1890
1891
|
h(this, "Wr");
|
|
1891
|
-
h(this, "Vr");
|
|
1892
|
-
h(this, "jr");
|
|
1893
1892
|
h(this, "Kr");
|
|
1894
|
-
h(this, "Yr"
|
|
1893
|
+
h(this, "Yr");
|
|
1894
|
+
h(this, "jr", !1);
|
|
1895
|
+
h(this, "Vr");
|
|
1895
1896
|
h(this, "qr");
|
|
1896
1897
|
h(this, "Zr");
|
|
1897
1898
|
h(this, "Qr");
|
|
1898
1899
|
h(this, "Jr");
|
|
1899
|
-
|
|
1900
|
-
this.er = t;
|
|
1900
|
+
this.tr = t;
|
|
1901
1901
|
}
|
|
1902
|
-
|
|
1902
|
+
tn(t) {
|
|
1903
1903
|
const e = performance.now() + Math.max(0, t);
|
|
1904
|
-
e > this.
|
|
1904
|
+
e > this.Hr && (this.Hr = e);
|
|
1905
1905
|
}
|
|
1906
1906
|
sn() {
|
|
1907
|
-
return performance.now() < this.
|
|
1907
|
+
return performance.now() < this.Hr;
|
|
1908
1908
|
}
|
|
1909
|
-
|
|
1910
|
-
const e = this.
|
|
1909
|
+
en(t) {
|
|
1910
|
+
const e = this.tr.canvas;
|
|
1911
1911
|
e.style.cursor = t == null || t === "" ? "" : t;
|
|
1912
1912
|
}
|
|
1913
|
-
|
|
1914
|
-
this.
|
|
1913
|
+
Wi(t) {
|
|
1914
|
+
this.Br = t, this.rn();
|
|
1915
1915
|
}
|
|
1916
|
-
|
|
1917
|
-
if (this.
|
|
1918
|
-
const t = this.
|
|
1919
|
-
this.
|
|
1920
|
-
this.
|
|
1921
|
-
}, this.
|
|
1922
|
-
this.Or = { ...this.Lr }, this.Lr.x = -1, this.Lr.y = -1, this.
|
|
1916
|
+
nn() {
|
|
1917
|
+
if (this.jr) return;
|
|
1918
|
+
const t = this.tr.canvas;
|
|
1919
|
+
this.Ir = (e) => {
|
|
1920
|
+
this.hn(e), this.an(e);
|
|
1921
|
+
}, this.Nr = () => {
|
|
1922
|
+
this.Or = { ...this.Lr }, this.Lr.x = -1, this.Lr.y = -1, this.Gr = null;
|
|
1923
|
+
}, this.Xr = (e) => {
|
|
1924
|
+
this.hn(e), this.cn(e);
|
|
1923
1925
|
}, this.Wr = (e) => {
|
|
1924
|
-
this.
|
|
1925
|
-
}, this.Vr = (e) => {
|
|
1926
|
-
this.an(e), this.un(e);
|
|
1927
|
-
}, this.jr = (e) => {
|
|
1928
|
-
this.an(e), this.fn(e);
|
|
1926
|
+
this.hn(e), this.ln(e);
|
|
1929
1927
|
}, this.Kr = (e) => {
|
|
1930
|
-
this.
|
|
1931
|
-
},
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1928
|
+
this.hn(e), this.un(e);
|
|
1929
|
+
}, this.Yr = (e) => {
|
|
1930
|
+
this.hn(e), this.fn(e);
|
|
1931
|
+
}, t.addEventListener("mousemove", this.Ir, { passive: !0 }), t.addEventListener("mouseleave", this.Nr, { passive: !0 }), t.addEventListener("mousedown", this.Xr, { passive: !0 }), t.addEventListener("mouseup", this.Wr, { passive: !0 }), t.addEventListener("click", this.Kr, { passive: !0 }), t.addEventListener("wheel", this.Yr, { passive: !1 }), this.jr = !0;
|
|
1932
|
+
}
|
|
1933
|
+
dn() {
|
|
1934
|
+
if (!this.jr) return;
|
|
1935
|
+
const t = this.tr.canvas;
|
|
1936
|
+
t.removeEventListener("mousemove", this.Ir), t.removeEventListener("mouseleave", this.Nr), t.removeEventListener("mousedown", this.Xr), t.removeEventListener("mouseup", this.Wr), t.removeEventListener("click", this.Kr), t.removeEventListener("wheel", this.Yr), this.jr = !1;
|
|
1937
|
+
}
|
|
1938
|
+
rn() {
|
|
1939
|
+
if (this.jr) try {
|
|
1940
|
+
if (this.Gr) {
|
|
1941
|
+
const t = new MouseEvent("mousemove", { clientX: this.Gr.x, clientY: this.Gr.y, bubbles: !1, cancelable: !1 });
|
|
1942
|
+
this.hn(t);
|
|
1943
|
+
} else this.Lr.x !== -1 && this.Lr.y !== -1 && (this.Lr.x >= this.Br.cols || this.Lr.y >= this.Br.rows) && (this.Lr.x = -1, this.Lr.y = -1);
|
|
1944
1944
|
} catch {
|
|
1945
1945
|
this.Lr.x = -1, this.Lr.y = -1;
|
|
1946
1946
|
}
|
|
1947
1947
|
}
|
|
1948
1948
|
_n(t) {
|
|
1949
|
+
this.Vr = t;
|
|
1950
|
+
}
|
|
1951
|
+
pn(t) {
|
|
1949
1952
|
this.qr = t;
|
|
1950
1953
|
}
|
|
1951
|
-
|
|
1954
|
+
vn(t) {
|
|
1952
1955
|
this.Zr = t;
|
|
1953
1956
|
}
|
|
1954
|
-
|
|
1957
|
+
mn(t) {
|
|
1955
1958
|
this.Qr = t;
|
|
1956
1959
|
}
|
|
1957
|
-
|
|
1960
|
+
gn(t) {
|
|
1958
1961
|
this.Jr = t;
|
|
1959
1962
|
}
|
|
1960
|
-
|
|
1961
|
-
this.tn = t;
|
|
1962
|
-
}
|
|
1963
|
-
yn() {
|
|
1963
|
+
An() {
|
|
1964
1964
|
return { x: this.Lr.x, y: this.Lr.y };
|
|
1965
1965
|
}
|
|
1966
|
-
|
|
1967
|
-
if (this.
|
|
1966
|
+
an(t) {
|
|
1967
|
+
if (this.Qr && !this.sn()) {
|
|
1968
1968
|
const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, originalEvent: t };
|
|
1969
|
-
this.
|
|
1969
|
+
this.Qr(e);
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
cn(t) {
|
|
1973
|
+
if (this.qr && !this.sn()) {
|
|
1974
|
+
const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
|
|
1975
|
+
this.qr(e);
|
|
1970
1976
|
}
|
|
1971
1977
|
}
|
|
1972
1978
|
ln(t) {
|
|
@@ -1976,330 +1982,324 @@ class ct {
|
|
|
1976
1982
|
}
|
|
1977
1983
|
}
|
|
1978
1984
|
un(t) {
|
|
1979
|
-
if (this.
|
|
1985
|
+
if (this.Vr && !this.sn()) {
|
|
1980
1986
|
const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
|
|
1981
|
-
this.
|
|
1987
|
+
this.Vr(e);
|
|
1982
1988
|
}
|
|
1983
1989
|
}
|
|
1984
1990
|
fn(t) {
|
|
1985
|
-
if (this.
|
|
1986
|
-
const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
|
|
1987
|
-
this.qr(e);
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
dn(t) {
|
|
1991
|
-
if (this.tn && !this.sn()) {
|
|
1991
|
+
if (this.Jr && !this.sn()) {
|
|
1992
1992
|
const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
|
|
1993
|
-
this.
|
|
1993
|
+
this.Jr(e);
|
|
1994
1994
|
}
|
|
1995
1995
|
}
|
|
1996
|
-
|
|
1997
|
-
const e = this.
|
|
1998
|
-
this.Or = { ...this.Lr }, this.
|
|
1999
|
-
const i = e.getBoundingClientRect(), s = t.clientX - i.left, r = t.clientY - i.top, n = e.width / i.width, o = r * (e.height / i.height), c = s * n - this.
|
|
2000
|
-
|
|
1996
|
+
hn(t) {
|
|
1997
|
+
const e = this.tr.canvas;
|
|
1998
|
+
this.Or = { ...this.Lr }, this.Gr = { x: t.clientX, y: t.clientY };
|
|
1999
|
+
const i = e.getBoundingClientRect(), s = t.clientX - i.left, r = t.clientY - i.top, n = e.width / i.width, o = r * (e.height / i.height), c = s * n - this.Br.offsetX, l = o - this.Br.offsetY, f = Math.floor(c / this.Br.cellWidth), u = Math.floor(l / this.Br.cellHeight);
|
|
2000
|
+
f >= 0 && f < this.Br.cols && u >= 0 && u < this.Br.rows ? (this.Lr.x = f, this.Lr.y = u) : (this.Lr.x = -1, this.Lr.y = -1);
|
|
2001
2001
|
}
|
|
2002
2002
|
}
|
|
2003
|
-
const
|
|
2004
|
-
class
|
|
2003
|
+
const Ht = Object.freeze(Object.defineProperty({ __proto__: null, MouseManager: rt }, Symbol.toStringTag, { value: "Module" }));
|
|
2004
|
+
class nt {
|
|
2005
2005
|
constructor() {
|
|
2006
|
-
h(this, "
|
|
2007
|
-
h(this, "
|
|
2008
|
-
h(this, "
|
|
2006
|
+
h(this, "yn", /* @__PURE__ */ new Map());
|
|
2007
|
+
h(this, "Cn", null);
|
|
2008
|
+
h(this, "wn", null);
|
|
2009
|
+
h(this, "bn");
|
|
2009
2010
|
h(this, "xn");
|
|
2011
|
+
h(this, "jr", !1);
|
|
2010
2012
|
h(this, "Mn");
|
|
2011
|
-
h(this, "Yr", !1);
|
|
2012
|
-
h(this, "$n");
|
|
2013
2013
|
h(this, "Fn");
|
|
2014
|
-
h(this, "
|
|
2014
|
+
h(this, "zn", { ArrowUp: "UP_ARROW", ArrowDown: "DOWN_ARROW", ArrowLeft: "LEFT_ARROW", ArrowRight: "RIGHT_ARROW", F1: "F1", F2: "F2", F3: "F3", F4: "F4", F5: "F5", F6: "F6", F7: "F7", F8: "F8", F9: "F9", F10: "F10", F11: "F11", F12: "F12", Enter: "ENTER", Return: "RETURN", Tab: "TAB", Escape: "ESCAPE", Backspace: "BACKSPACE", Delete: "DELETE", Insert: "INSERT", Home: "HOME", End: "END", PageUp: "PAGE_UP", PageDown: "PAGE_DOWN", Shift: "SHIFT", Control: "CONTROL", Alt: "ALT", Meta: "META", " ": "SPACE" });
|
|
2015
2015
|
}
|
|
2016
|
-
|
|
2017
|
-
this.
|
|
2016
|
+
nn() {
|
|
2017
|
+
this.jr || (this.bn = (t) => {
|
|
2018
2018
|
this.Rn(t);
|
|
2019
|
-
}, this.
|
|
2020
|
-
this.
|
|
2021
|
-
}, window.addEventListener("keydown", this.
|
|
2019
|
+
}, this.xn = (t) => {
|
|
2020
|
+
this.Tn(t);
|
|
2021
|
+
}, window.addEventListener("keydown", this.bn, { passive: !1 }), window.addEventListener("keyup", this.xn, { passive: !1 }), this.jr = !0);
|
|
2022
2022
|
}
|
|
2023
|
-
|
|
2024
|
-
this.
|
|
2023
|
+
dn() {
|
|
2024
|
+
this.jr && (window.removeEventListener("keydown", this.bn), window.removeEventListener("keyup", this.xn), this.jr = !1, this.yn.clear(), this.Cn = null, this.wn = null);
|
|
2025
2025
|
}
|
|
2026
|
-
|
|
2027
|
-
this
|
|
2026
|
+
pn(t) {
|
|
2027
|
+
this.Mn = t;
|
|
2028
2028
|
}
|
|
2029
|
-
|
|
2029
|
+
vn(t) {
|
|
2030
2030
|
this.Fn = t;
|
|
2031
2031
|
}
|
|
2032
2032
|
Pn(t) {
|
|
2033
|
-
const e = this.Sn(t), i = this.
|
|
2033
|
+
const e = this.Sn(t), i = this.yn.get(t) || this.yn.get(e);
|
|
2034
2034
|
return (i == null ? void 0 : i.isPressed) || !1;
|
|
2035
2035
|
}
|
|
2036
2036
|
En() {
|
|
2037
|
-
return this.
|
|
2037
|
+
return this.Cn;
|
|
2038
2038
|
}
|
|
2039
|
-
|
|
2040
|
-
return this.
|
|
2039
|
+
$n() {
|
|
2040
|
+
return this.wn;
|
|
2041
2041
|
}
|
|
2042
|
-
|
|
2042
|
+
Dn() {
|
|
2043
2043
|
const t = [];
|
|
2044
|
-
for (const [e, i] of this.
|
|
2044
|
+
for (const [e, i] of this.yn) i.isPressed && t.push(e);
|
|
2045
2045
|
return t;
|
|
2046
2046
|
}
|
|
2047
|
-
|
|
2047
|
+
kn() {
|
|
2048
2048
|
return { ctrl: this.Pn("Control"), shift: this.Pn("Shift"), alt: this.Pn("Alt"), meta: this.Pn("Meta") };
|
|
2049
2049
|
}
|
|
2050
|
-
|
|
2051
|
-
this.
|
|
2050
|
+
Bn() {
|
|
2051
|
+
this.yn.clear(), this.Cn = null, this.wn = null;
|
|
2052
2052
|
}
|
|
2053
2053
|
Rn(t) {
|
|
2054
2054
|
const e = t.key, i = Date.now();
|
|
2055
|
-
this.
|
|
2056
|
-
const s = this.
|
|
2057
|
-
if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.
|
|
2055
|
+
this.yn.has(e) || this.yn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
|
|
2056
|
+
const s = this.yn.get(e);
|
|
2057
|
+
if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.Cn = e, this.Mn)) {
|
|
2058
2058
|
const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
|
|
2059
|
-
this
|
|
2059
|
+
this.Mn(r);
|
|
2060
2060
|
}
|
|
2061
2061
|
}
|
|
2062
|
-
|
|
2062
|
+
Tn(t) {
|
|
2063
2063
|
const e = t.key, i = Date.now();
|
|
2064
|
-
this.
|
|
2065
|
-
const s = this.
|
|
2066
|
-
if (s.isPressed = !1, s.lastReleaseTime = i, this.
|
|
2064
|
+
this.yn.has(e) || this.yn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
|
|
2065
|
+
const s = this.yn.get(e);
|
|
2066
|
+
if (s.isPressed = !1, s.lastReleaseTime = i, this.wn = e, this.Fn) {
|
|
2067
2067
|
const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
|
|
2068
2068
|
this.Fn(r);
|
|
2069
2069
|
}
|
|
2070
2070
|
}
|
|
2071
2071
|
Sn(t) {
|
|
2072
|
-
return this.
|
|
2072
|
+
return this.zn[t] || t.toLowerCase();
|
|
2073
2073
|
}
|
|
2074
2074
|
}
|
|
2075
|
-
const
|
|
2076
|
-
class
|
|
2075
|
+
const jt = Object.freeze(Object.defineProperty({ __proto__: null, KeyboardManager: nt }, Symbol.toStringTag, { value: "Module" }));
|
|
2076
|
+
class ot {
|
|
2077
2077
|
constructor(t, e) {
|
|
2078
|
-
h(this, "
|
|
2078
|
+
h(this, "tr");
|
|
2079
2079
|
h(this, "Ln");
|
|
2080
|
-
h(this, "
|
|
2080
|
+
h(this, "Br");
|
|
2081
2081
|
h(this, "On", /* @__PURE__ */ new Map());
|
|
2082
|
+
h(this, "Gn", /* @__PURE__ */ new Map());
|
|
2082
2083
|
h(this, "Hn", /* @__PURE__ */ new Map());
|
|
2083
|
-
h(this, "In",
|
|
2084
|
-
h(this, "Nn"
|
|
2084
|
+
h(this, "In", null);
|
|
2085
|
+
h(this, "Nn");
|
|
2085
2086
|
h(this, "Xn");
|
|
2086
2087
|
h(this, "Wn");
|
|
2087
|
-
h(this, "Vn");
|
|
2088
|
-
h(this, "jn");
|
|
2089
2088
|
h(this, "Kn");
|
|
2090
2089
|
h(this, "Yn");
|
|
2091
|
-
h(this, "
|
|
2090
|
+
h(this, "jn");
|
|
2091
|
+
h(this, "jr", !1);
|
|
2092
|
+
h(this, "Vn");
|
|
2092
2093
|
h(this, "qn");
|
|
2093
2094
|
h(this, "Zn");
|
|
2094
2095
|
h(this, "Qn");
|
|
2095
2096
|
h(this, "Jn");
|
|
2096
|
-
h(this, "eo");
|
|
2097
2097
|
h(this, "so");
|
|
2098
|
+
h(this, "eo");
|
|
2098
2099
|
h(this, "io");
|
|
2099
2100
|
h(this, "ro");
|
|
2100
2101
|
h(this, "no");
|
|
2101
|
-
h(this, "oo");
|
|
2102
|
-
h(this, "ho",
|
|
2103
|
-
h(this, "ao",
|
|
2104
|
-
h(this, "co",
|
|
2105
|
-
h(this, "lo",
|
|
2106
|
-
h(this, "uo",
|
|
2107
|
-
h(this, "fo",
|
|
2108
|
-
h(this, "do",
|
|
2109
|
-
h(this, "po", 0.02);
|
|
2102
|
+
h(this, "oo", 320);
|
|
2103
|
+
h(this, "ho", 350);
|
|
2104
|
+
h(this, "ao", 10);
|
|
2105
|
+
h(this, "co", 550);
|
|
2106
|
+
h(this, "lo", 14);
|
|
2107
|
+
h(this, "uo", 48);
|
|
2108
|
+
h(this, "fo", 650);
|
|
2109
|
+
h(this, "do", 0.02);
|
|
2110
2110
|
h(this, "_o", 2);
|
|
2111
|
-
h(this, "
|
|
2111
|
+
h(this, "po", 600);
|
|
2112
2112
|
h(this, "vo", 0);
|
|
2113
|
-
h(this, "
|
|
2114
|
-
this.
|
|
2115
|
-
const i = this.
|
|
2116
|
-
this.
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
this.
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
if (this.
|
|
2123
|
-
const t = this.
|
|
2124
|
-
this.
|
|
2113
|
+
h(this, "mo", null);
|
|
2114
|
+
this.tr = t, this.Ln = e;
|
|
2115
|
+
const i = this.tr.canvas;
|
|
2116
|
+
this.Nn = i.style.touchAction, this.Xn = i.style.userSelect, i.style.touchAction || (i.style.touchAction = "none"), i.style.userSelect || (i.style.userSelect = "none");
|
|
2117
|
+
}
|
|
2118
|
+
Wi(t) {
|
|
2119
|
+
this.Br = t, this.Ao();
|
|
2120
|
+
}
|
|
2121
|
+
nn() {
|
|
2122
|
+
if (this.jr) return;
|
|
2123
|
+
const t = this.tr.canvas;
|
|
2124
|
+
this.Wn = (e) => {
|
|
2125
|
+
this.yo(e);
|
|
2126
|
+
}, this.Kn = (e) => {
|
|
2125
2127
|
this.Co(e);
|
|
2128
|
+
}, this.Yn = (e) => {
|
|
2129
|
+
this.wo(e);
|
|
2126
2130
|
}, this.jn = (e) => {
|
|
2127
|
-
this.Ao(e);
|
|
2128
|
-
}, this.Kn = (e) => {
|
|
2129
2131
|
this.bo(e);
|
|
2130
|
-
}, this.Yn
|
|
2131
|
-
this.xo(e);
|
|
2132
|
-
}, t.addEventListener("touchstart", this.Vn, { passive: !1 }), t.addEventListener("touchmove", this.jn, { passive: !1 }), t.addEventListener("touchend", this.Kn, { passive: !1 }), t.addEventListener("touchcancel", this.Yn, { passive: !1 }), this.Yr = !0;
|
|
2132
|
+
}, t.addEventListener("touchstart", this.Wn, { passive: !1 }), t.addEventListener("touchmove", this.Kn, { passive: !1 }), t.addEventListener("touchend", this.Yn, { passive: !1 }), t.addEventListener("touchcancel", this.jn, { passive: !1 }), this.jr = !0;
|
|
2133
2133
|
}
|
|
2134
|
-
|
|
2135
|
-
if (!this.
|
|
2136
|
-
const t = this.
|
|
2137
|
-
t.removeEventListener("touchstart", this.
|
|
2134
|
+
dn() {
|
|
2135
|
+
if (!this.jr) return;
|
|
2136
|
+
const t = this.tr.canvas;
|
|
2137
|
+
t.removeEventListener("touchstart", this.Wn), t.removeEventListener("touchmove", this.Kn), t.removeEventListener("touchend", this.Yn), t.removeEventListener("touchcancel", this.jn), this.jr = !1, this.In = null, this.On.clear(), this.Gn.clear(), this.Hn.forEach((e) => {
|
|
2138
2138
|
e.longPressTimer !== null && window.clearTimeout(e.longPressTimer);
|
|
2139
|
-
}), this.
|
|
2139
|
+
}), this.Hn.clear(), this.mo = null, this.vo = 0, t.style.touchAction = this.Nn, t.style.userSelect = this.Xn;
|
|
2140
2140
|
}
|
|
2141
|
-
|
|
2142
|
-
if (!this.
|
|
2141
|
+
Ao() {
|
|
2142
|
+
if (!this.Br || this.On.size === 0) return;
|
|
2143
2143
|
const t = /* @__PURE__ */ new Map();
|
|
2144
2144
|
for (const e of this.On.values()) {
|
|
2145
|
-
const i = this.
|
|
2145
|
+
const i = this.xo(e.clientX, e.clientY, e.id, e);
|
|
2146
2146
|
t.set(e.id, i);
|
|
2147
2147
|
}
|
|
2148
2148
|
this.On = t;
|
|
2149
2149
|
}
|
|
2150
|
-
|
|
2150
|
+
Mo() {
|
|
2151
2151
|
return Array.from(this.On.values()).map((t) => ({ ...t }));
|
|
2152
2152
|
}
|
|
2153
2153
|
Fo(t) {
|
|
2154
|
+
this.Vn = t;
|
|
2155
|
+
}
|
|
2156
|
+
mn(t) {
|
|
2154
2157
|
this.qn = t;
|
|
2155
2158
|
}
|
|
2156
|
-
|
|
2159
|
+
zo(t) {
|
|
2157
2160
|
this.Zn = t;
|
|
2158
2161
|
}
|
|
2159
|
-
|
|
2162
|
+
Ro(t) {
|
|
2160
2163
|
this.Qn = t;
|
|
2161
2164
|
}
|
|
2162
|
-
|
|
2165
|
+
To(t) {
|
|
2163
2166
|
this.Jn = t;
|
|
2164
2167
|
}
|
|
2165
|
-
zo(t) {
|
|
2166
|
-
this.eo = t;
|
|
2167
|
-
}
|
|
2168
2168
|
Po(t) {
|
|
2169
2169
|
this.so = t;
|
|
2170
2170
|
}
|
|
2171
2171
|
So(t) {
|
|
2172
|
-
this.
|
|
2172
|
+
this.eo = t;
|
|
2173
2173
|
}
|
|
2174
2174
|
Eo(t) {
|
|
2175
|
+
this.io = t;
|
|
2176
|
+
}
|
|
2177
|
+
$o(t) {
|
|
2175
2178
|
this.ro = t;
|
|
2176
2179
|
}
|
|
2177
2180
|
Do(t) {
|
|
2178
2181
|
this.no = t;
|
|
2179
2182
|
}
|
|
2180
|
-
|
|
2181
|
-
this.oo = t;
|
|
2182
|
-
}
|
|
2183
|
-
Co(t) {
|
|
2183
|
+
yo(t) {
|
|
2184
2184
|
var s;
|
|
2185
|
-
if (!this.
|
|
2186
|
-
t.preventDefault(), (s = this.Ln) == null || s.
|
|
2187
|
-
const e = performance.now(), i = this.
|
|
2185
|
+
if (!this.Br) return;
|
|
2186
|
+
t.preventDefault(), (s = this.Ln) == null || s.tn(this.po);
|
|
2187
|
+
const e = performance.now(), i = this.ko(t.changedTouches);
|
|
2188
2188
|
for (const r of i) {
|
|
2189
2189
|
const n = this.On.get(r.id);
|
|
2190
|
-
n && this.
|
|
2190
|
+
n && this.Gn.set(r.id, this.Bo(n)), this.On.set(r.id, r);
|
|
2191
2191
|
const o = { id: r.id, startPosition: r, lastPosition: r, startTime: e, lastTime: e, longPressTimer: null, longPressFired: !1 };
|
|
2192
|
-
this.
|
|
2192
|
+
this.eo && (o.longPressTimer = window.setTimeout(() => {
|
|
2193
2193
|
const c = this.On.get(r.id);
|
|
2194
|
-
c && (o.longPressFired = !0, this.
|
|
2195
|
-
}, this.
|
|
2194
|
+
c && (o.longPressFired = !0, this.eo({ touch: this.Bo(c), duration: performance.now() - o.startTime, originalEvent: t }));
|
|
2195
|
+
}, this.co)), this.Hn.set(r.id, o), this.Vn && this.Vn(this.Lo(r, t, void 0, e));
|
|
2196
2196
|
}
|
|
2197
2197
|
this.On.size === 2 && this.Oo();
|
|
2198
2198
|
}
|
|
2199
|
-
|
|
2199
|
+
Co(t) {
|
|
2200
2200
|
var s;
|
|
2201
|
-
if (!this.
|
|
2202
|
-
t.preventDefault(), (s = this.Ln) == null || s.
|
|
2203
|
-
const e = performance.now(), i = this.
|
|
2201
|
+
if (!this.Br) return;
|
|
2202
|
+
t.preventDefault(), (s = this.Ln) == null || s.tn(this.po);
|
|
2203
|
+
const e = performance.now(), i = this.ko(t.changedTouches);
|
|
2204
2204
|
for (const r of i) {
|
|
2205
|
-
const n = this.On.get(r.id), o = n ? this.
|
|
2206
|
-
o && this.
|
|
2207
|
-
const c = this.
|
|
2208
|
-
c && (c.lastPosition = r, c.lastTime = e, o) && this.
|
|
2205
|
+
const n = this.On.get(r.id), o = n ? this.Bo(n) : void 0;
|
|
2206
|
+
o && this.Gn.set(r.id, o), this.On.set(r.id, r);
|
|
2207
|
+
const c = this.Hn.get(r.id);
|
|
2208
|
+
c && (c.lastPosition = r, c.lastTime = e, o) && this.Go(o, r, !0) > this.lo && c.longPressTimer !== null && (window.clearTimeout(c.longPressTimer), c.longPressTimer = null), this.qn && this.qn(this.Lo(r, t, o, e));
|
|
2209
2209
|
}
|
|
2210
|
-
this.On.size === 2 ? this.
|
|
2210
|
+
this.On.size === 2 ? this.Ho(t) : this.In = null;
|
|
2211
2211
|
}
|
|
2212
|
-
|
|
2213
|
-
if (!this.
|
|
2212
|
+
wo(t) {
|
|
2213
|
+
if (!this.Br) return;
|
|
2214
2214
|
t.preventDefault();
|
|
2215
|
-
const e = performance.now(), i = this.
|
|
2215
|
+
const e = performance.now(), i = this.ko(t.changedTouches);
|
|
2216
2216
|
for (const s of i) {
|
|
2217
|
-
const r = this.On.get(s.id), n = r ? this.
|
|
2218
|
-
o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.
|
|
2217
|
+
const r = this.On.get(s.id), n = r ? this.Bo(r) : void 0, o = this.Hn.get(s.id);
|
|
2218
|
+
o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Zn && this.Zn(this.Lo(s, t, n, e)), o && this.Io(o, t), this.Hn.delete(s.id), this.Gn.delete(s.id), this.On.delete(s.id);
|
|
2219
2219
|
}
|
|
2220
|
-
this.On.size < 2 && (this.
|
|
2220
|
+
this.On.size < 2 && (this.In = null);
|
|
2221
2221
|
}
|
|
2222
|
-
|
|
2223
|
-
if (!this.
|
|
2222
|
+
bo(t) {
|
|
2223
|
+
if (!this.Br) return;
|
|
2224
2224
|
t.preventDefault();
|
|
2225
|
-
const e = performance.now(), i = this.
|
|
2225
|
+
const e = performance.now(), i = this.ko(t.changedTouches);
|
|
2226
2226
|
for (const s of i) {
|
|
2227
|
-
const r = this.On.get(s.id), n = r ? this.
|
|
2228
|
-
o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.
|
|
2227
|
+
const r = this.On.get(s.id), n = r ? this.Bo(r) : void 0, o = this.Hn.get(s.id);
|
|
2228
|
+
o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Qn && this.Qn(this.Lo(s, t, n, e)), this.Hn.delete(s.id), this.Gn.delete(s.id), this.On.delete(s.id);
|
|
2229
2229
|
}
|
|
2230
|
-
this.On.size < 2 && (this.
|
|
2230
|
+
this.On.size < 2 && (this.In = null);
|
|
2231
2231
|
}
|
|
2232
|
-
|
|
2232
|
+
ko(t) {
|
|
2233
2233
|
const e = [];
|
|
2234
2234
|
for (let i = 0; i < t.length; i += 1) {
|
|
2235
2235
|
const s = t.item(i);
|
|
2236
|
-
s && e.push(this.
|
|
2236
|
+
s && e.push(this.No(s));
|
|
2237
2237
|
}
|
|
2238
2238
|
return e;
|
|
2239
2239
|
}
|
|
2240
|
-
|
|
2241
|
-
return this.
|
|
2240
|
+
No(t) {
|
|
2241
|
+
return this.xo(t.clientX, t.clientY, t.identifier, { id: t.identifier, x: -1, y: -1, clientX: t.clientX, clientY: t.clientY, pressure: t.force, radiusX: t.radiusX, radiusY: t.radiusY, rotationAngle: t.rotationAngle });
|
|
2242
2242
|
}
|
|
2243
|
-
|
|
2244
|
-
const r = this.
|
|
2245
|
-
return { id: i, x: d ?
|
|
2243
|
+
xo(t, e, i, s) {
|
|
2244
|
+
const r = this.tr.canvas, n = r.getBoundingClientRect(), o = t - n.left, c = e - n.top, l = r.width / n.width, f = c * (r.height / n.height), u = o * l - this.Br.offsetX, m = f - this.Br.offsetY, p = Math.floor(u / this.Br.cellWidth), g = Math.floor(m / this.Br.cellHeight), d = p >= 0 && p < this.Br.cols && g >= 0 && g < this.Br.rows;
|
|
2245
|
+
return { id: i, x: d ? p : -1, y: d ? g : -1, clientX: t, clientY: e, pressure: s.pressure, radiusX: s.radiusX, radiusY: s.radiusY, rotationAngle: s.rotationAngle };
|
|
2246
2246
|
}
|
|
2247
2247
|
Lo(t, e, i, s) {
|
|
2248
|
-
const r = this.
|
|
2249
|
-
return { touch: this.
|
|
2248
|
+
const r = this.Hn.get(t.id), n = Array.from(this.Gn.values()).map((l) => this.Bo(l)), o = Array.from(this.On.values()).map((l) => this.Bo(l)), c = this.ko(e.changedTouches);
|
|
2249
|
+
return { touch: this.Bo(t), previousTouch: i ? this.Bo(i) : void 0, touches: o, previousTouches: n, changedTouches: c, deltaTime: r ? s - r.lastTime : 0, originalEvent: e };
|
|
2250
2250
|
}
|
|
2251
2251
|
Oo() {
|
|
2252
|
-
if (this.On.size !== 2) return void (this.
|
|
2253
|
-
const t = Array.from(this.On.values()), [e, i] = t, s = this.
|
|
2254
|
-
this.
|
|
2252
|
+
if (this.On.size !== 2) return void (this.In = null);
|
|
2253
|
+
const t = Array.from(this.On.values()), [e, i] = t, s = this.Go(e, i, !1), r = this.Xo(e, i);
|
|
2254
|
+
this.In = { ids: [e.id, i.id], initialDistance: Math.max(s, 1e-4), initialAngle: r, lastScale: 1, lastRotation: 0 };
|
|
2255
2255
|
}
|
|
2256
|
-
|
|
2257
|
-
if (this.
|
|
2258
|
-
const [e, i] = this.
|
|
2256
|
+
Ho(t) {
|
|
2257
|
+
if (this.In || this.Oo(), !this.In) return;
|
|
2258
|
+
const [e, i] = this.In.ids, s = this.On.get(e), r = this.On.get(i);
|
|
2259
2259
|
if (!s || !r) return;
|
|
2260
|
-
const n = this.
|
|
2261
|
-
this.
|
|
2262
|
-
let c = this.
|
|
2260
|
+
const n = this.Go(s, r, !1) / this.In.initialDistance, o = n - this.In.lastScale;
|
|
2261
|
+
this.ro && Math.abs(o) > this.do && (this.ro({ touches: [this.Bo(s), this.Bo(r)], scale: n, deltaScale: o, center: this.Wo(s, r), originalEvent: t }), this.In.lastScale = n);
|
|
2262
|
+
let c = this.Xo(s, r) - this.In.initialAngle;
|
|
2263
2263
|
c = (c + 180) % 360 - 180;
|
|
2264
|
-
const l = c - this.
|
|
2265
|
-
this.
|
|
2264
|
+
const l = c - this.In.lastRotation;
|
|
2265
|
+
this.no && Math.abs(l) > this._o && (this.no({ touches: [this.Bo(s), this.Bo(r)], rotation: c, deltaRotation: l, center: this.Wo(s, r), originalEvent: t }), this.In.lastRotation = c);
|
|
2266
2266
|
}
|
|
2267
|
-
|
|
2268
|
-
const i = (t.clientX + e.clientX) / 2, s = (t.clientY + e.clientY) / 2, r = this.
|
|
2267
|
+
Wo(t, e) {
|
|
2268
|
+
const i = (t.clientX + e.clientX) / 2, s = (t.clientY + e.clientY) / 2, r = this.xo(i, s, -1, { id: -1, x: -1, y: -1, clientX: i, clientY: s });
|
|
2269
2269
|
return { x: r.x, y: r.y };
|
|
2270
2270
|
}
|
|
2271
|
-
|
|
2272
|
-
const i = performance.now(), s = i - t.startTime, r = this.
|
|
2273
|
-
if (!t.longPressFired && s <= this.
|
|
2274
|
-
this.
|
|
2275
|
-
else if (!t.longPressFired && s <= this.
|
|
2271
|
+
Io(t, e) {
|
|
2272
|
+
const i = performance.now(), s = i - t.startTime, r = this.Go(t.startPosition, t.lastPosition, !0);
|
|
2273
|
+
if (!t.longPressFired && s <= this.oo && r <= this.ao)
|
|
2274
|
+
this.Ko(t.lastPosition, i) && this.so ? this.so({ touch: this.Bo(t.lastPosition), taps: 2, originalEvent: e }) : this.Jn && this.Jn({ touch: this.Bo(t.lastPosition), taps: 1, originalEvent: e });
|
|
2275
|
+
else if (!t.longPressFired && s <= this.fo && r >= this.uo) {
|
|
2276
2276
|
const n = { x: t.lastPosition.clientX - t.startPosition.clientX, y: t.lastPosition.clientY - t.startPosition.clientY }, o = Math.max(Math.hypot(n.x, n.y), 1e-4), c = { x: n.x / o, y: n.y / o }, l = { x: n.x / s, y: n.y / s };
|
|
2277
|
-
this.
|
|
2277
|
+
this.io && this.io({ touch: this.Bo(t.lastPosition), direction: c, distance: o, velocity: l, originalEvent: e });
|
|
2278
2278
|
}
|
|
2279
|
-
this.vo = i, this.
|
|
2279
|
+
this.vo = i, this.mo = this.Bo(t.lastPosition);
|
|
2280
2280
|
}
|
|
2281
|
-
|
|
2282
|
-
return !this.
|
|
2281
|
+
Ko(t, e) {
|
|
2282
|
+
return !this.mo || e - this.vo > this.ho ? !1 : this.Go(t, this.mo, !0) <= this.ao;
|
|
2283
2283
|
}
|
|
2284
|
-
|
|
2284
|
+
Bo(t) {
|
|
2285
2285
|
return { ...t };
|
|
2286
2286
|
}
|
|
2287
|
-
|
|
2287
|
+
Go(t, e, i) {
|
|
2288
2288
|
return i ? Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY) : Math.hypot(t.x - e.x, t.y - e.y);
|
|
2289
2289
|
}
|
|
2290
|
-
|
|
2290
|
+
Xo(t, e) {
|
|
2291
2291
|
return 180 * Math.atan2(e.clientY - t.clientY, e.clientX - t.clientX) / Math.PI;
|
|
2292
2292
|
}
|
|
2293
2293
|
}
|
|
2294
|
-
const
|
|
2294
|
+
const kt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: ot }, Symbol.toStringTag, { value: "Module" })), Vt = (a) => class extends a {
|
|
2295
2295
|
rotate(t = 0, e = 0, i = 0) {
|
|
2296
|
-
this.xt.state.
|
|
2296
|
+
this.xt.state.st(t), this.xt.state.et(e), this.xt.state.it(i);
|
|
2297
2297
|
}
|
|
2298
2298
|
rotateX(t) {
|
|
2299
|
-
this.xt.state.
|
|
2299
|
+
this.xt.state.st(t);
|
|
2300
2300
|
}
|
|
2301
2301
|
rotateY(t) {
|
|
2302
|
-
this.xt.state.
|
|
2302
|
+
this.xt.state.et(t);
|
|
2303
2303
|
}
|
|
2304
2304
|
rotateZ(t) {
|
|
2305
2305
|
this.xt.state.it(t);
|
|
@@ -2311,19 +2311,19 @@ const Jt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
|
|
|
2311
2311
|
this.xt.state.Z();
|
|
2312
2312
|
}
|
|
2313
2313
|
rect(t, e, i = 1, s = 1) {
|
|
2314
|
-
this.xt.
|
|
2314
|
+
this.xt.Ne(t, e, i, s);
|
|
2315
2315
|
}
|
|
2316
2316
|
point(t, e) {
|
|
2317
|
-
this.xt.
|
|
2317
|
+
this.xt.Ne(t, e, 1, 1);
|
|
2318
2318
|
}
|
|
2319
2319
|
line(t, e, i, s) {
|
|
2320
|
-
this.xt.
|
|
2320
|
+
this.xt.Xe(t, e, i, s);
|
|
2321
2321
|
}
|
|
2322
2322
|
lineWeight(t) {
|
|
2323
2323
|
this.xt.state.tt(t);
|
|
2324
2324
|
}
|
|
2325
2325
|
background(t, e = t, i = t, s = 255) {
|
|
2326
|
-
this.xt.
|
|
2326
|
+
this.xt.qe(t, e, i, s);
|
|
2327
2327
|
}
|
|
2328
2328
|
char(t) {
|
|
2329
2329
|
this.xt.state.rt(this.Ei.Pi(t));
|
|
@@ -2347,444 +2347,64 @@ const Jt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
|
|
|
2347
2347
|
this.xt.state.lt(t);
|
|
2348
2348
|
}
|
|
2349
2349
|
clear() {
|
|
2350
|
-
this.xt.
|
|
2350
|
+
this.xt.qe(0, 0, 0, 0);
|
|
2351
2351
|
}
|
|
2352
2352
|
ellipse(t, e, i, s) {
|
|
2353
|
-
this.xt.
|
|
2353
|
+
this.xt.We(t, e, i / 2, s / 2);
|
|
2354
2354
|
}
|
|
2355
2355
|
triangle(t, e, i, s, r, n) {
|
|
2356
|
-
this.xt.
|
|
2356
|
+
this.xt.Ke(t, e, i, s, r, n);
|
|
2357
2357
|
}
|
|
2358
2358
|
bezierCurve(t, e, i, s, r, n, o, c) {
|
|
2359
|
-
this.xt.
|
|
2359
|
+
this.xt.Ye(t, e, i, s, r, n, o, c);
|
|
2360
2360
|
}
|
|
2361
2361
|
arc(t, e, i, s, r, n) {
|
|
2362
|
-
this.xt.
|
|
2362
|
+
this.xt.Ve(t, e, i, s, r, n);
|
|
2363
2363
|
}
|
|
2364
2364
|
shader(t) {
|
|
2365
|
-
this.xt.
|
|
2365
|
+
this.xt.Be(t);
|
|
2366
2366
|
}
|
|
2367
2367
|
setUniform(t, e) {
|
|
2368
|
-
this.xt.
|
|
2368
|
+
this.xt.Kt(t, e);
|
|
2369
2369
|
}
|
|
2370
2370
|
setUniforms(t) {
|
|
2371
|
-
this.xt.
|
|
2371
|
+
this.xt.Le(t);
|
|
2372
2372
|
}
|
|
2373
2373
|
createFilterShader(t) {
|
|
2374
|
-
return this.xt.
|
|
2374
|
+
return this.xt.hs(t);
|
|
2375
2375
|
}
|
|
2376
2376
|
createFramebuffer(t) {
|
|
2377
|
-
return this.xt.
|
|
2377
|
+
return this.xt.je(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
|
|
2378
2378
|
}
|
|
2379
2379
|
image(t, e, i, s, r) {
|
|
2380
2380
|
if (t.textures) {
|
|
2381
2381
|
const n = t;
|
|
2382
|
-
this.xt.
|
|
2382
|
+
this.xt.Oe(n, e, i, s ?? n.width, r ?? n.height);
|
|
2383
2383
|
} else {
|
|
2384
2384
|
const n = t;
|
|
2385
|
-
this.xt.
|
|
2385
|
+
this.xt.Ge(n, e, i, s ?? Math.floor(this.Br.cols / 2), r ?? Math.floor(this.Br.rows / 2));
|
|
2386
2386
|
}
|
|
2387
2387
|
}
|
|
2388
2388
|
async loadImage(t) {
|
|
2389
|
-
if (typeof t != "string") return
|
|
2389
|
+
if (typeof t != "string") return G.Mr(this.xt, t, (s) => this.Ei.Si(s));
|
|
2390
2390
|
const e = t, i = await new Promise((s, r) => {
|
|
2391
2391
|
const n = new Image();
|
|
2392
2392
|
n.crossOrigin = "anonymous", n.onload = () => s(n), n.onerror = (o) => r(o), n.src = e;
|
|
2393
2393
|
});
|
|
2394
|
-
return
|
|
2395
|
-
}
|
|
2396
|
-
};
|
|
2397
|
-
class J {
|
|
2398
|
-
Ko(t) {
|
|
2399
|
-
const e = t.zt(0), i = t.zt(1), s = t.zt(2), r = t.zt(3);
|
|
2400
|
-
return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: s, transformPixels: t.zt(4), rotationPixels: r };
|
|
2401
|
-
}
|
|
2402
|
-
Yo(t, e) {
|
|
2403
|
-
return t[e] + (t[e + 1] << 8);
|
|
2404
|
-
}
|
|
2405
|
-
qo(t, e) {
|
|
2406
|
-
return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
class $ {
|
|
2410
|
-
Zo(t, e) {
|
|
2411
|
-
return new Blob([t], { type: e });
|
|
2412
|
-
}
|
|
2413
|
-
Qo(t, e, i) {
|
|
2414
|
-
try {
|
|
2415
|
-
const s = this.Zo(t, i), r = URL.createObjectURL(s), n = document.createElement("a");
|
|
2416
|
-
n.href = r, n.download = e, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(r);
|
|
2417
|
-
} catch (s) {
|
|
2418
|
-
console.error("Failed to download file:", s);
|
|
2419
|
-
}
|
|
2420
|
-
}
|
|
2421
|
-
Jo() {
|
|
2422
|
-
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
|
|
2423
|
-
}
|
|
2424
|
-
th() {
|
|
2425
|
-
const t = /* @__PURE__ */ new Date();
|
|
2426
|
-
return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
|
|
2427
|
-
}
|
|
2428
|
-
eh(t) {
|
|
2429
|
-
return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
|
|
2430
|
-
}
|
|
2431
|
-
sh() {
|
|
2432
|
-
return "textmode-export-" + this.Jo();
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
class Qt extends J {
|
|
2436
|
-
ih(t, e, i) {
|
|
2437
|
-
const s = t[i] === 255, r = t[i + 1] === 255, n = t[i + 2] === 255, o = e[i], c = e[i + 1];
|
|
2438
|
-
return { isInverted: s, flipHorizontal: r, flipVertical: n, rotation: Math.round(360 * (o + c / 255) / 255 * 100) / 100 };
|
|
2439
|
-
}
|
|
2440
|
-
rh(t, e, i) {
|
|
2441
|
-
return { x: t, y: e, cellX: t * i.cellWidth, cellY: e * i.cellHeight };
|
|
2442
|
-
}
|
|
2443
|
-
nh(t, e) {
|
|
2444
|
-
const i = [];
|
|
2445
|
-
let s = 0;
|
|
2446
|
-
for (let r = 0; r < e.rows; r++) for (let n = 0; n < e.cols; n++) {
|
|
2447
|
-
const o = 4 * s, c = this.Yo(t.characterPixels, o);
|
|
2448
|
-
let l = this.qo(t.primaryColorPixels, o), u = this.qo(t.secondaryColorPixels, o);
|
|
2449
|
-
const f = this.ih(t.transformPixels, t.rotationPixels, o);
|
|
2450
|
-
if (f.isInverted) {
|
|
2451
|
-
const v = l;
|
|
2452
|
-
l = u, u = v;
|
|
2453
|
-
}
|
|
2454
|
-
const g = this.rh(n, r, e);
|
|
2455
|
-
i.push({ charIndex: c, primaryColor: l, secondaryColor: u, transform: f, position: g }), s++;
|
|
2456
|
-
}
|
|
2457
|
-
return i;
|
|
2458
|
-
}
|
|
2459
|
-
}
|
|
2460
|
-
class te {
|
|
2461
|
-
oh(t, e) {
|
|
2462
|
-
const i = t.cmap;
|
|
2463
|
-
for (const s of i.tables) if (s.format === 4) {
|
|
2464
|
-
const r = s;
|
|
2465
|
-
for (let n = 0; n < r.startCount.length; n++) if (e >= r.startCount[n] && e <= r.endCount[n]) {
|
|
2466
|
-
if (r.idRangeOffset[n] === 0) return e + r.idDelta[n] & 65535;
|
|
2467
|
-
{
|
|
2468
|
-
const o = r.idRangeOffset[n] / 2 + (e - r.startCount[n]) - (r.startCount.length - n);
|
|
2469
|
-
if (o >= 0 && o < r.glyphIdArray.length) {
|
|
2470
|
-
const c = r.glyphIdArray[o];
|
|
2471
|
-
if (c !== 0) return c + r.idDelta[n] & 65535;
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
} else if (s.format === 12) {
|
|
2476
|
-
const r = s;
|
|
2477
|
-
for (let n = 0; n < r.groups.length; n += 3) {
|
|
2478
|
-
const o = r.groups[n], c = r.groups[n + 1], l = r.groups[n + 2];
|
|
2479
|
-
if (e >= o && e <= c) return l + (e - o);
|
|
2480
|
-
}
|
|
2481
|
-
}
|
|
2482
|
-
return 0;
|
|
2483
|
-
}
|
|
2484
|
-
hh(t, e, i, s, r) {
|
|
2485
|
-
const n = r / t.head.unitsPerEm;
|
|
2486
|
-
return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: s + -e.yMax * n, x2: i + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.ah(e, i, s, n) };
|
|
2487
|
-
}
|
|
2488
|
-
ah(t, e, i, s) {
|
|
2489
|
-
if (!t || !t.xs) return "";
|
|
2490
|
-
const { xs: r, ys: n, endPts: o, flags: c } = t;
|
|
2491
|
-
if (!(r && n && o && c)) return "";
|
|
2492
|
-
let l = "", u = 0;
|
|
2493
|
-
for (let f = 0; f < o.length; f++) {
|
|
2494
|
-
const g = o[f];
|
|
2495
|
-
if (!(g < u)) {
|
|
2496
|
-
if (g >= u) {
|
|
2497
|
-
const v = e + r[u] * s, m = i - n[u] * s;
|
|
2498
|
-
l += `M${v.toFixed(2)},${m.toFixed(2)}`;
|
|
2499
|
-
let d = u + 1;
|
|
2500
|
-
for (; d <= g; )
|
|
2501
|
-
if (1 & c[d]) {
|
|
2502
|
-
const A = e + r[d] * s, p = i - n[d] * s;
|
|
2503
|
-
l += `L${A.toFixed(2)},${p.toFixed(2)}`, d++;
|
|
2504
|
-
} else {
|
|
2505
|
-
const A = e + r[d] * s, p = i - n[d] * s;
|
|
2506
|
-
let x = d + 1 > g ? u : d + 1;
|
|
2507
|
-
if (1 & c[x]) {
|
|
2508
|
-
const y = e + r[x] * s, C = i - n[x] * s;
|
|
2509
|
-
l += `Q${A.toFixed(2)},${p.toFixed(2)} ${y.toFixed(2)},${C.toFixed(2)}`, d = x + 1;
|
|
2510
|
-
} else {
|
|
2511
|
-
const y = (A + (e + r[x] * s)) / 2, C = (p + (i - n[x] * s)) / 2;
|
|
2512
|
-
l += `Q${A.toFixed(2)},${p.toFixed(2)} ${y.toFixed(2)},${C.toFixed(2)}`, d = x;
|
|
2513
|
-
}
|
|
2514
|
-
}
|
|
2515
|
-
l += "Z";
|
|
2516
|
-
}
|
|
2517
|
-
u = g + 1;
|
|
2518
|
-
}
|
|
2519
|
-
}
|
|
2520
|
-
return l;
|
|
2521
|
-
}
|
|
2522
|
-
uh(t, e, i, s, r) {
|
|
2523
|
-
const n = t.codePointAt(0) || 0, o = this.oh(e, n);
|
|
2524
|
-
let c = null;
|
|
2525
|
-
return e.glyf && e.glyf[o] !== null ? c = e.glyf[o] : (c = L.T.glyf.Js(e, o), e.glyf[o] = c), this.hh(e, c, i, s, r);
|
|
2526
|
-
}
|
|
2527
|
-
fh(t, e, i, s, r, n, o, c) {
|
|
2528
|
-
const l = i + (r - c * (o / e.head.unitsPerEm)) / 2, u = s + (n + 0.7 * o) / 2;
|
|
2529
|
-
return this.uh(t, e, l, u, o).toSVG() || null;
|
|
2530
|
-
}
|
|
2531
|
-
}
|
|
2532
|
-
class ee {
|
|
2533
|
-
constructor() {
|
|
2534
|
-
h(this, "dh");
|
|
2535
|
-
this.dh = new te();
|
|
2536
|
-
}
|
|
2537
|
-
ph(t) {
|
|
2538
|
-
const { width: e, height: i } = t;
|
|
2539
|
-
return `<?xml version="1.0" encoding="UTF-8"?><svg width="${e}" height="${i}" viewBox="0 0 ${e} ${i}" xmlns="http://www.w3.org/2000/svg"><title>textmode.js sketch</title>`;
|
|
2540
|
-
}
|
|
2541
|
-
_h() {
|
|
2542
|
-
return "</g></svg>";
|
|
2543
|
-
}
|
|
2544
|
-
mh(t, e) {
|
|
2545
|
-
if (!e.includeBackgroundRectangles) return "";
|
|
2546
|
-
const [i, s, r, n] = e.backgroundColor;
|
|
2547
|
-
return `<rect width="${t.width}" height="${t.height}" fill="rgba(${i},${s},${r},${n / 255})"/>`;
|
|
2548
|
-
}
|
|
2549
|
-
gh(t, e) {
|
|
2550
|
-
const { transform: i, position: s } = t;
|
|
2551
|
-
if (!i.flipHorizontal && !i.flipVertical && !i.rotation) return "";
|
|
2552
|
-
const r = s.cellX + e.cellWidth / 2, n = s.cellY + e.cellHeight / 2, o = [];
|
|
2553
|
-
if (i.flipHorizontal || i.flipVertical) {
|
|
2554
|
-
const c = i.flipHorizontal ? -1 : 1, l = i.flipVertical ? -1 : 1;
|
|
2555
|
-
o.push(`translate(${r} ${n})scale(${c} ${l})translate(${-r} ${-n})`);
|
|
2556
|
-
}
|
|
2557
|
-
return i.rotation && o.push(`rotate(${i.rotation} ${r} ${n})`), ` transform="${o.join(" ")}"`;
|
|
2558
|
-
}
|
|
2559
|
-
wh(t, e, i) {
|
|
2560
|
-
if (!i.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
|
|
2561
|
-
const { position: s } = t, { r, g: n, b: o, a: c } = t.secondaryColor, l = `rgba(${r},${n},${o},${c / 255})`;
|
|
2562
|
-
return i.drawMode === "stroke" ? `<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${l}" fill="none" stroke-width="${i.strokeWidth}"/>` : `<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${l}"/>`;
|
|
2563
|
-
}
|
|
2564
|
-
uh(t, e, i, s) {
|
|
2565
|
-
const r = i.characters[t.charIndex];
|
|
2566
|
-
if (!r) return "";
|
|
2567
|
-
const n = this.dh.fh(r.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, r.advanceWidth);
|
|
2568
|
-
if (!n) return "";
|
|
2569
|
-
const { r: o, g: c, b: l, a: u } = t.primaryColor, f = `rgba(${o},${c},${l},${u / 255})`;
|
|
2570
|
-
return s.drawMode === "stroke" ? `<path d="${n}" stroke="${f}" stroke-width="${s.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${f}"/>`;
|
|
2571
|
-
}
|
|
2572
|
-
yh(t, e, i, s) {
|
|
2573
|
-
const r = [], n = this.wh(t, e, s);
|
|
2574
|
-
n && r.push(n);
|
|
2575
|
-
const o = this.uh(t, e, i, s);
|
|
2576
|
-
if (o) {
|
|
2577
|
-
const c = this.gh(t, e);
|
|
2578
|
-
r.push(c ? `<g${c}>${o}</g>` : o);
|
|
2579
|
-
}
|
|
2580
|
-
return r.join("");
|
|
2581
|
-
}
|
|
2582
|
-
Ch(t, e, i, s) {
|
|
2583
|
-
const r = [this.ph(e), this.mh(e, s), '<g id="ascii-cells">'];
|
|
2584
|
-
for (const n of t) r.push(this.yh(n, e, i, s));
|
|
2585
|
-
return r.push(this._h()), r.join("");
|
|
2586
|
-
}
|
|
2587
|
-
Ah(t) {
|
|
2588
|
-
return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\s+/g, " ").replace(/> </g, "><");
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
class ie extends $ {
|
|
2592
|
-
bh(t) {
|
|
2593
|
-
return this.Zo(t, "image/svg+xml;charset=utf-8");
|
|
2594
|
-
}
|
|
2595
|
-
xh(t, e) {
|
|
2596
|
-
this.Qo(t, this.eh(e) + ".svg", "image/svg+xml;charset=utf-8");
|
|
2597
|
-
}
|
|
2598
|
-
Mh(t, e) {
|
|
2599
|
-
this.xh(t, e || this.sh());
|
|
2600
|
-
}
|
|
2601
|
-
}
|
|
2602
|
-
class st {
|
|
2603
|
-
constructor() {
|
|
2604
|
-
h(this, "$h");
|
|
2605
|
-
h(this, "Fh");
|
|
2606
|
-
h(this, "Th");
|
|
2607
|
-
this.$h = new Qt(), this.Fh = new ee(), this.Th = new ie();
|
|
2608
|
-
}
|
|
2609
|
-
Rh(t) {
|
|
2610
|
-
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.Th.sh() };
|
|
2611
|
-
}
|
|
2612
|
-
zh(t, e = {}) {
|
|
2613
|
-
const i = this.$h.nh(this.$h.Ko(t.pipeline), t.grid), s = this.Fh.Ch(i, t.grid, t.font, this.Rh(e));
|
|
2614
|
-
return this.Fh.Ah(s);
|
|
2615
|
-
}
|
|
2616
|
-
Mh(t, e = {}) {
|
|
2617
|
-
this.Th.Mh(this.zh(t, e), e.filename);
|
|
2618
|
-
}
|
|
2619
|
-
}
|
|
2620
|
-
class se extends J {
|
|
2621
|
-
Ph(t, e, i, s = " ") {
|
|
2622
|
-
var o;
|
|
2623
|
-
const r = [];
|
|
2624
|
-
let n = 0;
|
|
2625
|
-
for (let c = 0; c < e.rows; c++) {
|
|
2626
|
-
const l = [];
|
|
2627
|
-
for (let u = 0; u < e.cols; u++) {
|
|
2628
|
-
const f = 4 * n, g = this.Yo(t.characterPixels, f), v = ((o = i.characters[g]) == null ? void 0 : o.character) || s;
|
|
2629
|
-
l.push(v), n++;
|
|
2630
|
-
}
|
|
2631
|
-
r.push(l);
|
|
2632
|
-
}
|
|
2633
|
-
return r;
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
class re {
|
|
2637
|
-
Sh(t, e) {
|
|
2638
|
-
const i = [];
|
|
2639
|
-
for (const r of t) {
|
|
2640
|
-
let n = r.join("");
|
|
2641
|
-
e.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")), i.push(n);
|
|
2642
|
-
}
|
|
2643
|
-
const s = e.lineEnding === "crlf" ? `\r
|
|
2644
|
-
` : `
|
|
2645
|
-
`;
|
|
2646
|
-
return i.join(s);
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
class ne extends $ {
|
|
2650
|
-
Eh(t, e) {
|
|
2651
|
-
const i = this.Dh(e);
|
|
2652
|
-
this.Qo(t, i, "text/plain;charset=utf-8");
|
|
2653
|
-
}
|
|
2654
|
-
Dh(t) {
|
|
2655
|
-
let e = this.eh(t);
|
|
2656
|
-
return e === ".txt" || e.length <= 4 ? this.sh() : e;
|
|
2657
|
-
}
|
|
2658
|
-
}
|
|
2659
|
-
class rt {
|
|
2660
|
-
constructor() {
|
|
2661
|
-
h(this, "$h");
|
|
2662
|
-
h(this, "Fh");
|
|
2663
|
-
h(this, "Th");
|
|
2664
|
-
this.$h = new se(), this.Fh = new re(), this.Th = new ne();
|
|
2665
|
-
}
|
|
2666
|
-
Rh(t) {
|
|
2667
|
-
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.Th.sh() };
|
|
2668
|
-
}
|
|
2669
|
-
kh(t, e = {}) {
|
|
2670
|
-
const i = this.Rh(e), s = this.$h.Ph(this.$h.Ko(t.pipeline), t.grid, t.font, i.emptyCharacter);
|
|
2671
|
-
return this.Fh.Sh(s, i);
|
|
2672
|
-
}
|
|
2673
|
-
Eh(t, e = {}) {
|
|
2674
|
-
this.Th.Eh(this.kh(t, e), e.filename);
|
|
2675
|
-
}
|
|
2676
|
-
}
|
|
2677
|
-
class oe extends J {
|
|
2678
|
-
Bh(t, e = 1, i = "transparent") {
|
|
2679
|
-
const s = t.canvas;
|
|
2680
|
-
if (e === 1 && i === "transparent") return s;
|
|
2681
|
-
const r = document.createElement("canvas"), n = r.getContext("2d"), o = Math.round(s.width * e), c = Math.round(s.height * e);
|
|
2682
|
-
return r.width = o, r.height = c, i !== "transparent" && (n.fillStyle = i, n.fillRect(0, 0, o, c)), n.imageSmoothingEnabled = !1, n.drawImage(s, 0, 0, s.width, s.height, 0, 0, o, c), r;
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
2685
|
-
class he {
|
|
2686
|
-
Gh(t, e) {
|
|
2687
|
-
const i = this.Lh(e.format);
|
|
2688
|
-
return e.format === "png" ? t.toDataURL(i) : t.toDataURL(i, e.quality);
|
|
2689
|
-
}
|
|
2690
|
-
async Oh(t, e) {
|
|
2691
|
-
return new Promise((i, s) => {
|
|
2692
|
-
const r = this.Lh(e.format), n = (o) => {
|
|
2693
|
-
o ? i(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
|
|
2694
|
-
};
|
|
2695
|
-
e.format === "png" ? t.toBlob(n, r) : t.toBlob(n, r, e.quality);
|
|
2696
|
-
});
|
|
2697
|
-
}
|
|
2698
|
-
Lh(t) {
|
|
2699
|
-
switch (t) {
|
|
2700
|
-
case "png":
|
|
2701
|
-
return "image/png";
|
|
2702
|
-
case "jpg":
|
|
2703
|
-
return "image/jpeg";
|
|
2704
|
-
case "webp":
|
|
2705
|
-
return "image/webp";
|
|
2706
|
-
default:
|
|
2707
|
-
throw Error("Unsupported image format: " + t);
|
|
2708
|
-
}
|
|
2709
|
-
}
|
|
2710
|
-
}
|
|
2711
|
-
const ae = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, nt = { png: ".png", jpg: ".jpg", webp: ".webp" };
|
|
2712
|
-
class ce extends $ {
|
|
2713
|
-
Hh(t, e, i) {
|
|
2714
|
-
this.Ih(t, this.eh(e) + nt[i]);
|
|
2715
|
-
}
|
|
2716
|
-
Ih(t, e) {
|
|
2717
|
-
const i = URL.createObjectURL(t);
|
|
2718
|
-
try {
|
|
2719
|
-
const s = document.createElement("a");
|
|
2720
|
-
s.href = i, s.download = e, s.style.display = "none", s.rel = "noopener", document.body.appendChild(s), s.click(), document.body.removeChild(s);
|
|
2721
|
-
} finally {
|
|
2722
|
-
URL.revokeObjectURL(i);
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
Nh(t) {
|
|
2726
|
-
return t in ae && t in nt;
|
|
2727
|
-
}
|
|
2728
|
-
}
|
|
2729
|
-
class le {
|
|
2730
|
-
constructor() {
|
|
2731
|
-
h(this, "$h");
|
|
2732
|
-
h(this, "Fh");
|
|
2733
|
-
h(this, "Th");
|
|
2734
|
-
this.$h = new oe(), this.Fh = new he(), this.Th = new ce();
|
|
2735
|
-
}
|
|
2736
|
-
Rh(t) {
|
|
2737
|
-
return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.Th.sh() };
|
|
2738
|
-
}
|
|
2739
|
-
Xh(t) {
|
|
2740
|
-
if (!this.Th.Nh(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
|
|
2741
|
-
if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
|
|
2742
|
-
if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
|
|
2743
|
-
t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
|
|
2744
|
-
}
|
|
2745
|
-
async Oh(t, e) {
|
|
2746
|
-
if (e.scale === 1 && e.backgroundColor === "transparent") return await this.Fh.Oh(t.canvas, e);
|
|
2747
|
-
const i = this.$h.Bh(t, e.scale, e.backgroundColor);
|
|
2748
|
-
return await this.Fh.Oh(i, e);
|
|
2749
|
-
}
|
|
2750
|
-
async Hh(t, e = {}) {
|
|
2751
|
-
const i = this.Rh(e);
|
|
2752
|
-
this.Xh(i);
|
|
2753
|
-
const s = await this.Oh(t, i);
|
|
2754
|
-
this.Th.Hh(s, i.filename, i.format);
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
const ue = (a) => class extends a {
|
|
2758
|
-
Wh() {
|
|
2759
|
-
this.xt.St(this.Vh);
|
|
2760
|
-
}
|
|
2761
|
-
toString(t = {}) {
|
|
2762
|
-
return this.Wh(), new rt().kh({ pipeline: this.jh, grid: this.Gr, font: this.Ei }, t);
|
|
2763
|
-
}
|
|
2764
|
-
saveStrings(t = {}) {
|
|
2765
|
-
this.Wh(), new rt().Eh({ pipeline: this.jh, grid: this.Gr, font: this.Ei }, t);
|
|
2766
|
-
}
|
|
2767
|
-
toSVG(t = {}) {
|
|
2768
|
-
return this.Wh(), new st().zh({ pipeline: this.jh, grid: this.Gr, font: this.Ei }, t);
|
|
2769
|
-
}
|
|
2770
|
-
saveSVG(t = {}) {
|
|
2771
|
-
this.Wh(), new st().Mh({ pipeline: this.jh, grid: this.Gr, font: this.Ei }, t);
|
|
2772
|
-
}
|
|
2773
|
-
async saveCanvas(t = {}) {
|
|
2774
|
-
await new le().Hh(this.er, t);
|
|
2394
|
+
return G.Mr(this.xt, i, (s) => this.Ei.Si(s));
|
|
2775
2395
|
}
|
|
2776
|
-
},
|
|
2396
|
+
}, qt = (a) => class extends a {
|
|
2777
2397
|
async loadFont(t) {
|
|
2778
|
-
return this.Ei.
|
|
2398
|
+
return this.Ei.Vi(t).then(() => {
|
|
2779
2399
|
const e = this.Ei.maxGlyphDimensions;
|
|
2780
|
-
this.
|
|
2400
|
+
this.Br.rr(e.width, e.height), this.Yo.resize(this.Br.cols, this.Br.rows), this.xt.Ze(), this.Ln.rn();
|
|
2781
2401
|
});
|
|
2782
2402
|
}
|
|
2783
2403
|
fontSize(t) {
|
|
2784
|
-
if (!N.
|
|
2785
|
-
this.Ei.
|
|
2404
|
+
if (!N.m(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ei.fontSize === t) return;
|
|
2405
|
+
this.Ei.ji(t);
|
|
2786
2406
|
const e = this.Ei.maxGlyphDimensions;
|
|
2787
|
-
this.
|
|
2407
|
+
this.Br.rr(e.width, e.height), this.Yo.resize(this.Br.cols, this.Br.rows), this.xt.Ze(), this.Ln.rn();
|
|
2788
2408
|
}
|
|
2789
2409
|
glyphColor(t) {
|
|
2790
2410
|
return this.Ei.Pi(t);
|
|
@@ -2792,29 +2412,29 @@ const ue = (a) => class extends a {
|
|
|
2792
2412
|
glyphColors(t) {
|
|
2793
2413
|
return this.Ei.Si(t);
|
|
2794
2414
|
}
|
|
2795
|
-
},
|
|
2415
|
+
}, Kt = (a) => class extends a {
|
|
2796
2416
|
get frameCount() {
|
|
2797
|
-
return this.
|
|
2417
|
+
return this.jo.frameCount;
|
|
2798
2418
|
}
|
|
2799
2419
|
set frameCount(t) {
|
|
2800
|
-
this.
|
|
2420
|
+
this.jo.frameCount = t;
|
|
2801
2421
|
}
|
|
2802
2422
|
frameRate(t) {
|
|
2803
|
-
return t === void 0 ? this.
|
|
2423
|
+
return t === void 0 ? this.jo.currentFrameRate : this.jo.frameRate(t, () => this.Vo());
|
|
2804
2424
|
}
|
|
2805
2425
|
noLoop() {
|
|
2806
|
-
this.
|
|
2426
|
+
this.jo.pause();
|
|
2807
2427
|
}
|
|
2808
2428
|
loop() {
|
|
2809
|
-
this.
|
|
2429
|
+
this.jo.resume(() => this.Vo());
|
|
2810
2430
|
}
|
|
2811
2431
|
redraw(t = 1) {
|
|
2812
|
-
if (N.
|
|
2432
|
+
if (N.m(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.Vo();
|
|
2813
2433
|
}
|
|
2814
2434
|
isLooping() {
|
|
2815
|
-
return this.
|
|
2435
|
+
return this.jo.isLooping;
|
|
2816
2436
|
}
|
|
2817
|
-
},
|
|
2437
|
+
}, Zt = (a) => class extends a {
|
|
2818
2438
|
constructor(...t) {
|
|
2819
2439
|
super(...t);
|
|
2820
2440
|
}
|
|
@@ -2822,210 +2442,235 @@ const ue = (a) => class extends a {
|
|
|
2822
2442
|
this.Ln._n(t);
|
|
2823
2443
|
}
|
|
2824
2444
|
mousePressed(t) {
|
|
2825
|
-
this.Ln.
|
|
2445
|
+
this.Ln.pn(t);
|
|
2826
2446
|
}
|
|
2827
2447
|
mouseReleased(t) {
|
|
2828
|
-
this.Ln.
|
|
2448
|
+
this.Ln.vn(t);
|
|
2829
2449
|
}
|
|
2830
2450
|
mouseMoved(t) {
|
|
2831
|
-
this.Ln.
|
|
2451
|
+
this.Ln.mn(t);
|
|
2832
2452
|
}
|
|
2833
2453
|
mouseScrolled(t) {
|
|
2834
|
-
this.Ln.
|
|
2454
|
+
this.Ln.gn(t);
|
|
2835
2455
|
}
|
|
2836
2456
|
get mouse() {
|
|
2837
|
-
return this.Ln.
|
|
2457
|
+
return this.Ln.An();
|
|
2838
2458
|
}
|
|
2839
2459
|
cursor(t) {
|
|
2840
|
-
this.Ln.
|
|
2460
|
+
this.Ln.en(t);
|
|
2841
2461
|
}
|
|
2842
|
-
},
|
|
2462
|
+
}, Qt = (a) => class extends a {
|
|
2843
2463
|
constructor(...t) {
|
|
2844
2464
|
super(...t);
|
|
2845
2465
|
}
|
|
2846
2466
|
touchStarted(t) {
|
|
2847
|
-
this.
|
|
2467
|
+
this.qo.Fo(t);
|
|
2848
2468
|
}
|
|
2849
2469
|
touchMoved(t) {
|
|
2850
|
-
this.
|
|
2470
|
+
this.qo.mn(t);
|
|
2851
2471
|
}
|
|
2852
2472
|
touchEnded(t) {
|
|
2853
|
-
this.
|
|
2473
|
+
this.qo.zo(t);
|
|
2854
2474
|
}
|
|
2855
2475
|
touchCancelled(t) {
|
|
2856
|
-
this.
|
|
2476
|
+
this.qo.Ro(t);
|
|
2857
2477
|
}
|
|
2858
2478
|
tap(t) {
|
|
2859
|
-
this.
|
|
2479
|
+
this.qo.To(t);
|
|
2860
2480
|
}
|
|
2861
2481
|
doubleTap(t) {
|
|
2862
|
-
this.
|
|
2482
|
+
this.qo.Po(t);
|
|
2863
2483
|
}
|
|
2864
2484
|
longPress(t) {
|
|
2865
|
-
this.
|
|
2485
|
+
this.qo.So(t);
|
|
2866
2486
|
}
|
|
2867
2487
|
swipe(t) {
|
|
2868
|
-
this.
|
|
2488
|
+
this.qo.Eo(t);
|
|
2869
2489
|
}
|
|
2870
2490
|
pinch(t) {
|
|
2871
|
-
this.
|
|
2491
|
+
this.qo.$o(t);
|
|
2872
2492
|
}
|
|
2873
2493
|
rotateGesture(t) {
|
|
2874
|
-
this.
|
|
2494
|
+
this.qo.Do(t);
|
|
2875
2495
|
}
|
|
2876
2496
|
get touches() {
|
|
2877
|
-
return this.
|
|
2497
|
+
return this.qo.Mo();
|
|
2878
2498
|
}
|
|
2879
|
-
},
|
|
2499
|
+
}, Jt = (a) => class extends a {
|
|
2880
2500
|
constructor(...t) {
|
|
2881
2501
|
super(...t);
|
|
2882
2502
|
}
|
|
2883
2503
|
keyPressed(t) {
|
|
2884
|
-
this.
|
|
2504
|
+
this.Zo.pn(t);
|
|
2885
2505
|
}
|
|
2886
2506
|
keyReleased(t) {
|
|
2887
|
-
this.
|
|
2507
|
+
this.Zo.vn(t);
|
|
2888
2508
|
}
|
|
2889
2509
|
isKeyPressed(t) {
|
|
2890
|
-
return this.
|
|
2510
|
+
return this.Zo.Pn(t);
|
|
2891
2511
|
}
|
|
2892
2512
|
get lastKeyPressed() {
|
|
2893
|
-
return this.
|
|
2513
|
+
return this.Zo.En();
|
|
2894
2514
|
}
|
|
2895
2515
|
get lastKeyReleased() {
|
|
2896
|
-
return this.
|
|
2516
|
+
return this.Zo.$n();
|
|
2897
2517
|
}
|
|
2898
2518
|
get pressedKeys() {
|
|
2899
|
-
return this.
|
|
2519
|
+
return this.Zo.Dn();
|
|
2900
2520
|
}
|
|
2901
2521
|
get modifierState() {
|
|
2902
|
-
return this.
|
|
2522
|
+
return this.Zo.kn();
|
|
2903
2523
|
}
|
|
2904
2524
|
};
|
|
2905
|
-
class
|
|
2525
|
+
class $t {
|
|
2906
2526
|
constructor() {
|
|
2907
2527
|
h(this, "xt");
|
|
2908
2528
|
h(this, "Ei");
|
|
2909
|
-
h(this, "
|
|
2910
|
-
h(this, "
|
|
2911
|
-
h(this, "
|
|
2529
|
+
h(this, "tr");
|
|
2530
|
+
h(this, "Br");
|
|
2531
|
+
h(this, "jo");
|
|
2912
2532
|
h(this, "Ln");
|
|
2913
|
-
h(this, "
|
|
2914
|
-
h(this, "
|
|
2915
|
-
h(this, "
|
|
2916
|
-
h(this, "
|
|
2917
|
-
h(this, "
|
|
2918
|
-
h(this, "
|
|
2919
|
-
h(this, "
|
|
2533
|
+
h(this, "qo");
|
|
2534
|
+
h(this, "Zo");
|
|
2535
|
+
h(this, "Qo");
|
|
2536
|
+
h(this, "Yo");
|
|
2537
|
+
h(this, "Jo");
|
|
2538
|
+
h(this, "th");
|
|
2539
|
+
h(this, "sh");
|
|
2920
2540
|
}
|
|
2921
|
-
|
|
2541
|
+
Vo() {
|
|
2922
2542
|
}
|
|
2923
2543
|
}
|
|
2924
|
-
class
|
|
2544
|
+
class te extends function(e, ...i) {
|
|
2925
2545
|
return i.reduce((s, r) => r(s), e);
|
|
2926
|
-
}(
|
|
2546
|
+
}($t, Vt, qt, Kt, Zt, Qt, Jt) {
|
|
2927
2547
|
constructor(e = {}) {
|
|
2548
|
+
var i;
|
|
2928
2549
|
super();
|
|
2929
|
-
h(this, "
|
|
2930
|
-
h(this, "
|
|
2550
|
+
h(this, "eh", /* @__PURE__ */ new Map());
|
|
2551
|
+
h(this, "ih");
|
|
2552
|
+
h(this, "rh", !1);
|
|
2553
|
+
h(this, "nh", !1);
|
|
2554
|
+
h(this, "oh", () => {
|
|
2931
2555
|
});
|
|
2932
|
-
h(this, "
|
|
2556
|
+
h(this, "hh", () => {
|
|
2933
2557
|
});
|
|
2934
|
-
h(this, "
|
|
2558
|
+
h(this, "ah", () => {
|
|
2935
2559
|
});
|
|
2936
|
-
h(this, "
|
|
2937
|
-
h(this, "
|
|
2938
|
-
h(this, "
|
|
2939
|
-
h(this, "
|
|
2940
|
-
this.
|
|
2941
|
-
}
|
|
2942
|
-
async
|
|
2943
|
-
await this.Ei.
|
|
2560
|
+
h(this, "uh");
|
|
2561
|
+
h(this, "ar");
|
|
2562
|
+
h(this, "hr", !1);
|
|
2563
|
+
h(this, "fh");
|
|
2564
|
+
this.ih = ((i = e.plugins) == null ? void 0 : i.slice()) ?? [], this.hr = e.overlay ?? !1, this.tr = new Yt(e), this.xt = new Ut(this.tr.vr()), this.Ei = new Gt(this.xt, e.fontSize ?? 16), this.jo = new Wt(e.frameRate ?? 60), this.Ln = new rt(this.tr), this.qo = new ot(this.tr, this.Ln), this.Zo = new nt(), this.Qo = this.xt.Pt(), this.Jo = this.xt.rs(), this.dh(e);
|
|
2565
|
+
}
|
|
2566
|
+
async dh(e) {
|
|
2567
|
+
await this.Ei.Wi(e.fontSource);
|
|
2944
2568
|
const i = this.Ei.maxGlyphDimensions;
|
|
2945
|
-
this.
|
|
2946
|
-
}
|
|
2947
|
-
|
|
2948
|
-
this.
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2569
|
+
this.Br = new Xt(this.tr.canvas, i.width, i.height), this.Ln.Wi(this.Br), this.qo.Wi(this.Br), this.Yo = this.xt.je(this.Br.cols, this.Br.rows, 5), this.th = this.xt.je(this.Br.width, this.Br.height, 1), this.hr && (this.fh = G.Mr(this.xt, this.tr.targetCanvas, (s) => this.Ei.Si(s))), this.sh = this.xt.cs(st, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this._h(), await this.ph(this.ih), this.ih = [], this.rh = !0, this.oh(), this.jo.start(() => this.Vo());
|
|
2570
|
+
}
|
|
2571
|
+
async ph(e) {
|
|
2572
|
+
if (e.length) for (const i of e) this.eh.has(i.name) ? console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`) : (await i.install(this, this.mh()), this.eh.set(i.name, i));
|
|
2573
|
+
}
|
|
2574
|
+
async gh(e) {
|
|
2575
|
+
const i = this.eh.get(e);
|
|
2576
|
+
i && (i.uninstall && await i.uninstall(this, this.mh()), this.eh.delete(e));
|
|
2577
|
+
}
|
|
2578
|
+
async use(e) {
|
|
2579
|
+
return this.rh ? await this.ph([e]) : this.ih.push(e), this;
|
|
2580
|
+
}
|
|
2581
|
+
async unuse(e) {
|
|
2582
|
+
return this.rh ? (await this.gh(e), this) : (this.ih = this.ih.filter((i) => i.name !== e), this);
|
|
2583
|
+
}
|
|
2584
|
+
hasPlugin(e) {
|
|
2585
|
+
return this.rh ? this.eh.has(e) : this.ih.some((i) => i.name === e) || this.eh.has(e);
|
|
2586
|
+
}
|
|
2587
|
+
mh() {
|
|
2588
|
+
return { renderer: this.xt, font: this.Ei, grid: this.Br, canvas: this.tr, drawFramebuffer: this.Yo, asciiFramebuffer: this.th, flushDrawCommands: () => {
|
|
2589
|
+
this.xt.St(this.Qo);
|
|
2590
|
+
} };
|
|
2591
|
+
}
|
|
2592
|
+
_h() {
|
|
2593
|
+
this.uh = () => {
|
|
2594
|
+
this.hr && this.resizeCanvas(this.tr.targetCanvas.width, this.tr.targetCanvas.height), this.ah();
|
|
2595
|
+
}, window.addEventListener("resize", this.uh), this.Ln.nn(), this.qo.nn(), this.Zo.nn(), window.addEventListener("blur", () => {
|
|
2596
|
+
this.Zo.Bn();
|
|
2597
|
+
}), window.ResizeObserver && this.hr && (this.ar = new ResizeObserver(() => {
|
|
2598
|
+
this.resizeCanvas(this.tr.targetCanvas.width, this.tr.targetCanvas.height);
|
|
2599
|
+
}), this.ar.observe(this.tr.targetCanvas));
|
|
2600
|
+
}
|
|
2601
|
+
Vo() {
|
|
2602
|
+
if (this.jo.measureFrameRate(), this.jo.incrementFrame(), this.nh) return;
|
|
2603
|
+
if (this.hr) {
|
|
2959
2604
|
const i = this.xt.context;
|
|
2960
|
-
i.bindTexture(i.TEXTURE_2D, this.
|
|
2605
|
+
i.bindTexture(i.TEXTURE_2D, this.fh.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.tr.targetCanvas), i.bindTexture(i.TEXTURE_2D, null);
|
|
2961
2606
|
}
|
|
2962
|
-
this.
|
|
2607
|
+
this.Yo.begin(), this.xt.ke(this.Qo), this.hh(), this.xt.St(this.Qo), this.Yo.end(), this.th.begin(), this.xt.ke(this.Jo), this.Jo.Wt({ U0: this.Ei.fontFramebuffer, U1: [this.Ei.textureColumns, this.Ei.textureRows], U2: this.Yo.textures[0], U3: this.Yo.textures[1], U4: this.Yo.textures[2], U5: this.Yo.textures[4], U6: this.Yo.textures[3], U7: [this.Br.cols, this.Br.rows], U8: [this.th.width, this.th.height], U9: this.th.width / this.th.height }), this.xt.Ie(0, 0, this.tr.width, this.tr.height), this.th.end();
|
|
2963
2608
|
const e = this.xt.state.canvasBackgroundColor;
|
|
2964
|
-
this.xt.
|
|
2609
|
+
this.xt.js(e[0], e[1], e[2], e[3]), this.xt.ke(this.sh), this.sh.Wt({ Ua: this.th.textures[0], Ub: [this.th.width, this.th.height], Uc: [this.Br.offsetX, this.Br.offsetY], Ud: [this.Br.width, this.Br.height] }), this.xt.Ie(this.Br.offsetX, this.Br.offsetY, this.Br.width, this.Br.height);
|
|
2965
2610
|
}
|
|
2966
2611
|
setup(e) {
|
|
2967
|
-
this.
|
|
2612
|
+
this.oh = e;
|
|
2968
2613
|
}
|
|
2969
2614
|
draw(e) {
|
|
2970
|
-
this.
|
|
2615
|
+
this.hh = e;
|
|
2971
2616
|
}
|
|
2972
2617
|
windowResized(e) {
|
|
2973
|
-
this.
|
|
2618
|
+
this.ah = e;
|
|
2974
2619
|
}
|
|
2975
2620
|
resizeCanvas(e, i) {
|
|
2976
|
-
this.
|
|
2621
|
+
this.tr.pr(e, i), this.Br.ir(), this.Yo.resize(this.Br.cols, this.Br.rows), this.th.resize(this.Br.width, this.Br.height), this.xt.Ze(), this.Ln.rn(), this.qo.Ao(), this.Vo();
|
|
2977
2622
|
}
|
|
2978
2623
|
destroy() {
|
|
2979
|
-
this.
|
|
2624
|
+
this.nh || (this.jo.stop(), window.removeEventListener("resize", this.uh), this.Ln.dn(), this.qo.dn(), this.Zo.dn(), this.Ei.Dt(), this.xt.Dt(), this.th.Dt(), this.sh.Dt(), this.fh && this.fh.Dt(), this.nh = !0);
|
|
2980
2625
|
}
|
|
2981
2626
|
get grid() {
|
|
2982
|
-
return this.
|
|
2627
|
+
return this.Br;
|
|
2983
2628
|
}
|
|
2984
2629
|
get font() {
|
|
2985
2630
|
return this.Ei;
|
|
2986
2631
|
}
|
|
2987
2632
|
get width() {
|
|
2988
|
-
return this.
|
|
2633
|
+
return this.tr.width;
|
|
2989
2634
|
}
|
|
2990
2635
|
get height() {
|
|
2991
|
-
return this.
|
|
2636
|
+
return this.tr.height;
|
|
2992
2637
|
}
|
|
2993
2638
|
get canvas() {
|
|
2994
|
-
return this.
|
|
2639
|
+
return this.tr.canvas;
|
|
2995
2640
|
}
|
|
2996
2641
|
get isDisposed() {
|
|
2997
|
-
return this.
|
|
2642
|
+
return this.nh;
|
|
2998
2643
|
}
|
|
2999
2644
|
get overlay() {
|
|
3000
|
-
return this.
|
|
2645
|
+
return this.fh;
|
|
3001
2646
|
}
|
|
3002
2647
|
}
|
|
3003
2648
|
class Q {
|
|
3004
2649
|
constructor() {
|
|
3005
2650
|
}
|
|
3006
2651
|
static create(t = {}) {
|
|
3007
|
-
return new
|
|
2652
|
+
return new te(t);
|
|
3008
2653
|
}
|
|
3009
2654
|
static setErrorLevel(t) {
|
|
3010
|
-
N.
|
|
2655
|
+
N.A(t);
|
|
3011
2656
|
}
|
|
3012
2657
|
static get version() {
|
|
3013
|
-
return "0.3.1";
|
|
2658
|
+
return "0.3.2-beta.1";
|
|
3014
2659
|
}
|
|
3015
2660
|
}
|
|
3016
|
-
const
|
|
2661
|
+
const ie = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), se = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: jt, mouse: Ht, touch: kt }, Symbol.toStringTag, { value: "Module" })), re = Q.create, ne = Q.setErrorLevel, oe = Q.version;
|
|
3017
2662
|
export {
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
2663
|
+
Yt as TextmodeCanvas,
|
|
2664
|
+
ct as TextmodeErrorLevel,
|
|
2665
|
+
Gt as TextmodeFont,
|
|
2666
|
+
K as TextmodeFramebuffer,
|
|
2667
|
+
Xt as TextmodeGrid,
|
|
2668
|
+
G as TextmodeImage,
|
|
2669
|
+
te as Textmodifier,
|
|
2670
|
+
re as create,
|
|
2671
|
+
ie as export,
|
|
2672
|
+
se as input,
|
|
2673
|
+
ne as setErrorLevel,
|
|
3029
2674
|
Q as textmode,
|
|
3030
|
-
|
|
2675
|
+
oe as version
|
|
3031
2676
|
};
|