textmode.js 0.1.4-beta.2 → 0.1.4-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/textmode.esm.js +322 -219
- package/dist/textmode.esm.min.js +402 -299
- package/dist/textmode.umd.js +3 -3
- package/dist/textmode.umd.min.js +12 -12
- package/dist/types/textmode/Textmodifier.d.ts +85 -0
- package/package.json +2 -2
package/dist/textmode.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var iA = Object.defineProperty;
|
|
2
|
-
var sA = (
|
|
3
|
-
var
|
|
2
|
+
var sA = (a, A, e) => A in a ? iA(a, A, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[A] = e;
|
|
3
|
+
var n = (a, A, e) => sA(a, typeof A != "symbol" ? A + "" : A, e);
|
|
4
4
|
class P extends Error {
|
|
5
5
|
constructor(e, t, r = {}) {
|
|
6
6
|
const i = P.createFormattedMessage(e, r);
|
|
7
7
|
super(i);
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
n(this, "originalError");
|
|
9
|
+
n(this, "context");
|
|
10
10
|
this.name = "TextmodeError", this.originalError = t, this.context = r;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -46,10 +46,10 @@ class P extends Error {
|
|
|
46
46
|
return String(e);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
var oA = /* @__PURE__ */ ((
|
|
49
|
+
var oA = /* @__PURE__ */ ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(oA || {});
|
|
50
50
|
const v = class v {
|
|
51
51
|
constructor() {
|
|
52
|
-
|
|
52
|
+
n(this, "_options", {
|
|
53
53
|
globalLevel: 3
|
|
54
54
|
/* THROW */
|
|
55
55
|
});
|
|
@@ -103,19 +103,19 @@ const v = class v {
|
|
|
103
103
|
this._options.globalLevel = A;
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
|
|
106
|
+
n(v, "_instance", null);
|
|
107
107
|
let V = v;
|
|
108
108
|
const f = V.getInstance();
|
|
109
|
-
class
|
|
109
|
+
class nA {
|
|
110
110
|
constructor(A, e, t = e, r = {}) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
n(this, "gl");
|
|
112
|
+
n(this, "_framebuffer");
|
|
113
|
+
n(this, "_texture");
|
|
114
|
+
n(this, "_width");
|
|
115
|
+
n(this, "_height");
|
|
116
|
+
n(this, "options");
|
|
117
|
+
n(this, "previousState", null);
|
|
118
|
+
n(this, "_pixels", null);
|
|
119
119
|
this.gl = A, this._width = e, this._height = t, this.options = {
|
|
120
120
|
filter: "nearest",
|
|
121
121
|
wrap: "clamp",
|
|
@@ -233,22 +233,22 @@ class aA {
|
|
|
233
233
|
}
|
|
234
234
|
class K {
|
|
235
235
|
constructor(A, e, t) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
n(this, "gl");
|
|
237
|
+
n(this, "x");
|
|
238
|
+
n(this, "y");
|
|
239
239
|
this.gl = A, this.x = e, this.y = t;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
class y {
|
|
243
243
|
constructor(A, e, t, r, i) {
|
|
244
244
|
/** The WebGL rendering context */
|
|
245
|
-
|
|
245
|
+
n(this, "gl");
|
|
246
246
|
/** The vertex buffer containing position and texture coordinates */
|
|
247
|
-
|
|
247
|
+
n(this, "vertexBuffer");
|
|
248
248
|
/** The number of vertices in this geometry (always 6 for two triangles) */
|
|
249
|
-
|
|
249
|
+
n(this, "vertexCount", 6);
|
|
250
250
|
/** Bytes per vertex: depends on position format (vec2 vs vec3) */
|
|
251
|
-
|
|
251
|
+
n(this, "bytesPerVertex");
|
|
252
252
|
this.gl = A, this.bytesPerVertex = 16;
|
|
253
253
|
const s = A.getParameter(A.VIEWPORT), o = s[2], g = s[3], B = A.getParameter(A.FRAMEBUFFER_BINDING) !== null, E = e / o * 2 - 1, h = (e + r) / o * 2 - 1;
|
|
254
254
|
let l, c;
|
|
@@ -306,11 +306,11 @@ class y {
|
|
|
306
306
|
this.gl.enableVertexAttribArray(e), this.gl.vertexAttribPointer(e, 2, this.gl.FLOAT, !1, this.bytesPerVertex, 0), this.gl.enableVertexAttribArray(t), this.gl.vertexAttribPointer(t, 2, this.gl.FLOAT, !1, this.bytesPerVertex, 8), this.gl.drawArrays(this.gl.TRIANGLES, 0, this.vertexCount), this.gl.disableVertexAttribArray(e), this.gl.disableVertexAttribArray(t);
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
-
class
|
|
309
|
+
class aA extends K {
|
|
310
310
|
constructor(e, t, r, i, s) {
|
|
311
311
|
super(e, t, r);
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
n(this, "width");
|
|
313
|
+
n(this, "height");
|
|
314
314
|
this.width = i, this.height = s;
|
|
315
315
|
}
|
|
316
316
|
/**
|
|
@@ -333,13 +333,13 @@ class nA extends K {
|
|
|
333
333
|
class gA {
|
|
334
334
|
constructor(A, e, t, r, i, s) {
|
|
335
335
|
/** The WebGL rendering context */
|
|
336
|
-
|
|
336
|
+
n(this, "gl");
|
|
337
337
|
/** The vertex buffer containing position and texture coordinates */
|
|
338
|
-
|
|
338
|
+
n(this, "vertexBuffer");
|
|
339
339
|
/** The number of vertices in this geometry (always 6 for two triangles) */
|
|
340
|
-
|
|
340
|
+
n(this, "vertexCount", 6);
|
|
341
341
|
/** Bytes per vertex: vec2+vec2 = 16 bytes */
|
|
342
|
-
|
|
342
|
+
n(this, "bytesPerVertex");
|
|
343
343
|
this.gl = A, this.bytesPerVertex = 16;
|
|
344
344
|
const o = A.getParameter(A.VIEWPORT), g = o[2], B = o[3], E = A.getParameter(A.FRAMEBUFFER_BINDING) !== null, h = r - e, l = i - t, c = Math.sqrt(h * h + l * l);
|
|
345
345
|
if (c === 0) {
|
|
@@ -452,8 +452,8 @@ class gA {
|
|
|
452
452
|
class BA extends K {
|
|
453
453
|
constructor(e, t, r, i, s) {
|
|
454
454
|
super(e, t, r);
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
n(this, "x2");
|
|
456
|
+
n(this, "y2");
|
|
457
457
|
this.x2 = i, this.y2 = s;
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
@@ -473,11 +473,11 @@ class BA extends K {
|
|
|
473
473
|
}
|
|
474
474
|
class w {
|
|
475
475
|
constructor(A, e, t) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
476
|
+
n(this, "gl");
|
|
477
|
+
n(this, "program");
|
|
478
|
+
n(this, "uniformLocations", /* @__PURE__ */ new Map());
|
|
479
|
+
n(this, "attributeLocations", /* @__PURE__ */ new Map());
|
|
480
|
+
n(this, "textureUnitCounter", 0);
|
|
481
481
|
this.gl = A, this.program = this.createProgram(e, t), this.cacheLocations();
|
|
482
482
|
}
|
|
483
483
|
createProgram(A, e) {
|
|
@@ -627,22 +627,22 @@ class w {
|
|
|
627
627
|
var I = "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);}", EA = "precision lowp float;uniform sampler2D u_texture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(u_texture,v_uv);}", hA = "precision lowp float;uniform vec4 u_color;void main(){gl_FragColor=u_color;}";
|
|
628
628
|
class lA {
|
|
629
629
|
constructor(A) {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
630
|
+
n(this, "gl");
|
|
631
|
+
n(this, "imageShader");
|
|
632
|
+
n(this, "solidColorShader");
|
|
633
|
+
n(this, "currentShader", null);
|
|
634
634
|
// Fill state management - default: white fill enabled
|
|
635
|
-
|
|
636
|
-
|
|
635
|
+
n(this, "currentFillColor", [1, 1, 1, 1]);
|
|
636
|
+
n(this, "fillMode", !0);
|
|
637
637
|
// Stroke state management - default: black stroke enabled, weight 1
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
638
|
+
n(this, "currentStrokeColor", [0, 0, 0, 1]);
|
|
639
|
+
n(this, "currentStrokeWeight", 1);
|
|
640
|
+
n(this, "strokeMode", !0);
|
|
641
641
|
// Transformation state management
|
|
642
|
-
|
|
642
|
+
n(this, "currentRotation", 0);
|
|
643
643
|
// in degrees
|
|
644
644
|
// State stack for push/pop functionality
|
|
645
|
-
|
|
645
|
+
n(this, "stateStack", []);
|
|
646
646
|
this.gl = A, this.imageShader = new w(this.gl, I, EA), this.solidColorShader = new w(this.gl, I, hA), this.gl.enable(this.gl.BLEND), this.gl.blendEquation(this.gl.FUNC_ADD), this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
|
|
647
647
|
}
|
|
648
648
|
/**
|
|
@@ -756,7 +756,7 @@ class lA {
|
|
|
756
756
|
* Draw a rectangle with the current fill and/or stroke settings
|
|
757
757
|
*/
|
|
758
758
|
rect(A, e, t, r) {
|
|
759
|
-
const i = new
|
|
759
|
+
const i = new aA(this.gl, A, e, t, r);
|
|
760
760
|
if (this.currentShader !== null) {
|
|
761
761
|
if (this.currentRotation !== 0) {
|
|
762
762
|
const { centerX: h, centerY: l, radians: c, aspectRatio: d } = this.calculateRotationParams(A, e, t, r);
|
|
@@ -806,7 +806,7 @@ class lA {
|
|
|
806
806
|
* Create a new framebuffer
|
|
807
807
|
*/
|
|
808
808
|
createFramebuffer(A, e, t = {}) {
|
|
809
|
-
return new
|
|
809
|
+
return new nA(this.gl, A, e, t);
|
|
810
810
|
}
|
|
811
811
|
/**
|
|
812
812
|
* Fill the current framebuffer with a solid color
|
|
@@ -860,7 +860,7 @@ class lA {
|
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
862
|
var Q = {};
|
|
863
|
-
Q.parse = function(
|
|
863
|
+
Q.parse = function(a) {
|
|
864
864
|
var A = function(i, s, o, g) {
|
|
865
865
|
var B = Q.T, E = {
|
|
866
866
|
cmap: B.cmap,
|
|
@@ -879,14 +879,14 @@ Q.parse = function(n) {
|
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
return h;
|
|
882
|
-
}, e = new Uint8Array(
|
|
882
|
+
}, e = new Uint8Array(a), t = {}, r = A(e, 0, 0, t);
|
|
883
883
|
return [r];
|
|
884
884
|
};
|
|
885
|
-
Q.findTable = function(
|
|
886
|
-
for (var t = Q.B, r = t.readUshort(
|
|
887
|
-
var o = t.readASCII(
|
|
888
|
-
t.readUint(
|
|
889
|
-
var g = t.readUint(
|
|
885
|
+
Q.findTable = function(a, A, e) {
|
|
886
|
+
for (var t = Q.B, r = t.readUshort(a, e + 4), i = e + 12, s = 0; s < r; s++) {
|
|
887
|
+
var o = t.readASCII(a, i, 4);
|
|
888
|
+
t.readUint(a, i + 4);
|
|
889
|
+
var g = t.readUint(a, i + 8), B = t.readUint(a, i + 12);
|
|
890
890
|
if (o == A) return [g, B];
|
|
891
891
|
i += 16;
|
|
892
892
|
}
|
|
@@ -894,95 +894,95 @@ Q.findTable = function(n, A, e) {
|
|
|
894
894
|
};
|
|
895
895
|
Q.T = {};
|
|
896
896
|
Q.B = {
|
|
897
|
-
readShort: function(
|
|
897
|
+
readShort: function(a, A) {
|
|
898
898
|
var e = Q.B.t.uint16;
|
|
899
|
-
return e[0] =
|
|
899
|
+
return e[0] = a[A] << 8 | a[A + 1], Q.B.t.int16[0];
|
|
900
900
|
},
|
|
901
|
-
readUshort: function(
|
|
902
|
-
return
|
|
901
|
+
readUshort: function(a, A) {
|
|
902
|
+
return a[A] << 8 | a[A + 1];
|
|
903
903
|
},
|
|
904
|
-
readUshorts: function(
|
|
904
|
+
readUshorts: function(a, A, e) {
|
|
905
905
|
for (var t = [], r = 0; r < e; r++)
|
|
906
|
-
t.push(Q.B.readUshort(
|
|
906
|
+
t.push(Q.B.readUshort(a, A + r * 2));
|
|
907
907
|
return t;
|
|
908
908
|
},
|
|
909
|
-
readUint: function(
|
|
909
|
+
readUint: function(a, A) {
|
|
910
910
|
var e = Q.B.t.uint8;
|
|
911
|
-
return e[3] =
|
|
911
|
+
return e[3] = a[A], e[2] = a[A + 1], e[1] = a[A + 2], e[0] = a[A + 3], Q.B.t.uint32[0];
|
|
912
912
|
},
|
|
913
|
-
readASCII: function(
|
|
914
|
-
for (var t = "", r = 0; r < e; r++) t += String.fromCharCode(
|
|
913
|
+
readASCII: function(a, A, e) {
|
|
914
|
+
for (var t = "", r = 0; r < e; r++) t += String.fromCharCode(a[A + r]);
|
|
915
915
|
return t;
|
|
916
916
|
},
|
|
917
917
|
// Simplified typed array buffer - only what's needed
|
|
918
918
|
t: function() {
|
|
919
|
-
var
|
|
919
|
+
var a = new ArrayBuffer(8);
|
|
920
920
|
return {
|
|
921
|
-
uint8: new Uint8Array(
|
|
922
|
-
int16: new Int16Array(
|
|
923
|
-
uint16: new Uint16Array(
|
|
924
|
-
uint32: new Uint32Array(
|
|
921
|
+
uint8: new Uint8Array(a),
|
|
922
|
+
int16: new Int16Array(a),
|
|
923
|
+
uint16: new Uint16Array(a),
|
|
924
|
+
uint32: new Uint32Array(a)
|
|
925
925
|
};
|
|
926
926
|
}()
|
|
927
927
|
};
|
|
928
928
|
Q.T.cmap = {
|
|
929
|
-
parseTab: function(
|
|
929
|
+
parseTab: function(a, A, e) {
|
|
930
930
|
var t = { tables: [], ids: {}, off: A };
|
|
931
|
-
|
|
931
|
+
a = new Uint8Array(a.buffer, A, e), A = 0;
|
|
932
932
|
var r = Q.B, i = r.readUshort, s = Q.T.cmap;
|
|
933
|
-
i(
|
|
934
|
-
var o = i(
|
|
933
|
+
i(a, A), A += 2;
|
|
934
|
+
var o = i(a, A);
|
|
935
935
|
A += 2;
|
|
936
936
|
for (var g = [], B = 0; B < o; B++) {
|
|
937
|
-
var E = i(
|
|
937
|
+
var E = i(a, A);
|
|
938
938
|
A += 2;
|
|
939
|
-
var h = i(
|
|
939
|
+
var h = i(a, A);
|
|
940
940
|
A += 2;
|
|
941
|
-
var l = r.readUint(
|
|
941
|
+
var l = r.readUint(a, A);
|
|
942
942
|
A += 4;
|
|
943
943
|
var c = "p" + E + "e" + h, d = g.indexOf(l);
|
|
944
944
|
if (d == -1) {
|
|
945
945
|
d = t.tables.length;
|
|
946
946
|
var u = {};
|
|
947
947
|
g.push(l);
|
|
948
|
-
var m = u.format = i(
|
|
949
|
-
m == 4 ? u = s.parse4(
|
|
948
|
+
var m = u.format = i(a, l);
|
|
949
|
+
m == 4 ? u = s.parse4(a, l, u) : m == 12 && (u = s.parse12(a, l, u)), t.tables.push(u);
|
|
950
950
|
}
|
|
951
951
|
t.ids[c] != null && console.log("multiple tables for one platform+encoding: " + c), t.ids[c] = d;
|
|
952
952
|
}
|
|
953
953
|
return t;
|
|
954
954
|
},
|
|
955
|
-
parse4: function(
|
|
955
|
+
parse4: function(a, A, e) {
|
|
956
956
|
var t = Q.B, r = t.readUshort, i = t.readUshorts, s = A;
|
|
957
957
|
A += 2;
|
|
958
|
-
var o = r(
|
|
959
|
-
A += 2, r(
|
|
960
|
-
var g = r(
|
|
958
|
+
var o = r(a, A);
|
|
959
|
+
A += 2, r(a, A), A += 2;
|
|
960
|
+
var g = r(a, A);
|
|
961
961
|
A += 2;
|
|
962
962
|
var B = g >>> 1;
|
|
963
|
-
e.searchRange = r(
|
|
963
|
+
e.searchRange = r(a, A), A += 2, e.entrySelector = r(a, A), A += 2, e.rangeShift = r(a, A), A += 2, e.endCount = i(a, A, B), A += B * 2, A += 2, e.startCount = i(a, A, B), A += B * 2, e.idDelta = [];
|
|
964
964
|
for (var E = 0; E < B; E++)
|
|
965
|
-
e.idDelta.push(t.readShort(
|
|
966
|
-
return e.idRangeOffset = i(
|
|
965
|
+
e.idDelta.push(t.readShort(a, A)), A += 2;
|
|
966
|
+
return e.idRangeOffset = i(a, A, B), A += B * 2, e.glyphIdArray = i(a, A, s + o - A >> 1), e;
|
|
967
967
|
},
|
|
968
|
-
parse12: function(
|
|
968
|
+
parse12: function(a, A, e) {
|
|
969
969
|
var t = Q.B, r = t.readUint;
|
|
970
|
-
A += 4, r(
|
|
971
|
-
var i = r(
|
|
970
|
+
A += 4, r(a, A), A += 4, r(a, A), A += 4;
|
|
971
|
+
var i = r(a, A) * 3;
|
|
972
972
|
A += 4;
|
|
973
973
|
for (var s = e.groups = new Uint32Array(i), o = 0; o < i; o += 3)
|
|
974
|
-
s[o] = r(
|
|
974
|
+
s[o] = r(a, A + (o << 2)), s[o + 1] = r(a, A + (o << 2) + 4), s[o + 2] = r(a, A + (o << 2) + 8);
|
|
975
975
|
return e;
|
|
976
976
|
}
|
|
977
977
|
};
|
|
978
978
|
Q.T.head = {
|
|
979
|
-
parseTab: function(
|
|
979
|
+
parseTab: function(a, A, e) {
|
|
980
980
|
var t = Q.B, r = {};
|
|
981
|
-
return A += 18, r.unitsPerEm = t.readUshort(
|
|
981
|
+
return A += 18, r.unitsPerEm = t.readUshort(a, A), A += 2, A += 16, r.xMin = t.readShort(a, A), A += 2, r.yMin = t.readShort(a, A), A += 2, r.xMax = t.readShort(a, A), A += 2, r.yMax = t.readShort(a, A), A += 2, A += 6, r.indexToLocFormat = t.readShort(a, A), r;
|
|
982
982
|
}
|
|
983
983
|
};
|
|
984
984
|
Q.T.hhea = {
|
|
985
|
-
parseTab: function(
|
|
985
|
+
parseTab: function(a, A, e) {
|
|
986
986
|
var t = Q.B, r = {};
|
|
987
987
|
A += 4;
|
|
988
988
|
for (var i = [
|
|
@@ -1004,43 +1004,43 @@ Q.T.hhea = {
|
|
|
1004
1004
|
"numberOfHMetrics"
|
|
1005
1005
|
], s = 0; s < i.length; s++) {
|
|
1006
1006
|
var o = i[s], g = o == "advanceWidthMax" || o == "numberOfHMetrics" ? t.readUshort : t.readShort;
|
|
1007
|
-
r[o] = g(
|
|
1007
|
+
r[o] = g(a, A + s * 2);
|
|
1008
1008
|
}
|
|
1009
1009
|
return r;
|
|
1010
1010
|
}
|
|
1011
1011
|
};
|
|
1012
1012
|
Q.T.hmtx = {
|
|
1013
|
-
parseTab: function(
|
|
1013
|
+
parseTab: function(a, A, e, t) {
|
|
1014
1014
|
for (var r = Q.B, i = [], s = [], o = t.maxp.numGlyphs, g = t.hhea.numberOfHMetrics, B = 0, E = 0, h = 0; h < g; )
|
|
1015
|
-
B = r.readUshort(
|
|
1015
|
+
B = r.readUshort(a, A + (h << 2)), E = r.readShort(a, A + (h << 2) + 2), i.push(B), s.push(E), h++;
|
|
1016
1016
|
for (; h < o; )
|
|
1017
1017
|
i.push(B), s.push(E), h++;
|
|
1018
1018
|
return { aWidth: i, lsBearing: s };
|
|
1019
1019
|
}
|
|
1020
1020
|
};
|
|
1021
1021
|
Q.T.maxp = {
|
|
1022
|
-
parseTab: function(
|
|
1022
|
+
parseTab: function(a, A, e) {
|
|
1023
1023
|
var t = Q.B, r = t.readUshort, i = {};
|
|
1024
|
-
return t.readUint(
|
|
1024
|
+
return t.readUint(a, A), A += 4, i.numGlyphs = r(a, A), A += 2, i;
|
|
1025
1025
|
}
|
|
1026
1026
|
};
|
|
1027
1027
|
Q.T.loca = {
|
|
1028
|
-
parseTab: function(
|
|
1028
|
+
parseTab: function(a, A, e, t) {
|
|
1029
1029
|
var r = Q.B, i = [], s = t.head.indexToLocFormat, o = t.maxp.numGlyphs + 1;
|
|
1030
|
-
if (s == 0) for (var g = 0; g < o; g++) i.push(r.readUshort(
|
|
1031
|
-
if (s == 1) for (var g = 0; g < o; g++) i.push(r.readUint(
|
|
1030
|
+
if (s == 0) for (var g = 0; g < o; g++) i.push(r.readUshort(a, A + (g << 1)) << 1);
|
|
1031
|
+
if (s == 1) for (var g = 0; g < o; g++) i.push(r.readUint(a, A + (g << 2)));
|
|
1032
1032
|
return i;
|
|
1033
1033
|
}
|
|
1034
1034
|
};
|
|
1035
1035
|
Q.T.glyf = {
|
|
1036
|
-
parseTab: function(
|
|
1036
|
+
parseTab: function(a, A, e, t) {
|
|
1037
1037
|
for (var r = [], i = t.maxp.numGlyphs, s = 0; s < i; s++) r.push(null);
|
|
1038
1038
|
return r;
|
|
1039
1039
|
},
|
|
1040
|
-
_parseGlyf: function(
|
|
1041
|
-
var e = Q.B, t =
|
|
1040
|
+
_parseGlyf: function(a, A) {
|
|
1041
|
+
var e = Q.B, t = a._data, r = a.loca;
|
|
1042
1042
|
if (r[A] == r[A + 1]) return null;
|
|
1043
|
-
var i = Q.findTable(t, "glyf",
|
|
1043
|
+
var i = Q.findTable(t, "glyf", a._offset)[0] + r[A], s = {};
|
|
1044
1044
|
if (s.noc = e.readShort(t, i), i += 2, s.xMin = e.readShort(t, i), i += 2, s.yMin = e.readShort(t, i), i += 2, s.xMax = e.readShort(t, i), i += 2, s.yMax = e.readShort(t, i), i += 2, s.xMin >= s.xMax || s.yMin >= s.yMax) return null;
|
|
1045
1045
|
if (s.noc > 0) {
|
|
1046
1046
|
s.endPts = [];
|
|
@@ -1183,9 +1183,9 @@ class uA {
|
|
|
1183
1183
|
* @param renderer The WebGL renderer instance
|
|
1184
1184
|
*/
|
|
1185
1185
|
constructor(A) {
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1186
|
+
n(this, "_textureCanvas");
|
|
1187
|
+
n(this, "_textureContext");
|
|
1188
|
+
n(this, "_renderer");
|
|
1189
1189
|
this._renderer = A, this._textureCanvas = document.createElement("canvas"), this._textureContext = this._textureCanvas.getContext("2d", { willReadFrequently: !0, alpha: !1 });
|
|
1190
1190
|
}
|
|
1191
1191
|
/**
|
|
@@ -1251,8 +1251,8 @@ class dA {
|
|
|
1251
1251
|
* Creates a new MetricsCalculation instance.
|
|
1252
1252
|
*/
|
|
1253
1253
|
constructor() {
|
|
1254
|
-
|
|
1255
|
-
|
|
1254
|
+
n(this, "_tempCanvas");
|
|
1255
|
+
n(this, "_tempContext");
|
|
1256
1256
|
this._tempCanvas = document.createElement("canvas"), this._tempContext = this._tempCanvas.getContext("2d");
|
|
1257
1257
|
}
|
|
1258
1258
|
/**
|
|
@@ -1374,20 +1374,20 @@ class CA {
|
|
|
1374
1374
|
* @ignore
|
|
1375
1375
|
*/
|
|
1376
1376
|
constructor(A, e = 16) {
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1377
|
+
n(this, "_font");
|
|
1378
|
+
n(this, "_characters", []);
|
|
1379
|
+
n(this, "_fontFramebuffer");
|
|
1380
|
+
n(this, "_fontSize", 16);
|
|
1381
|
+
n(this, "_textureColumns", 0);
|
|
1382
|
+
n(this, "_textureRows", 0);
|
|
1383
|
+
n(this, "_maxGlyphDimensions", { width: 0, height: 0 });
|
|
1384
|
+
n(this, "_fontFace");
|
|
1385
|
+
n(this, "_fontFamilyName", "UrsaFont");
|
|
1386
1386
|
// Component classes
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1387
|
+
n(this, "_characterExtractor");
|
|
1388
|
+
n(this, "_textureAtlas");
|
|
1389
|
+
n(this, "_metricsCalculator");
|
|
1390
|
+
n(this, "_characterColorMapper");
|
|
1391
1391
|
this._fontSize = e, this._characterExtractor = new cA(), this._textureAtlas = new uA(A), this._metricsCalculator = new dA(), this._characterColorMapper = new fA();
|
|
1392
1392
|
}
|
|
1393
1393
|
/**
|
|
@@ -1558,25 +1558,25 @@ class mA {
|
|
|
1558
1558
|
*/
|
|
1559
1559
|
constructor(A, e, t) {
|
|
1560
1560
|
/** The number of columns in the grid. */
|
|
1561
|
-
|
|
1561
|
+
n(this, "_cols");
|
|
1562
1562
|
/** The number of rows in the grid. */
|
|
1563
|
-
|
|
1563
|
+
n(this, "_rows");
|
|
1564
1564
|
/** The total width of the grid in pixels. */
|
|
1565
|
-
|
|
1565
|
+
n(this, "_width");
|
|
1566
1566
|
/** The total height of the grid in pixels. */
|
|
1567
|
-
|
|
1567
|
+
n(this, "_height");
|
|
1568
1568
|
/** The offset to the outer canvas on the x-axis when centering the grid. */
|
|
1569
|
-
|
|
1569
|
+
n(this, "_offsetX");
|
|
1570
1570
|
/** The offset to the outer canvas on the y-axis when centering the grid. */
|
|
1571
|
-
|
|
1571
|
+
n(this, "_offsetY");
|
|
1572
1572
|
/** Whether the grid dimensions are fixed, or responsive based on the canvas dimensions. */
|
|
1573
|
-
|
|
1573
|
+
n(this, "_fixedDimensions", !1);
|
|
1574
1574
|
/** The canvas element used to determine the grid dimensions. */
|
|
1575
|
-
|
|
1575
|
+
n(this, "_canvas");
|
|
1576
1576
|
/** The width of each cell in the grid. */
|
|
1577
|
-
|
|
1577
|
+
n(this, "_cellWidth");
|
|
1578
1578
|
/** The height of each cell in the grid. */
|
|
1579
|
-
|
|
1579
|
+
n(this, "_cellHeight");
|
|
1580
1580
|
this._canvas = A, this._cellWidth = e, this._cellHeight = t, this.reset();
|
|
1581
1581
|
}
|
|
1582
1582
|
/**
|
|
@@ -1693,9 +1693,9 @@ class mA {
|
|
|
1693
1693
|
}
|
|
1694
1694
|
class DA {
|
|
1695
1695
|
constructor(A, e = !1, t = {}) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1696
|
+
n(this, "_canvas");
|
|
1697
|
+
n(this, "captureSource");
|
|
1698
|
+
n(this, "_isStandalone");
|
|
1699
1699
|
this.captureSource = A, this._isStandalone = e, this._canvas = this.createCanvas(t.width, t.height);
|
|
1700
1700
|
}
|
|
1701
1701
|
createCanvas(A, e) {
|
|
@@ -1797,15 +1797,15 @@ class x {
|
|
|
1797
1797
|
* @ignore
|
|
1798
1798
|
*/
|
|
1799
1799
|
constructor(A, e, t, r = {}) {
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1800
|
+
n(this, "renderer");
|
|
1801
|
+
n(this, "fontManager");
|
|
1802
|
+
n(this, "grid");
|
|
1803
|
+
n(this, "_characterFramebuffer");
|
|
1804
|
+
n(this, "_primaryColorFramebuffer");
|
|
1805
|
+
n(this, "_secondaryColorFramebuffer");
|
|
1806
|
+
n(this, "_rotationFramebuffer");
|
|
1807
|
+
n(this, "_transformFramebuffer");
|
|
1808
|
+
n(this, "_options");
|
|
1809
1809
|
this.renderer = A, this.fontManager = e, this.grid = t, this._options = r, this._characterFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows), this._primaryColorFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows), this._secondaryColorFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows), this._rotationFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows), this._transformFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows);
|
|
1810
1810
|
}
|
|
1811
1811
|
/**
|
|
@@ -1880,9 +1880,9 @@ class PA {
|
|
|
1880
1880
|
*/
|
|
1881
1881
|
constructor(A, e) {
|
|
1882
1882
|
/** The framebuffer used to store the color palette. */
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1883
|
+
n(this, "_framebuffer");
|
|
1884
|
+
n(this, "_renderer");
|
|
1885
|
+
n(this, "_colors");
|
|
1886
1886
|
this._renderer = A, this._colors = e;
|
|
1887
1887
|
const t = Math.max(this._colors.length, 1);
|
|
1888
1888
|
this._framebuffer = this._renderer.createFramebuffer(t, 1), this._updateFramebuffer();
|
|
@@ -1930,7 +1930,7 @@ class PA {
|
|
|
1930
1930
|
class z extends x {
|
|
1931
1931
|
constructor(e, t, r, i = {}) {
|
|
1932
1932
|
super(e, t, r, i);
|
|
1933
|
-
|
|
1933
|
+
n(this, "palette");
|
|
1934
1934
|
this.palette = new PA(this.renderer, this.fontManager.getCharacterColors(" .:-=+*%@#"));
|
|
1935
1935
|
}
|
|
1936
1936
|
/**
|
|
@@ -2084,12 +2084,12 @@ class O extends z {
|
|
|
2084
2084
|
*/
|
|
2085
2085
|
constructor(e, t, r) {
|
|
2086
2086
|
super(e, t, r, { ...vA });
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2087
|
+
n(this, "sampleShader");
|
|
2088
|
+
n(this, "colorFillShader");
|
|
2089
|
+
n(this, "charMappingShader");
|
|
2090
|
+
n(this, "transformFillShader");
|
|
2091
|
+
n(this, "rotationFillShader");
|
|
2092
|
+
n(this, "sampleFramebuffer");
|
|
2093
2093
|
this.sampleShader = new w(e.context, I, pA), this.colorFillShader = new w(e.context, I, _A), this.transformFillShader = new w(e.context, I, wA), this.rotationFillShader = new w(e.context, I, IA), this.charMappingShader = new w(e.context, I, bA), this.sampleFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows);
|
|
2094
2094
|
}
|
|
2095
2095
|
convert(e) {
|
|
@@ -2113,7 +2113,7 @@ class O extends z {
|
|
|
2113
2113
|
) && (this._options.brightnessRange = e);
|
|
2114
2114
|
}
|
|
2115
2115
|
}
|
|
2116
|
-
const
|
|
2116
|
+
const LA = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2117
2117
|
__proto__: null,
|
|
2118
2118
|
TextmodeBrightnessConverter: O,
|
|
2119
2119
|
TextmodeConverter: x,
|
|
@@ -2129,17 +2129,17 @@ class FA {
|
|
|
2129
2129
|
* @ignore
|
|
2130
2130
|
*/
|
|
2131
2131
|
constructor(A, e, t) {
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2132
|
+
n(this, "renderer");
|
|
2133
|
+
n(this, "font");
|
|
2134
|
+
n(this, "grid");
|
|
2135
|
+
n(this, "converters");
|
|
2136
|
+
n(this, "_resultFramebuffer");
|
|
2137
|
+
n(this, "_asciiShader");
|
|
2138
|
+
n(this, "_characterFramebuffer");
|
|
2139
|
+
n(this, "_primaryColorFramebuffer");
|
|
2140
|
+
n(this, "_secondaryColorFramebuffer");
|
|
2141
|
+
n(this, "_rotationFramebuffer");
|
|
2142
|
+
n(this, "_transformFramebuffer");
|
|
2143
2143
|
this.renderer = A, this.font = e, this.grid = t, this._asciiShader = this.renderer.createShader(I, xA), this.converters = [
|
|
2144
2144
|
{ name: "brightness", converter: new O(A, e, t) },
|
|
2145
2145
|
{ name: "custom", converter: new x(A, e, t) }
|
|
@@ -2305,7 +2305,7 @@ class FA {
|
|
|
2305
2305
|
return this._transformFramebuffer;
|
|
2306
2306
|
}
|
|
2307
2307
|
}
|
|
2308
|
-
class
|
|
2308
|
+
class L {
|
|
2309
2309
|
/**
|
|
2310
2310
|
* Extracts pixel data from all framebuffers needed for export
|
|
2311
2311
|
* @param pipeline The conversion pipeline containing framebuffers
|
|
@@ -2347,7 +2347,7 @@ class H {
|
|
|
2347
2347
|
};
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
2350
|
-
class
|
|
2350
|
+
class H {
|
|
2351
2351
|
/**
|
|
2352
2352
|
* Creates a downloadable blob from content
|
|
2353
2353
|
* @param content The content to include in the blob
|
|
@@ -2404,7 +2404,7 @@ class L {
|
|
|
2404
2404
|
return `'textmode-export'-${this.generateTimestamp()}`;
|
|
2405
2405
|
}
|
|
2406
2406
|
}
|
|
2407
|
-
class yA extends
|
|
2407
|
+
class yA extends L {
|
|
2408
2408
|
/**
|
|
2409
2409
|
* Extracts transform data from transform pixels
|
|
2410
2410
|
* @param transformPixels Transform framebuffer pixels
|
|
@@ -2625,7 +2625,7 @@ class TA {
|
|
|
2625
2625
|
}
|
|
2626
2626
|
class SA {
|
|
2627
2627
|
constructor() {
|
|
2628
|
-
|
|
2628
|
+
n(this, "pathGenerator");
|
|
2629
2629
|
this.pathGenerator = new TA();
|
|
2630
2630
|
}
|
|
2631
2631
|
/**
|
|
@@ -2771,7 +2771,7 @@ class SA {
|
|
|
2771
2771
|
`).replace(/[ \t]+$/gm, "");
|
|
2772
2772
|
}
|
|
2773
2773
|
}
|
|
2774
|
-
class RA extends
|
|
2774
|
+
class RA extends H {
|
|
2775
2775
|
/**
|
|
2776
2776
|
* Creates a downloadable blob from SVG content
|
|
2777
2777
|
* @param svgContent The SVG content string
|
|
@@ -2803,9 +2803,9 @@ class RA extends L {
|
|
|
2803
2803
|
}
|
|
2804
2804
|
class W {
|
|
2805
2805
|
constructor() {
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2806
|
+
n(this, "dataExtractor");
|
|
2807
|
+
n(this, "contentGenerator");
|
|
2808
|
+
n(this, "fileHandler");
|
|
2809
2809
|
this.dataExtractor = new yA(), this.contentGenerator = new SA(), this.fileHandler = new RA();
|
|
2810
2810
|
}
|
|
2811
2811
|
/**
|
|
@@ -2853,7 +2853,7 @@ class W {
|
|
|
2853
2853
|
}
|
|
2854
2854
|
}
|
|
2855
2855
|
}
|
|
2856
|
-
class GA extends
|
|
2856
|
+
class GA extends L {
|
|
2857
2857
|
/**
|
|
2858
2858
|
* Extracts character data for TXT generation
|
|
2859
2859
|
* @param framebufferData Framebuffer pixel data
|
|
@@ -2899,7 +2899,7 @@ class MA {
|
|
|
2899
2899
|
return t.join(r);
|
|
2900
2900
|
}
|
|
2901
2901
|
}
|
|
2902
|
-
class UA extends
|
|
2902
|
+
class UA extends H {
|
|
2903
2903
|
/**
|
|
2904
2904
|
* Saves TXT content as a downloadable file
|
|
2905
2905
|
* @param content The TXT content to save
|
|
@@ -2925,9 +2925,9 @@ class UA extends L {
|
|
|
2925
2925
|
}
|
|
2926
2926
|
class $ {
|
|
2927
2927
|
constructor() {
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2928
|
+
n(this, "dataExtractor");
|
|
2929
|
+
n(this, "contentGenerator");
|
|
2930
|
+
n(this, "fileHandler");
|
|
2931
2931
|
this.dataExtractor = new GA(), this.contentGenerator = new MA(), this.fileHandler = new UA();
|
|
2932
2932
|
}
|
|
2933
2933
|
/**
|
|
@@ -2974,7 +2974,7 @@ class $ {
|
|
|
2974
2974
|
}
|
|
2975
2975
|
}
|
|
2976
2976
|
}
|
|
2977
|
-
class YA extends
|
|
2977
|
+
class YA extends L {
|
|
2978
2978
|
/**
|
|
2979
2979
|
* Captures the current state of the textmode canvas as image data
|
|
2980
2980
|
* @param canvas The canvas data containing the rendered textmode graphics
|
|
@@ -3052,7 +3052,7 @@ const J = {
|
|
|
3052
3052
|
jpg: ".jpg",
|
|
3053
3053
|
webp: ".webp"
|
|
3054
3054
|
};
|
|
3055
|
-
class VA extends
|
|
3055
|
+
class VA extends H {
|
|
3056
3056
|
/**
|
|
3057
3057
|
* Saves image content as a downloadable file
|
|
3058
3058
|
* @param content The image content (data URL or blob)
|
|
@@ -3117,9 +3117,9 @@ class VA extends L {
|
|
|
3117
3117
|
}
|
|
3118
3118
|
class OA {
|
|
3119
3119
|
constructor() {
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3120
|
+
n(this, "dataExtractor");
|
|
3121
|
+
n(this, "contentGenerator");
|
|
3122
|
+
n(this, "fileHandler");
|
|
3123
3123
|
this.dataExtractor = new YA(), this.contentGenerator = new kA(), this.fileHandler = new VA();
|
|
3124
3124
|
}
|
|
3125
3125
|
/**
|
|
@@ -3206,37 +3206,38 @@ class OA {
|
|
|
3206
3206
|
class S {
|
|
3207
3207
|
constructor(A = null, e = {}) {
|
|
3208
3208
|
/** The element to capture content from (optional for standalone mode) */
|
|
3209
|
-
|
|
3209
|
+
n(this, "captureSource");
|
|
3210
3210
|
/** Our WebGL overlay canvas manager */
|
|
3211
|
-
|
|
3211
|
+
n(this, "textmodeCanvas");
|
|
3212
3212
|
/** Core WebGL renderer */
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3213
|
+
n(this, "_renderer");
|
|
3214
|
+
n(this, "_canvasFramebuffer");
|
|
3215
|
+
n(this, "_font");
|
|
3216
|
+
n(this, "_grid");
|
|
3217
|
+
n(this, "resizeObserver");
|
|
3218
3218
|
// Auto-rendering properties
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3219
|
+
n(this, "_mode");
|
|
3220
|
+
n(this, "_frameRateLimit");
|
|
3221
|
+
n(this, "animationFrameId", null);
|
|
3222
|
+
n(this, "lastFrameTime", 0);
|
|
3223
|
+
n(this, "frameInterval");
|
|
3224
|
+
n(this, "_isLooping", !0);
|
|
3225
|
+
n(this, "_frameRate", 0);
|
|
3226
|
+
n(this, "lastRenderTime", 0);
|
|
3227
|
+
n(this, "_frameCount", 0);
|
|
3227
3228
|
// Frame rate measurement smoothing
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3229
|
+
n(this, "frameTimeHistory", []);
|
|
3230
|
+
n(this, "frameTimeHistorySize", 10);
|
|
3231
|
+
n(this, "_pipeline");
|
|
3231
3232
|
// Standalone canvas properties
|
|
3232
|
-
|
|
3233
|
-
|
|
3233
|
+
n(this, "_standalone", !1);
|
|
3234
|
+
n(this, "_drawCallback", () => {
|
|
3234
3235
|
});
|
|
3235
|
-
|
|
3236
|
+
n(this, "_resizedCallback", () => {
|
|
3236
3237
|
});
|
|
3237
3238
|
// Destroy state
|
|
3238
|
-
|
|
3239
|
-
|
|
3239
|
+
n(this, "_isDestroyed", !1);
|
|
3240
|
+
n(this, "_windowResizeListener", null);
|
|
3240
3241
|
this.captureSource = A, this._standalone = A === null, this._mode = e.renderMode ?? "auto", this._frameRateLimit = e.frameRate ?? 60, this.frameInterval = 1e3 / this._frameRateLimit;
|
|
3241
3242
|
}
|
|
3242
3243
|
/**
|
|
@@ -3499,13 +3500,17 @@ class S {
|
|
|
3499
3500
|
* Start automatic rendering
|
|
3500
3501
|
*/
|
|
3501
3502
|
startAutoRendering() {
|
|
3502
|
-
if (this._mode !== "auto" || this._isDestroyed) return;
|
|
3503
|
+
if (this._mode !== "auto" || this._isDestroyed || !this._isLooping) return;
|
|
3503
3504
|
this.lastFrameTime = performance.now();
|
|
3504
3505
|
const A = (e) => {
|
|
3505
3506
|
if (this._isDestroyed)
|
|
3506
3507
|
return;
|
|
3508
|
+
if (!this._isLooping) {
|
|
3509
|
+
this.animationFrameId = null;
|
|
3510
|
+
return;
|
|
3511
|
+
}
|
|
3507
3512
|
const t = e - this.lastFrameTime;
|
|
3508
|
-
t >= this.frameInterval && (this.render(), this.lastFrameTime = e - t % this.frameInterval), this._isDestroyed
|
|
3513
|
+
t >= this.frameInterval && (this.render(), this.lastFrameTime = e - t % this.frameInterval), !this._isDestroyed && this._isLooping && (this.animationFrameId = requestAnimationFrame(A));
|
|
3509
3514
|
};
|
|
3510
3515
|
this.animationFrameId = requestAnimationFrame(A);
|
|
3511
3516
|
}
|
|
@@ -3559,7 +3564,7 @@ class S {
|
|
|
3559
3564
|
console.warn("Cannot change render mode: Textmodifier instance has been destroyed");
|
|
3560
3565
|
return;
|
|
3561
3566
|
}
|
|
3562
|
-
this._mode !== A && (this.stopAutoRendering(), this._mode = A, A === "auto" && this.startAutoRendering());
|
|
3567
|
+
this._mode !== A && (this.stopAutoRendering(), this._mode = A, A === "auto" && this._isLooping && this.startAutoRendering());
|
|
3563
3568
|
}
|
|
3564
3569
|
/**
|
|
3565
3570
|
* Set the maximum frame rate for auto rendering. If called without arguments, returns the current measured frame rate.
|
|
@@ -3580,7 +3585,105 @@ class S {
|
|
|
3580
3585
|
frameRate(A) {
|
|
3581
3586
|
if (A === void 0)
|
|
3582
3587
|
return this._frameRate;
|
|
3583
|
-
this._frameRateLimit = A, this.frameInterval = 1e3 / A, this._mode === "auto" && (this.stopAutoRendering(), this.startAutoRendering());
|
|
3588
|
+
this._frameRateLimit = A, this.frameInterval = 1e3 / A, this._mode === "auto" && this._isLooping && (this.stopAutoRendering(), this.startAutoRendering());
|
|
3589
|
+
}
|
|
3590
|
+
/**
|
|
3591
|
+
* Stop the automatic rendering loop while keeping the render mode as 'auto'.
|
|
3592
|
+
*
|
|
3593
|
+
* This method pauses the render loop without changing the render mode, allowing
|
|
3594
|
+
* it to be resumed later with {@link loop}. This is useful for temporarily pausing
|
|
3595
|
+
* animation while maintaining the ability to restart it.
|
|
3596
|
+
*
|
|
3597
|
+
* **Note:** This only affects rendering when in `'auto'` mode. In `'manual'` mode,
|
|
3598
|
+
* this method has no effect since rendering is already controlled manually.
|
|
3599
|
+
*
|
|
3600
|
+
* @example
|
|
3601
|
+
* ```javascript
|
|
3602
|
+
* // Create a textmodifier instance in auto mode
|
|
3603
|
+
* const textmodifier = await textmode.create(canvas);
|
|
3604
|
+
*
|
|
3605
|
+
* // The render loop is running automatically
|
|
3606
|
+
* console.log(textmodifier.isLooping()); // true
|
|
3607
|
+
*
|
|
3608
|
+
* // Stop the automatic rendering loop
|
|
3609
|
+
* textmodifier.noLoop();
|
|
3610
|
+
* console.log(textmodifier.isLooping()); // false
|
|
3611
|
+
*
|
|
3612
|
+
* // Resume the automatic rendering loop
|
|
3613
|
+
* textmodifier.loop();
|
|
3614
|
+
* console.log(textmodifier.isLooping()); // true
|
|
3615
|
+
* ```
|
|
3616
|
+
*/
|
|
3617
|
+
noLoop() {
|
|
3618
|
+
if (this._isDestroyed) {
|
|
3619
|
+
console.warn("Cannot stop loop: Textmodifier instance has been destroyed");
|
|
3620
|
+
return;
|
|
3621
|
+
}
|
|
3622
|
+
this._isLooping && (this._isLooping = !1, this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null));
|
|
3623
|
+
}
|
|
3624
|
+
/**
|
|
3625
|
+
* Resume the automatic rendering loop if it was stopped by {@link noLoop}.
|
|
3626
|
+
*
|
|
3627
|
+
* This method restarts the render loop when in `'auto'` mode. If the render mode
|
|
3628
|
+
* is `'manual'`, the loop state will be set but automatic rendering will not start
|
|
3629
|
+
* until the mode is changed back to `'auto'`.
|
|
3630
|
+
*
|
|
3631
|
+
* @example
|
|
3632
|
+
* ```javascript
|
|
3633
|
+
* // Create a textmodifier instance
|
|
3634
|
+
* const textmodifier = await textmode.create(canvas);
|
|
3635
|
+
*
|
|
3636
|
+
* // Stop the loop
|
|
3637
|
+
* textmodifier.noLoop();
|
|
3638
|
+
*
|
|
3639
|
+
* // Resume the loop
|
|
3640
|
+
* textmodifier.loop();
|
|
3641
|
+
*
|
|
3642
|
+
* // You can also use this pattern for conditional animation
|
|
3643
|
+
* if (someCondition) {
|
|
3644
|
+
* textmodifier.loop();
|
|
3645
|
+
* } else {
|
|
3646
|
+
* textmodifier.noLoop();
|
|
3647
|
+
* }
|
|
3648
|
+
* ```
|
|
3649
|
+
*/
|
|
3650
|
+
loop() {
|
|
3651
|
+
if (this._isDestroyed) {
|
|
3652
|
+
console.warn("Cannot start loop: Textmodifier instance has been destroyed");
|
|
3653
|
+
return;
|
|
3654
|
+
}
|
|
3655
|
+
this._isLooping || (this._isLooping = !0, this._mode === "auto" && this.startAutoRendering());
|
|
3656
|
+
}
|
|
3657
|
+
/**
|
|
3658
|
+
* Check whether the textmodifier is currently running the automatic render loop.
|
|
3659
|
+
*
|
|
3660
|
+
* Returns `true` when both the render mode is `'auto'` AND the loop is active.
|
|
3661
|
+
* Returns `false` when in `'manual'` mode or when {@link noLoop} has been called.
|
|
3662
|
+
*
|
|
3663
|
+
* @returns True if the automatic render loop is currently active, false otherwise.
|
|
3664
|
+
*
|
|
3665
|
+
* @example
|
|
3666
|
+
* ```javascript
|
|
3667
|
+
* const textmodifier = await textmode.create(canvas);
|
|
3668
|
+
*
|
|
3669
|
+
* // Check loop status in different states
|
|
3670
|
+
* console.log(textmodifier.isLooping()); // true (auto mode, looping)
|
|
3671
|
+
*
|
|
3672
|
+
* textmodifier.noLoop();
|
|
3673
|
+
* console.log(textmodifier.isLooping()); // false (auto mode, not looping)
|
|
3674
|
+
*
|
|
3675
|
+
* textmodifier.renderMode('manual');
|
|
3676
|
+
* console.log(textmodifier.isLooping()); // false (manual mode)
|
|
3677
|
+
*
|
|
3678
|
+
* textmodifier.renderMode('auto');
|
|
3679
|
+
* console.log(textmodifier.isLooping()); // false (auto mode, but loop was stopped)
|
|
3680
|
+
*
|
|
3681
|
+
* textmodifier.loop();
|
|
3682
|
+
* console.log(textmodifier.isLooping()); // true (auto mode, looping)
|
|
3683
|
+
* ```
|
|
3684
|
+
*/
|
|
3685
|
+
isLooping() {
|
|
3686
|
+
return this._isDestroyed ? !1 : this._mode === "auto" && this._isLooping;
|
|
3584
3687
|
}
|
|
3585
3688
|
/**
|
|
3586
3689
|
* Set the font size used for rendering.
|
|
@@ -4142,7 +4245,7 @@ class S {
|
|
|
4142
4245
|
destroy() {
|
|
4143
4246
|
this._isDestroyed || (this._isDestroyed = !0, this.stopAutoRendering(), this._windowResizeListener && (window.removeEventListener("resize", this._windowResizeListener), this._windowResizeListener = null), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this._pipeline && !this._pipeline.isDisposed && this._pipeline.dispose(), this._font && !this._font.isDisposed && this._font.dispose(), this._grid && !this._grid.isDisposed && this._grid.dispose(), this._canvasFramebuffer && !this._canvasFramebuffer.isDisposed && this._canvasFramebuffer.dispose(), this._renderer && !this._renderer.isDisposed && this._renderer.dispose(), this.textmodeCanvas && !this.textmodeCanvas.isDisposed && this.textmodeCanvas.dispose(), this.captureSource = null, this.textmodeCanvas = null, this._renderer = null, this._canvasFramebuffer = null, this._font = null, this._grid = null, this._pipeline = null, this.resizeObserver = null, this._drawCallback = () => {
|
|
4144
4247
|
}, this._resizedCallback = () => {
|
|
4145
|
-
}, this.animationFrameId = null, this.lastFrameTime = 0, this.lastRenderTime = 0, this._frameCount = 0, this._frameRate = 0, this.frameTimeHistory = []);
|
|
4248
|
+
}, this.animationFrameId = null, this.lastFrameTime = 0, this.lastRenderTime = 0, this._frameCount = 0, this._frameRate = 0, this.frameTimeHistory = [], this._isLooping = !1);
|
|
4146
4249
|
}
|
|
4147
4250
|
/** Get the current grid object used for rendering. */
|
|
4148
4251
|
get grid() {
|
|
@@ -4275,13 +4378,13 @@ class N {
|
|
|
4275
4378
|
* ```
|
|
4276
4379
|
*/
|
|
4277
4380
|
static get version() {
|
|
4278
|
-
return "0.1.4-beta.
|
|
4381
|
+
return "0.1.4-beta.2";
|
|
4279
4382
|
}
|
|
4280
4383
|
constructor() {
|
|
4281
4384
|
throw new Error("Textmode is a static class and cannot be instantiated.");
|
|
4282
4385
|
}
|
|
4283
4386
|
}
|
|
4284
|
-
const
|
|
4387
|
+
const HA = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4285
4388
|
__proto__: null
|
|
4286
4389
|
}, Symbol.toStringTag, { value: "Module" })), NA = N.create, XA = N.setErrorLevel, WA = N.version;
|
|
4287
4390
|
export {
|
|
@@ -4291,10 +4394,10 @@ export {
|
|
|
4291
4394
|
CA as TextmodeFont,
|
|
4292
4395
|
mA as TextmodeGrid,
|
|
4293
4396
|
S as Textmodifier,
|
|
4294
|
-
|
|
4397
|
+
LA as converters,
|
|
4295
4398
|
NA as create,
|
|
4296
4399
|
N as default,
|
|
4297
|
-
|
|
4400
|
+
HA as export,
|
|
4298
4401
|
XA as setErrorLevel,
|
|
4299
4402
|
N as textmode,
|
|
4300
4403
|
WA as version
|