textmode.js 0.1.9-beta.4 → 0.1.9-beta.6
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 +213 -219
- package/dist/textmode.esm.min.js +475 -481
- package/dist/textmode.umd.js +14 -13
- package/dist/textmode.umd.min.js +17 -16
- package/dist/types/rendering/webgl/Renderer.d.ts +6 -0
- package/dist/types/textmode/font/utils/FontTableReader.d.ts +2 -7
- package/package.json +1 -1
package/dist/textmode.esm.min.js
CHANGED
|
@@ -34,14 +34,14 @@ class w extends Error {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
var rt = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(rt || {});
|
|
37
|
-
const
|
|
37
|
+
const P = class P {
|
|
38
38
|
constructor() {
|
|
39
39
|
h(this, "l", { globalLevel: 3 });
|
|
40
40
|
}
|
|
41
41
|
static u() {
|
|
42
|
-
return
|
|
42
|
+
return P.h || (P.h = new P()), P.h;
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
p(t, e) {
|
|
45
45
|
const r = "%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.l.globalLevel) {
|
|
47
47
|
case 0:
|
|
@@ -54,16 +54,16 @@ const M = class M {
|
|
|
54
54
|
throw new w(t, e);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
return !!t || (this.
|
|
57
|
+
m(t, e, r) {
|
|
58
|
+
return !!t || (this.p(e, r), !1);
|
|
59
59
|
}
|
|
60
60
|
_(t) {
|
|
61
61
|
this.l.globalLevel = t;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
h(
|
|
65
|
-
let
|
|
66
|
-
const x =
|
|
64
|
+
h(P, "h", null);
|
|
65
|
+
let L = P;
|
|
66
|
+
const x = L.u(), q = /* @__PURE__ */ new WeakMap();
|
|
67
67
|
function I(a, t) {
|
|
68
68
|
q.set(a, t);
|
|
69
69
|
}
|
|
@@ -135,21 +135,21 @@ class J {
|
|
|
135
135
|
get(t, e, r, s) {
|
|
136
136
|
const { v: i } = this;
|
|
137
137
|
if (t === void 0 && e === void 0) {
|
|
138
|
-
const
|
|
139
|
-
return this.k(() => (i.readPixels(0, 0, this.F, this.M, i.RGBA, i.UNSIGNED_BYTE,
|
|
138
|
+
const o = new Uint8Array(this.F * this.M * 4);
|
|
139
|
+
return this.k(() => (i.readPixels(0, 0, this.F, this.M, i.RGBA, i.UNSIGNED_BYTE, o), o));
|
|
140
140
|
}
|
|
141
141
|
if (r === void 0 && s === void 0) {
|
|
142
142
|
(t < 0 || e < 0 || t >= this.F || e >= this.M) && (console.warn("The x and y values passed to Framebuffer.get are outside of its range and will be clamped."), t = Math.max(0, Math.min(t, this.F - 1)), e = Math.max(0, Math.min(e, this.M - 1)));
|
|
143
|
-
const
|
|
144
|
-
return this.k(() => (i.readPixels(t, e, 1, 1, i.RGBA, i.UNSIGNED_BYTE,
|
|
143
|
+
const o = new Uint8Array(4);
|
|
144
|
+
return this.k(() => (i.readPixels(t, e, 1, 1, i.RGBA, i.UNSIGNED_BYTE, o), [o[0], o[1], o[2], o[3]]));
|
|
145
145
|
}
|
|
146
146
|
{
|
|
147
147
|
t = Math.max(0, Math.min(t, this.F - 1)), e = Math.max(0, Math.min(e, this.M - 1)), r = Math.max(1, Math.min(r, this.F - t)), s = Math.max(1, Math.min(s, this.M - e));
|
|
148
|
-
const
|
|
149
|
-
return this.k(() => (i.readPixels(t, e, r, s, i.RGBA, i.UNSIGNED_BYTE,
|
|
148
|
+
const o = new Uint8Array(r * s * 4);
|
|
149
|
+
return this.k(() => (i.readPixels(t, e, r, s, i.RGBA, i.UNSIGNED_BYTE, o), o));
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
P() {
|
|
153
153
|
this.C && this.v.deleteFramebuffer(this.C), this.$ && this.v.deleteTexture(this.$);
|
|
154
154
|
}
|
|
155
155
|
get framebuffer() {
|
|
@@ -171,19 +171,19 @@ class J {
|
|
|
171
171
|
class R {
|
|
172
172
|
constructor(t, e, r) {
|
|
173
173
|
h(this, "v");
|
|
174
|
-
h(this, "
|
|
174
|
+
h(this, "G");
|
|
175
175
|
h(this, "A", /* @__PURE__ */ new Map());
|
|
176
176
|
h(this, "U", /* @__PURE__ */ new Map());
|
|
177
177
|
h(this, "L", 0);
|
|
178
178
|
h(this, "H");
|
|
179
|
-
this.v = t, this.
|
|
179
|
+
this.v = t, this.G = this.j(e, r), this.H = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.O();
|
|
180
180
|
}
|
|
181
181
|
O() {
|
|
182
|
-
const t = this.v.getProgramParameter(this.
|
|
182
|
+
const t = this.v.getProgramParameter(this.G, this.v.ACTIVE_UNIFORMS);
|
|
183
183
|
for (let e = 0; e < t; e++) {
|
|
184
|
-
const r = this.v.getActiveUniform(this.
|
|
184
|
+
const r = this.v.getActiveUniform(this.G, e);
|
|
185
185
|
if (r) {
|
|
186
|
-
const s = this.v.getUniformLocation(this.
|
|
186
|
+
const s = this.v.getUniformLocation(this.G, r.name);
|
|
187
187
|
s && (this.A.set(r.name, s), this.U.set(r.name, r.type));
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -191,8 +191,8 @@ class R {
|
|
|
191
191
|
j(t, e) {
|
|
192
192
|
const r = this.W(this.v.VERTEX_SHADER, t), s = this.W(this.v.FRAGMENT_SHADER, e), i = this.v.createProgram();
|
|
193
193
|
if (this.v.attachShader(i, r), this.v.attachShader(i, s), this.v.linkProgram(i), !this.v.getProgramParameter(i, this.v.LINK_STATUS)) {
|
|
194
|
-
const
|
|
195
|
-
throw Error("Shader program link error: " +
|
|
194
|
+
const o = this.v.getProgramInfoLog(i);
|
|
195
|
+
throw Error("Shader program link error: " + o);
|
|
196
196
|
}
|
|
197
197
|
return this.v.deleteShader(r), this.v.deleteShader(s), i;
|
|
198
198
|
}
|
|
@@ -205,7 +205,7 @@ class R {
|
|
|
205
205
|
return r;
|
|
206
206
|
}
|
|
207
207
|
N() {
|
|
208
|
-
this.v.useProgram(this.
|
|
208
|
+
this.v.useProgram(this.G), this.X();
|
|
209
209
|
}
|
|
210
210
|
setUniform(t, e) {
|
|
211
211
|
const r = this.A.get(t);
|
|
@@ -241,10 +241,10 @@ class R {
|
|
|
241
241
|
return !!e && (e === this.v.INT || e === this.v.INT_VEC2 || e === this.v.INT_VEC3 || e === this.v.INT_VEC4 || e === this.v.SAMPLER_2D || e === this.v.SAMPLER_CUBE);
|
|
242
242
|
}
|
|
243
243
|
get glProgram() {
|
|
244
|
-
return this.
|
|
244
|
+
return this.G;
|
|
245
245
|
}
|
|
246
|
-
|
|
247
|
-
this.v.deleteProgram(this.
|
|
246
|
+
P() {
|
|
247
|
+
this.v.deleteProgram(this.G);
|
|
248
248
|
}
|
|
249
249
|
X() {
|
|
250
250
|
this.L = 0;
|
|
@@ -279,10 +279,10 @@ class Q {
|
|
|
279
279
|
it(t, e, r, s) {
|
|
280
280
|
const i = this.v;
|
|
281
281
|
this.tt(), i.bindBuffer(i.ARRAY_BUFFER, this.Z);
|
|
282
|
-
const
|
|
283
|
-
i.bufferData(i.ARRAY_BUFFER,
|
|
282
|
+
const o = new Float32Array([t, s, 0, 0, r, s, 1, 0, t, e, 0, 1, t, e, 0, 1, r, s, 1, 0, r, e, 1, 1]);
|
|
283
|
+
i.bufferData(i.ARRAY_BUFFER, o, i.DYNAMIC_DRAW);
|
|
284
284
|
}
|
|
285
|
-
|
|
285
|
+
P() {
|
|
286
286
|
this.Z && this.v.deleteBuffer(this.Z);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
@@ -290,14 +290,14 @@ class st extends Q {
|
|
|
290
290
|
constructor(t) {
|
|
291
291
|
super(t);
|
|
292
292
|
}
|
|
293
|
-
|
|
294
|
-
const i = this.st(t, e),
|
|
295
|
-
this.it(i.nx, i.ny,
|
|
296
|
-
const
|
|
297
|
-
this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.rt(
|
|
293
|
+
ot(t, e, r, s) {
|
|
294
|
+
const i = this.st(t, e), o = this.st(t + r, e + s);
|
|
295
|
+
this.it(i.nx, i.ny, o.nx, o.ny);
|
|
296
|
+
const n = this.et();
|
|
297
|
+
this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.rt(n.positionLoc, n.texLoc);
|
|
298
298
|
}
|
|
299
|
-
|
|
300
|
-
this.
|
|
299
|
+
nt(t, e, r, s, i) {
|
|
300
|
+
this.ot(t, e, r, i), this.ot(t + r - i, e, i, s), this.ot(t, e + s - i, r, i), this.ot(t, e, i, s);
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
class it extends Q {
|
|
@@ -305,14 +305,14 @@ class it extends Q {
|
|
|
305
305
|
super(t);
|
|
306
306
|
}
|
|
307
307
|
ht(t, e, r, s, i) {
|
|
308
|
-
const
|
|
308
|
+
const o = r - t, n = s - e, l = Math.hypot(o, n);
|
|
309
309
|
if (l === 0) {
|
|
310
310
|
const u = i / 2, f = this.st(t - u, e - u), d = this.st(t + u, e + u);
|
|
311
311
|
this.it(f.nx, f.ny, d.nx, d.ny);
|
|
312
312
|
} else {
|
|
313
|
-
const u = -
|
|
313
|
+
const u = -n / l, f = o / l, d = i / 2, m = t + u * d, p = e + f * d, g = t - u * d, C = e - f * d, v = r + u * d, b = s + f * d, T = r - u * d, E = s - f * d, M = this.st(m, p), F = this.st(g, C), A = this.st(v, b), W = this.st(T, E), S = this.v;
|
|
314
314
|
this.tt(), S.bindBuffer(S.ARRAY_BUFFER, this.Z);
|
|
315
|
-
const K = new Float32Array([
|
|
315
|
+
const K = new Float32Array([M.nx, M.ny, 0, 0, F.nx, F.ny, 0, 1, A.nx, A.ny, 1, 0, F.nx, F.ny, 0, 1, W.nx, W.ny, 1, 1, A.nx, A.ny, 1, 0]);
|
|
316
316
|
S.bufferData(S.ARRAY_BUFFER, K, S.DYNAMIC_DRAW);
|
|
317
317
|
}
|
|
318
318
|
const c = this.et();
|
|
@@ -320,7 +320,7 @@ class it extends Q {
|
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
var $ = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;uniform float u_rotation;uniform vec2 u_center;uniform float u_aspectRatio;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_uv=a_texCoord;vec2 pos=a_position;pos-=u_center;pos.x*=u_aspectRatio;pos=rotate2D(-u_rotation)*pos;pos.x/=u_aspectRatio;pos+=u_center;gl_Position=vec4(pos,0.0,1.0);}";
|
|
323
|
-
class
|
|
323
|
+
class ot {
|
|
324
324
|
constructor(t) {
|
|
325
325
|
h(this, "v");
|
|
326
326
|
h(this, "lt");
|
|
@@ -383,77 +383,83 @@ class nt {
|
|
|
383
383
|
kt() {
|
|
384
384
|
this.ut = null, this.Ct = [], this.wt = 0;
|
|
385
385
|
}
|
|
386
|
-
It(t
|
|
386
|
+
It(t) {
|
|
387
|
+
const e = t.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").trim().match(/^#version\s+(\d+)\s+(es)?/i);
|
|
388
|
+
return e ? parseInt(e[1], 10) >= 300 : !1;
|
|
389
|
+
}
|
|
390
|
+
Pt(t, e) {
|
|
387
391
|
return new R(this.v, t, e);
|
|
388
392
|
}
|
|
389
393
|
zt(t) {
|
|
390
|
-
|
|
394
|
+
const e = this.It(t) ? `#version 300 es
|
|
395
|
+
in vec2 a_position;in vec2 a_texCoord;out vec2 v_uv;uniform float u_rotation;uniform vec2 u_center;uniform float u_aspectRatio;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_uv=a_texCoord;vec2 pos=a_position;pos-=u_center;pos.x*=u_aspectRatio;pos=rotate2D(-u_rotation)*pos;pos.x/=u_aspectRatio;pos+=u_center;gl_Position=vec4(pos,0.0,1.0);}` : $;
|
|
396
|
+
return new R(this.v, e, t);
|
|
391
397
|
}
|
|
392
398
|
Et(t, e) {
|
|
393
399
|
this.ut.setUniform(t, e);
|
|
394
400
|
}
|
|
395
401
|
Gt(t, e, r, s) {
|
|
396
402
|
if (this.ut !== null) {
|
|
397
|
-
const { centerX: f, centerY: d, radians:
|
|
398
|
-
return this.Et("u_rotation",
|
|
403
|
+
const { centerX: f, centerY: d, radians: m, aspectRatio: p } = this.At(t, e, r, s);
|
|
404
|
+
return this.Et("u_rotation", m), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p), this.ft.ot(t, e, r, s), void (this.ut = null);
|
|
399
405
|
}
|
|
400
406
|
const i = this.ct;
|
|
401
|
-
let
|
|
402
|
-
const u = this.
|
|
403
|
-
|
|
407
|
+
let o = 0, n = 0, l = 0, c = 1;
|
|
408
|
+
const u = this.At(t, e, r, s);
|
|
409
|
+
o = u.centerX, n = u.centerY, l = u.radians, c = u.aspectRatio, this._t && (this.yt(i), this.Et("u_color", this.gt), this.Et("u_rotation", l), this.Et("u_center", [o, n]), this.Et("u_aspectRatio", c), this.ft.ot(t, e, r, s)), this.bt && this.xt > 0 && (this.yt(i), this.Et("u_color", this.vt), this.Et("u_rotation", l), this.Et("u_center", [o, n]), this.Et("u_aspectRatio", c), this.ft.nt(t, e, r, s, this.xt)), this.ut = null;
|
|
404
410
|
}
|
|
405
|
-
|
|
411
|
+
Ut(t, e, r, s) {
|
|
406
412
|
if (this.ut !== null) {
|
|
407
|
-
const g = (t + r) / 2, C = (e + s) / 2,
|
|
408
|
-
this.Et("u_rotation",
|
|
409
|
-
const
|
|
410
|
-
return this.dt.ht(t, e, r, s,
|
|
413
|
+
const g = (t + r) / 2, C = (e + s) / 2, v = Math.abs(r - t) || 1, b = Math.abs(s - e) || 1, { centerX: T, centerY: E, radians: M, aspectRatio: F } = this.At(g - v / 2, C - b / 2, v, b);
|
|
414
|
+
this.Et("u_rotation", M), this.Et("u_center", [T, E]), this.Et("u_aspectRatio", F);
|
|
415
|
+
const A = this.xt > 0 ? this.xt : 1;
|
|
416
|
+
return this.dt.ht(t, e, r, s, A), void (this.ut = null);
|
|
411
417
|
}
|
|
412
418
|
if (!this.bt || this.xt <= 0) return;
|
|
413
|
-
const i = this.ct,
|
|
414
|
-
let f = 0, d = 0,
|
|
419
|
+
const i = this.ct, o = (t + r) / 2, n = (e + s) / 2, l = Math.abs(r - t) || 1, c = Math.abs(s - e) || 1, u = this.wt !== 0;
|
|
420
|
+
let f = 0, d = 0, m = 0, p = 1;
|
|
415
421
|
if (u) {
|
|
416
|
-
const g = this.
|
|
417
|
-
f = g.centerX, d = g.centerY,
|
|
422
|
+
const g = this.At(o - l / 2, n - c / 2, l, c);
|
|
423
|
+
f = g.centerX, d = g.centerY, m = g.radians, p = g.aspectRatio;
|
|
418
424
|
}
|
|
419
|
-
this.yt(i), this.Et("u_color", this.vt), u && (this.Et("u_rotation",
|
|
425
|
+
this.yt(i), this.Et("u_color", this.vt), u && (this.Et("u_rotation", m), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p)), this.dt.ht(t, e, r, s, this.xt);
|
|
420
426
|
}
|
|
421
|
-
|
|
422
|
-
const i = Z(this.v) || [0, 0, this.v.canvas.width, this.v.canvas.height],
|
|
423
|
-
return { centerX: (t + r / 2) /
|
|
427
|
+
At(t, e, r, s) {
|
|
428
|
+
const i = Z(this.v) || [0, 0, this.v.canvas.width, this.v.canvas.height], o = i[2], n = i[3], l = o / n;
|
|
429
|
+
return { centerX: (t + r / 2) / o * 2 - 1, centerY: 1 - (e + s / 2) / n * 2, radians: this.wt * Math.PI / 180, aspectRatio: l };
|
|
424
430
|
}
|
|
425
|
-
|
|
431
|
+
Lt(t, e, r = {}) {
|
|
426
432
|
return new J(this.v, t, e, r);
|
|
427
433
|
}
|
|
428
|
-
|
|
429
|
-
this.
|
|
434
|
+
Ht(t, e = t, r = t, s = 255) {
|
|
435
|
+
this.jt(t / 255, e / 255, r / 255, s / 255);
|
|
430
436
|
}
|
|
431
|
-
|
|
437
|
+
jt(t = 0, e = 0, r = 0, s = 0) {
|
|
432
438
|
this.v.clearColor(t, e, r, s), this.v.clear(this.v.COLOR_BUFFER_BIT);
|
|
433
439
|
}
|
|
434
|
-
|
|
440
|
+
Ot() {
|
|
435
441
|
this.v.viewport(0, 0, this.v.canvas.width, this.v.canvas.height), I(this.v, [0, 0, this.v.canvas.width, this.v.canvas.height]);
|
|
436
442
|
}
|
|
437
443
|
get context() {
|
|
438
444
|
return this.v;
|
|
439
445
|
}
|
|
440
|
-
|
|
441
|
-
this.lt.
|
|
446
|
+
P() {
|
|
447
|
+
this.lt.P(), this.ct.P(), this.ft.P(), this.dt.P();
|
|
442
448
|
}
|
|
443
449
|
Bt(t, e, r, s, i) {
|
|
444
|
-
const
|
|
450
|
+
const o = this.v, n = s ?? t.width, l = i ?? t.height;
|
|
445
451
|
this.yt(this.lt), this.Et("u_texture", t.texture);
|
|
446
|
-
const c = this.
|
|
447
|
-
this.Et("u_rotation", c.radians), this.Et("u_center", [c.centerX, c.centerY]), this.Et("u_aspectRatio", c.aspectRatio), this.ft.
|
|
452
|
+
const c = this.At(e, r, n, l);
|
|
453
|
+
this.Et("u_rotation", c.radians), this.Et("u_center", [c.centerX, c.centerY]), this.Et("u_aspectRatio", c.aspectRatio), this.ft.ot(e, r, n, l), o.bindTexture(o.TEXTURE_2D, null), this.ut = null;
|
|
448
454
|
}
|
|
449
455
|
}
|
|
450
|
-
const
|
|
456
|
+
const _ = { readShort: (a, t) => (_.t.uint16[0] = a[t] << 8 | a[t + 1], _.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
|
|
451
457
|
const r = [];
|
|
452
|
-
for (let s = 0; s < e; s++) r.push(
|
|
458
|
+
for (let s = 0; s < e; s++) r.push(_.readUshort(a, t + 2 * s));
|
|
453
459
|
return r;
|
|
454
460
|
}, readUint(a, t) {
|
|
455
|
-
const e =
|
|
456
|
-
return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3],
|
|
461
|
+
const e = _.t.uint8;
|
|
462
|
+
return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], _.t.uint32[0];
|
|
457
463
|
}, readASCII(a, t, e) {
|
|
458
464
|
let r = "";
|
|
459
465
|
for (let s = 0; s < e; s++) r += String.fromCharCode(a[t + s]);
|
|
@@ -461,37 +467,37 @@ const y = { readShort: (a, t) => (y.t.uint16[0] = a[t] << 8 | a[t + 1], y.t.int1
|
|
|
461
467
|
}, t: (() => {
|
|
462
468
|
const a = new ArrayBuffer(8);
|
|
463
469
|
return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
|
|
464
|
-
})() },
|
|
470
|
+
})() }, nt = { parseTab(a, t, e) {
|
|
465
471
|
const r = { tables: [], ids: {}, off: t };
|
|
466
472
|
a = new Uint8Array(a.buffer, t, e), t = 0;
|
|
467
|
-
const s =
|
|
473
|
+
const s = _, i = s.readUshort, o = i(a, t += 2);
|
|
468
474
|
t += 2;
|
|
469
|
-
const
|
|
470
|
-
for (let l = 0; l <
|
|
475
|
+
const n = [];
|
|
476
|
+
for (let l = 0; l < o; l++) {
|
|
471
477
|
const c = i(a, t), u = i(a, t += 2);
|
|
472
478
|
t += 2;
|
|
473
479
|
const f = s.readUint(a, t);
|
|
474
480
|
t += 4;
|
|
475
481
|
const d = `p${c}e${u}`;
|
|
476
|
-
let
|
|
477
|
-
if (
|
|
482
|
+
let m = n.indexOf(f);
|
|
483
|
+
if (m === -1) {
|
|
478
484
|
let p;
|
|
479
|
-
|
|
485
|
+
m = r.tables.length, n.push(f);
|
|
480
486
|
const g = i(a, f);
|
|
481
487
|
p = g === 4 ? this.parse4(a, f) : g === 12 ? this.parse12(a, f) : { format: g }, r.tables.push(p);
|
|
482
488
|
}
|
|
483
|
-
r.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), r.ids[d] =
|
|
489
|
+
r.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), r.ids[d] = m;
|
|
484
490
|
}
|
|
485
491
|
return r;
|
|
486
492
|
}, parse4(a, t) {
|
|
487
|
-
const e =
|
|
493
|
+
const e = _, r = e.readUshort, s = e.readUshorts, i = t, o = r(a, t += 2);
|
|
488
494
|
t += 2;
|
|
489
|
-
const
|
|
490
|
-
t += 2, l.entrySelector = r(a, t), t += 2, l.rangeShift = r(a, t), t += 2, l.endCount = s(a, t,
|
|
491
|
-
for (let c = 0; c <
|
|
492
|
-
return l.idRangeOffset = s(a, t,
|
|
495
|
+
const n = r(a, t += 2) >>> 1, l = { format: 4, searchRange: r(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
|
|
496
|
+
t += 2, l.entrySelector = r(a, t), t += 2, l.rangeShift = r(a, t), t += 2, l.endCount = s(a, t, n), t += 2 * n, t += 2, l.startCount = s(a, t, n), t += 2 * n;
|
|
497
|
+
for (let c = 0; c < n; c++) l.idDelta.push(e.readShort(a, t)), t += 2;
|
|
498
|
+
return l.idRangeOffset = s(a, t, n), t += 2 * n, l.glyphIdArray = s(a, t, i + o - t >> 1), l;
|
|
493
499
|
}, parse12(a, t) {
|
|
494
|
-
const e =
|
|
500
|
+
const e = _.readUint;
|
|
495
501
|
e(a, t += 4), e(a, t += 4);
|
|
496
502
|
const r = e(a, t += 4);
|
|
497
503
|
t += 4;
|
|
@@ -499,152 +505,140 @@ const y = { readShort: (a, t) => (y.t.uint16[0] = a[t] << 8 | a[t + 1], y.t.int1
|
|
|
499
505
|
for (let i = 0; i < 3 * r; i += 3) s[i] = e(a, t + (i << 2)), s[i + 1] = e(a, t + (i << 2) + 4), s[i + 2] = e(a, t + (i << 2) + 8);
|
|
500
506
|
return { format: 12, groups: s };
|
|
501
507
|
} }, at = { parseTab(a, t, e) {
|
|
502
|
-
const r =
|
|
508
|
+
const r = _;
|
|
503
509
|
t += 18;
|
|
504
510
|
const s = r.readUshort(a, t);
|
|
505
511
|
t += 2, t += 16;
|
|
506
512
|
const i = r.readShort(a, t);
|
|
507
513
|
t += 2;
|
|
508
|
-
const n = r.readShort(a, t);
|
|
509
|
-
t += 2;
|
|
510
514
|
const o = r.readShort(a, t);
|
|
511
515
|
t += 2;
|
|
516
|
+
const n = r.readShort(a, t);
|
|
517
|
+
t += 2;
|
|
512
518
|
const l = r.readShort(a, t);
|
|
513
|
-
return t += 2, t += 6, { unitsPerEm: s, xMin: i, yMin:
|
|
519
|
+
return t += 2, t += 6, { unitsPerEm: s, xMin: i, yMin: o, xMax: n, yMax: l, indexToLocFormat: r.readShort(a, t) };
|
|
514
520
|
} }, ht = { parseTab(a, t, e) {
|
|
515
|
-
const r =
|
|
521
|
+
const r = _;
|
|
516
522
|
t += 4;
|
|
517
523
|
const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], i = {};
|
|
518
|
-
for (let
|
|
519
|
-
const
|
|
520
|
-
i[
|
|
524
|
+
for (let o = 0; o < s.length; o++) {
|
|
525
|
+
const n = s[o], l = n === "advanceWidthMax" || n === "numberOfHMetrics" ? r.readUshort : r.readShort;
|
|
526
|
+
i[n] = l(a, t + 2 * o);
|
|
521
527
|
}
|
|
522
528
|
return i;
|
|
523
529
|
} }, lt = { parseTab(a, t, e, r) {
|
|
524
530
|
if (!r) throw Error("Font object required for hmtx parsing");
|
|
525
|
-
const s =
|
|
531
|
+
const s = _, i = [], o = [], n = r.maxp.numGlyphs, l = r.hhea.numberOfHMetrics;
|
|
526
532
|
let c = 0, u = 0, f = 0;
|
|
527
|
-
for (; f < l; ) c = s.readUshort(a, t + (f << 2)), u = s.readShort(a, t + (f << 2) + 2), i.push(c),
|
|
528
|
-
for (; f <
|
|
529
|
-
return { aWidth: i, lsBearing:
|
|
530
|
-
} },
|
|
531
|
-
const r =
|
|
533
|
+
for (; f < l; ) c = s.readUshort(a, t + (f << 2)), u = s.readShort(a, t + (f << 2) + 2), i.push(c), o.push(u), f++;
|
|
534
|
+
for (; f < n; ) i.push(c), o.push(u), f++;
|
|
535
|
+
return { aWidth: i, lsBearing: o };
|
|
536
|
+
} }, j = { cmap: nt, head: at, hhea: ht, maxp: { parseTab(a, t, e) {
|
|
537
|
+
const r = _;
|
|
532
538
|
return r.readUint(a, t), t += 4, { numGlyphs: r.readUshort(a, t) };
|
|
533
539
|
} }, hmtx: lt, loca: { parseTab(a, t, e, r) {
|
|
534
540
|
if (!r) throw Error("Font object required for loca parsing");
|
|
535
|
-
const s =
|
|
536
|
-
if (
|
|
537
|
-
else if (
|
|
541
|
+
const s = _, i = [], o = r.head.indexToLocFormat, n = r.maxp.numGlyphs + 1;
|
|
542
|
+
if (o === 0) for (let l = 0; l < n; l++) i.push(s.readUshort(a, t + (l << 1)) << 1);
|
|
543
|
+
else if (o === 1) for (let l = 0; l < n; l++) i.push(s.readUint(a, t + (l << 2)));
|
|
538
544
|
return i;
|
|
539
545
|
} }, glyf: { parseTab(a, t, e, r) {
|
|
540
546
|
if (!r) throw Error("Font object required for glyf parsing");
|
|
541
547
|
const s = [], i = r.maxp.numGlyphs;
|
|
542
|
-
for (let
|
|
548
|
+
for (let o = 0; o < i; o++) s.push(null);
|
|
543
549
|
return s;
|
|
544
|
-
},
|
|
545
|
-
const e =
|
|
550
|
+
}, Wt(a, t) {
|
|
551
|
+
const e = _, r = a.Nt, s = a.loca;
|
|
546
552
|
if (s[t] === s[t + 1]) return null;
|
|
547
|
-
const i =
|
|
553
|
+
const i = y.findTable(r, "glyf", a.Xt);
|
|
548
554
|
if (!i) return null;
|
|
549
|
-
let
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
552
|
-
if (
|
|
553
|
-
|
|
554
|
-
for (let d = 0; d <
|
|
555
|
-
const l = e.readUshort(r,
|
|
556
|
-
if (
|
|
557
|
-
|
|
558
|
-
const c =
|
|
559
|
-
|
|
555
|
+
let o = i[0] + s[t];
|
|
556
|
+
const n = {};
|
|
557
|
+
if (n.noc = e.readShort(r, o), o += 2, n.xMin = e.readShort(r, o), o += 2, n.yMin = e.readShort(r, o), o += 2, n.xMax = e.readShort(r, o), o += 2, n.yMax = e.readShort(r, o), o += 2, n.xMin >= n.xMax || n.yMin >= n.yMax) return null;
|
|
558
|
+
if (n.noc > 0) {
|
|
559
|
+
n.endPts = [];
|
|
560
|
+
for (let d = 0; d < n.noc; d++) n.endPts.push(e.readUshort(r, o)), o += 2;
|
|
561
|
+
const l = e.readUshort(r, o);
|
|
562
|
+
if (o += 2, r.length - o < l) return null;
|
|
563
|
+
o += l;
|
|
564
|
+
const c = n.endPts[n.noc - 1] + 1;
|
|
565
|
+
n.flags = [];
|
|
560
566
|
for (let d = 0; d < c; d++) {
|
|
561
|
-
const
|
|
562
|
-
if (
|
|
563
|
-
const p = r[
|
|
564
|
-
|
|
565
|
-
for (let g = 0; g < p; g++)
|
|
567
|
+
const m = r[o];
|
|
568
|
+
if (o++, n.flags.push(m), 8 & m) {
|
|
569
|
+
const p = r[o];
|
|
570
|
+
o++;
|
|
571
|
+
for (let g = 0; g < p; g++) n.flags.push(m), d++;
|
|
566
572
|
}
|
|
567
573
|
}
|
|
568
|
-
|
|
574
|
+
n.xs = [];
|
|
569
575
|
for (let d = 0; d < c; d++) {
|
|
570
|
-
const
|
|
571
|
-
2 &
|
|
576
|
+
const m = n.flags[d], p = !!(16 & m);
|
|
577
|
+
2 & m ? (n.xs.push(p ? r[o] : -r[o]), o++) : p ? n.xs.push(0) : (n.xs.push(e.readShort(r, o)), o += 2);
|
|
572
578
|
}
|
|
573
|
-
|
|
579
|
+
n.ys = [];
|
|
574
580
|
for (let d = 0; d < c; d++) {
|
|
575
|
-
const
|
|
576
|
-
4 &
|
|
581
|
+
const m = n.flags[d], p = !!(32 & m);
|
|
582
|
+
4 & m ? (n.ys.push(p ? r[o] : -r[o]), o++) : p ? n.ys.push(0) : (n.ys.push(e.readShort(r, o)), o += 2);
|
|
577
583
|
}
|
|
578
584
|
let u = 0, f = 0;
|
|
579
|
-
for (let d = 0; d < c; d++) u +=
|
|
580
|
-
} else
|
|
581
|
-
return
|
|
582
|
-
} } },
|
|
583
|
-
const i =
|
|
584
|
-
for (const
|
|
585
|
-
const l =
|
|
585
|
+
for (let d = 0; d < c; d++) u += n.xs[d], f += n.ys[d], n.xs[d] = u, n.ys[d] = f;
|
|
586
|
+
} else n.parts = [], n.endPts = [], n.flags = [], n.xs = [], n.ys = [];
|
|
587
|
+
return n;
|
|
588
|
+
} } }, y = { parse: (a) => [((t, e, r, s) => {
|
|
589
|
+
const i = j, o = { Nt: t, qt: e, Xt: r };
|
|
590
|
+
for (const n in i) {
|
|
591
|
+
const l = n, c = y.findTable(t, l, r);
|
|
586
592
|
if (c) {
|
|
587
593
|
const [u, f] = c;
|
|
588
594
|
let d = s[u];
|
|
589
|
-
d == null && (d = i[l].parseTab(t, u, f,
|
|
595
|
+
d == null && (d = i[l].parseTab(t, u, f, o), s[u] = d), o[l] = d;
|
|
590
596
|
}
|
|
591
597
|
}
|
|
592
|
-
return
|
|
598
|
+
return o;
|
|
593
599
|
})(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
|
|
594
|
-
const r =
|
|
600
|
+
const r = _, s = r.readUshort(a, e + 4);
|
|
595
601
|
let i = e + 12;
|
|
596
|
-
for (let
|
|
597
|
-
const
|
|
602
|
+
for (let o = 0; o < s; o++) {
|
|
603
|
+
const n = r.readASCII(a, i, 4);
|
|
598
604
|
r.readUint(a, i + 4);
|
|
599
605
|
const l = r.readUint(a, i + 8), c = r.readUint(a, i + 12);
|
|
600
|
-
if (
|
|
606
|
+
if (n === t) return [l, c];
|
|
601
607
|
i += 16;
|
|
602
608
|
}
|
|
603
609
|
return null;
|
|
604
|
-
}, T:
|
|
605
|
-
class
|
|
610
|
+
}, T: j, B: _ };
|
|
611
|
+
class k {
|
|
606
612
|
constructor() {
|
|
607
|
-
h(this, "qt", /* @__PURE__ */ new Map());
|
|
608
613
|
h(this, "Yt", /* @__PURE__ */ new Map());
|
|
614
|
+
h(this, "Qt", /* @__PURE__ */ new Map());
|
|
609
615
|
}
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
if (this.Yt.has(
|
|
613
|
-
const
|
|
614
|
-
if (!
|
|
615
|
-
const s = ["p3e1", "p3e10", "p0e3", "p0e4"];
|
|
616
|
-
for (const n of s) if (r.ids[n] !== void 0) {
|
|
617
|
-
const o = r.tables[r.ids[n]];
|
|
618
|
-
return this.Yt.set(e, o), o;
|
|
619
|
-
}
|
|
620
|
-
const i = r.tables[0] || null;
|
|
621
|
-
return this.Yt.set(e, i), i;
|
|
622
|
-
}
|
|
623
|
-
Jt(t, e) {
|
|
624
|
-
const r = `${this.Zt(t)}_${e}`;
|
|
625
|
-
if (this.qt.has(r)) return this.qt.get(r);
|
|
626
|
-
const s = this.Qt(t);
|
|
627
|
-
if (!s) return this.qt.set(r, 0), 0;
|
|
616
|
+
Zt(t, e) {
|
|
617
|
+
const r = `${this.Jt(t)}_${e}`;
|
|
618
|
+
if (this.Yt.has(r)) return this.Yt.get(r);
|
|
619
|
+
const s = t.cmap;
|
|
620
|
+
if (!s || !s.tables) return this.Yt.set(r, 0), 0;
|
|
628
621
|
let i = 0;
|
|
629
|
-
|
|
622
|
+
for (const o of s.tables) if (o.format === 4 ? i = this.Kt(e, o) : o.format === 12 && (i = this.te(e, o)), i > 0) break;
|
|
623
|
+
return this.Yt.set(r, i), i;
|
|
630
624
|
}
|
|
631
625
|
ee(t, e) {
|
|
632
626
|
const r = e.codePointAt(0);
|
|
633
|
-
return r === void 0 ? 0 : this.
|
|
627
|
+
return r === void 0 ? 0 : this.Zt(t, r);
|
|
634
628
|
}
|
|
635
629
|
re(t, e) {
|
|
636
630
|
const r = t.hmtx;
|
|
637
631
|
return r && r.aWidth && r.aWidth.length !== 0 ? e < r.aWidth.length ? r.aWidth[e] : r.aWidth[r.aWidth.length - 1] : 0;
|
|
638
632
|
}
|
|
639
633
|
se(t, e) {
|
|
640
|
-
const r = e / t.head.unitsPerEm, s = t.hhea.ascender * r, i = t.hhea.descender * r,
|
|
641
|
-
return { ascender: s, descender: i, lineGap:
|
|
634
|
+
const r = e / t.head.unitsPerEm, s = t.hhea.ascender * r, i = t.hhea.descender * r, o = t.hhea.lineGap * r;
|
|
635
|
+
return { ascender: s, descender: i, lineGap: o, lineHeight: s - i + o, unitsPerEm: t.head.unitsPerEm, scale: r };
|
|
642
636
|
}
|
|
643
637
|
ie() {
|
|
644
|
-
this.
|
|
638
|
+
this.Yt.clear(), this.Qt.clear();
|
|
645
639
|
}
|
|
646
|
-
|
|
647
|
-
return `${t.
|
|
640
|
+
Jt(t) {
|
|
641
|
+
return `${t.Xt}_${t.Nt.length}`;
|
|
648
642
|
}
|
|
649
643
|
Kt(t, e) {
|
|
650
644
|
const r = e.endCount.length;
|
|
@@ -658,8 +652,8 @@ class G {
|
|
|
658
652
|
{
|
|
659
653
|
const i = e.idRangeOffset[s] / 2 + (t - e.startCount[s]) - (r - s);
|
|
660
654
|
if (i >= 0 && i < e.glyphIdArray.length) {
|
|
661
|
-
const
|
|
662
|
-
return
|
|
655
|
+
const o = e.glyphIdArray[i];
|
|
656
|
+
return o === 0 ? 0 : o + e.idDelta[s] & 65535;
|
|
663
657
|
}
|
|
664
658
|
}
|
|
665
659
|
return 0;
|
|
@@ -667,18 +661,18 @@ class G {
|
|
|
667
661
|
te(t, e) {
|
|
668
662
|
const r = e.groups.length / 3;
|
|
669
663
|
for (let s = 0; s < r; s++) {
|
|
670
|
-
const i = e.groups[3 * s],
|
|
671
|
-
if (t >= i && t <=
|
|
664
|
+
const i = e.groups[3 * s], o = e.groups[3 * s + 1], n = e.groups[3 * s + 2];
|
|
665
|
+
if (t >= i && t <= o) return n + (t - i);
|
|
672
666
|
}
|
|
673
667
|
return 0;
|
|
674
668
|
}
|
|
675
669
|
}
|
|
676
670
|
class ct {
|
|
677
671
|
constructor(t) {
|
|
678
|
-
h(this, "
|
|
679
|
-
this.
|
|
672
|
+
h(this, "oe");
|
|
673
|
+
this.oe = t;
|
|
680
674
|
}
|
|
681
|
-
|
|
675
|
+
ne(t) {
|
|
682
676
|
var r;
|
|
683
677
|
const e = [];
|
|
684
678
|
return (r = t == null ? void 0 : t.cmap) != null && r.tables ? (t.cmap.tables.forEach((s) => {
|
|
@@ -692,7 +686,7 @@ class ct {
|
|
|
692
686
|
}), [...new Set(e)]) : [];
|
|
693
687
|
}
|
|
694
688
|
le(t, e) {
|
|
695
|
-
return this.
|
|
689
|
+
return this.oe.ee(t, e) > 0;
|
|
696
690
|
}
|
|
697
691
|
ce(t, e) {
|
|
698
692
|
for (const r of e) if (!this.le(t, r)) return !1;
|
|
@@ -710,10 +704,10 @@ class ct {
|
|
|
710
704
|
for (let r = 0; r < t.startCount.length; r++) {
|
|
711
705
|
const s = t.startCount[r], i = t.endCount[r];
|
|
712
706
|
if (s !== 65535 || i !== 65535) {
|
|
713
|
-
for (let
|
|
714
|
-
if (this.
|
|
715
|
-
const
|
|
716
|
-
e.push(
|
|
707
|
+
for (let o = s; o <= i; o++)
|
|
708
|
+
if (this.pe(t, o, r) > 0) try {
|
|
709
|
+
const n = String.fromCodePoint(o);
|
|
710
|
+
e.push(n);
|
|
717
711
|
} catch {
|
|
718
712
|
}
|
|
719
713
|
}
|
|
@@ -724,17 +718,17 @@ class ct {
|
|
|
724
718
|
const e = [];
|
|
725
719
|
if (!t.groups) return e;
|
|
726
720
|
for (let r = 0; r < t.groups.length; r += 3) {
|
|
727
|
-
const s = t.groups[r], i = t.groups[r + 1],
|
|
728
|
-
for (let
|
|
729
|
-
if (
|
|
730
|
-
const l = String.fromCodePoint(
|
|
721
|
+
const s = t.groups[r], i = t.groups[r + 1], o = t.groups[r + 2];
|
|
722
|
+
for (let n = s; n <= i; n++)
|
|
723
|
+
if (o + (n - s) > 0) try {
|
|
724
|
+
const l = String.fromCodePoint(n);
|
|
731
725
|
e.push(l);
|
|
732
726
|
} catch {
|
|
733
727
|
}
|
|
734
728
|
}
|
|
735
729
|
return e;
|
|
736
730
|
}
|
|
737
|
-
|
|
731
|
+
pe(t, e, r) {
|
|
738
732
|
if (t.idRangeOffset[r] === 0) return e + t.idDelta[r] & 65535;
|
|
739
733
|
{
|
|
740
734
|
const s = t.idRangeOffset[r] / 2 + (e - t.startCount[r]) - (t.startCount.length - r);
|
|
@@ -752,21 +746,21 @@ class ct {
|
|
|
752
746
|
}
|
|
753
747
|
class ut {
|
|
754
748
|
constructor() {
|
|
755
|
-
h(this, "
|
|
756
|
-
const t = new
|
|
757
|
-
this.
|
|
749
|
+
h(this, "me");
|
|
750
|
+
const t = new k();
|
|
751
|
+
this.me = new ct(t);
|
|
758
752
|
}
|
|
759
753
|
extractCharacters(t) {
|
|
760
|
-
return this.
|
|
754
|
+
return this.me.ne(t);
|
|
761
755
|
}
|
|
762
756
|
filterProblematicCharacters(t) {
|
|
763
|
-
return this.
|
|
757
|
+
return this.me.fe(t);
|
|
764
758
|
}
|
|
765
759
|
characterExists(t, e) {
|
|
766
|
-
return this.
|
|
760
|
+
return this.me.le(t, e);
|
|
767
761
|
}
|
|
768
762
|
allCharactersExist(t, e) {
|
|
769
|
-
return this.
|
|
763
|
+
return this.me.ce(t, e);
|
|
770
764
|
}
|
|
771
765
|
}
|
|
772
766
|
class dt {
|
|
@@ -775,32 +769,32 @@ class dt {
|
|
|
775
769
|
h(this, "_e");
|
|
776
770
|
h(this, "ve");
|
|
777
771
|
h(this, "xe");
|
|
778
|
-
this.ve = t, this.xe = new
|
|
772
|
+
this.ve = t, this.xe = new k(), this.ge = document.createElement("canvas"), this._e = this.ge.getContext("2d", { willReadFrequently: !0, alpha: !1 });
|
|
779
773
|
}
|
|
780
774
|
createTextureAtlas(t, e, r, s) {
|
|
781
|
-
const i = t.length,
|
|
782
|
-
this.be(l, c), this.we(t, e,
|
|
783
|
-
const f = this.ve.
|
|
784
|
-
return f.update(this.ge), { framebuffer: f, columns:
|
|
775
|
+
const i = t.length, o = Math.ceil(Math.sqrt(i)), n = Math.ceil(i / o), l = e.width * o, c = e.height * n, u = typeof s == "object" ? s : null;
|
|
776
|
+
this.be(l, c), this.we(t, e, o, r, u);
|
|
777
|
+
const f = this.ve.Lt(l, c, { filter: "nearest" });
|
|
778
|
+
return f.update(this.ge), { framebuffer: f, columns: o, rows: n };
|
|
785
779
|
}
|
|
786
780
|
be(t, e) {
|
|
787
781
|
this.ge.width = t, this.ge.height = e, this.ge.style.width = t + "px", this.ge.style.height = t + "px", this._e.imageSmoothingEnabled = !1, this.ge.style.imageRendering = "pixelated", this._e.fillStyle = "black", this._e.fillRect(0, 0, t, e), this._e.textBaseline = "top", this._e.textAlign = "left", this._e.fillStyle = "white";
|
|
788
782
|
}
|
|
789
783
|
we(t, e, r, s, i) {
|
|
790
|
-
const
|
|
791
|
-
for (let
|
|
792
|
-
const l =
|
|
784
|
+
const o = s / i.head.unitsPerEm;
|
|
785
|
+
for (let n = 0; n < t.length; n++) {
|
|
786
|
+
const l = n % r, c = Math.floor(n / r), u = t[n].character, f = this.Ce(i, u);
|
|
793
787
|
if (!f) continue;
|
|
794
|
-
const d = u.codePointAt(0) || 0,
|
|
795
|
-
this.$e(f,
|
|
788
|
+
const d = u.codePointAt(0) || 0, m = this.xe.Zt(i, d), p = this.ye(i, m) * o, g = l * e.width, C = c * e.height, v = g + 0.5 * e.width, b = C + 0.5 * e.height, T = Math.round(v - 0.5 * e.width), E = Math.round(b - 0.5 * s), M = T + 0.5 * (e.width - p), F = E + i.hhea.ascender * o;
|
|
789
|
+
this.$e(f, M, F, o);
|
|
796
790
|
}
|
|
797
791
|
}
|
|
798
792
|
Ce(t, e) {
|
|
799
|
-
const r = e.codePointAt(0) || 0, s = this.xe.
|
|
793
|
+
const r = e.codePointAt(0) || 0, s = this.xe.Zt(t, r);
|
|
800
794
|
if (s === 0) return null;
|
|
801
795
|
if (t.glyf && t.glyf[s] !== null) return t.glyf[s];
|
|
802
|
-
if (
|
|
803
|
-
const i =
|
|
796
|
+
if (y && y.T && y.T.glyf && y.T.glyf.Wt) {
|
|
797
|
+
const i = y.T.glyf.Wt(t, s);
|
|
804
798
|
return t.glyf && i && (t.glyf[s] = i), i;
|
|
805
799
|
}
|
|
806
800
|
return null;
|
|
@@ -811,30 +805,30 @@ class dt {
|
|
|
811
805
|
}
|
|
812
806
|
$e(t, e, r, s) {
|
|
813
807
|
if (!t || !t.xs || t.noc === 0) return;
|
|
814
|
-
const { xs: i, ys:
|
|
815
|
-
if (!(i &&
|
|
808
|
+
const { xs: i, ys: o, endPts: n, flags: l } = t;
|
|
809
|
+
if (!(i && o && n && l)) return;
|
|
816
810
|
this._e.beginPath();
|
|
817
811
|
let c = 0;
|
|
818
|
-
for (let u = 0; u <
|
|
819
|
-
const f =
|
|
812
|
+
for (let u = 0; u < n.length; u++) {
|
|
813
|
+
const f = n[u];
|
|
820
814
|
if (!(f < c)) {
|
|
821
815
|
if (f >= c) {
|
|
822
|
-
const d = e + i[c] * s,
|
|
823
|
-
this._e.moveTo(d,
|
|
816
|
+
const d = e + i[c] * s, m = r - o[c] * s;
|
|
817
|
+
this._e.moveTo(d, m);
|
|
824
818
|
let p = c + 1;
|
|
825
819
|
for (; p <= f; )
|
|
826
820
|
if (1 & l[p]) {
|
|
827
|
-
const g = e + i[p] * s, C = r -
|
|
821
|
+
const g = e + i[p] * s, C = r - o[p] * s;
|
|
828
822
|
this._e.lineTo(g, C), p++;
|
|
829
823
|
} else {
|
|
830
|
-
const g = e + i[p] * s, C = r -
|
|
831
|
-
let
|
|
832
|
-
if (1 & l[
|
|
833
|
-
const b = e + i[
|
|
834
|
-
this._e.quadraticCurveTo(g, C, b, T), p =
|
|
824
|
+
const g = e + i[p] * s, C = r - o[p] * s;
|
|
825
|
+
let v = p + 1 > f ? c : p + 1;
|
|
826
|
+
if (1 & l[v]) {
|
|
827
|
+
const b = e + i[v] * s, T = r - o[v] * s;
|
|
828
|
+
this._e.quadraticCurveTo(g, C, b, T), p = v + 1;
|
|
835
829
|
} else {
|
|
836
|
-
const b = (g + (e + i[
|
|
837
|
-
this._e.quadraticCurveTo(g, C, b, T), p =
|
|
830
|
+
const b = (g + (e + i[v] * s)) / 2, T = (C + (r - o[v] * s)) / 2;
|
|
831
|
+
this._e.quadraticCurveTo(g, C, b, T), p = v;
|
|
838
832
|
}
|
|
839
833
|
}
|
|
840
834
|
this._e.closePath();
|
|
@@ -847,57 +841,57 @@ class dt {
|
|
|
847
841
|
}
|
|
848
842
|
class ft {
|
|
849
843
|
constructor() {
|
|
850
|
-
h(this, "
|
|
851
|
-
this.
|
|
844
|
+
h(this, "oe");
|
|
845
|
+
this.oe = new k();
|
|
852
846
|
}
|
|
853
847
|
calculateMaxGlyphDimensions(t, e, r) {
|
|
854
848
|
let s = 0;
|
|
855
|
-
const i = this.
|
|
856
|
-
for (const
|
|
857
|
-
const l = this.
|
|
849
|
+
const i = this.oe.se(r, e), o = i.lineHeight;
|
|
850
|
+
for (const n of t) {
|
|
851
|
+
const l = this.oe.ee(r, n);
|
|
858
852
|
if (l === 0) continue;
|
|
859
|
-
const c = this.
|
|
853
|
+
const c = this.oe.re(r, l) * i.scale;
|
|
860
854
|
s = Math.max(s, c);
|
|
861
855
|
}
|
|
862
|
-
return { width: Math.ceil(s), height: Math.ceil(
|
|
856
|
+
return { width: Math.ceil(s), height: Math.ceil(o) };
|
|
863
857
|
}
|
|
864
858
|
getCharacterAdvanceWidth(t, e, r) {
|
|
865
|
-
const s = this.
|
|
866
|
-
return this.
|
|
859
|
+
const s = this.oe.se(r, e), i = this.oe.ee(r, t);
|
|
860
|
+
return this.oe.re(r, i) * s.scale;
|
|
867
861
|
}
|
|
868
862
|
getFontMetrics(t, e) {
|
|
869
|
-
return this.
|
|
863
|
+
return this.oe.se(e, t);
|
|
870
864
|
}
|
|
871
865
|
ie() {
|
|
872
|
-
this.
|
|
866
|
+
this.oe.ie();
|
|
873
867
|
}
|
|
874
868
|
}
|
|
875
869
|
class gt {
|
|
876
870
|
constructor() {
|
|
877
871
|
h(this, "xe");
|
|
878
|
-
this.xe = new
|
|
872
|
+
this.xe = new k();
|
|
879
873
|
}
|
|
880
874
|
createCharacterObjects(t, e) {
|
|
881
875
|
return t.map((r, s) => {
|
|
882
|
-
const i = r.codePointAt(0) || 0,
|
|
883
|
-
let
|
|
876
|
+
const i = r.codePointAt(0) || 0, o = this.Fe(s);
|
|
877
|
+
let n = 0;
|
|
884
878
|
if (e.hmtx && e.hmtx.aWidth) {
|
|
885
|
-
const l = this.xe.
|
|
886
|
-
l > 0 && e.hmtx.aWidth[l] !== void 0 && (
|
|
879
|
+
const l = this.xe.Zt(e, i);
|
|
880
|
+
l > 0 && e.hmtx.aWidth[l] !== void 0 && (n = e.hmtx.aWidth[l]);
|
|
887
881
|
}
|
|
888
|
-
return { character: r, unicode: i, color:
|
|
882
|
+
return { character: r, unicode: i, color: o, advanceWidth: n };
|
|
889
883
|
});
|
|
890
884
|
}
|
|
891
885
|
Fe(t) {
|
|
892
886
|
return [t % 256, Math.floor(t / 256) % 256, Math.floor(t / 65536) % 256];
|
|
893
887
|
}
|
|
894
888
|
getCharacterColor(t, e) {
|
|
895
|
-
if (!x.
|
|
889
|
+
if (!x.m(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
|
|
896
890
|
const r = e.find((s) => s.character === t);
|
|
897
891
|
return r ? r.color : [0, 0, 0];
|
|
898
892
|
}
|
|
899
893
|
getCharacterColors(t, e) {
|
|
900
|
-
return x.
|
|
894
|
+
return x.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((r) => this.getCharacterColor(r, e) || [0, 0, 0]) : [[0, 0, 0]];
|
|
901
895
|
}
|
|
902
896
|
}
|
|
903
897
|
class pt {
|
|
@@ -910,12 +904,12 @@ class pt {
|
|
|
910
904
|
h(this, "Ve", 0);
|
|
911
905
|
h(this, "ke", { width: 0, height: 0 });
|
|
912
906
|
h(this, "Ie");
|
|
913
|
-
h(this, "
|
|
907
|
+
h(this, "Pe", "UrsaFont");
|
|
908
|
+
h(this, "ze");
|
|
914
909
|
h(this, "Ee");
|
|
915
910
|
h(this, "Ge");
|
|
916
|
-
h(this, "Pe");
|
|
917
911
|
h(this, "Ae");
|
|
918
|
-
this.Se = e, this.
|
|
912
|
+
this.Se = e, this.ze = new ut(), this.Ee = new dt(t), this.Ge = new ft(), this.Ae = new gt();
|
|
919
913
|
}
|
|
920
914
|
async Ue(t) {
|
|
921
915
|
let e;
|
|
@@ -925,21 +919,21 @@ class pt {
|
|
|
925
919
|
if (!r.ok) throw new w(`Failed to load font file: ${r.status} ${r.statusText}`);
|
|
926
920
|
e = await r.arrayBuffer();
|
|
927
921
|
}
|
|
928
|
-
await this.Le(e), this.Te =
|
|
922
|
+
await this.Le(e), this.Te = y.parse(e)[0], await this.He();
|
|
929
923
|
}
|
|
930
924
|
je(t) {
|
|
931
925
|
if (t === void 0) return this.Se;
|
|
932
|
-
this.Se = t, this.ke = this.
|
|
933
|
-
const e = this.
|
|
926
|
+
this.Se = t, this.ke = this.Ge.calculateMaxGlyphDimensions(this.Me.map((r) => r.character), this.Se, this.Te);
|
|
927
|
+
const e = this.Ee.createTextureAtlas(this.Me, this.ke, this.Se, this.Te);
|
|
934
928
|
this.De = e.framebuffer, this.Re = e.columns, this.Ve = e.rows;
|
|
935
929
|
}
|
|
936
|
-
async
|
|
930
|
+
async Oe(t) {
|
|
937
931
|
try {
|
|
938
932
|
const e = await fetch(t);
|
|
939
933
|
if (!e.ok) throw new w(`Failed to load font file: ${e.status} ${e.statusText}`);
|
|
940
934
|
const r = await e.arrayBuffer();
|
|
941
935
|
await this.Le(r);
|
|
942
|
-
const s =
|
|
936
|
+
const s = y.parse(r);
|
|
943
937
|
if (!s || s.length === 0) throw Error("Failed to parse font file");
|
|
944
938
|
this.Te = s[0], await this.He();
|
|
945
939
|
} catch (e) {
|
|
@@ -948,12 +942,12 @@ class pt {
|
|
|
948
942
|
}
|
|
949
943
|
async Le(t) {
|
|
950
944
|
const e = Date.now();
|
|
951
|
-
this.
|
|
945
|
+
this.Pe = this.Pe === "UrsaFont" ? "UrsaFont" : "CustomFont_" + e, this.Ie = new FontFace(this.Pe, t), await this.Ie.load(), document.fonts.add(this.Ie);
|
|
952
946
|
}
|
|
953
947
|
async He() {
|
|
954
|
-
const t = this.
|
|
955
|
-
this.Me = this.Ae.createCharacterObjects(e, this.Te), this.ke = this.
|
|
956
|
-
const r = this.
|
|
948
|
+
const t = this.ze.extractCharacters(this.Te), e = this.ze.filterProblematicCharacters(t);
|
|
949
|
+
this.Me = this.Ae.createCharacterObjects(e, this.Te), this.ke = this.Ge.calculateMaxGlyphDimensions(e, this.Se, this.Te);
|
|
950
|
+
const r = this.Ee.createTextureAtlas(this.Me, this.ke, this.Se, this.Te);
|
|
957
951
|
this.De = r.framebuffer, this.Re = r.columns, this.Ve = r.rows;
|
|
958
952
|
}
|
|
959
953
|
getCharacterColor(t) {
|
|
@@ -968,8 +962,8 @@ class pt {
|
|
|
968
962
|
for (const r of t) if (!e.has(r)) return !1;
|
|
969
963
|
return !0;
|
|
970
964
|
}
|
|
971
|
-
|
|
972
|
-
this.De.
|
|
965
|
+
P() {
|
|
966
|
+
this.De.P(), document.fonts.delete(this.Ie);
|
|
973
967
|
}
|
|
974
968
|
get fontFramebuffer() {
|
|
975
969
|
return this.De;
|
|
@@ -993,9 +987,9 @@ class pt {
|
|
|
993
987
|
return this.Te;
|
|
994
988
|
}
|
|
995
989
|
}
|
|
996
|
-
class
|
|
990
|
+
class mt {
|
|
997
991
|
constructor(t, e, r) {
|
|
998
|
-
h(this, "
|
|
992
|
+
h(this, "Be");
|
|
999
993
|
h(this, "We");
|
|
1000
994
|
h(this, "F");
|
|
1001
995
|
h(this, "M");
|
|
@@ -1008,16 +1002,16 @@ class vt {
|
|
|
1008
1002
|
this.Ye = t, this.Qe = e, this.Ze = r, this.kt();
|
|
1009
1003
|
}
|
|
1010
1004
|
kt() {
|
|
1011
|
-
this.qe || (this.
|
|
1005
|
+
this.qe || (this.Be = Math.floor(this.Ye.width / this.Qe), this.We = Math.floor(this.Ye.height / this.Ze)), this.Je();
|
|
1012
1006
|
}
|
|
1013
1007
|
Je() {
|
|
1014
|
-
this.F = this.
|
|
1008
|
+
this.F = this.Be * this.Qe, this.M = this.We * this.Ze, this.Ne = Math.floor((this.Ye.width - this.F) / 2), this.Xe = Math.floor((this.Ye.height - this.M) / 2);
|
|
1015
1009
|
}
|
|
1016
1010
|
Ke(t, e) {
|
|
1017
1011
|
this.Qe = t, this.Ze = e, this.kt();
|
|
1018
1012
|
}
|
|
1019
1013
|
tr(t, e) {
|
|
1020
|
-
this.qe = !0, this.
|
|
1014
|
+
this.qe = !0, this.Be = t, this.We = e, this.Je();
|
|
1021
1015
|
}
|
|
1022
1016
|
er() {
|
|
1023
1017
|
this.qe = !1, this.kt();
|
|
@@ -1036,7 +1030,7 @@ class vt {
|
|
|
1036
1030
|
return this.Ze;
|
|
1037
1031
|
}
|
|
1038
1032
|
get cols() {
|
|
1039
|
-
return this.
|
|
1033
|
+
return this.Be;
|
|
1040
1034
|
}
|
|
1041
1035
|
get rows() {
|
|
1042
1036
|
return this.We;
|
|
@@ -1054,7 +1048,7 @@ class vt {
|
|
|
1054
1048
|
return this.Xe;
|
|
1055
1049
|
}
|
|
1056
1050
|
}
|
|
1057
|
-
class
|
|
1051
|
+
class vt {
|
|
1058
1052
|
constructor(t, e = !1, r = {}) {
|
|
1059
1053
|
h(this, "Ye");
|
|
1060
1054
|
h(this, "ir");
|
|
@@ -1069,12 +1063,12 @@ class mt {
|
|
|
1069
1063
|
if (r.className = "textmodeCanvas", r.style.imageRendering = "pixelated", this.nr) r.width = t || 800, r.height = e || 600, document.body.appendChild(r);
|
|
1070
1064
|
else {
|
|
1071
1065
|
const i = this.ir.getBoundingClientRect();
|
|
1072
|
-
let
|
|
1066
|
+
let o = Math.round(i.width), n = Math.round(i.height);
|
|
1073
1067
|
if (this.ir instanceof HTMLVideoElement) {
|
|
1074
1068
|
const u = this.ir;
|
|
1075
|
-
(
|
|
1069
|
+
(o === 0 || n === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (o = u.videoWidth, n = u.videoHeight);
|
|
1076
1070
|
}
|
|
1077
|
-
r.width =
|
|
1071
|
+
r.width = o, r.height = n, r.style.position = "absolute", r.style.pointerEvents = "none";
|
|
1078
1072
|
const l = window.getComputedStyle(this.ir);
|
|
1079
1073
|
let c = parseInt(l.zIndex || "0", 10);
|
|
1080
1074
|
isNaN(c) && (c = 0), r.style.zIndex = "" + (c + 1), this.lr(r), (s = this.ir.parentNode) == null || s.insertBefore(r, this.ir.nextSibling);
|
|
@@ -1095,8 +1089,8 @@ class mt {
|
|
|
1095
1089
|
const r = this.ir.getBoundingClientRect();
|
|
1096
1090
|
let s = Math.round(r.width), i = Math.round(r.height);
|
|
1097
1091
|
if (this.ir instanceof HTMLVideoElement) {
|
|
1098
|
-
const
|
|
1099
|
-
(s === 0 || i === 0) &&
|
|
1092
|
+
const o = this.ir;
|
|
1093
|
+
(s === 0 || i === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (s = o.videoWidth, i = o.videoHeight);
|
|
1100
1094
|
}
|
|
1101
1095
|
this.Ye.width = s, this.Ye.height = i, this.lr(this.Ye);
|
|
1102
1096
|
}
|
|
@@ -1114,7 +1108,7 @@ class mt {
|
|
|
1114
1108
|
}
|
|
1115
1109
|
}), this.ar.observe(this.Ye);
|
|
1116
1110
|
}
|
|
1117
|
-
|
|
1111
|
+
P() {
|
|
1118
1112
|
this.ar && this.ar.disconnect();
|
|
1119
1113
|
const t = this.Ye.getContext("webgl") || this.Ye.getContext("webgl2");
|
|
1120
1114
|
if (t) {
|
|
@@ -1138,22 +1132,22 @@ class D {
|
|
|
1138
1132
|
h(this, "ve");
|
|
1139
1133
|
h(this, "ur");
|
|
1140
1134
|
h(this, "dr");
|
|
1141
|
-
h(this, "mr");
|
|
1142
1135
|
h(this, "pr");
|
|
1136
|
+
h(this, "mr");
|
|
1143
1137
|
h(this, "gr");
|
|
1144
1138
|
h(this, "_r");
|
|
1145
1139
|
h(this, "vr");
|
|
1146
1140
|
h(this, "l");
|
|
1147
1141
|
this.ve = t, this.ur = e, this.dr = r, this.l = s;
|
|
1148
|
-
const i = this.dr.cols,
|
|
1149
|
-
this.
|
|
1142
|
+
const i = this.dr.cols, o = this.dr.rows;
|
|
1143
|
+
this.pr = this.ve.Lt(i, o), this.mr = this.ve.Lt(i, o), this.gr = this.ve.Lt(i, o), this._r = this.ve.Lt(i, o), this.vr = this.ve.Lt(i, o);
|
|
1150
1144
|
}
|
|
1151
1145
|
rr() {
|
|
1152
1146
|
const t = this.dr.cols, e = this.dr.rows;
|
|
1153
|
-
this.
|
|
1147
|
+
this.pr.resize(t, e), this.mr.resize(t, e), this.gr.resize(t, e), this._r.resize(t, e), this.vr.resize(t, e);
|
|
1154
1148
|
}
|
|
1155
1149
|
enabled(t) {
|
|
1156
|
-
x.
|
|
1150
|
+
x.m(typeof t == "boolean" || typeof t == "number" && Number.isInteger(t), "Enabled must be a boolean value or an integer (0 for false, any other number for true).", { method: "enabled", providedValue: t }) && (this.l.enabled = !!t);
|
|
1157
1151
|
}
|
|
1158
1152
|
enable() {
|
|
1159
1153
|
this.enabled(!0);
|
|
@@ -1161,14 +1155,14 @@ class D {
|
|
|
1161
1155
|
disable() {
|
|
1162
1156
|
this.enabled(!1);
|
|
1163
1157
|
}
|
|
1164
|
-
|
|
1165
|
-
this.
|
|
1158
|
+
P() {
|
|
1159
|
+
this.pr.P(), this.mr.P(), this.gr.P(), this._r.P(), this.vr.P();
|
|
1166
1160
|
}
|
|
1167
1161
|
get characterFramebuffer() {
|
|
1168
|
-
return this.
|
|
1162
|
+
return this.pr;
|
|
1169
1163
|
}
|
|
1170
1164
|
get primaryColorFramebuffer() {
|
|
1171
|
-
return this.
|
|
1165
|
+
return this.mr;
|
|
1172
1166
|
}
|
|
1173
1167
|
get secondaryColorFramebuffer() {
|
|
1174
1168
|
return this.gr;
|
|
@@ -1190,7 +1184,7 @@ class xt {
|
|
|
1190
1184
|
h(this, "br");
|
|
1191
1185
|
this.ve = t, this.br = e;
|
|
1192
1186
|
const r = Math.max(this.br.length, 1);
|
|
1193
|
-
this.C = this.ve.
|
|
1187
|
+
this.C = this.ve.Lt(r, 1), this.wr();
|
|
1194
1188
|
}
|
|
1195
1189
|
wr() {
|
|
1196
1190
|
const t = this.br.length;
|
|
@@ -1215,25 +1209,25 @@ class xt {
|
|
|
1215
1209
|
return this.C.texture;
|
|
1216
1210
|
}
|
|
1217
1211
|
}
|
|
1218
|
-
class
|
|
1212
|
+
class B extends D {
|
|
1219
1213
|
constructor(e, r, s, i = {}) {
|
|
1220
1214
|
super(e, r, s, i);
|
|
1221
1215
|
h(this, "Cr");
|
|
1222
1216
|
this.Cr = new xt(this.ve, this.ur.getCharacterColors(" .:-=+*%@#"));
|
|
1223
1217
|
}
|
|
1224
1218
|
characters(e) {
|
|
1225
|
-
x.
|
|
1219
|
+
x.m(this.ur.hasAllCharacters(e), "One or more characters do not exist in the current font.", { method: "characters", providedValue: e }) && (this.l.characters = e, this.Cr.setColors(this.ur.getCharacterColors(e)));
|
|
1226
1220
|
}
|
|
1227
1221
|
characterColor(e, r, s, i = 255) {
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1222
|
+
const o = this.yr(e, "characterColor", r, s, i);
|
|
1223
|
+
o && (this.l.characterColor = o);
|
|
1230
1224
|
}
|
|
1231
1225
|
characterColorMode(e) {
|
|
1232
1226
|
this.$r(e, "characterColorMode");
|
|
1233
1227
|
}
|
|
1234
1228
|
cellColor(e, r, s, i = 255) {
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1229
|
+
const o = this.yr(e, "cellColor", r, s, i);
|
|
1230
|
+
o && (this.l.cellColor = o);
|
|
1237
1231
|
}
|
|
1238
1232
|
cellColorMode(e) {
|
|
1239
1233
|
this.$r(e, "cellColorMode");
|
|
@@ -1242,7 +1236,7 @@ class Y extends D {
|
|
|
1242
1236
|
this.Fr(e, "invert", "Invert");
|
|
1243
1237
|
}
|
|
1244
1238
|
rotation(e) {
|
|
1245
|
-
if (!x.
|
|
1239
|
+
if (!x.m(typeof e == "number", "Rotation angle must be a number.", { method: "rotation", providedValue: e })) return;
|
|
1246
1240
|
(e %= 360) < 0 && (e += 360);
|
|
1247
1241
|
const r = 255 * e / 360, s = Math.floor(r) / 255, i = Math.round(r - s);
|
|
1248
1242
|
this.l.rotation = [s, i, 0, 1];
|
|
@@ -1253,26 +1247,26 @@ class Y extends D {
|
|
|
1253
1247
|
flipVertically(e) {
|
|
1254
1248
|
this.Fr(e, "flipVertically", "Flip vertically");
|
|
1255
1249
|
}
|
|
1256
|
-
yr(e, r, s, i,
|
|
1257
|
-
let
|
|
1250
|
+
yr(e, r, s, i, o = 255) {
|
|
1251
|
+
let n, l, c, u;
|
|
1258
1252
|
if (typeof e == "string") {
|
|
1259
1253
|
const f = this.Tr(e);
|
|
1260
|
-
if (!f) return x.
|
|
1261
|
-
[
|
|
1262
|
-
} else if (
|
|
1263
|
-
return [
|
|
1254
|
+
if (!f) return x.m(!1, "Invalid hex color format. Use '#FF0000', '#F00', 'FF0000', or 'F00'.", { method: r, providedValue: e }), null;
|
|
1255
|
+
[n, l, c, u] = f;
|
|
1256
|
+
} else if (n = e, l = s !== void 0 ? s : e, c = i !== void 0 ? i : e, u = o, !x.m([n, l, c, u].every((f) => f >= 0 && f <= 255), r.charAt(0).toUpperCase() + r.slice(1) + " color values must be between 0 and 255", { method: r, providedValues: { r: n, g: l, b: c, a: u } })) return null;
|
|
1257
|
+
return [n / 255, l / 255, c / 255, u / 255];
|
|
1264
1258
|
}
|
|
1265
1259
|
$r(e, r) {
|
|
1266
|
-
x.
|
|
1260
|
+
x.m(["sampled", "fixed"].includes(e), "Invalid color mode. Must be 'sampled' or 'fixed'.", { method: r, providedValue: e }) && (this.l[r] = e);
|
|
1267
1261
|
}
|
|
1268
1262
|
Fr(e, r, s) {
|
|
1269
|
-
x.
|
|
1263
|
+
x.m(typeof e == "boolean" || typeof e == "number" && Number.isInteger(e), s + " must be a boolean value or an integer (0 for false, any other number for true).", { method: r, providedValue: e }) && (this.l[r] = !!e);
|
|
1270
1264
|
}
|
|
1271
1265
|
Tr(e) {
|
|
1272
1266
|
return e = e.replace(/^#/, ""), /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(e) ? (e.length === 3 && (e = e.split("").map((r) => r + r).join("")), [parseInt(e.slice(0, 2), 16), parseInt(e.slice(2, 4), 16), parseInt(e.slice(4, 6), 16), 255]) : null;
|
|
1273
1267
|
}
|
|
1274
1268
|
}
|
|
1275
|
-
const
|
|
1269
|
+
const U = `attribute vec2 a_position;\r
|
|
1276
1270
|
attribute vec2 a_texCoord;\r
|
|
1277
1271
|
varying vec2 v_uv;\r
|
|
1278
1272
|
\r
|
|
@@ -1311,7 +1305,7 @@ void main() {\r
|
|
|
1311
1305
|
gl_Position = vec4(pos, 0.0, 1.0);\r
|
|
1312
1306
|
}\r
|
|
1313
1307
|
`, bt = { enabled: !0, characters: " .:-=+*%@#", characterColor: [1, 1, 1, 1], characterColorMode: "sampled", cellColor: [0, 0, 0, 1], cellColorMode: "fixed", invert: !1, rotation: [0, 0, 0, 255], flipHorizontally: !1, flipVertically: !1, brightnessRange: [0, 255] };
|
|
1314
|
-
class
|
|
1308
|
+
class Y extends B {
|
|
1315
1309
|
constructor(e, r, s) {
|
|
1316
1310
|
super(e, r, s, { ...bt });
|
|
1317
1311
|
h(this, "Mr");
|
|
@@ -1320,96 +1314,96 @@ class B extends Y {
|
|
|
1320
1314
|
h(this, "Rr");
|
|
1321
1315
|
h(this, "Vr");
|
|
1322
1316
|
h(this, "kr");
|
|
1323
|
-
this.Mr = new R(e.context,
|
|
1317
|
+
this.Mr = new R(e.context, U, "precision lowp float;uniform sampler2D u_sketchTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec2 cellCenter=(floor(v_uv*u_gridCellDimensions)+vec2(0.5))/u_gridCellDimensions;vec4 color=texture2D(u_sketchTexture,cellCenter);float brightness=dot(color.rgb,vec3(0.299,0.587,0.114));float brightnessValue=brightness*255.0;if(brightnessValue>=u_brightnessRange.x&&brightnessValue<=u_brightnessRange.y){gl_FragColor=color;}else{gl_FragColor=vec4(0.0);}}"), this.Dr = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_fillColor;uniform bool u_useFixedColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){if(u_useFixedColor){gl_FragColor=u_fillColor;}else{gl_FragColor=sampleColor;}}else{gl_FragColor=vec4(0.0);}}"), this.Rr = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform bool u_invert;uniform bool u_flipHorizontally;uniform bool u_flipVertically;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){float invertValue=u_invert ? 1.0 : 0.0;float flipHValue=u_flipHorizontally ? 1.0 : 0.0;float flipVValue=u_flipVertically ? 1.0 : 0.0;gl_FragColor=vec4(invertValue,flipHValue,flipVValue,1.0);}else{gl_FragColor=vec4(0.0);}}"), this.Vr = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_rotationColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){gl_FragColor=u_rotationColor;}else{gl_FragColor=vec4(0.0);}}"), this.Sr = new R(e.context, U, "precision lowp float;uniform sampler2D u_colorSampleFramebuffer;uniform sampler2D u_charPaletteTexture;uniform vec2 u_charPaletteSize;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec4 color=texture2D(u_colorSampleFramebuffer,v_uv);if(color.a==0.0){gl_FragColor=vec4(0.0);return;}float brightness=dot(color.rgb,vec3(0.299,0.587,0.114))*255.0;vec2 range=u_brightnessRange;if(brightness<range.x||brightness>range.y){gl_FragColor=vec4(0.0);return;}float t=(brightness-range.x)/(range.y-range.x);float idx=clamp(floor(t*u_charPaletteSize.x),0.0,u_charPaletteSize.x-1.0);vec3 charColor=texture2D(u_charPaletteTexture,vec2((idx+0.5)/u_charPaletteSize.x,0.0)).rgb;gl_FragColor=vec4(charColor,1.0);}"), this.kr = this.ve.Lt(this.dr.cols, this.dr.rows);
|
|
1324
1318
|
}
|
|
1325
1319
|
Ir(e) {
|
|
1326
1320
|
const r = this.dr.cols, s = this.dr.rows;
|
|
1327
|
-
this.kr.begin(), this.ve.
|
|
1321
|
+
this.kr.begin(), this.ve.jt(), this.ve.yt(this.Mr), this.ve.Et("u_sketchTexture", e), this.ve.Et("u_gridCellDimensions", [r, s]), this.ve.Et("u_brightnessRange", this.l.brightnessRange), this.ve.Gt(0, 0, r, s), this.kr.end(), this.mr.begin(), this.ve.jt(), this.ve.yt(this.Dr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_fillColor", this.l.characterColor), this.ve.Et("u_useFixedColor", this.l.characterColorMode === "fixed"), this.ve.Gt(0, 0, r, s), this.mr.end(), this.gr.begin(), this.ve.jt(), this.ve.yt(this.Dr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_fillColor", this.l.cellColor), this.ve.Et("u_useFixedColor", this.l.cellColorMode === "fixed"), this.ve.Gt(0, 0, r, s), this.gr.end(), this.vr.begin(), this.ve.jt(), this.ve.yt(this.Rr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_invert", this.l.invert), this.ve.Et("u_flipHorizontally", this.l.flipHorizontally), this.ve.Et("u_flipVertically", this.l.flipVertically), this.ve.Gt(0, 0, r, s), this.vr.end(), this._r.begin(), this.ve.jt(), this.ve.yt(this.Vr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_rotationColor", this.l.rotation), this.ve.Gt(0, 0, r, s), this._r.end(), this.pr.begin(), this.ve.jt(), this.ve.yt(this.Sr), this.ve.Et("u_colorSampleFramebuffer", this.kr), this.ve.Et("u_charPaletteTexture", this.Cr.texture), this.ve.Et("u_charPaletteSize", [this.Cr.colors.length, 1]), this.ve.Et("u_brightnessRange", this.l.brightnessRange), this.ve.Gt(0, 0, r, s), this.pr.end();
|
|
1328
1322
|
}
|
|
1329
1323
|
rr() {
|
|
1330
1324
|
super.rr(), this.kr.resize(this.dr.cols, this.dr.rows);
|
|
1331
1325
|
}
|
|
1332
1326
|
brightnessRange(e) {
|
|
1333
|
-
x.
|
|
1327
|
+
x.m(Array.isArray(e) && e.length === 2 && e.every((r) => typeof r == "number" && r >= 0 && r <= 255), "Brightness range must be an array of two numbers between 0 and 255.", { method: "brightnessRange", providedValue: e }) && (this.l.brightnessRange = e);
|
|
1334
1328
|
}
|
|
1335
1329
|
}
|
|
1336
|
-
const
|
|
1330
|
+
const Bt = Object.freeze(Object.defineProperty({ __proto__: null, TextmodeBrightnessConverter: Y, TextmodeConverter: D, TextmodeFeatureConverter: B }, Symbol.toStringTag, { value: "Module" }));
|
|
1337
1331
|
class wt {
|
|
1338
1332
|
constructor(t, e, r) {
|
|
1339
1333
|
h(this, "ve");
|
|
1340
1334
|
h(this, "Te");
|
|
1341
1335
|
h(this, "dr");
|
|
1336
|
+
h(this, "Pr");
|
|
1342
1337
|
h(this, "zr");
|
|
1343
1338
|
h(this, "Er");
|
|
1344
1339
|
h(this, "Gr");
|
|
1345
|
-
h(this, "Pr");
|
|
1346
1340
|
h(this, "Ar");
|
|
1347
|
-
h(this, "mr");
|
|
1348
1341
|
h(this, "pr");
|
|
1342
|
+
h(this, "mr");
|
|
1349
1343
|
h(this, "gr");
|
|
1350
1344
|
h(this, "_r");
|
|
1351
1345
|
h(this, "vr");
|
|
1352
|
-
this.ve = t, this.Te = e, this.dr = r, this.Ar = this.ve.
|
|
1346
|
+
this.ve = t, this.Te = e, this.dr = r, this.Ar = this.ve.Pt($, "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 sampler2D u_captureTexture;uniform vec2 u_captureDimensions;uniform int u_backgroundMode;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;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_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);if(encodedIndexVec.a<0.01){gl_FragColor=(u_backgroundMode==0)? vec4(0.0):texture2D(u_captureTexture,gl_FragCoord.xy/u_captureDimensions);return;}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.zr = new Y(t, e, r), this.Er = new D(t, e, r), this.Pr = [this.zr, this.Er], this.pr = this.ve.Lt(r.cols, r.rows), this.mr = this.ve.Lt(r.cols, r.rows), this.gr = this.ve.Lt(r.cols, r.rows), this._r = this.ve.Lt(r.cols, r.rows), this.vr = this.ve.Lt(r.cols, r.rows), this.Gr = this.ve.Lt(this.dr.width, this.dr.height);
|
|
1353
1347
|
}
|
|
1354
1348
|
Ur(t) {
|
|
1355
|
-
for (const r of this.
|
|
1349
|
+
for (const r of this.Pr) r.options.enabled && r instanceof B && r.Ir(t);
|
|
1356
1350
|
const e = (r, s) => {
|
|
1357
|
-
r.begin(), this.ve.
|
|
1358
|
-
for (const i of this.
|
|
1351
|
+
r.begin(), this.ve.jt();
|
|
1352
|
+
for (const i of this.Pr) i.options.enabled && this.ve.Bt(s(i), 0, 0);
|
|
1359
1353
|
r.end();
|
|
1360
1354
|
};
|
|
1361
|
-
e(this.
|
|
1355
|
+
e(this.pr, (r) => r.characterFramebuffer), e(this.mr, (r) => r.primaryColorFramebuffer), e(this.gr, (r) => r.secondaryColorFramebuffer), e(this._r, (r) => r.rotationFramebuffer), e(this.vr, (r) => r.transformFramebuffer), this.Gr.begin(), this.ve.jt(), this.ve.yt(this.Ar), this.ve.Et("u_characterTexture", this.Te.fontFramebuffer), this.ve.Et("u_charsetDimensions", [this.Te.textureColumns, this.Te.textureRows]), this.ve.Et("u_asciiCharacterTexture", this.pr.texture), this.ve.Et("u_primaryColorTexture", this.mr.texture), this.ve.Et("u_secondaryColorTexture", this.gr.texture), this.ve.Et("u_transformTexture", this.vr.texture), this.ve.Et("u_rotationTexture", this._r.texture), this.ve.Et("u_captureTexture", t.texture), this.ve.Et("u_backgroundMode", !1), this.ve.Et("u_captureDimensions", [t.width, t.height]), this.ve.Et("u_gridCellDimensions", [this.dr.cols, this.dr.rows]), this.ve.Et("u_gridPixelDimensions", [this.dr.width, this.dr.height]), this.ve.Gt(0, 0, this.Gr.width, this.Gr.height), this.Gr.end();
|
|
1362
1356
|
}
|
|
1363
1357
|
add(t) {
|
|
1364
|
-
if (!x.
|
|
1358
|
+
if (!x.m(t === "brightness" || t === "custom", 'Converter type must be either "brightness" or "custom".', { method: "add", providedValue: t })) return;
|
|
1365
1359
|
let e;
|
|
1366
|
-
return e = t === "brightness" ? new
|
|
1360
|
+
return e = t === "brightness" ? new Y(this.ve, this.Te, this.dr) : new D(this.ve, this.Te, this.dr), this.Pr.push(e), e;
|
|
1367
1361
|
}
|
|
1368
1362
|
remove(t) {
|
|
1369
|
-
if (!x.
|
|
1370
|
-
const e = this.
|
|
1371
|
-
x.
|
|
1363
|
+
if (!x.m(t instanceof D, "Parameter must be a TextmodeConverter instance.", { method: "remove", providedValue: t })) return;
|
|
1364
|
+
const e = this.Pr.indexOf(t);
|
|
1365
|
+
x.m(e !== -1, "Converter instance not found in pipeline.", { method: "remove", providedValue: t, convertersCount: this.Pr.length }) && this.Pr.splice(e, 1);
|
|
1372
1366
|
}
|
|
1373
1367
|
swap(t, e) {
|
|
1374
|
-
const r = (
|
|
1375
|
-
if (typeof
|
|
1376
|
-
if (
|
|
1377
|
-
const c = this.
|
|
1378
|
-
return x.
|
|
1368
|
+
const r = (n, l) => {
|
|
1369
|
+
if (typeof n == "number") return x.m(Number.isInteger(n) && n >= 0 && n < this.Pr.length, l + " index must be a valid integer within the converter array bounds.", { method: "swap", providedValue: n, convertersCount: this.Pr.length }) ? n : null;
|
|
1370
|
+
if (n instanceof D) {
|
|
1371
|
+
const c = this.Pr.indexOf(n);
|
|
1372
|
+
return x.m(c !== -1, l + " converter instance not found in pipeline.", { method: "swap", providedValue: n, convertersCount: this.Pr.length }) ? c : null;
|
|
1379
1373
|
}
|
|
1380
|
-
return x.
|
|
1374
|
+
return x.m(!1, l + " parameter must be either an integer index or a TextmodeConverter instance.", { method: "swap", providedValue: n }), null;
|
|
1381
1375
|
}, s = r(t, "First"), i = r(e, "Second");
|
|
1382
|
-
if (s === null || i === null || !x.
|
|
1383
|
-
const
|
|
1384
|
-
this.
|
|
1376
|
+
if (s === null || i === null || !x.m(s !== i, "Cannot swap a converter with itself.", { method: "swap", firstIndex: s, secondIndex: i })) return;
|
|
1377
|
+
const o = this.Pr[s];
|
|
1378
|
+
this.Pr[s] = this.Pr[i], this.Pr[i] = o;
|
|
1385
1379
|
}
|
|
1386
1380
|
rr() {
|
|
1387
|
-
this.
|
|
1381
|
+
this.Gr.resize(this.dr.width, this.dr.height);
|
|
1388
1382
|
const t = this.dr.cols, e = this.dr.rows;
|
|
1389
|
-
this.
|
|
1390
|
-
for (const r of this.
|
|
1383
|
+
this.pr.resize(t, e), this.mr.resize(t, e), this.gr.resize(t, e), this._r.resize(t, e), this.vr.resize(t, e);
|
|
1384
|
+
for (const r of this.Pr) r.rr();
|
|
1391
1385
|
}
|
|
1392
1386
|
hasEnabledConverters() {
|
|
1393
|
-
return this.
|
|
1387
|
+
return this.Pr.some((t) => t.options.enabled);
|
|
1394
1388
|
}
|
|
1395
1389
|
disable() {
|
|
1396
|
-
for (const t of this.
|
|
1390
|
+
for (const t of this.Pr) t.disable();
|
|
1397
1391
|
}
|
|
1398
1392
|
enable() {
|
|
1399
|
-
for (const t of this.
|
|
1393
|
+
for (const t of this.Pr) t.enable();
|
|
1400
1394
|
}
|
|
1401
|
-
|
|
1402
|
-
for (const t of this.
|
|
1403
|
-
this.
|
|
1395
|
+
P() {
|
|
1396
|
+
for (const t of this.Pr) t.P();
|
|
1397
|
+
this.pr.P(), this.mr.P(), this.gr.P(), this._r.P(), this.vr.P(), this.Gr.P(), this.Ar.P();
|
|
1404
1398
|
}
|
|
1405
1399
|
get texture() {
|
|
1406
|
-
return this.
|
|
1400
|
+
return this.Gr;
|
|
1407
1401
|
}
|
|
1408
1402
|
get characterFramebuffer() {
|
|
1409
|
-
return this.
|
|
1403
|
+
return this.pr;
|
|
1410
1404
|
}
|
|
1411
1405
|
get primaryColorFramebuffer() {
|
|
1412
|
-
return this.
|
|
1406
|
+
return this.mr;
|
|
1413
1407
|
}
|
|
1414
1408
|
get secondaryColorFramebuffer() {
|
|
1415
1409
|
return this.gr;
|
|
@@ -1421,10 +1415,10 @@ class wt {
|
|
|
1421
1415
|
return this.vr;
|
|
1422
1416
|
}
|
|
1423
1417
|
get brightness() {
|
|
1424
|
-
return this.
|
|
1418
|
+
return this.zr;
|
|
1425
1419
|
}
|
|
1426
1420
|
get custom() {
|
|
1427
|
-
return this.
|
|
1421
|
+
return this.Er;
|
|
1428
1422
|
}
|
|
1429
1423
|
}
|
|
1430
1424
|
const Ct = (a) => class extends a {
|
|
@@ -1456,13 +1450,13 @@ const Ct = (a) => class extends a {
|
|
|
1456
1450
|
this.ve.Gt(t, e, r, s);
|
|
1457
1451
|
}
|
|
1458
1452
|
line(t, e, r, s) {
|
|
1459
|
-
this.ve.
|
|
1453
|
+
this.ve.Ut(t, e, r, s);
|
|
1460
1454
|
}
|
|
1461
1455
|
background(t, e = t, r = t, s = 255) {
|
|
1462
|
-
this.ve.
|
|
1456
|
+
this.ve.Ht(t, e, r, s);
|
|
1463
1457
|
}
|
|
1464
1458
|
createShader(t, e) {
|
|
1465
|
-
return this.ve.
|
|
1459
|
+
return this.ve.Pt(t, e);
|
|
1466
1460
|
}
|
|
1467
1461
|
createFilterShader(t) {
|
|
1468
1462
|
return this.ve.zt(t);
|
|
@@ -1477,16 +1471,16 @@ const Ct = (a) => class extends a {
|
|
|
1477
1471
|
this.ve.Bt(t, e, r, s, i);
|
|
1478
1472
|
}
|
|
1479
1473
|
clear() {
|
|
1480
|
-
this.ve.
|
|
1474
|
+
this.ve.jt();
|
|
1481
1475
|
}
|
|
1482
1476
|
createFramebuffer(t, e, r = {}) {
|
|
1483
|
-
return this.ve.
|
|
1477
|
+
return this.ve.Lt(t, e, r);
|
|
1484
1478
|
}
|
|
1485
1479
|
};
|
|
1486
|
-
class
|
|
1480
|
+
class G {
|
|
1487
1481
|
Lr(t) {
|
|
1488
|
-
const e = t.characterFramebuffer, r = t.primaryColorFramebuffer, s = t.secondaryColorFramebuffer, i = t.transformFramebuffer,
|
|
1489
|
-
return e == null || e.loadPixels(), r == null || r.loadPixels(), s == null || s.loadPixels(), i == null || i.loadPixels(),
|
|
1482
|
+
const e = t.characterFramebuffer, r = t.primaryColorFramebuffer, s = t.secondaryColorFramebuffer, i = t.transformFramebuffer, o = t.rotationFramebuffer;
|
|
1483
|
+
return e == null || e.loadPixels(), r == null || r.loadPixels(), s == null || s.loadPixels(), i == null || i.loadPixels(), o == null || o.loadPixels(), { characterPixels: (e == null ? void 0 : e.pixels) || new Uint8Array(0), primaryColorPixels: (r == null ? void 0 : r.pixels) || new Uint8Array(0), secondaryColorPixels: (s == null ? void 0 : s.pixels) || new Uint8Array(0), transformPixels: (i == null ? void 0 : i.pixels) || new Uint8Array(0), rotationPixels: (o == null ? void 0 : o.pixels) || new Uint8Array(0) };
|
|
1490
1484
|
}
|
|
1491
1485
|
Hr(t, e) {
|
|
1492
1486
|
return t[e] + (t[e + 1] << 8);
|
|
@@ -1495,14 +1489,14 @@ class z {
|
|
|
1495
1489
|
return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
|
|
1496
1490
|
}
|
|
1497
1491
|
}
|
|
1498
|
-
class
|
|
1499
|
-
|
|
1492
|
+
class V {
|
|
1493
|
+
Or(t, e) {
|
|
1500
1494
|
return new Blob([t], { type: e });
|
|
1501
1495
|
}
|
|
1502
|
-
|
|
1496
|
+
Br(t, e, r) {
|
|
1503
1497
|
try {
|
|
1504
|
-
const s = this.
|
|
1505
|
-
|
|
1498
|
+
const s = this.Or(t, r), i = URL.createObjectURL(s), o = document.createElement("a");
|
|
1499
|
+
o.href = i, o.download = e, o.style.display = "none", o.rel = "noopener", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
|
|
1506
1500
|
} catch (s) {
|
|
1507
1501
|
throw console.error("Failed to download file:", s), Error("File download failed: " + (s instanceof Error ? s.message : "Unknown error"));
|
|
1508
1502
|
}
|
|
@@ -1521,10 +1515,10 @@ class L {
|
|
|
1521
1515
|
return "'textmode-export'-" + this.Wr();
|
|
1522
1516
|
}
|
|
1523
1517
|
}
|
|
1524
|
-
class
|
|
1518
|
+
class _t extends G {
|
|
1525
1519
|
Yr(t, e, r) {
|
|
1526
|
-
const s = t[r] === 255, i = t[r + 1] === 255,
|
|
1527
|
-
return { isInverted: s, flipHorizontal: i, flipVertical:
|
|
1520
|
+
const s = t[r] === 255, i = t[r + 1] === 255, o = t[r + 2] === 255, n = e[r], l = e[r + 1];
|
|
1521
|
+
return { isInverted: s, flipHorizontal: i, flipVertical: o, rotation: Math.round(360 * (n + l / 255) / 255 * 100) / 100 };
|
|
1528
1522
|
}
|
|
1529
1523
|
Qr(t, e, r) {
|
|
1530
1524
|
return { x: t, y: e, cellX: t * r.cellWidth, cellY: e * r.cellHeight };
|
|
@@ -1532,31 +1526,31 @@ class yt extends z {
|
|
|
1532
1526
|
Zr(t, e) {
|
|
1533
1527
|
const r = [];
|
|
1534
1528
|
let s = 0;
|
|
1535
|
-
for (let i = 0; i < e.rows; i++) for (let
|
|
1536
|
-
const
|
|
1537
|
-
let c = this.jr(t.primaryColorPixels,
|
|
1538
|
-
const f = this.Yr(t.transformPixels, t.rotationPixels,
|
|
1529
|
+
for (let i = 0; i < e.rows; i++) for (let o = 0; o < e.cols; o++) {
|
|
1530
|
+
const n = 4 * s, l = this.Hr(t.characterPixels, n);
|
|
1531
|
+
let c = this.jr(t.primaryColorPixels, n), u = this.jr(t.secondaryColorPixels, n);
|
|
1532
|
+
const f = this.Yr(t.transformPixels, t.rotationPixels, n);
|
|
1539
1533
|
if (f.isInverted) {
|
|
1540
|
-
const
|
|
1541
|
-
c = u, u =
|
|
1534
|
+
const m = c;
|
|
1535
|
+
c = u, u = m;
|
|
1542
1536
|
}
|
|
1543
|
-
const d = this.Qr(
|
|
1537
|
+
const d = this.Qr(o, i, e);
|
|
1544
1538
|
r.push({ charIndex: l, primaryColor: c, secondaryColor: u, transform: f, position: d }), s++;
|
|
1545
1539
|
}
|
|
1546
1540
|
return r;
|
|
1547
1541
|
}
|
|
1548
1542
|
}
|
|
1549
|
-
class
|
|
1543
|
+
class yt {
|
|
1550
1544
|
Jr(t, e) {
|
|
1551
1545
|
const r = t.cmap;
|
|
1552
1546
|
for (const s of r.tables) if (s.format === 4) {
|
|
1553
1547
|
for (let i = 0; i < s.startCount.length; i++) if (e >= s.startCount[i] && e <= s.endCount[i]) {
|
|
1554
1548
|
if (s.idRangeOffset[i] === 0) return e + s.idDelta[i] & 65535;
|
|
1555
1549
|
{
|
|
1556
|
-
const
|
|
1557
|
-
if (
|
|
1558
|
-
const
|
|
1559
|
-
if (
|
|
1550
|
+
const o = s.idRangeOffset[i] / 2 + (e - s.startCount[i]) - (s.startCount.length - i);
|
|
1551
|
+
if (o >= 0 && o < s.glyphIdArray.length) {
|
|
1552
|
+
const n = s.glyphIdArray[o];
|
|
1553
|
+
if (n !== 0) return n + s.idDelta[i] & 65535;
|
|
1560
1554
|
}
|
|
1561
1555
|
}
|
|
1562
1556
|
}
|
|
@@ -1564,34 +1558,34 @@ class _t {
|
|
|
1564
1558
|
return 0;
|
|
1565
1559
|
}
|
|
1566
1560
|
Kr(t, e, r, s, i) {
|
|
1567
|
-
const
|
|
1568
|
-
return { getBoundingBox: () => ({ x1: r + e.xMin *
|
|
1561
|
+
const o = i / t.head.unitsPerEm;
|
|
1562
|
+
return { getBoundingBox: () => ({ x1: r + e.xMin * o, y1: s + -e.yMax * o, x2: r + e.xMax * o, y2: s + -e.yMin * o }), toSVG: () => this.ts(e, r, s, o) };
|
|
1569
1563
|
}
|
|
1570
1564
|
ts(t, e, r, s) {
|
|
1571
1565
|
if (!t || !t.xs) return "";
|
|
1572
|
-
const { xs: i, ys:
|
|
1573
|
-
if (!(i &&
|
|
1566
|
+
const { xs: i, ys: o, endPts: n, flags: l } = t;
|
|
1567
|
+
if (!(i && o && n && l)) return "";
|
|
1574
1568
|
let c = "", u = 0;
|
|
1575
|
-
for (let f = 0; f <
|
|
1576
|
-
const d =
|
|
1569
|
+
for (let f = 0; f < n.length; f++) {
|
|
1570
|
+
const d = n[f];
|
|
1577
1571
|
if (!(d < u)) {
|
|
1578
1572
|
if (d >= u) {
|
|
1579
|
-
const
|
|
1580
|
-
c += `M${
|
|
1573
|
+
const m = e + i[u] * s, p = r - o[u] * s;
|
|
1574
|
+
c += `M${m.toFixed(2)},${p.toFixed(2)}`;
|
|
1581
1575
|
let g = u + 1;
|
|
1582
1576
|
for (; g <= d; )
|
|
1583
1577
|
if (1 & l[g]) {
|
|
1584
|
-
const C = e + i[g] * s,
|
|
1585
|
-
c += `L${C.toFixed(2)},${
|
|
1578
|
+
const C = e + i[g] * s, v = r - o[g] * s;
|
|
1579
|
+
c += `L${C.toFixed(2)},${v.toFixed(2)}`, g++;
|
|
1586
1580
|
} else {
|
|
1587
|
-
const C = e + i[g] * s,
|
|
1581
|
+
const C = e + i[g] * s, v = r - o[g] * s;
|
|
1588
1582
|
let b = g + 1 > d ? u : g + 1;
|
|
1589
1583
|
if (1 & l[b]) {
|
|
1590
|
-
const T = e + i[b] * s, E = r -
|
|
1591
|
-
c += `Q${C.toFixed(2)},${
|
|
1584
|
+
const T = e + i[b] * s, E = r - o[b] * s;
|
|
1585
|
+
c += `Q${C.toFixed(2)},${v.toFixed(2)} ${T.toFixed(2)},${E.toFixed(2)}`, g = b + 1;
|
|
1592
1586
|
} else {
|
|
1593
|
-
const T = (C + (e + i[b] * s)) / 2, E = (
|
|
1594
|
-
c += `Q${C.toFixed(2)},${
|
|
1587
|
+
const T = (C + (e + i[b] * s)) / 2, E = (v + (r - o[b] * s)) / 2;
|
|
1588
|
+
c += `Q${C.toFixed(2)},${v.toFixed(2)} ${T.toFixed(2)},${E.toFixed(2)}`, g = b;
|
|
1595
1589
|
}
|
|
1596
1590
|
}
|
|
1597
1591
|
c += "Z";
|
|
@@ -1602,19 +1596,19 @@ class _t {
|
|
|
1602
1596
|
return c;
|
|
1603
1597
|
}
|
|
1604
1598
|
es(t, e, r, s, i) {
|
|
1605
|
-
const
|
|
1599
|
+
const o = t.codePointAt(0) || 0, n = this.Jr(e, o);
|
|
1606
1600
|
let l = null;
|
|
1607
|
-
return e.glyf && e.glyf[
|
|
1601
|
+
return e.glyf && e.glyf[n] !== null ? l = e.glyf[n] : y && y.T && y.T.glyf && y.T.glyf.Wt && (l = y.T.glyf.Wt(e, n), e.glyf && l && (e.glyf[n] = l)), this.Kr(e, l, r, s, i);
|
|
1608
1602
|
}
|
|
1609
|
-
rs(t, e, r, s, i,
|
|
1610
|
-
const c = r + (i - l * (
|
|
1611
|
-
return this.es(t, e, c, u,
|
|
1603
|
+
rs(t, e, r, s, i, o, n, l) {
|
|
1604
|
+
const c = r + (i - l * (n / e.head.unitsPerEm)) / 2, u = s + (o + 0.7 * n) / 2;
|
|
1605
|
+
return this.es(t, e, c, u, n).toSVG() || null;
|
|
1612
1606
|
}
|
|
1613
1607
|
}
|
|
1614
1608
|
class Tt {
|
|
1615
1609
|
constructor() {
|
|
1616
1610
|
h(this, "ss");
|
|
1617
|
-
this.ss = new
|
|
1611
|
+
this.ss = new yt();
|
|
1618
1612
|
}
|
|
1619
1613
|
ns(t) {
|
|
1620
1614
|
return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
@@ -1639,12 +1633,12 @@ class Tt {
|
|
|
1639
1633
|
return `rgba(${t.r},${t.g},${t.b},${t.a / 255})`;
|
|
1640
1634
|
}
|
|
1641
1635
|
us(t, e) {
|
|
1642
|
-
const { transform: r, position: s } = t, i = s.cellX + e.cellWidth / 2,
|
|
1636
|
+
const { transform: r, position: s } = t, i = s.cellX + e.cellWidth / 2, o = s.cellY + e.cellHeight / 2, n = [];
|
|
1643
1637
|
if (r.flipHorizontal || r.flipVertical) {
|
|
1644
1638
|
const l = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
|
|
1645
|
-
|
|
1639
|
+
n.push(`translate(${i} ${o})`), n.push(`scale(${l} ${c})`), n.push(`translate(${-i} ${-o})`);
|
|
1646
1640
|
}
|
|
1647
|
-
return r.rotation &&
|
|
1641
|
+
return r.rotation && n.push(`rotate(${r.rotation} ${i} ${o})`), n.length ? ` transform="${n.join(" ")}"` : "";
|
|
1648
1642
|
}
|
|
1649
1643
|
fs(t, e, r) {
|
|
1650
1644
|
if (!r.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
|
|
@@ -1656,26 +1650,26 @@ class Tt {
|
|
|
1656
1650
|
es(t, e, r, s) {
|
|
1657
1651
|
const i = r.characters[t.charIndex];
|
|
1658
1652
|
if (!i) return "";
|
|
1659
|
-
const
|
|
1660
|
-
if (!
|
|
1661
|
-
const
|
|
1653
|
+
const o = this.ss.rs(i.character, r.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.advanceWidth);
|
|
1654
|
+
if (!o) return "";
|
|
1655
|
+
const n = this.cs(t.primaryColor);
|
|
1662
1656
|
return s.drawMode === "stroke" ? `
|
|
1663
|
-
<path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${
|
|
1664
|
-
<path d="${
|
|
1657
|
+
<path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${o}" stroke="${n}" stroke-width="${s.strokeWidth}" fill="none" />` : `
|
|
1658
|
+
<path d="${o}" fill="${n}" />`;
|
|
1665
1659
|
}
|
|
1666
1660
|
ds(t, e, r, s) {
|
|
1667
1661
|
let i = "";
|
|
1668
1662
|
i += this.fs(t, e, s);
|
|
1669
|
-
const
|
|
1670
|
-
return
|
|
1671
|
-
<g${
|
|
1672
|
-
</g>`) : i +=
|
|
1663
|
+
const o = this.us(t, e), n = this.es(t, e, r, s);
|
|
1664
|
+
return n && (o ? (i += `
|
|
1665
|
+
<g${o}>`, i += n, i += `
|
|
1666
|
+
</g>`) : i += n), i;
|
|
1673
1667
|
}
|
|
1674
1668
|
ps(t, e, r, s) {
|
|
1675
1669
|
let i = this.ns(e);
|
|
1676
1670
|
i += this.ls(e, s), i += `
|
|
1677
1671
|
<g id="ascii-cells">`;
|
|
1678
|
-
for (const
|
|
1672
|
+
for (const o of t) i += this.ds(o, e, r, s);
|
|
1679
1673
|
return i += this.hs(), i;
|
|
1680
1674
|
}
|
|
1681
1675
|
gs(t) {
|
|
@@ -1683,46 +1677,46 @@ class Tt {
|
|
|
1683
1677
|
`).replace(/[ \t]+$/gm, "");
|
|
1684
1678
|
}
|
|
1685
1679
|
}
|
|
1686
|
-
class Et extends
|
|
1680
|
+
class Et extends V {
|
|
1687
1681
|
_s(t) {
|
|
1688
|
-
return this.
|
|
1682
|
+
return this.Or(t, "image/svg+xml;charset=utf-8");
|
|
1689
1683
|
}
|
|
1690
1684
|
vs(t, e) {
|
|
1691
|
-
this.
|
|
1685
|
+
this.Br(t, this.Xr(e) + ".svg", "image/svg+xml;charset=utf-8");
|
|
1692
1686
|
}
|
|
1693
1687
|
bs(t, e) {
|
|
1694
1688
|
this.vs(t, e || this.qr());
|
|
1695
1689
|
}
|
|
1696
1690
|
}
|
|
1697
|
-
class
|
|
1691
|
+
class z {
|
|
1698
1692
|
constructor() {
|
|
1699
1693
|
h(this, "ws");
|
|
1700
1694
|
h(this, "Cs");
|
|
1701
1695
|
h(this, "$s");
|
|
1702
|
-
this.ws = new
|
|
1696
|
+
this.ws = new _t(), this.Cs = new Tt(), this.$s = new Et();
|
|
1703
1697
|
}
|
|
1704
1698
|
Fs(t) {
|
|
1705
1699
|
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0] };
|
|
1706
1700
|
}
|
|
1707
1701
|
Ts(t, e = {}) {
|
|
1708
|
-
const r = this.Fs(e), s = this.ws.Lr(t.pipeline), i = this.ws.Zr(s, t.grid),
|
|
1709
|
-
return this.Cs.gs(
|
|
1702
|
+
const r = this.Fs(e), s = this.ws.Lr(t.pipeline), i = this.ws.Zr(s, t.grid), o = this.Cs.ps(i, t.grid, t.font, r);
|
|
1703
|
+
return this.Cs.gs(o);
|
|
1710
1704
|
}
|
|
1711
1705
|
bs(t, e = {}) {
|
|
1712
1706
|
const r = this.Ts(t, e), s = e.filename || this.$s.qr();
|
|
1713
1707
|
this.$s.bs(r, s);
|
|
1714
1708
|
}
|
|
1715
1709
|
}
|
|
1716
|
-
class Rt extends
|
|
1710
|
+
class Rt extends G {
|
|
1717
1711
|
Ms(t, e, r, s = " ") {
|
|
1718
|
-
var
|
|
1712
|
+
var n;
|
|
1719
1713
|
const i = [];
|
|
1720
|
-
let
|
|
1714
|
+
let o = 0;
|
|
1721
1715
|
for (let l = 0; l < e.rows; l++) {
|
|
1722
1716
|
const c = [];
|
|
1723
1717
|
for (let u = 0; u < e.cols; u++) {
|
|
1724
|
-
const f = 4 *
|
|
1725
|
-
c.push(
|
|
1718
|
+
const f = 4 * o, d = this.Hr(t.characterPixels, f), m = ((n = r.characters[d]) == null ? void 0 : n.character) || s;
|
|
1719
|
+
c.push(m), o++;
|
|
1726
1720
|
}
|
|
1727
1721
|
i.push(c);
|
|
1728
1722
|
}
|
|
@@ -1733,8 +1727,8 @@ class Ft {
|
|
|
1733
1727
|
Ds(t, e) {
|
|
1734
1728
|
const r = [];
|
|
1735
1729
|
for (const i of t) {
|
|
1736
|
-
let
|
|
1737
|
-
e.preserveTrailingSpaces || (
|
|
1730
|
+
let o = i.join("");
|
|
1731
|
+
e.preserveTrailingSpaces || (o = o.replace(/\s+$/, "")), r.push(o);
|
|
1738
1732
|
}
|
|
1739
1733
|
const s = e.lineEnding === "crlf" ? `\r
|
|
1740
1734
|
` : `
|
|
@@ -1742,22 +1736,22 @@ class Ft {
|
|
|
1742
1736
|
return r.join(s);
|
|
1743
1737
|
}
|
|
1744
1738
|
}
|
|
1745
|
-
class
|
|
1739
|
+
class Pt extends V {
|
|
1746
1740
|
Ss(t, e) {
|
|
1747
1741
|
const r = this.Rs(e);
|
|
1748
|
-
this.
|
|
1742
|
+
this.Br(t, r, "text/plain;charset=utf-8");
|
|
1749
1743
|
}
|
|
1750
1744
|
Rs(t) {
|
|
1751
1745
|
let e = this.Xr(t);
|
|
1752
1746
|
return e === ".txt" || e.length <= 4 ? this.qr() : e;
|
|
1753
1747
|
}
|
|
1754
1748
|
}
|
|
1755
|
-
class
|
|
1749
|
+
class H {
|
|
1756
1750
|
constructor() {
|
|
1757
1751
|
h(this, "ws");
|
|
1758
1752
|
h(this, "Cs");
|
|
1759
1753
|
h(this, "$s");
|
|
1760
|
-
this.ws = new Rt(), this.Cs = new Ft(), this.$s = new
|
|
1754
|
+
this.ws = new Rt(), this.Cs = new Ft(), this.$s = new Pt();
|
|
1761
1755
|
}
|
|
1762
1756
|
Fs(t) {
|
|
1763
1757
|
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " " };
|
|
@@ -1771,28 +1765,28 @@ class N {
|
|
|
1771
1765
|
this.$s.Ss(r, s);
|
|
1772
1766
|
}
|
|
1773
1767
|
}
|
|
1774
|
-
class
|
|
1768
|
+
class Mt extends G {
|
|
1775
1769
|
ks(t, e = 1, r = "transparent") {
|
|
1776
1770
|
const s = t.canvas;
|
|
1777
1771
|
if (e === 1 && r === "transparent") return s;
|
|
1778
|
-
const i = document.createElement("canvas"),
|
|
1779
|
-
return i.width =
|
|
1772
|
+
const i = document.createElement("canvas"), o = i.getContext("2d"), n = Math.round(s.width * e), l = Math.round(s.height * e);
|
|
1773
|
+
return i.width = n, i.height = l, r !== "transparent" && (o.fillStyle = r, o.fillRect(0, 0, n, l)), o.imageSmoothingEnabled = !1, o.drawImage(s, 0, 0, s.width, s.height, 0, 0, n, l), i;
|
|
1780
1774
|
}
|
|
1781
1775
|
}
|
|
1782
|
-
class
|
|
1776
|
+
class At {
|
|
1783
1777
|
Is(t, e) {
|
|
1784
|
-
const r = this.
|
|
1778
|
+
const r = this.Ps(e.format);
|
|
1785
1779
|
return e.format === "png" ? t.toDataURL(r) : t.toDataURL(r, e.quality);
|
|
1786
1780
|
}
|
|
1787
|
-
async
|
|
1781
|
+
async zs(t, e) {
|
|
1788
1782
|
return new Promise((r, s) => {
|
|
1789
|
-
const i = this.
|
|
1790
|
-
|
|
1783
|
+
const i = this.Ps(e.format), o = (n) => {
|
|
1784
|
+
n ? r(n) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
|
|
1791
1785
|
};
|
|
1792
|
-
e.format === "png" ? t.toBlob(
|
|
1786
|
+
e.format === "png" ? t.toBlob(o, i) : t.toBlob(o, i, e.quality);
|
|
1793
1787
|
});
|
|
1794
1788
|
}
|
|
1795
|
-
|
|
1789
|
+
Ps(t) {
|
|
1796
1790
|
switch (t) {
|
|
1797
1791
|
case "png":
|
|
1798
1792
|
return "image/png";
|
|
@@ -1805,12 +1799,12 @@ class Ut {
|
|
|
1805
1799
|
}
|
|
1806
1800
|
}
|
|
1807
1801
|
}
|
|
1808
|
-
const Dt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" },
|
|
1809
|
-
class St extends
|
|
1810
|
-
|
|
1811
|
-
this.
|
|
1802
|
+
const Dt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, N = { png: ".png", jpg: ".jpg", webp: ".webp" };
|
|
1803
|
+
class St extends V {
|
|
1804
|
+
Es(t, e, r) {
|
|
1805
|
+
this.Gs(t, this.Xr(e) + N[r]);
|
|
1812
1806
|
}
|
|
1813
|
-
|
|
1807
|
+
Gs(t, e) {
|
|
1814
1808
|
const r = URL.createObjectURL(t);
|
|
1815
1809
|
try {
|
|
1816
1810
|
const s = document.createElement("a");
|
|
@@ -1820,15 +1814,15 @@ class St extends L {
|
|
|
1820
1814
|
}
|
|
1821
1815
|
}
|
|
1822
1816
|
As(t) {
|
|
1823
|
-
return t in Dt && t in
|
|
1817
|
+
return t in Dt && t in N;
|
|
1824
1818
|
}
|
|
1825
1819
|
}
|
|
1826
|
-
class
|
|
1820
|
+
class Ut {
|
|
1827
1821
|
constructor() {
|
|
1828
1822
|
h(this, "ws");
|
|
1829
1823
|
h(this, "Cs");
|
|
1830
1824
|
h(this, "$s");
|
|
1831
|
-
this.ws = new
|
|
1825
|
+
this.ws = new Mt(), this.Cs = new At(), this.$s = new St();
|
|
1832
1826
|
}
|
|
1833
1827
|
Fs(t) {
|
|
1834
1828
|
return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent" };
|
|
@@ -1845,47 +1839,47 @@ class Pt {
|
|
|
1845
1839
|
const s = this.ws.ks(t, r.scale, r.backgroundColor);
|
|
1846
1840
|
return this.Cs.Is(s, r);
|
|
1847
1841
|
}
|
|
1848
|
-
async
|
|
1842
|
+
async zs(t, e = {}) {
|
|
1849
1843
|
const r = this.Fs(e);
|
|
1850
|
-
if (this.Us(r), r.scale === 1 && r.backgroundColor === "transparent") return await this.Cs.
|
|
1844
|
+
if (this.Us(r), r.scale === 1 && r.backgroundColor === "transparent") return await this.Cs.zs(t.canvas, r);
|
|
1851
1845
|
const s = this.ws.ks(t, r.scale, r.backgroundColor);
|
|
1852
|
-
return await this.Cs.
|
|
1846
|
+
return await this.Cs.zs(s, r);
|
|
1853
1847
|
}
|
|
1854
|
-
async
|
|
1855
|
-
const r = await this.
|
|
1856
|
-
this.$s.
|
|
1848
|
+
async Es(t, e = {}) {
|
|
1849
|
+
const r = await this.zs(t, e), s = e.format ?? "png", i = e.filename || this.$s.qr();
|
|
1850
|
+
this.$s.Es(r, i, s);
|
|
1857
1851
|
}
|
|
1858
1852
|
}
|
|
1859
1853
|
const $t = (a) => class extends a {
|
|
1860
1854
|
toString(t = {}) {
|
|
1861
|
-
return new
|
|
1855
|
+
return new H().Vs({ pipeline: this.Hs, grid: this.dr, font: this.Te }, t);
|
|
1862
1856
|
}
|
|
1863
1857
|
saveStrings(t = {}) {
|
|
1864
|
-
new
|
|
1858
|
+
new H().Ss({ pipeline: this.Hs, grid: this.dr, font: this.Te }, t);
|
|
1865
1859
|
}
|
|
1866
1860
|
toSVG(t = {}) {
|
|
1867
|
-
return new
|
|
1861
|
+
return new z().Ts(this, t);
|
|
1868
1862
|
}
|
|
1869
1863
|
saveSVG(t = {}) {
|
|
1870
|
-
new
|
|
1864
|
+
new z().bs(this, t);
|
|
1871
1865
|
}
|
|
1872
1866
|
async saveCanvas(t, e = "png", r = {}) {
|
|
1873
|
-
await new
|
|
1867
|
+
await new Ut().Es(this.Ye, { ...r, filename: t, format: e });
|
|
1874
1868
|
}
|
|
1875
1869
|
}, It = (a) => class extends a {
|
|
1876
1870
|
async loadFont(t) {
|
|
1877
|
-
return this.Te.
|
|
1871
|
+
return this.Te.Oe(t).then(() => {
|
|
1878
1872
|
const e = this.Te.maxGlyphDimensions;
|
|
1879
1873
|
this.dr.Ke(e.width, e.height), this.Hs.rr();
|
|
1880
1874
|
});
|
|
1881
1875
|
}
|
|
1882
1876
|
fontSize(t) {
|
|
1883
|
-
if (!x.
|
|
1877
|
+
if (!x.m(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Te.fontSize === t) return;
|
|
1884
1878
|
this.Te.je(t);
|
|
1885
1879
|
const e = this.Te.maxGlyphDimensions;
|
|
1886
|
-
this.dr.Ke(e.width, e.height), this.Hs.rr(), this.ve.
|
|
1880
|
+
this.dr.Ke(e.width, e.height), this.Hs.rr(), this.ve.Ot();
|
|
1887
1881
|
}
|
|
1888
|
-
},
|
|
1882
|
+
}, kt = (a) => class extends a {
|
|
1889
1883
|
addConverter(t) {
|
|
1890
1884
|
return this.Hs.add(t);
|
|
1891
1885
|
}
|
|
@@ -1893,7 +1887,7 @@ const $t = (a) => class extends a {
|
|
|
1893
1887
|
this.Hs.remove(t);
|
|
1894
1888
|
}
|
|
1895
1889
|
};
|
|
1896
|
-
class
|
|
1890
|
+
class Lt {
|
|
1897
1891
|
constructor() {
|
|
1898
1892
|
h(this, "ve");
|
|
1899
1893
|
h(this, "Te");
|
|
@@ -1904,14 +1898,14 @@ class kt {
|
|
|
1904
1898
|
}
|
|
1905
1899
|
class X extends function(e, ...r) {
|
|
1906
1900
|
return r.reduce((s, i) => i(s), e);
|
|
1907
|
-
}(
|
|
1901
|
+
}(Lt, Ct, $t, It, kt) {
|
|
1908
1902
|
constructor(e = null, r = {}) {
|
|
1909
1903
|
super();
|
|
1910
1904
|
h(this, "ir");
|
|
1911
1905
|
h(this, "js");
|
|
1912
1906
|
h(this, "ar");
|
|
1913
|
-
h(this, "Bs");
|
|
1914
1907
|
h(this, "Os");
|
|
1908
|
+
h(this, "Bs");
|
|
1915
1909
|
h(this, "Ws", null);
|
|
1916
1910
|
h(this, "Ns", 0);
|
|
1917
1911
|
h(this, "Xs");
|
|
@@ -1928,16 +1922,16 @@ class X extends function(e, ...r) {
|
|
|
1928
1922
|
h(this, "si", () => {
|
|
1929
1923
|
});
|
|
1930
1924
|
h(this, "ii");
|
|
1931
|
-
this.ir = e, this.ei = e === null, this.
|
|
1925
|
+
this.ir = e, this.ei = e === null, this.Os = r.renderMode ?? "auto", this.Bs = r.frameRate ?? 60, this.Xs = 1e3 / this.Bs;
|
|
1932
1926
|
}
|
|
1933
1927
|
static async create(e = null, r = {}) {
|
|
1934
1928
|
const s = new this(e, r), i = s.ei ? r : void 0;
|
|
1935
|
-
let
|
|
1936
|
-
s.Ye = new
|
|
1929
|
+
let o, n;
|
|
1930
|
+
s.Ye = new vt(s.ir, s.ei, i), s.ve = new ot(s.Ye.cr()), s.ei ? (o = r.width || 800, n = r.height || 600) : (o = s.Ye.width || 800, n = s.Ye.height || 600), s.js = s.ve.Lt(o, n), s.Te = new pt(s.ve, r.fontSize ?? 16), await s.Te.Ue(r.fontSource);
|
|
1937
1931
|
const l = s.Te.maxGlyphDimensions;
|
|
1938
|
-
return s.dr = new
|
|
1932
|
+
return s.dr = new mt(s.Ye.canvas, l.width, l.height), s.Hs = new wt(s.ve, s.Te, s.dr), s.oi(), s.ni(), s;
|
|
1939
1933
|
}
|
|
1940
|
-
|
|
1934
|
+
oi() {
|
|
1941
1935
|
this.ii = () => {
|
|
1942
1936
|
this.ei ? this.si() : this.ai();
|
|
1943
1937
|
}, window.addEventListener("resize", this.ii), window.ResizeObserver && this.ir && !this.ei && (this.ar = new ResizeObserver(() => {
|
|
@@ -1945,13 +1939,13 @@ class X extends function(e, ...r) {
|
|
|
1945
1939
|
}), this.ar.observe(this.ir));
|
|
1946
1940
|
}
|
|
1947
1941
|
render() {
|
|
1948
|
-
this.hi(), this.Zs++, this.ti ? console.warn("Cannot render: Required resources have been disposed") : (this.ei ? (this.js.begin(), this.ri(), this.js.end()) : this.js.update(this.ir), this.Hs.hasEnabledConverters() ? (this.Hs.Ur(this.js), this.ve.
|
|
1942
|
+
this.hi(), this.Zs++, this.ti ? console.warn("Cannot render: Required resources have been disposed") : (this.ei ? (this.js.begin(), this.ri(), this.js.end()) : this.js.update(this.ir), this.Hs.hasEnabledConverters() ? (this.Hs.Ur(this.js), this.ve.Ht(0), this.ve.Bt(this.Hs.texture, this.dr.offsetX, this.dr.offsetY, this.Hs.texture.width, this.Hs.texture.height)) : (this.ve.jt(), this.ve.Bt(this.js, this.dr.offsetX, this.dr.offsetY, this.js.width, this.js.height)));
|
|
1949
1943
|
}
|
|
1950
1944
|
ai() {
|
|
1951
|
-
this.Ye.rr(), this.js.resize(this.Ye.width, this.Ye.height), this.dr.rr(), this.Hs.rr(), this.ve.
|
|
1945
|
+
this.Ye.rr(), this.js.resize(this.Ye.width, this.Ye.height), this.dr.rr(), this.Hs.rr(), this.ve.Ot(), this.Os !== "manual" && this.render();
|
|
1952
1946
|
}
|
|
1953
|
-
|
|
1954
|
-
if (this.
|
|
1947
|
+
ni() {
|
|
1948
|
+
if (this.Os !== "auto" || !this.qs) return;
|
|
1955
1949
|
this.Ns = performance.now();
|
|
1956
1950
|
const e = (r) => {
|
|
1957
1951
|
if (!this.qs) return void (this.Ws = null);
|
|
@@ -1965,7 +1959,7 @@ class X extends function(e, ...r) {
|
|
|
1965
1959
|
if (this.Qs > 0) {
|
|
1966
1960
|
const r = e - this.Qs;
|
|
1967
1961
|
this.Js.push(r), this.Js.length > this.Ks && this.Js.shift();
|
|
1968
|
-
const s = this.Js.reduce((i,
|
|
1962
|
+
const s = this.Js.reduce((i, o) => i + o, 0) / this.Js.length;
|
|
1969
1963
|
this.Ys = 1e3 / s;
|
|
1970
1964
|
}
|
|
1971
1965
|
this.Qs = e;
|
|
@@ -1974,23 +1968,23 @@ class X extends function(e, ...r) {
|
|
|
1974
1968
|
this.Ws && (cancelAnimationFrame(this.Ws), this.Ws = null);
|
|
1975
1969
|
}
|
|
1976
1970
|
renderMode(e) {
|
|
1977
|
-
this.
|
|
1971
|
+
this.Os !== e && (this.li(), this.Os = e, e === "auto" && this.qs && this.ni());
|
|
1978
1972
|
}
|
|
1979
1973
|
frameRate(e) {
|
|
1980
1974
|
if (e === void 0) return this.Ys;
|
|
1981
|
-
this.
|
|
1975
|
+
this.Bs = e, this.Xs = 1e3 / e, this.Os === "auto" && this.qs && (this.li(), this.ni());
|
|
1982
1976
|
}
|
|
1983
1977
|
noLoop() {
|
|
1984
1978
|
this.qs && (this.qs = !1, this.Ws && (cancelAnimationFrame(this.Ws), this.Ws = null));
|
|
1985
1979
|
}
|
|
1986
1980
|
loop() {
|
|
1987
|
-
this.qs || (this.qs = !0, this.
|
|
1981
|
+
this.qs || (this.qs = !0, this.Os === "auto" && this.ni());
|
|
1988
1982
|
}
|
|
1989
1983
|
redraw(e = 1) {
|
|
1990
|
-
if (x.
|
|
1984
|
+
if (x.m(typeof e == "number" && e > 0 && Number.isInteger(e), "Redraw count must be a positive integer.", { method: "redraw", providedValue: e })) for (let r = 0; r < e; r++) this.render();
|
|
1991
1985
|
}
|
|
1992
1986
|
isLooping() {
|
|
1993
|
-
return this.
|
|
1987
|
+
return this.Os === "auto" && this.qs;
|
|
1994
1988
|
}
|
|
1995
1989
|
draw(e) {
|
|
1996
1990
|
this.ri = e;
|
|
@@ -1999,10 +1993,10 @@ class X extends function(e, ...r) {
|
|
|
1999
1993
|
this.si = e;
|
|
2000
1994
|
}
|
|
2001
1995
|
resizeCanvas(e, r) {
|
|
2002
|
-
this.ei && (this.Ye.rr(e, r), this.js.resize(this.Ye.width, this.Ye.height), this.dr.rr(), this.Hs.rr(), this.ve.
|
|
1996
|
+
this.ei && (this.Ye.rr(e, r), this.js.resize(this.Ye.width, this.Ye.height), this.dr.rr(), this.Hs.rr(), this.ve.Ot(), this.Os !== "manual" && this.render());
|
|
2003
1997
|
}
|
|
2004
1998
|
destroy() {
|
|
2005
|
-
this.ti || (this.li(), window.removeEventListener("resize", this.ii), this.ar && this.ar.disconnect(), this.Hs.
|
|
1999
|
+
this.ti || (this.li(), window.removeEventListener("resize", this.ii), this.ar && this.ar.disconnect(), this.Hs.P(), this.Te.P(), this.js.P(), this.ve.P(), this.ti = !0);
|
|
2006
2000
|
}
|
|
2007
2001
|
get grid() {
|
|
2008
2002
|
return this.dr;
|
|
@@ -2011,7 +2005,7 @@ class X extends function(e, ...r) {
|
|
|
2011
2005
|
return this.Te;
|
|
2012
2006
|
}
|
|
2013
2007
|
get mode() {
|
|
2014
|
-
return this.
|
|
2008
|
+
return this.Os;
|
|
2015
2009
|
}
|
|
2016
2010
|
get pipeline() {
|
|
2017
2011
|
return this.Hs;
|
|
@@ -2038,7 +2032,7 @@ class X extends function(e, ...r) {
|
|
|
2038
2032
|
return this.ti;
|
|
2039
2033
|
}
|
|
2040
2034
|
}
|
|
2041
|
-
class
|
|
2035
|
+
class O {
|
|
2042
2036
|
constructor() {
|
|
2043
2037
|
throw new w("Textmode is a static class and cannot be instantiated.");
|
|
2044
2038
|
}
|
|
@@ -2055,23 +2049,23 @@ class H {
|
|
|
2055
2049
|
x._(t);
|
|
2056
2050
|
}
|
|
2057
2051
|
static get version() {
|
|
2058
|
-
return "0.1.9-beta.
|
|
2052
|
+
return "0.1.9-beta.6";
|
|
2059
2053
|
}
|
|
2060
2054
|
}
|
|
2061
|
-
const
|
|
2055
|
+
const Gt = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), Vt = O.create, Ot = O.setErrorLevel, Wt = O.version;
|
|
2062
2056
|
export {
|
|
2063
|
-
|
|
2057
|
+
vt as TextmodeCanvas,
|
|
2064
2058
|
xt as TextmodeColorPalette,
|
|
2065
2059
|
wt as TextmodeConversionPipeline,
|
|
2066
2060
|
rt as TextmodeErrorLevel,
|
|
2067
2061
|
pt as TextmodeFont,
|
|
2068
|
-
|
|
2062
|
+
mt as TextmodeGrid,
|
|
2069
2063
|
X as Textmodifier,
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2064
|
+
Bt as converters,
|
|
2065
|
+
Vt as create,
|
|
2066
|
+
O as default,
|
|
2067
|
+
Gt as export,
|
|
2068
|
+
Ot as setErrorLevel,
|
|
2069
|
+
O as textmode,
|
|
2070
|
+
Wt as version
|
|
2077
2071
|
};
|