textmode.js 0.2.0 → 0.2.1-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/dist/textmode.esm.js +1145 -906
- package/dist/textmode.esm.min.js +1391 -1152
- package/dist/textmode.umd.js +21 -21
- package/dist/textmode.umd.min.js +18 -18
- package/dist/types/textmode/Textmodifier.d.ts +8 -2
- package/dist/types/textmode/keyboard/KeyboardManager.d.ts +123 -0
- package/dist/types/textmode/keyboard/index.d.ts +2 -0
- package/dist/types/textmode/mixins/KeyboardMixin.d.ts +39 -0
- package/dist/types/textmode/mixins/MouseMixin.d.ts +27 -0
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +19 -0
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +6 -0
- package/dist/types/textmode/mixins/index.d.ts +4 -0
- package/dist/types/textmode/mouse/MouseManager.d.ts +130 -0
- package/dist/types/textmode/mouse/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/textmode.esm.min.js
CHANGED
|
@@ -1,156 +1,156 @@
|
|
|
1
|
-
var
|
|
2
|
-
var q = (a, t, e) => t in a ?
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
|
+
var q = (a, t, e) => t in a ? J(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var h = (a, t, e) => q(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
class T extends Error {
|
|
5
5
|
constructor(t, e = {}) {
|
|
6
|
-
super(
|
|
6
|
+
super(T.i(t, e)), this.name = "TextmodeError";
|
|
7
7
|
}
|
|
8
8
|
static i(t, e) {
|
|
9
|
-
let
|
|
9
|
+
let i = t;
|
|
10
10
|
if (e && Object.keys(e).length > 0) {
|
|
11
|
-
|
|
11
|
+
i += `
|
|
12
12
|
|
|
13
13
|
📋 Context:`;
|
|
14
|
-
for (const [
|
|
15
|
-
|
|
16
|
-
- ${
|
|
14
|
+
for (const [s, r] of Object.entries(e))
|
|
15
|
+
i += `
|
|
16
|
+
- ${s}: ${T.o(r)}`;
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return i += `
|
|
19
19
|
|
|
20
|
-
`,
|
|
21
|
-
`,
|
|
20
|
+
`, i += "↓".repeat(24) + `
|
|
21
|
+
`, i;
|
|
22
22
|
}
|
|
23
23
|
static o(t) {
|
|
24
24
|
if (t === null) return "null";
|
|
25
25
|
if (t === void 0) return "undefined";
|
|
26
26
|
if (typeof t == "string") return `"${t}"`;
|
|
27
27
|
if (typeof t == "number" || typeof t == "boolean") return t + "";
|
|
28
|
-
if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) =>
|
|
28
|
+
if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => T.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => T.o(e)).join(", ")}, ... +${t.length - 3} more]`;
|
|
29
29
|
if (typeof t == "object") {
|
|
30
30
|
const e = Object.keys(t);
|
|
31
|
-
return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((
|
|
31
|
+
return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${T.o(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${T.o(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
|
|
32
32
|
}
|
|
33
33
|
return t + "";
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
var
|
|
36
|
+
var Q = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(Q || {});
|
|
37
37
|
const A = class A {
|
|
38
38
|
constructor() {
|
|
39
|
-
|
|
39
|
+
h(this, "u", { globalLevel: 3 });
|
|
40
40
|
}
|
|
41
41
|
static p() {
|
|
42
42
|
return A.l || (A.l = new A()), A.l;
|
|
43
43
|
}
|
|
44
44
|
_(t, e) {
|
|
45
|
-
const
|
|
45
|
+
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;";
|
|
46
46
|
switch (this.u.globalLevel) {
|
|
47
47
|
case 0:
|
|
48
48
|
return !1;
|
|
49
49
|
case 1:
|
|
50
|
-
return console.group(
|
|
50
|
+
return console.group(i, s), console.warn(T.i(t, e)), console.groupEnd(), !1;
|
|
51
51
|
case 2:
|
|
52
|
-
return console.group(
|
|
52
|
+
return console.group(i, s), console.error(T.i(t, e)), console.groupEnd(), !1;
|
|
53
53
|
default:
|
|
54
|
-
throw new
|
|
54
|
+
throw new T(t, e);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
m(t, e,
|
|
58
|
-
return !!t || (this._(e,
|
|
57
|
+
m(t, e, i) {
|
|
58
|
+
return !!t || (this._(e, i), !1);
|
|
59
59
|
}
|
|
60
60
|
v(t) {
|
|
61
61
|
this.u.globalLevel = t;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
let
|
|
66
|
-
const
|
|
67
|
-
function
|
|
68
|
-
|
|
64
|
+
h(A, "l", null);
|
|
65
|
+
let z = A;
|
|
66
|
+
const D = z.p(), H = /* @__PURE__ */ new WeakMap();
|
|
67
|
+
function I(a, t) {
|
|
68
|
+
H.set(a, t);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
70
|
+
function L(a) {
|
|
71
|
+
return H.get(a);
|
|
72
72
|
}
|
|
73
|
-
class
|
|
74
|
-
constructor(t, e,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.C = e, this.$ =
|
|
73
|
+
class G {
|
|
74
|
+
constructor(t, e, i = e, s = 1, r = {}) {
|
|
75
|
+
h(this, "C");
|
|
76
|
+
h(this, "$");
|
|
77
|
+
h(this, "u");
|
|
78
|
+
h(this, "R", null);
|
|
79
|
+
h(this, "S");
|
|
80
|
+
h(this, "P");
|
|
81
|
+
h(this, "M", []);
|
|
82
|
+
h(this, "F");
|
|
83
|
+
h(this, "A", null);
|
|
84
|
+
h(this, "D", []);
|
|
85
|
+
this.C = e, this.$ = i, this.u = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.S = t, this.F = Math.min(Math.max(1, s), 8);
|
|
86
86
|
const n = t.getParameter(t.MAX_DRAW_BUFFERS), o = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
|
|
87
|
-
this.
|
|
87
|
+
this.F = Math.min(this.F, n, o), this.P = t.createFramebuffer(), this.G(), this.k(), this.D = Array(this.F).fill(null);
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
const t = this.S, e = this.u.filter === "linear" ? t.LINEAR : t.NEAREST,
|
|
91
|
-
for (let
|
|
89
|
+
G() {
|
|
90
|
+
const t = this.S, 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;
|
|
91
|
+
for (let r = 0; r < this.F; r++) {
|
|
92
92
|
const n = t.createTexture();
|
|
93
|
-
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,
|
|
93
|
+
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.C, this.$, 0, t.RGBA, s, null), this.M.push(n);
|
|
94
94
|
}
|
|
95
95
|
t.bindTexture(t.TEXTURE_2D, null);
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
k() {
|
|
98
98
|
const t = this.S;
|
|
99
|
-
if (t.bindFramebuffer(t.FRAMEBUFFER, this.
|
|
99
|
+
if (t.bindFramebuffer(t.FRAMEBUFFER, this.P), this.F === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.M[0], 0);
|
|
100
100
|
else {
|
|
101
|
-
const
|
|
102
|
-
for (let
|
|
103
|
-
const
|
|
104
|
-
t.framebufferTexture2D(t.FRAMEBUFFER,
|
|
101
|
+
const i = [];
|
|
102
|
+
for (let s = 0; s < this.F; s++) {
|
|
103
|
+
const r = t.COLOR_ATTACHMENT0 + s;
|
|
104
|
+
t.framebufferTexture2D(t.FRAMEBUFFER, r, t.TEXTURE_2D, this.M[s], 0), i.push(r);
|
|
105
105
|
}
|
|
106
|
-
t.drawBuffers(
|
|
106
|
+
t.drawBuffers(i);
|
|
107
107
|
}
|
|
108
108
|
const e = t.checkFramebufferStatus(t.FRAMEBUFFER);
|
|
109
109
|
e !== t.FRAMEBUFFER_COMPLETE && console.error("GLFramebuffer is not complete:", e), t.bindFramebuffer(t.FRAMEBUFFER, null);
|
|
110
110
|
}
|
|
111
111
|
L(t) {
|
|
112
112
|
const e = this.S;
|
|
113
|
-
e.bindTexture(e.TEXTURE_2D, this.
|
|
113
|
+
e.bindTexture(e.TEXTURE_2D, this.M[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);
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
this.C = t, this.$ = e, this.R = null, this.
|
|
117
|
-
const
|
|
118
|
-
for (const
|
|
119
|
-
|
|
115
|
+
I(t, e) {
|
|
116
|
+
this.C = t, this.$ = e, this.R = null, this.D = Array(this.F).fill(null);
|
|
117
|
+
const i = this.S, s = this.u.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
|
|
118
|
+
for (const r of this.M) i.bindTexture(i.TEXTURE_2D, r), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.C, this.$, 0, i.RGBA, s, null);
|
|
119
|
+
i.bindTexture(i.TEXTURE_2D, null);
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
W(t) {
|
|
122
122
|
const e = this.S;
|
|
123
|
-
if (t < 0 || t >= this.
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
e.bindFramebuffer(e.READ_FRAMEBUFFER, this.
|
|
128
|
-
const
|
|
129
|
-
for (let d = 0; d <
|
|
130
|
-
const u = (
|
|
131
|
-
l.set(n.subarray(u, u +
|
|
123
|
+
if (t < 0 || t >= this.F) throw Error(`GLFramebuffer: attachment index ${t} out of range (count=${this.F})`);
|
|
124
|
+
const i = this.D[t];
|
|
125
|
+
if (i) return i;
|
|
126
|
+
const s = this.C, r = this.$, n = new Uint8Array(s * r * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
|
|
127
|
+
e.bindFramebuffer(e.READ_FRAMEBUFFER, this.P), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, s, r, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
|
|
128
|
+
const c = 4 * s, l = new Uint8Array(n.length);
|
|
129
|
+
for (let d = 0; d < r; d++) {
|
|
130
|
+
const u = (r - 1 - d) * c, f = d * c;
|
|
131
|
+
l.set(n.subarray(u, u + c), f);
|
|
132
132
|
}
|
|
133
|
-
return this.
|
|
133
|
+
return this.D[t] = l, l;
|
|
134
134
|
}
|
|
135
135
|
U() {
|
|
136
|
-
for (let t = 0; t < this.
|
|
136
|
+
for (let t = 0; t < this.F; t++) this.W(t);
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
O() {
|
|
139
139
|
const t = this.S;
|
|
140
|
-
this.
|
|
141
|
-
for (let e = 0; e < this.
|
|
142
|
-
t.viewport(0, 0, this.C, this.$),
|
|
140
|
+
this.A = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.P), this.D = Array(this.F).fill(null);
|
|
141
|
+
for (let e = 0; e < this.F; e++) t.clearBufferfv(t.COLOR, e, new Float32Array([0, 0, 0, 0]));
|
|
142
|
+
t.viewport(0, 0, this.C, this.$), I(t, [0, 0, this.C, this.$]);
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
if (!this.
|
|
144
|
+
V() {
|
|
145
|
+
if (!this.A) return;
|
|
146
146
|
const t = this.S;
|
|
147
|
-
t.bindFramebuffer(t.FRAMEBUFFER, this.
|
|
147
|
+
t.bindFramebuffer(t.FRAMEBUFFER, this.A.framebuffer), t.viewport(...this.A.viewport), I(t, this.A.viewport), this.A = null;
|
|
148
148
|
}
|
|
149
149
|
j() {
|
|
150
150
|
const t = this.S;
|
|
151
|
-
this.
|
|
152
|
-
for (const e of this.
|
|
153
|
-
this.
|
|
151
|
+
this.P && t.deleteFramebuffer(this.P);
|
|
152
|
+
for (const e of this.M) t.deleteTexture(e);
|
|
153
|
+
this.M = [], this.D = [];
|
|
154
154
|
}
|
|
155
155
|
get width() {
|
|
156
156
|
return this.C;
|
|
@@ -165,100 +165,100 @@ class $ {
|
|
|
165
165
|
return { ...this.u };
|
|
166
166
|
}
|
|
167
167
|
get framebuffer() {
|
|
168
|
-
return this.
|
|
168
|
+
return this.P;
|
|
169
169
|
}
|
|
170
170
|
get texture() {
|
|
171
|
-
return this.
|
|
171
|
+
return this.M[0];
|
|
172
172
|
}
|
|
173
173
|
get textures() {
|
|
174
|
-
return [...this.
|
|
174
|
+
return [...this.M];
|
|
175
175
|
}
|
|
176
176
|
get attachmentCount() {
|
|
177
|
-
return this.
|
|
177
|
+
return this.F;
|
|
178
178
|
}
|
|
179
179
|
getAttachmentPixels(t) {
|
|
180
|
-
return this.
|
|
180
|
+
return this.D[t] ?? null;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
class
|
|
184
|
-
constructor(t, e,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
this.S = t, this.H = this.
|
|
192
|
-
}
|
|
193
|
-
|
|
183
|
+
class O {
|
|
184
|
+
constructor(t, e, i) {
|
|
185
|
+
h(this, "S");
|
|
186
|
+
h(this, "H");
|
|
187
|
+
h(this, "K", /* @__PURE__ */ new Map());
|
|
188
|
+
h(this, "X", /* @__PURE__ */ new Map());
|
|
189
|
+
h(this, "Y", 0);
|
|
190
|
+
h(this, "N");
|
|
191
|
+
this.S = t, this.H = this.q(e, i), this.N = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.Z();
|
|
192
|
+
}
|
|
193
|
+
Z() {
|
|
194
194
|
const t = this.S.getProgramParameter(this.H, this.S.ACTIVE_UNIFORMS);
|
|
195
195
|
for (let e = 0; e < t; e++) {
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
199
|
-
|
|
196
|
+
const i = this.S.getActiveUniform(this.H, e);
|
|
197
|
+
if (i) {
|
|
198
|
+
const s = this.S.getUniformLocation(this.H, i.name);
|
|
199
|
+
s && (this.K.set(i.name, s), this.X.set(i.name, i.type));
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
if (this.S.attachShader(
|
|
206
|
-
const n = this.S.getProgramInfoLog(
|
|
203
|
+
q(t, e) {
|
|
204
|
+
const i = this.J(this.S.VERTEX_SHADER, t), s = this.J(this.S.FRAGMENT_SHADER, e), r = this.S.createProgram();
|
|
205
|
+
if (this.S.attachShader(r, i), this.S.attachShader(r, s), this.S.linkProgram(r), !this.S.getProgramParameter(r, this.S.LINK_STATUS)) {
|
|
206
|
+
const n = this.S.getProgramInfoLog(r);
|
|
207
207
|
throw Error("Shader program link error: " + n);
|
|
208
208
|
}
|
|
209
|
-
return this.S.deleteShader(
|
|
209
|
+
return this.S.deleteShader(i), this.S.deleteShader(s), r;
|
|
210
210
|
}
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
if (this.S.shaderSource(
|
|
214
|
-
const
|
|
215
|
-
throw this.S.deleteShader(
|
|
211
|
+
J(t, e) {
|
|
212
|
+
const i = this.S.createShader(t);
|
|
213
|
+
if (this.S.shaderSource(i, e), this.S.compileShader(i), !this.S.getShaderParameter(i, this.S.COMPILE_STATUS)) {
|
|
214
|
+
const s = this.S.getShaderInfoLog(i);
|
|
215
|
+
throw this.S.deleteShader(i), Error("Shader compilation error: " + s);
|
|
216
216
|
}
|
|
217
|
-
return
|
|
217
|
+
return i;
|
|
218
218
|
}
|
|
219
219
|
tt() {
|
|
220
220
|
this.S.useProgram(this.H), this.et();
|
|
221
221
|
}
|
|
222
222
|
et() {
|
|
223
|
-
this.
|
|
223
|
+
this.Y = 0;
|
|
224
224
|
}
|
|
225
225
|
st(t) {
|
|
226
|
-
for (const [e,
|
|
226
|
+
for (const [e, i] of Object.entries(t)) this.it(e, i);
|
|
227
227
|
}
|
|
228
228
|
rt(t) {
|
|
229
|
-
return this.
|
|
229
|
+
return this.K.has(t);
|
|
230
230
|
}
|
|
231
231
|
it(t, e) {
|
|
232
232
|
if (this.S.getParameter(this.S.CURRENT_PROGRAM) !== this.H) return void console.warn(`Attempting to set uniform '${t}' on shader that is not currently bound`);
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
235
|
-
else if (typeof e == "boolean") this.S.uniform1i(
|
|
233
|
+
const i = this.K.get(t);
|
|
234
|
+
if (i) if (typeof e == "number") this.S.uniform1f(i, e);
|
|
235
|
+
else if (typeof e == "boolean") this.S.uniform1i(i, e ? 1 : 0);
|
|
236
236
|
else if (Array.isArray(e)) switch (e.length) {
|
|
237
237
|
case 2:
|
|
238
|
-
this.S.uniform2f(
|
|
238
|
+
this.S.uniform2f(i, e[0], e[1]);
|
|
239
239
|
break;
|
|
240
240
|
case 3:
|
|
241
|
-
this.S.uniform3f(
|
|
241
|
+
this.S.uniform3f(i, e[0], e[1], e[2]);
|
|
242
242
|
break;
|
|
243
243
|
case 4:
|
|
244
|
-
this.S.uniform4f(
|
|
244
|
+
this.S.uniform4f(i, e[0], e[1], e[2], e[3]);
|
|
245
245
|
break;
|
|
246
246
|
default:
|
|
247
247
|
console.warn(`Unsupported array length ${e.length} for uniform '${t}'`);
|
|
248
248
|
}
|
|
249
249
|
else if (e instanceof WebGLTexture) {
|
|
250
|
-
const
|
|
251
|
-
this.S.uniform1i(
|
|
252
|
-
} else if (e instanceof
|
|
253
|
-
const
|
|
254
|
-
this.S.uniform1i(
|
|
250
|
+
const s = this.nt();
|
|
251
|
+
this.S.uniform1i(i, s), this.S.activeTexture(this.S.TEXTURE0 + s), this.S.bindTexture(this.S.TEXTURE_2D, e);
|
|
252
|
+
} else if (e instanceof G) {
|
|
253
|
+
const s = this.nt();
|
|
254
|
+
this.S.uniform1i(i, s), this.S.activeTexture(this.S.TEXTURE0 + s), this.S.bindTexture(this.S.TEXTURE_2D, e.texture);
|
|
255
255
|
} else if (typeof e == "object" && "texture" in e) {
|
|
256
|
-
const
|
|
257
|
-
this.S.uniform1i(
|
|
256
|
+
const s = this.nt();
|
|
257
|
+
this.S.uniform1i(i, s), this.S.activeTexture(this.S.TEXTURE0 + s), this.S.bindTexture(this.S.TEXTURE_2D, e.texture);
|
|
258
258
|
} else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
|
|
259
259
|
}
|
|
260
260
|
nt() {
|
|
261
|
-
return this.
|
|
261
|
+
return this.Y >= this.N && console.warn(`Exceeded maximum texture units (${this.N}). Texture may not render correctly.`), this.Y++;
|
|
262
262
|
}
|
|
263
263
|
get ot() {
|
|
264
264
|
return this.H;
|
|
@@ -269,215 +269,215 @@ class G {
|
|
|
269
269
|
}
|
|
270
270
|
class tt {
|
|
271
271
|
constructor() {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
272
|
+
h(this, "ht", 1);
|
|
273
|
+
h(this, "ct", 0);
|
|
274
|
+
h(this, "lt", 0);
|
|
275
|
+
h(this, "ut", 0);
|
|
276
|
+
h(this, "dt", [0, 0, 0]);
|
|
277
|
+
h(this, "ft", [1, 1, 1, 1]);
|
|
278
|
+
h(this, "_t", [0, 0, 0, 1]);
|
|
279
|
+
h(this, "gt", !1);
|
|
280
|
+
h(this, "vt", !1);
|
|
281
|
+
h(this, "yt", !1);
|
|
282
|
+
h(this, "Ct", [0, 0]);
|
|
283
|
+
h(this, "xt", [0, 0, 0, 1]);
|
|
284
|
+
h(this, "wt", []);
|
|
285
285
|
}
|
|
286
286
|
$t() {
|
|
287
|
-
this.wt.push({ lineWeight: this.ht, rotationX: this.ct, rotationY: this.lt, rotationZ: this.ut, charRotation: [...this.Ct], flipHorizontally: this.gt, flipVertically: this.vt, invert: this.
|
|
287
|
+
this.wt.push({ lineWeight: this.ht, rotationX: this.ct, rotationY: this.lt, rotationZ: this.ut, charRotation: [...this.Ct], flipHorizontally: this.gt, flipVertically: this.vt, invert: this.yt, character: [...this.dt], charColor: [...this.ft], cellColor: [...this._t] });
|
|
288
288
|
}
|
|
289
289
|
bt() {
|
|
290
290
|
const t = this.wt.pop();
|
|
291
|
-
t ? (this.ht = t.lineWeight, this.ct = t.rotationX, this.lt = t.rotationY, this.ut = t.rotationZ, this.Ct = t.charRotation, this.gt = t.flipHorizontally, this.vt = t.flipVertically, this.
|
|
291
|
+
t ? (this.ht = t.lineWeight, this.ct = t.rotationX, this.lt = t.rotationY, this.ut = t.rotationZ, this.Ct = t.charRotation, this.gt = t.flipHorizontally, this.vt = t.flipVertically, this.yt = t.invert, this.dt = t.character, this.ft = t.charColor, this._t = t.cellColor) : console.warn("pop() called without matching push()");
|
|
292
292
|
}
|
|
293
|
-
|
|
293
|
+
Rt() {
|
|
294
294
|
this.wt = [], this.ct = 0, this.lt = 0, this.ut = 0;
|
|
295
295
|
}
|
|
296
|
-
|
|
297
|
-
t.lineWeight = this.ht, t.rotationX = this.ct, t.rotationY = this.lt, t.rotationZ = this.ut, t.character[0] = this.
|
|
296
|
+
zt(t) {
|
|
297
|
+
t.lineWeight = this.ht, t.rotationX = this.ct, t.rotationY = this.lt, t.rotationZ = this.ut, t.character[0] = this.dt[0], t.character[1] = this.dt[1], t.character[2] = this.dt[2], t.charColor[0] = this.ft[0], t.charColor[1] = this.ft[1], t.charColor[2] = this.ft[2], t.charColor[3] = this.ft[3], t.bgColor[0] = this._t[0], t.bgColor[1] = this._t[1], t.bgColor[2] = this._t[2], t.bgColor[3] = this._t[3], t.flipHorizontally = this.gt, t.flipVertically = this.vt, t.invert = this.yt, t.charRotation[0] = this.Ct[0], t.charRotation[1] = this.Ct[1];
|
|
298
298
|
}
|
|
299
299
|
get lineWeight() {
|
|
300
300
|
return this.ht;
|
|
301
301
|
}
|
|
302
302
|
get canvasBackgroundColor() {
|
|
303
|
-
return this.
|
|
303
|
+
return this.xt;
|
|
304
304
|
}
|
|
305
|
-
|
|
305
|
+
St(t) {
|
|
306
306
|
this.ht = Math.abs(t);
|
|
307
307
|
}
|
|
308
|
-
|
|
308
|
+
Tt(t) {
|
|
309
309
|
this.ct = t;
|
|
310
310
|
}
|
|
311
|
-
|
|
311
|
+
Pt(t) {
|
|
312
312
|
this.lt = t;
|
|
313
313
|
}
|
|
314
|
-
|
|
314
|
+
Mt(t) {
|
|
315
315
|
this.ut = t;
|
|
316
316
|
}
|
|
317
|
-
|
|
318
|
-
this.
|
|
317
|
+
Ft(t) {
|
|
318
|
+
this.dt = t;
|
|
319
319
|
}
|
|
320
|
-
|
|
321
|
-
this.
|
|
320
|
+
At(t, e, i, s = 255) {
|
|
321
|
+
this.ft = [t / 255, e / 255, i / 255, s / 255];
|
|
322
322
|
}
|
|
323
|
-
|
|
324
|
-
this._t = [t / 255, e / 255,
|
|
323
|
+
Dt(t, e, i, s = 255) {
|
|
324
|
+
this._t = [t / 255, e / 255, i / 255, s / 255];
|
|
325
325
|
}
|
|
326
|
-
|
|
326
|
+
Gt(t) {
|
|
327
327
|
this.gt = t;
|
|
328
328
|
}
|
|
329
|
-
|
|
329
|
+
kt(t) {
|
|
330
330
|
this.vt = t;
|
|
331
331
|
}
|
|
332
|
-
|
|
333
|
-
this.
|
|
332
|
+
Et(t) {
|
|
333
|
+
this.yt = t;
|
|
334
334
|
}
|
|
335
335
|
Lt(t) {
|
|
336
|
-
const e = 255 * t / 360,
|
|
337
|
-
this.Ct = [
|
|
336
|
+
const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
|
|
337
|
+
this.Ct = [i, s];
|
|
338
338
|
}
|
|
339
|
-
|
|
340
|
-
this.
|
|
339
|
+
Bt(t, e, i, s) {
|
|
340
|
+
this.xt = [t / 255, e / 255, i / 255, s / 255];
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
var
|
|
344
|
-
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 u_aspectRatio;uniform vec2 u_viewportSize;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 rotateX(float a){float s=sin(a),c=cos(a);return mat3(1,0,0,0,c,-s,0,s,c);}mat3 rotateY(float a){float s=sin(a),c=cos(a);return mat3(c,0,s,0,1,0,-s,0,c);}mat3 rotateZ(float a){float s=sin(a),c=cos(a);return mat3(c,-s,0,s,c,0,0,0,1);}vec2 evaluateBezier(float t,vec2 p0,vec2 p1,vec2 p2,vec2 p3){float u=1.-t,u2=u*u,t2=t*t;return u2*u*p0+3.*u2*t*p1+3.*u*t2*p2+t2*t*p3;}vec2 evaluateBezierDerivative(float t,vec2 p0,vec2 p1,vec2 p2,vec2 p3){float u=1.-t,u2=u*u,t2=t*t;return-3.*u2*p0+3.*u2*p1-6.*u*t*p1+6.*u*t*p2-3.*t2*p2+3.*t2*p3;}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 worldPosition;bool isBezier=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool isArc=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(isBezier){float t=a_position.x;vec2 curvePoint=evaluateBezier(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 tangent=evaluateBezierDerivative(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float tLen=length(tangent);tangent=tLen>0.?tangent/tLen:vec2(1,0);worldPosition=curvePoint+vec2(-tangent.y,tangent.x)*a_position.y*a_instanceSize.y;}else if(isArc){float s=a_instanceArcAngles.x,e=a_instanceArcAngles.y;s=mod(s,6.28318530718);if(s<0.)s+=6.28318530718;e=mod(e,6.28318530718);if(e<0.)e+=6.28318530718;float d=s-e;if(d<=0.)d+=6.28318530718;float angle=s-a_position.x*d;vec2 local=vec2(cos(angle),sin(angle))*a_position.y;worldPosition=local*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{worldPosition=a_position*a_instanceSize+a_instancePosition;}vec2 ndc=(worldPosition/u_viewportSize)*2.-1.;ndc.y=-ndc.y;if(length(a_instanceGlobalRotation)>0.){vec3 pos3D=vec3(ndc-a_instanceRotationCenter,0);pos3D.x*=u_aspectRatio;if(a_instanceGlobalRotation.x!=0.)pos3D=rotateX(-a_instanceGlobalRotation.x)*pos3D;if(a_instanceGlobalRotation.y!=0.)pos3D=rotateY(-a_instanceGlobalRotation.y)*pos3D;if(a_instanceGlobalRotation.z!=0.)pos3D=rotateZ(-a_instanceGlobalRotation.z)*pos3D;pos3D.x/=u_aspectRatio;ndc=pos3D.xy+a_instanceRotationCenter;}gl_Position=vec4(ndc,0,1);}`,
|
|
343
|
+
var W = `#version 300 es
|
|
344
|
+
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 u_aspectRatio;uniform vec2 u_viewportSize;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 rotateX(float a){float s=sin(a),c=cos(a);return mat3(1,0,0,0,c,-s,0,s,c);}mat3 rotateY(float a){float s=sin(a),c=cos(a);return mat3(c,0,s,0,1,0,-s,0,c);}mat3 rotateZ(float a){float s=sin(a),c=cos(a);return mat3(c,-s,0,s,c,0,0,0,1);}vec2 evaluateBezier(float t,vec2 p0,vec2 p1,vec2 p2,vec2 p3){float u=1.-t,u2=u*u,t2=t*t;return u2*u*p0+3.*u2*t*p1+3.*u*t2*p2+t2*t*p3;}vec2 evaluateBezierDerivative(float t,vec2 p0,vec2 p1,vec2 p2,vec2 p3){float u=1.-t,u2=u*u,t2=t*t;return-3.*u2*p0+3.*u2*p1-6.*u*t*p1+6.*u*t*p2-3.*t2*p2+3.*t2*p3;}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 worldPosition;bool isBezier=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool isArc=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(isBezier){float t=a_position.x;vec2 curvePoint=evaluateBezier(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 tangent=evaluateBezierDerivative(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float tLen=length(tangent);tangent=tLen>0.?tangent/tLen:vec2(1,0);worldPosition=curvePoint+vec2(-tangent.y,tangent.x)*a_position.y*a_instanceSize.y;}else if(isArc){float s=a_instanceArcAngles.x,e=a_instanceArcAngles.y;s=mod(s,6.28318530718);if(s<0.)s+=6.28318530718;e=mod(e,6.28318530718);if(e<0.)e+=6.28318530718;float d=s-e;if(d<=0.)d+=6.28318530718;float angle=s-a_position.x*d;vec2 local=vec2(cos(angle),sin(angle))*a_position.y;worldPosition=local*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{worldPosition=a_position*a_instanceSize+a_instancePosition;}vec2 ndc=(worldPosition/u_viewportSize)*2.-1.;ndc.y=-ndc.y;if(length(a_instanceGlobalRotation)>0.){vec3 pos3D=vec3(ndc-a_instanceRotationCenter,0);pos3D.x*=u_aspectRatio;if(a_instanceGlobalRotation.x!=0.)pos3D=rotateX(-a_instanceGlobalRotation.x)*pos3D;if(a_instanceGlobalRotation.y!=0.)pos3D=rotateY(-a_instanceGlobalRotation.y)*pos3D;if(a_instanceGlobalRotation.z!=0.)pos3D=rotateZ(-a_instanceGlobalRotation.z)*pos3D;pos3D.x/=u_aspectRatio;ndc=pos3D.xy+a_instanceRotationCenter;}gl_Position=vec4(ndc,0,1);}`, y = ((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))(y || {});
|
|
345
345
|
class et {
|
|
346
346
|
constructor(t) {
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
h(this, "S");
|
|
348
|
+
h(this, "It", /* @__PURE__ */ new Map());
|
|
349
349
|
this.S = t;
|
|
350
350
|
}
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
let n = this.
|
|
354
|
-
n || (n = /* @__PURE__ */ new Map(), this.
|
|
351
|
+
Wt(t, e, i, s) {
|
|
352
|
+
const r = this.S;
|
|
353
|
+
let n = this.It.get(t);
|
|
354
|
+
n || (n = /* @__PURE__ */ new Map(), this.It.set(t, n));
|
|
355
355
|
let o = n.get(e) || null;
|
|
356
356
|
if (!o) {
|
|
357
|
-
o =
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
const l =
|
|
361
|
-
l !== -1 && (
|
|
357
|
+
o = r.createVertexArray(), n.set(e, o), r.bindVertexArray(o), r.bindBuffer(r.ARRAY_BUFFER, s);
|
|
358
|
+
const c = r.getAttribLocation(t, "a_position");
|
|
359
|
+
c !== -1 && (r.enableVertexAttribArray(c), r.vertexAttribPointer(c, i.attributes.position.size, r.FLOAT, !1, i.stride, i.attributes.position.offset), r.vertexAttribDivisor(c, 0));
|
|
360
|
+
const l = r.getAttribLocation(t, "a_texCoord");
|
|
361
|
+
l !== -1 && (r.enableVertexAttribArray(l), r.vertexAttribPointer(l, i.attributes.texCoord.size, r.FLOAT, !1, i.stride, i.attributes.texCoord.offset), r.vertexAttribDivisor(l, 0));
|
|
362
362
|
}
|
|
363
|
-
|
|
363
|
+
r.bindVertexArray(o);
|
|
364
364
|
}
|
|
365
365
|
Ut() {
|
|
366
366
|
this.S.bindVertexArray(null);
|
|
367
367
|
}
|
|
368
368
|
j() {
|
|
369
369
|
const t = this.S;
|
|
370
|
-
for (const [, e] of this.
|
|
371
|
-
this.
|
|
370
|
+
for (const [, e] of this.It) for (const [, i] of e) i && t.deleteVertexArray(i);
|
|
371
|
+
this.It.clear();
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
class
|
|
374
|
+
class it {
|
|
375
375
|
constructor(t) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
this.S = t, this.
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const { shader:
|
|
385
|
-
for (const [u, f] of Object.entries(n))
|
|
386
|
-
Object.keys(o).length > 0 &&
|
|
387
|
-
const
|
|
388
|
-
if (!u || !u.
|
|
376
|
+
h(this, "Ot");
|
|
377
|
+
h(this, "S");
|
|
378
|
+
h(this, "Vt", null);
|
|
379
|
+
h(this, "jt", null);
|
|
380
|
+
h(this, "Ht", null);
|
|
381
|
+
this.S = t, this.Ot = new et(t);
|
|
382
|
+
}
|
|
383
|
+
Kt(t, e, i) {
|
|
384
|
+
const { shader: s } = t, r = L(this.S) || this.S.getParameter(this.S.VIEWPORT), n = { u_aspectRatio: r[2] / r[3], u_viewportSize: [r[2], r[3]] }, o = {};
|
|
385
|
+
for (const [u, f] of Object.entries(n)) s.rt(u) && (o[u] = f);
|
|
386
|
+
Object.keys(o).length > 0 && s.st(o);
|
|
387
|
+
const c = (u) => {
|
|
388
|
+
if (!u || !u.Xt()) return;
|
|
389
389
|
const f = u.unitGeometry, g = u.unitBuffer;
|
|
390
390
|
try {
|
|
391
|
-
this.
|
|
391
|
+
this.Ot.Wt(s.ot, u.type + "", f, g), u.batch.Yt(s), u.batch.Nt(f.primitiveType, f.vertexCount);
|
|
392
392
|
} finally {
|
|
393
|
-
u.batch.
|
|
393
|
+
u.batch.qt(s), this.Ot.Ut(), u.Zt();
|
|
394
394
|
}
|
|
395
395
|
};
|
|
396
396
|
let l = null, d = null;
|
|
397
397
|
for (const u of e) {
|
|
398
|
-
if (u.type ===
|
|
399
|
-
d && (
|
|
398
|
+
if (u.type === y.CUSTOM) {
|
|
399
|
+
d && (c(d), l = null, d = null), this.Qt(t, u.params, u.state, i.get(y.RECTANGLE) || null);
|
|
400
400
|
continue;
|
|
401
401
|
}
|
|
402
|
-
l !== null && u.type !== l && (
|
|
402
|
+
l !== null && u.type !== l && (c(d), l = null, d = null);
|
|
403
403
|
let f = d;
|
|
404
|
-
f && u.type === l || (f =
|
|
404
|
+
f && u.type === l || (f = i.get(u.type) || null, d = f, l = u.type), f && f.Jt(u.params, u.state);
|
|
405
405
|
}
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (!
|
|
410
|
-
const { x:
|
|
411
|
-
l.tt(),
|
|
412
|
-
const f = this.te(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(
|
|
413
|
-
f.
|
|
406
|
+
c(d);
|
|
407
|
+
}
|
|
408
|
+
Qt(t, e, i, s) {
|
|
409
|
+
if (!s) return;
|
|
410
|
+
const { x: r, y: n, width: o, height: c, shader: l, uniforms: d } = e, u = this.S;
|
|
411
|
+
l.tt(), s.Zt();
|
|
412
|
+
const f = this.te(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
|
|
413
|
+
f.O(), l.tt(), d && Object.keys(d).length && l.st(d);
|
|
414
414
|
{
|
|
415
|
-
const
|
|
416
|
-
l.rt("u_aspectRatio") && l.it("u_aspectRatio",
|
|
415
|
+
const x = L(u) || u.getParameter(u.VIEWPORT);
|
|
416
|
+
l.rt("u_aspectRatio") && l.it("u_aspectRatio", x[2] / x[3]), l.rt("u_viewportSize") && l.it("u_viewportSize", [x[2], x[3]]);
|
|
417
417
|
}
|
|
418
|
-
const g = { ...
|
|
419
|
-
if (
|
|
420
|
-
const
|
|
418
|
+
const g = { ...i, rotationX: 0, rotationY: 0, rotationZ: 0 };
|
|
419
|
+
if (s.Jt({ x: 0, y: 0, width: f.width, height: f.height }, g), s.Xt()) {
|
|
420
|
+
const x = s.unitGeometry, U = s.unitBuffer;
|
|
421
421
|
try {
|
|
422
|
-
this.
|
|
422
|
+
this.Ot.Wt(l.ot, s.type + "", x, U), s.batch.Yt(l), s.batch.Nt(x.primitiveType, x.vertexCount);
|
|
423
423
|
} finally {
|
|
424
|
-
|
|
424
|
+
s.batch.qt(l), this.Ot.Ut(), s.Zt();
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
f.
|
|
427
|
+
f.V();
|
|
428
428
|
const p = this.ee();
|
|
429
429
|
p.tt(), p.st({ u_src0: f.textures[0], u_src1: f.textures[1], u_src2: f.textures[2], u_src3: f.textures[3], u_src4: f.textures[4], u_srcSize: [f.width, f.height] });
|
|
430
|
-
const m =
|
|
430
|
+
const m = L(u) || u.getParameter(u.VIEWPORT);
|
|
431
431
|
p.rt("u_aspectRatio") && p.it("u_aspectRatio", m[2] / m[3]), p.rt("u_viewportSize") && p.it("u_viewportSize", [m[2], m[3]]);
|
|
432
|
-
const
|
|
433
|
-
if (
|
|
434
|
-
const
|
|
432
|
+
const E = Math.floor(r), C = Math.floor(n), S = Math.max(1, Math.floor(o)), w = Math.max(1, Math.floor(c));
|
|
433
|
+
if (s.Jt({ x: E, y: C, width: S, height: w }, i), s.Xt()) {
|
|
434
|
+
const x = s.unitGeometry, U = s.unitBuffer;
|
|
435
435
|
try {
|
|
436
|
-
this.
|
|
436
|
+
this.Ot.Wt(p.ot, s.type + "", x, U), s.batch.Yt(p), s.batch.Nt(x.primitiveType, x.vertexCount);
|
|
437
437
|
} finally {
|
|
438
|
-
|
|
438
|
+
s.batch.qt(p), this.Ot.Ut(), s.Zt();
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
t.shader.tt();
|
|
442
442
|
}
|
|
443
443
|
ee() {
|
|
444
|
-
return this.
|
|
445
|
-
precision highp float;in vec2 v_uv;uniform sampler2D u_src0;uniform sampler2D u_src1;uniform sampler2D u_src2;uniform sampler2D u_src3;uniform sampler2D u_src4;uniform vec2 u_srcSize;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 uvTex=v_uv*u_srcSize;vec2 uvQ=(floor(uvTex)+0.5f)/u_srcSize;o_character=texture(u_src0,uvQ);o_primaryColor=texture(u_src1,uvQ);o_secondaryColor=texture(u_src2,uvQ);o_rotation=texture(u_src3,uvQ);o_transform=texture(u_src4,uvQ);}`)), this.
|
|
444
|
+
return this.Vt || (this.Vt = new O(this.S, W, `#version 300 es
|
|
445
|
+
precision highp float;in vec2 v_uv;uniform sampler2D u_src0;uniform sampler2D u_src1;uniform sampler2D u_src2;uniform sampler2D u_src3;uniform sampler2D u_src4;uniform vec2 u_srcSize;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 uvTex=v_uv*u_srcSize;vec2 uvQ=(floor(uvTex)+0.5f)/u_srcSize;o_character=texture(u_src0,uvQ);o_primaryColor=texture(u_src1,uvQ);o_secondaryColor=texture(u_src2,uvQ);o_rotation=texture(u_src3,uvQ);o_transform=texture(u_src4,uvQ);}`)), this.Vt;
|
|
446
446
|
}
|
|
447
447
|
te(t, e) {
|
|
448
|
-
return this.jt && this.Ht && this.Ht.w === t && this.Ht.h === e || (this.jt && this.jt.j(), this.jt = new
|
|
448
|
+
return this.jt && this.Ht && this.Ht.w === t && this.Ht.h === e || (this.jt && this.jt.j(), this.jt = new G(this.S, t, e, 5), this.Ht = { w: t, h: e }), this.jt;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
class
|
|
451
|
+
class st {
|
|
452
452
|
constructor() {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
h(this, "se", []);
|
|
454
|
+
h(this, "ie", 1);
|
|
455
|
+
h(this, "re", 0);
|
|
456
456
|
}
|
|
457
457
|
ne(t) {
|
|
458
458
|
if (this.re >= this.se.length) {
|
|
459
|
-
const
|
|
460
|
-
this.se.push(
|
|
459
|
+
const i = { id: this.ie++, type: t, params: {}, state: { lineWeight: 1, rotationX: 0, rotationY: 0, rotationZ: 0, character: [0, 0, 0], charColor: [1, 1, 1, 1], bgColor: [0, 0, 0, 1], flipHorizontally: !1, flipVertically: !1, invert: !1, charRotation: [0, 0] } };
|
|
460
|
+
this.se.push(i);
|
|
461
461
|
}
|
|
462
462
|
const e = this.se[this.re];
|
|
463
463
|
switch (e.id = this.ie++, e.type = t, t) {
|
|
464
|
-
case
|
|
465
|
-
case
|
|
464
|
+
case y.RECTANGLE:
|
|
465
|
+
case y.ELLIPSE:
|
|
466
466
|
e.params && "width" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0 });
|
|
467
467
|
break;
|
|
468
|
-
case
|
|
468
|
+
case y.CUSTOM:
|
|
469
469
|
e.params && "shader" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, shader: void 0, uniforms: {} });
|
|
470
470
|
break;
|
|
471
|
-
case
|
|
471
|
+
case y.ARC:
|
|
472
472
|
e.params && "start" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, start: 0, stop: 0 });
|
|
473
473
|
break;
|
|
474
|
-
case
|
|
474
|
+
case y.LINE:
|
|
475
475
|
e.params && "x2" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, thickness: void 0 });
|
|
476
476
|
break;
|
|
477
|
-
case
|
|
477
|
+
case y.TRIANGLE:
|
|
478
478
|
e.params && "x3" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, x3: 0, y3: 0 });
|
|
479
479
|
break;
|
|
480
|
-
case
|
|
480
|
+
case y.BEZIER_CURVE:
|
|
481
481
|
e.params && "cp2y" in e.params || (e.params = { x1: 0, y1: 0, cp1x: 0, cp1y: 0, cp2x: 0, cp2y: 0, x2: 0, y2: 0, thickness: void 0 });
|
|
482
482
|
break;
|
|
483
483
|
default:
|
|
@@ -485,33 +485,33 @@ class it {
|
|
|
485
485
|
}
|
|
486
486
|
return this.re++, e;
|
|
487
487
|
}
|
|
488
|
-
oe(t, e,
|
|
489
|
-
const n = this.ne(
|
|
490
|
-
return n.params.x = t, n.params.y = e, n.params.width =
|
|
488
|
+
oe(t, e, i, s, r) {
|
|
489
|
+
const n = this.ne(y.RECTANGLE);
|
|
490
|
+
return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.zt(n.state), n.id;
|
|
491
491
|
}
|
|
492
|
-
ae(t, e,
|
|
493
|
-
const
|
|
494
|
-
return
|
|
492
|
+
ae(t, e, i, s, r, n, o) {
|
|
493
|
+
const c = this.ne(y.CUSTOM);
|
|
494
|
+
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.zt(c.state), c.id;
|
|
495
495
|
}
|
|
496
|
-
he(t, e,
|
|
497
|
-
const o = this.ne(
|
|
498
|
-
return o.params.x1 = t, o.params.y1 = e, o.params.x2 =
|
|
496
|
+
he(t, e, i, s, r, n) {
|
|
497
|
+
const o = this.ne(y.LINE);
|
|
498
|
+
return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = s, o.params.thickness = r, n.zt(o.state), o.id;
|
|
499
499
|
}
|
|
500
|
-
ce(t, e,
|
|
501
|
-
const n = this.ne(
|
|
502
|
-
return n.params.x = t, n.params.y = e, n.params.width =
|
|
500
|
+
ce(t, e, i, s, r) {
|
|
501
|
+
const n = this.ne(y.ELLIPSE);
|
|
502
|
+
return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.zt(n.state), n.id;
|
|
503
503
|
}
|
|
504
|
-
le(t, e,
|
|
505
|
-
const
|
|
506
|
-
return
|
|
504
|
+
le(t, e, i, s, r, n, o) {
|
|
505
|
+
const c = this.ne(y.ARC);
|
|
506
|
+
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.zt(c.state), c.id;
|
|
507
507
|
}
|
|
508
|
-
ue(t, e,
|
|
509
|
-
const
|
|
510
|
-
return
|
|
508
|
+
ue(t, e, i, s, r, n, o) {
|
|
509
|
+
const c = this.ne(y.TRIANGLE);
|
|
510
|
+
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.zt(c.state), c.id;
|
|
511
511
|
}
|
|
512
|
-
|
|
513
|
-
const u = this.ne(
|
|
514
|
-
return u.params.x1 = t, u.params.y1 = e, u.params.cp1x =
|
|
512
|
+
de(t, e, i, s, r, n, o, c, l, d) {
|
|
513
|
+
const u = this.ne(y.BEZIER_CURVE);
|
|
514
|
+
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, d.zt(u.state), u.id;
|
|
515
515
|
}
|
|
516
516
|
get length() {
|
|
517
517
|
return this.re;
|
|
@@ -519,51 +519,51 @@ class it {
|
|
|
519
519
|
get isEmpty() {
|
|
520
520
|
return this.re === 0;
|
|
521
521
|
}
|
|
522
|
-
|
|
522
|
+
fe() {
|
|
523
523
|
this.re = 0;
|
|
524
524
|
}
|
|
525
525
|
[Symbol.iterator]() {
|
|
526
526
|
let t = 0;
|
|
527
|
-
const e = this.re,
|
|
528
|
-
return { next: () => t < e ? { value:
|
|
527
|
+
const e = this.re, i = this.se;
|
|
528
|
+
return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
-
const
|
|
532
|
-
static pe(t, e,
|
|
533
|
-
var n, o,
|
|
534
|
-
const
|
|
535
|
-
let
|
|
536
|
-
return
|
|
531
|
+
const _ = class _ {
|
|
532
|
+
static pe(t, e, i = 0) {
|
|
533
|
+
var n, o, c, l, d, u, f, g, p, m;
|
|
534
|
+
const s = e || new Float32Array(_.FLOATS_PER_INSTANCE);
|
|
535
|
+
let r = i;
|
|
536
|
+
return s[r++] = t.position[0], s[r++] = t.position[1], s[r++] = t.size[0], s[r++] = t.size[1], s[r++] = t.character[0], s[r++] = t.character[1], s[r++] = t.character[2], s[r++] = t.primaryColor[0], s[r++] = t.primaryColor[1], s[r++] = t.primaryColor[2], s[r++] = t.primaryColor[3], s[r++] = t.secondaryColor[0], s[r++] = t.secondaryColor[1], s[r++] = t.secondaryColor[2], s[r++] = t.secondaryColor[3], s[r++] = t.rotation[0], s[r++] = t.rotation[1], s[r++] = t.transform[0], s[r++] = t.transform[1], s[r++] = t.transform[2], s[r++] = t.globalRotationX, s[r++] = t.globalRotationY, s[r++] = t.globalRotationZ, s[r++] = t.rotationCenter[0], s[r++] = t.rotationCenter[1], s[r++] = ((n = t.arcAngles) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.arcAngles) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.bezierControlPoint1) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.bezierControlPoint1) == null ? void 0 : l[1]) || 0, s[r++] = ((d = t.bezierControlPoint2) == null ? void 0 : d[0]) || 0, s[r++] = ((u = t.bezierControlPoint2) == null ? void 0 : u[1]) || 0, s[r++] = ((f = t.bezierStartPoint) == null ? void 0 : f[0]) || 0, s[r++] = ((g = t.bezierStartPoint) == null ? void 0 : g[1]) || 0, s[r++] = ((p = t.bezierEndPoint) == null ? void 0 : p[0]) || 0, s[r++] = ((m = t.bezierEndPoint) == null ? void 0 : m[1]) || 0, s;
|
|
537
537
|
}
|
|
538
538
|
static _e(t) {
|
|
539
|
-
const e = t.length *
|
|
540
|
-
for (let
|
|
541
|
-
const
|
|
542
|
-
|
|
539
|
+
const e = t.length * _.FLOATS_PER_INSTANCE, i = new Float32Array(e);
|
|
540
|
+
for (let s = 0; s < t.length; s++) {
|
|
541
|
+
const r = s * _.FLOATS_PER_INSTANCE;
|
|
542
|
+
_.pe(t[s], i, r);
|
|
543
543
|
}
|
|
544
|
-
return
|
|
544
|
+
return i;
|
|
545
545
|
}
|
|
546
546
|
};
|
|
547
|
-
|
|
548
|
-
let F =
|
|
549
|
-
const
|
|
547
|
+
h(_, "BYTES_PER_INSTANCE", 140), h(_, "FLOATS_PER_INSTANCE", 35);
|
|
548
|
+
let F = _;
|
|
549
|
+
const v = class v {
|
|
550
550
|
};
|
|
551
|
-
|
|
552
|
-
let
|
|
553
|
-
class
|
|
554
|
-
constructor(t, e = 1e3,
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
this.S = t, this.me = e, this.ve =
|
|
565
|
-
}
|
|
566
|
-
|
|
551
|
+
h(v, "STRIDE", F.BYTES_PER_INSTANCE), h(v, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: v.STRIDE, offset: 132, divisor: 1 } });
|
|
552
|
+
let B = v;
|
|
553
|
+
class rt {
|
|
554
|
+
constructor(t, e = 1e3, i = 1.5) {
|
|
555
|
+
h(this, "S");
|
|
556
|
+
h(this, "ge", []);
|
|
557
|
+
h(this, "me");
|
|
558
|
+
h(this, "ve");
|
|
559
|
+
h(this, "ye", null);
|
|
560
|
+
h(this, "Ce", !0);
|
|
561
|
+
h(this, "xe", 0);
|
|
562
|
+
h(this, "we", /* @__PURE__ */ new Map());
|
|
563
|
+
h(this, "$e", null);
|
|
564
|
+
this.S = t, this.me = e, this.ve = i, this.be();
|
|
565
|
+
}
|
|
566
|
+
Jt(t) {
|
|
567
567
|
const e = this.ge.length;
|
|
568
568
|
return this.ge.push(t), this.Ce = !0, e;
|
|
569
569
|
}
|
|
@@ -576,400 +576,400 @@ class st {
|
|
|
576
576
|
clear() {
|
|
577
577
|
this.ge.length = 0, this.Ce = !0;
|
|
578
578
|
}
|
|
579
|
-
|
|
579
|
+
Re(t) {
|
|
580
580
|
if (t <= this.me) return;
|
|
581
581
|
const e = Math.ceil(t * this.ve);
|
|
582
582
|
this.me = e, this.be();
|
|
583
583
|
}
|
|
584
584
|
be() {
|
|
585
585
|
const t = this.S;
|
|
586
|
-
this.
|
|
586
|
+
this.ye && t.deleteBuffer(this.ye), this.ye = t.createBuffer();
|
|
587
587
|
const e = this.me * F.BYTES_PER_INSTANCE;
|
|
588
|
-
t.bindBuffer(t.ARRAY_BUFFER, this.
|
|
588
|
+
t.bindBuffer(t.ARRAY_BUFFER, this.ye), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.Ce = !0, this.xe = 0;
|
|
589
589
|
}
|
|
590
|
-
|
|
590
|
+
ze() {
|
|
591
591
|
if (!this.Ce || this.ge.length === 0) return;
|
|
592
592
|
const t = this.S, e = this.ge.length;
|
|
593
|
-
this.
|
|
594
|
-
const
|
|
595
|
-
t.bindBuffer(t.ARRAY_BUFFER, this.
|
|
593
|
+
this.Re(e), (!this.$e || this.$e.length < e * F.FLOATS_PER_INSTANCE) && (this.$e = new Float32Array(e * F.FLOATS_PER_INSTANCE));
|
|
594
|
+
const i = F._e(this.ge);
|
|
595
|
+
t.bindBuffer(t.ARRAY_BUFFER, this.ye), e <= this.xe ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.Ce = !1, this.xe = e;
|
|
596
596
|
}
|
|
597
|
-
|
|
597
|
+
Se(t) {
|
|
598
598
|
let e = this.we.get(t);
|
|
599
599
|
if (!e) {
|
|
600
600
|
e = /* @__PURE__ */ new Map();
|
|
601
|
-
const
|
|
602
|
-
for (const
|
|
603
|
-
const
|
|
604
|
-
|
|
601
|
+
const i = this.S;
|
|
602
|
+
for (const s in B.ATTRIBUTES) {
|
|
603
|
+
const r = i.getAttribLocation(t, s);
|
|
604
|
+
r !== -1 && e.set(s, r);
|
|
605
605
|
}
|
|
606
606
|
this.we.set(t, e);
|
|
607
607
|
}
|
|
608
608
|
return e;
|
|
609
609
|
}
|
|
610
|
-
|
|
611
|
-
if (!this.
|
|
612
|
-
const e = this.S,
|
|
613
|
-
this.
|
|
614
|
-
const
|
|
615
|
-
e.bindBuffer(e.ARRAY_BUFFER, this.
|
|
616
|
-
for (const [
|
|
617
|
-
const o =
|
|
610
|
+
Yt(t) {
|
|
611
|
+
if (!this.ye || this.ge.length === 0) return;
|
|
612
|
+
const e = this.S, i = t.ot;
|
|
613
|
+
this.ze();
|
|
614
|
+
const s = this.Se(i);
|
|
615
|
+
e.bindBuffer(e.ARRAY_BUFFER, this.ye);
|
|
616
|
+
for (const [r, n] of s) {
|
|
617
|
+
const o = B.ATTRIBUTES[r];
|
|
618
618
|
o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
-
|
|
622
|
-
const e = this.S,
|
|
623
|
-
for (const [,
|
|
621
|
+
qt(t) {
|
|
622
|
+
const e = this.S, i = this.Se(t.ot);
|
|
623
|
+
for (const [, s] of i) e.disableVertexAttribArray(s), e.vertexAttribDivisor(s, 0);
|
|
624
624
|
}
|
|
625
|
-
|
|
625
|
+
Nt(t, e) {
|
|
626
626
|
this.ge.length !== 0 && this.S.drawArraysInstanced(t, 0, e, this.ge.length);
|
|
627
627
|
}
|
|
628
628
|
j() {
|
|
629
629
|
const t = this.S;
|
|
630
|
-
this.
|
|
630
|
+
this.ye && (t.deleteBuffer(this.ye), this.ye = null), this.ge.length = 0, this.we.clear(), this.$e = null;
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
|
-
class
|
|
634
|
-
constructor(t, e,
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
this.S = t, this.
|
|
641
|
-
const
|
|
642
|
-
if (!
|
|
643
|
-
this.S.bindBuffer(this.S.ARRAY_BUFFER,
|
|
633
|
+
class P {
|
|
634
|
+
constructor(t, e, i, s) {
|
|
635
|
+
h(this, "S");
|
|
636
|
+
h(this, "Te");
|
|
637
|
+
h(this, "Pe");
|
|
638
|
+
h(this, "Me");
|
|
639
|
+
h(this, "Fe", null);
|
|
640
|
+
this.S = t, this.Te = e, this.Pe = i, this.Me = s;
|
|
641
|
+
const r = this.S.createBuffer();
|
|
642
|
+
if (!r) throw Error("Failed to create unit geometry buffer");
|
|
643
|
+
this.S.bindBuffer(this.S.ARRAY_BUFFER, r), this.S.bufferData(this.S.ARRAY_BUFFER, this.Me.vertices, this.S.STATIC_DRAW), this.S.bindBuffer(this.S.ARRAY_BUFFER, null), this.Fe = r;
|
|
644
644
|
}
|
|
645
645
|
get type() {
|
|
646
|
-
return this.
|
|
646
|
+
return this.Pe;
|
|
647
647
|
}
|
|
648
648
|
get unitGeometry() {
|
|
649
|
-
return this.
|
|
649
|
+
return this.Me;
|
|
650
650
|
}
|
|
651
651
|
get unitBuffer() {
|
|
652
|
-
return this.
|
|
652
|
+
return this.Fe;
|
|
653
653
|
}
|
|
654
654
|
get batch() {
|
|
655
|
-
return this.
|
|
655
|
+
return this.Te;
|
|
656
656
|
}
|
|
657
|
-
|
|
658
|
-
this.
|
|
657
|
+
Zt() {
|
|
658
|
+
this.Te.clear();
|
|
659
659
|
}
|
|
660
|
-
|
|
661
|
-
return !this.
|
|
660
|
+
Xt() {
|
|
661
|
+
return !this.Te.isEmpty;
|
|
662
662
|
}
|
|
663
663
|
j() {
|
|
664
|
-
this.
|
|
664
|
+
this.Te.j(), this.Fe && (this.S.deleteBuffer(this.Fe), this.Fe = null);
|
|
665
665
|
}
|
|
666
|
-
|
|
667
|
-
const n = this.
|
|
668
|
-
return { position: [t, e], size: [
|
|
666
|
+
Ae(t, e, i, s, r) {
|
|
667
|
+
const n = this.De(t, e, i, s, r.rotationX || 0, r.rotationY || 0, r.rotationZ || 0);
|
|
668
|
+
return { position: [t, e], size: [i, s], character: r.character || [0, 0, 0], primaryColor: r.charColor || [1, 1, 1, 1], secondaryColor: r.bgColor || [0, 0, 0, 1], rotation: r.charRotation || [0, 0], transform: [r.invert ? 1 : 0, r.flipHorizontally ? 1 : 0, r.flipVertically ? 1 : 0], globalRotationX: n.radiansX, globalRotationY: n.radiansY, globalRotationZ: n.radiansZ, rotationCenter: [n.centerX, n.centerY] };
|
|
669
669
|
}
|
|
670
|
-
|
|
671
|
-
const
|
|
672
|
-
return { nx: t /
|
|
670
|
+
Ge(t, e) {
|
|
671
|
+
const i = L(this.S) || [0, 0, this.S.canvas.width, this.S.canvas.height];
|
|
672
|
+
return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
|
|
673
673
|
}
|
|
674
|
-
|
|
675
|
-
const
|
|
676
|
-
t.rotationCenter = [
|
|
674
|
+
ke(t, e, i) {
|
|
675
|
+
const s = this.Ge(e, i);
|
|
676
|
+
t.rotationCenter = [s.nx, s.ny];
|
|
677
677
|
}
|
|
678
|
-
|
|
679
|
-
const
|
|
680
|
-
return { centerX: (t +
|
|
678
|
+
De(t, e, i, s, r, n, o) {
|
|
679
|
+
const c = L(this.S) || [0, 0, this.S.canvas.width, this.S.canvas.height], l = c[2], d = c[3];
|
|
680
|
+
return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + s / 2) / d * 2, radiansX: -r * Math.PI / 180, radiansY: -n * Math.PI / 180, radiansZ: -o * Math.PI / 180, aspectRatio: l / d };
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
683
|
const nt = { vertices: 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]), vertexCount: 6, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
684
|
-
class ot extends
|
|
684
|
+
class ot extends P {
|
|
685
685
|
constructor(t, e) {
|
|
686
|
-
super(t, e,
|
|
686
|
+
super(t, e, y.RECTANGLE, nt);
|
|
687
687
|
}
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
return this.
|
|
688
|
+
Jt(t, e) {
|
|
689
|
+
const i = this.Ae(t.x, t.y, t.width, t.height, e);
|
|
690
|
+
return this.Te.Jt(i);
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
const at = { vertices: 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]), vertexCount: 6, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
694
|
-
class ht extends
|
|
694
|
+
class ht extends P {
|
|
695
695
|
constructor(t, e) {
|
|
696
|
-
super(t, e,
|
|
696
|
+
super(t, e, y.LINE, at);
|
|
697
697
|
}
|
|
698
|
-
|
|
699
|
-
const
|
|
700
|
-
return this.
|
|
698
|
+
Jt(t, e) {
|
|
699
|
+
const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = Math.atan2(s, i), o = t.thickness || e.lineWeight || 1, c = t.x1 + i / 2, l = t.y1 + s / 2, d = c - r / 2, u = l, f = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotationX: e.rotationX || 0, rotationY: e.rotationY || 0, rotationZ: (e.rotationZ || 0) + 180 * n / Math.PI, lineWeight: o }, g = this.Ae(d, u, r, o, f);
|
|
700
|
+
return this.ke(g, c, l), this.Te.Jt(g);
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
703
|
const ct = { vertices: function(a = 32) {
|
|
704
704
|
const t = [], e = 2 * Math.PI / a;
|
|
705
|
-
for (let
|
|
706
|
-
const
|
|
707
|
-
t.push(0, 0, 0.5, 0.5, n, o,
|
|
705
|
+
for (let i = 0; i < a; i++) {
|
|
706
|
+
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), d = Math.cos(r), u = Math.sin(r), f = 0.5 * (d + 1), g = 0.5 * (u + 1);
|
|
707
|
+
t.push(0, 0, 0.5, 0.5, n, o, c, l, d, u, f, g);
|
|
708
708
|
}
|
|
709
709
|
return new Float32Array(t);
|
|
710
710
|
}(32), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
711
|
-
class lt extends
|
|
711
|
+
class lt extends P {
|
|
712
712
|
constructor(t, e) {
|
|
713
|
-
super(t, e,
|
|
713
|
+
super(t, e, y.ELLIPSE, ct);
|
|
714
714
|
}
|
|
715
|
-
|
|
716
|
-
const
|
|
717
|
-
return this.
|
|
715
|
+
Jt(t, e) {
|
|
716
|
+
const i = this.Ae(t.x, t.y, t.width, t.height, e);
|
|
717
|
+
return this.ke(i, t.x, t.y), this.Te.Jt(i);
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
720
|
let ut = { vertices: function(a) {
|
|
721
721
|
const t = [];
|
|
722
722
|
for (let e = 0; e < a; e++) {
|
|
723
|
-
const
|
|
724
|
-
t.push(
|
|
723
|
+
const i = e / a, s = (e + 1) / a;
|
|
724
|
+
t.push(i, 0, i, 0, i, 1, i, 1, s, 1, s, 1);
|
|
725
725
|
}
|
|
726
726
|
return new Float32Array(t);
|
|
727
727
|
}(32), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
728
|
-
class
|
|
728
|
+
class dt extends P {
|
|
729
729
|
constructor(t, e) {
|
|
730
|
-
super(t, e,
|
|
730
|
+
super(t, e, y.ARC, ut);
|
|
731
731
|
}
|
|
732
|
-
|
|
733
|
-
const
|
|
734
|
-
return this.
|
|
732
|
+
Jt(t, e) {
|
|
733
|
+
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.Ae(i, s, t.width, t.height, e);
|
|
734
|
+
return this.ke(o, t.x, t.y), o.arcAngles = [r, n], this.Te.Jt(o);
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
|
-
const
|
|
738
|
-
class pt extends
|
|
737
|
+
const ft = { vertices: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), vertexCount: 3, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
738
|
+
class pt extends P {
|
|
739
739
|
constructor(t, e) {
|
|
740
|
-
super(t, e,
|
|
740
|
+
super(t, e, y.TRIANGLE, ft);
|
|
741
741
|
}
|
|
742
|
-
|
|
743
|
-
const
|
|
744
|
-
return this.
|
|
742
|
+
Jt(t, e) {
|
|
743
|
+
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.Ae(i, r, n, o, e), l = i + 0.5 * n, d = r + o * (1 / 3);
|
|
744
|
+
return this.ke(c, l, d), this.Te.Jt(c);
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
|
-
function
|
|
748
|
-
const
|
|
749
|
-
return n *
|
|
747
|
+
function X(a, t, e, i, s) {
|
|
748
|
+
const r = 1 - a, n = r * r, o = a * a;
|
|
749
|
+
return n * r * t + 3 * n * a * e + 3 * r * o * i + o * a * s;
|
|
750
750
|
}
|
|
751
751
|
const gt = { vertices: function(a = 16) {
|
|
752
752
|
const t = [];
|
|
753
753
|
for (let e = 0; e < a; e++) {
|
|
754
|
-
const
|
|
755
|
-
t.push(
|
|
754
|
+
const i = e / a, s = (e + 1) / a;
|
|
755
|
+
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);
|
|
756
756
|
}
|
|
757
757
|
return new Float32Array(t);
|
|
758
758
|
}(16), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
759
|
-
class mt extends
|
|
759
|
+
class mt extends P {
|
|
760
760
|
constructor(t, e) {
|
|
761
|
-
super(t, e,
|
|
761
|
+
super(t, e, y.BEZIER_CURVE, gt);
|
|
762
762
|
}
|
|
763
|
-
|
|
764
|
-
const
|
|
765
|
-
return this.
|
|
763
|
+
Jt(t, e) {
|
|
764
|
+
const i = e.lineWeight || 1, s = X(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = X(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotationX: e.rotationX || 0, rotationY: e.rotationY || 0, rotationZ: e.rotationZ || 0, lineWeight: i }, o = this.Ae(0, 0, 1, i, n);
|
|
765
|
+
return this.ke(o, s, r), o.bezierStartPoint = [t.x1, t.y1], o.bezierControlPoint1 = [t.cp1x, t.cp1y], o.bezierControlPoint2 = [t.cp2x, t.cp2y], o.bezierEndPoint = [t.x2, t.y2], this.Te.Jt(o);
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
|
-
class
|
|
768
|
+
class yt {
|
|
769
769
|
constructor(t) {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
this.S = t, this.
|
|
770
|
+
h(this, "S");
|
|
771
|
+
h(this, "Ee", null);
|
|
772
|
+
h(this, "Le", null);
|
|
773
|
+
h(this, "Be", {});
|
|
774
|
+
h(this, "Ie", null);
|
|
775
|
+
h(this, "We", /* @__PURE__ */ new Map());
|
|
776
|
+
h(this, "Ue");
|
|
777
|
+
h(this, "Oe");
|
|
778
|
+
h(this, "Ve");
|
|
779
|
+
this.S = t, this.Ve = new tt(), this.Ue = new it(t), this.Oe = new st(), this.Ie = t.createBuffer(), I(this.S, [0, 0, this.S.canvas.width, this.S.canvas.height]);
|
|
780
780
|
}
|
|
781
781
|
je(t) {
|
|
782
|
-
let e = this.
|
|
782
|
+
let e = this.We.get(t);
|
|
783
783
|
if (e) return e;
|
|
784
|
-
const
|
|
785
|
-
return e = (0, { [
|
|
784
|
+
const i = new rt(this.S);
|
|
785
|
+
return e = (0, { [y.RECTANGLE]: () => new ot(this.S, i), [y.LINE]: () => new ht(this.S, i), [y.ELLIPSE]: () => new lt(this.S, i), [y.ARC]: () => new dt(this.S, i), [y.TRIANGLE]: () => new pt(this.S, i), [y.BEZIER_CURVE]: () => new mt(this.S, i) }[t])(), this.We.set(t, e), e;
|
|
786
786
|
}
|
|
787
787
|
He(t) {
|
|
788
|
-
this.
|
|
788
|
+
this.Ee !== t && (this.Ee = t, t.tt());
|
|
789
789
|
}
|
|
790
|
-
|
|
791
|
-
return new
|
|
790
|
+
Ke(t, e) {
|
|
791
|
+
return new O(this.S, t, e);
|
|
792
792
|
}
|
|
793
|
-
|
|
794
|
-
this.Le = t, t && (this.
|
|
793
|
+
Xe(t) {
|
|
794
|
+
this.Le = t, t && (this.Be = {});
|
|
795
795
|
}
|
|
796
|
-
|
|
797
|
-
this.
|
|
798
|
-
}
|
|
799
|
-
Ze(t) {
|
|
800
|
-
Object.assign(this.Ee, t);
|
|
796
|
+
Ye(t, e) {
|
|
797
|
+
this.Be[t] = e;
|
|
801
798
|
}
|
|
802
799
|
Ne(t) {
|
|
803
|
-
|
|
800
|
+
Object.assign(this.Be, t);
|
|
801
|
+
}
|
|
802
|
+
qe(t) {
|
|
803
|
+
return new O(this.S, W, t);
|
|
804
804
|
}
|
|
805
|
-
|
|
805
|
+
Ze(t, e, i, s) {
|
|
806
806
|
var m;
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
const g = ((m = this.
|
|
810
|
-
p !== -1 && (
|
|
807
|
+
const r = this.S, n = r.canvas.width, o = r.canvas.height, c = t / n * 2 - 1, l = (t + i) / n * 2 - 1, d = 1 - e / o * 2, u = 1 - (e + s) / o * 2, f = new Float32Array([c, u, l, u, c, d, l, u, l, d, c, d]);
|
|
808
|
+
r.bindBuffer(r.ARRAY_BUFFER, this.Ie), r.bufferData(r.ARRAY_BUFFER, f, r.DYNAMIC_DRAW);
|
|
809
|
+
const g = ((m = this.Ee) == null ? void 0 : m.ot) || r.getParameter(r.CURRENT_PROGRAM), p = g ? r.getAttribLocation(g, "a_position") : -1;
|
|
810
|
+
p !== -1 && (r.enableVertexAttribArray(p), r.vertexAttribPointer(p, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), p !== -1 && r.disableVertexAttribArray(p);
|
|
811
811
|
}
|
|
812
|
-
|
|
813
|
-
this.Le ? (this.
|
|
812
|
+
Qe(t, e, i, s) {
|
|
813
|
+
this.Le ? (this.Oe.ae(t, e, i, s, this.Le, { ...this.Be }, this.Ve), this.Le = null, this.Be = {}) : this.Oe.oe(t, e, i, s, this.Ve);
|
|
814
814
|
}
|
|
815
|
-
|
|
816
|
-
this.
|
|
815
|
+
Je(t, e, i, s) {
|
|
816
|
+
this.Oe.he(t, e, i, s, this.Ve.lineWeight, this.Ve);
|
|
817
817
|
}
|
|
818
|
-
ts(t, e,
|
|
819
|
-
this.
|
|
818
|
+
ts(t, e, i, s) {
|
|
819
|
+
this.Oe.ce(t, e, i, s, this.Ve);
|
|
820
820
|
}
|
|
821
|
-
es(t, e,
|
|
822
|
-
this.
|
|
821
|
+
es(t, e, i, s, r, n) {
|
|
822
|
+
this.Oe.ue(t, e, i, s, r, n, this.Ve);
|
|
823
823
|
}
|
|
824
|
-
ss(t, e,
|
|
825
|
-
const l = this.
|
|
826
|
-
this.
|
|
824
|
+
ss(t, e, i, s, r, n, o, c) {
|
|
825
|
+
const l = this.Ve.lineWeight;
|
|
826
|
+
this.Oe.de(t, e, i, s, r, n, o, c, l, this.Ve);
|
|
827
827
|
}
|
|
828
|
-
rs(t, e,
|
|
829
|
-
return new
|
|
828
|
+
rs(t, e, i = 1, s = {}) {
|
|
829
|
+
return new G(this.S, t, e, i, s);
|
|
830
830
|
}
|
|
831
|
-
ns(t, e,
|
|
832
|
-
this.
|
|
831
|
+
ns(t, e, i, s, r, n) {
|
|
832
|
+
this.Oe.le(t, e, i, s, r, n, this.Ve);
|
|
833
833
|
}
|
|
834
|
-
hs(t, e = t,
|
|
835
|
-
this.state.
|
|
834
|
+
hs(t, e = t, i = t, s = 255) {
|
|
835
|
+
this.state.Bt(t, e, i, s), this.fe(t / 255, e / 255, i / 255, s / 255);
|
|
836
836
|
}
|
|
837
|
-
|
|
838
|
-
this.S.clearColor(t, e,
|
|
837
|
+
fe(t = 0, e = 0, i = 0, s = 0) {
|
|
838
|
+
this.S.clearColor(t, e, i, s), this.S.clear(this.S.COLOR_BUFFER_BIT);
|
|
839
839
|
}
|
|
840
840
|
cs() {
|
|
841
|
-
this.S.viewport(0, 0, this.S.canvas.width, this.S.canvas.height),
|
|
841
|
+
this.S.viewport(0, 0, this.S.canvas.width, this.S.canvas.height), I(this.S, [0, 0, this.S.canvas.width, this.S.canvas.height]);
|
|
842
842
|
}
|
|
843
843
|
get context() {
|
|
844
844
|
return this.S;
|
|
845
845
|
}
|
|
846
846
|
get state() {
|
|
847
|
-
return this.
|
|
847
|
+
return this.Ve;
|
|
848
848
|
}
|
|
849
849
|
ls(t) {
|
|
850
|
-
const e = t,
|
|
850
|
+
const e = t, i = L(this.S) ?? this.S.getParameter(this.S.VIEWPORT), s = { shader: e, gl: this.S, viewport: i };
|
|
851
851
|
this.He(e);
|
|
852
|
-
const
|
|
853
|
-
for (const n of this.
|
|
854
|
-
for (const n of
|
|
855
|
-
this.Ue.
|
|
852
|
+
const r = /* @__PURE__ */ new Set();
|
|
853
|
+
for (const n of this.Oe) n.type === y.CUSTOM ? r.add(y.RECTANGLE) : r.add(n.type);
|
|
854
|
+
for (const n of r) n !== y.CUSTOM && this.je(n);
|
|
855
|
+
this.Ue.Kt(s, this.Oe, this.We), this.Oe.fe();
|
|
856
856
|
}
|
|
857
857
|
j() {
|
|
858
|
-
this.S.deleteBuffer(this.
|
|
859
|
-
for (const t of this.
|
|
858
|
+
this.S.deleteBuffer(this.Ie), this.Oe.fe();
|
|
859
|
+
for (const t of this.We.values()) t.j();
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
-
const
|
|
863
|
-
const
|
|
864
|
-
for (let
|
|
865
|
-
return
|
|
862
|
+
const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
|
|
863
|
+
const i = [];
|
|
864
|
+
for (let s = 0; s < e; s++) i.push(R.readUshort(a, t + 2 * s));
|
|
865
|
+
return i;
|
|
866
866
|
}, readUint(a, t) {
|
|
867
|
-
const e =
|
|
868
|
-
return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3],
|
|
867
|
+
const e = R.t.uint8;
|
|
868
|
+
return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], R.t.uint32[0];
|
|
869
869
|
}, readASCII(a, t, e) {
|
|
870
|
-
let
|
|
871
|
-
for (let
|
|
872
|
-
return
|
|
870
|
+
let i = "";
|
|
871
|
+
for (let s = 0; s < e; s++) i += String.fromCharCode(a[t + s]);
|
|
872
|
+
return i;
|
|
873
873
|
}, t: (() => {
|
|
874
874
|
const a = new ArrayBuffer(8);
|
|
875
875
|
return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
|
|
876
|
-
})() },
|
|
877
|
-
const
|
|
876
|
+
})() }, xt = { parseTab(a, t, e) {
|
|
877
|
+
const i = { tables: [], ids: {}, off: t };
|
|
878
878
|
a = new Uint8Array(a.buffer, t, e), t = 0;
|
|
879
|
-
const
|
|
879
|
+
const s = R, r = s.readUshort, n = r(a, t += 2);
|
|
880
880
|
t += 2;
|
|
881
881
|
const o = [];
|
|
882
|
-
for (let
|
|
883
|
-
const l =
|
|
882
|
+
for (let c = 0; c < n; c++) {
|
|
883
|
+
const l = r(a, t), d = r(a, t += 2);
|
|
884
884
|
t += 2;
|
|
885
|
-
const u =
|
|
885
|
+
const u = s.readUint(a, t);
|
|
886
886
|
t += 4;
|
|
887
887
|
const f = `p${l}e${d}`;
|
|
888
888
|
let g = o.indexOf(u);
|
|
889
889
|
if (g === -1) {
|
|
890
890
|
let p;
|
|
891
|
-
g =
|
|
892
|
-
const m =
|
|
893
|
-
p = m === 4 ? this.parse4(a, u) : m === 12 ? this.parse12(a, u) : { format: m },
|
|
891
|
+
g = i.tables.length, o.push(u);
|
|
892
|
+
const m = r(a, u);
|
|
893
|
+
p = m === 4 ? this.parse4(a, u) : m === 12 ? this.parse12(a, u) : { format: m }, i.tables.push(p);
|
|
894
894
|
}
|
|
895
|
-
|
|
895
|
+
i.ids[f] != null && console.warn("Multiple tables for one platform+encoding: " + f), i.ids[f] = g;
|
|
896
896
|
}
|
|
897
|
-
return
|
|
897
|
+
return i;
|
|
898
898
|
}, parse4(a, t) {
|
|
899
|
-
const e =
|
|
899
|
+
const e = R, i = e.readUshort, s = e.readUshorts, r = t, n = i(a, t += 2);
|
|
900
900
|
t += 2;
|
|
901
|
-
const o =
|
|
902
|
-
t += 2,
|
|
903
|
-
for (let l = 0; l < o; l++)
|
|
904
|
-
return
|
|
901
|
+
const o = i(a, t += 2) >>> 1, c = { format: 4, searchRange: i(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
|
|
902
|
+
t += 2, c.entrySelector = i(a, t), t += 2, c.rangeShift = i(a, t), t += 2, c.endCount = s(a, t, o), t += 2 * o, t += 2, c.startCount = s(a, t, o), t += 2 * o;
|
|
903
|
+
for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(a, t)), t += 2;
|
|
904
|
+
return c.idRangeOffset = s(a, t, o), t += 2 * o, c.glyphIdArray = s(a, t, r + n - t >> 1), c;
|
|
905
905
|
}, parse12(a, t) {
|
|
906
|
-
const e =
|
|
906
|
+
const e = R.readUint;
|
|
907
907
|
e(a, t += 4), e(a, t += 4);
|
|
908
|
-
const
|
|
908
|
+
const i = e(a, t += 4);
|
|
909
909
|
t += 4;
|
|
910
|
-
const
|
|
911
|
-
for (let
|
|
912
|
-
return { format: 12, groups:
|
|
913
|
-
} },
|
|
914
|
-
const
|
|
910
|
+
const s = new Uint32Array(3 * i);
|
|
911
|
+
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);
|
|
912
|
+
return { format: 12, groups: s };
|
|
913
|
+
} }, vt = { parseTab(a, t, e) {
|
|
914
|
+
const i = R;
|
|
915
915
|
t += 18;
|
|
916
|
-
const
|
|
916
|
+
const s = i.readUshort(a, t);
|
|
917
917
|
t += 2, t += 16;
|
|
918
|
-
const
|
|
918
|
+
const r = i.readShort(a, t);
|
|
919
919
|
t += 2;
|
|
920
|
-
const n =
|
|
920
|
+
const n = i.readShort(a, t);
|
|
921
921
|
t += 2;
|
|
922
|
-
const o =
|
|
922
|
+
const o = i.readShort(a, t);
|
|
923
923
|
t += 2;
|
|
924
|
-
const
|
|
925
|
-
return t += 2, t += 6, { unitsPerEm:
|
|
926
|
-
} },
|
|
927
|
-
const
|
|
924
|
+
const c = i.readShort(a, t);
|
|
925
|
+
return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(a, t) };
|
|
926
|
+
} }, Ct = { parseTab(a, t, e) {
|
|
927
|
+
const i = R;
|
|
928
928
|
t += 4;
|
|
929
|
-
const
|
|
930
|
-
for (let n = 0; n <
|
|
931
|
-
const o =
|
|
932
|
-
|
|
929
|
+
const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], r = {};
|
|
930
|
+
for (let n = 0; n < s.length; n++) {
|
|
931
|
+
const o = s[n], c = o === "advanceWidthMax" || o === "numberOfHMetrics" ? i.readUshort : i.readShort;
|
|
932
|
+
r[o] = c(a, t + 2 * n);
|
|
933
933
|
}
|
|
934
|
-
return
|
|
935
|
-
} },
|
|
936
|
-
const
|
|
934
|
+
return r;
|
|
935
|
+
} }, Rt = { parseTab(a, t, e, i) {
|
|
936
|
+
const s = R, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
|
|
937
937
|
let l = 0, d = 0, u = 0;
|
|
938
|
-
for (; u <
|
|
939
|
-
for (; u < o; )
|
|
940
|
-
return { aWidth:
|
|
941
|
-
} },
|
|
942
|
-
const
|
|
943
|
-
return
|
|
944
|
-
} }, hmtx:
|
|
945
|
-
const
|
|
946
|
-
if (n === 0) for (let
|
|
947
|
-
else if (n === 1) for (let
|
|
938
|
+
for (; u < c; ) l = s.readUshort(a, t + (u << 2)), d = s.readShort(a, t + (u << 2) + 2), r.push(l), n.push(d), u++;
|
|
939
|
+
for (; u < o; ) r.push(l), n.push(d), u++;
|
|
940
|
+
return { aWidth: r, lsBearing: n };
|
|
941
|
+
} }, V = { cmap: xt, head: vt, hhea: Ct, maxp: { parseTab(a, t, e) {
|
|
942
|
+
const i = R;
|
|
943
|
+
return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
|
|
944
|
+
} }, hmtx: Rt, loca: { parseTab(a, t, e, i) {
|
|
945
|
+
const s = R, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
|
|
946
|
+
if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(a, t + (c << 1)) << 1);
|
|
947
|
+
else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(a, t + (c << 2)));
|
|
948
|
+
return r;
|
|
949
|
+
} }, glyf: { parseTab(a, t, e, i) {
|
|
950
|
+
const s = [], r = i.maxp.numGlyphs;
|
|
951
|
+
for (let n = 0; n < r; n++) s.push(null);
|
|
948
952
|
return s;
|
|
949
|
-
} }, glyf: { parseTab(a, t, e, r) {
|
|
950
|
-
const i = [], s = r.maxp.numGlyphs;
|
|
951
|
-
for (let n = 0; n < s; n++) i.push(null);
|
|
952
|
-
return i;
|
|
953
953
|
}, us(a, t) {
|
|
954
|
-
const e =
|
|
955
|
-
if (
|
|
956
|
-
const
|
|
957
|
-
if (!
|
|
958
|
-
let n =
|
|
954
|
+
const e = R, i = a.ds, s = a.loca;
|
|
955
|
+
if (s[t] === s[t + 1]) return null;
|
|
956
|
+
const r = b.findTable(i, "glyf", a.fs);
|
|
957
|
+
if (!r) return null;
|
|
958
|
+
let n = r[0] + s[t];
|
|
959
959
|
const o = {};
|
|
960
|
-
if (o.noc = e.readShort(
|
|
960
|
+
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;
|
|
961
961
|
if (o.noc > 0) {
|
|
962
962
|
o.endPts = [];
|
|
963
|
-
for (let f = 0; f < o.noc; f++) o.endPts.push(e.readUshort(
|
|
964
|
-
const
|
|
965
|
-
if (n += 2,
|
|
966
|
-
n +=
|
|
963
|
+
for (let f = 0; f < o.noc; f++) o.endPts.push(e.readUshort(i, n)), n += 2;
|
|
964
|
+
const c = e.readUshort(i, n);
|
|
965
|
+
if (n += 2, i.length - n < c) return null;
|
|
966
|
+
n += c;
|
|
967
967
|
const l = o.endPts[o.noc - 1] + 1;
|
|
968
968
|
o.flags = [];
|
|
969
969
|
for (let f = 0; f < l; f++) {
|
|
970
|
-
const g =
|
|
970
|
+
const g = i[n];
|
|
971
971
|
if (n++, o.flags.push(g), 8 & g) {
|
|
972
|
-
const p =
|
|
972
|
+
const p = i[n];
|
|
973
973
|
n++;
|
|
974
974
|
for (let m = 0; m < p; m++) o.flags.push(g), f++;
|
|
975
975
|
}
|
|
@@ -977,138 +977,138 @@ const S = { readShort: (a, t) => (S.t.uint16[0] = a[t] << 8 | a[t + 1], S.t.int1
|
|
|
977
977
|
o.xs = [];
|
|
978
978
|
for (let f = 0; f < l; f++) {
|
|
979
979
|
const g = o.flags[f], p = !!(16 & g);
|
|
980
|
-
2 & g ? (o.xs.push(p ?
|
|
980
|
+
2 & g ? (o.xs.push(p ? i[n] : -i[n]), n++) : p ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
|
|
981
981
|
}
|
|
982
982
|
o.ys = [];
|
|
983
983
|
for (let f = 0; f < l; f++) {
|
|
984
984
|
const g = o.flags[f], p = !!(32 & g);
|
|
985
|
-
4 & g ? (o.ys.push(p ?
|
|
985
|
+
4 & g ? (o.ys.push(p ? i[n] : -i[n]), n++) : p ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
|
|
986
986
|
}
|
|
987
987
|
let d = 0, u = 0;
|
|
988
988
|
for (let f = 0; f < l; f++) d += o.xs[f], u += o.ys[f], o.xs[f] = d, o.ys[f] = u;
|
|
989
989
|
} else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
|
|
990
990
|
return o;
|
|
991
|
-
} } },
|
|
992
|
-
const
|
|
993
|
-
for (const o in
|
|
994
|
-
const
|
|
991
|
+
} } }, b = { parse: (a) => [((t, e, i, s) => {
|
|
992
|
+
const r = V, n = { ds: t, ps: e, fs: i };
|
|
993
|
+
for (const o in r) {
|
|
994
|
+
const c = o, l = b.findTable(t, c, i);
|
|
995
995
|
if (l) {
|
|
996
996
|
const [d, u] = l;
|
|
997
|
-
let f =
|
|
998
|
-
f == null && (f =
|
|
997
|
+
let f = s[d];
|
|
998
|
+
f == null && (f = r[c].parseTab(t, d, u, n), s[d] = f), n[c] = f;
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
1001
|
return n;
|
|
1002
1002
|
})(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
|
|
1003
|
-
const
|
|
1004
|
-
let
|
|
1005
|
-
for (let n = 0; n <
|
|
1006
|
-
const o =
|
|
1007
|
-
|
|
1008
|
-
const
|
|
1009
|
-
if (o === t) return [
|
|
1010
|
-
|
|
1003
|
+
const i = R, s = i.readUshort(a, e + 4);
|
|
1004
|
+
let r = e + 12;
|
|
1005
|
+
for (let n = 0; n < s; n++) {
|
|
1006
|
+
const o = i.readASCII(a, r, 4);
|
|
1007
|
+
i.readUint(a, r + 4);
|
|
1008
|
+
const c = i.readUint(a, r + 8), l = i.readUint(a, r + 12);
|
|
1009
|
+
if (o === t) return [c, l];
|
|
1010
|
+
r += 16;
|
|
1011
1011
|
}
|
|
1012
1012
|
return null;
|
|
1013
|
-
}, T:
|
|
1014
|
-
class
|
|
1013
|
+
}, T: V, B: R };
|
|
1014
|
+
class M {
|
|
1015
1015
|
constructor() {
|
|
1016
|
-
|
|
1017
|
-
|
|
1016
|
+
h(this, "_s", /* @__PURE__ */ new Map());
|
|
1017
|
+
h(this, "gs", /* @__PURE__ */ new Map());
|
|
1018
1018
|
}
|
|
1019
1019
|
vs(t, e) {
|
|
1020
|
-
const
|
|
1021
|
-
if (this._s.has(
|
|
1022
|
-
const
|
|
1023
|
-
if (!
|
|
1024
|
-
let
|
|
1025
|
-
for (const n of
|
|
1026
|
-
return this._s.set(
|
|
1020
|
+
const i = `${this.Cs(t)}_${e}`;
|
|
1021
|
+
if (this._s.has(i)) return this._s.get(i);
|
|
1022
|
+
const s = t.cmap;
|
|
1023
|
+
if (!s || !s.tables) return this._s.set(i, 0), 0;
|
|
1024
|
+
let r = 0;
|
|
1025
|
+
for (const n of s.tables) if (n.format === 4 ? r = this.ws(e, n) : n.format === 12 && (r = this.$s(e, n)), r > 0) break;
|
|
1026
|
+
return this._s.set(i, r), r;
|
|
1027
1027
|
}
|
|
1028
1028
|
bs(t, e) {
|
|
1029
|
-
const
|
|
1030
|
-
return
|
|
1031
|
-
}
|
|
1032
|
-
zs(t, e) {
|
|
1033
|
-
const r = t.hmtx;
|
|
1034
|
-
return r && r.aWidth && r.aWidth.length !== 0 ? e < r.aWidth.length ? r.aWidth[e] : r.aWidth[r.aWidth.length - 1] : 0;
|
|
1029
|
+
const i = e.codePointAt(0);
|
|
1030
|
+
return i === void 0 ? 0 : this.vs(t, i);
|
|
1035
1031
|
}
|
|
1036
1032
|
Rs(t, e) {
|
|
1037
|
-
const
|
|
1038
|
-
return
|
|
1033
|
+
const i = t.hmtx;
|
|
1034
|
+
return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
|
|
1035
|
+
}
|
|
1036
|
+
zs(t, e) {
|
|
1037
|
+
const i = e / t.head.unitsPerEm, s = t.hhea.ascender * i, r = t.hhea.descender * i, n = t.hhea.lineGap * i;
|
|
1038
|
+
return { ascender: s, descender: r, lineGap: n, lineHeight: s - r + n, unitsPerEm: t.head.unitsPerEm, scale: i };
|
|
1039
1039
|
}
|
|
1040
|
-
|
|
1040
|
+
Ss() {
|
|
1041
1041
|
this._s.clear(), this.gs.clear();
|
|
1042
1042
|
}
|
|
1043
1043
|
Cs(t) {
|
|
1044
|
-
return `${t.
|
|
1044
|
+
return `${t.fs}_${t.ds.length}`;
|
|
1045
1045
|
}
|
|
1046
1046
|
ws(t, e) {
|
|
1047
|
-
const
|
|
1048
|
-
let
|
|
1049
|
-
for (let
|
|
1050
|
-
|
|
1047
|
+
const i = e.endCount.length;
|
|
1048
|
+
let s = -1;
|
|
1049
|
+
for (let r = 0; r < i; r++) if (t <= e.endCount[r]) {
|
|
1050
|
+
s = r;
|
|
1051
1051
|
break;
|
|
1052
1052
|
}
|
|
1053
|
-
if (
|
|
1054
|
-
if (e.idRangeOffset[
|
|
1053
|
+
if (s === -1 || t < e.startCount[s]) return 0;
|
|
1054
|
+
if (e.idRangeOffset[s] === 0) return t + e.idDelta[s] & 65535;
|
|
1055
1055
|
{
|
|
1056
|
-
const
|
|
1057
|
-
if (
|
|
1058
|
-
const n = e.glyphIdArray[
|
|
1059
|
-
return n === 0 ? 0 : n + e.idDelta[
|
|
1056
|
+
const r = e.idRangeOffset[s] / 2 + (t - e.startCount[s]) - (i - s);
|
|
1057
|
+
if (r >= 0 && r < e.glyphIdArray.length) {
|
|
1058
|
+
const n = e.glyphIdArray[r];
|
|
1059
|
+
return n === 0 ? 0 : n + e.idDelta[s] & 65535;
|
|
1060
1060
|
}
|
|
1061
1061
|
}
|
|
1062
1062
|
return 0;
|
|
1063
1063
|
}
|
|
1064
1064
|
$s(t, e) {
|
|
1065
|
-
const
|
|
1066
|
-
for (let
|
|
1067
|
-
const
|
|
1068
|
-
if (t >=
|
|
1065
|
+
const i = e.groups.length / 3;
|
|
1066
|
+
for (let s = 0; s < i; s++) {
|
|
1067
|
+
const r = e.groups[3 * s], n = e.groups[3 * s + 1], o = e.groups[3 * s + 2];
|
|
1068
|
+
if (t >= r && t <= n) return o + (t - r);
|
|
1069
1069
|
}
|
|
1070
1070
|
return 0;
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
|
-
class
|
|
1073
|
+
class Et {
|
|
1074
1074
|
constructor(t) {
|
|
1075
|
-
|
|
1076
|
-
this.
|
|
1075
|
+
h(this, "Ts");
|
|
1076
|
+
this.Ts = t;
|
|
1077
1077
|
}
|
|
1078
|
-
|
|
1079
|
-
var
|
|
1078
|
+
Ps(t) {
|
|
1079
|
+
var i;
|
|
1080
1080
|
const e = [];
|
|
1081
|
-
return (
|
|
1082
|
-
if (
|
|
1083
|
-
const
|
|
1084
|
-
e.push(...
|
|
1085
|
-
} else if (
|
|
1086
|
-
const
|
|
1087
|
-
e.push(...
|
|
1081
|
+
return (i = t.cmap) != null && i.tables ? (t.cmap.tables.forEach((s) => {
|
|
1082
|
+
if (s.format === 4) {
|
|
1083
|
+
const r = this.Ms(s);
|
|
1084
|
+
e.push(...r);
|
|
1085
|
+
} else if (s.format === 12) {
|
|
1086
|
+
const r = this.Fs(s);
|
|
1087
|
+
e.push(...r);
|
|
1088
1088
|
}
|
|
1089
1089
|
}), [...new Set(e)]) : [];
|
|
1090
1090
|
}
|
|
1091
|
-
|
|
1092
|
-
return this.
|
|
1091
|
+
As(t, e) {
|
|
1092
|
+
return this.Ts.bs(t, e) > 0;
|
|
1093
1093
|
}
|
|
1094
|
-
|
|
1095
|
-
for (const
|
|
1094
|
+
Ds(t, e) {
|
|
1095
|
+
for (const i of e) if (!this.As(t, i)) return !1;
|
|
1096
1096
|
return !0;
|
|
1097
1097
|
}
|
|
1098
|
-
|
|
1099
|
-
return e.filter((
|
|
1098
|
+
Gs(t, e) {
|
|
1099
|
+
return e.filter((i) => this.As(t, i));
|
|
1100
1100
|
}
|
|
1101
|
-
|
|
1102
|
-
return t.filter((e) => this.
|
|
1101
|
+
ks(t) {
|
|
1102
|
+
return t.filter((e) => this.Es(e));
|
|
1103
1103
|
}
|
|
1104
|
-
|
|
1104
|
+
Ms(t) {
|
|
1105
1105
|
const e = [];
|
|
1106
1106
|
if (!(t.startCount && t.endCount && t.idRangeOffset && t.idDelta)) return e;
|
|
1107
|
-
for (let
|
|
1108
|
-
const
|
|
1109
|
-
if (
|
|
1110
|
-
for (let n =
|
|
1111
|
-
if (this.Ls(t, n,
|
|
1107
|
+
for (let i = 0; i < t.startCount.length; i++) {
|
|
1108
|
+
const s = t.startCount[i], r = t.endCount[i];
|
|
1109
|
+
if (s !== 65535 || r !== 65535) {
|
|
1110
|
+
for (let n = s; n <= r; n++)
|
|
1111
|
+
if (this.Ls(t, n, i) > 0) try {
|
|
1112
1112
|
const o = String.fromCodePoint(n);
|
|
1113
1113
|
e.push(o);
|
|
1114
1114
|
} catch {
|
|
@@ -1117,229 +1117,229 @@ class Rt {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
return e;
|
|
1119
1119
|
}
|
|
1120
|
-
|
|
1120
|
+
Fs(t) {
|
|
1121
1121
|
const e = [];
|
|
1122
1122
|
if (!t.groups) return e;
|
|
1123
|
-
for (let
|
|
1124
|
-
const
|
|
1125
|
-
for (let o =
|
|
1126
|
-
if (n + (o -
|
|
1127
|
-
const
|
|
1128
|
-
e.push(
|
|
1123
|
+
for (let i = 0; i < t.groups.length; i += 3) {
|
|
1124
|
+
const s = t.groups[i], r = t.groups[i + 1], n = t.groups[i + 2];
|
|
1125
|
+
for (let o = s; o <= r; o++)
|
|
1126
|
+
if (n + (o - s) > 0) try {
|
|
1127
|
+
const c = String.fromCodePoint(o);
|
|
1128
|
+
e.push(c);
|
|
1129
1129
|
} catch {
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
1132
|
return e;
|
|
1133
1133
|
}
|
|
1134
|
-
Ls(t, e,
|
|
1135
|
-
if (t.idRangeOffset[
|
|
1134
|
+
Ls(t, e, i) {
|
|
1135
|
+
if (t.idRangeOffset[i] === 0) return e + t.idDelta[i] & 65535;
|
|
1136
1136
|
{
|
|
1137
|
-
const
|
|
1138
|
-
if (
|
|
1139
|
-
const
|
|
1140
|
-
if (
|
|
1137
|
+
const s = t.idRangeOffset[i] / 2 + (e - t.startCount[i]) - (t.startCount.length - i);
|
|
1138
|
+
if (s >= 0 && t.glyphIdArray && s < t.glyphIdArray.length) {
|
|
1139
|
+
const r = t.glyphIdArray[s];
|
|
1140
|
+
if (r !== 0) return r + t.idDelta[i] & 65535;
|
|
1141
1141
|
}
|
|
1142
1142
|
}
|
|
1143
1143
|
return 0;
|
|
1144
1144
|
}
|
|
1145
|
-
|
|
1145
|
+
Es(t) {
|
|
1146
1146
|
const e = t.codePointAt(0) || 0;
|
|
1147
1147
|
return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
1150
|
-
class
|
|
1150
|
+
class St {
|
|
1151
1151
|
constructor() {
|
|
1152
|
-
|
|
1153
|
-
const t = new
|
|
1154
|
-
this.
|
|
1152
|
+
h(this, "Bs");
|
|
1153
|
+
const t = new M();
|
|
1154
|
+
this.Bs = new Et(t);
|
|
1155
1155
|
}
|
|
1156
1156
|
extractCharacters(t) {
|
|
1157
|
-
return this.
|
|
1157
|
+
return this.Bs.Ps(t);
|
|
1158
1158
|
}
|
|
1159
1159
|
filterProblematicCharacters(t) {
|
|
1160
|
-
return this.
|
|
1160
|
+
return this.Bs.ks(t);
|
|
1161
1161
|
}
|
|
1162
1162
|
characterExists(t, e) {
|
|
1163
|
-
return this.
|
|
1163
|
+
return this.Bs.As(t, e);
|
|
1164
1164
|
}
|
|
1165
1165
|
allCharactersExist(t, e) {
|
|
1166
|
-
return this.
|
|
1166
|
+
return this.Bs.Ds(t, e);
|
|
1167
1167
|
}
|
|
1168
1168
|
}
|
|
1169
|
-
class
|
|
1169
|
+
class Tt {
|
|
1170
1170
|
constructor(t) {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
this.Us = t, this.
|
|
1176
|
-
}
|
|
1177
|
-
createTextureAtlas(t, e,
|
|
1178
|
-
const
|
|
1179
|
-
this.
|
|
1180
|
-
const u = this.Us.rs(
|
|
1181
|
-
return u.L(this.
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
this.
|
|
1185
|
-
}
|
|
1186
|
-
js(t, e,
|
|
1187
|
-
const n =
|
|
1171
|
+
h(this, "Is");
|
|
1172
|
+
h(this, "Ws");
|
|
1173
|
+
h(this, "Us");
|
|
1174
|
+
h(this, "Os");
|
|
1175
|
+
this.Us = t, this.Os = new M(), this.Is = document.createElement("canvas"), this.Ws = this.Is.getContext("2d", { willReadFrequently: !0, alpha: !1 });
|
|
1176
|
+
}
|
|
1177
|
+
createTextureAtlas(t, e, i, s) {
|
|
1178
|
+
const r = t.length, n = Math.ceil(Math.sqrt(r)), o = Math.ceil(r / n), c = e.width * n, l = e.height * o, d = typeof s == "object" ? s : null;
|
|
1179
|
+
this.Vs(c, l), this.js(t, e, n, i, d);
|
|
1180
|
+
const u = this.Us.rs(c, l, 1, { filter: "nearest" });
|
|
1181
|
+
return u.L(this.Is), { framebuffer: u, columns: n, rows: o };
|
|
1182
|
+
}
|
|
1183
|
+
Vs(t, e) {
|
|
1184
|
+
this.Is.width = t, this.Is.height = e, this.Is.style.width = t + "px", this.Is.style.height = t + "px", this.Ws.imageSmoothingEnabled = !1, this.Is.style.imageRendering = "pixelated", this.Ws.fillStyle = "black", this.Ws.fillRect(0, 0, t, e), this.Ws.textBaseline = "top", this.Ws.textAlign = "left", this.Ws.fillStyle = "white";
|
|
1185
|
+
}
|
|
1186
|
+
js(t, e, i, s, r) {
|
|
1187
|
+
const n = s / r.head.unitsPerEm;
|
|
1188
1188
|
for (let o = 0; o < t.length; o++) {
|
|
1189
|
-
const
|
|
1189
|
+
const c = o % i, l = Math.floor(o / i), d = t[o].character, u = this.Hs(r, d);
|
|
1190
1190
|
if (!u) continue;
|
|
1191
|
-
const f = d.codePointAt(0) || 0, g = this.
|
|
1192
|
-
this.
|
|
1191
|
+
const f = d.codePointAt(0) || 0, g = this.Os.vs(r, f), p = this.Ks(r, g) * n, m = c * e.width, E = l * e.height, C = m + 0.5 * e.width, S = E + 0.5 * e.height, w = Math.round(C - 0.5 * e.width), x = Math.round(S - 0.5 * s), U = w + 0.5 * (e.width - p), K = x + r.hhea.ascender * n;
|
|
1192
|
+
this.Xs(u, U, K, n);
|
|
1193
1193
|
}
|
|
1194
1194
|
}
|
|
1195
1195
|
Hs(t, e) {
|
|
1196
|
-
const
|
|
1197
|
-
if (
|
|
1198
|
-
if (t.glyf && t.glyf[
|
|
1199
|
-
if (
|
|
1200
|
-
const
|
|
1201
|
-
return t.glyf &&
|
|
1196
|
+
const i = e.codePointAt(0) || 0, s = this.Os.vs(t, i);
|
|
1197
|
+
if (s === 0) return null;
|
|
1198
|
+
if (t.glyf && t.glyf[s] !== null) return t.glyf[s];
|
|
1199
|
+
if (b && b.T && b.T.glyf) {
|
|
1200
|
+
const r = b.T.glyf.us(t, s);
|
|
1201
|
+
return t.glyf && r && (t.glyf[s] = r), r;
|
|
1202
1202
|
}
|
|
1203
1203
|
return null;
|
|
1204
1204
|
}
|
|
1205
|
-
|
|
1206
|
-
const
|
|
1207
|
-
return
|
|
1205
|
+
Ks(t, e) {
|
|
1206
|
+
const i = t.hmtx;
|
|
1207
|
+
return i && i.aWidth ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
|
|
1208
1208
|
}
|
|
1209
|
-
|
|
1209
|
+
Xs(t, e, i, s) {
|
|
1210
1210
|
if (!t || !t.xs || t.noc === 0) return;
|
|
1211
|
-
const { xs:
|
|
1212
|
-
if (!(
|
|
1213
|
-
this.
|
|
1211
|
+
const { xs: r, ys: n, endPts: o, flags: c } = t;
|
|
1212
|
+
if (!(r && n && o && c)) return;
|
|
1213
|
+
this.Ws.beginPath();
|
|
1214
1214
|
let l = 0;
|
|
1215
1215
|
for (let d = 0; d < o.length; d++) {
|
|
1216
1216
|
const u = o[d];
|
|
1217
1217
|
if (!(u < l)) {
|
|
1218
1218
|
if (u >= l) {
|
|
1219
|
-
const f = e +
|
|
1220
|
-
this.
|
|
1219
|
+
const f = e + r[l] * s, g = i - n[l] * s;
|
|
1220
|
+
this.Ws.moveTo(f, g);
|
|
1221
1221
|
let p = l + 1;
|
|
1222
1222
|
for (; p <= u; )
|
|
1223
|
-
if (1 &
|
|
1224
|
-
const m = e +
|
|
1225
|
-
this.
|
|
1223
|
+
if (1 & c[p]) {
|
|
1224
|
+
const m = e + r[p] * s, E = i - n[p] * s;
|
|
1225
|
+
this.Ws.lineTo(m, E), p++;
|
|
1226
1226
|
} else {
|
|
1227
|
-
const m = e +
|
|
1228
|
-
let
|
|
1229
|
-
if (1 &
|
|
1230
|
-
const
|
|
1231
|
-
this.
|
|
1227
|
+
const m = e + r[p] * s, E = i - n[p] * s;
|
|
1228
|
+
let C = p + 1 > u ? l : p + 1;
|
|
1229
|
+
if (1 & c[C]) {
|
|
1230
|
+
const S = e + r[C] * s, w = i - n[C] * s;
|
|
1231
|
+
this.Ws.quadraticCurveTo(m, E, S, w), p = C + 1;
|
|
1232
1232
|
} else {
|
|
1233
|
-
const
|
|
1234
|
-
this.
|
|
1233
|
+
const S = (m + (e + r[C] * s)) / 2, w = (E + (i - n[C] * s)) / 2;
|
|
1234
|
+
this.Ws.quadraticCurveTo(m, E, S, w), p = C;
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
this.
|
|
1237
|
+
this.Ws.closePath();
|
|
1238
1238
|
}
|
|
1239
1239
|
l = u + 1;
|
|
1240
1240
|
}
|
|
1241
1241
|
}
|
|
1242
|
-
this.
|
|
1242
|
+
this.Ws.fill();
|
|
1243
1243
|
}
|
|
1244
1244
|
}
|
|
1245
|
-
class
|
|
1245
|
+
class wt {
|
|
1246
1246
|
constructor() {
|
|
1247
|
-
|
|
1248
|
-
this.
|
|
1247
|
+
h(this, "Ts");
|
|
1248
|
+
this.Ts = new M();
|
|
1249
1249
|
}
|
|
1250
|
-
calculateMaxGlyphDimensions(t, e,
|
|
1251
|
-
let
|
|
1252
|
-
const
|
|
1250
|
+
calculateMaxGlyphDimensions(t, e, i) {
|
|
1251
|
+
let s = 0;
|
|
1252
|
+
const r = this.Ts.zs(i, e), n = r.lineHeight;
|
|
1253
1253
|
for (const o of t) {
|
|
1254
|
-
const
|
|
1255
|
-
if (
|
|
1256
|
-
const l = this.
|
|
1257
|
-
|
|
1254
|
+
const c = this.Ts.bs(i, o);
|
|
1255
|
+
if (c === 0) continue;
|
|
1256
|
+
const l = this.Ts.Rs(i, c) * r.scale;
|
|
1257
|
+
s = Math.max(s, l);
|
|
1258
1258
|
}
|
|
1259
|
-
return { width: Math.ceil(
|
|
1259
|
+
return { width: Math.ceil(s), height: Math.ceil(n) };
|
|
1260
1260
|
}
|
|
1261
|
-
getCharacterAdvanceWidth(t, e,
|
|
1262
|
-
const
|
|
1263
|
-
return this.
|
|
1261
|
+
getCharacterAdvanceWidth(t, e, i) {
|
|
1262
|
+
const s = this.Ts.zs(i, e), r = this.Ts.bs(i, t);
|
|
1263
|
+
return this.Ts.Rs(i, r) * s.scale;
|
|
1264
1264
|
}
|
|
1265
1265
|
getFontMetrics(t, e) {
|
|
1266
|
-
return this.
|
|
1266
|
+
return this.Ts.zs(e, t);
|
|
1267
1267
|
}
|
|
1268
|
-
|
|
1269
|
-
this.Ss
|
|
1268
|
+
Ss() {
|
|
1269
|
+
this.Ts.Ss();
|
|
1270
1270
|
}
|
|
1271
1271
|
}
|
|
1272
|
-
class
|
|
1272
|
+
class bt {
|
|
1273
1273
|
constructor() {
|
|
1274
|
-
|
|
1275
|
-
this.
|
|
1274
|
+
h(this, "Os");
|
|
1275
|
+
this.Os = new M();
|
|
1276
1276
|
}
|
|
1277
1277
|
createCharacterObjects(t, e) {
|
|
1278
|
-
return t.map((
|
|
1279
|
-
const
|
|
1278
|
+
return t.map((i, s) => {
|
|
1279
|
+
const r = i.codePointAt(0) || 0, n = this.Ys(s);
|
|
1280
1280
|
let o = 0;
|
|
1281
1281
|
if (e.hmtx && e.hmtx.aWidth) {
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1282
|
+
const c = this.Os.vs(e, r);
|
|
1283
|
+
c > 0 && e.hmtx.aWidth[c] !== void 0 && (o = e.hmtx.aWidth[c]);
|
|
1284
1284
|
}
|
|
1285
|
-
return { character:
|
|
1285
|
+
return { character: i, unicode: r, color: n, advanceWidth: o };
|
|
1286
1286
|
});
|
|
1287
1287
|
}
|
|
1288
|
-
|
|
1288
|
+
Ys(t) {
|
|
1289
1289
|
return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
|
|
1290
1290
|
}
|
|
1291
|
-
Zs(t, e) {
|
|
1292
|
-
if (!I.m(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
|
|
1293
|
-
const r = e.find((i) => i.character === t);
|
|
1294
|
-
return r ? r.color : [0, 0, 0];
|
|
1295
|
-
}
|
|
1296
1291
|
Ns(t, e) {
|
|
1297
|
-
|
|
1292
|
+
if (!D.m(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
|
|
1293
|
+
const i = e.find((s) => s.character === t);
|
|
1294
|
+
return i ? i.color : [0, 0, 0];
|
|
1295
|
+
}
|
|
1296
|
+
qs(t, e) {
|
|
1297
|
+
return D.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.Ns(i, e) || [0, 0, 0]) : [[0, 0, 0]];
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
|
-
class
|
|
1300
|
+
class _t {
|
|
1301
1301
|
constructor(t, e = 16) {
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
this.ti = e, this.ni = new
|
|
1302
|
+
h(this, "Zs");
|
|
1303
|
+
h(this, "Qs", []);
|
|
1304
|
+
h(this, "Js");
|
|
1305
|
+
h(this, "ti", 16);
|
|
1306
|
+
h(this, "ei", 0);
|
|
1307
|
+
h(this, "si", 0);
|
|
1308
|
+
h(this, "ii", { width: 0, height: 0 });
|
|
1309
|
+
h(this, "ri");
|
|
1310
|
+
h(this, "ni");
|
|
1311
|
+
h(this, "oi");
|
|
1312
|
+
h(this, "ai");
|
|
1313
|
+
h(this, "hi");
|
|
1314
|
+
this.ti = e, this.ni = new St(), this.oi = new Tt(t), this.ai = new wt(), this.hi = new bt();
|
|
1315
1315
|
}
|
|
1316
1316
|
async ci(t) {
|
|
1317
1317
|
let e;
|
|
1318
|
-
if (!t) throw new
|
|
1318
|
+
if (!t) throw new T("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
|
|
1319
1319
|
{
|
|
1320
|
-
const
|
|
1321
|
-
if (!
|
|
1322
|
-
e = await
|
|
1320
|
+
const i = await fetch(t);
|
|
1321
|
+
if (!i.ok) throw new T(`Failed to load font file: ${i.status} ${i.statusText}`);
|
|
1322
|
+
e = await i.arrayBuffer();
|
|
1323
1323
|
}
|
|
1324
|
-
await this.li(e), this.
|
|
1324
|
+
await this.li(e), this.Zs = b.parse(e)[0], await this.ui();
|
|
1325
1325
|
}
|
|
1326
|
-
|
|
1326
|
+
di(t) {
|
|
1327
1327
|
if (t === void 0) return this.ti;
|
|
1328
|
-
this.ti = t, this.ii = this.ai.calculateMaxGlyphDimensions(this.
|
|
1329
|
-
const e = this.oi.createTextureAtlas(this.
|
|
1330
|
-
this.
|
|
1328
|
+
this.ti = t, this.ii = this.ai.calculateMaxGlyphDimensions(this.Qs.map((i) => i.character), this.ti, this.Zs);
|
|
1329
|
+
const e = this.oi.createTextureAtlas(this.Qs, this.ii, this.ti, this.Zs);
|
|
1330
|
+
this.Js = e.framebuffer, this.ei = e.columns, this.si = e.rows;
|
|
1331
1331
|
}
|
|
1332
|
-
async
|
|
1332
|
+
async fi(t) {
|
|
1333
1333
|
try {
|
|
1334
1334
|
const e = await fetch(t);
|
|
1335
|
-
if (!e.ok) throw new
|
|
1336
|
-
const
|
|
1337
|
-
await this.li(
|
|
1338
|
-
const
|
|
1339
|
-
if (!
|
|
1340
|
-
this.
|
|
1335
|
+
if (!e.ok) throw new T(`Failed to load font file: ${e.status} ${e.statusText}`);
|
|
1336
|
+
const i = await e.arrayBuffer();
|
|
1337
|
+
await this.li(i);
|
|
1338
|
+
const s = b.parse(i);
|
|
1339
|
+
if (!s || s.length === 0) throw Error("Failed to parse font file");
|
|
1340
|
+
this.Zs = s[0], await this.ui();
|
|
1341
1341
|
} catch (e) {
|
|
1342
|
-
throw new
|
|
1342
|
+
throw new T("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
|
|
1343
1343
|
}
|
|
1344
1344
|
}
|
|
1345
1345
|
async li(t) {
|
|
@@ -1347,25 +1347,25 @@ class Tt {
|
|
|
1347
1347
|
this.ri = new FontFace("CustomFont_" + e, t), await this.ri.load(), document.fonts.add(this.ri);
|
|
1348
1348
|
}
|
|
1349
1349
|
async ui() {
|
|
1350
|
-
const t = this.ni.extractCharacters(this.
|
|
1351
|
-
this.
|
|
1352
|
-
const
|
|
1353
|
-
this.
|
|
1354
|
-
}
|
|
1355
|
-
Zs(t) {
|
|
1356
|
-
return this.hi.Zs(t, this.Js);
|
|
1350
|
+
const t = this.ni.extractCharacters(this.Zs), e = this.ni.filterProblematicCharacters(t);
|
|
1351
|
+
this.Qs = this.hi.createCharacterObjects(e, this.Zs), this.ii = this.ai.calculateMaxGlyphDimensions(e, this.ti, this.Zs);
|
|
1352
|
+
const i = this.oi.createTextureAtlas(this.Qs, this.ii, this.ti, this.Zs);
|
|
1353
|
+
this.Js = i.framebuffer, this.ei = i.columns, this.si = i.rows;
|
|
1357
1354
|
}
|
|
1358
1355
|
Ns(t) {
|
|
1359
|
-
return this.hi.Ns(t, this.
|
|
1356
|
+
return this.hi.Ns(t, this.Qs);
|
|
1357
|
+
}
|
|
1358
|
+
qs(t) {
|
|
1359
|
+
return this.hi.qs(t, this.Qs);
|
|
1360
1360
|
}
|
|
1361
1361
|
j() {
|
|
1362
|
-
this.
|
|
1362
|
+
this.Js.j(), document.fonts.delete(this.ri);
|
|
1363
1363
|
}
|
|
1364
1364
|
get fontFramebuffer() {
|
|
1365
|
-
return this.
|
|
1365
|
+
return this.Js;
|
|
1366
1366
|
}
|
|
1367
1367
|
get characters() {
|
|
1368
|
-
return this.
|
|
1368
|
+
return this.Qs;
|
|
1369
1369
|
}
|
|
1370
1370
|
get textureColumns() {
|
|
1371
1371
|
return this.ei;
|
|
@@ -1380,33 +1380,33 @@ class Tt {
|
|
|
1380
1380
|
return this.ti;
|
|
1381
1381
|
}
|
|
1382
1382
|
get font() {
|
|
1383
|
-
return this.
|
|
1383
|
+
return this.Zs;
|
|
1384
1384
|
}
|
|
1385
1385
|
}
|
|
1386
1386
|
class At {
|
|
1387
|
-
constructor(t, e,
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
this.
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
this.pi = Math.floor(this.
|
|
1387
|
+
constructor(t, e, i) {
|
|
1388
|
+
h(this, "pi");
|
|
1389
|
+
h(this, "_i");
|
|
1390
|
+
h(this, "C");
|
|
1391
|
+
h(this, "$");
|
|
1392
|
+
h(this, "gi");
|
|
1393
|
+
h(this, "mi");
|
|
1394
|
+
h(this, "yi");
|
|
1395
|
+
h(this, "Ci");
|
|
1396
|
+
h(this, "xi");
|
|
1397
|
+
this.yi = t, this.Ci = e, this.xi = i, this.Rt();
|
|
1398
|
+
}
|
|
1399
|
+
Rt() {
|
|
1400
|
+
this.pi = Math.floor(this.yi.width / this.Ci), this._i = Math.floor(this.yi.height / this.xi), this.C = this.pi * this.Ci, this.$ = this._i * this.xi, this.gi = Math.floor((this.yi.width - this.C) / 2), this.mi = Math.floor((this.yi.height - this.$) / 2);
|
|
1401
1401
|
}
|
|
1402
1402
|
wi(t, e) {
|
|
1403
|
-
this.Ci = t, this.
|
|
1403
|
+
this.Ci = t, this.xi = e, this.Rt();
|
|
1404
1404
|
}
|
|
1405
1405
|
get cellWidth() {
|
|
1406
1406
|
return this.Ci;
|
|
1407
1407
|
}
|
|
1408
1408
|
get cellHeight() {
|
|
1409
|
-
return this.
|
|
1409
|
+
return this.xi;
|
|
1410
1410
|
}
|
|
1411
1411
|
get cols() {
|
|
1412
1412
|
return this.pi;
|
|
@@ -1429,123 +1429,305 @@ class At {
|
|
|
1429
1429
|
}
|
|
1430
1430
|
class Ft {
|
|
1431
1431
|
constructor(t = {}) {
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
t.canvas ? (this.
|
|
1432
|
+
h(this, "yi");
|
|
1433
|
+
h(this, "$i");
|
|
1434
|
+
h(this, "bi");
|
|
1435
|
+
t.canvas ? (this.yi = t.canvas, this.bi = !1) : (this.yi = this.Ri(t.width, t.height), this.bi = !0), this.yi.style.imageRendering = "pixelated";
|
|
1436
1436
|
}
|
|
1437
|
-
|
|
1438
|
-
const
|
|
1439
|
-
return
|
|
1437
|
+
Ri(t, e) {
|
|
1438
|
+
const i = document.createElement("canvas");
|
|
1439
|
+
return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
|
|
1440
1440
|
}
|
|
1441
|
-
|
|
1442
|
-
this.
|
|
1441
|
+
I(t, e) {
|
|
1442
|
+
this.yi.width = t ?? this.yi.width, this.yi.height = e ?? this.yi.height;
|
|
1443
1443
|
}
|
|
1444
|
-
|
|
1445
|
-
const t = this.
|
|
1446
|
-
if (!t) throw new
|
|
1444
|
+
zi() {
|
|
1445
|
+
const t = this.yi.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
|
|
1446
|
+
if (!t) throw new T("`textmode.js` requires WebGL2 support.");
|
|
1447
1447
|
return t;
|
|
1448
1448
|
}
|
|
1449
1449
|
j() {
|
|
1450
1450
|
this.$i && this.$i.disconnect();
|
|
1451
|
-
const t = this.
|
|
1451
|
+
const t = this.yi.getContext("webgl") || this.yi.getContext("webgl2");
|
|
1452
1452
|
if (t) {
|
|
1453
1453
|
const e = t.getExtension("WEBGL_lose_context");
|
|
1454
1454
|
e && e.loseContext();
|
|
1455
1455
|
}
|
|
1456
|
-
this.bi && this.
|
|
1456
|
+
this.bi && this.yi.parentNode && this.yi.parentNode.removeChild(this.yi);
|
|
1457
1457
|
}
|
|
1458
1458
|
get canvas() {
|
|
1459
|
-
return this.
|
|
1459
|
+
return this.yi;
|
|
1460
1460
|
}
|
|
1461
1461
|
get width() {
|
|
1462
|
-
return this.
|
|
1462
|
+
return this.yi.width;
|
|
1463
1463
|
}
|
|
1464
1464
|
get height() {
|
|
1465
|
-
return this.
|
|
1465
|
+
return this.yi.height;
|
|
1466
1466
|
}
|
|
1467
1467
|
}
|
|
1468
|
-
class
|
|
1468
|
+
class Lt {
|
|
1469
1469
|
constructor(t = 60) {
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
this.
|
|
1470
|
+
h(this, "Si");
|
|
1471
|
+
h(this, "Ti");
|
|
1472
|
+
h(this, "Pi", null);
|
|
1473
|
+
h(this, "Mi", 0);
|
|
1474
|
+
h(this, "Fi", !0);
|
|
1475
|
+
h(this, "Ai", 0);
|
|
1476
|
+
h(this, "Di", 0);
|
|
1477
|
+
h(this, "Gi", []);
|
|
1478
|
+
h(this, "ki", 10);
|
|
1479
|
+
h(this, "Ei", 0);
|
|
1480
|
+
this.Si = t, this.Ti = 1e3 / t;
|
|
1481
1481
|
}
|
|
1482
1482
|
start(t) {
|
|
1483
|
-
if (!this.
|
|
1484
|
-
this.
|
|
1485
|
-
const e = (
|
|
1486
|
-
if (!this.
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1483
|
+
if (!this.Fi) return;
|
|
1484
|
+
this.Mi = performance.now();
|
|
1485
|
+
const e = (i) => {
|
|
1486
|
+
if (!this.Fi) return void (this.Pi = null);
|
|
1487
|
+
const s = i - this.Mi;
|
|
1488
|
+
s >= this.Ti && (t(), this.Mi = i - s % this.Ti), this.Fi && (this.Pi = requestAnimationFrame(e));
|
|
1489
1489
|
};
|
|
1490
|
-
this.
|
|
1490
|
+
this.Pi = requestAnimationFrame(e);
|
|
1491
1491
|
}
|
|
1492
1492
|
stop() {
|
|
1493
|
-
this.
|
|
1493
|
+
this.Pi && (cancelAnimationFrame(this.Pi), this.Pi = null);
|
|
1494
1494
|
}
|
|
1495
1495
|
pause() {
|
|
1496
|
-
this.
|
|
1496
|
+
this.Fi && (this.Fi = !1, this.stop());
|
|
1497
1497
|
}
|
|
1498
1498
|
resume(t) {
|
|
1499
|
-
this.
|
|
1499
|
+
this.Fi || (this.Fi = !0, this.start(t));
|
|
1500
1500
|
}
|
|
1501
1501
|
frameRate(t, e) {
|
|
1502
|
-
if (t === void 0) return this.
|
|
1503
|
-
this.
|
|
1502
|
+
if (t === void 0) return this.Ai;
|
|
1503
|
+
this.Si = t, this.Ti = 1e3 / t, this.Fi && e && (this.stop(), this.start(e));
|
|
1504
1504
|
}
|
|
1505
1505
|
measureFrameRate() {
|
|
1506
1506
|
const t = performance.now();
|
|
1507
|
-
if (this.
|
|
1508
|
-
const e = t - this.
|
|
1509
|
-
this.
|
|
1510
|
-
const
|
|
1511
|
-
this.
|
|
1507
|
+
if (this.Di > 0) {
|
|
1508
|
+
const e = t - this.Di;
|
|
1509
|
+
this.Gi.push(e), this.Gi.length > this.ki && this.Gi.shift();
|
|
1510
|
+
const i = this.Gi.reduce((s, r) => s + r, 0) / this.Gi.length;
|
|
1511
|
+
this.Ai = 1e3 / i;
|
|
1512
1512
|
}
|
|
1513
|
-
this.
|
|
1513
|
+
this.Di = t;
|
|
1514
1514
|
}
|
|
1515
1515
|
get isLooping() {
|
|
1516
|
-
return this.
|
|
1516
|
+
return this.Fi;
|
|
1517
1517
|
}
|
|
1518
1518
|
get frameRateLimit() {
|
|
1519
|
-
return this.
|
|
1519
|
+
return this.Si;
|
|
1520
1520
|
}
|
|
1521
1521
|
get currentFrameRate() {
|
|
1522
|
-
return this.
|
|
1522
|
+
return this.Ai;
|
|
1523
1523
|
}
|
|
1524
1524
|
get frameCount() {
|
|
1525
|
-
return this.
|
|
1525
|
+
return this.Ei;
|
|
1526
1526
|
}
|
|
1527
1527
|
set frameCount(t) {
|
|
1528
|
-
this.
|
|
1528
|
+
this.Ei = t;
|
|
1529
1529
|
}
|
|
1530
1530
|
incrementFrame() {
|
|
1531
|
-
this.
|
|
1531
|
+
this.Ei++;
|
|
1532
1532
|
}
|
|
1533
1533
|
resetFrameCount() {
|
|
1534
|
-
this.
|
|
1534
|
+
this.Ei = 0;
|
|
1535
1535
|
}
|
|
1536
1536
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1537
|
+
class Pt {
|
|
1538
|
+
constructor(t) {
|
|
1539
|
+
h(this, "yi");
|
|
1540
|
+
h(this, "Li");
|
|
1541
|
+
h(this, "Bi", { x: -1, y: -1 });
|
|
1542
|
+
h(this, "Ii", { x: -1, y: -1 });
|
|
1543
|
+
h(this, "Wi", null);
|
|
1544
|
+
h(this, "Ui");
|
|
1545
|
+
h(this, "Oi");
|
|
1546
|
+
h(this, "Vi");
|
|
1547
|
+
h(this, "ji");
|
|
1548
|
+
h(this, "Hi");
|
|
1549
|
+
h(this, "Ki");
|
|
1550
|
+
h(this, "Xi", !1);
|
|
1551
|
+
h(this, "Yi");
|
|
1552
|
+
h(this, "Ni");
|
|
1553
|
+
h(this, "qi");
|
|
1554
|
+
h(this, "Zi");
|
|
1555
|
+
h(this, "Qi");
|
|
1556
|
+
this.yi = t;
|
|
1557
|
+
}
|
|
1558
|
+
ci(t) {
|
|
1559
|
+
this.Li = t, this.Ji();
|
|
1560
|
+
}
|
|
1561
|
+
tr() {
|
|
1562
|
+
if (this.Xi) return;
|
|
1563
|
+
const t = this.yi.canvas;
|
|
1564
|
+
this.Ui = (e) => {
|
|
1565
|
+
this.er(e), this.sr(e);
|
|
1566
|
+
}, this.Oi = () => {
|
|
1567
|
+
this.Ii = { ...this.Bi }, this.Bi.x = -1, this.Bi.y = -1, this.Wi = null;
|
|
1568
|
+
}, this.Vi = (e) => {
|
|
1569
|
+
this.er(e), this.ir(e);
|
|
1570
|
+
}, this.ji = (e) => {
|
|
1571
|
+
this.er(e), this.rr(e);
|
|
1572
|
+
}, this.Hi = (e) => {
|
|
1573
|
+
this.er(e), this.nr(e);
|
|
1574
|
+
}, this.Ki = (e) => {
|
|
1575
|
+
this.er(e), this.ar(e);
|
|
1576
|
+
}, t.addEventListener("mousemove", this.Ui, { passive: !0 }), t.addEventListener("mouseleave", this.Oi, { passive: !0 }), t.addEventListener("mousedown", this.Vi, { passive: !0 }), t.addEventListener("mouseup", this.ji, { passive: !0 }), t.addEventListener("click", this.Hi, { passive: !0 }), t.addEventListener("wheel", this.Ki, { passive: !1 }), this.Xi = !0;
|
|
1577
|
+
}
|
|
1578
|
+
hr() {
|
|
1579
|
+
if (!this.Xi) return;
|
|
1580
|
+
const t = this.yi.canvas;
|
|
1581
|
+
t.removeEventListener("mousemove", this.Ui), t.removeEventListener("mouseleave", this.Oi), t.removeEventListener("mousedown", this.Vi), t.removeEventListener("mouseup", this.ji), t.removeEventListener("click", this.Hi), t.removeEventListener("wheel", this.Ki), this.Xi = !1;
|
|
1582
|
+
}
|
|
1583
|
+
Ji() {
|
|
1584
|
+
if (this.Xi) try {
|
|
1585
|
+
if (this.Wi) {
|
|
1586
|
+
const t = new MouseEvent("mousemove", { clientX: this.Wi.x, clientY: this.Wi.y, bubbles: !1, cancelable: !1 });
|
|
1587
|
+
this.er(t);
|
|
1588
|
+
} else this.Bi.x !== -1 && this.Bi.y !== -1 && (this.Bi.x >= this.Li.cols || this.Bi.y >= this.Li.rows) && (this.Bi.x = -1, this.Bi.y = -1);
|
|
1589
|
+
} catch {
|
|
1590
|
+
this.Bi.x = -1, this.Bi.y = -1;
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
cr(t) {
|
|
1594
|
+
this.Yi = t;
|
|
1595
|
+
}
|
|
1596
|
+
lr(t) {
|
|
1597
|
+
this.Ni = t;
|
|
1598
|
+
}
|
|
1599
|
+
ur(t) {
|
|
1600
|
+
this.qi = t;
|
|
1601
|
+
}
|
|
1602
|
+
dr(t) {
|
|
1603
|
+
this.Zi = t;
|
|
1604
|
+
}
|
|
1605
|
+
pr(t) {
|
|
1606
|
+
this.Qi = t;
|
|
1607
|
+
}
|
|
1608
|
+
_r() {
|
|
1609
|
+
return { x: this.Bi.x, y: this.Bi.y };
|
|
1610
|
+
}
|
|
1611
|
+
sr(t) {
|
|
1612
|
+
if (this.Zi) {
|
|
1613
|
+
const e = { position: { ...this.Bi }, previousPosition: { ...this.Ii }, originalEvent: t };
|
|
1614
|
+
this.Zi(e);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
ir(t) {
|
|
1618
|
+
if (this.Ni) {
|
|
1619
|
+
const e = { position: { ...this.Bi }, previousPosition: { ...this.Ii }, button: t.button, originalEvent: t };
|
|
1620
|
+
this.Ni(e);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
rr(t) {
|
|
1624
|
+
if (this.qi) {
|
|
1625
|
+
const e = { position: { ...this.Bi }, previousPosition: { ...this.Ii }, button: t.button, originalEvent: t };
|
|
1626
|
+
this.qi(e);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
nr(t) {
|
|
1630
|
+
if (this.Yi) {
|
|
1631
|
+
const e = { position: { ...this.Bi }, previousPosition: { ...this.Ii }, button: t.button, originalEvent: t };
|
|
1632
|
+
this.Yi(e);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
ar(t) {
|
|
1636
|
+
if (this.Qi) {
|
|
1637
|
+
const e = { position: { ...this.Bi }, previousPosition: { ...this.Ii }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
|
|
1638
|
+
this.Qi(e);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
er(t) {
|
|
1642
|
+
const e = this.yi.canvas;
|
|
1643
|
+
this.Ii = { ...this.Bi }, this.Wi = { x: t.clientX, y: t.clientY };
|
|
1644
|
+
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.Li.offsetX, l = o - this.Li.offsetY, d = Math.floor(c / this.Li.cellWidth), u = Math.floor(l / this.Li.cellHeight);
|
|
1645
|
+
d >= 0 && d < this.Li.cols && u >= 0 && u < this.Li.rows ? (this.Bi.x = d, this.Bi.y = u) : (this.Bi.x = -1, this.Bi.y = -1);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
class Ut {
|
|
1649
|
+
constructor() {
|
|
1650
|
+
h(this, "gr", /* @__PURE__ */ new Map());
|
|
1651
|
+
h(this, "mr", null);
|
|
1652
|
+
h(this, "vr", null);
|
|
1653
|
+
h(this, "yr");
|
|
1654
|
+
h(this, "Cr");
|
|
1655
|
+
h(this, "Xi", !1);
|
|
1656
|
+
h(this, "wr");
|
|
1657
|
+
h(this, "$r");
|
|
1658
|
+
h(this, "br", { 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" });
|
|
1659
|
+
}
|
|
1660
|
+
tr() {
|
|
1661
|
+
this.Xi || (this.yr = (t) => {
|
|
1662
|
+
this.Rr(t);
|
|
1663
|
+
}, this.Cr = (t) => {
|
|
1664
|
+
this.zr(t);
|
|
1665
|
+
}, window.addEventListener("keydown", this.yr, { passive: !1 }), window.addEventListener("keyup", this.Cr, { passive: !1 }), this.Xi = !0);
|
|
1666
|
+
}
|
|
1667
|
+
hr() {
|
|
1668
|
+
this.Xi && (window.removeEventListener("keydown", this.yr), window.removeEventListener("keyup", this.Cr), this.Xi = !1, this.gr.clear(), this.mr = null, this.vr = null);
|
|
1669
|
+
}
|
|
1670
|
+
lr(t) {
|
|
1671
|
+
this.wr = t;
|
|
1672
|
+
}
|
|
1673
|
+
ur(t) {
|
|
1674
|
+
this.$r = t;
|
|
1675
|
+
}
|
|
1676
|
+
Sr(t) {
|
|
1677
|
+
const e = this.Tr(t), i = this.gr.get(t) || this.gr.get(e);
|
|
1678
|
+
return (i == null ? void 0 : i.isPressed) || !1;
|
|
1679
|
+
}
|
|
1680
|
+
Pr() {
|
|
1681
|
+
return this.mr;
|
|
1682
|
+
}
|
|
1683
|
+
Mr() {
|
|
1684
|
+
return this.vr;
|
|
1685
|
+
}
|
|
1686
|
+
Fr() {
|
|
1687
|
+
const t = [];
|
|
1688
|
+
for (const [e, i] of this.gr) i.isPressed && t.push(e);
|
|
1689
|
+
return t;
|
|
1690
|
+
}
|
|
1691
|
+
Ar() {
|
|
1692
|
+
return { ctrl: this.Sr("Control"), shift: this.Sr("Shift"), alt: this.Sr("Alt"), meta: this.Sr("Meta") };
|
|
1693
|
+
}
|
|
1694
|
+
Dr() {
|
|
1695
|
+
this.gr.clear(), this.mr = null, this.vr = null;
|
|
1696
|
+
}
|
|
1697
|
+
Rr(t) {
|
|
1698
|
+
const e = t.key, i = Date.now();
|
|
1699
|
+
this.gr.has(e) || this.gr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
|
|
1700
|
+
const s = this.gr.get(e);
|
|
1701
|
+
if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.mr = e, this.wr)) {
|
|
1702
|
+
const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
|
|
1703
|
+
this.wr(r);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
zr(t) {
|
|
1707
|
+
const e = t.key, i = Date.now();
|
|
1708
|
+
this.gr.has(e) || this.gr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
|
|
1709
|
+
const s = this.gr.get(e);
|
|
1710
|
+
if (s.isPressed = !1, s.lastReleaseTime = i, this.vr = e, this.$r) {
|
|
1711
|
+
const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
|
|
1712
|
+
this.$r(r);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
Tr(t) {
|
|
1716
|
+
return this.br[t] || t.toLowerCase();
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
const Dt = (a) => class extends a {
|
|
1720
|
+
rotate(t = 0, e = 0, i = 0) {
|
|
1721
|
+
this.Us.state.Tt(t), this.Us.state.Pt(e), this.Us.state.Mt(i);
|
|
1540
1722
|
}
|
|
1541
1723
|
rotateX(t) {
|
|
1542
|
-
this.Us.state.
|
|
1724
|
+
this.Us.state.Tt(t);
|
|
1543
1725
|
}
|
|
1544
1726
|
rotateY(t) {
|
|
1545
|
-
this.Us.state.
|
|
1727
|
+
this.Us.state.Pt(t);
|
|
1546
1728
|
}
|
|
1547
1729
|
rotateZ(t) {
|
|
1548
|
-
this.Us.state.
|
|
1730
|
+
this.Us.state.Mt(t);
|
|
1549
1731
|
}
|
|
1550
1732
|
push() {
|
|
1551
1733
|
this.Us.state.$t();
|
|
@@ -1553,183 +1735,186 @@ const Lt = (a) => class extends a {
|
|
|
1553
1735
|
pop() {
|
|
1554
1736
|
this.Us.state.bt();
|
|
1555
1737
|
}
|
|
1556
|
-
rect(t, e,
|
|
1557
|
-
this.Us.
|
|
1738
|
+
rect(t, e, i = 1, s = 1) {
|
|
1739
|
+
this.Us.Qe(t, e, i, s);
|
|
1740
|
+
}
|
|
1741
|
+
point(t, e) {
|
|
1742
|
+
this.Us.Qe(t, e, 1, 1);
|
|
1558
1743
|
}
|
|
1559
|
-
line(t, e,
|
|
1560
|
-
this.Us.
|
|
1744
|
+
line(t, e, i, s) {
|
|
1745
|
+
this.Us.Je(t, e, i, s);
|
|
1561
1746
|
}
|
|
1562
1747
|
lineWeight(t) {
|
|
1563
|
-
this.Us.state.
|
|
1748
|
+
this.Us.state.St(t);
|
|
1564
1749
|
}
|
|
1565
|
-
background(t, e = t,
|
|
1566
|
-
this.Us.hs(t, e,
|
|
1750
|
+
background(t, e = t, i = t, s = 255) {
|
|
1751
|
+
this.Us.hs(t, e, i, s);
|
|
1567
1752
|
}
|
|
1568
1753
|
char(t) {
|
|
1569
|
-
this.Us.state.
|
|
1754
|
+
this.Us.state.Ft(this.Zs.Ns(t));
|
|
1570
1755
|
}
|
|
1571
|
-
charColor(t, e,
|
|
1572
|
-
this.Us.state.
|
|
1756
|
+
charColor(t, e, i) {
|
|
1757
|
+
this.Us.state.At(t, e, i);
|
|
1573
1758
|
}
|
|
1574
|
-
cellColor(t, e,
|
|
1575
|
-
this.Us.state.
|
|
1759
|
+
cellColor(t, e, i) {
|
|
1760
|
+
this.Us.state.Dt(t, e, i);
|
|
1576
1761
|
}
|
|
1577
1762
|
flipX(t) {
|
|
1578
|
-
this.Us.state.
|
|
1763
|
+
this.Us.state.Gt(t);
|
|
1579
1764
|
}
|
|
1580
1765
|
flipY(t) {
|
|
1581
|
-
this.Us.state.
|
|
1766
|
+
this.Us.state.kt(t);
|
|
1582
1767
|
}
|
|
1583
1768
|
charRotation(t) {
|
|
1584
1769
|
this.Us.state.Lt(t);
|
|
1585
1770
|
}
|
|
1586
1771
|
invert(t) {
|
|
1587
|
-
this.Us.state.
|
|
1772
|
+
this.Us.state.Et(t);
|
|
1588
1773
|
}
|
|
1589
1774
|
clear() {
|
|
1590
1775
|
this.Us.hs(0, 0, 0, 0);
|
|
1591
1776
|
}
|
|
1592
|
-
ellipse(t, e,
|
|
1593
|
-
this.Us.ts(t, e,
|
|
1777
|
+
ellipse(t, e, i, s) {
|
|
1778
|
+
this.Us.ts(t, e, i / 2, s / 2);
|
|
1594
1779
|
}
|
|
1595
|
-
triangle(t, e,
|
|
1596
|
-
this.Us.es(t, e,
|
|
1780
|
+
triangle(t, e, i, s, r, n) {
|
|
1781
|
+
this.Us.es(t, e, i, s, r, n);
|
|
1597
1782
|
}
|
|
1598
|
-
bezierCurve(t, e,
|
|
1599
|
-
this.Us.ss(t, e,
|
|
1783
|
+
bezierCurve(t, e, i, s, r, n, o, c) {
|
|
1784
|
+
this.Us.ss(t, e, i, s, r, n, o, c);
|
|
1600
1785
|
}
|
|
1601
|
-
arc(t, e,
|
|
1602
|
-
this.Us.ns(t, e,
|
|
1786
|
+
arc(t, e, i, s, r, n) {
|
|
1787
|
+
this.Us.ns(t, e, i, s, r, n);
|
|
1603
1788
|
}
|
|
1604
1789
|
shader(t) {
|
|
1605
|
-
this.Us.
|
|
1790
|
+
this.Us.Xe(t);
|
|
1606
1791
|
}
|
|
1607
1792
|
setUniform(t, e) {
|
|
1608
|
-
this.Us.
|
|
1793
|
+
this.Us.Ye(t, e);
|
|
1609
1794
|
}
|
|
1610
1795
|
setUniforms(t) {
|
|
1611
|
-
this.Us.
|
|
1796
|
+
this.Us.Ne(t);
|
|
1612
1797
|
}
|
|
1613
1798
|
createFilterShader(t) {
|
|
1614
|
-
return this.Us.
|
|
1799
|
+
return this.Us.qe(t);
|
|
1615
1800
|
}
|
|
1616
1801
|
};
|
|
1617
|
-
class
|
|
1618
|
-
|
|
1619
|
-
const e = t.
|
|
1620
|
-
return { characterPixels: e, primaryColorPixels:
|
|
1802
|
+
class $ {
|
|
1803
|
+
Gr(t) {
|
|
1804
|
+
const e = t.W(0), i = t.W(1), s = t.W(2), r = t.W(3);
|
|
1805
|
+
return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: s, transformPixels: t.W(4), rotationPixels: r };
|
|
1621
1806
|
}
|
|
1622
|
-
|
|
1807
|
+
kr(t, e) {
|
|
1623
1808
|
return t[e] + (t[e + 1] << 8);
|
|
1624
1809
|
}
|
|
1625
|
-
|
|
1810
|
+
Er(t, e) {
|
|
1626
1811
|
return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
|
|
1627
1812
|
}
|
|
1628
1813
|
}
|
|
1629
|
-
class
|
|
1630
|
-
|
|
1814
|
+
class N {
|
|
1815
|
+
Lr(t, e) {
|
|
1631
1816
|
return new Blob([t], { type: e });
|
|
1632
1817
|
}
|
|
1633
|
-
|
|
1818
|
+
Br(t, e, i) {
|
|
1634
1819
|
try {
|
|
1635
|
-
const
|
|
1636
|
-
n.href =
|
|
1637
|
-
} catch (
|
|
1638
|
-
throw console.error("Failed to download file:",
|
|
1820
|
+
const s = this.Lr(t, i), r = URL.createObjectURL(s), n = document.createElement("a");
|
|
1821
|
+
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);
|
|
1822
|
+
} catch (s) {
|
|
1823
|
+
throw console.error("Failed to download file:", s), Error("File download failed: " + (s instanceof Error ? s.message : "Unknown error"));
|
|
1639
1824
|
}
|
|
1640
1825
|
}
|
|
1641
|
-
|
|
1826
|
+
Ir() {
|
|
1642
1827
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
|
|
1643
1828
|
}
|
|
1644
|
-
|
|
1829
|
+
Wr() {
|
|
1645
1830
|
const t = /* @__PURE__ */ new Date();
|
|
1646
1831
|
return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
|
|
1647
1832
|
}
|
|
1648
|
-
|
|
1833
|
+
Ur(t) {
|
|
1649
1834
|
return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
|
|
1650
1835
|
}
|
|
1651
|
-
|
|
1652
|
-
return "textmode-export-" + this.
|
|
1836
|
+
Or() {
|
|
1837
|
+
return "textmode-export-" + this.Ir();
|
|
1653
1838
|
}
|
|
1654
1839
|
}
|
|
1655
|
-
class
|
|
1656
|
-
|
|
1657
|
-
const
|
|
1658
|
-
return { isInverted:
|
|
1840
|
+
class It extends $ {
|
|
1841
|
+
Vr(t, e, i) {
|
|
1842
|
+
const s = t[i] === 255, r = t[i + 1] === 255, n = t[i + 2] === 255, o = e[i], c = e[i + 1];
|
|
1843
|
+
return { isInverted: s, flipHorizontal: r, flipVertical: n, rotation: Math.round(360 * (o + c / 255) / 255 * 100) / 100 };
|
|
1659
1844
|
}
|
|
1660
|
-
|
|
1661
|
-
return { x: t, y: e, cellX: t *
|
|
1845
|
+
jr(t, e, i) {
|
|
1846
|
+
return { x: t, y: e, cellX: t * i.cellWidth, cellY: e * i.cellHeight };
|
|
1662
1847
|
}
|
|
1663
|
-
|
|
1664
|
-
const
|
|
1665
|
-
let
|
|
1666
|
-
for (let
|
|
1667
|
-
const o = 4 *
|
|
1668
|
-
let l = this.
|
|
1669
|
-
const u = this.
|
|
1848
|
+
Hr(t, e) {
|
|
1849
|
+
const i = [];
|
|
1850
|
+
let s = 0;
|
|
1851
|
+
for (let r = 0; r < e.rows; r++) for (let n = 0; n < e.cols; n++) {
|
|
1852
|
+
const o = 4 * s, c = this.kr(t.characterPixels, o);
|
|
1853
|
+
let l = this.Er(t.primaryColorPixels, o), d = this.Er(t.secondaryColorPixels, o);
|
|
1854
|
+
const u = this.Vr(t.transformPixels, t.rotationPixels, o);
|
|
1670
1855
|
if (u.isInverted) {
|
|
1671
1856
|
const g = l;
|
|
1672
1857
|
l = d, d = g;
|
|
1673
1858
|
}
|
|
1674
|
-
const f = this.
|
|
1675
|
-
|
|
1859
|
+
const f = this.jr(n, r, e);
|
|
1860
|
+
i.push({ charIndex: c, primaryColor: l, secondaryColor: d, transform: u, position: f }), s++;
|
|
1676
1861
|
}
|
|
1677
|
-
return
|
|
1862
|
+
return i;
|
|
1678
1863
|
}
|
|
1679
1864
|
}
|
|
1680
|
-
class
|
|
1681
|
-
|
|
1682
|
-
const
|
|
1683
|
-
for (const
|
|
1684
|
-
const
|
|
1685
|
-
for (let n = 0; n <
|
|
1686
|
-
if (
|
|
1865
|
+
class Bt {
|
|
1866
|
+
Kr(t, e) {
|
|
1867
|
+
const i = t.cmap;
|
|
1868
|
+
for (const s of i.tables) if (s.format === 4) {
|
|
1869
|
+
const r = s;
|
|
1870
|
+
for (let n = 0; n < r.startCount.length; n++) if (e >= r.startCount[n] && e <= r.endCount[n]) {
|
|
1871
|
+
if (r.idRangeOffset[n] === 0) return e + r.idDelta[n] & 65535;
|
|
1687
1872
|
{
|
|
1688
|
-
const o =
|
|
1689
|
-
if (o >= 0 && o <
|
|
1690
|
-
const
|
|
1691
|
-
if (
|
|
1873
|
+
const o = r.idRangeOffset[n] / 2 + (e - r.startCount[n]) - (r.startCount.length - n);
|
|
1874
|
+
if (o >= 0 && o < r.glyphIdArray.length) {
|
|
1875
|
+
const c = r.glyphIdArray[o];
|
|
1876
|
+
if (c !== 0) return c + r.idDelta[n] & 65535;
|
|
1692
1877
|
}
|
|
1693
1878
|
}
|
|
1694
1879
|
}
|
|
1695
|
-
} else if (
|
|
1696
|
-
const
|
|
1697
|
-
for (let n = 0; n <
|
|
1698
|
-
const o =
|
|
1699
|
-
if (e >= o && e <=
|
|
1880
|
+
} else if (s.format === 12) {
|
|
1881
|
+
const r = s;
|
|
1882
|
+
for (let n = 0; n < r.groups.length; n += 3) {
|
|
1883
|
+
const o = r.groups[n], c = r.groups[n + 1], l = r.groups[n + 2];
|
|
1884
|
+
if (e >= o && e <= c) return l + (e - o);
|
|
1700
1885
|
}
|
|
1701
1886
|
}
|
|
1702
1887
|
return 0;
|
|
1703
1888
|
}
|
|
1704
|
-
|
|
1705
|
-
const n =
|
|
1706
|
-
return { getBoundingBox: () => ({ x1:
|
|
1889
|
+
Xr(t, e, i, s, r) {
|
|
1890
|
+
const n = r / t.head.unitsPerEm;
|
|
1891
|
+
return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: s + -e.yMax * n, x2: i + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.Yr(e, i, s, n) };
|
|
1707
1892
|
}
|
|
1708
|
-
|
|
1893
|
+
Yr(t, e, i, s) {
|
|
1709
1894
|
if (!t || !t.xs) return "";
|
|
1710
|
-
const { xs:
|
|
1711
|
-
if (!(
|
|
1895
|
+
const { xs: r, ys: n, endPts: o, flags: c } = t;
|
|
1896
|
+
if (!(r && n && o && c)) return "";
|
|
1712
1897
|
let l = "", d = 0;
|
|
1713
1898
|
for (let u = 0; u < o.length; u++) {
|
|
1714
1899
|
const f = o[u];
|
|
1715
1900
|
if (!(f < d)) {
|
|
1716
1901
|
if (f >= d) {
|
|
1717
|
-
const g = e +
|
|
1902
|
+
const g = e + r[d] * s, p = i - n[d] * s;
|
|
1718
1903
|
l += `M${g.toFixed(2)},${p.toFixed(2)}`;
|
|
1719
1904
|
let m = d + 1;
|
|
1720
1905
|
for (; m <= f; )
|
|
1721
|
-
if (1 &
|
|
1722
|
-
const
|
|
1723
|
-
l += `L${
|
|
1906
|
+
if (1 & c[m]) {
|
|
1907
|
+
const E = e + r[m] * s, C = i - n[m] * s;
|
|
1908
|
+
l += `L${E.toFixed(2)},${C.toFixed(2)}`, m++;
|
|
1724
1909
|
} else {
|
|
1725
|
-
const
|
|
1726
|
-
let
|
|
1727
|
-
if (1 &
|
|
1728
|
-
const
|
|
1729
|
-
l += `Q${
|
|
1910
|
+
const E = e + r[m] * s, C = i - n[m] * s;
|
|
1911
|
+
let S = m + 1 > f ? d : m + 1;
|
|
1912
|
+
if (1 & c[S]) {
|
|
1913
|
+
const w = e + r[S] * s, x = i - n[S] * s;
|
|
1914
|
+
l += `Q${E.toFixed(2)},${C.toFixed(2)} ${w.toFixed(2)},${x.toFixed(2)}`, m = S + 1;
|
|
1730
1915
|
} else {
|
|
1731
|
-
const
|
|
1732
|
-
l += `Q${
|
|
1916
|
+
const w = (E + (e + r[S] * s)) / 2, x = (C + (i - n[S] * s)) / 2;
|
|
1917
|
+
l += `Q${E.toFixed(2)},${C.toFixed(2)} ${w.toFixed(2)},${x.toFixed(2)}`, m = S;
|
|
1733
1918
|
}
|
|
1734
1919
|
}
|
|
1735
1920
|
l += "Z";
|
|
@@ -1739,22 +1924,22 @@ class It {
|
|
|
1739
1924
|
}
|
|
1740
1925
|
return l;
|
|
1741
1926
|
}
|
|
1742
|
-
|
|
1743
|
-
const n = t.codePointAt(0) || 0, o = this.
|
|
1744
|
-
let
|
|
1745
|
-
return e.glyf && e.glyf[o] !== null ?
|
|
1927
|
+
Nr(t, e, i, s, r) {
|
|
1928
|
+
const n = t.codePointAt(0) || 0, o = this.Kr(e, n);
|
|
1929
|
+
let c = null;
|
|
1930
|
+
return e.glyf && e.glyf[o] !== null ? c = e.glyf[o] : (c = b.T.glyf.us(e, o), e.glyf[o] = c), this.Xr(e, c, i, s, r);
|
|
1746
1931
|
}
|
|
1747
|
-
|
|
1748
|
-
const l =
|
|
1749
|
-
return this.
|
|
1932
|
+
qr(t, e, i, s, r, n, o, c) {
|
|
1933
|
+
const l = i + (r - c * (o / e.head.unitsPerEm)) / 2, d = s + (n + 0.7 * o) / 2;
|
|
1934
|
+
return this.Nr(t, e, l, d, o).toSVG() || null;
|
|
1750
1935
|
}
|
|
1751
1936
|
}
|
|
1752
|
-
class
|
|
1937
|
+
class Mt {
|
|
1753
1938
|
constructor() {
|
|
1754
|
-
|
|
1755
|
-
this.
|
|
1939
|
+
h(this, "Zr");
|
|
1940
|
+
this.Zr = new Bt();
|
|
1756
1941
|
}
|
|
1757
|
-
|
|
1942
|
+
Qr(t) {
|
|
1758
1943
|
return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
1759
1944
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
1760
1945
|
<svg width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}"
|
|
@@ -1762,173 +1947,173 @@ class Dt {
|
|
|
1762
1947
|
<title>textmode art generated via textmode.js</title>
|
|
1763
1948
|
<desc>textmode art visualization generated by textmode.js library</desc>`;
|
|
1764
1949
|
}
|
|
1765
|
-
|
|
1950
|
+
Jr() {
|
|
1766
1951
|
return `
|
|
1767
1952
|
</g>
|
|
1768
1953
|
</svg>`;
|
|
1769
1954
|
}
|
|
1770
|
-
|
|
1955
|
+
tn(t, e) {
|
|
1771
1956
|
if (!e.includeBackgroundRectangles) return "";
|
|
1772
|
-
const
|
|
1957
|
+
const i = e.backgroundColor, s = `rgba(${i[0]},${i[1]},${i[2]},${i[3] / 255})`;
|
|
1773
1958
|
return `
|
|
1774
|
-
<rect width="${t.width}" height="${t.height}" fill="${
|
|
1959
|
+
<rect width="${t.width}" height="${t.height}" fill="${s}" />`;
|
|
1775
1960
|
}
|
|
1776
|
-
|
|
1961
|
+
en(t) {
|
|
1777
1962
|
return `rgba(${t.r},${t.g},${t.b},${t.a / 255})`;
|
|
1778
1963
|
}
|
|
1779
|
-
|
|
1780
|
-
const { transform:
|
|
1781
|
-
if (
|
|
1782
|
-
const
|
|
1783
|
-
o.push(`translate(${
|
|
1964
|
+
sn(t, e) {
|
|
1965
|
+
const { transform: i, position: s } = t, r = s.cellX + e.cellWidth / 2, n = s.cellY + e.cellHeight / 2, o = [];
|
|
1966
|
+
if (i.flipHorizontal || i.flipVertical) {
|
|
1967
|
+
const c = i.flipHorizontal ? -1 : 1, l = i.flipVertical ? -1 : 1;
|
|
1968
|
+
o.push(`translate(${r} ${n})`), o.push(`scale(${c} ${l})`), o.push(`translate(${-r} ${-n})`);
|
|
1784
1969
|
}
|
|
1785
|
-
return
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
if (!
|
|
1789
|
-
const { position:
|
|
1790
|
-
return r.drawMode === "stroke" ? `
|
|
1791
|
-
<rect x="${i.cellX}" y="${i.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${s}" fill="none" stroke-width="${r.strokeWidth}" />` : `
|
|
1792
|
-
<rect x="${i.cellX}" y="${i.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${s}" />`;
|
|
1793
|
-
}
|
|
1794
|
-
Ji(t, e, r, i) {
|
|
1795
|
-
const s = r.characters[t.charIndex];
|
|
1796
|
-
if (!s) return "";
|
|
1797
|
-
const n = this.tr.Ki(s.character, r.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, s.advanceWidth);
|
|
1798
|
-
if (!n) return "";
|
|
1799
|
-
const o = this.rr(t.primaryColor);
|
|
1970
|
+
return i.rotation && o.push(`rotate(${i.rotation} ${r} ${n})`), o.length ? ` transform="${o.join(" ")}"` : "";
|
|
1971
|
+
}
|
|
1972
|
+
rn(t, e, i) {
|
|
1973
|
+
if (!i.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
|
|
1974
|
+
const { position: s } = t, r = this.en(t.secondaryColor);
|
|
1800
1975
|
return i.drawMode === "stroke" ? `
|
|
1801
|
-
|
|
1976
|
+
<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${r}" fill="none" stroke-width="${i.strokeWidth}" />` : `
|
|
1977
|
+
<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${r}" />`;
|
|
1978
|
+
}
|
|
1979
|
+
Nr(t, e, i, s) {
|
|
1980
|
+
const r = i.characters[t.charIndex];
|
|
1981
|
+
if (!r) return "";
|
|
1982
|
+
const n = this.Zr.qr(r.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, r.advanceWidth);
|
|
1983
|
+
if (!n) return "";
|
|
1984
|
+
const o = this.en(t.primaryColor);
|
|
1985
|
+
return s.drawMode === "stroke" ? `
|
|
1986
|
+
<path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${n}" stroke="${o}" stroke-width="${s.strokeWidth}" fill="none" />` : `
|
|
1802
1987
|
<path d="${n}" fill="${o}" />`;
|
|
1803
1988
|
}
|
|
1804
|
-
|
|
1805
|
-
let
|
|
1806
|
-
|
|
1807
|
-
const n = this.
|
|
1808
|
-
return o && (n ? (
|
|
1809
|
-
<g${n}>`,
|
|
1810
|
-
</g>`) :
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
let
|
|
1814
|
-
|
|
1989
|
+
nn(t, e, i, s) {
|
|
1990
|
+
let r = "";
|
|
1991
|
+
r += this.rn(t, e, s);
|
|
1992
|
+
const n = this.sn(t, e), o = this.Nr(t, e, i, s);
|
|
1993
|
+
return o && (n ? (r += `
|
|
1994
|
+
<g${n}>`, r += o, r += `
|
|
1995
|
+
</g>`) : r += o), r;
|
|
1996
|
+
}
|
|
1997
|
+
an(t, e, i, s) {
|
|
1998
|
+
let r = this.Qr(e);
|
|
1999
|
+
r += this.tn(e, s), r += `
|
|
1815
2000
|
<g id="ascii-cells">`;
|
|
1816
|
-
for (const n of t)
|
|
1817
|
-
return
|
|
2001
|
+
for (const n of t) r += this.nn(n, e, i, s);
|
|
2002
|
+
return r += this.Jr(), r;
|
|
1818
2003
|
}
|
|
1819
|
-
|
|
2004
|
+
hn(t) {
|
|
1820
2005
|
return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\n\s*\n/g, `
|
|
1821
2006
|
`).replace(/[ \t]+$/gm, "");
|
|
1822
2007
|
}
|
|
1823
2008
|
}
|
|
1824
|
-
class
|
|
1825
|
-
|
|
1826
|
-
return this.
|
|
2009
|
+
class zt extends N {
|
|
2010
|
+
cn(t) {
|
|
2011
|
+
return this.Lr(t, "image/svg+xml;charset=utf-8");
|
|
1827
2012
|
}
|
|
1828
|
-
|
|
1829
|
-
this.
|
|
2013
|
+
ln(t, e) {
|
|
2014
|
+
this.Br(t, this.Ur(e) + ".svg", "image/svg+xml;charset=utf-8");
|
|
1830
2015
|
}
|
|
1831
|
-
|
|
1832
|
-
this.
|
|
2016
|
+
un(t, e) {
|
|
2017
|
+
this.ln(t, e || this.Or());
|
|
1833
2018
|
}
|
|
1834
2019
|
}
|
|
1835
|
-
class
|
|
2020
|
+
class Y {
|
|
1836
2021
|
constructor() {
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
this.
|
|
2022
|
+
h(this, "dn");
|
|
2023
|
+
h(this, "fn");
|
|
2024
|
+
h(this, "pn");
|
|
2025
|
+
this.dn = new It(), this.fn = new Mt(), this.pn = new zt();
|
|
1841
2026
|
}
|
|
1842
|
-
|
|
1843
|
-
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.
|
|
2027
|
+
_n(t) {
|
|
2028
|
+
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.pn.Or() };
|
|
1844
2029
|
}
|
|
1845
|
-
|
|
1846
|
-
const
|
|
1847
|
-
return this.
|
|
2030
|
+
gn(t, e = {}) {
|
|
2031
|
+
const i = this.dn.Hr(this.dn.Gr(t.pipeline), t.grid), s = this.fn.an(i, t.grid, t.font, this._n(e));
|
|
2032
|
+
return this.fn.hn(s);
|
|
1848
2033
|
}
|
|
1849
|
-
|
|
1850
|
-
this.
|
|
2034
|
+
un(t, e = {}) {
|
|
2035
|
+
this.pn.un(this.gn(t, e), e.filename);
|
|
1851
2036
|
}
|
|
1852
2037
|
}
|
|
1853
|
-
class
|
|
1854
|
-
|
|
2038
|
+
class Ot extends $ {
|
|
2039
|
+
mn(t, e, i, s = " ") {
|
|
1855
2040
|
var o;
|
|
1856
|
-
const
|
|
2041
|
+
const r = [];
|
|
1857
2042
|
let n = 0;
|
|
1858
|
-
for (let
|
|
2043
|
+
for (let c = 0; c < e.rows; c++) {
|
|
1859
2044
|
const l = [];
|
|
1860
2045
|
for (let d = 0; d < e.cols; d++) {
|
|
1861
|
-
const u = 4 * n, f = this.
|
|
2046
|
+
const u = 4 * n, f = this.kr(t.characterPixels, u), g = ((o = i.characters[f]) == null ? void 0 : o.character) || s;
|
|
1862
2047
|
l.push(g), n++;
|
|
1863
2048
|
}
|
|
1864
|
-
|
|
2049
|
+
r.push(l);
|
|
1865
2050
|
}
|
|
1866
|
-
return
|
|
2051
|
+
return r;
|
|
1867
2052
|
}
|
|
1868
2053
|
}
|
|
1869
|
-
class
|
|
1870
|
-
|
|
1871
|
-
const
|
|
1872
|
-
for (const
|
|
1873
|
-
let n =
|
|
1874
|
-
e.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")),
|
|
2054
|
+
class Gt {
|
|
2055
|
+
vn(t, e) {
|
|
2056
|
+
const i = [];
|
|
2057
|
+
for (const r of t) {
|
|
2058
|
+
let n = r.join("");
|
|
2059
|
+
e.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")), i.push(n);
|
|
1875
2060
|
}
|
|
1876
|
-
const
|
|
2061
|
+
const s = e.lineEnding === "crlf" ? `\r
|
|
1877
2062
|
` : `
|
|
1878
2063
|
`;
|
|
1879
|
-
return
|
|
2064
|
+
return i.join(s);
|
|
1880
2065
|
}
|
|
1881
2066
|
}
|
|
1882
|
-
class
|
|
1883
|
-
|
|
1884
|
-
const
|
|
1885
|
-
this.
|
|
2067
|
+
class Wt extends N {
|
|
2068
|
+
yn(t, e) {
|
|
2069
|
+
const i = this.Cn(e);
|
|
2070
|
+
this.Br(t, i, "text/plain;charset=utf-8");
|
|
1886
2071
|
}
|
|
1887
|
-
|
|
1888
|
-
let e = this.
|
|
1889
|
-
return e === ".txt" || e.length <= 4 ? this.
|
|
2072
|
+
Cn(t) {
|
|
2073
|
+
let e = this.Ur(t);
|
|
2074
|
+
return e === ".txt" || e.length <= 4 ? this.Or() : e;
|
|
1890
2075
|
}
|
|
1891
2076
|
}
|
|
1892
|
-
class
|
|
2077
|
+
class j {
|
|
1893
2078
|
constructor() {
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
this.
|
|
2079
|
+
h(this, "dn");
|
|
2080
|
+
h(this, "fn");
|
|
2081
|
+
h(this, "pn");
|
|
2082
|
+
this.dn = new Ot(), this.fn = new Gt(), this.pn = new Wt();
|
|
1898
2083
|
}
|
|
1899
|
-
|
|
1900
|
-
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.
|
|
2084
|
+
_n(t) {
|
|
2085
|
+
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.pn.Or() };
|
|
1901
2086
|
}
|
|
1902
|
-
|
|
1903
|
-
const
|
|
1904
|
-
return this.
|
|
2087
|
+
xn(t, e = {}) {
|
|
2088
|
+
const i = this._n(e), s = this.dn.mn(this.dn.Gr(t.pipeline), t.grid, t.font, i.emptyCharacter);
|
|
2089
|
+
return this.fn.vn(s, i);
|
|
1905
2090
|
}
|
|
1906
|
-
|
|
1907
|
-
this.
|
|
2091
|
+
yn(t, e = {}) {
|
|
2092
|
+
this.pn.yn(this.xn(t, e), e.filename);
|
|
1908
2093
|
}
|
|
1909
2094
|
}
|
|
1910
|
-
class $t extends
|
|
1911
|
-
|
|
1912
|
-
const
|
|
1913
|
-
if (e === 1 &&
|
|
1914
|
-
const
|
|
1915
|
-
return
|
|
2095
|
+
class $t extends $ {
|
|
2096
|
+
wn(t, e = 1, i = "transparent") {
|
|
2097
|
+
const s = t.canvas;
|
|
2098
|
+
if (e === 1 && i === "transparent") return s;
|
|
2099
|
+
const r = document.createElement("canvas"), n = r.getContext("2d"), o = Math.round(s.width * e), c = Math.round(s.height * e);
|
|
2100
|
+
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;
|
|
1916
2101
|
}
|
|
1917
2102
|
}
|
|
1918
|
-
class
|
|
1919
|
-
|
|
1920
|
-
const
|
|
1921
|
-
return e.format === "png" ? t.toDataURL(
|
|
1922
|
-
}
|
|
1923
|
-
async
|
|
1924
|
-
return new Promise((
|
|
1925
|
-
const
|
|
1926
|
-
o ?
|
|
2103
|
+
class Nt {
|
|
2104
|
+
$n(t, e) {
|
|
2105
|
+
const i = this.bn(e.format);
|
|
2106
|
+
return e.format === "png" ? t.toDataURL(i) : t.toDataURL(i, e.quality);
|
|
2107
|
+
}
|
|
2108
|
+
async Rn(t, e) {
|
|
2109
|
+
return new Promise((i, s) => {
|
|
2110
|
+
const r = this.bn(e.format), n = (o) => {
|
|
2111
|
+
o ? i(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
|
|
1927
2112
|
};
|
|
1928
|
-
e.format === "png" ? t.toBlob(n,
|
|
2113
|
+
e.format === "png" ? t.toBlob(n, r) : t.toBlob(n, r, e.quality);
|
|
1929
2114
|
});
|
|
1930
2115
|
}
|
|
1931
|
-
|
|
2116
|
+
bn(t) {
|
|
1932
2117
|
switch (t) {
|
|
1933
2118
|
case "png":
|
|
1934
2119
|
return "image/png";
|
|
@@ -1941,213 +2126,267 @@ class Ot {
|
|
|
1941
2126
|
}
|
|
1942
2127
|
}
|
|
1943
2128
|
}
|
|
1944
|
-
const
|
|
1945
|
-
class
|
|
1946
|
-
|
|
1947
|
-
this.
|
|
2129
|
+
const kt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, Z = { png: ".png", jpg: ".jpg", webp: ".webp" };
|
|
2130
|
+
class Xt extends N {
|
|
2131
|
+
zn(t, e, i) {
|
|
2132
|
+
this.Sn(t, this.Ur(e) + Z[i]);
|
|
1948
2133
|
}
|
|
1949
|
-
|
|
1950
|
-
const
|
|
2134
|
+
Sn(t, e) {
|
|
2135
|
+
const i = URL.createObjectURL(t);
|
|
1951
2136
|
try {
|
|
1952
|
-
const
|
|
1953
|
-
|
|
2137
|
+
const s = document.createElement("a");
|
|
2138
|
+
s.href = i, s.download = e, s.style.display = "none", s.rel = "noopener", document.body.appendChild(s), s.click(), document.body.removeChild(s);
|
|
1954
2139
|
} finally {
|
|
1955
|
-
URL.revokeObjectURL(
|
|
2140
|
+
URL.revokeObjectURL(i);
|
|
1956
2141
|
}
|
|
1957
2142
|
}
|
|
1958
|
-
|
|
1959
|
-
return t in
|
|
2143
|
+
Tn(t) {
|
|
2144
|
+
return t in kt && t in Z;
|
|
1960
2145
|
}
|
|
1961
2146
|
}
|
|
1962
|
-
class
|
|
2147
|
+
class Vt {
|
|
1963
2148
|
constructor() {
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
this.
|
|
2149
|
+
h(this, "dn");
|
|
2150
|
+
h(this, "fn");
|
|
2151
|
+
h(this, "pn");
|
|
2152
|
+
this.dn = new $t(), this.fn = new Nt(), this.pn = new Xt();
|
|
1968
2153
|
}
|
|
1969
|
-
|
|
1970
|
-
return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.
|
|
2154
|
+
_n(t) {
|
|
2155
|
+
return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.pn.Or() };
|
|
1971
2156
|
}
|
|
1972
|
-
|
|
1973
|
-
if (!this.
|
|
2157
|
+
Pn(t) {
|
|
2158
|
+
if (!this.pn.Tn(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
|
|
1974
2159
|
if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
|
|
1975
2160
|
if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
|
|
1976
2161
|
t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
|
|
1977
2162
|
}
|
|
1978
|
-
async
|
|
1979
|
-
if (e.scale === 1 && e.backgroundColor === "transparent") return await this.
|
|
1980
|
-
const
|
|
1981
|
-
return await this.
|
|
2163
|
+
async Rn(t, e) {
|
|
2164
|
+
if (e.scale === 1 && e.backgroundColor === "transparent") return await this.fn.Rn(t.canvas, e);
|
|
2165
|
+
const i = this.dn.wn(t, e.scale, e.backgroundColor);
|
|
2166
|
+
return await this.fn.Rn(i, e);
|
|
1982
2167
|
}
|
|
1983
|
-
async
|
|
1984
|
-
const
|
|
1985
|
-
this.
|
|
1986
|
-
const
|
|
1987
|
-
this.
|
|
2168
|
+
async zn(t, e = {}) {
|
|
2169
|
+
const i = this._n(e);
|
|
2170
|
+
this.Pn(i);
|
|
2171
|
+
const s = await this.Rn(t, i);
|
|
2172
|
+
this.pn.zn(s, i.filename, i.format);
|
|
1988
2173
|
}
|
|
1989
2174
|
}
|
|
1990
|
-
const
|
|
1991
|
-
|
|
1992
|
-
this.Us.ls(this.
|
|
2175
|
+
const Yt = (a) => class extends a {
|
|
2176
|
+
Mn() {
|
|
2177
|
+
this.Us.ls(this.Fn);
|
|
1993
2178
|
}
|
|
1994
2179
|
toString(t = {}) {
|
|
1995
|
-
return this.
|
|
2180
|
+
return this.Mn(), new j().xn({ pipeline: this.An, grid: this.Li, font: this.Zs }, t);
|
|
1996
2181
|
}
|
|
1997
2182
|
saveStrings(t = {}) {
|
|
1998
|
-
this.
|
|
2183
|
+
this.Mn(), new j().yn({ pipeline: this.An, grid: this.Li, font: this.Zs }, t);
|
|
1999
2184
|
}
|
|
2000
2185
|
toSVG(t = {}) {
|
|
2001
|
-
return this.
|
|
2186
|
+
return this.Mn(), new Y().gn({ pipeline: this.An, grid: this.Li, font: this.Zs }, t);
|
|
2002
2187
|
}
|
|
2003
2188
|
saveSVG(t = {}) {
|
|
2004
|
-
this.
|
|
2189
|
+
this.Mn(), new Y().un({ pipeline: this.An, grid: this.Li, font: this.Zs }, t);
|
|
2005
2190
|
}
|
|
2006
2191
|
async saveCanvas(t = {}) {
|
|
2007
|
-
await new
|
|
2192
|
+
await new Vt().zn(this.yi, t);
|
|
2008
2193
|
}
|
|
2009
|
-
},
|
|
2194
|
+
}, jt = (a) => class extends a {
|
|
2010
2195
|
async loadFont(t) {
|
|
2011
|
-
return this.
|
|
2012
|
-
const e = this.
|
|
2013
|
-
this.
|
|
2196
|
+
return this.Zs.fi(t).then(() => {
|
|
2197
|
+
const e = this.Zs.maxGlyphDimensions;
|
|
2198
|
+
this.Li.wi(e.width, e.height), this.An.I(this.Li.cols, this.Li.rows), this.Us.cs(), this.Dn.Ji();
|
|
2014
2199
|
});
|
|
2015
2200
|
}
|
|
2016
2201
|
fontSize(t) {
|
|
2017
|
-
if (!
|
|
2018
|
-
this.
|
|
2019
|
-
const e = this.
|
|
2020
|
-
this.
|
|
2202
|
+
if (!D.m(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Zs.fontSize === t) return;
|
|
2203
|
+
this.Zs.di(t);
|
|
2204
|
+
const e = this.Zs.maxGlyphDimensions;
|
|
2205
|
+
this.Li.wi(e.width, e.height), this.An.I(this.Li.cols, this.Li.rows), this.Us.cs(), this.Dn.Ji();
|
|
2021
2206
|
}
|
|
2022
|
-
},
|
|
2207
|
+
}, Zt = (a) => class extends a {
|
|
2023
2208
|
get frameCount() {
|
|
2024
|
-
return this.
|
|
2209
|
+
return this.Gn.frameCount;
|
|
2025
2210
|
}
|
|
2026
2211
|
set frameCount(t) {
|
|
2027
|
-
this.
|
|
2212
|
+
this.Gn.frameCount = t;
|
|
2028
2213
|
}
|
|
2029
2214
|
frameRate(t) {
|
|
2030
|
-
return t === void 0 ? this.
|
|
2215
|
+
return t === void 0 ? this.Gn.currentFrameRate : this.Gn.frameRate(t, () => this.kn());
|
|
2031
2216
|
}
|
|
2032
2217
|
noLoop() {
|
|
2033
|
-
this.
|
|
2218
|
+
this.Gn.pause();
|
|
2034
2219
|
}
|
|
2035
2220
|
loop() {
|
|
2036
|
-
this.
|
|
2221
|
+
this.Gn.resume(() => this.kn());
|
|
2037
2222
|
}
|
|
2038
2223
|
redraw(t = 1) {
|
|
2039
|
-
if (
|
|
2224
|
+
if (D.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.kn();
|
|
2040
2225
|
}
|
|
2041
2226
|
isLooping() {
|
|
2042
|
-
return this.
|
|
2227
|
+
return this.Gn.isLooping;
|
|
2228
|
+
}
|
|
2229
|
+
}, Ht = (a) => class extends a {
|
|
2230
|
+
constructor(...t) {
|
|
2231
|
+
super(...t);
|
|
2232
|
+
}
|
|
2233
|
+
mouseClicked(t) {
|
|
2234
|
+
this.Dn.cr(t);
|
|
2235
|
+
}
|
|
2236
|
+
mousePressed(t) {
|
|
2237
|
+
this.Dn.lr(t);
|
|
2238
|
+
}
|
|
2239
|
+
mouseReleased(t) {
|
|
2240
|
+
this.Dn.ur(t);
|
|
2241
|
+
}
|
|
2242
|
+
mouseMoved(t) {
|
|
2243
|
+
this.Dn.dr(t);
|
|
2244
|
+
}
|
|
2245
|
+
mouseScrolled(t) {
|
|
2246
|
+
this.Dn.pr(t);
|
|
2247
|
+
}
|
|
2248
|
+
get mouse() {
|
|
2249
|
+
return this.Dn._r();
|
|
2250
|
+
}
|
|
2251
|
+
}, Kt = (a) => class extends a {
|
|
2252
|
+
constructor(...t) {
|
|
2253
|
+
super(...t);
|
|
2254
|
+
}
|
|
2255
|
+
keyPressed(t) {
|
|
2256
|
+
this.En.lr(t);
|
|
2257
|
+
}
|
|
2258
|
+
keyReleased(t) {
|
|
2259
|
+
this.En.ur(t);
|
|
2260
|
+
}
|
|
2261
|
+
isKeyPressed(t) {
|
|
2262
|
+
return this.En.Sr(t);
|
|
2263
|
+
}
|
|
2264
|
+
clearKeyStates() {
|
|
2265
|
+
this.En.Dr();
|
|
2266
|
+
}
|
|
2267
|
+
get lastKeyPressed() {
|
|
2268
|
+
return this.En.Pr();
|
|
2269
|
+
}
|
|
2270
|
+
get lastKeyReleased() {
|
|
2271
|
+
return this.En.Mr();
|
|
2272
|
+
}
|
|
2273
|
+
get pressedKeys() {
|
|
2274
|
+
return this.En.Fr();
|
|
2275
|
+
}
|
|
2276
|
+
get modifierState() {
|
|
2277
|
+
return this.En.Ar();
|
|
2043
2278
|
}
|
|
2044
2279
|
};
|
|
2045
|
-
class
|
|
2280
|
+
class Jt {
|
|
2046
2281
|
constructor() {
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2282
|
+
h(this, "Us");
|
|
2283
|
+
h(this, "Zs");
|
|
2284
|
+
h(this, "yi");
|
|
2285
|
+
h(this, "Li");
|
|
2286
|
+
h(this, "Gn");
|
|
2287
|
+
h(this, "Dn");
|
|
2288
|
+
h(this, "En");
|
|
2289
|
+
h(this, "Fn");
|
|
2290
|
+
h(this, "An");
|
|
2291
|
+
h(this, "Ln");
|
|
2292
|
+
}
|
|
2293
|
+
kn() {
|
|
2057
2294
|
}
|
|
2058
2295
|
}
|
|
2059
|
-
class
|
|
2060
|
-
return
|
|
2061
|
-
}(Yt,
|
|
2296
|
+
class qt extends function(e, ...i) {
|
|
2297
|
+
return i.reduce((s, r) => r(s), e);
|
|
2298
|
+
}(Jt, Dt, Yt, jt, Zt, Ht, Kt) {
|
|
2062
2299
|
constructor(e = {}) {
|
|
2063
2300
|
super();
|
|
2064
|
-
|
|
2065
|
-
|
|
2301
|
+
h(this, "Bn", !1);
|
|
2302
|
+
h(this, "In", () => {
|
|
2066
2303
|
});
|
|
2067
|
-
|
|
2304
|
+
h(this, "Wn", () => {
|
|
2068
2305
|
});
|
|
2069
|
-
|
|
2306
|
+
h(this, "Un", () => {
|
|
2307
|
+
});
|
|
2308
|
+
h(this, "On");
|
|
2309
|
+
this.yi = new Ft(e), this.Us = new yt(this.yi.zi()), this.Zs = new _t(this.Us, e.fontSize ?? 16), this.Gn = new Lt(e.frameRate ?? 60), this.Dn = new Pt(this.yi), this.En = new Ut(), this.Fn = this.Us.Ke(W, `#version 300 es
|
|
2310
|
+
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.0);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.0,1.0);o_transform=vec4(v_transform,1.0);}`), this.Ln = this.Us.Ke("attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.0,1.0);}", "precision mediump float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D u_primaryColorTexture;uniform sampler2D u_secondaryColorTexture;uniform sampler2D u_transformTexture;uniform sampler2D u_asciiCharacterTexture;uniform sampler2D u_rotationTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;uniform vec2 u_gridOffsetPixels;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){vec2 adjustedCoord=(gl_FragCoord.xy-u_gridOffsetPixels)/u_gridPixelDimensions;vec2 gridCoord=adjustedCoord*u_gridCellDimensions;vec2 cellCoord=floor(gridCoord);vec2 charIndexTexCoord=(cellCoord+0.5)/u_gridCellDimensions;vec4 primaryColor=texture2D(u_primaryColorTexture,charIndexTexCoord);vec4 secondaryColor=texture2D(u_secondaryColorTexture,charIndexTexCoord);vec4 transformColor=texture2D(u_transformTexture,charIndexTexCoord);bool isInverted=transformColor.r>0.5;bool flipHorizontal=transformColor.g>0.5;bool flipVertical=transformColor.b>0.5;vec4 encodedIndexVec=texture2D(u_asciiCharacterTexture,charIndexTexCoord);int charIndex=int(encodedIndexVec.r*255.0+0.5)+int(encodedIndexVec.g*255.0+0.5)*256;int charCol=int(mod(float(charIndex),u_charsetDimensions.x));int charRow=charIndex/int(u_charsetDimensions.x);float flippedRow=(u_charsetDimensions.y-1.0)-float(charRow);vec2 charCoord=vec2(float(charCol),flippedRow)/u_charsetDimensions;vec4 rotationColor=texture2D(u_rotationTexture,charIndexTexCoord);float scaledAngle=rotationColor.r*255.0+rotationColor.g;float rotationAngle=-(scaledAngle*360.0/255.0)*0.017453292;vec2 fractionalPart=fract(gridCoord)-0.5;if(flipHorizontal)fractionalPart.x=-fractionalPart.x;if(flipVertical)fractionalPart.y=-fractionalPart.y;fractionalPart=rotate2D(rotationAngle)*fractionalPart+0.5;vec2 cellSize=1.0/u_charsetDimensions;vec2 texCoord=charCoord+fractionalPart*cellSize;vec2 cellMax=charCoord+cellSize;if(any(lessThan(texCoord,charCoord))||any(greaterThan(texCoord,cellMax))){gl_FragColor=isInverted ? primaryColor : secondaryColor;return;}vec4 charTexel=texture2D(u_characterTexture,texCoord);if(isInverted)charTexel.rgb=1.0-charTexel.rgb;gl_FragColor=mix(secondaryColor,primaryColor,charTexel);}"), this.Vn(e);
|
|
2311
|
+
}
|
|
2312
|
+
async Vn(e) {
|
|
2313
|
+
await this.Zs.ci(e.fontSource);
|
|
2314
|
+
const i = this.Zs.maxGlyphDimensions;
|
|
2315
|
+
this.Li = new At(this.yi.canvas, i.width, i.height), this.Dn.ci(this.Li), this.An = this.Us.rs(this.Li.cols, this.Li.rows, 5), this.jn(), this.In(), this.Gn.start(() => this.kn());
|
|
2316
|
+
}
|
|
2317
|
+
jn() {
|
|
2318
|
+
this.On = () => {
|
|
2319
|
+
this.Un();
|
|
2320
|
+
}, window.addEventListener("resize", this.On), this.Dn.tr(), this.En.tr(), window.addEventListener("blur", () => {
|
|
2321
|
+
this.En.Dr();
|
|
2070
2322
|
});
|
|
2071
|
-
c(this, "Hr");
|
|
2072
|
-
this.xi = new Ft(e), this.Us = new xt(this.xi.Ri()), this.Qs = new Tt(this.Us, e.fontSize ?? 16), this.Er = new Ut(e.frameRate ?? 60), this.Br = this.Us.Xe(O, `#version 300 es
|
|
2073
|
-
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.0);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.0,1.0);o_transform=vec4(v_transform,1.0);}`), this.kr = this.Us.Xe("attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.0,1.0);}", "precision mediump float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D u_primaryColorTexture;uniform sampler2D u_secondaryColorTexture;uniform sampler2D u_transformTexture;uniform sampler2D u_asciiCharacterTexture;uniform sampler2D u_rotationTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;uniform vec2 u_gridOffsetPixels;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){vec2 adjustedCoord=(gl_FragCoord.xy-u_gridOffsetPixels)/u_gridPixelDimensions;vec2 gridCoord=adjustedCoord*u_gridCellDimensions;vec2 cellCoord=floor(gridCoord);vec2 charIndexTexCoord=(cellCoord+0.5)/u_gridCellDimensions;vec4 primaryColor=texture2D(u_primaryColorTexture,charIndexTexCoord);vec4 secondaryColor=texture2D(u_secondaryColorTexture,charIndexTexCoord);vec4 transformColor=texture2D(u_transformTexture,charIndexTexCoord);bool isInverted=transformColor.r>0.5;bool flipHorizontal=transformColor.g>0.5;bool flipVertical=transformColor.b>0.5;vec4 encodedIndexVec=texture2D(u_asciiCharacterTexture,charIndexTexCoord);int charIndex=int(encodedIndexVec.r*255.0+0.5)+int(encodedIndexVec.g*255.0+0.5)*256;int charCol=int(mod(float(charIndex),u_charsetDimensions.x));int charRow=charIndex/int(u_charsetDimensions.x);float flippedRow=(u_charsetDimensions.y-1.0)-float(charRow);vec2 charCoord=vec2(float(charCol),flippedRow)/u_charsetDimensions;vec4 rotationColor=texture2D(u_rotationTexture,charIndexTexCoord);float scaledAngle=rotationColor.r*255.0+rotationColor.g;float rotationAngle=-(scaledAngle*360.0/255.0)*0.017453292;vec2 fractionalPart=fract(gridCoord)-0.5;if(flipHorizontal)fractionalPart.x=-fractionalPart.x;if(flipVertical)fractionalPart.y=-fractionalPart.y;fractionalPart=rotate2D(rotationAngle)*fractionalPart+0.5;vec2 cellSize=1.0/u_charsetDimensions;vec2 texCoord=charCoord+fractionalPart*cellSize;vec2 cellMax=charCoord+cellSize;if(any(lessThan(texCoord,charCoord))||any(greaterThan(texCoord,cellMax))){gl_FragColor=isInverted ? primaryColor : secondaryColor;return;}vec4 charTexel=texture2D(u_characterTexture,texCoord);if(isInverted)charTexel.rgb=1.0-charTexel.rgb;gl_FragColor=mix(secondaryColor,primaryColor,charTexel);}"), this.Xr(e);
|
|
2074
|
-
}
|
|
2075
|
-
async Xr(e) {
|
|
2076
|
-
await this.Qs.ci(e.fontSource);
|
|
2077
|
-
const r = this.Qs.maxGlyphDimensions;
|
|
2078
|
-
this.Lr = new At(this.xi.canvas, r.width, r.height), this.Ir = this.Us.rs(this.Lr.cols, this.Lr.rows, 5), this.Yr(), this.Vr(), this.Er.start(() => this.Wr());
|
|
2079
|
-
}
|
|
2080
|
-
Yr() {
|
|
2081
|
-
this.Hr = () => {
|
|
2082
|
-
this.jr();
|
|
2083
|
-
}, window.addEventListener("resize", this.Hr);
|
|
2084
2323
|
}
|
|
2085
|
-
|
|
2086
|
-
if (this.
|
|
2087
|
-
this.
|
|
2324
|
+
kn() {
|
|
2325
|
+
if (this.Gn.measureFrameRate(), this.Gn.incrementFrame(), this.Bn) return;
|
|
2326
|
+
this.An.O(), this.Us.He(this.Fn), this.Wn(), this.Us.ls(this.Fn), this.An.V();
|
|
2088
2327
|
const e = this.Us.state.canvasBackgroundColor;
|
|
2089
|
-
this.Us.
|
|
2328
|
+
this.Us.fe(e[0], e[1], e[2], e[3]), this.Us.He(this.Ln), this.Ln.st({ u_characterTexture: this.Zs.fontFramebuffer, u_charsetDimensions: [this.Zs.textureColumns, this.Zs.textureRows], u_asciiCharacterTexture: this.An.textures[0], u_primaryColorTexture: this.An.textures[1], u_secondaryColorTexture: this.An.textures[2], u_transformTexture: this.An.textures[4], u_rotationTexture: this.An.textures[3], u_gridCellDimensions: [this.Li.cols, this.Li.rows], u_gridPixelDimensions: [this.Li.width, this.Li.height], u_gridOffsetPixels: [this.Li.offsetX, this.Li.offsetY], u_aspectRatio: this.Li.width / this.Li.height }), this.Us.Ze(this.Li.offsetX, this.Li.offsetY, this.Li.width, this.Li.height);
|
|
2090
2329
|
}
|
|
2091
2330
|
setup(e) {
|
|
2092
|
-
this.
|
|
2331
|
+
this.In = e;
|
|
2093
2332
|
}
|
|
2094
2333
|
draw(e) {
|
|
2095
|
-
this.
|
|
2334
|
+
this.Wn = e;
|
|
2096
2335
|
}
|
|
2097
2336
|
windowResized(e) {
|
|
2098
|
-
this.
|
|
2337
|
+
this.Un = e;
|
|
2099
2338
|
}
|
|
2100
|
-
resizeCanvas(e,
|
|
2101
|
-
this.
|
|
2339
|
+
resizeCanvas(e, i) {
|
|
2340
|
+
this.yi.I(e, i), this.Li.Rt(), this.An.I(this.Li.cols, this.Li.rows), this.Us.cs(), this.Dn.Ji(), this.kn();
|
|
2102
2341
|
}
|
|
2103
2342
|
destroy() {
|
|
2104
|
-
this.
|
|
2343
|
+
this.Bn || (this.Gn.stop(), window.removeEventListener("resize", this.On), this.Dn.hr(), this.En.hr(), this.Zs.j(), this.Us.j(), this.Bn = !0);
|
|
2105
2344
|
}
|
|
2106
2345
|
get grid() {
|
|
2107
|
-
return this.
|
|
2346
|
+
return this.Li;
|
|
2108
2347
|
}
|
|
2109
2348
|
get font() {
|
|
2110
|
-
return this.
|
|
2349
|
+
return this.Zs;
|
|
2111
2350
|
}
|
|
2112
2351
|
get width() {
|
|
2113
|
-
return this.
|
|
2352
|
+
return this.yi.width;
|
|
2114
2353
|
}
|
|
2115
2354
|
get height() {
|
|
2116
|
-
return this.
|
|
2355
|
+
return this.yi.height;
|
|
2117
2356
|
}
|
|
2118
2357
|
get canvas() {
|
|
2119
|
-
return this.
|
|
2358
|
+
return this.yi.canvas;
|
|
2120
2359
|
}
|
|
2121
2360
|
get isDisposed() {
|
|
2122
|
-
return this.
|
|
2361
|
+
return this.Bn;
|
|
2123
2362
|
}
|
|
2124
2363
|
get drawFramebuffer() {
|
|
2125
|
-
return this.
|
|
2364
|
+
return this.An;
|
|
2126
2365
|
}
|
|
2127
2366
|
}
|
|
2128
|
-
class
|
|
2367
|
+
class k {
|
|
2129
2368
|
constructor() {
|
|
2130
2369
|
}
|
|
2131
2370
|
static create(t = {}) {
|
|
2132
|
-
return new
|
|
2371
|
+
return new qt(t);
|
|
2133
2372
|
}
|
|
2134
2373
|
static setErrorLevel(t) {
|
|
2135
|
-
|
|
2374
|
+
D.v(t);
|
|
2136
2375
|
}
|
|
2137
2376
|
static get version() {
|
|
2138
|
-
return "0.2.
|
|
2377
|
+
return "0.2.1-beta.1";
|
|
2139
2378
|
}
|
|
2140
2379
|
}
|
|
2141
|
-
const
|
|
2380
|
+
const te = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), ee = k.create, ie = k.setErrorLevel, se = k.version;
|
|
2142
2381
|
export {
|
|
2143
2382
|
Ft as TextmodeCanvas,
|
|
2144
|
-
|
|
2145
|
-
|
|
2383
|
+
Q as TextmodeErrorLevel,
|
|
2384
|
+
_t as TextmodeFont,
|
|
2146
2385
|
At as TextmodeGrid,
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2386
|
+
qt as Textmodifier,
|
|
2387
|
+
ee as create,
|
|
2388
|
+
te as export,
|
|
2389
|
+
ie as setErrorLevel,
|
|
2390
|
+
k as textmode,
|
|
2391
|
+
se as version
|
|
2153
2392
|
};
|