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