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