textmode.js 0.1.9-beta.1 → 0.1.9-beta.3
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 +224 -220
- package/dist/textmode.esm.min.js +503 -499
- package/dist/textmode.umd.js +5 -5
- package/dist/textmode.umd.min.js +4 -4
- package/dist/types/ColorPalette.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/textmode/converters/FeatureConverter.d.ts +2 -2
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +8 -0
- package/package.json +1 -1
package/dist/textmode.esm.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var tt = Object.defineProperty;
|
|
2
|
-
var et = (
|
|
3
|
-
var
|
|
2
|
+
var et = (a, t, e) => t in a ? tt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var h = (a, t, e) => et(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
class w extends Error {
|
|
5
5
|
constructor(t, e = {}) {
|
|
6
6
|
super(w.i(t, e)), this.name = "TextmodeError";
|
|
@@ -33,10 +33,10 @@ class w extends Error {
|
|
|
33
33
|
return t + "";
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
var rt = ((
|
|
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
37
|
const M = class M {
|
|
38
38
|
constructor() {
|
|
39
|
-
|
|
39
|
+
h(this, "l", { globalLevel: 3 });
|
|
40
40
|
}
|
|
41
41
|
static u() {
|
|
42
42
|
return M.h || (M.h = new M()), M.h;
|
|
@@ -61,25 +61,25 @@ const M = class M {
|
|
|
61
61
|
this.l.globalLevel = t;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
h(M, "h", null);
|
|
65
65
|
let k = M;
|
|
66
66
|
const x = k.u(), q = /* @__PURE__ */ new WeakMap();
|
|
67
|
-
function I(
|
|
68
|
-
q.set(
|
|
67
|
+
function I(a, t) {
|
|
68
|
+
q.set(a, t);
|
|
69
69
|
}
|
|
70
|
-
function Z(
|
|
71
|
-
return q.get(
|
|
70
|
+
function Z(a) {
|
|
71
|
+
return q.get(a);
|
|
72
72
|
}
|
|
73
73
|
class J {
|
|
74
74
|
constructor(t, e, r = e, s = {}) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
h(this, "v");
|
|
76
|
+
h(this, "C");
|
|
77
|
+
h(this, "$");
|
|
78
|
+
h(this, "F");
|
|
79
|
+
h(this, "M");
|
|
80
|
+
h(this, "l");
|
|
81
|
+
h(this, "D", null);
|
|
82
|
+
h(this, "S", null);
|
|
83
83
|
this.v = t, this.F = e, this.M = r, this.l = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...s }, this.$ = this.R(), this.C = t.createFramebuffer(), this.V();
|
|
84
84
|
}
|
|
85
85
|
k(t) {
|
|
@@ -170,12 +170,12 @@ class J {
|
|
|
170
170
|
}
|
|
171
171
|
class R {
|
|
172
172
|
constructor(t, e, r) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
h(this, "v");
|
|
174
|
+
h(this, "P");
|
|
175
|
+
h(this, "A", /* @__PURE__ */ new Map());
|
|
176
|
+
h(this, "U", /* @__PURE__ */ new Map());
|
|
177
|
+
h(this, "L", 0);
|
|
178
|
+
h(this, "H");
|
|
179
179
|
this.v = t, this.P = this.j(e, r), this.H = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.O();
|
|
180
180
|
}
|
|
181
181
|
O() {
|
|
@@ -252,10 +252,10 @@ class R {
|
|
|
252
252
|
}
|
|
253
253
|
class Q {
|
|
254
254
|
constructor(t) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
255
|
+
h(this, "v");
|
|
256
|
+
h(this, "Z", null);
|
|
257
|
+
h(this, "J", 16);
|
|
258
|
+
h(this, "K", /* @__PURE__ */ new Map());
|
|
259
259
|
this.v = t;
|
|
260
260
|
}
|
|
261
261
|
tt() {
|
|
@@ -268,11 +268,11 @@ class Q {
|
|
|
268
268
|
let r = this.K.get(e);
|
|
269
269
|
return r || (r = { a_position: t.getAttribLocation(e, "a_position"), a_texCoord: t.getAttribLocation(e, "a_texCoord") }, this.K.set(e, r)), t.enableVertexAttribArray(r.a_position), t.vertexAttribPointer(r.a_position, 2, t.FLOAT, !1, this.J, 0), t.enableVertexAttribArray(r.a_texCoord), t.vertexAttribPointer(r.a_texCoord, 2, t.FLOAT, !1, this.J, 8), { positionLoc: r.a_position, texLoc: r.a_texCoord };
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
rt(t, e) {
|
|
272
272
|
const r = this.v;
|
|
273
273
|
r.disableVertexAttribArray(t), r.disableVertexAttribArray(e);
|
|
274
274
|
}
|
|
275
|
-
|
|
275
|
+
st(t, e) {
|
|
276
276
|
const r = this.v, s = Z(r) || [0, 0, r.canvas.width, r.canvas.height];
|
|
277
277
|
return { nx: t / s[2] * 2 - 1, ny: 1 - e / s[3] * 2 };
|
|
278
278
|
}
|
|
@@ -291,10 +291,10 @@ class st extends Q {
|
|
|
291
291
|
super(t);
|
|
292
292
|
}
|
|
293
293
|
nt(t, e, r, s) {
|
|
294
|
-
const i = this.
|
|
294
|
+
const i = this.st(t, e), n = this.st(t + r, e + s);
|
|
295
295
|
this.it(i.nx, i.ny, n.nx, n.ny);
|
|
296
296
|
const o = this.et();
|
|
297
|
-
this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.
|
|
297
|
+
this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.rt(o.positionLoc, o.texLoc);
|
|
298
298
|
}
|
|
299
299
|
ot(t, e, r, s, i) {
|
|
300
300
|
this.nt(t, e, r, i), this.nt(t + r - i, e, i, s), this.nt(t, e + s - i, r, i), this.nt(t, e, i, s);
|
|
@@ -307,34 +307,34 @@ class it extends Q {
|
|
|
307
307
|
ht(t, e, r, s, i) {
|
|
308
308
|
const n = r - t, o = s - e, l = Math.hypot(n, o);
|
|
309
309
|
if (l === 0) {
|
|
310
|
-
const u = i / 2, f = this.
|
|
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 = -o / l, f = n / l, d = i / 2, v = t + u * d, p = e + f * d, g = t - u * d, C = e - f * d, m = r + u * d, b = s + f * d, T = r - u * d, E = s - f * d, A = this.
|
|
314
|
-
this.tt(),
|
|
315
|
-
const K = new Float32Array([A.nx, A.ny, 0, 0, F.nx, F.ny, 0, 1,
|
|
316
|
-
|
|
313
|
+
const u = -o / l, f = n / l, d = i / 2, v = t + u * d, p = e + f * d, g = t - u * d, C = e - f * d, m = r + u * d, b = s + f * d, T = r - u * d, E = s - f * d, A = this.st(v, p), F = this.st(g, C), U = this.st(m, b), V = this.st(T, E), S = this.v;
|
|
314
|
+
this.tt(), S.bindBuffer(S.ARRAY_BUFFER, this.Z);
|
|
315
|
+
const K = new Float32Array([A.nx, A.ny, 0, 0, F.nx, F.ny, 0, 1, U.nx, U.ny, 1, 0, F.nx, F.ny, 0, 1, V.nx, V.ny, 1, 1, U.nx, U.ny, 1, 0]);
|
|
316
|
+
S.bufferData(S.ARRAY_BUFFER, K, S.DYNAMIC_DRAW);
|
|
317
317
|
}
|
|
318
318
|
const c = this.et();
|
|
319
|
-
this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.
|
|
319
|
+
this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.rt(c.positionLoc, c.texLoc);
|
|
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
323
|
class nt {
|
|
324
324
|
constructor(t) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
325
|
+
h(this, "v");
|
|
326
|
+
h(this, "lt");
|
|
327
|
+
h(this, "ct");
|
|
328
|
+
h(this, "ut", null);
|
|
329
|
+
h(this, "ft");
|
|
330
|
+
h(this, "dt");
|
|
331
|
+
h(this, "gt", [1, 1, 1, 1]);
|
|
332
|
+
h(this, "_t", !0);
|
|
333
|
+
h(this, "vt", [0, 0, 0, 1]);
|
|
334
|
+
h(this, "xt", 1);
|
|
335
|
+
h(this, "bt", !0);
|
|
336
|
+
h(this, "wt", 0);
|
|
337
|
+
h(this, "Ct", []);
|
|
338
338
|
this.v = t, this.lt = new R(this.v, $, "precision lowp float;uniform sampler2D u_texture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(u_texture,v_uv);}"), this.ct = new R(this.v, $, "precision lowp float;uniform vec4 u_color;void main(){gl_FragColor=u_color;}"), this.ft = new st(this.v), this.dt = new it(this.v), this.v.enable(this.v.BLEND), this.v.blendEquation(this.v.FUNC_ADD), this.v.blendFunc(this.v.ONE, this.v.ONE_MINUS_SRC_ALPHA), I(this.v, [0, 0, this.v.canvas.width, this.v.canvas.height]);
|
|
339
339
|
}
|
|
340
340
|
yt(t) {
|
|
@@ -406,8 +406,8 @@ class nt {
|
|
|
406
406
|
if (this.ut !== null) {
|
|
407
407
|
const g = (t + r) / 2, C = (e + s) / 2, m = Math.abs(r - t) || 1, b = Math.abs(s - e) || 1, { centerX: T, centerY: E, radians: A, aspectRatio: F } = this.Pt(g - m / 2, C - b / 2, m, b);
|
|
408
408
|
this.Et("u_rotation", A), this.Et("u_center", [T, E]), this.Et("u_aspectRatio", F);
|
|
409
|
-
const
|
|
410
|
-
return this.dt.ht(t, e, r, s,
|
|
409
|
+
const U = this.xt > 0 ? this.xt : 1;
|
|
410
|
+
return this.dt.ht(t, e, r, s, U), void (this.ut = null);
|
|
411
411
|
}
|
|
412
412
|
if (!this.bt || this.xt <= 0) return;
|
|
413
413
|
const i = this.ct, n = (t + r) / 2, o = (e + s) / 2, l = Math.abs(r - t) || 1, c = Math.abs(s - e) || 1, u = this.wt !== 0;
|
|
@@ -447,104 +447,104 @@ class nt {
|
|
|
447
447
|
this.Et("u_rotation", c.radians), this.Et("u_center", [c.centerX, c.centerY]), this.Et("u_aspectRatio", c.aspectRatio), this.ft.nt(e, r, o, l), n.bindTexture(n.TEXTURE_2D, null), this.ut = null;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
-
const y = { readShort: (
|
|
450
|
+
const y = { readShort: (a, t) => (y.t.uint16[0] = a[t] << 8 | a[t + 1], y.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
|
|
451
451
|
const r = [];
|
|
452
|
-
for (let s = 0; s < e; s++) r.push(y.readUshort(
|
|
452
|
+
for (let s = 0; s < e; s++) r.push(y.readUshort(a, t + 2 * s));
|
|
453
453
|
return r;
|
|
454
|
-
}, readUint(
|
|
454
|
+
}, readUint(a, t) {
|
|
455
455
|
const e = y.t.uint8;
|
|
456
|
-
return e[3] =
|
|
457
|
-
}, readASCII(
|
|
456
|
+
return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], y.t.uint32[0];
|
|
457
|
+
}, readASCII(a, t, e) {
|
|
458
458
|
let r = "";
|
|
459
|
-
for (let s = 0; s < e; s++) r += String.fromCharCode(
|
|
459
|
+
for (let s = 0; s < e; s++) r += String.fromCharCode(a[t + s]);
|
|
460
460
|
return r;
|
|
461
461
|
}, t: (() => {
|
|
462
|
-
const
|
|
463
|
-
return { uint8: new Uint8Array(
|
|
464
|
-
})() }, ot = { parseTab(
|
|
462
|
+
const a = new ArrayBuffer(8);
|
|
463
|
+
return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
|
|
464
|
+
})() }, ot = { parseTab(a, t, e) {
|
|
465
465
|
const r = { tables: [], ids: {}, off: t };
|
|
466
|
-
|
|
467
|
-
const s = y, i = s.readUshort, n = i(
|
|
466
|
+
a = new Uint8Array(a.buffer, t, e), t = 0;
|
|
467
|
+
const s = y, i = s.readUshort, n = i(a, t += 2);
|
|
468
468
|
t += 2;
|
|
469
469
|
const o = [];
|
|
470
470
|
for (let l = 0; l < n; l++) {
|
|
471
|
-
const c = i(
|
|
471
|
+
const c = i(a, t), u = i(a, t += 2);
|
|
472
472
|
t += 2;
|
|
473
|
-
const f = s.readUint(
|
|
473
|
+
const f = s.readUint(a, t);
|
|
474
474
|
t += 4;
|
|
475
475
|
const d = `p${c}e${u}`;
|
|
476
476
|
let v = o.indexOf(f);
|
|
477
477
|
if (v === -1) {
|
|
478
478
|
let p;
|
|
479
479
|
v = r.tables.length, o.push(f);
|
|
480
|
-
const g = i(
|
|
481
|
-
p = g === 4 ? this.parse4(
|
|
480
|
+
const g = i(a, f);
|
|
481
|
+
p = g === 4 ? this.parse4(a, f) : g === 12 ? this.parse12(a, f) : { format: g }, r.tables.push(p);
|
|
482
482
|
}
|
|
483
483
|
r.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), r.ids[d] = v;
|
|
484
484
|
}
|
|
485
485
|
return r;
|
|
486
|
-
}, parse4(
|
|
487
|
-
const e = y, r = e.readUshort, s = e.readUshorts, i = t, n = r(
|
|
486
|
+
}, parse4(a, t) {
|
|
487
|
+
const e = y, r = e.readUshort, s = e.readUshorts, i = t, n = r(a, t += 2);
|
|
488
488
|
t += 2;
|
|
489
|
-
const o = r(
|
|
490
|
-
t += 2, l.entrySelector = r(
|
|
491
|
-
for (let c = 0; c < o; c++) l.idDelta.push(e.readShort(
|
|
492
|
-
return l.idRangeOffset = s(
|
|
493
|
-
}, parse12(
|
|
489
|
+
const o = r(a, t += 2) >>> 1, l = { format: 4, searchRange: r(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
|
|
490
|
+
t += 2, l.entrySelector = r(a, t), t += 2, l.rangeShift = r(a, t), t += 2, l.endCount = s(a, t, o), t += 2 * o, t += 2, l.startCount = s(a, t, o), t += 2 * o;
|
|
491
|
+
for (let c = 0; c < o; c++) l.idDelta.push(e.readShort(a, t)), t += 2;
|
|
492
|
+
return l.idRangeOffset = s(a, t, o), t += 2 * o, l.glyphIdArray = s(a, t, i + n - t >> 1), l;
|
|
493
|
+
}, parse12(a, t) {
|
|
494
494
|
const e = y.readUint;
|
|
495
|
-
e(
|
|
496
|
-
const r = e(
|
|
495
|
+
e(a, t += 4), e(a, t += 4);
|
|
496
|
+
const r = e(a, t += 4);
|
|
497
497
|
t += 4;
|
|
498
498
|
const s = new Uint32Array(3 * r);
|
|
499
|
-
for (let i = 0; i < 3 * r; i += 3) s[i] = e(
|
|
499
|
+
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
500
|
return { format: 12, groups: s };
|
|
501
|
-
} },
|
|
501
|
+
} }, at = { parseTab(a, t, e) {
|
|
502
502
|
const r = y;
|
|
503
503
|
t += 18;
|
|
504
|
-
const s = r.readUshort(
|
|
504
|
+
const s = r.readUshort(a, t);
|
|
505
505
|
t += 2, t += 16;
|
|
506
|
-
const i = r.readShort(
|
|
506
|
+
const i = r.readShort(a, t);
|
|
507
507
|
t += 2;
|
|
508
|
-
const n = r.readShort(
|
|
508
|
+
const n = r.readShort(a, t);
|
|
509
509
|
t += 2;
|
|
510
|
-
const o = r.readShort(
|
|
510
|
+
const o = r.readShort(a, t);
|
|
511
511
|
t += 2;
|
|
512
|
-
const l = r.readShort(
|
|
513
|
-
return t += 2, t += 6, { unitsPerEm: s, xMin: i, yMin: n, xMax: o, yMax: l, indexToLocFormat: r.readShort(
|
|
514
|
-
} },
|
|
512
|
+
const l = r.readShort(a, t);
|
|
513
|
+
return t += 2, t += 6, { unitsPerEm: s, xMin: i, yMin: n, xMax: o, yMax: l, indexToLocFormat: r.readShort(a, t) };
|
|
514
|
+
} }, ht = { parseTab(a, t, e) {
|
|
515
515
|
const r = y;
|
|
516
516
|
t += 4;
|
|
517
517
|
const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], i = {};
|
|
518
518
|
for (let n = 0; n < s.length; n++) {
|
|
519
519
|
const o = s[n], l = o === "advanceWidthMax" || o === "numberOfHMetrics" ? r.readUshort : r.readShort;
|
|
520
|
-
i[o] = l(
|
|
520
|
+
i[o] = l(a, t + 2 * n);
|
|
521
521
|
}
|
|
522
522
|
return i;
|
|
523
|
-
} }, lt = { parseTab(
|
|
523
|
+
} }, lt = { parseTab(a, t, e, r) {
|
|
524
524
|
if (!r) throw Error("Font object required for hmtx parsing");
|
|
525
525
|
const s = y, i = [], n = [], o = r.maxp.numGlyphs, l = r.hhea.numberOfHMetrics;
|
|
526
526
|
let c = 0, u = 0, f = 0;
|
|
527
|
-
for (; f < l; ) c = s.readUshort(
|
|
527
|
+
for (; f < l; ) c = s.readUshort(a, t + (f << 2)), u = s.readShort(a, t + (f << 2) + 2), i.push(c), n.push(u), f++;
|
|
528
528
|
for (; f < o; ) i.push(c), n.push(u), f++;
|
|
529
529
|
return { aWidth: i, lsBearing: n };
|
|
530
|
-
} }, O = { cmap: ot, head:
|
|
530
|
+
} }, O = { cmap: ot, head: at, hhea: ht, maxp: { parseTab(a, t, e) {
|
|
531
531
|
const r = y;
|
|
532
|
-
return r.readUint(
|
|
533
|
-
} }, hmtx: lt, loca: { parseTab(
|
|
532
|
+
return r.readUint(a, t), t += 4, { numGlyphs: r.readUshort(a, t) };
|
|
533
|
+
} }, hmtx: lt, loca: { parseTab(a, t, e, r) {
|
|
534
534
|
if (!r) throw Error("Font object required for loca parsing");
|
|
535
535
|
const s = y, i = [], n = r.head.indexToLocFormat, o = r.maxp.numGlyphs + 1;
|
|
536
|
-
if (n === 0) for (let l = 0; l < o; l++) i.push(s.readUshort(
|
|
537
|
-
else if (n === 1) for (let l = 0; l < o; l++) i.push(s.readUint(
|
|
536
|
+
if (n === 0) for (let l = 0; l < o; l++) i.push(s.readUshort(a, t + (l << 1)) << 1);
|
|
537
|
+
else if (n === 1) for (let l = 0; l < o; l++) i.push(s.readUint(a, t + (l << 2)));
|
|
538
538
|
return i;
|
|
539
|
-
} }, glyf: { parseTab(
|
|
539
|
+
} }, glyf: { parseTab(a, t, e, r) {
|
|
540
540
|
if (!r) throw Error("Font object required for glyf parsing");
|
|
541
541
|
const s = [], i = r.maxp.numGlyphs;
|
|
542
542
|
for (let n = 0; n < i; n++) s.push(null);
|
|
543
543
|
return s;
|
|
544
|
-
}, Ot(
|
|
545
|
-
const e = y, r =
|
|
544
|
+
}, Ot(a, t) {
|
|
545
|
+
const e = y, r = a.Wt, s = a.loca;
|
|
546
546
|
if (s[t] === s[t + 1]) return null;
|
|
547
|
-
const i = _.findTable(r, "glyf",
|
|
547
|
+
const i = _.findTable(r, "glyf", a.Nt);
|
|
548
548
|
if (!i) return null;
|
|
549
549
|
let n = i[0] + s[t];
|
|
550
550
|
const o = {};
|
|
@@ -579,7 +579,7 @@ const y = { readShort: (h, t) => (y.t.uint16[0] = h[t] << 8 | h[t + 1], y.t.int1
|
|
|
579
579
|
for (let d = 0; d < c; d++) u += o.xs[d], f += o.ys[d], o.xs[d] = u, o.ys[d] = f;
|
|
580
580
|
} else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
|
|
581
581
|
return o;
|
|
582
|
-
} } }, _ = { parse: (
|
|
582
|
+
} } }, _ = { parse: (a) => [((t, e, r, s) => {
|
|
583
583
|
const i = O, n = { Wt: t, Xt: e, Nt: r };
|
|
584
584
|
for (const o in i) {
|
|
585
585
|
const l = o, c = _.findTable(t, l, r);
|
|
@@ -590,13 +590,13 @@ const y = { readShort: (h, t) => (y.t.uint16[0] = h[t] << 8 | h[t + 1], y.t.int1
|
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
592
|
return n;
|
|
593
|
-
})(new Uint8Array(
|
|
594
|
-
const r = y, s = r.readUshort(
|
|
593
|
+
})(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
|
|
594
|
+
const r = y, s = r.readUshort(a, e + 4);
|
|
595
595
|
let i = e + 12;
|
|
596
596
|
for (let n = 0; n < s; n++) {
|
|
597
|
-
const o = r.readASCII(
|
|
598
|
-
r.readUint(
|
|
599
|
-
const l = r.readUint(
|
|
597
|
+
const o = r.readASCII(a, i, 4);
|
|
598
|
+
r.readUint(a, i + 4);
|
|
599
|
+
const l = r.readUint(a, i + 8), c = r.readUint(a, i + 12);
|
|
600
600
|
if (o === t) return [l, c];
|
|
601
601
|
i += 16;
|
|
602
602
|
}
|
|
@@ -604,8 +604,8 @@ const y = { readShort: (h, t) => (y.t.uint16[0] = h[t] << 8 | h[t + 1], y.t.int1
|
|
|
604
604
|
}, T: O, B: y };
|
|
605
605
|
class G {
|
|
606
606
|
constructor() {
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
h(this, "qt", /* @__PURE__ */ new Map());
|
|
608
|
+
h(this, "Yt", /* @__PURE__ */ new Map());
|
|
609
609
|
}
|
|
610
610
|
Qt(t) {
|
|
611
611
|
const e = this.Zt(t);
|
|
@@ -632,11 +632,11 @@ class G {
|
|
|
632
632
|
const r = e.codePointAt(0);
|
|
633
633
|
return r === void 0 ? 0 : this.Jt(t, r);
|
|
634
634
|
}
|
|
635
|
-
|
|
635
|
+
re(t, e) {
|
|
636
636
|
const r = t.hmtx;
|
|
637
637
|
return r && r.aWidth && r.aWidth.length !== 0 ? e < r.aWidth.length ? r.aWidth[e] : r.aWidth[r.aWidth.length - 1] : 0;
|
|
638
638
|
}
|
|
639
|
-
|
|
639
|
+
se(t, e) {
|
|
640
640
|
const r = e / t.head.unitsPerEm, s = t.hhea.ascender * r, i = t.hhea.descender * r, n = t.hhea.lineGap * r;
|
|
641
641
|
return { ascender: s, descender: i, lineGap: n, lineHeight: s - i + n, unitsPerEm: t.head.unitsPerEm, scale: r };
|
|
642
642
|
}
|
|
@@ -675,7 +675,7 @@ class G {
|
|
|
675
675
|
}
|
|
676
676
|
class ct {
|
|
677
677
|
constructor(t) {
|
|
678
|
-
|
|
678
|
+
h(this, "ne");
|
|
679
679
|
this.ne = t;
|
|
680
680
|
}
|
|
681
681
|
oe(t) {
|
|
@@ -752,7 +752,7 @@ class ct {
|
|
|
752
752
|
}
|
|
753
753
|
class ut {
|
|
754
754
|
constructor() {
|
|
755
|
-
|
|
755
|
+
h(this, "pe");
|
|
756
756
|
const t = new G();
|
|
757
757
|
this.pe = new ct(t);
|
|
758
758
|
}
|
|
@@ -771,10 +771,10 @@ class ut {
|
|
|
771
771
|
}
|
|
772
772
|
class dt {
|
|
773
773
|
constructor(t) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
774
|
+
h(this, "ge");
|
|
775
|
+
h(this, "_e");
|
|
776
|
+
h(this, "ve");
|
|
777
|
+
h(this, "xe");
|
|
778
778
|
this.ve = t, this.xe = new G(), this.ge = document.createElement("canvas"), this._e = this.ge.getContext("2d", { willReadFrequently: !0, alpha: !1 });
|
|
779
779
|
}
|
|
780
780
|
createTextureAtlas(t, e, r, s) {
|
|
@@ -847,26 +847,26 @@ class dt {
|
|
|
847
847
|
}
|
|
848
848
|
class ft {
|
|
849
849
|
constructor() {
|
|
850
|
-
|
|
850
|
+
h(this, "ne");
|
|
851
851
|
this.ne = new G();
|
|
852
852
|
}
|
|
853
853
|
calculateMaxGlyphDimensions(t, e, r) {
|
|
854
854
|
let s = 0;
|
|
855
|
-
const i = this.ne.
|
|
855
|
+
const i = this.ne.se(r, e), n = i.lineHeight;
|
|
856
856
|
for (const o of t) {
|
|
857
857
|
const l = this.ne.ee(r, o);
|
|
858
858
|
if (l === 0) continue;
|
|
859
|
-
const c = this.ne.
|
|
859
|
+
const c = this.ne.re(r, l) * i.scale;
|
|
860
860
|
s = Math.max(s, c);
|
|
861
861
|
}
|
|
862
862
|
return { width: Math.ceil(s), height: Math.ceil(n) };
|
|
863
863
|
}
|
|
864
864
|
getCharacterAdvanceWidth(t, e, r) {
|
|
865
|
-
const s = this.ne.
|
|
866
|
-
return this.ne.
|
|
865
|
+
const s = this.ne.se(r, e), i = this.ne.ee(r, t);
|
|
866
|
+
return this.ne.re(r, i) * s.scale;
|
|
867
867
|
}
|
|
868
868
|
getFontMetrics(t, e) {
|
|
869
|
-
return this.ne.
|
|
869
|
+
return this.ne.se(e, t);
|
|
870
870
|
}
|
|
871
871
|
ie() {
|
|
872
872
|
this.ne.ie();
|
|
@@ -874,7 +874,7 @@ class ft {
|
|
|
874
874
|
}
|
|
875
875
|
class gt {
|
|
876
876
|
constructor() {
|
|
877
|
-
|
|
877
|
+
h(this, "xe");
|
|
878
878
|
this.xe = new G();
|
|
879
879
|
}
|
|
880
880
|
createCharacterObjects(t, e) {
|
|
@@ -902,19 +902,19 @@ class gt {
|
|
|
902
902
|
}
|
|
903
903
|
class pt {
|
|
904
904
|
constructor(t, e = 16) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
905
|
+
h(this, "Te");
|
|
906
|
+
h(this, "Me", []);
|
|
907
|
+
h(this, "De");
|
|
908
|
+
h(this, "Se", 16);
|
|
909
|
+
h(this, "Re", 0);
|
|
910
|
+
h(this, "Ve", 0);
|
|
911
|
+
h(this, "ke", { width: 0, height: 0 });
|
|
912
|
+
h(this, "Ie");
|
|
913
|
+
h(this, "ze", "UrsaFont");
|
|
914
|
+
h(this, "Ee");
|
|
915
|
+
h(this, "Ge");
|
|
916
|
+
h(this, "Pe");
|
|
917
|
+
h(this, "Ae");
|
|
918
918
|
this.Se = e, this.Ee = new ut(), this.Ge = new dt(t), this.Pe = new ft(), this.Ae = new gt();
|
|
919
919
|
}
|
|
920
920
|
async Ue(t) {
|
|
@@ -995,16 +995,16 @@ class pt {
|
|
|
995
995
|
}
|
|
996
996
|
class vt {
|
|
997
997
|
constructor(t, e, r) {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
998
|
+
h(this, "Oe");
|
|
999
|
+
h(this, "We");
|
|
1000
|
+
h(this, "F");
|
|
1001
|
+
h(this, "M");
|
|
1002
|
+
h(this, "Ne");
|
|
1003
|
+
h(this, "Xe");
|
|
1004
|
+
h(this, "qe", !1);
|
|
1005
|
+
h(this, "Ye");
|
|
1006
|
+
h(this, "Qe");
|
|
1007
|
+
h(this, "Ze");
|
|
1008
1008
|
this.Ye = t, this.Qe = e, this.Ze = r, this.kt();
|
|
1009
1009
|
}
|
|
1010
1010
|
kt() {
|
|
@@ -1016,16 +1016,16 @@ class vt {
|
|
|
1016
1016
|
Ke(t, e) {
|
|
1017
1017
|
this.Qe = t, this.Ze = e, this.kt();
|
|
1018
1018
|
}
|
|
1019
|
-
|
|
1019
|
+
tr(t, e) {
|
|
1020
1020
|
this.qe = !0, this.Oe = t, this.We = e, this.Je();
|
|
1021
1021
|
}
|
|
1022
|
-
|
|
1022
|
+
er() {
|
|
1023
1023
|
this.qe = !1, this.kt();
|
|
1024
1024
|
}
|
|
1025
|
-
|
|
1025
|
+
rr() {
|
|
1026
1026
|
this.qe ? this.Je() : this.kt();
|
|
1027
1027
|
}
|
|
1028
|
-
|
|
1028
|
+
sr(t) {
|
|
1029
1029
|
if (t === void 0) return this.qe;
|
|
1030
1030
|
this.qe = t;
|
|
1031
1031
|
}
|
|
@@ -1056,66 +1056,66 @@ class vt {
|
|
|
1056
1056
|
}
|
|
1057
1057
|
class mt {
|
|
1058
1058
|
constructor(t, e = !1, r = {}) {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
this.
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1059
|
+
h(this, "Ye");
|
|
1060
|
+
h(this, "ir");
|
|
1061
|
+
h(this, "nr");
|
|
1062
|
+
h(this, "ar");
|
|
1063
|
+
h(this, "onTransformChange");
|
|
1064
|
+
this.ir = t, this.nr = e, this.Ye = this.hr(r.width, r.height), e && this.setupTransformObserver();
|
|
1065
|
+
}
|
|
1066
|
+
hr(t, e) {
|
|
1067
1067
|
var s;
|
|
1068
1068
|
const r = document.createElement("canvas");
|
|
1069
|
-
if (r.className = "textmodeCanvas", r.style.imageRendering = "pixelated", this.
|
|
1069
|
+
if (r.className = "textmodeCanvas", r.style.imageRendering = "pixelated", this.nr) r.width = t || 800, r.height = e || 600, document.body.appendChild(r);
|
|
1070
1070
|
else {
|
|
1071
|
-
const i = this.
|
|
1071
|
+
const i = this.ir.getBoundingClientRect();
|
|
1072
1072
|
let n = Math.round(i.width), o = Math.round(i.height);
|
|
1073
|
-
if (this.
|
|
1074
|
-
const u = this.
|
|
1073
|
+
if (this.ir instanceof HTMLVideoElement) {
|
|
1074
|
+
const u = this.ir;
|
|
1075
1075
|
(n === 0 || o === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (n = u.videoWidth, o = u.videoHeight);
|
|
1076
1076
|
}
|
|
1077
1077
|
r.width = n, r.height = o, r.style.position = "absolute", r.style.pointerEvents = "none";
|
|
1078
|
-
const l = window.getComputedStyle(this.
|
|
1078
|
+
const l = window.getComputedStyle(this.ir);
|
|
1079
1079
|
let c = parseInt(l.zIndex || "0", 10);
|
|
1080
|
-
isNaN(c) && (c = 0), r.style.zIndex = "" + (c + 1), this.
|
|
1080
|
+
isNaN(c) && (c = 0), r.style.zIndex = "" + (c + 1), this.lr(r), (s = this.ir.parentNode) == null || s.insertBefore(r, this.ir.nextSibling);
|
|
1081
1081
|
}
|
|
1082
1082
|
return r;
|
|
1083
1083
|
}
|
|
1084
|
-
|
|
1085
|
-
const e = this.
|
|
1086
|
-
let r = this.
|
|
1084
|
+
lr(t) {
|
|
1085
|
+
const e = this.ir.getBoundingClientRect();
|
|
1086
|
+
let r = this.ir.offsetParent;
|
|
1087
1087
|
if (r && r !== document.body) {
|
|
1088
1088
|
const s = r.getBoundingClientRect();
|
|
1089
1089
|
t.style.top = e.top - s.top + "px", t.style.left = e.left - s.left + "px";
|
|
1090
1090
|
} else t.style.top = e.top + window.scrollY + "px", t.style.left = e.left + window.scrollX + "px";
|
|
1091
1091
|
}
|
|
1092
|
-
|
|
1093
|
-
if (this.
|
|
1092
|
+
rr(t, e) {
|
|
1093
|
+
if (this.nr) this.Ye.width = t ?? this.Ye.width, this.Ye.height = e ?? this.Ye.height;
|
|
1094
1094
|
else {
|
|
1095
|
-
const r = this.
|
|
1095
|
+
const r = this.ir.getBoundingClientRect();
|
|
1096
1096
|
let s = Math.round(r.width), i = Math.round(r.height);
|
|
1097
|
-
if (this.
|
|
1098
|
-
const n = this.
|
|
1097
|
+
if (this.ir instanceof HTMLVideoElement) {
|
|
1098
|
+
const n = this.ir;
|
|
1099
1099
|
(s === 0 || i === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (s = n.videoWidth, i = n.videoHeight);
|
|
1100
1100
|
}
|
|
1101
|
-
this.Ye.width = s, this.Ye.height = i, this.
|
|
1101
|
+
this.Ye.width = s, this.Ye.height = i, this.lr(this.Ye);
|
|
1102
1102
|
}
|
|
1103
1103
|
}
|
|
1104
|
-
|
|
1104
|
+
cr() {
|
|
1105
1105
|
const t = { alpha: !1, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" }, e = this.Ye.getContext("webgl2", t) || this.Ye.getContext("webgl", t);
|
|
1106
1106
|
if (!e) throw new w("WebGL context could not be created. Ensure your browser supports WebGL.");
|
|
1107
1107
|
return e;
|
|
1108
1108
|
}
|
|
1109
1109
|
setupTransformObserver() {
|
|
1110
|
-
this.
|
|
1110
|
+
this.ar = new ResizeObserver((t) => {
|
|
1111
1111
|
for (const e of t) {
|
|
1112
1112
|
const r = e.contentRect;
|
|
1113
1113
|
!this.onTransformChange || Math.round(r.width) === this.Ye.width && Math.round(r.height) === this.Ye.height || this.onTransformChange();
|
|
1114
1114
|
}
|
|
1115
|
-
}), this.
|
|
1115
|
+
}), this.ar.observe(this.Ye);
|
|
1116
1116
|
}
|
|
1117
1117
|
G() {
|
|
1118
|
-
this.
|
|
1118
|
+
this.ar && this.ar.disconnect();
|
|
1119
1119
|
const t = this.Ye.getContext("webgl") || this.Ye.getContext("webgl2");
|
|
1120
1120
|
if (t) {
|
|
1121
1121
|
const e = t.getExtension("WEBGL_lose_context");
|
|
@@ -1133,24 +1133,24 @@ class mt {
|
|
|
1133
1133
|
return this.Ye.height;
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
|
-
class
|
|
1136
|
+
class D {
|
|
1137
1137
|
constructor(t, e, r, s = {}) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
this.ve = t, this.
|
|
1148
|
-
const i = this.
|
|
1149
|
-
this.
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
const t = this.
|
|
1153
|
-
this.
|
|
1138
|
+
h(this, "ve");
|
|
1139
|
+
h(this, "ur");
|
|
1140
|
+
h(this, "dr");
|
|
1141
|
+
h(this, "mr");
|
|
1142
|
+
h(this, "pr");
|
|
1143
|
+
h(this, "gr");
|
|
1144
|
+
h(this, "_r");
|
|
1145
|
+
h(this, "vr");
|
|
1146
|
+
h(this, "l");
|
|
1147
|
+
this.ve = t, this.ur = e, this.dr = r, this.l = s;
|
|
1148
|
+
const i = this.dr.cols, n = this.dr.rows;
|
|
1149
|
+
this.mr = this.ve.Ut(i, n), this.pr = this.ve.Ut(i, n), this.gr = this.ve.Ut(i, n), this._r = this.ve.Ut(i, n), this.vr = this.ve.Ut(i, n);
|
|
1150
|
+
}
|
|
1151
|
+
rr() {
|
|
1152
|
+
const t = this.dr.cols, e = this.dr.rows;
|
|
1153
|
+
this.mr.resize(t, e), this.pr.resize(t, e), this.gr.resize(t, e), this._r.resize(t, e), this.vr.resize(t, e);
|
|
1154
1154
|
}
|
|
1155
1155
|
enabled(t) {
|
|
1156
1156
|
x.p(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);
|
|
@@ -1162,22 +1162,22 @@ class U {
|
|
|
1162
1162
|
this.enabled(!1);
|
|
1163
1163
|
}
|
|
1164
1164
|
G() {
|
|
1165
|
-
this.
|
|
1165
|
+
this.mr.G(), this.pr.G(), this.gr.G(), this._r.G(), this.vr.G();
|
|
1166
1166
|
}
|
|
1167
1167
|
get characterFramebuffer() {
|
|
1168
|
-
return this.
|
|
1168
|
+
return this.mr;
|
|
1169
1169
|
}
|
|
1170
1170
|
get primaryColorFramebuffer() {
|
|
1171
|
-
return this.
|
|
1171
|
+
return this.pr;
|
|
1172
1172
|
}
|
|
1173
1173
|
get secondaryColorFramebuffer() {
|
|
1174
|
-
return this.
|
|
1174
|
+
return this.gr;
|
|
1175
1175
|
}
|
|
1176
1176
|
get rotationFramebuffer() {
|
|
1177
|
-
return this.
|
|
1177
|
+
return this._r;
|
|
1178
1178
|
}
|
|
1179
1179
|
get transformFramebuffer() {
|
|
1180
|
-
return this.
|
|
1180
|
+
return this.vr;
|
|
1181
1181
|
}
|
|
1182
1182
|
get options() {
|
|
1183
1183
|
return this.l;
|
|
@@ -1185,28 +1185,28 @@ class U {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
class xt {
|
|
1187
1187
|
constructor(t, e) {
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
this.ve = t, this.
|
|
1192
|
-
const r = Math.max(this.
|
|
1193
|
-
this.C = this.ve.Ut(r, 1), this
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
const t = this.
|
|
1188
|
+
h(this, "C");
|
|
1189
|
+
h(this, "ve");
|
|
1190
|
+
h(this, "br");
|
|
1191
|
+
this.ve = t, this.br = e;
|
|
1192
|
+
const r = Math.max(this.br.length, 1);
|
|
1193
|
+
this.C = this.ve.Ut(r, 1), this.wr();
|
|
1194
|
+
}
|
|
1195
|
+
wr() {
|
|
1196
|
+
const t = this.br.length;
|
|
1197
1197
|
this.C.width !== t && this.C.resize(t, 1);
|
|
1198
1198
|
const e = new Uint8Array(1 * t * 4);
|
|
1199
1199
|
for (let r = 0; r < t; r++) {
|
|
1200
|
-
const s = this.
|
|
1200
|
+
const s = this.br[r], i = 4 * r;
|
|
1201
1201
|
e[i] = s[0], e[i + 1] = s[1], e[i + 2] = s[2], e[i + 3] = 255;
|
|
1202
1202
|
}
|
|
1203
1203
|
this.C.updatePixels(e, t, 1);
|
|
1204
1204
|
}
|
|
1205
1205
|
setColors(t) {
|
|
1206
|
-
this.
|
|
1206
|
+
this.br = t, this.wr();
|
|
1207
1207
|
}
|
|
1208
1208
|
get colors() {
|
|
1209
|
-
return this.
|
|
1209
|
+
return this.br;
|
|
1210
1210
|
}
|
|
1211
1211
|
get framebuffer() {
|
|
1212
1212
|
return this.C;
|
|
@@ -1215,31 +1215,31 @@ class xt {
|
|
|
1215
1215
|
return this.C.texture;
|
|
1216
1216
|
}
|
|
1217
1217
|
}
|
|
1218
|
-
class
|
|
1218
|
+
class Y extends D {
|
|
1219
1219
|
constructor(e, r, s, i = {}) {
|
|
1220
1220
|
super(e, r, s, i);
|
|
1221
|
-
|
|
1222
|
-
this.
|
|
1221
|
+
h(this, "Cr");
|
|
1222
|
+
this.Cr = new xt(this.ve, this.ur.getCharacterColors(" .:-=+*%@#"));
|
|
1223
1223
|
}
|
|
1224
1224
|
characters(e) {
|
|
1225
|
-
x.p(this.
|
|
1225
|
+
x.p(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
1226
|
}
|
|
1227
1227
|
characterColor(e, r, s, i = 255) {
|
|
1228
|
-
const n = this.
|
|
1228
|
+
const n = this.yr(e, "characterColor", r, s, i);
|
|
1229
1229
|
n && (this.l.characterColor = n);
|
|
1230
1230
|
}
|
|
1231
1231
|
characterColorMode(e) {
|
|
1232
|
-
this
|
|
1232
|
+
this.$r(e, "characterColorMode");
|
|
1233
1233
|
}
|
|
1234
1234
|
cellColor(e, r, s, i = 255) {
|
|
1235
|
-
const n = this.
|
|
1235
|
+
const n = this.yr(e, "cellColor", r, s, i);
|
|
1236
1236
|
n && (this.l.cellColor = n);
|
|
1237
1237
|
}
|
|
1238
1238
|
cellColorMode(e) {
|
|
1239
|
-
this
|
|
1239
|
+
this.$r(e, "cellColorMode");
|
|
1240
1240
|
}
|
|
1241
1241
|
invert(e) {
|
|
1242
|
-
this.
|
|
1242
|
+
this.Fr(e, "invert", "Invert");
|
|
1243
1243
|
}
|
|
1244
1244
|
rotation(e) {
|
|
1245
1245
|
if (!x.p(typeof e == "number", "Rotation angle must be a number.", { method: "rotation", providedValue: e })) return;
|
|
@@ -1248,31 +1248,31 @@ class L extends U {
|
|
|
1248
1248
|
this.l.rotation = [s, i, 0, 1];
|
|
1249
1249
|
}
|
|
1250
1250
|
flipHorizontally(e) {
|
|
1251
|
-
this.
|
|
1251
|
+
this.Fr(e, "flipHorizontally", "Flip horizontally");
|
|
1252
1252
|
}
|
|
1253
1253
|
flipVertically(e) {
|
|
1254
|
-
this.
|
|
1254
|
+
this.Fr(e, "flipVertically", "Flip vertically");
|
|
1255
1255
|
}
|
|
1256
|
-
|
|
1256
|
+
yr(e, r, s, i, n = 255) {
|
|
1257
1257
|
let o, l, c, u;
|
|
1258
1258
|
if (typeof e == "string") {
|
|
1259
|
-
const f = this.
|
|
1259
|
+
const f = this.Tr(e);
|
|
1260
1260
|
if (!f) return x.p(!1, "Invalid hex color format. Use '#FF0000', '#F00', 'FF0000', or 'F00'.", { method: r, providedValue: e }), null;
|
|
1261
1261
|
[o, l, c, u] = f;
|
|
1262
1262
|
} else if (o = e, l = s !== void 0 ? s : e, c = i !== void 0 ? i : e, u = n, !x.p([o, 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: o, g: l, b: c, a: u } })) return null;
|
|
1263
1263
|
return [o / 255, l / 255, c / 255, u / 255];
|
|
1264
1264
|
}
|
|
1265
|
-
|
|
1265
|
+
$r(e, r) {
|
|
1266
1266
|
x.p(["sampled", "fixed"].includes(e), "Invalid color mode. Must be 'sampled' or 'fixed'.", { method: r, providedValue: e }) && (this.l[r] = e);
|
|
1267
1267
|
}
|
|
1268
|
-
|
|
1268
|
+
Fr(e, r, s) {
|
|
1269
1269
|
x.p(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
1270
|
}
|
|
1271
|
-
|
|
1271
|
+
Tr(e) {
|
|
1272
1272
|
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
1273
|
}
|
|
1274
1274
|
}
|
|
1275
|
-
const
|
|
1275
|
+
const P = `attribute vec2 a_position;\r
|
|
1276
1276
|
attribute vec2 a_texCoord;\r
|
|
1277
1277
|
varying vec2 v_uv;\r
|
|
1278
1278
|
\r
|
|
@@ -1311,123 +1311,123 @@ void main() {\r
|
|
|
1311
1311
|
gl_Position = vec4(pos, 0.0, 1.0);\r
|
|
1312
1312
|
}\r
|
|
1313
1313
|
`, 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 B extends
|
|
1314
|
+
class B extends Y {
|
|
1315
1315
|
constructor(e, r, s) {
|
|
1316
1316
|
super(e, r, s, { ...bt });
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
this.
|
|
1317
|
+
h(this, "Mr");
|
|
1318
|
+
h(this, "Dr");
|
|
1319
|
+
h(this, "Sr");
|
|
1320
|
+
h(this, "Rr");
|
|
1321
|
+
h(this, "Vr");
|
|
1322
|
+
h(this, "kr");
|
|
1323
|
+
this.Mr = new R(e.context, P, "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, P, "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, P, "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, P, "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, P, "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.Ut(this.dr.cols, this.dr.rows);
|
|
1324
1324
|
}
|
|
1325
|
-
|
|
1326
|
-
const r = this.
|
|
1327
|
-
this.
|
|
1325
|
+
Ir(e) {
|
|
1326
|
+
const r = this.dr.cols, s = this.dr.rows;
|
|
1327
|
+
this.kr.begin(), this.ve.Ht(), 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.pr.begin(), this.ve.Ht(), 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.pr.end(), this.gr.begin(), this.ve.Ht(), 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.Ht(), 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.Ht(), 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.mr.begin(), this.ve.Ht(), 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.mr.end();
|
|
1328
1328
|
}
|
|
1329
|
-
|
|
1330
|
-
super.
|
|
1329
|
+
rr() {
|
|
1330
|
+
super.rr(), this.kr.resize(this.dr.cols, this.dr.rows);
|
|
1331
1331
|
}
|
|
1332
1332
|
brightnessRange(e) {
|
|
1333
1333
|
x.p(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
1334
|
}
|
|
1335
1335
|
}
|
|
1336
|
-
const
|
|
1336
|
+
const Yt = Object.freeze(Object.defineProperty({ __proto__: null, TextmodeBrightnessConverter: B, TextmodeConverter: D, TextmodeFeatureConverter: Y }, Symbol.toStringTag, { value: "Module" }));
|
|
1337
1337
|
class wt {
|
|
1338
1338
|
constructor(t, e, r) {
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
this.ve = t, this.Te = e, this.
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
for (const r of this.
|
|
1339
|
+
h(this, "ve");
|
|
1340
|
+
h(this, "Te");
|
|
1341
|
+
h(this, "dr");
|
|
1342
|
+
h(this, "zr");
|
|
1343
|
+
h(this, "Er");
|
|
1344
|
+
h(this, "Gr");
|
|
1345
|
+
h(this, "Pr");
|
|
1346
|
+
h(this, "Ar");
|
|
1347
|
+
h(this, "mr");
|
|
1348
|
+
h(this, "pr");
|
|
1349
|
+
h(this, "gr");
|
|
1350
|
+
h(this, "_r");
|
|
1351
|
+
h(this, "vr");
|
|
1352
|
+
this.ve = t, this.Te = e, this.dr = r, this.Ar = this.ve.It($, "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.Er = new B(t, e, r), this.Gr = new D(t, e, r), this.zr = [this.Er, this.Gr], this.mr = this.ve.Ut(r.cols, r.rows), this.pr = this.ve.Ut(r.cols, r.rows), this.gr = this.ve.Ut(r.cols, r.rows), this._r = this.ve.Ut(r.cols, r.rows), this.vr = this.ve.Ut(r.cols, r.rows), this.Pr = this.ve.Ut(this.dr.width, this.dr.height);
|
|
1353
|
+
}
|
|
1354
|
+
Ur(t) {
|
|
1355
|
+
for (const r of this.zr) r.options.enabled && r instanceof Y && r.Ir(t);
|
|
1356
1356
|
const e = (r, s) => {
|
|
1357
1357
|
r.begin(), this.ve.Ht();
|
|
1358
|
-
for (const i of this.
|
|
1358
|
+
for (const i of this.zr) i.options.enabled && this.ve.Bt(s(i), 0, 0);
|
|
1359
1359
|
r.end();
|
|
1360
1360
|
};
|
|
1361
|
-
e(this.
|
|
1361
|
+
e(this.mr, (r) => r.characterFramebuffer), e(this.pr, (r) => r.primaryColorFramebuffer), e(this.gr, (r) => r.secondaryColorFramebuffer), e(this._r, (r) => r.rotationFramebuffer), e(this.vr, (r) => r.transformFramebuffer), this.Pr.begin(), this.ve.Ht(), 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.mr.texture), this.ve.Et("u_primaryColorTexture", this.pr.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.Pr.width, this.Pr.height), this.Pr.end();
|
|
1362
1362
|
}
|
|
1363
1363
|
add(t) {
|
|
1364
1364
|
if (!x.p(t === "brightness" || t === "custom", 'Converter type must be either "brightness" or "custom".', { method: "add", providedValue: t })) return;
|
|
1365
1365
|
let e;
|
|
1366
|
-
return e = t === "brightness" ? new B(this.ve, this.Te, this.
|
|
1366
|
+
return e = t === "brightness" ? new B(this.ve, this.Te, this.dr) : new D(this.ve, this.Te, this.dr), this.zr.push(e), e;
|
|
1367
1367
|
}
|
|
1368
1368
|
remove(t) {
|
|
1369
|
-
if (!x.p(t instanceof
|
|
1370
|
-
const e = this.
|
|
1371
|
-
x.p(e !== -1, "Converter instance not found in pipeline.", { method: "remove", providedValue: t, convertersCount: this.
|
|
1369
|
+
if (!x.p(t instanceof D, "Parameter must be a TextmodeConverter instance.", { method: "remove", providedValue: t })) return;
|
|
1370
|
+
const e = this.zr.indexOf(t);
|
|
1371
|
+
x.p(e !== -1, "Converter instance not found in pipeline.", { method: "remove", providedValue: t, convertersCount: this.zr.length }) && this.zr.splice(e, 1);
|
|
1372
1372
|
}
|
|
1373
1373
|
swap(t, e) {
|
|
1374
1374
|
const r = (o, l) => {
|
|
1375
|
-
if (typeof o == "number") return x.p(Number.isInteger(o) && o >= 0 && o < this.
|
|
1376
|
-
if (o instanceof
|
|
1377
|
-
const c = this.
|
|
1378
|
-
return x.p(c !== -1, l + " converter instance not found in pipeline.", { method: "swap", providedValue: o, convertersCount: this.
|
|
1375
|
+
if (typeof o == "number") return x.p(Number.isInteger(o) && o >= 0 && o < this.zr.length, l + " index must be a valid integer within the converter array bounds.", { method: "swap", providedValue: o, convertersCount: this.zr.length }) ? o : null;
|
|
1376
|
+
if (o instanceof D) {
|
|
1377
|
+
const c = this.zr.indexOf(o);
|
|
1378
|
+
return x.p(c !== -1, l + " converter instance not found in pipeline.", { method: "swap", providedValue: o, convertersCount: this.zr.length }) ? c : null;
|
|
1379
1379
|
}
|
|
1380
1380
|
return x.p(!1, l + " parameter must be either an integer index or a TextmodeConverter instance.", { method: "swap", providedValue: o }), null;
|
|
1381
1381
|
}, s = r(t, "First"), i = r(e, "Second");
|
|
1382
1382
|
if (s === null || i === null || !x.p(s !== i, "Cannot swap a converter with itself.", { method: "swap", firstIndex: s, secondIndex: i })) return;
|
|
1383
|
-
const n = this.
|
|
1384
|
-
this.
|
|
1383
|
+
const n = this.zr[s];
|
|
1384
|
+
this.zr[s] = this.zr[i], this.zr[i] = n;
|
|
1385
1385
|
}
|
|
1386
|
-
|
|
1387
|
-
this.
|
|
1388
|
-
const t = this.
|
|
1389
|
-
this.
|
|
1390
|
-
for (const r of this.
|
|
1386
|
+
rr() {
|
|
1387
|
+
this.Pr.resize(this.dr.width, this.dr.height);
|
|
1388
|
+
const t = this.dr.cols, e = this.dr.rows;
|
|
1389
|
+
this.mr.resize(t, e), this.pr.resize(t, e), this.gr.resize(t, e), this._r.resize(t, e), this.vr.resize(t, e);
|
|
1390
|
+
for (const r of this.zr) r.rr();
|
|
1391
1391
|
}
|
|
1392
1392
|
hasEnabledConverters() {
|
|
1393
|
-
return this.
|
|
1393
|
+
return this.zr.some((t) => t.options.enabled);
|
|
1394
1394
|
}
|
|
1395
1395
|
disable() {
|
|
1396
|
-
for (const t of this.
|
|
1396
|
+
for (const t of this.zr) t.disable();
|
|
1397
1397
|
}
|
|
1398
1398
|
enable() {
|
|
1399
|
-
for (const t of this.
|
|
1399
|
+
for (const t of this.zr) t.enable();
|
|
1400
1400
|
}
|
|
1401
1401
|
G() {
|
|
1402
|
-
for (const t of this.
|
|
1403
|
-
this.
|
|
1402
|
+
for (const t of this.zr) t.G();
|
|
1403
|
+
this.mr.G(), this.pr.G(), this.gr.G(), this._r.G(), this.vr.G(), this.Pr.G(), this.Ar.G();
|
|
1404
1404
|
}
|
|
1405
1405
|
get texture() {
|
|
1406
|
-
return this.
|
|
1406
|
+
return this.Pr;
|
|
1407
1407
|
}
|
|
1408
1408
|
get characterFramebuffer() {
|
|
1409
|
-
return this.
|
|
1409
|
+
return this.mr;
|
|
1410
1410
|
}
|
|
1411
1411
|
get primaryColorFramebuffer() {
|
|
1412
|
-
return this.
|
|
1412
|
+
return this.pr;
|
|
1413
1413
|
}
|
|
1414
1414
|
get secondaryColorFramebuffer() {
|
|
1415
|
-
return this.
|
|
1415
|
+
return this.gr;
|
|
1416
1416
|
}
|
|
1417
1417
|
get rotationFramebuffer() {
|
|
1418
|
-
return this.
|
|
1418
|
+
return this._r;
|
|
1419
1419
|
}
|
|
1420
1420
|
get transformFramebuffer() {
|
|
1421
|
-
return this.
|
|
1421
|
+
return this.vr;
|
|
1422
1422
|
}
|
|
1423
1423
|
get brightness() {
|
|
1424
|
-
return this.
|
|
1424
|
+
return this.Er;
|
|
1425
1425
|
}
|
|
1426
1426
|
get custom() {
|
|
1427
|
-
return this.
|
|
1427
|
+
return this.Gr;
|
|
1428
1428
|
}
|
|
1429
1429
|
}
|
|
1430
|
-
const Ct = (
|
|
1430
|
+
const Ct = (a) => class extends a {
|
|
1431
1431
|
fill(t, e, r, s) {
|
|
1432
1432
|
this.ve.$t(t, e, r, s);
|
|
1433
1433
|
}
|
|
@@ -1479,72 +1479,75 @@ const Ct = (h) => class extends h {
|
|
|
1479
1479
|
clear() {
|
|
1480
1480
|
this.ve.Ht();
|
|
1481
1481
|
}
|
|
1482
|
+
createFramebuffer(t, e, r = {}) {
|
|
1483
|
+
return this.ve.Ut(t, e, r);
|
|
1484
|
+
}
|
|
1482
1485
|
};
|
|
1483
|
-
class
|
|
1484
|
-
|
|
1486
|
+
class z {
|
|
1487
|
+
Lr(t) {
|
|
1485
1488
|
const e = t.characterFramebuffer, r = t.primaryColorFramebuffer, s = t.secondaryColorFramebuffer, i = t.transformFramebuffer, n = t.rotationFramebuffer;
|
|
1486
1489
|
return e == null || e.loadPixels(), r == null || r.loadPixels(), s == null || s.loadPixels(), i == null || i.loadPixels(), n == null || n.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: (n == null ? void 0 : n.pixels) || new Uint8Array(0) };
|
|
1487
1490
|
}
|
|
1488
|
-
|
|
1491
|
+
Hr(t, e) {
|
|
1489
1492
|
return t[e] + (t[e + 1] << 8);
|
|
1490
1493
|
}
|
|
1491
|
-
|
|
1494
|
+
jr(t, e) {
|
|
1492
1495
|
return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
|
|
1493
1496
|
}
|
|
1494
1497
|
}
|
|
1495
|
-
class
|
|
1496
|
-
|
|
1498
|
+
class L {
|
|
1499
|
+
Br(t, e) {
|
|
1497
1500
|
return new Blob([t], { type: e });
|
|
1498
1501
|
}
|
|
1499
|
-
|
|
1502
|
+
Or(t, e, r) {
|
|
1500
1503
|
try {
|
|
1501
|
-
const s = this.
|
|
1504
|
+
const s = this.Br(t, r), i = URL.createObjectURL(s), n = document.createElement("a");
|
|
1502
1505
|
n.href = i, n.download = e, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(i);
|
|
1503
1506
|
} catch (s) {
|
|
1504
1507
|
throw console.error("Failed to download file:", s), Error("File download failed: " + (s instanceof Error ? s.message : "Unknown error"));
|
|
1505
1508
|
}
|
|
1506
1509
|
}
|
|
1507
|
-
|
|
1510
|
+
Wr() {
|
|
1508
1511
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
|
|
1509
1512
|
}
|
|
1510
|
-
|
|
1513
|
+
Nr() {
|
|
1511
1514
|
const t = /* @__PURE__ */ new Date();
|
|
1512
1515
|
return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
|
|
1513
1516
|
}
|
|
1514
|
-
|
|
1517
|
+
Xr(t) {
|
|
1515
1518
|
return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
|
|
1516
1519
|
}
|
|
1517
|
-
|
|
1518
|
-
return "'textmode-export'-" + this.
|
|
1520
|
+
qr() {
|
|
1521
|
+
return "'textmode-export'-" + this.Wr();
|
|
1519
1522
|
}
|
|
1520
1523
|
}
|
|
1521
|
-
class yt extends
|
|
1522
|
-
|
|
1524
|
+
class yt extends z {
|
|
1525
|
+
Yr(t, e, r) {
|
|
1523
1526
|
const s = t[r] === 255, i = t[r + 1] === 255, n = t[r + 2] === 255, o = e[r], l = e[r + 1];
|
|
1524
1527
|
return { isInverted: s, flipHorizontal: i, flipVertical: n, rotation: Math.round(360 * (o + l / 255) / 255 * 100) / 100 };
|
|
1525
1528
|
}
|
|
1526
|
-
|
|
1529
|
+
Qr(t, e, r) {
|
|
1527
1530
|
return { x: t, y: e, cellX: t * r.cellWidth, cellY: e * r.cellHeight };
|
|
1528
1531
|
}
|
|
1529
|
-
|
|
1532
|
+
Zr(t, e) {
|
|
1530
1533
|
const r = [];
|
|
1531
1534
|
let s = 0;
|
|
1532
1535
|
for (let i = 0; i < e.rows; i++) for (let n = 0; n < e.cols; n++) {
|
|
1533
|
-
const o = 4 * s, l = this.
|
|
1534
|
-
let c = this.
|
|
1535
|
-
const f = this.
|
|
1536
|
+
const o = 4 * s, l = this.Hr(t.characterPixels, o);
|
|
1537
|
+
let c = this.jr(t.primaryColorPixels, o), u = this.jr(t.secondaryColorPixels, o);
|
|
1538
|
+
const f = this.Yr(t.transformPixels, t.rotationPixels, o);
|
|
1536
1539
|
if (f.isInverted) {
|
|
1537
1540
|
const v = c;
|
|
1538
1541
|
c = u, u = v;
|
|
1539
1542
|
}
|
|
1540
|
-
const d = this.
|
|
1543
|
+
const d = this.Qr(n, i, e);
|
|
1541
1544
|
r.push({ charIndex: l, primaryColor: c, secondaryColor: u, transform: f, position: d }), s++;
|
|
1542
1545
|
}
|
|
1543
1546
|
return r;
|
|
1544
1547
|
}
|
|
1545
1548
|
}
|
|
1546
1549
|
class _t {
|
|
1547
|
-
|
|
1550
|
+
Jr(t, e) {
|
|
1548
1551
|
const r = t.cmap;
|
|
1549
1552
|
for (const s of r.tables) if (s.format === 4) {
|
|
1550
1553
|
for (let i = 0; i < s.startCount.length; i++) if (e >= s.startCount[i] && e <= s.endCount[i]) {
|
|
@@ -1560,11 +1563,11 @@ class _t {
|
|
|
1560
1563
|
}
|
|
1561
1564
|
return 0;
|
|
1562
1565
|
}
|
|
1563
|
-
|
|
1566
|
+
Kr(t, e, r, s, i) {
|
|
1564
1567
|
const n = i / t.head.unitsPerEm;
|
|
1565
|
-
return { getBoundingBox: () => ({ x1: r + e.xMin * n, y1: s + -e.yMax * n, x2: r + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.
|
|
1568
|
+
return { getBoundingBox: () => ({ x1: r + e.xMin * n, y1: s + -e.yMax * n, x2: r + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.ts(e, r, s, n) };
|
|
1566
1569
|
}
|
|
1567
|
-
|
|
1570
|
+
ts(t, e, r, s) {
|
|
1568
1571
|
if (!t || !t.xs) return "";
|
|
1569
1572
|
const { xs: i, ys: n, endPts: o, flags: l } = t;
|
|
1570
1573
|
if (!(i && n && o && l)) return "";
|
|
@@ -1598,22 +1601,22 @@ class _t {
|
|
|
1598
1601
|
}
|
|
1599
1602
|
return c;
|
|
1600
1603
|
}
|
|
1601
|
-
|
|
1602
|
-
const n = t.codePointAt(0) || 0, o = this.
|
|
1604
|
+
es(t, e, r, s, i) {
|
|
1605
|
+
const n = t.codePointAt(0) || 0, o = this.Jr(e, n);
|
|
1603
1606
|
let l = null;
|
|
1604
|
-
return e.glyf && e.glyf[o] !== null ? l = e.glyf[o] : _ && _.T && _.T.glyf && _.T.glyf.Ot && (l = _.T.glyf.Ot(e, o), e.glyf && l && (e.glyf[o] = l)), this.
|
|
1607
|
+
return e.glyf && e.glyf[o] !== null ? l = e.glyf[o] : _ && _.T && _.T.glyf && _.T.glyf.Ot && (l = _.T.glyf.Ot(e, o), e.glyf && l && (e.glyf[o] = l)), this.Kr(e, l, r, s, i);
|
|
1605
1608
|
}
|
|
1606
|
-
|
|
1609
|
+
rs(t, e, r, s, i, n, o, l) {
|
|
1607
1610
|
const c = r + (i - l * (o / e.head.unitsPerEm)) / 2, u = s + (n + 0.7 * o) / 2;
|
|
1608
|
-
return this.
|
|
1611
|
+
return this.es(t, e, c, u, o).toSVG() || null;
|
|
1609
1612
|
}
|
|
1610
1613
|
}
|
|
1611
1614
|
class Tt {
|
|
1612
1615
|
constructor() {
|
|
1613
|
-
|
|
1614
|
-
this.
|
|
1616
|
+
h(this, "ss");
|
|
1617
|
+
this.ss = new _t();
|
|
1615
1618
|
}
|
|
1616
|
-
|
|
1619
|
+
ns(t) {
|
|
1617
1620
|
return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
1618
1621
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
1619
1622
|
<svg width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}"
|
|
@@ -1621,21 +1624,21 @@ class Tt {
|
|
|
1621
1624
|
<title>textmode art generated via textmode.js</title>
|
|
1622
1625
|
<desc>textmode art visualization generated by textmode.js library</desc>`;
|
|
1623
1626
|
}
|
|
1624
|
-
|
|
1627
|
+
hs() {
|
|
1625
1628
|
return `
|
|
1626
1629
|
</g>
|
|
1627
1630
|
</svg>`;
|
|
1628
1631
|
}
|
|
1629
|
-
|
|
1632
|
+
ls(t, e) {
|
|
1630
1633
|
if (!e.includeBackgroundRectangles) return "";
|
|
1631
1634
|
const r = e.backgroundColor, s = `rgba(${r[0]},${r[1]},${r[2]},${r[3] / 255})`;
|
|
1632
1635
|
return `
|
|
1633
1636
|
<rect width="${t.width}" height="${t.height}" fill="${s}" />`;
|
|
1634
1637
|
}
|
|
1635
|
-
|
|
1638
|
+
cs(t) {
|
|
1636
1639
|
return `rgba(${t.r},${t.g},${t.b},${t.a / 255})`;
|
|
1637
1640
|
}
|
|
1638
|
-
|
|
1641
|
+
us(t, e) {
|
|
1639
1642
|
const { transform: r, position: s } = t, i = s.cellX + e.cellWidth / 2, n = s.cellY + e.cellHeight / 2, o = [];
|
|
1640
1643
|
if (r.flipHorizontal || r.flipVertical) {
|
|
1641
1644
|
const l = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
|
|
@@ -1643,82 +1646,82 @@ class Tt {
|
|
|
1643
1646
|
}
|
|
1644
1647
|
return r.rotation && o.push(`rotate(${r.rotation} ${i} ${n})`), o.length ? ` transform="${o.join(" ")}"` : "";
|
|
1645
1648
|
}
|
|
1646
|
-
|
|
1649
|
+
fs(t, e, r) {
|
|
1647
1650
|
if (!r.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
|
|
1648
|
-
const { position: s } = t, i = this.
|
|
1651
|
+
const { position: s } = t, i = this.cs(t.secondaryColor);
|
|
1649
1652
|
return r.drawMode === "stroke" ? `
|
|
1650
1653
|
<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${i}" fill="none" stroke-width="${r.strokeWidth}" />` : `
|
|
1651
1654
|
<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${i}" />`;
|
|
1652
1655
|
}
|
|
1653
|
-
|
|
1656
|
+
es(t, e, r, s) {
|
|
1654
1657
|
const i = r.characters[t.charIndex];
|
|
1655
1658
|
if (!i) return "";
|
|
1656
|
-
const n = this.
|
|
1659
|
+
const n = this.ss.rs(i.character, r.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.advanceWidth);
|
|
1657
1660
|
if (!n) return "";
|
|
1658
|
-
const o = this.
|
|
1661
|
+
const o = this.cs(t.primaryColor);
|
|
1659
1662
|
return s.drawMode === "stroke" ? `
|
|
1660
1663
|
<path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${n}" stroke="${o}" stroke-width="${s.strokeWidth}" fill="none" />` : `
|
|
1661
1664
|
<path d="${n}" fill="${o}" />`;
|
|
1662
1665
|
}
|
|
1663
|
-
|
|
1666
|
+
ds(t, e, r, s) {
|
|
1664
1667
|
let i = "";
|
|
1665
|
-
i += this.
|
|
1666
|
-
const n = this.
|
|
1668
|
+
i += this.fs(t, e, s);
|
|
1669
|
+
const n = this.us(t, e), o = this.es(t, e, r, s);
|
|
1667
1670
|
return o && (n ? (i += `
|
|
1668
1671
|
<g${n}>`, i += o, i += `
|
|
1669
1672
|
</g>`) : i += o), i;
|
|
1670
1673
|
}
|
|
1671
|
-
|
|
1672
|
-
let i = this.
|
|
1673
|
-
i += this.
|
|
1674
|
+
ps(t, e, r, s) {
|
|
1675
|
+
let i = this.ns(e);
|
|
1676
|
+
i += this.ls(e, s), i += `
|
|
1674
1677
|
<g id="ascii-cells">`;
|
|
1675
|
-
for (const n of t) i += this.
|
|
1676
|
-
return i += this.
|
|
1678
|
+
for (const n of t) i += this.ds(n, e, r, s);
|
|
1679
|
+
return i += this.hs(), i;
|
|
1677
1680
|
}
|
|
1678
|
-
|
|
1681
|
+
gs(t) {
|
|
1679
1682
|
return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\n\s*\n/g, `
|
|
1680
1683
|
`).replace(/[ \t]+$/gm, "");
|
|
1681
1684
|
}
|
|
1682
1685
|
}
|
|
1683
|
-
class Et extends
|
|
1684
|
-
|
|
1685
|
-
return this.
|
|
1686
|
+
class Et extends L {
|
|
1687
|
+
_s(t) {
|
|
1688
|
+
return this.Br(t, "image/svg+xml;charset=utf-8");
|
|
1686
1689
|
}
|
|
1687
|
-
|
|
1688
|
-
this.
|
|
1690
|
+
vs(t, e) {
|
|
1691
|
+
this.Or(t, this.Xr(e) + ".svg", "image/svg+xml;charset=utf-8");
|
|
1689
1692
|
}
|
|
1690
|
-
|
|
1691
|
-
this.
|
|
1693
|
+
bs(t, e) {
|
|
1694
|
+
this.vs(t, e || this.qr());
|
|
1692
1695
|
}
|
|
1693
1696
|
}
|
|
1694
|
-
class
|
|
1697
|
+
class W {
|
|
1695
1698
|
constructor() {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
this.
|
|
1699
|
+
h(this, "ws");
|
|
1700
|
+
h(this, "Cs");
|
|
1701
|
+
h(this, "$s");
|
|
1702
|
+
this.ws = new yt(), this.Cs = new Tt(), this.$s = new Et();
|
|
1700
1703
|
}
|
|
1701
|
-
|
|
1704
|
+
Fs(t) {
|
|
1702
1705
|
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0] };
|
|
1703
1706
|
}
|
|
1704
|
-
|
|
1705
|
-
const r = this.
|
|
1706
|
-
return this.
|
|
1707
|
+
Ts(t, e = {}) {
|
|
1708
|
+
const r = this.Fs(e), s = this.ws.Lr(t.pipeline), i = this.ws.Zr(s, t.grid), n = this.Cs.ps(i, t.grid, t.font, r);
|
|
1709
|
+
return this.Cs.gs(n);
|
|
1707
1710
|
}
|
|
1708
|
-
|
|
1709
|
-
const r = this.
|
|
1710
|
-
this.$
|
|
1711
|
+
bs(t, e = {}) {
|
|
1712
|
+
const r = this.Ts(t, e), s = e.filename || this.$s.qr();
|
|
1713
|
+
this.$s.bs(r, s);
|
|
1711
1714
|
}
|
|
1712
1715
|
}
|
|
1713
|
-
class Rt extends
|
|
1714
|
-
|
|
1716
|
+
class Rt extends z {
|
|
1717
|
+
Ms(t, e, r, s = " ") {
|
|
1715
1718
|
var o;
|
|
1716
1719
|
const i = [];
|
|
1717
1720
|
let n = 0;
|
|
1718
1721
|
for (let l = 0; l < e.rows; l++) {
|
|
1719
1722
|
const c = [];
|
|
1720
1723
|
for (let u = 0; u < e.cols; u++) {
|
|
1721
|
-
const f = 4 * n, d = this.
|
|
1724
|
+
const f = 4 * n, d = this.Hr(t.characterPixels, f), v = ((o = r.characters[d]) == null ? void 0 : o.character) || s;
|
|
1722
1725
|
c.push(v), n++;
|
|
1723
1726
|
}
|
|
1724
1727
|
i.push(c);
|
|
@@ -1727,7 +1730,7 @@ class Rt extends Y {
|
|
|
1727
1730
|
}
|
|
1728
1731
|
}
|
|
1729
1732
|
class Ft {
|
|
1730
|
-
|
|
1733
|
+
Ds(t, e) {
|
|
1731
1734
|
const r = [];
|
|
1732
1735
|
for (const i of t) {
|
|
1733
1736
|
let n = i.join("");
|
|
@@ -1739,57 +1742,57 @@ class Ft {
|
|
|
1739
1742
|
return r.join(s);
|
|
1740
1743
|
}
|
|
1741
1744
|
}
|
|
1742
|
-
class Mt extends
|
|
1743
|
-
|
|
1744
|
-
const r = this.
|
|
1745
|
-
this.
|
|
1745
|
+
class Mt extends L {
|
|
1746
|
+
Ss(t, e) {
|
|
1747
|
+
const r = this.Rs(e);
|
|
1748
|
+
this.Or(t, r, "text/plain;charset=utf-8");
|
|
1746
1749
|
}
|
|
1747
|
-
|
|
1748
|
-
let e = this.
|
|
1749
|
-
return e === ".txt" || e.length <= 4 ? this.
|
|
1750
|
+
Rs(t) {
|
|
1751
|
+
let e = this.Xr(t);
|
|
1752
|
+
return e === ".txt" || e.length <= 4 ? this.qr() : e;
|
|
1750
1753
|
}
|
|
1751
1754
|
}
|
|
1752
|
-
class
|
|
1755
|
+
class N {
|
|
1753
1756
|
constructor() {
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
this.
|
|
1757
|
+
h(this, "ws");
|
|
1758
|
+
h(this, "Cs");
|
|
1759
|
+
h(this, "$s");
|
|
1760
|
+
this.ws = new Rt(), this.Cs = new Ft(), this.$s = new Mt();
|
|
1758
1761
|
}
|
|
1759
|
-
|
|
1762
|
+
Fs(t) {
|
|
1760
1763
|
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " " };
|
|
1761
1764
|
}
|
|
1762
|
-
|
|
1763
|
-
const r = this.
|
|
1764
|
-
return this.
|
|
1765
|
+
Vs(t, e = {}) {
|
|
1766
|
+
const r = this.Fs(e), s = this.ws.Lr(t.pipeline), i = this.ws.Ms(s, t.grid, t.font, r.emptyCharacter);
|
|
1767
|
+
return this.Cs.Ds(i, r);
|
|
1765
1768
|
}
|
|
1766
|
-
|
|
1767
|
-
const r = this.
|
|
1768
|
-
this.$
|
|
1769
|
+
Ss(t, e = {}) {
|
|
1770
|
+
const r = this.Vs(t, e), s = e.filename || this.$s.qr();
|
|
1771
|
+
this.$s.Ss(r, s);
|
|
1769
1772
|
}
|
|
1770
1773
|
}
|
|
1771
|
-
class At extends
|
|
1772
|
-
|
|
1774
|
+
class At extends z {
|
|
1775
|
+
ks(t, e = 1, r = "transparent") {
|
|
1773
1776
|
const s = t.canvas;
|
|
1774
1777
|
if (e === 1 && r === "transparent") return s;
|
|
1775
1778
|
const i = document.createElement("canvas"), n = i.getContext("2d"), o = Math.round(s.width * e), l = Math.round(s.height * e);
|
|
1776
1779
|
return i.width = o, i.height = l, r !== "transparent" && (n.fillStyle = r, n.fillRect(0, 0, o, l)), n.imageSmoothingEnabled = !1, n.drawImage(s, 0, 0, s.width, s.height, 0, 0, o, l), i;
|
|
1777
1780
|
}
|
|
1778
1781
|
}
|
|
1779
|
-
class
|
|
1780
|
-
|
|
1781
|
-
const r = this.
|
|
1782
|
+
class Ut {
|
|
1783
|
+
Is(t, e) {
|
|
1784
|
+
const r = this.zs(e.format);
|
|
1782
1785
|
return e.format === "png" ? t.toDataURL(r) : t.toDataURL(r, e.quality);
|
|
1783
1786
|
}
|
|
1784
|
-
async
|
|
1787
|
+
async Es(t, e) {
|
|
1785
1788
|
return new Promise((r, s) => {
|
|
1786
|
-
const i = this.
|
|
1789
|
+
const i = this.zs(e.format), n = (o) => {
|
|
1787
1790
|
o ? r(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
|
|
1788
1791
|
};
|
|
1789
1792
|
e.format === "png" ? t.toBlob(n, i) : t.toBlob(n, i, e.quality);
|
|
1790
1793
|
});
|
|
1791
1794
|
}
|
|
1792
|
-
|
|
1795
|
+
zs(t) {
|
|
1793
1796
|
switch (t) {
|
|
1794
1797
|
case "png":
|
|
1795
1798
|
return "image/png";
|
|
@@ -1802,12 +1805,12 @@ class Pt {
|
|
|
1802
1805
|
}
|
|
1803
1806
|
}
|
|
1804
1807
|
}
|
|
1805
|
-
const
|
|
1806
|
-
class
|
|
1807
|
-
|
|
1808
|
-
this.
|
|
1808
|
+
const Dt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, j = { png: ".png", jpg: ".jpg", webp: ".webp" };
|
|
1809
|
+
class St extends L {
|
|
1810
|
+
Gs(t, e, r) {
|
|
1811
|
+
this.Ps(t, this.Xr(e) + j[r]);
|
|
1809
1812
|
}
|
|
1810
|
-
|
|
1813
|
+
Ps(t, e) {
|
|
1811
1814
|
const r = URL.createObjectURL(t);
|
|
1812
1815
|
try {
|
|
1813
1816
|
const s = document.createElement("a");
|
|
@@ -1816,87 +1819,87 @@ class Dt extends H {
|
|
|
1816
1819
|
URL.revokeObjectURL(r);
|
|
1817
1820
|
}
|
|
1818
1821
|
}
|
|
1819
|
-
|
|
1820
|
-
return t in
|
|
1822
|
+
As(t) {
|
|
1823
|
+
return t in Dt && t in j;
|
|
1821
1824
|
}
|
|
1822
1825
|
}
|
|
1823
|
-
class
|
|
1826
|
+
class Pt {
|
|
1824
1827
|
constructor() {
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
this.
|
|
1828
|
+
h(this, "ws");
|
|
1829
|
+
h(this, "Cs");
|
|
1830
|
+
h(this, "$s");
|
|
1831
|
+
this.ws = new At(), this.Cs = new Ut(), this.$s = new St();
|
|
1829
1832
|
}
|
|
1830
|
-
|
|
1833
|
+
Fs(t) {
|
|
1831
1834
|
return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent" };
|
|
1832
1835
|
}
|
|
1833
|
-
|
|
1834
|
-
if (console.log("Validating image export options:", t), !this.$
|
|
1836
|
+
Us(t) {
|
|
1837
|
+
if (console.log("Validating image export options:", t), !this.$s.As(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
|
|
1835
1838
|
if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
|
|
1836
1839
|
if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
|
|
1837
1840
|
t.scale > 10 && console.warn("Large scale factors may result in very large files and slow performance"), t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
|
|
1838
1841
|
}
|
|
1839
|
-
|
|
1840
|
-
const r = this.
|
|
1841
|
-
if (this.
|
|
1842
|
-
const s = this.
|
|
1843
|
-
return this.
|
|
1842
|
+
Ls(t, e = {}) {
|
|
1843
|
+
const r = this.Fs(e);
|
|
1844
|
+
if (this.Us(r), r.scale === 1 && r.backgroundColor === "transparent") return this.Cs.Is(t.canvas, r);
|
|
1845
|
+
const s = this.ws.ks(t, r.scale, r.backgroundColor);
|
|
1846
|
+
return this.Cs.Is(s, r);
|
|
1844
1847
|
}
|
|
1845
|
-
async
|
|
1846
|
-
const r = this.
|
|
1847
|
-
if (this.
|
|
1848
|
-
const s = this.
|
|
1849
|
-
return await this.
|
|
1848
|
+
async Es(t, e = {}) {
|
|
1849
|
+
const r = this.Fs(e);
|
|
1850
|
+
if (this.Us(r), r.scale === 1 && r.backgroundColor === "transparent") return await this.Cs.Es(t.canvas, r);
|
|
1851
|
+
const s = this.ws.ks(t, r.scale, r.backgroundColor);
|
|
1852
|
+
return await this.Cs.Es(s, r);
|
|
1850
1853
|
}
|
|
1851
|
-
async
|
|
1852
|
-
const r = await this.
|
|
1853
|
-
this.$
|
|
1854
|
+
async Gs(t, e = {}) {
|
|
1855
|
+
const r = await this.Es(t, e), s = e.format ?? "png", i = e.filename || this.$s.qr();
|
|
1856
|
+
this.$s.Gs(r, i, s);
|
|
1854
1857
|
}
|
|
1855
1858
|
}
|
|
1856
|
-
const $t = (
|
|
1859
|
+
const $t = (a) => class extends a {
|
|
1857
1860
|
toString(t = {}) {
|
|
1858
|
-
return new
|
|
1861
|
+
return new N().Vs({ pipeline: this.Hs, grid: this.dr, font: this.Te }, t);
|
|
1859
1862
|
}
|
|
1860
1863
|
saveStrings(t = {}) {
|
|
1861
|
-
new
|
|
1864
|
+
new N().Ss({ pipeline: this.Hs, grid: this.dr, font: this.Te }, t);
|
|
1862
1865
|
}
|
|
1863
1866
|
toSVG(t = {}) {
|
|
1864
|
-
return new
|
|
1867
|
+
return new W().Ts(this, t);
|
|
1865
1868
|
}
|
|
1866
1869
|
saveSVG(t = {}) {
|
|
1867
|
-
new
|
|
1870
|
+
new W().bs(this, t);
|
|
1868
1871
|
}
|
|
1869
1872
|
async saveCanvas(t, e = "png", r = {}) {
|
|
1870
|
-
await new
|
|
1873
|
+
await new Pt().Gs(this.Ye, { ...r, filename: t, format: e });
|
|
1871
1874
|
}
|
|
1872
|
-
}, It = (
|
|
1875
|
+
}, It = (a) => class extends a {
|
|
1873
1876
|
async loadFont(t) {
|
|
1874
1877
|
return this.Te.Be(t).then(() => {
|
|
1875
1878
|
const e = this.Te.maxGlyphDimensions;
|
|
1876
|
-
this.
|
|
1879
|
+
this.dr.Ke(e.width, e.height), this.Hs.rr();
|
|
1877
1880
|
});
|
|
1878
1881
|
}
|
|
1879
1882
|
fontSize(t) {
|
|
1880
1883
|
if (!x.p(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Te.fontSize === t) return;
|
|
1881
1884
|
this.Te.je(t);
|
|
1882
1885
|
const e = this.Te.maxGlyphDimensions;
|
|
1883
|
-
this.
|
|
1886
|
+
this.dr.Ke(e.width, e.height), this.Hs.rr(), this.ve.jt();
|
|
1884
1887
|
}
|
|
1885
|
-
}, Gt = (
|
|
1888
|
+
}, Gt = (a) => class extends a {
|
|
1886
1889
|
addConverter(t) {
|
|
1887
|
-
return this.
|
|
1890
|
+
return this.Hs.add(t);
|
|
1888
1891
|
}
|
|
1889
1892
|
removeConverter(t) {
|
|
1890
|
-
this.
|
|
1893
|
+
this.Hs.remove(t);
|
|
1891
1894
|
}
|
|
1892
1895
|
};
|
|
1893
1896
|
class kt {
|
|
1894
1897
|
constructor() {
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1898
|
+
h(this, "ve");
|
|
1899
|
+
h(this, "Te");
|
|
1900
|
+
h(this, "Hs");
|
|
1901
|
+
h(this, "Ye");
|
|
1902
|
+
h(this, "dr");
|
|
1900
1903
|
}
|
|
1901
1904
|
}
|
|
1902
1905
|
class X extends function(e, ...r) {
|
|
@@ -1904,120 +1907,120 @@ class X extends function(e, ...r) {
|
|
|
1904
1907
|
}(kt, Ct, $t, It, Gt) {
|
|
1905
1908
|
constructor(e = null, r = {}) {
|
|
1906
1909
|
super();
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1910
|
+
h(this, "ir");
|
|
1911
|
+
h(this, "js");
|
|
1912
|
+
h(this, "ar");
|
|
1913
|
+
h(this, "Bs");
|
|
1914
|
+
h(this, "Os");
|
|
1915
|
+
h(this, "Ws", null);
|
|
1916
|
+
h(this, "Ns", 0);
|
|
1917
|
+
h(this, "Xs");
|
|
1918
|
+
h(this, "qs", !0);
|
|
1919
|
+
h(this, "Ys", 0);
|
|
1920
|
+
h(this, "Qs", 0);
|
|
1921
|
+
h(this, "Zs", 0);
|
|
1922
|
+
h(this, "Js", []);
|
|
1923
|
+
h(this, "Ks", 10);
|
|
1924
|
+
h(this, "ti", !1);
|
|
1925
|
+
h(this, "ei", !1);
|
|
1926
|
+
h(this, "ri", () => {
|
|
1924
1927
|
});
|
|
1925
|
-
|
|
1928
|
+
h(this, "si", () => {
|
|
1926
1929
|
});
|
|
1927
|
-
|
|
1928
|
-
this.
|
|
1930
|
+
h(this, "ii");
|
|
1931
|
+
this.ir = e, this.ei = e === null, this.Bs = r.renderMode ?? "auto", this.Os = r.frameRate ?? 60, this.Xs = 1e3 / this.Os;
|
|
1929
1932
|
}
|
|
1930
1933
|
static async create(e = null, r = {}) {
|
|
1931
1934
|
const s = new this(e, r), i = s.ei ? r : void 0;
|
|
1932
1935
|
let n, o;
|
|
1933
|
-
s.Ye = new mt(s.
|
|
1936
|
+
s.Ye = new mt(s.ir, s.ei, i), s.ve = new nt(s.Ye.cr()), s.ei ? (n = r.width || 800, o = r.height || 600) : (n = s.Ye.width || 800, o = s.Ye.height || 600), s.js = s.ve.Ut(n, o), s.Te = new pt(s.ve, r.fontSize ?? 16), await s.Te.Ue(r.fontSource);
|
|
1934
1937
|
const l = s.Te.maxGlyphDimensions;
|
|
1935
|
-
return s.
|
|
1938
|
+
return s.dr = new vt(s.Ye.canvas, l.width, l.height), s.Hs = new wt(s.ve, s.Te, s.dr), s.ni(), s.oi(), s;
|
|
1936
1939
|
}
|
|
1937
1940
|
ni() {
|
|
1938
1941
|
this.ii = () => {
|
|
1939
|
-
this.ei ? this.
|
|
1940
|
-
}, window.addEventListener("resize", this.ii), window.ResizeObserver && this.
|
|
1942
|
+
this.ei ? this.si() : this.ai();
|
|
1943
|
+
}, window.addEventListener("resize", this.ii), window.ResizeObserver && this.ir && !this.ei && (this.ar = new ResizeObserver(() => {
|
|
1941
1944
|
this.ai();
|
|
1942
|
-
}), this.
|
|
1945
|
+
}), this.ar.observe(this.ir));
|
|
1943
1946
|
}
|
|
1944
1947
|
render() {
|
|
1945
|
-
this.hi(), this.
|
|
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.Lt(0), this.ve.Bt(this.Hs.texture, this.dr.offsetX, this.dr.offsetY, this.Hs.texture.width, this.Hs.texture.height)) : (this.ve.Ht(), this.ve.Bt(this.js, this.dr.offsetX, this.dr.offsetY, this.js.width, this.js.height)));
|
|
1946
1949
|
}
|
|
1947
1950
|
ai() {
|
|
1948
|
-
this.Ye.
|
|
1951
|
+
this.Ye.rr(), this.js.resize(this.Ye.width, this.Ye.height), this.dr.rr(), this.Hs.rr(), this.ve.jt(), this.Bs !== "manual" && this.render();
|
|
1949
1952
|
}
|
|
1950
1953
|
oi() {
|
|
1951
|
-
if (this.
|
|
1952
|
-
this.
|
|
1954
|
+
if (this.Bs !== "auto" || !this.qs) return;
|
|
1955
|
+
this.Ns = performance.now();
|
|
1953
1956
|
const e = (r) => {
|
|
1954
|
-
if (!this.
|
|
1955
|
-
const s = r - this.
|
|
1956
|
-
s >= this.
|
|
1957
|
+
if (!this.qs) return void (this.Ws = null);
|
|
1958
|
+
const s = r - this.Ns;
|
|
1959
|
+
s >= this.Xs && (this.render(), this.Ns = r - s % this.Xs), this.qs && (this.Ws = requestAnimationFrame(e));
|
|
1957
1960
|
};
|
|
1958
|
-
this.
|
|
1961
|
+
this.Ws = requestAnimationFrame(e);
|
|
1959
1962
|
}
|
|
1960
1963
|
hi() {
|
|
1961
1964
|
const e = performance.now();
|
|
1962
|
-
if (this.
|
|
1963
|
-
const r = e - this.
|
|
1964
|
-
this.
|
|
1965
|
-
const s = this.
|
|
1966
|
-
this.
|
|
1965
|
+
if (this.Qs > 0) {
|
|
1966
|
+
const r = e - this.Qs;
|
|
1967
|
+
this.Js.push(r), this.Js.length > this.Ks && this.Js.shift();
|
|
1968
|
+
const s = this.Js.reduce((i, n) => i + n, 0) / this.Js.length;
|
|
1969
|
+
this.Ys = 1e3 / s;
|
|
1967
1970
|
}
|
|
1968
|
-
this.
|
|
1971
|
+
this.Qs = e;
|
|
1969
1972
|
}
|
|
1970
1973
|
li() {
|
|
1971
|
-
this.
|
|
1974
|
+
this.Ws && (cancelAnimationFrame(this.Ws), this.Ws = null);
|
|
1972
1975
|
}
|
|
1973
1976
|
renderMode(e) {
|
|
1974
|
-
this.
|
|
1977
|
+
this.Bs !== e && (this.li(), this.Bs = e, e === "auto" && this.qs && this.oi());
|
|
1975
1978
|
}
|
|
1976
1979
|
frameRate(e) {
|
|
1977
|
-
if (e === void 0) return this.
|
|
1978
|
-
this.
|
|
1980
|
+
if (e === void 0) return this.Ys;
|
|
1981
|
+
this.Os = e, this.Xs = 1e3 / e, this.Bs === "auto" && this.qs && (this.li(), this.oi());
|
|
1979
1982
|
}
|
|
1980
1983
|
noLoop() {
|
|
1981
|
-
this.
|
|
1984
|
+
this.qs && (this.qs = !1, this.Ws && (cancelAnimationFrame(this.Ws), this.Ws = null));
|
|
1982
1985
|
}
|
|
1983
1986
|
loop() {
|
|
1984
|
-
this.
|
|
1987
|
+
this.qs || (this.qs = !0, this.Bs === "auto" && this.oi());
|
|
1985
1988
|
}
|
|
1986
1989
|
redraw(e = 1) {
|
|
1987
1990
|
if (x.p(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();
|
|
1988
1991
|
}
|
|
1989
1992
|
isLooping() {
|
|
1990
|
-
return this.
|
|
1993
|
+
return this.Bs === "auto" && this.qs;
|
|
1991
1994
|
}
|
|
1992
1995
|
draw(e) {
|
|
1993
|
-
this.
|
|
1996
|
+
this.ri = e;
|
|
1994
1997
|
}
|
|
1995
1998
|
windowResized(e) {
|
|
1996
|
-
this.
|
|
1999
|
+
this.si = e;
|
|
1997
2000
|
}
|
|
1998
2001
|
resizeCanvas(e, r) {
|
|
1999
|
-
this.ei && (this.Ye.
|
|
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.jt(), this.Bs !== "manual" && this.render());
|
|
2000
2003
|
}
|
|
2001
2004
|
destroy() {
|
|
2002
|
-
this.ti || (this.li(), window.removeEventListener("resize", this.ii), this.
|
|
2005
|
+
this.ti || (this.li(), window.removeEventListener("resize", this.ii), this.ar && this.ar.disconnect(), this.Hs.G(), this.Te.G(), this.js.G(), this.ve.G(), this.ti = !0);
|
|
2003
2006
|
}
|
|
2004
2007
|
get grid() {
|
|
2005
|
-
return this.
|
|
2008
|
+
return this.dr;
|
|
2006
2009
|
}
|
|
2007
2010
|
get font() {
|
|
2008
2011
|
return this.Te;
|
|
2009
2012
|
}
|
|
2010
2013
|
get mode() {
|
|
2011
|
-
return this.
|
|
2014
|
+
return this.Bs;
|
|
2012
2015
|
}
|
|
2013
2016
|
get pipeline() {
|
|
2014
|
-
return this.
|
|
2017
|
+
return this.Hs;
|
|
2015
2018
|
}
|
|
2016
2019
|
get frameCount() {
|
|
2017
|
-
return this.
|
|
2020
|
+
return this.Zs;
|
|
2018
2021
|
}
|
|
2019
2022
|
set frameCount(e) {
|
|
2020
|
-
this.
|
|
2023
|
+
this.Zs = e;
|
|
2021
2024
|
}
|
|
2022
2025
|
get width() {
|
|
2023
2026
|
return this.Ye.width;
|
|
@@ -2032,7 +2035,7 @@ class X extends function(e, ...r) {
|
|
|
2032
2035
|
return this.ti;
|
|
2033
2036
|
}
|
|
2034
2037
|
}
|
|
2035
|
-
class
|
|
2038
|
+
class H {
|
|
2036
2039
|
constructor() {
|
|
2037
2040
|
throw new w("Textmode is a static class and cannot be instantiated.");
|
|
2038
2041
|
}
|
|
@@ -2049,22 +2052,23 @@ class V {
|
|
|
2049
2052
|
x._(t);
|
|
2050
2053
|
}
|
|
2051
2054
|
static get version() {
|
|
2052
|
-
return "0.1.9-beta.
|
|
2055
|
+
return "0.1.9-beta.3";
|
|
2053
2056
|
}
|
|
2054
2057
|
}
|
|
2055
|
-
const
|
|
2058
|
+
const zt = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), Lt = H.create, Ht = H.setErrorLevel, Vt = H.version;
|
|
2056
2059
|
export {
|
|
2057
2060
|
mt as TextmodeCanvas,
|
|
2061
|
+
xt as TextmodeColorPalette,
|
|
2058
2062
|
wt as TextmodeConversionPipeline,
|
|
2059
2063
|
rt as TextmodeErrorLevel,
|
|
2060
2064
|
pt as TextmodeFont,
|
|
2061
2065
|
vt as TextmodeGrid,
|
|
2062
2066
|
X as Textmodifier,
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2067
|
+
Yt as converters,
|
|
2068
|
+
Lt as create,
|
|
2069
|
+
H as default,
|
|
2070
|
+
zt as export,
|
|
2071
|
+
Ht as setErrorLevel,
|
|
2072
|
+
H as textmode,
|
|
2073
|
+
Vt as version
|
|
2070
2074
|
};
|