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