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