textmode.js 0.1.8 → 0.1.9-beta.2
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.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,15 +33,15 @@ 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;
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
m(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,32 +54,32 @@ const M = class M {
|
|
|
54
54
|
throw new w(t, e);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
return !!t || (this.
|
|
57
|
+
p(t, e, r) {
|
|
58
|
+
return !!t || (this.m(e, r), !1);
|
|
59
59
|
}
|
|
60
60
|
_(t) {
|
|
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,
|
|
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) {
|
|
@@ -394,8 +394,8 @@ class nt {
|
|
|
394
394
|
}
|
|
395
395
|
Gt(t, e, r, s) {
|
|
396
396
|
if (this.ut !== null) {
|
|
397
|
-
const { centerX: f, centerY: d, radians:
|
|
398
|
-
return this.Et("u_rotation",
|
|
397
|
+
const { centerX: f, centerY: d, radians: v, aspectRatio: p } = this.Pt(t, e, r, s);
|
|
398
|
+
return this.Et("u_rotation", v), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p), this.ft.nt(t, e, r, s), void (this.ut = null);
|
|
399
399
|
}
|
|
400
400
|
const i = this.ct;
|
|
401
401
|
let n = 0, o = 0, l = 0, c = 1;
|
|
@@ -404,19 +404,19 @@ class nt {
|
|
|
404
404
|
}
|
|
405
405
|
At(t, e, r, s) {
|
|
406
406
|
if (this.ut !== null) {
|
|
407
|
-
const g = (t + r) / 2, C = (e + s) / 2,
|
|
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;
|
|
414
|
-
let f = 0, d = 0,
|
|
414
|
+
let f = 0, d = 0, v = 0, p = 1;
|
|
415
415
|
if (u) {
|
|
416
416
|
const g = this.Pt(n - l / 2, o - c / 2, l, c);
|
|
417
|
-
f = g.centerX, d = g.centerY,
|
|
417
|
+
f = g.centerX, d = g.centerY, v = g.radians, p = g.aspectRatio;
|
|
418
418
|
}
|
|
419
|
-
this.yt(i), this.Et("u_color", this.vt), u && (this.Et("u_rotation",
|
|
419
|
+
this.yt(i), this.Et("u_color", this.vt), u && (this.Et("u_rotation", v), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p)), this.dt.ht(t, e, r, s, this.xt);
|
|
420
420
|
}
|
|
421
421
|
Pt(t, e, r, s) {
|
|
422
422
|
const i = Z(this.v) || [0, 0, this.v.canvas.width, this.v.canvas.height], n = i[2], o = i[3], l = n / o;
|
|
@@ -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
|
-
let
|
|
477
|
-
if (
|
|
476
|
+
let v = o.indexOf(f);
|
|
477
|
+
if (v === -1) {
|
|
478
478
|
let p;
|
|
479
|
-
|
|
480
|
-
const g = i(
|
|
481
|
-
p = g === 4 ? this.parse4(
|
|
479
|
+
v = r.tables.length, o.push(f);
|
|
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
|
-
r.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), r.ids[d] =
|
|
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 = {};
|
|
@@ -558,28 +558,28 @@ const y = { readShort: (h, t) => (y.t.uint16[0] = h[t] << 8 | h[t + 1], y.t.int1
|
|
|
558
558
|
const c = o.endPts[o.noc - 1] + 1;
|
|
559
559
|
o.flags = [];
|
|
560
560
|
for (let d = 0; d < c; d++) {
|
|
561
|
-
const
|
|
562
|
-
if (n++, o.flags.push(
|
|
561
|
+
const v = r[n];
|
|
562
|
+
if (n++, o.flags.push(v), 8 & v) {
|
|
563
563
|
const p = r[n];
|
|
564
564
|
n++;
|
|
565
|
-
for (let g = 0; g < p; g++) o.flags.push(
|
|
565
|
+
for (let g = 0; g < p; g++) o.flags.push(v), d++;
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
o.xs = [];
|
|
569
569
|
for (let d = 0; d < c; d++) {
|
|
570
|
-
const
|
|
571
|
-
2 &
|
|
570
|
+
const v = o.flags[d], p = !!(16 & v);
|
|
571
|
+
2 & v ? (o.xs.push(p ? r[n] : -r[n]), n++) : p ? o.xs.push(0) : (o.xs.push(e.readShort(r, n)), n += 2);
|
|
572
572
|
}
|
|
573
573
|
o.ys = [];
|
|
574
574
|
for (let d = 0; d < c; d++) {
|
|
575
|
-
const
|
|
576
|
-
4 &
|
|
575
|
+
const v = o.flags[d], p = !!(32 & v);
|
|
576
|
+
4 & v ? (o.ys.push(p ? r[n] : -r[n]), n++) : p ? o.ys.push(0) : (o.ys.push(e.readShort(r, n)), n += 2);
|
|
577
577
|
}
|
|
578
578
|
let u = 0, f = 0;
|
|
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) {
|
|
@@ -711,7 +711,7 @@ class ct {
|
|
|
711
711
|
const s = t.startCount[r], i = t.endCount[r];
|
|
712
712
|
if (s !== 65535 || i !== 65535) {
|
|
713
713
|
for (let n = s; n <= i; n++)
|
|
714
|
-
if (this.
|
|
714
|
+
if (this.me(t, n, r) > 0) try {
|
|
715
715
|
const o = String.fromCodePoint(n);
|
|
716
716
|
e.push(o);
|
|
717
717
|
} catch {
|
|
@@ -734,7 +734,7 @@ class ct {
|
|
|
734
734
|
}
|
|
735
735
|
return e;
|
|
736
736
|
}
|
|
737
|
-
|
|
737
|
+
me(t, e, r) {
|
|
738
738
|
if (t.idRangeOffset[r] === 0) return e + t.idDelta[r] & 65535;
|
|
739
739
|
{
|
|
740
740
|
const s = t.idRangeOffset[r] / 2 + (e - t.startCount[r]) - (t.startCount.length - r);
|
|
@@ -752,29 +752,29 @@ class ct {
|
|
|
752
752
|
}
|
|
753
753
|
class ut {
|
|
754
754
|
constructor() {
|
|
755
|
-
|
|
755
|
+
h(this, "pe");
|
|
756
756
|
const t = new G();
|
|
757
|
-
this.
|
|
757
|
+
this.pe = new ct(t);
|
|
758
758
|
}
|
|
759
759
|
extractCharacters(t) {
|
|
760
|
-
return this.
|
|
760
|
+
return this.pe.oe(t);
|
|
761
761
|
}
|
|
762
762
|
filterProblematicCharacters(t) {
|
|
763
|
-
return this.
|
|
763
|
+
return this.pe.fe(t);
|
|
764
764
|
}
|
|
765
765
|
characterExists(t, e) {
|
|
766
|
-
return this.
|
|
766
|
+
return this.pe.le(t, e);
|
|
767
767
|
}
|
|
768
768
|
allCharactersExist(t, e) {
|
|
769
|
-
return this.
|
|
769
|
+
return this.pe.ce(t, e);
|
|
770
770
|
}
|
|
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) {
|
|
@@ -791,7 +791,7 @@ class dt {
|
|
|
791
791
|
for (let o = 0; o < t.length; o++) {
|
|
792
792
|
const l = o % r, c = Math.floor(o / r), u = t[o].character, f = this.Ce(i, u);
|
|
793
793
|
if (!f) continue;
|
|
794
|
-
const d = u.codePointAt(0) || 0,
|
|
794
|
+
const d = u.codePointAt(0) || 0, v = this.xe.Jt(i, d), p = this.ye(i, v) * n, g = l * e.width, C = c * e.height, m = g + 0.5 * e.width, b = C + 0.5 * e.height, T = Math.round(m - 0.5 * e.width), E = Math.round(b - 0.5 * s), A = T + 0.5 * (e.width - p), F = E + i.hhea.ascender * n;
|
|
795
795
|
this.$e(f, A, F, n);
|
|
796
796
|
}
|
|
797
797
|
}
|
|
@@ -819,8 +819,8 @@ class dt {
|
|
|
819
819
|
const f = o[u];
|
|
820
820
|
if (!(f < c)) {
|
|
821
821
|
if (f >= c) {
|
|
822
|
-
const d = e + i[c] * s,
|
|
823
|
-
this._e.moveTo(d,
|
|
822
|
+
const d = e + i[c] * s, v = r - n[c] * s;
|
|
823
|
+
this._e.moveTo(d, v);
|
|
824
824
|
let p = c + 1;
|
|
825
825
|
for (; p <= f; )
|
|
826
826
|
if (1 & l[p]) {
|
|
@@ -828,13 +828,13 @@ class dt {
|
|
|
828
828
|
this._e.lineTo(g, C), p++;
|
|
829
829
|
} else {
|
|
830
830
|
const g = e + i[p] * s, C = r - n[p] * s;
|
|
831
|
-
let
|
|
832
|
-
if (1 & l[
|
|
833
|
-
const b = e + i[
|
|
834
|
-
this._e.quadraticCurveTo(g, C, b, T), p =
|
|
831
|
+
let m = p + 1 > f ? c : p + 1;
|
|
832
|
+
if (1 & l[m]) {
|
|
833
|
+
const b = e + i[m] * s, T = r - n[m] * s;
|
|
834
|
+
this._e.quadraticCurveTo(g, C, b, T), p = m + 1;
|
|
835
835
|
} else {
|
|
836
|
-
const b = (g + (e + i[
|
|
837
|
-
this._e.quadraticCurveTo(g, C, b, T), p =
|
|
836
|
+
const b = (g + (e + i[m] * s)) / 2, T = (C + (r - n[m] * s)) / 2;
|
|
837
|
+
this._e.quadraticCurveTo(g, C, b, T), p = m;
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
840
|
this._e.closePath();
|
|
@@ -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) {
|
|
@@ -892,29 +892,29 @@ class gt {
|
|
|
892
892
|
return [t % 256, Math.floor(t / 256) % 256, Math.floor(t / 65536) % 256];
|
|
893
893
|
}
|
|
894
894
|
getCharacterColor(t, e) {
|
|
895
|
-
if (!x.
|
|
895
|
+
if (!x.p(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
|
|
896
896
|
const r = e.find((s) => s.character === t);
|
|
897
897
|
return r ? r.color : [0, 0, 0];
|
|
898
898
|
}
|
|
899
899
|
getCharacterColors(t, e) {
|
|
900
|
-
return x.
|
|
900
|
+
return x.p(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? t.split("").map((r) => this.getCharacterColor(r, e) || [0, 0, 0]) : [[0, 0, 0]];
|
|
901
901
|
}
|
|
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) {
|
|
@@ -993,18 +993,18 @@ class pt {
|
|
|
993
993
|
return this.Te;
|
|
994
994
|
}
|
|
995
995
|
}
|
|
996
|
-
class
|
|
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 mt {
|
|
|
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
|
}
|
|
@@ -1054,68 +1054,68 @@ class mt {
|
|
|
1054
1054
|
return this.Xe;
|
|
1055
1055
|
}
|
|
1056
1056
|
}
|
|
1057
|
-
class
|
|
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,27 +1133,27 @@ class vt {
|
|
|
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
|
-
x.
|
|
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);
|
|
1157
1157
|
}
|
|
1158
1158
|
enable() {
|
|
1159
1159
|
this.enabled(!0);
|
|
@@ -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,64 +1215,64 @@ 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.
|
|
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
|
-
if (!x.
|
|
1245
|
+
if (!x.p(typeof e == "number", "Rotation angle must be a number.", { method: "rotation", providedValue: e })) return;
|
|
1246
1246
|
(e %= 360) < 0 && (e += 360);
|
|
1247
1247
|
const r = 255 * e / 360, s = Math.floor(r) / 255, i = Math.round(r - s);
|
|
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.
|
|
1260
|
-
if (!f) return x.
|
|
1259
|
+
const f = this.Tr(e);
|
|
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
|
-
} else if (o = e, l = s !== void 0 ? s : e, c = i !== void 0 ? i : e, u = n, !x.
|
|
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
|
-
|
|
1266
|
-
x.
|
|
1265
|
+
$r(e, r) {
|
|
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
|
-
|
|
1269
|
-
x.
|
|
1268
|
+
Fr(e, r, s) {
|
|
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
|
-
x.
|
|
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
|
-
if (!x.
|
|
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.
|
|
1370
|
-
const e = this.
|
|
1371
|
-
x.
|
|
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.
|
|
1376
|
-
if (o instanceof
|
|
1377
|
-
const c = this.
|
|
1378
|
-
return x.
|
|
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
|
-
return x.
|
|
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
|
-
if (s === null || i === null || !x.
|
|
1383
|
-
const n = this.
|
|
1384
|
-
this.
|
|
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.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
|
}
|
|
@@ -1473,72 +1473,81 @@ const Ct = (h) => class extends h {
|
|
|
1473
1473
|
setUniform(t, e) {
|
|
1474
1474
|
this.ve.Et(t, e);
|
|
1475
1475
|
}
|
|
1476
|
+
image(t, e, r, s, i) {
|
|
1477
|
+
this.ve.Bt(t, e, r, s, i);
|
|
1478
|
+
}
|
|
1479
|
+
clear() {
|
|
1480
|
+
this.ve.Ht();
|
|
1481
|
+
}
|
|
1482
|
+
createFramebuffer(t, e, r = {}) {
|
|
1483
|
+
return this.ve.Ut(t, e, r);
|
|
1484
|
+
}
|
|
1476
1485
|
};
|
|
1477
|
-
class
|
|
1478
|
-
|
|
1486
|
+
class z {
|
|
1487
|
+
Lr(t) {
|
|
1479
1488
|
const e = t.characterFramebuffer, r = t.primaryColorFramebuffer, s = t.secondaryColorFramebuffer, i = t.transformFramebuffer, n = t.rotationFramebuffer;
|
|
1480
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) };
|
|
1481
1490
|
}
|
|
1482
|
-
|
|
1491
|
+
Hr(t, e) {
|
|
1483
1492
|
return t[e] + (t[e + 1] << 8);
|
|
1484
1493
|
}
|
|
1485
|
-
|
|
1494
|
+
jr(t, e) {
|
|
1486
1495
|
return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
|
|
1487
1496
|
}
|
|
1488
1497
|
}
|
|
1489
|
-
class
|
|
1490
|
-
|
|
1498
|
+
class L {
|
|
1499
|
+
Br(t, e) {
|
|
1491
1500
|
return new Blob([t], { type: e });
|
|
1492
1501
|
}
|
|
1493
|
-
|
|
1502
|
+
Or(t, e, r) {
|
|
1494
1503
|
try {
|
|
1495
|
-
const s = this.
|
|
1504
|
+
const s = this.Br(t, r), i = URL.createObjectURL(s), n = document.createElement("a");
|
|
1496
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);
|
|
1497
1506
|
} catch (s) {
|
|
1498
1507
|
throw console.error("Failed to download file:", s), Error("File download failed: " + (s instanceof Error ? s.message : "Unknown error"));
|
|
1499
1508
|
}
|
|
1500
1509
|
}
|
|
1501
|
-
|
|
1510
|
+
Wr() {
|
|
1502
1511
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
|
|
1503
1512
|
}
|
|
1504
|
-
|
|
1513
|
+
Nr() {
|
|
1505
1514
|
const t = /* @__PURE__ */ new Date();
|
|
1506
1515
|
return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
|
|
1507
1516
|
}
|
|
1508
|
-
|
|
1517
|
+
Xr(t) {
|
|
1509
1518
|
return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
|
|
1510
1519
|
}
|
|
1511
|
-
|
|
1512
|
-
return "'textmode-export'-" + this.
|
|
1520
|
+
qr() {
|
|
1521
|
+
return "'textmode-export'-" + this.Wr();
|
|
1513
1522
|
}
|
|
1514
1523
|
}
|
|
1515
|
-
class yt extends
|
|
1516
|
-
|
|
1524
|
+
class yt extends z {
|
|
1525
|
+
Yr(t, e, r) {
|
|
1517
1526
|
const s = t[r] === 255, i = t[r + 1] === 255, n = t[r + 2] === 255, o = e[r], l = e[r + 1];
|
|
1518
1527
|
return { isInverted: s, flipHorizontal: i, flipVertical: n, rotation: Math.round(360 * (o + l / 255) / 255 * 100) / 100 };
|
|
1519
1528
|
}
|
|
1520
|
-
|
|
1529
|
+
Qr(t, e, r) {
|
|
1521
1530
|
return { x: t, y: e, cellX: t * r.cellWidth, cellY: e * r.cellHeight };
|
|
1522
1531
|
}
|
|
1523
|
-
|
|
1532
|
+
Zr(t, e) {
|
|
1524
1533
|
const r = [];
|
|
1525
1534
|
let s = 0;
|
|
1526
1535
|
for (let i = 0; i < e.rows; i++) for (let n = 0; n < e.cols; n++) {
|
|
1527
|
-
const o = 4 * s, l = this.
|
|
1528
|
-
let c = this.
|
|
1529
|
-
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);
|
|
1530
1539
|
if (f.isInverted) {
|
|
1531
|
-
const
|
|
1532
|
-
c = u, u =
|
|
1540
|
+
const v = c;
|
|
1541
|
+
c = u, u = v;
|
|
1533
1542
|
}
|
|
1534
|
-
const d = this.
|
|
1543
|
+
const d = this.Qr(n, i, e);
|
|
1535
1544
|
r.push({ charIndex: l, primaryColor: c, secondaryColor: u, transform: f, position: d }), s++;
|
|
1536
1545
|
}
|
|
1537
1546
|
return r;
|
|
1538
1547
|
}
|
|
1539
1548
|
}
|
|
1540
1549
|
class _t {
|
|
1541
|
-
|
|
1550
|
+
Jr(t, e) {
|
|
1542
1551
|
const r = t.cmap;
|
|
1543
1552
|
for (const s of r.tables) if (s.format === 4) {
|
|
1544
1553
|
for (let i = 0; i < s.startCount.length; i++) if (e >= s.startCount[i] && e <= s.endCount[i]) {
|
|
@@ -1554,11 +1563,11 @@ class _t {
|
|
|
1554
1563
|
}
|
|
1555
1564
|
return 0;
|
|
1556
1565
|
}
|
|
1557
|
-
|
|
1566
|
+
Kr(t, e, r, s, i) {
|
|
1558
1567
|
const n = i / t.head.unitsPerEm;
|
|
1559
|
-
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) };
|
|
1560
1569
|
}
|
|
1561
|
-
|
|
1570
|
+
ts(t, e, r, s) {
|
|
1562
1571
|
if (!t || !t.xs) return "";
|
|
1563
1572
|
const { xs: i, ys: n, endPts: o, flags: l } = t;
|
|
1564
1573
|
if (!(i && n && o && l)) return "";
|
|
@@ -1567,22 +1576,22 @@ class _t {
|
|
|
1567
1576
|
const d = o[f];
|
|
1568
1577
|
if (!(d < u)) {
|
|
1569
1578
|
if (d >= u) {
|
|
1570
|
-
const
|
|
1571
|
-
c += `M${
|
|
1579
|
+
const v = e + i[u] * s, p = r - n[u] * s;
|
|
1580
|
+
c += `M${v.toFixed(2)},${p.toFixed(2)}`;
|
|
1572
1581
|
let g = u + 1;
|
|
1573
1582
|
for (; g <= d; )
|
|
1574
1583
|
if (1 & l[g]) {
|
|
1575
|
-
const C = e + i[g] * s,
|
|
1576
|
-
c += `L${C.toFixed(2)},${
|
|
1584
|
+
const C = e + i[g] * s, m = r - n[g] * s;
|
|
1585
|
+
c += `L${C.toFixed(2)},${m.toFixed(2)}`, g++;
|
|
1577
1586
|
} else {
|
|
1578
|
-
const C = e + i[g] * s,
|
|
1587
|
+
const C = e + i[g] * s, m = r - n[g] * s;
|
|
1579
1588
|
let b = g + 1 > d ? u : g + 1;
|
|
1580
1589
|
if (1 & l[b]) {
|
|
1581
1590
|
const T = e + i[b] * s, E = r - n[b] * s;
|
|
1582
|
-
c += `Q${C.toFixed(2)},${
|
|
1591
|
+
c += `Q${C.toFixed(2)},${m.toFixed(2)} ${T.toFixed(2)},${E.toFixed(2)}`, g = b + 1;
|
|
1583
1592
|
} else {
|
|
1584
|
-
const T = (C + (e + i[b] * s)) / 2, E = (
|
|
1585
|
-
c += `Q${C.toFixed(2)},${
|
|
1593
|
+
const T = (C + (e + i[b] * s)) / 2, E = (m + (r - n[b] * s)) / 2;
|
|
1594
|
+
c += `Q${C.toFixed(2)},${m.toFixed(2)} ${T.toFixed(2)},${E.toFixed(2)}`, g = b;
|
|
1586
1595
|
}
|
|
1587
1596
|
}
|
|
1588
1597
|
c += "Z";
|
|
@@ -1592,22 +1601,22 @@ class _t {
|
|
|
1592
1601
|
}
|
|
1593
1602
|
return c;
|
|
1594
1603
|
}
|
|
1595
|
-
|
|
1596
|
-
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);
|
|
1597
1606
|
let l = null;
|
|
1598
|
-
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);
|
|
1599
1608
|
}
|
|
1600
|
-
|
|
1609
|
+
rs(t, e, r, s, i, n, o, l) {
|
|
1601
1610
|
const c = r + (i - l * (o / e.head.unitsPerEm)) / 2, u = s + (n + 0.7 * o) / 2;
|
|
1602
|
-
return this.
|
|
1611
|
+
return this.es(t, e, c, u, o).toSVG() || null;
|
|
1603
1612
|
}
|
|
1604
1613
|
}
|
|
1605
1614
|
class Tt {
|
|
1606
1615
|
constructor() {
|
|
1607
|
-
|
|
1608
|
-
this.
|
|
1616
|
+
h(this, "ss");
|
|
1617
|
+
this.ss = new _t();
|
|
1609
1618
|
}
|
|
1610
|
-
|
|
1619
|
+
ns(t) {
|
|
1611
1620
|
return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
1612
1621
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
1613
1622
|
<svg width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}"
|
|
@@ -1615,21 +1624,21 @@ class Tt {
|
|
|
1615
1624
|
<title>textmode art generated via textmode.js</title>
|
|
1616
1625
|
<desc>textmode art visualization generated by textmode.js library</desc>`;
|
|
1617
1626
|
}
|
|
1618
|
-
|
|
1627
|
+
hs() {
|
|
1619
1628
|
return `
|
|
1620
1629
|
</g>
|
|
1621
1630
|
</svg>`;
|
|
1622
1631
|
}
|
|
1623
|
-
|
|
1632
|
+
ls(t, e) {
|
|
1624
1633
|
if (!e.includeBackgroundRectangles) return "";
|
|
1625
1634
|
const r = e.backgroundColor, s = `rgba(${r[0]},${r[1]},${r[2]},${r[3] / 255})`;
|
|
1626
1635
|
return `
|
|
1627
1636
|
<rect width="${t.width}" height="${t.height}" fill="${s}" />`;
|
|
1628
1637
|
}
|
|
1629
|
-
|
|
1638
|
+
cs(t) {
|
|
1630
1639
|
return `rgba(${t.r},${t.g},${t.b},${t.a / 255})`;
|
|
1631
1640
|
}
|
|
1632
|
-
|
|
1641
|
+
us(t, e) {
|
|
1633
1642
|
const { transform: r, position: s } = t, i = s.cellX + e.cellWidth / 2, n = s.cellY + e.cellHeight / 2, o = [];
|
|
1634
1643
|
if (r.flipHorizontal || r.flipVertical) {
|
|
1635
1644
|
const l = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
|
|
@@ -1637,83 +1646,83 @@ class Tt {
|
|
|
1637
1646
|
}
|
|
1638
1647
|
return r.rotation && o.push(`rotate(${r.rotation} ${i} ${n})`), o.length ? ` transform="${o.join(" ")}"` : "";
|
|
1639
1648
|
}
|
|
1640
|
-
|
|
1649
|
+
fs(t, e, r) {
|
|
1641
1650
|
if (!r.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
|
|
1642
|
-
const { position: s } = t, i = this.
|
|
1651
|
+
const { position: s } = t, i = this.cs(t.secondaryColor);
|
|
1643
1652
|
return r.drawMode === "stroke" ? `
|
|
1644
1653
|
<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${i}" fill="none" stroke-width="${r.strokeWidth}" />` : `
|
|
1645
1654
|
<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${i}" />`;
|
|
1646
1655
|
}
|
|
1647
|
-
|
|
1656
|
+
es(t, e, r, s) {
|
|
1648
1657
|
const i = r.characters[t.charIndex];
|
|
1649
1658
|
if (!i) return "";
|
|
1650
|
-
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);
|
|
1651
1660
|
if (!n) return "";
|
|
1652
|
-
const o = this.
|
|
1661
|
+
const o = this.cs(t.primaryColor);
|
|
1653
1662
|
return s.drawMode === "stroke" ? `
|
|
1654
1663
|
<path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${n}" stroke="${o}" stroke-width="${s.strokeWidth}" fill="none" />` : `
|
|
1655
1664
|
<path d="${n}" fill="${o}" />`;
|
|
1656
1665
|
}
|
|
1657
|
-
|
|
1666
|
+
ds(t, e, r, s) {
|
|
1658
1667
|
let i = "";
|
|
1659
|
-
i += this.
|
|
1660
|
-
const n = this.
|
|
1668
|
+
i += this.fs(t, e, s);
|
|
1669
|
+
const n = this.us(t, e), o = this.es(t, e, r, s);
|
|
1661
1670
|
return o && (n ? (i += `
|
|
1662
1671
|
<g${n}>`, i += o, i += `
|
|
1663
1672
|
</g>`) : i += o), i;
|
|
1664
1673
|
}
|
|
1665
|
-
|
|
1666
|
-
let i = this.
|
|
1667
|
-
i += this.
|
|
1674
|
+
ps(t, e, r, s) {
|
|
1675
|
+
let i = this.ns(e);
|
|
1676
|
+
i += this.ls(e, s), i += `
|
|
1668
1677
|
<g id="ascii-cells">`;
|
|
1669
|
-
for (const n of t) i += this.
|
|
1670
|
-
return i += this.
|
|
1678
|
+
for (const n of t) i += this.ds(n, e, r, s);
|
|
1679
|
+
return i += this.hs(), i;
|
|
1671
1680
|
}
|
|
1672
|
-
|
|
1681
|
+
gs(t) {
|
|
1673
1682
|
return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\n\s*\n/g, `
|
|
1674
1683
|
`).replace(/[ \t]+$/gm, "");
|
|
1675
1684
|
}
|
|
1676
1685
|
}
|
|
1677
|
-
class Et extends
|
|
1678
|
-
|
|
1679
|
-
return this.
|
|
1686
|
+
class Et extends L {
|
|
1687
|
+
_s(t) {
|
|
1688
|
+
return this.Br(t, "image/svg+xml;charset=utf-8");
|
|
1680
1689
|
}
|
|
1681
|
-
|
|
1682
|
-
this.
|
|
1690
|
+
vs(t, e) {
|
|
1691
|
+
this.Or(t, this.Xr(e) + ".svg", "image/svg+xml;charset=utf-8");
|
|
1683
1692
|
}
|
|
1684
|
-
|
|
1685
|
-
this.
|
|
1693
|
+
bs(t, e) {
|
|
1694
|
+
this.vs(t, e || this.qr());
|
|
1686
1695
|
}
|
|
1687
1696
|
}
|
|
1688
|
-
class
|
|
1697
|
+
class W {
|
|
1689
1698
|
constructor() {
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
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();
|
|
1694
1703
|
}
|
|
1695
|
-
|
|
1704
|
+
Fs(t) {
|
|
1696
1705
|
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0] };
|
|
1697
1706
|
}
|
|
1698
|
-
|
|
1699
|
-
const r = this.
|
|
1700
|
-
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);
|
|
1701
1710
|
}
|
|
1702
|
-
|
|
1703
|
-
const r = this.
|
|
1704
|
-
this.$
|
|
1711
|
+
bs(t, e = {}) {
|
|
1712
|
+
const r = this.Ts(t, e), s = e.filename || this.$s.qr();
|
|
1713
|
+
this.$s.bs(r, s);
|
|
1705
1714
|
}
|
|
1706
1715
|
}
|
|
1707
|
-
class Rt extends
|
|
1708
|
-
|
|
1716
|
+
class Rt extends z {
|
|
1717
|
+
Ms(t, e, r, s = " ") {
|
|
1709
1718
|
var o;
|
|
1710
1719
|
const i = [];
|
|
1711
1720
|
let n = 0;
|
|
1712
1721
|
for (let l = 0; l < e.rows; l++) {
|
|
1713
1722
|
const c = [];
|
|
1714
1723
|
for (let u = 0; u < e.cols; u++) {
|
|
1715
|
-
const f = 4 * n, d = this.
|
|
1716
|
-
c.push(
|
|
1724
|
+
const f = 4 * n, d = this.Hr(t.characterPixels, f), v = ((o = r.characters[d]) == null ? void 0 : o.character) || s;
|
|
1725
|
+
c.push(v), n++;
|
|
1717
1726
|
}
|
|
1718
1727
|
i.push(c);
|
|
1719
1728
|
}
|
|
@@ -1721,7 +1730,7 @@ class Rt extends Y {
|
|
|
1721
1730
|
}
|
|
1722
1731
|
}
|
|
1723
1732
|
class Ft {
|
|
1724
|
-
|
|
1733
|
+
Ds(t, e) {
|
|
1725
1734
|
const r = [];
|
|
1726
1735
|
for (const i of t) {
|
|
1727
1736
|
let n = i.join("");
|
|
@@ -1733,57 +1742,57 @@ class Ft {
|
|
|
1733
1742
|
return r.join(s);
|
|
1734
1743
|
}
|
|
1735
1744
|
}
|
|
1736
|
-
class Mt extends
|
|
1737
|
-
|
|
1738
|
-
const r = this.
|
|
1739
|
-
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");
|
|
1740
1749
|
}
|
|
1741
|
-
|
|
1742
|
-
let e = this.
|
|
1743
|
-
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;
|
|
1744
1753
|
}
|
|
1745
1754
|
}
|
|
1746
|
-
class
|
|
1755
|
+
class N {
|
|
1747
1756
|
constructor() {
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
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();
|
|
1752
1761
|
}
|
|
1753
|
-
|
|
1762
|
+
Fs(t) {
|
|
1754
1763
|
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " " };
|
|
1755
1764
|
}
|
|
1756
|
-
|
|
1757
|
-
const r = this.
|
|
1758
|
-
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);
|
|
1759
1768
|
}
|
|
1760
|
-
|
|
1761
|
-
const r = this.
|
|
1762
|
-
this.$
|
|
1769
|
+
Ss(t, e = {}) {
|
|
1770
|
+
const r = this.Vs(t, e), s = e.filename || this.$s.qr();
|
|
1771
|
+
this.$s.Ss(r, s);
|
|
1763
1772
|
}
|
|
1764
1773
|
}
|
|
1765
|
-
class At extends
|
|
1766
|
-
|
|
1774
|
+
class At extends z {
|
|
1775
|
+
ks(t, e = 1, r = "transparent") {
|
|
1767
1776
|
const s = t.canvas;
|
|
1768
1777
|
if (e === 1 && r === "transparent") return s;
|
|
1769
1778
|
const i = document.createElement("canvas"), n = i.getContext("2d"), o = Math.round(s.width * e), l = Math.round(s.height * e);
|
|
1770
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;
|
|
1771
1780
|
}
|
|
1772
1781
|
}
|
|
1773
|
-
class
|
|
1774
|
-
|
|
1775
|
-
const r = this.
|
|
1782
|
+
class Ut {
|
|
1783
|
+
Is(t, e) {
|
|
1784
|
+
const r = this.zs(e.format);
|
|
1776
1785
|
return e.format === "png" ? t.toDataURL(r) : t.toDataURL(r, e.quality);
|
|
1777
1786
|
}
|
|
1778
|
-
async
|
|
1787
|
+
async Es(t, e) {
|
|
1779
1788
|
return new Promise((r, s) => {
|
|
1780
|
-
const i = this.
|
|
1789
|
+
const i = this.zs(e.format), n = (o) => {
|
|
1781
1790
|
o ? r(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
|
|
1782
1791
|
};
|
|
1783
1792
|
e.format === "png" ? t.toBlob(n, i) : t.toBlob(n, i, e.quality);
|
|
1784
1793
|
});
|
|
1785
1794
|
}
|
|
1786
|
-
|
|
1795
|
+
zs(t) {
|
|
1787
1796
|
switch (t) {
|
|
1788
1797
|
case "png":
|
|
1789
1798
|
return "image/png";
|
|
@@ -1796,12 +1805,12 @@ class Pt {
|
|
|
1796
1805
|
}
|
|
1797
1806
|
}
|
|
1798
1807
|
}
|
|
1799
|
-
const
|
|
1800
|
-
class
|
|
1801
|
-
|
|
1802
|
-
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]);
|
|
1803
1812
|
}
|
|
1804
|
-
|
|
1813
|
+
Ps(t, e) {
|
|
1805
1814
|
const r = URL.createObjectURL(t);
|
|
1806
1815
|
try {
|
|
1807
1816
|
const s = document.createElement("a");
|
|
@@ -1810,87 +1819,87 @@ class Dt extends H {
|
|
|
1810
1819
|
URL.revokeObjectURL(r);
|
|
1811
1820
|
}
|
|
1812
1821
|
}
|
|
1813
|
-
|
|
1814
|
-
return t in
|
|
1822
|
+
As(t) {
|
|
1823
|
+
return t in Dt && t in j;
|
|
1815
1824
|
}
|
|
1816
1825
|
}
|
|
1817
|
-
class
|
|
1826
|
+
class Pt {
|
|
1818
1827
|
constructor() {
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
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();
|
|
1823
1832
|
}
|
|
1824
|
-
|
|
1833
|
+
Fs(t) {
|
|
1825
1834
|
return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent" };
|
|
1826
1835
|
}
|
|
1827
|
-
|
|
1828
|
-
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`);
|
|
1829
1838
|
if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
|
|
1830
1839
|
if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
|
|
1831
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");
|
|
1832
1841
|
}
|
|
1833
|
-
|
|
1834
|
-
const r = this.
|
|
1835
|
-
if (this.
|
|
1836
|
-
const s = this.
|
|
1837
|
-
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);
|
|
1838
1847
|
}
|
|
1839
|
-
async
|
|
1840
|
-
const r = this.
|
|
1841
|
-
if (this.
|
|
1842
|
-
const s = this.
|
|
1843
|
-
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);
|
|
1844
1853
|
}
|
|
1845
|
-
async
|
|
1846
|
-
const r = await this.
|
|
1847
|
-
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);
|
|
1848
1857
|
}
|
|
1849
1858
|
}
|
|
1850
|
-
const $t = (
|
|
1859
|
+
const $t = (a) => class extends a {
|
|
1851
1860
|
toString(t = {}) {
|
|
1852
|
-
return new
|
|
1861
|
+
return new N().Vs({ pipeline: this.Hs, grid: this.dr, font: this.Te }, t);
|
|
1853
1862
|
}
|
|
1854
1863
|
saveStrings(t = {}) {
|
|
1855
|
-
new
|
|
1864
|
+
new N().Ss({ pipeline: this.Hs, grid: this.dr, font: this.Te }, t);
|
|
1856
1865
|
}
|
|
1857
1866
|
toSVG(t = {}) {
|
|
1858
|
-
return new
|
|
1867
|
+
return new W().Ts(this, t);
|
|
1859
1868
|
}
|
|
1860
1869
|
saveSVG(t = {}) {
|
|
1861
|
-
new
|
|
1870
|
+
new W().bs(this, t);
|
|
1862
1871
|
}
|
|
1863
1872
|
async saveCanvas(t, e = "png", r = {}) {
|
|
1864
|
-
await new
|
|
1873
|
+
await new Pt().Gs(this.Ye, { ...r, filename: t, format: e });
|
|
1865
1874
|
}
|
|
1866
|
-
}, It = (
|
|
1875
|
+
}, It = (a) => class extends a {
|
|
1867
1876
|
async loadFont(t) {
|
|
1868
1877
|
return this.Te.Be(t).then(() => {
|
|
1869
1878
|
const e = this.Te.maxGlyphDimensions;
|
|
1870
|
-
this.
|
|
1879
|
+
this.dr.Ke(e.width, e.height), this.Hs.rr();
|
|
1871
1880
|
});
|
|
1872
1881
|
}
|
|
1873
1882
|
fontSize(t) {
|
|
1874
|
-
if (!x.
|
|
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;
|
|
1875
1884
|
this.Te.je(t);
|
|
1876
1885
|
const e = this.Te.maxGlyphDimensions;
|
|
1877
|
-
this.
|
|
1886
|
+
this.dr.Ke(e.width, e.height), this.Hs.rr(), this.ve.jt();
|
|
1878
1887
|
}
|
|
1879
|
-
}, Gt = (
|
|
1888
|
+
}, Gt = (a) => class extends a {
|
|
1880
1889
|
addConverter(t) {
|
|
1881
|
-
return this.
|
|
1890
|
+
return this.Hs.add(t);
|
|
1882
1891
|
}
|
|
1883
1892
|
removeConverter(t) {
|
|
1884
|
-
this.
|
|
1893
|
+
this.Hs.remove(t);
|
|
1885
1894
|
}
|
|
1886
1895
|
};
|
|
1887
1896
|
class kt {
|
|
1888
1897
|
constructor() {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1898
|
+
h(this, "ve");
|
|
1899
|
+
h(this, "Te");
|
|
1900
|
+
h(this, "Hs");
|
|
1901
|
+
h(this, "Ye");
|
|
1902
|
+
h(this, "dr");
|
|
1894
1903
|
}
|
|
1895
1904
|
}
|
|
1896
1905
|
class X extends function(e, ...r) {
|
|
@@ -1898,120 +1907,120 @@ class X extends function(e, ...r) {
|
|
|
1898
1907
|
}(kt, Ct, $t, It, Gt) {
|
|
1899
1908
|
constructor(e = null, r = {}) {
|
|
1900
1909
|
super();
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
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", () => {
|
|
1918
1927
|
});
|
|
1919
|
-
|
|
1928
|
+
h(this, "si", () => {
|
|
1920
1929
|
});
|
|
1921
|
-
|
|
1922
|
-
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;
|
|
1923
1932
|
}
|
|
1924
1933
|
static async create(e = null, r = {}) {
|
|
1925
1934
|
const s = new this(e, r), i = s.ei ? r : void 0;
|
|
1926
1935
|
let n, o;
|
|
1927
|
-
s.Ye = new
|
|
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);
|
|
1928
1937
|
const l = s.Te.maxGlyphDimensions;
|
|
1929
|
-
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;
|
|
1930
1939
|
}
|
|
1931
1940
|
ni() {
|
|
1932
1941
|
this.ii = () => {
|
|
1933
|
-
this.ei ? this.
|
|
1934
|
-
}, 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(() => {
|
|
1935
1944
|
this.ai();
|
|
1936
|
-
}), this.
|
|
1945
|
+
}), this.ar.observe(this.ir));
|
|
1937
1946
|
}
|
|
1938
1947
|
render() {
|
|
1939
|
-
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)));
|
|
1940
1949
|
}
|
|
1941
1950
|
ai() {
|
|
1942
|
-
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();
|
|
1943
1952
|
}
|
|
1944
1953
|
oi() {
|
|
1945
|
-
if (this.
|
|
1946
|
-
this.
|
|
1954
|
+
if (this.Bs !== "auto" || !this.qs) return;
|
|
1955
|
+
this.Ns = performance.now();
|
|
1947
1956
|
const e = (r) => {
|
|
1948
|
-
if (!this.
|
|
1949
|
-
const s = r - this.
|
|
1950
|
-
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));
|
|
1951
1960
|
};
|
|
1952
|
-
this.
|
|
1961
|
+
this.Ws = requestAnimationFrame(e);
|
|
1953
1962
|
}
|
|
1954
1963
|
hi() {
|
|
1955
1964
|
const e = performance.now();
|
|
1956
|
-
if (this.
|
|
1957
|
-
const r = e - this.
|
|
1958
|
-
this.
|
|
1959
|
-
const s = this.
|
|
1960
|
-
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;
|
|
1961
1970
|
}
|
|
1962
|
-
this.
|
|
1971
|
+
this.Qs = e;
|
|
1963
1972
|
}
|
|
1964
1973
|
li() {
|
|
1965
|
-
this.
|
|
1974
|
+
this.Ws && (cancelAnimationFrame(this.Ws), this.Ws = null);
|
|
1966
1975
|
}
|
|
1967
1976
|
renderMode(e) {
|
|
1968
|
-
this.
|
|
1977
|
+
this.Bs !== e && (this.li(), this.Bs = e, e === "auto" && this.qs && this.oi());
|
|
1969
1978
|
}
|
|
1970
1979
|
frameRate(e) {
|
|
1971
|
-
if (e === void 0) return this.
|
|
1972
|
-
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());
|
|
1973
1982
|
}
|
|
1974
1983
|
noLoop() {
|
|
1975
|
-
this.
|
|
1984
|
+
this.qs && (this.qs = !1, this.Ws && (cancelAnimationFrame(this.Ws), this.Ws = null));
|
|
1976
1985
|
}
|
|
1977
1986
|
loop() {
|
|
1978
|
-
this.
|
|
1987
|
+
this.qs || (this.qs = !0, this.Bs === "auto" && this.oi());
|
|
1979
1988
|
}
|
|
1980
1989
|
redraw(e = 1) {
|
|
1981
|
-
if (x.
|
|
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();
|
|
1982
1991
|
}
|
|
1983
1992
|
isLooping() {
|
|
1984
|
-
return this.
|
|
1993
|
+
return this.Bs === "auto" && this.qs;
|
|
1985
1994
|
}
|
|
1986
1995
|
draw(e) {
|
|
1987
|
-
this.
|
|
1996
|
+
this.ri = e;
|
|
1988
1997
|
}
|
|
1989
1998
|
windowResized(e) {
|
|
1990
|
-
this.
|
|
1999
|
+
this.si = e;
|
|
1991
2000
|
}
|
|
1992
2001
|
resizeCanvas(e, r) {
|
|
1993
|
-
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());
|
|
1994
2003
|
}
|
|
1995
2004
|
destroy() {
|
|
1996
|
-
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);
|
|
1997
2006
|
}
|
|
1998
2007
|
get grid() {
|
|
1999
|
-
return this.
|
|
2008
|
+
return this.dr;
|
|
2000
2009
|
}
|
|
2001
2010
|
get font() {
|
|
2002
2011
|
return this.Te;
|
|
2003
2012
|
}
|
|
2004
2013
|
get mode() {
|
|
2005
|
-
return this.
|
|
2014
|
+
return this.Bs;
|
|
2006
2015
|
}
|
|
2007
2016
|
get pipeline() {
|
|
2008
|
-
return this.
|
|
2017
|
+
return this.Hs;
|
|
2009
2018
|
}
|
|
2010
2019
|
get frameCount() {
|
|
2011
|
-
return this.
|
|
2020
|
+
return this.Zs;
|
|
2012
2021
|
}
|
|
2013
2022
|
set frameCount(e) {
|
|
2014
|
-
this.
|
|
2023
|
+
this.Zs = e;
|
|
2015
2024
|
}
|
|
2016
2025
|
get width() {
|
|
2017
2026
|
return this.Ye.width;
|
|
@@ -2026,7 +2035,7 @@ class X extends function(e, ...r) {
|
|
|
2026
2035
|
return this.ti;
|
|
2027
2036
|
}
|
|
2028
2037
|
}
|
|
2029
|
-
class
|
|
2038
|
+
class H {
|
|
2030
2039
|
constructor() {
|
|
2031
2040
|
throw new w("Textmode is a static class and cannot be instantiated.");
|
|
2032
2041
|
}
|
|
@@ -2043,22 +2052,22 @@ class V {
|
|
|
2043
2052
|
x._(t);
|
|
2044
2053
|
}
|
|
2045
2054
|
static get version() {
|
|
2046
|
-
return "0.1.
|
|
2055
|
+
return "0.1.9-beta.2";
|
|
2047
2056
|
}
|
|
2048
2057
|
}
|
|
2049
|
-
const
|
|
2058
|
+
const zt = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), Lt = H.create, Ht = H.setErrorLevel, Vt = H.version;
|
|
2050
2059
|
export {
|
|
2051
|
-
|
|
2060
|
+
mt as TextmodeCanvas,
|
|
2052
2061
|
wt as TextmodeConversionPipeline,
|
|
2053
2062
|
rt as TextmodeErrorLevel,
|
|
2054
2063
|
pt as TextmodeFont,
|
|
2055
|
-
|
|
2064
|
+
vt as TextmodeGrid,
|
|
2056
2065
|
X as Textmodifier,
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2066
|
+
Yt as converters,
|
|
2067
|
+
Lt as create,
|
|
2068
|
+
H as default,
|
|
2069
|
+
zt as export,
|
|
2070
|
+
Ht as setErrorLevel,
|
|
2071
|
+
H as textmode,
|
|
2072
|
+
Vt as version
|
|
2064
2073
|
};
|