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