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