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