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