textmode.js 0.1.9-beta.2 → 0.1.9-beta.4
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 +5 -1
- 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/Textmodifier.d.ts +2 -0
- package/dist/types/textmode/converters/FeatureConverter.d.ts +2 -2
- package/package.json +1 -1
package/dist/textmode.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var AA = Object.defineProperty;
|
|
2
2
|
var tA = (E, A, t) => A in E ? AA(E, A, { enumerable: !0, configurable: !0, writable: !0, value: t }) : E[A] = t;
|
|
3
|
-
var
|
|
3
|
+
var o = (E, A, t) => tA(E, typeof A != "symbol" ? A + "" : A, t);
|
|
4
4
|
class I extends Error {
|
|
5
5
|
constructor(A, t = {}) {
|
|
6
6
|
super(I.A(A, t)), this.name = "TextmodeError";
|
|
@@ -36,7 +36,7 @@ class I extends Error {
|
|
|
36
36
|
var eA = ((E) => (E[E.SILENT = 0] = "SILENT", E[E.WARNING = 1] = "WARNING", E[E.ERROR = 2] = "ERROR", E[E.THROW = 3] = "THROW", E))(eA || {});
|
|
37
37
|
const v = class v {
|
|
38
38
|
constructor() {
|
|
39
|
-
|
|
39
|
+
o(this, "h", { globalLevel: 3 });
|
|
40
40
|
}
|
|
41
41
|
static l() {
|
|
42
42
|
return v.o || (v.o = new v()), v.o;
|
|
@@ -61,7 +61,7 @@ const v = class v {
|
|
|
61
61
|
this.h.globalLevel = A;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
o(v, "o", null);
|
|
65
65
|
let Y = v;
|
|
66
66
|
const u = Y.l(), X = /* @__PURE__ */ new WeakMap();
|
|
67
67
|
function F(E, A) {
|
|
@@ -72,14 +72,14 @@ function J(E) {
|
|
|
72
72
|
}
|
|
73
73
|
class K {
|
|
74
74
|
constructor(A, t, e = t, s = {}) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
o(this, "P");
|
|
76
|
+
o(this, "I");
|
|
77
|
+
o(this, "m");
|
|
78
|
+
o(this, "p");
|
|
79
|
+
o(this, "_");
|
|
80
|
+
o(this, "h");
|
|
81
|
+
o(this, "v", null);
|
|
82
|
+
o(this, "M", null);
|
|
83
83
|
this.P = A, this.p = t, this._ = e, this.h = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...s }, this.m = this.G(), this.I = A.createFramebuffer(), this.F();
|
|
84
84
|
}
|
|
85
85
|
$(A) {
|
|
@@ -170,12 +170,12 @@ class K {
|
|
|
170
170
|
}
|
|
171
171
|
class x {
|
|
172
172
|
constructor(A, t, e) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
o(this, "P");
|
|
174
|
+
o(this, "O");
|
|
175
|
+
o(this, "U", /* @__PURE__ */ new Map());
|
|
176
|
+
o(this, "k", /* @__PURE__ */ new Map());
|
|
177
|
+
o(this, "V", 0);
|
|
178
|
+
o(this, "R");
|
|
179
179
|
this.P = A, this.O = this.H(t, e), this.R = A.getParameter(A.MAX_TEXTURE_IMAGE_UNITS), this.L();
|
|
180
180
|
}
|
|
181
181
|
L() {
|
|
@@ -252,10 +252,10 @@ class x {
|
|
|
252
252
|
}
|
|
253
253
|
class Z {
|
|
254
254
|
constructor(A) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
255
|
+
o(this, "P");
|
|
256
|
+
o(this, "Z", null);
|
|
257
|
+
o(this, "X", 16);
|
|
258
|
+
o(this, "q", /* @__PURE__ */ new Map());
|
|
259
259
|
this.P = A;
|
|
260
260
|
}
|
|
261
261
|
AA() {
|
|
@@ -305,12 +305,12 @@ class rA extends Z {
|
|
|
305
305
|
super(A);
|
|
306
306
|
}
|
|
307
307
|
QA(A, t, e, s, r) {
|
|
308
|
-
const i = e - A, B = s - t,
|
|
309
|
-
if (
|
|
308
|
+
const i = e - A, B = s - t, Q = Math.hypot(i, B);
|
|
309
|
+
if (Q === 0) {
|
|
310
310
|
const g = r / 2, a = this.sA(A - g, t - g), h = this.sA(A + g, t + g);
|
|
311
311
|
this.rA(a.nx, a.ny, h.nx, h.ny);
|
|
312
312
|
} else {
|
|
313
|
-
const g = -B /
|
|
313
|
+
const g = -B / Q, a = i / Q, h = r / 2, D = A + g * h, c = t + a * h, l = A - g * h, d = t - a * h, C = e + g * h, P = s + a * h, p = e - g * h, m = s - a * h, y = this.sA(D, c), b = this.sA(l, d), _ = this.sA(C, P), V = this.sA(p, m), G = this.P;
|
|
314
314
|
this.AA(), G.bindBuffer(G.ARRAY_BUFFER, this.Z);
|
|
315
315
|
const q = new Float32Array([y.nx, y.ny, 0, 0, b.nx, b.ny, 0, 1, _.nx, _.ny, 1, 0, b.nx, b.ny, 0, 1, V.nx, V.ny, 1, 1, _.nx, _.ny, 1, 0]);
|
|
316
316
|
G.bufferData(G.ARRAY_BUFFER, q, G.DYNAMIC_DRAW);
|
|
@@ -322,19 +322,19 @@ class rA extends Z {
|
|
|
322
322
|
var R = "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 iA {
|
|
324
324
|
constructor(A) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
325
|
+
o(this, "P");
|
|
326
|
+
o(this, "EA");
|
|
327
|
+
o(this, "gA");
|
|
328
|
+
o(this, "oA", null);
|
|
329
|
+
o(this, "nA");
|
|
330
|
+
o(this, "aA");
|
|
331
|
+
o(this, "hA", [1, 1, 1, 1]);
|
|
332
|
+
o(this, "lA", !0);
|
|
333
|
+
o(this, "cA", [0, 0, 0, 1]);
|
|
334
|
+
o(this, "DA", 1);
|
|
335
|
+
o(this, "CA", !0);
|
|
336
|
+
o(this, "uA", 0);
|
|
337
|
+
o(this, "PA", []);
|
|
338
338
|
this.P = A, this.EA = new x(this.P, R, "precision lowp float;uniform sampler2D u_texture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(u_texture,v_uv);}"), this.gA = new x(this.P, R, "precision lowp float;uniform vec4 u_color;void main(){gl_FragColor=u_color;}"), this.nA = new sA(this.P), this.aA = new rA(this.P), this.P.enable(this.P.BLEND), this.P.blendEquation(this.P.FUNC_ADD), this.P.blendFunc(this.P.ONE, this.P.ONE_MINUS_SRC_ALPHA), F(this.P, [0, 0, this.P.canvas.width, this.P.canvas.height]);
|
|
339
339
|
}
|
|
340
340
|
IA(A) {
|
|
@@ -398,9 +398,9 @@ class iA {
|
|
|
398
398
|
return this.GA("u_rotation", D), this.GA("u_center", [a, h]), this.GA("u_aspectRatio", c), this.nA.BA(A, t, e, s), void (this.oA = null);
|
|
399
399
|
}
|
|
400
400
|
const r = this.gA;
|
|
401
|
-
let i = 0, B = 0,
|
|
401
|
+
let i = 0, B = 0, Q = 0, n = 1;
|
|
402
402
|
const g = this.$A(A, t, e, s);
|
|
403
|
-
i = g.centerX, B = g.centerY,
|
|
403
|
+
i = g.centerX, B = g.centerY, Q = g.radians, n = g.aspectRatio, this.lA && (this.IA(r), this.GA("u_color", this.hA), this.GA("u_rotation", Q), this.GA("u_center", [i, B]), this.GA("u_aspectRatio", n), this.nA.BA(A, t, e, s)), this.CA && this.DA > 0 && (this.IA(r), this.GA("u_color", this.cA), this.GA("u_rotation", Q), this.GA("u_center", [i, B]), this.GA("u_aspectRatio", n), this.nA.iA(A, t, e, s, this.DA)), this.oA = null;
|
|
404
404
|
}
|
|
405
405
|
YA(A, t, e, s) {
|
|
406
406
|
if (this.oA !== null) {
|
|
@@ -410,17 +410,17 @@ class iA {
|
|
|
410
410
|
return this.aA.QA(A, t, e, s, _), void (this.oA = null);
|
|
411
411
|
}
|
|
412
412
|
if (!this.CA || this.DA <= 0) return;
|
|
413
|
-
const r = this.gA, i = (A + e) / 2, B = (t + s) / 2,
|
|
413
|
+
const r = this.gA, i = (A + e) / 2, B = (t + s) / 2, Q = Math.abs(e - A) || 1, n = Math.abs(s - t) || 1, g = this.uA !== 0;
|
|
414
414
|
let a = 0, h = 0, D = 0, c = 1;
|
|
415
415
|
if (g) {
|
|
416
|
-
const l = this.$A(i -
|
|
416
|
+
const l = this.$A(i - Q / 2, B - n / 2, Q, n);
|
|
417
417
|
a = l.centerX, h = l.centerY, D = l.radians, c = l.aspectRatio;
|
|
418
418
|
}
|
|
419
419
|
this.IA(r), this.GA("u_color", this.cA), g && (this.GA("u_rotation", D), this.GA("u_center", [a, h]), this.GA("u_aspectRatio", c)), this.aA.QA(A, t, e, s, this.DA);
|
|
420
420
|
}
|
|
421
421
|
$A(A, t, e, s) {
|
|
422
|
-
const r = J(this.P) || [0, 0, this.P.canvas.width, this.P.canvas.height], i = r[2], B = r[3],
|
|
423
|
-
return { centerX: (A + e / 2) / i * 2 - 1, centerY: 1 - (t + s / 2) / B * 2, radians: this.uA * Math.PI / 180, aspectRatio:
|
|
422
|
+
const r = J(this.P) || [0, 0, this.P.canvas.width, this.P.canvas.height], i = r[2], B = r[3], Q = i / B;
|
|
423
|
+
return { centerX: (A + e / 2) / i * 2 - 1, centerY: 1 - (t + s / 2) / B * 2, radians: this.uA * Math.PI / 180, aspectRatio: Q };
|
|
424
424
|
}
|
|
425
425
|
TA(A, t, e = {}) {
|
|
426
426
|
return new K(this.P, A, t, e);
|
|
@@ -441,10 +441,10 @@ class iA {
|
|
|
441
441
|
this.EA.S(), this.gA.S(), this.nA.S(), this.aA.S();
|
|
442
442
|
}
|
|
443
443
|
kA(A, t, e, s, r) {
|
|
444
|
-
const i = this.P, B = s ?? A.width,
|
|
444
|
+
const i = this.P, B = s ?? A.width, Q = r ?? A.height;
|
|
445
445
|
this.IA(this.EA), this.GA("u_texture", A.texture);
|
|
446
|
-
const n = this.$A(t, e, B,
|
|
447
|
-
this.GA("u_rotation", n.radians), this.GA("u_center", [n.centerX, n.centerY]), this.GA("u_aspectRatio", n.aspectRatio), this.nA.BA(t, e, B,
|
|
446
|
+
const n = this.$A(t, e, B, Q);
|
|
447
|
+
this.GA("u_rotation", n.radians), this.GA("u_center", [n.centerX, n.centerY]), this.GA("u_aspectRatio", n.aspectRatio), this.nA.BA(t, e, B, Q), i.bindTexture(i.TEXTURE_2D, null), this.oA = null;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
const f = { readShort: (E, A) => (f.t.uint16[0] = E[A] << 8 | E[A + 1], f.t.int16[0]), readUshort: (E, A) => E[A] << 8 | E[A + 1], readUshorts(E, A, t) {
|
|
@@ -467,7 +467,7 @@ const f = { readShort: (E, A) => (f.t.uint16[0] = E[A] << 8 | E[A + 1], f.t.int1
|
|
|
467
467
|
const s = f, r = s.readUshort, i = r(E, A += 2);
|
|
468
468
|
A += 2;
|
|
469
469
|
const B = [];
|
|
470
|
-
for (let
|
|
470
|
+
for (let Q = 0; Q < i; Q++) {
|
|
471
471
|
const n = r(E, A), g = r(E, A += 2);
|
|
472
472
|
A += 2;
|
|
473
473
|
const a = s.readUint(E, A);
|
|
@@ -486,10 +486,10 @@ const f = { readShort: (E, A) => (f.t.uint16[0] = E[A] << 8 | E[A + 1], f.t.int1
|
|
|
486
486
|
}, parse4(E, A) {
|
|
487
487
|
const t = f, e = t.readUshort, s = t.readUshorts, r = A, i = e(E, A += 2);
|
|
488
488
|
A += 2;
|
|
489
|
-
const B = e(E, A += 2) >>> 1,
|
|
490
|
-
A += 2,
|
|
491
|
-
for (let n = 0; n < B; n++)
|
|
492
|
-
return
|
|
489
|
+
const B = e(E, A += 2) >>> 1, Q = { format: 4, searchRange: e(E, A += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
|
|
490
|
+
A += 2, Q.entrySelector = e(E, A), A += 2, Q.rangeShift = e(E, A), A += 2, Q.endCount = s(E, A, B), A += 2 * B, A += 2, Q.startCount = s(E, A, B), A += 2 * B;
|
|
491
|
+
for (let n = 0; n < B; n++) Q.idDelta.push(t.readShort(E, A)), A += 2;
|
|
492
|
+
return Q.idRangeOffset = s(E, A, B), A += 2 * B, Q.glyphIdArray = s(E, A, r + i - A >> 1), Q;
|
|
493
493
|
}, parse12(E, A) {
|
|
494
494
|
const t = f.readUint;
|
|
495
495
|
t(E, A += 4), t(E, A += 4);
|
|
@@ -509,32 +509,32 @@ const f = { readShort: (E, A) => (f.t.uint16[0] = E[A] << 8 | E[A + 1], f.t.int1
|
|
|
509
509
|
A += 2;
|
|
510
510
|
const B = e.readShort(E, A);
|
|
511
511
|
A += 2;
|
|
512
|
-
const
|
|
513
|
-
return A += 2, A += 6, { unitsPerEm: s, xMin: r, yMin: i, xMax: B, yMax:
|
|
514
|
-
} },
|
|
512
|
+
const Q = e.readShort(E, A);
|
|
513
|
+
return A += 2, A += 6, { unitsPerEm: s, xMin: r, yMin: i, xMax: B, yMax: Q, indexToLocFormat: e.readShort(E, A) };
|
|
514
|
+
} }, oA = { parseTab(E, A, t) {
|
|
515
515
|
const e = f;
|
|
516
516
|
A += 4;
|
|
517
517
|
const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], r = {};
|
|
518
518
|
for (let i = 0; i < s.length; i++) {
|
|
519
|
-
const B = s[i],
|
|
520
|
-
r[B] =
|
|
519
|
+
const B = s[i], Q = B === "advanceWidthMax" || B === "numberOfHMetrics" ? e.readUshort : e.readShort;
|
|
520
|
+
r[B] = Q(E, A + 2 * i);
|
|
521
521
|
}
|
|
522
522
|
return r;
|
|
523
|
-
} },
|
|
523
|
+
} }, QA = { parseTab(E, A, t, e) {
|
|
524
524
|
if (!e) throw Error("Font object required for hmtx parsing");
|
|
525
|
-
const s = f, r = [], i = [], B = e.maxp.numGlyphs,
|
|
525
|
+
const s = f, r = [], i = [], B = e.maxp.numGlyphs, Q = e.hhea.numberOfHMetrics;
|
|
526
526
|
let n = 0, g = 0, a = 0;
|
|
527
|
-
for (; a <
|
|
527
|
+
for (; a < Q; ) n = s.readUshort(E, A + (a << 2)), g = s.readShort(E, A + (a << 2) + 2), r.push(n), i.push(g), a++;
|
|
528
528
|
for (; a < B; ) r.push(n), i.push(g), a++;
|
|
529
529
|
return { aWidth: r, lsBearing: i };
|
|
530
|
-
} }, H = { cmap: BA, head: EA, hhea:
|
|
530
|
+
} }, H = { cmap: BA, head: EA, hhea: oA, maxp: { parseTab(E, A, t) {
|
|
531
531
|
const e = f;
|
|
532
532
|
return e.readUint(E, A), A += 4, { numGlyphs: e.readUshort(E, A) };
|
|
533
|
-
} }, hmtx:
|
|
533
|
+
} }, hmtx: QA, loca: { parseTab(E, A, t, e) {
|
|
534
534
|
if (!e) throw Error("Font object required for loca parsing");
|
|
535
535
|
const s = f, r = [], i = e.head.indexToLocFormat, B = e.maxp.numGlyphs + 1;
|
|
536
|
-
if (i === 0) for (let
|
|
537
|
-
else if (i === 1) for (let
|
|
536
|
+
if (i === 0) for (let Q = 0; Q < B; Q++) r.push(s.readUshort(E, A + (Q << 1)) << 1);
|
|
537
|
+
else if (i === 1) for (let Q = 0; Q < B; Q++) r.push(s.readUint(E, A + (Q << 2)));
|
|
538
538
|
return r;
|
|
539
539
|
} }, glyf: { parseTab(E, A, t, e) {
|
|
540
540
|
if (!e) throw Error("Font object required for glyf parsing");
|
|
@@ -552,9 +552,9 @@ const f = { readShort: (E, A) => (f.t.uint16[0] = E[A] << 8 | E[A + 1], f.t.int1
|
|
|
552
552
|
if (B.noc > 0) {
|
|
553
553
|
B.endPts = [];
|
|
554
554
|
for (let h = 0; h < B.noc; h++) B.endPts.push(t.readUshort(e, i)), i += 2;
|
|
555
|
-
const
|
|
556
|
-
if (i += 2, e.length - i <
|
|
557
|
-
i +=
|
|
555
|
+
const Q = t.readUshort(e, i);
|
|
556
|
+
if (i += 2, e.length - i < Q) return null;
|
|
557
|
+
i += Q;
|
|
558
558
|
const n = B.endPts[B.noc - 1] + 1;
|
|
559
559
|
B.flags = [];
|
|
560
560
|
for (let h = 0; h < n; h++) {
|
|
@@ -582,11 +582,11 @@ const f = { readShort: (E, A) => (f.t.uint16[0] = E[A] << 8 | E[A + 1], f.t.int1
|
|
|
582
582
|
} } }, w = { parse: (E) => [((A, t, e, s) => {
|
|
583
583
|
const r = H, i = { RA: A, zA: t, HA: e };
|
|
584
584
|
for (const B in r) {
|
|
585
|
-
const
|
|
585
|
+
const Q = B, n = w.findTable(A, Q, e);
|
|
586
586
|
if (n) {
|
|
587
587
|
const [g, a] = n;
|
|
588
588
|
let h = s[g];
|
|
589
|
-
h == null && (h = r[
|
|
589
|
+
h == null && (h = r[Q].parseTab(A, g, a, i), s[g] = h), i[Q] = h;
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
592
|
return i;
|
|
@@ -596,16 +596,16 @@ const f = { readShort: (E, A) => (f.t.uint16[0] = E[A] << 8 | E[A + 1], f.t.int1
|
|
|
596
596
|
for (let i = 0; i < s; i++) {
|
|
597
597
|
const B = e.readASCII(E, r, 4);
|
|
598
598
|
e.readUint(E, r + 4);
|
|
599
|
-
const
|
|
600
|
-
if (B === A) return [
|
|
599
|
+
const Q = e.readUint(E, r + 8), n = e.readUint(E, r + 12);
|
|
600
|
+
if (B === A) return [Q, n];
|
|
601
601
|
r += 16;
|
|
602
602
|
}
|
|
603
603
|
return null;
|
|
604
604
|
}, T: H, B: f };
|
|
605
605
|
class U {
|
|
606
606
|
constructor() {
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
o(this, "LA", /* @__PURE__ */ new Map());
|
|
608
|
+
o(this, "JA", /* @__PURE__ */ new Map());
|
|
609
609
|
}
|
|
610
610
|
KA(A) {
|
|
611
611
|
const t = this.WA(A);
|
|
@@ -675,7 +675,7 @@ class U {
|
|
|
675
675
|
}
|
|
676
676
|
class nA {
|
|
677
677
|
constructor(A) {
|
|
678
|
-
|
|
678
|
+
o(this, "et");
|
|
679
679
|
this.et = A;
|
|
680
680
|
}
|
|
681
681
|
st(A) {
|
|
@@ -727,8 +727,8 @@ class nA {
|
|
|
727
727
|
const s = A.groups[e], r = A.groups[e + 1], i = A.groups[e + 2];
|
|
728
728
|
for (let B = s; B <= r; B++)
|
|
729
729
|
if (i + (B - s) > 0) try {
|
|
730
|
-
const
|
|
731
|
-
t.push(
|
|
730
|
+
const Q = String.fromCodePoint(B);
|
|
731
|
+
t.push(Q);
|
|
732
732
|
} catch {
|
|
733
733
|
}
|
|
734
734
|
}
|
|
@@ -752,7 +752,7 @@ class nA {
|
|
|
752
752
|
}
|
|
753
753
|
class gA {
|
|
754
754
|
constructor() {
|
|
755
|
-
|
|
755
|
+
o(this, "ht");
|
|
756
756
|
const A = new U();
|
|
757
757
|
this.ht = new nA(A);
|
|
758
758
|
}
|
|
@@ -771,16 +771,16 @@ class gA {
|
|
|
771
771
|
}
|
|
772
772
|
class hA {
|
|
773
773
|
constructor(A) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
774
|
+
o(this, "lt");
|
|
775
|
+
o(this, "ct");
|
|
776
|
+
o(this, "Dt");
|
|
777
|
+
o(this, "Ct");
|
|
778
778
|
this.Dt = A, this.Ct = new U(), this.lt = document.createElement("canvas"), this.ct = this.lt.getContext("2d", { willReadFrequently: !0, alpha: !1 });
|
|
779
779
|
}
|
|
780
780
|
createTextureAtlas(A, t, e, s) {
|
|
781
|
-
const r = A.length, i = Math.ceil(Math.sqrt(r)), B = Math.ceil(r / i),
|
|
782
|
-
this.ut(
|
|
783
|
-
const a = this.Dt.TA(
|
|
781
|
+
const r = A.length, i = Math.ceil(Math.sqrt(r)), B = Math.ceil(r / i), Q = t.width * i, n = t.height * B, g = typeof s == "object" ? s : null;
|
|
782
|
+
this.ut(Q, n), this.Pt(A, t, i, e, g);
|
|
783
|
+
const a = this.Dt.TA(Q, n, { filter: "nearest" });
|
|
784
784
|
return a.update(this.lt), { framebuffer: a, columns: i, rows: B };
|
|
785
785
|
}
|
|
786
786
|
ut(A, t) {
|
|
@@ -789,9 +789,9 @@ class hA {
|
|
|
789
789
|
Pt(A, t, e, s, r) {
|
|
790
790
|
const i = s / r.head.unitsPerEm;
|
|
791
791
|
for (let B = 0; B < A.length; B++) {
|
|
792
|
-
const
|
|
792
|
+
const Q = B % e, n = Math.floor(B / e), g = A[B].character, a = this.It(r, g);
|
|
793
793
|
if (!a) continue;
|
|
794
|
-
const h = g.codePointAt(0) || 0, D = this.Ct.jA(r, h), c = this.wt(r, D) * i, l =
|
|
794
|
+
const h = g.codePointAt(0) || 0, D = this.Ct.jA(r, h), c = this.wt(r, D) * i, l = Q * t.width, d = n * t.height, C = l + 0.5 * t.width, P = d + 0.5 * t.height, p = Math.round(C - 0.5 * t.width), m = Math.round(P - 0.5 * s), y = p + 0.5 * (t.width - c), b = m + r.hhea.ascender * i;
|
|
795
795
|
this.ft(a, y, b, i);
|
|
796
796
|
}
|
|
797
797
|
}
|
|
@@ -811,8 +811,8 @@ class hA {
|
|
|
811
811
|
}
|
|
812
812
|
ft(A, t, e, s) {
|
|
813
813
|
if (!A || !A.xs || A.noc === 0) return;
|
|
814
|
-
const { xs: r, ys: i, endPts: B, flags:
|
|
815
|
-
if (!(r && i && B &&
|
|
814
|
+
const { xs: r, ys: i, endPts: B, flags: Q } = A;
|
|
815
|
+
if (!(r && i && B && Q)) return;
|
|
816
816
|
this.ct.beginPath();
|
|
817
817
|
let n = 0;
|
|
818
818
|
for (let g = 0; g < B.length; g++) {
|
|
@@ -823,13 +823,13 @@ class hA {
|
|
|
823
823
|
this.ct.moveTo(h, D);
|
|
824
824
|
let c = n + 1;
|
|
825
825
|
for (; c <= a; )
|
|
826
|
-
if (1 &
|
|
826
|
+
if (1 & Q[c]) {
|
|
827
827
|
const l = t + r[c] * s, d = e - i[c] * s;
|
|
828
828
|
this.ct.lineTo(l, d), c++;
|
|
829
829
|
} else {
|
|
830
830
|
const l = t + r[c] * s, d = e - i[c] * s;
|
|
831
831
|
let C = c + 1 > a ? n : c + 1;
|
|
832
|
-
if (1 &
|
|
832
|
+
if (1 & Q[C]) {
|
|
833
833
|
const P = t + r[C] * s, p = e - i[C] * s;
|
|
834
834
|
this.ct.quadraticCurveTo(l, d, P, p), c = C + 1;
|
|
835
835
|
} else {
|
|
@@ -847,16 +847,16 @@ class hA {
|
|
|
847
847
|
}
|
|
848
848
|
class aA {
|
|
849
849
|
constructor() {
|
|
850
|
-
|
|
850
|
+
o(this, "et");
|
|
851
851
|
this.et = new U();
|
|
852
852
|
}
|
|
853
853
|
calculateMaxGlyphDimensions(A, t, e) {
|
|
854
854
|
let s = 0;
|
|
855
855
|
const r = this.et.At(e, t), i = r.lineHeight;
|
|
856
856
|
for (const B of A) {
|
|
857
|
-
const
|
|
858
|
-
if (
|
|
859
|
-
const n = this.et.qA(e,
|
|
857
|
+
const Q = this.et.XA(e, B);
|
|
858
|
+
if (Q === 0) continue;
|
|
859
|
+
const n = this.et.qA(e, Q) * r.scale;
|
|
860
860
|
s = Math.max(s, n);
|
|
861
861
|
}
|
|
862
862
|
return { width: Math.ceil(s), height: Math.ceil(i) };
|
|
@@ -874,7 +874,7 @@ class aA {
|
|
|
874
874
|
}
|
|
875
875
|
class lA {
|
|
876
876
|
constructor() {
|
|
877
|
-
|
|
877
|
+
o(this, "Ct");
|
|
878
878
|
this.Ct = new U();
|
|
879
879
|
}
|
|
880
880
|
createCharacterObjects(A, t) {
|
|
@@ -882,8 +882,8 @@ class lA {
|
|
|
882
882
|
const r = e.codePointAt(0) || 0, i = this.dt(s);
|
|
883
883
|
let B = 0;
|
|
884
884
|
if (t.hmtx && t.hmtx.aWidth) {
|
|
885
|
-
const
|
|
886
|
-
|
|
885
|
+
const Q = this.Ct.jA(t, r);
|
|
886
|
+
Q > 0 && t.hmtx.aWidth[Q] !== void 0 && (B = t.hmtx.aWidth[Q]);
|
|
887
887
|
}
|
|
888
888
|
return { character: e, unicode: r, color: i, advanceWidth: B };
|
|
889
889
|
});
|
|
@@ -902,19 +902,19 @@ class lA {
|
|
|
902
902
|
}
|
|
903
903
|
class cA {
|
|
904
904
|
constructor(A, t = 16) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
905
|
+
o(this, "_t");
|
|
906
|
+
o(this, "vt", []);
|
|
907
|
+
o(this, "bt");
|
|
908
|
+
o(this, "xt", 16);
|
|
909
|
+
o(this, "yt", 0);
|
|
910
|
+
o(this, "Mt", 0);
|
|
911
|
+
o(this, "Gt", { width: 0, height: 0 });
|
|
912
|
+
o(this, "Ft");
|
|
913
|
+
o(this, "$t", "UrsaFont");
|
|
914
|
+
o(this, "Yt");
|
|
915
|
+
o(this, "Tt");
|
|
916
|
+
o(this, "St");
|
|
917
|
+
o(this, "Ot");
|
|
918
918
|
this.xt = t, this.Yt = new gA(), this.Tt = new hA(A), this.St = new aA(), this.Ot = new lA();
|
|
919
919
|
}
|
|
920
920
|
async Ut(A) {
|
|
@@ -996,16 +996,16 @@ class cA {
|
|
|
996
996
|
}
|
|
997
997
|
class DA {
|
|
998
998
|
constructor(A, t, e) {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
999
|
+
o(this, "zt");
|
|
1000
|
+
o(this, "Lt");
|
|
1001
|
+
o(this, "p");
|
|
1002
|
+
o(this, "_");
|
|
1003
|
+
o(this, "Jt");
|
|
1004
|
+
o(this, "Kt");
|
|
1005
|
+
o(this, "Wt", !1);
|
|
1006
|
+
o(this, "jt");
|
|
1007
|
+
o(this, "Nt");
|
|
1008
|
+
o(this, "Zt");
|
|
1009
1009
|
this.jt = A, this.Nt = t, this.Zt = e, this.xA();
|
|
1010
1010
|
}
|
|
1011
1011
|
xA() {
|
|
@@ -1057,11 +1057,11 @@ class DA {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
class CA {
|
|
1059
1059
|
constructor(A, t = !1, e = {}) {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1060
|
+
o(this, "jt");
|
|
1061
|
+
o(this, "re");
|
|
1062
|
+
o(this, "Be");
|
|
1063
|
+
o(this, "ie");
|
|
1064
|
+
o(this, "onTransformChange");
|
|
1065
1065
|
this.re = A, this.Be = t, this.jt = this.Qe(e.width, e.height), t && this.setupTransformObserver();
|
|
1066
1066
|
}
|
|
1067
1067
|
Qe(A, t) {
|
|
@@ -1076,8 +1076,8 @@ class CA {
|
|
|
1076
1076
|
(i === 0 || B === 0) && g.videoWidth > 0 && g.videoHeight > 0 && (i = g.videoWidth, B = g.videoHeight);
|
|
1077
1077
|
}
|
|
1078
1078
|
e.width = i, e.height = B, e.style.position = "absolute", e.style.pointerEvents = "none";
|
|
1079
|
-
const
|
|
1080
|
-
let n = parseInt(
|
|
1079
|
+
const Q = window.getComputedStyle(this.re);
|
|
1080
|
+
let n = parseInt(Q.zIndex || "0", 10);
|
|
1081
1081
|
isNaN(n) && (n = 0), e.style.zIndex = "" + (n + 1), this.Ee(e), (s = this.re.parentNode) == null || s.insertBefore(e, this.re.nextSibling);
|
|
1082
1082
|
}
|
|
1083
1083
|
return e;
|
|
@@ -1136,15 +1136,15 @@ class CA {
|
|
|
1136
1136
|
}
|
|
1137
1137
|
class M {
|
|
1138
1138
|
constructor(A, t, e, s = {}) {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1139
|
+
o(this, "Dt");
|
|
1140
|
+
o(this, "oe");
|
|
1141
|
+
o(this, "ne");
|
|
1142
|
+
o(this, "ae");
|
|
1143
|
+
o(this, "he");
|
|
1144
|
+
o(this, "le");
|
|
1145
|
+
o(this, "ce");
|
|
1146
|
+
o(this, "De");
|
|
1147
|
+
o(this, "h");
|
|
1148
1148
|
this.Dt = A, this.oe = t, this.ne = e, this.h = s;
|
|
1149
1149
|
const r = this.ne.cols, i = this.ne.rows;
|
|
1150
1150
|
this.ae = this.Dt.TA(r, i), this.he = this.Dt.TA(r, i), this.le = this.Dt.TA(r, i), this.ce = this.Dt.TA(r, i), this.De = this.Dt.TA(r, i);
|
|
@@ -1186,9 +1186,9 @@ class M {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
class uA {
|
|
1188
1188
|
constructor(A, t) {
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1189
|
+
o(this, "I");
|
|
1190
|
+
o(this, "Dt");
|
|
1191
|
+
o(this, "Ce");
|
|
1192
1192
|
this.Dt = A, this.Ce = t;
|
|
1193
1193
|
const e = Math.max(this.Ce.length, 1);
|
|
1194
1194
|
this.I = this.Dt.TA(e, 1), this.ue();
|
|
@@ -1219,7 +1219,7 @@ class uA {
|
|
|
1219
1219
|
class O extends M {
|
|
1220
1220
|
constructor(t, e, s, r = {}) {
|
|
1221
1221
|
super(t, e, s, r);
|
|
1222
|
-
|
|
1222
|
+
o(this, "Pe");
|
|
1223
1223
|
this.Pe = new uA(this.Dt, this.oe.getCharacterColors(" .:-=+*%@#"));
|
|
1224
1224
|
}
|
|
1225
1225
|
characters(t) {
|
|
@@ -1255,13 +1255,13 @@ class O extends M {
|
|
|
1255
1255
|
this.fe(t, "flipVertically", "Flip vertically");
|
|
1256
1256
|
}
|
|
1257
1257
|
Ie(t, e, s, r, i = 255) {
|
|
1258
|
-
let B,
|
|
1258
|
+
let B, Q, n, g;
|
|
1259
1259
|
if (typeof t == "string") {
|
|
1260
1260
|
const a = this.de(t);
|
|
1261
1261
|
if (!a) return u.C(!1, "Invalid hex color format. Use '#FF0000', '#F00', 'FF0000', or 'F00'.", { method: e, providedValue: t }), null;
|
|
1262
|
-
[B,
|
|
1263
|
-
} else if (B = t,
|
|
1264
|
-
return [B / 255,
|
|
1262
|
+
[B, Q, n, g] = a;
|
|
1263
|
+
} else if (B = t, Q = s !== void 0 ? s : t, n = r !== void 0 ? r : t, g = i, !u.C([B, Q, n, g].every((a) => a >= 0 && a <= 255), e.charAt(0).toUpperCase() + e.slice(1) + " color values must be between 0 and 255", { method: e, providedValues: { r: B, g: Q, b: n, a: g } })) return null;
|
|
1264
|
+
return [B / 255, Q / 255, n / 255, g / 255];
|
|
1265
1265
|
}
|
|
1266
1266
|
we(t, e) {
|
|
1267
1267
|
u.C(["sampled", "fixed"].includes(t), "Invalid color mode. Must be 'sampled' or 'fixed'.", { method: e, providedValue: t }) && (this.h[e] = t);
|
|
@@ -1315,12 +1315,12 @@ void main() {\r
|
|
|
1315
1315
|
class S extends O {
|
|
1316
1316
|
constructor(t, e, s) {
|
|
1317
1317
|
super(t, e, s, { ...PA });
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1318
|
+
o(this, "me");
|
|
1319
|
+
o(this, "pe");
|
|
1320
|
+
o(this, "_e");
|
|
1321
|
+
o(this, "ve");
|
|
1322
|
+
o(this, "be");
|
|
1323
|
+
o(this, "xe");
|
|
1324
1324
|
this.me = new x(t.context, T, "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.pe = new x(t.context, T, "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.ve = new x(t.context, T, "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.be = new x(t.context, T, "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._e = new x(t.context, T, "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.xe = this.Dt.TA(this.ne.cols, this.ne.rows);
|
|
1325
1325
|
}
|
|
1326
1326
|
ye(t) {
|
|
@@ -1337,19 +1337,19 @@ class S extends O {
|
|
|
1337
1337
|
const OA = Object.freeze(Object.defineProperty({ __proto__: null, TextmodeBrightnessConverter: S, TextmodeConverter: M, TextmodeFeatureConverter: O }, Symbol.toStringTag, { value: "Module" }));
|
|
1338
1338
|
class dA {
|
|
1339
1339
|
constructor(A, t, e) {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1340
|
+
o(this, "Dt");
|
|
1341
|
+
o(this, "_t");
|
|
1342
|
+
o(this, "ne");
|
|
1343
|
+
o(this, "Me");
|
|
1344
|
+
o(this, "Ge");
|
|
1345
|
+
o(this, "Fe");
|
|
1346
|
+
o(this, "$e");
|
|
1347
|
+
o(this, "Ye");
|
|
1348
|
+
o(this, "ae");
|
|
1349
|
+
o(this, "he");
|
|
1350
|
+
o(this, "le");
|
|
1351
|
+
o(this, "ce");
|
|
1352
|
+
o(this, "De");
|
|
1353
1353
|
this.Dt = A, this._t = t, this.ne = e, this.Ye = this.Dt.yA(R, "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.Ge = new S(A, t, e), this.Fe = new M(A, t, e), this.Me = [this.Ge, this.Fe], this.ae = this.Dt.TA(e.cols, e.rows), this.he = this.Dt.TA(e.cols, e.rows), this.le = this.Dt.TA(e.cols, e.rows), this.ce = this.Dt.TA(e.cols, e.rows), this.De = this.Dt.TA(e.cols, e.rows), this.$e = this.Dt.TA(this.ne.width, this.ne.height);
|
|
1354
1354
|
}
|
|
1355
1355
|
Te(A) {
|
|
@@ -1372,13 +1372,13 @@ class dA {
|
|
|
1372
1372
|
u.C(t !== -1, "Converter instance not found in pipeline.", { method: "remove", providedValue: A, convertersCount: this.Me.length }) && this.Me.splice(t, 1);
|
|
1373
1373
|
}
|
|
1374
1374
|
swap(A, t) {
|
|
1375
|
-
const e = (B,
|
|
1376
|
-
if (typeof B == "number") return u.C(Number.isInteger(B) && B >= 0 && B < this.Me.length,
|
|
1375
|
+
const e = (B, Q) => {
|
|
1376
|
+
if (typeof B == "number") return u.C(Number.isInteger(B) && B >= 0 && B < this.Me.length, Q + " index must be a valid integer within the converter array bounds.", { method: "swap", providedValue: B, convertersCount: this.Me.length }) ? B : null;
|
|
1377
1377
|
if (B instanceof M) {
|
|
1378
1378
|
const n = this.Me.indexOf(B);
|
|
1379
|
-
return u.C(n !== -1,
|
|
1379
|
+
return u.C(n !== -1, Q + " converter instance not found in pipeline.", { method: "swap", providedValue: B, convertersCount: this.Me.length }) ? n : null;
|
|
1380
1380
|
}
|
|
1381
|
-
return u.C(!1,
|
|
1381
|
+
return u.C(!1, Q + " parameter must be either an integer index or a TextmodeConverter instance.", { method: "swap", providedValue: B }), null;
|
|
1382
1382
|
}, s = e(A, "First"), r = e(t, "Second");
|
|
1383
1383
|
if (s === null || r === null || !u.C(s !== r, "Cannot swap a converter with itself.", { method: "swap", firstIndex: s, secondIndex: r })) return;
|
|
1384
1384
|
const i = this.Me[s];
|
|
@@ -1524,8 +1524,8 @@ class k {
|
|
|
1524
1524
|
}
|
|
1525
1525
|
class fA extends L {
|
|
1526
1526
|
Je(A, t, e) {
|
|
1527
|
-
const s = A[e] === 255, r = A[e + 1] === 255, i = A[e + 2] === 255, B = t[e],
|
|
1528
|
-
return { isInverted: s, flipHorizontal: r, flipVertical: i, rotation: Math.round(360 * (B +
|
|
1527
|
+
const s = A[e] === 255, r = A[e + 1] === 255, i = A[e + 2] === 255, B = t[e], Q = t[e + 1];
|
|
1528
|
+
return { isInverted: s, flipHorizontal: r, flipVertical: i, rotation: Math.round(360 * (B + Q / 255) / 255 * 100) / 100 };
|
|
1529
1529
|
}
|
|
1530
1530
|
Ke(A, t, e) {
|
|
1531
1531
|
return { x: A, y: t, cellX: A * e.cellWidth, cellY: t * e.cellHeight };
|
|
@@ -1534,7 +1534,7 @@ class fA extends L {
|
|
|
1534
1534
|
const e = [];
|
|
1535
1535
|
let s = 0;
|
|
1536
1536
|
for (let r = 0; r < t.rows; r++) for (let i = 0; i < t.cols; i++) {
|
|
1537
|
-
const B = 4 * s,
|
|
1537
|
+
const B = 4 * s, Q = this.Oe(A.characterPixels, B);
|
|
1538
1538
|
let n = this.Ue(A.primaryColorPixels, B), g = this.Ue(A.secondaryColorPixels, B);
|
|
1539
1539
|
const a = this.Je(A.transformPixels, A.rotationPixels, B);
|
|
1540
1540
|
if (a.isInverted) {
|
|
@@ -1542,7 +1542,7 @@ class fA extends L {
|
|
|
1542
1542
|
n = g, g = D;
|
|
1543
1543
|
}
|
|
1544
1544
|
const h = this.Ke(i, r, t);
|
|
1545
|
-
e.push({ charIndex:
|
|
1545
|
+
e.push({ charIndex: Q, primaryColor: n, secondaryColor: g, transform: a, position: h }), s++;
|
|
1546
1546
|
}
|
|
1547
1547
|
return e;
|
|
1548
1548
|
}
|
|
@@ -1570,8 +1570,8 @@ class wA {
|
|
|
1570
1570
|
}
|
|
1571
1571
|
Ze(A, t, e, s) {
|
|
1572
1572
|
if (!A || !A.xs) return "";
|
|
1573
|
-
const { xs: r, ys: i, endPts: B, flags:
|
|
1574
|
-
if (!(r && i && B &&
|
|
1573
|
+
const { xs: r, ys: i, endPts: B, flags: Q } = A;
|
|
1574
|
+
if (!(r && i && B && Q)) return "";
|
|
1575
1575
|
let n = "", g = 0;
|
|
1576
1576
|
for (let a = 0; a < B.length; a++) {
|
|
1577
1577
|
const h = B[a];
|
|
@@ -1581,13 +1581,13 @@ class wA {
|
|
|
1581
1581
|
n += `M${D.toFixed(2)},${c.toFixed(2)}`;
|
|
1582
1582
|
let l = g + 1;
|
|
1583
1583
|
for (; l <= h; )
|
|
1584
|
-
if (1 &
|
|
1584
|
+
if (1 & Q[l]) {
|
|
1585
1585
|
const d = t + r[l] * s, C = e - i[l] * s;
|
|
1586
1586
|
n += `L${d.toFixed(2)},${C.toFixed(2)}`, l++;
|
|
1587
1587
|
} else {
|
|
1588
1588
|
const d = t + r[l] * s, C = e - i[l] * s;
|
|
1589
1589
|
let P = l + 1 > h ? g : l + 1;
|
|
1590
|
-
if (1 &
|
|
1590
|
+
if (1 & Q[P]) {
|
|
1591
1591
|
const p = t + r[P] * s, m = e - i[P] * s;
|
|
1592
1592
|
n += `Q${d.toFixed(2)},${C.toFixed(2)} ${p.toFixed(2)},${m.toFixed(2)}`, l = P + 1;
|
|
1593
1593
|
} else {
|
|
@@ -1604,17 +1604,17 @@ class wA {
|
|
|
1604
1604
|
}
|
|
1605
1605
|
Xe(A, t, e, s, r) {
|
|
1606
1606
|
const i = A.codePointAt(0) || 0, B = this.je(t, i);
|
|
1607
|
-
let
|
|
1608
|
-
return t.glyf && t.glyf[B] !== null ?
|
|
1607
|
+
let Q = null;
|
|
1608
|
+
return t.glyf && t.glyf[B] !== null ? Q = t.glyf[B] : w && w.T && w.T.glyf && w.T.glyf.VA && (Q = w.T.glyf.VA(t, B), t.glyf && Q && (t.glyf[B] = Q)), this.Ne(t, Q, e, s, r);
|
|
1609
1609
|
}
|
|
1610
|
-
qe(A, t, e, s, r, i, B,
|
|
1611
|
-
const n = e + (r -
|
|
1610
|
+
qe(A, t, e, s, r, i, B, Q) {
|
|
1611
|
+
const n = e + (r - Q * (B / t.head.unitsPerEm)) / 2, g = s + (i + 0.7 * B) / 2;
|
|
1612
1612
|
return this.Xe(A, t, n, g, B).toSVG() || null;
|
|
1613
1613
|
}
|
|
1614
1614
|
}
|
|
1615
1615
|
class pA {
|
|
1616
1616
|
constructor() {
|
|
1617
|
-
|
|
1617
|
+
o(this, "As");
|
|
1618
1618
|
this.As = new wA();
|
|
1619
1619
|
}
|
|
1620
1620
|
ts(A) {
|
|
@@ -1642,8 +1642,8 @@ class pA {
|
|
|
1642
1642
|
Bs(A, t) {
|
|
1643
1643
|
const { transform: e, position: s } = A, r = s.cellX + t.cellWidth / 2, i = s.cellY + t.cellHeight / 2, B = [];
|
|
1644
1644
|
if (e.flipHorizontal || e.flipVertical) {
|
|
1645
|
-
const
|
|
1646
|
-
B.push(`translate(${r} ${i})`), B.push(`scale(${
|
|
1645
|
+
const Q = e.flipHorizontal ? -1 : 1, n = e.flipVertical ? -1 : 1;
|
|
1646
|
+
B.push(`translate(${r} ${i})`), B.push(`scale(${Q} ${n})`), B.push(`translate(${-r} ${-i})`);
|
|
1647
1647
|
}
|
|
1648
1648
|
return e.rotation && B.push(`rotate(${e.rotation} ${r} ${i})`), B.length ? ` transform="${B.join(" ")}"` : "";
|
|
1649
1649
|
}
|
|
@@ -1697,9 +1697,9 @@ class mA extends k {
|
|
|
1697
1697
|
}
|
|
1698
1698
|
class $ {
|
|
1699
1699
|
constructor() {
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1700
|
+
o(this, "Ds");
|
|
1701
|
+
o(this, "Cs");
|
|
1702
|
+
o(this, "us");
|
|
1703
1703
|
this.Ds = new fA(), this.Cs = new pA(), this.us = new mA();
|
|
1704
1704
|
}
|
|
1705
1705
|
Ps(A) {
|
|
@@ -1719,7 +1719,7 @@ class xA extends L {
|
|
|
1719
1719
|
var B;
|
|
1720
1720
|
const r = [];
|
|
1721
1721
|
let i = 0;
|
|
1722
|
-
for (let
|
|
1722
|
+
for (let Q = 0; Q < t.rows; Q++) {
|
|
1723
1723
|
const n = [];
|
|
1724
1724
|
for (let g = 0; g < t.cols; g++) {
|
|
1725
1725
|
const a = 4 * i, h = this.Oe(A.characterPixels, a), D = ((B = e.characters[h]) == null ? void 0 : B.character) || s;
|
|
@@ -1755,9 +1755,9 @@ class vA extends k {
|
|
|
1755
1755
|
}
|
|
1756
1756
|
class N {
|
|
1757
1757
|
constructor() {
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1758
|
+
o(this, "Ds");
|
|
1759
|
+
o(this, "Cs");
|
|
1760
|
+
o(this, "us");
|
|
1761
1761
|
this.Ds = new xA(), this.Cs = new bA(), this.us = new vA();
|
|
1762
1762
|
}
|
|
1763
1763
|
Ps(A) {
|
|
@@ -1776,8 +1776,8 @@ class yA extends L {
|
|
|
1776
1776
|
vs(A, t = 1, e = "transparent") {
|
|
1777
1777
|
const s = A.canvas;
|
|
1778
1778
|
if (t === 1 && e === "transparent") return s;
|
|
1779
|
-
const r = document.createElement("canvas"), i = r.getContext("2d"), B = Math.round(s.width * t),
|
|
1780
|
-
return r.width = B, r.height =
|
|
1779
|
+
const r = document.createElement("canvas"), i = r.getContext("2d"), B = Math.round(s.width * t), Q = Math.round(s.height * t);
|
|
1780
|
+
return r.width = B, r.height = Q, e !== "transparent" && (i.fillStyle = e, i.fillRect(0, 0, B, Q)), i.imageSmoothingEnabled = !1, i.drawImage(s, 0, 0, s.width, s.height, 0, 0, B, Q), r;
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
1783
|
class _A {
|
|
@@ -1826,9 +1826,9 @@ class GA extends k {
|
|
|
1826
1826
|
}
|
|
1827
1827
|
class TA {
|
|
1828
1828
|
constructor() {
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1829
|
+
o(this, "Ds");
|
|
1830
|
+
o(this, "Cs");
|
|
1831
|
+
o(this, "us");
|
|
1832
1832
|
this.Ds = new yA(), this.Cs = new _A(), this.us = new GA();
|
|
1833
1833
|
}
|
|
1834
1834
|
Ps(A) {
|
|
@@ -1896,11 +1896,11 @@ const RA = (E) => class extends E {
|
|
|
1896
1896
|
};
|
|
1897
1897
|
class YA {
|
|
1898
1898
|
constructor() {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1899
|
+
o(this, "Dt");
|
|
1900
|
+
o(this, "_t");
|
|
1901
|
+
o(this, "Os");
|
|
1902
|
+
o(this, "jt");
|
|
1903
|
+
o(this, "ne");
|
|
1904
1904
|
}
|
|
1905
1905
|
}
|
|
1906
1906
|
class z extends function(t, ...e) {
|
|
@@ -1908,35 +1908,35 @@ class z extends function(t, ...e) {
|
|
|
1908
1908
|
}(YA, IA, RA, FA, UA) {
|
|
1909
1909
|
constructor(t = null, e = {}) {
|
|
1910
1910
|
super();
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1911
|
+
o(this, "re");
|
|
1912
|
+
o(this, "Us");
|
|
1913
|
+
o(this, "ie");
|
|
1914
|
+
o(this, "ks");
|
|
1915
|
+
o(this, "Vs");
|
|
1916
|
+
o(this, "Rs", null);
|
|
1917
|
+
o(this, "Hs", 0);
|
|
1918
|
+
o(this, "zs");
|
|
1919
|
+
o(this, "Ls", !0);
|
|
1920
|
+
o(this, "Js", 0);
|
|
1921
|
+
o(this, "Ks", 0);
|
|
1922
|
+
o(this, "Ws", 0);
|
|
1923
|
+
o(this, "js", []);
|
|
1924
|
+
o(this, "Ns", 10);
|
|
1925
|
+
o(this, "Zs", !1);
|
|
1926
|
+
o(this, "Xs", !1);
|
|
1927
|
+
o(this, "qs", () => {
|
|
1928
1928
|
});
|
|
1929
|
-
|
|
1929
|
+
o(this, "Ar", () => {
|
|
1930
1930
|
});
|
|
1931
|
-
|
|
1931
|
+
o(this, "tr");
|
|
1932
1932
|
this.re = t, this.Xs = t === null, this.ks = e.renderMode ?? "auto", this.Vs = e.frameRate ?? 60, this.zs = 1e3 / this.Vs;
|
|
1933
1933
|
}
|
|
1934
1934
|
static async create(t = null, e = {}) {
|
|
1935
1935
|
const s = new this(t, e), r = s.Xs ? e : void 0;
|
|
1936
1936
|
let i, B;
|
|
1937
1937
|
s.jt = new CA(s.re, s.Xs, r), s.Dt = new iA(s.jt.ge()), s.Xs ? (i = e.width || 800, B = e.height || 600) : (i = s.jt.width || 800, B = s.jt.height || 600), s.Us = s.Dt.TA(i, B), s._t = new cA(s.Dt, e.fontSize ?? 16), await s._t.Ut(e.fontSource);
|
|
1938
|
-
const
|
|
1939
|
-
return s.ne = new DA(s.jt.canvas,
|
|
1938
|
+
const Q = s._t.maxGlyphDimensions;
|
|
1939
|
+
return s.ne = new DA(s.jt.canvas, Q.width, Q.height), s.Os = new dA(s.Dt, s._t, s.ne), s.er(), s.sr(), s;
|
|
1940
1940
|
}
|
|
1941
1941
|
er() {
|
|
1942
1942
|
this.tr = () => {
|
|
@@ -2020,6 +2020,9 @@ class z extends function(t, ...e) {
|
|
|
2020
2020
|
get frameCount() {
|
|
2021
2021
|
return this.Ws;
|
|
2022
2022
|
}
|
|
2023
|
+
get renderer() {
|
|
2024
|
+
return this.Dt;
|
|
2025
|
+
}
|
|
2023
2026
|
set frameCount(t) {
|
|
2024
2027
|
this.Ws = t;
|
|
2025
2028
|
}
|
|
@@ -2053,12 +2056,13 @@ class j {
|
|
|
2053
2056
|
u.u(A);
|
|
2054
2057
|
}
|
|
2055
2058
|
static get version() {
|
|
2056
|
-
return "0.1.9-beta.
|
|
2059
|
+
return "0.1.9-beta.4";
|
|
2057
2060
|
}
|
|
2058
2061
|
}
|
|
2059
2062
|
const LA = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), kA = j.create, jA = j.setErrorLevel, VA = j.version;
|
|
2060
2063
|
export {
|
|
2061
2064
|
CA as TextmodeCanvas,
|
|
2065
|
+
uA as TextmodeColorPalette,
|
|
2062
2066
|
dA as TextmodeConversionPipeline,
|
|
2063
2067
|
eA as TextmodeErrorLevel,
|
|
2064
2068
|
cA as TextmodeFont,
|