textmode.js 0.1.9-beta.6 → 0.2.0-beta.1
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/README.md +14 -13
- package/dist/textmode.esm.js +1408 -1419
- package/dist/textmode.esm.min.js +1488 -1499
- package/dist/textmode.umd.js +19 -56
- package/dist/textmode.umd.min.js +19 -56
- package/dist/types/Textmode.d.ts +10 -38
- package/dist/types/export/base/DataExtractor.d.ts +3 -3
- package/dist/types/export/image/ImageExporter.d.ts +4 -11
- package/dist/types/export/image/types.d.ts +2 -3
- package/dist/types/export/svg/SVGExporter.d.ts +1 -1
- package/dist/types/export/svg/types.d.ts +1 -0
- package/dist/types/export/txt/TXTDataExtractor.d.ts +3 -3
- package/dist/types/export/txt/TXTExporter.d.ts +1 -1
- package/dist/types/export/txt/types.d.ts +4 -2
- package/dist/types/index.d.ts +1 -6
- package/dist/types/rendering/index.d.ts +2 -2
- package/dist/types/rendering/webgl/DrawQueue.d.ts +26 -0
- package/dist/types/rendering/webgl/Framebuffer.d.ts +38 -52
- package/dist/types/rendering/webgl/InstanceBatch.d.ts +91 -0
- package/dist/types/rendering/webgl/InstanceData.d.ts +65 -0
- package/dist/types/rendering/webgl/RenderPipeline.d.ts +15 -0
- package/dist/types/rendering/webgl/RenderState.d.ts +76 -0
- package/dist/types/rendering/webgl/Renderer.d.ts +58 -83
- package/dist/types/rendering/webgl/Shader.d.ts +23 -12
- package/dist/types/rendering/webgl/VAOManager.d.ts +15 -0
- package/dist/types/rendering/webgl/geometries/Arc.d.ts +16 -0
- package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +35 -29
- package/dist/types/rendering/webgl/geometries/BezierCurve.d.ts +22 -0
- package/dist/types/rendering/webgl/geometries/Ellipse.d.ts +20 -0
- package/dist/types/rendering/webgl/geometries/Line.d.ts +13 -4
- package/dist/types/rendering/webgl/geometries/Rectangle.d.ts +13 -8
- package/dist/types/rendering/webgl/geometries/Triangle.d.ts +20 -0
- package/dist/types/rendering/webgl/geometries/index.d.ts +4 -1
- package/dist/types/rendering/webgl/index.d.ts +17 -1
- package/dist/types/rendering/webgl/types/DrawCommand.d.ts +9 -0
- package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +144 -0
- package/dist/types/rendering/webgl/types/RenderTypes.d.ts +12 -0
- package/dist/types/textmode/AnimationController.d.ts +81 -0
- package/dist/types/textmode/Canvas.d.ts +18 -19
- package/dist/types/textmode/Grid.d.ts +1 -34
- package/dist/types/textmode/Textmodifier.d.ts +36 -277
- package/dist/types/textmode/font/CharacterColorMapper.d.ts +3 -3
- package/dist/types/textmode/font/TextmodeFont.d.ts +8 -13
- package/dist/types/textmode/font/TextureAtlas.d.ts +2 -2
- package/dist/types/textmode/font/types.d.ts +1 -1
- package/dist/types/textmode/font/typr/types.d.ts +1 -1
- package/dist/types/textmode/font/utils/index.d.ts +0 -1
- package/dist/types/textmode/mixins/AnimationMixin.d.ts +120 -0
- package/dist/types/textmode/mixins/ExportMixin.d.ts +4 -6
- package/dist/types/textmode/mixins/FontMixin.d.ts +4 -10
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +224 -246
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +13 -4
- package/dist/types/textmode/mixins/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/ColorPalette.d.ts +0 -38
- package/dist/types/rendering/core/AbstractFramebuffer.d.ts +0 -1
- package/dist/types/rendering/core/AbstractGeometry.d.ts +0 -1
- package/dist/types/rendering/core/AbstractShader.d.ts +0 -1
- package/dist/types/rendering/core/AbstractTexture.d.ts +0 -1
- package/dist/types/rendering/core/GraphicsContext.d.ts +0 -1
- package/dist/types/textmode/ConversionPipeline.d.ts +0 -110
- package/dist/types/textmode/converters/BrightnessConverter.d.ts +0 -58
- package/dist/types/textmode/converters/Converter.d.ts +0 -62
- package/dist/types/textmode/converters/FeatureConverter.d.ts +0 -106
- package/dist/types/textmode/converters/index.d.ts +0 -3
- package/dist/types/textmode/font/utils/FontConstants.d.ts +0 -60
- package/dist/types/textmode/mixins/ConversionMixin.d.ts +0 -62
package/dist/textmode.esm.min.js
CHANGED
|
@@ -1,1616 +1,1672 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
|
+
var q = (a, t, e) => t in a ? J(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var c = (a, t, e) => q(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
class C extends Error {
|
|
5
5
|
constructor(t, e = {}) {
|
|
6
|
-
super(
|
|
6
|
+
super(C.i(t, e)), this.name = "TextmodeError";
|
|
7
7
|
}
|
|
8
8
|
static i(t, e) {
|
|
9
|
-
let
|
|
9
|
+
let s = t;
|
|
10
10
|
if (e && Object.keys(e).length > 0) {
|
|
11
|
-
|
|
11
|
+
s += `
|
|
12
12
|
|
|
13
13
|
📋 Context:`;
|
|
14
|
-
for (const [
|
|
15
|
-
|
|
16
|
-
- ${
|
|
14
|
+
for (const [r, i] of Object.entries(e))
|
|
15
|
+
s += `
|
|
16
|
+
- ${r}: ${C.o(i)}`;
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return s += `
|
|
19
19
|
|
|
20
|
-
`,
|
|
21
|
-
`,
|
|
20
|
+
`, s += "↓".repeat(24) + `
|
|
21
|
+
`, s;
|
|
22
22
|
}
|
|
23
23
|
static o(t) {
|
|
24
24
|
if (t === null) return "null";
|
|
25
25
|
if (t === void 0) return "undefined";
|
|
26
26
|
if (typeof t == "string") return `"${t}"`;
|
|
27
27
|
if (typeof t == "number" || typeof t == "boolean") return t + "";
|
|
28
|
-
if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) =>
|
|
28
|
+
if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => C.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => C.o(e)).join(", ")}, ... +${t.length - 3} more]`;
|
|
29
29
|
if (typeof t == "object") {
|
|
30
30
|
const e = Object.keys(t);
|
|
31
|
-
return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((
|
|
31
|
+
return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((s) => `${s}: ${C.o(t[s])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((s) => `${s}: ${C.o(t[s])}`).join(", ")}, ... +${e.length - 2} more }`;
|
|
32
32
|
}
|
|
33
33
|
return t + "";
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
var
|
|
37
|
-
const
|
|
36
|
+
var Z = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(Z || {});
|
|
37
|
+
const w = class w {
|
|
38
38
|
constructor() {
|
|
39
|
-
|
|
39
|
+
c(this, "l", { globalLevel: 3 });
|
|
40
40
|
}
|
|
41
41
|
static u() {
|
|
42
|
-
return
|
|
42
|
+
return w.h || (w.h = new w()), w.h;
|
|
43
43
|
}
|
|
44
44
|
p(t, e) {
|
|
45
|
-
const
|
|
45
|
+
const s = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", r = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
|
|
46
46
|
switch (this.l.globalLevel) {
|
|
47
47
|
case 0:
|
|
48
48
|
return !1;
|
|
49
49
|
case 1:
|
|
50
|
-
return console.group(
|
|
50
|
+
return console.group(s, r), console.warn(C.i(t, e)), console.groupEnd(), !1;
|
|
51
51
|
case 2:
|
|
52
|
-
return console.group(
|
|
52
|
+
return console.group(s, r), console.error(C.i(t, e)), console.groupEnd(), !1;
|
|
53
53
|
default:
|
|
54
|
-
throw new
|
|
54
|
+
throw new C(t, e);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
return !!t || (this.p(e,
|
|
57
|
+
_(t, e, s) {
|
|
58
|
+
return !!t || (this.p(e, s), !1);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
m(t) {
|
|
61
61
|
this.l.globalLevel = t;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
let
|
|
66
|
-
const
|
|
67
|
-
function
|
|
68
|
-
|
|
64
|
+
c(w, "h", null);
|
|
65
|
+
let z = w;
|
|
66
|
+
const I = z.u(), X = /* @__PURE__ */ new WeakMap();
|
|
67
|
+
function D(a, t) {
|
|
68
|
+
X.set(a, t);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
70
|
+
function L(a) {
|
|
71
|
+
return X.get(a);
|
|
72
72
|
}
|
|
73
|
-
class
|
|
74
|
-
constructor(t, e,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
73
|
+
class Y {
|
|
74
|
+
constructor(t, e, s = e, r = 1, i = {}) {
|
|
75
|
+
c(this, "v");
|
|
76
|
+
c(this, "C");
|
|
77
|
+
c(this, "l");
|
|
78
|
+
c(this, "$", null);
|
|
79
|
+
c(this, "R");
|
|
80
|
+
c(this, "M");
|
|
81
|
+
c(this, "S", []);
|
|
82
|
+
c(this, "A");
|
|
83
|
+
c(this, "P", null);
|
|
84
|
+
c(this, "F", []);
|
|
85
|
+
this.v = e, this.C = s, this.l = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...i }, this.R = t, this.A = Math.min(Math.max(1, r), 8);
|
|
86
|
+
const n = t.getParameter(t.MAX_DRAW_BUFFERS), o = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
|
|
87
|
+
this.A = Math.min(this.A, n, o), this.M = t.createFramebuffer(), this.G(), this.D(), this.F = Array(this.A).fill(null);
|
|
88
|
+
}
|
|
89
|
+
G() {
|
|
90
|
+
const t = this.R, e = this.l.filter === "linear" ? t.LINEAR : t.NEAREST, s = this.l.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, r = this.l.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
|
|
91
|
+
for (let i = 0; i < this.A; i++) {
|
|
92
|
+
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, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, s), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.v, this.C, 0, t.RGBA, r, null), this.S.push(n);
|
|
92
94
|
}
|
|
95
|
+
t.bindTexture(t.TEXTURE_2D, null);
|
|
93
96
|
}
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
t.
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
D() {
|
|
98
|
+
const t = this.R;
|
|
99
|
+
if (t.bindFramebuffer(t.FRAMEBUFFER, this.M), this.A === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.S[0], 0);
|
|
100
|
+
else {
|
|
101
|
+
const s = [];
|
|
102
|
+
for (let r = 0; r < this.A; r++) {
|
|
103
|
+
const i = t.COLOR_ATTACHMENT0 + r;
|
|
104
|
+
t.framebufferTexture2D(t.FRAMEBUFFER, i, t.TEXTURE_2D, this.S[r], 0), s.push(i);
|
|
105
|
+
}
|
|
106
|
+
t.drawBuffers(s);
|
|
107
|
+
}
|
|
108
|
+
const e = t.checkFramebufferStatus(t.FRAMEBUFFER);
|
|
109
|
+
e !== t.FRAMEBUFFER_COMPLETE && console.error("GLFramebuffer is not complete:", e), t.bindFramebuffer(t.FRAMEBUFFER, null);
|
|
110
|
+
}
|
|
111
|
+
I(t) {
|
|
112
|
+
const e = this.R;
|
|
113
|
+
e.bindTexture(e.TEXTURE_2D, this.S[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
|
|
114
|
+
}
|
|
115
|
+
L(t, e) {
|
|
116
|
+
this.v = t, this.C = e, this.$ = null, this.F = Array(this.A).fill(null);
|
|
117
|
+
const s = this.R, r = this.l.type === "float" ? s.FLOAT : s.UNSIGNED_BYTE;
|
|
118
|
+
for (const i of this.S) s.bindTexture(s.TEXTURE_2D, i), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, this.v, this.C, 0, s.RGBA, r, null);
|
|
119
|
+
s.bindTexture(s.TEXTURE_2D, null);
|
|
120
|
+
}
|
|
121
|
+
W(t) {
|
|
122
|
+
const e = this.R;
|
|
123
|
+
if (t < 0 || t >= this.A) throw Error(`GLFramebuffer: attachment index ${t} out of range (count=${this.A})`);
|
|
124
|
+
const s = this.F[t];
|
|
125
|
+
if (s) return s;
|
|
126
|
+
const r = this.v, i = this.C, n = new Uint8Array(r * i * 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, r, i, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
|
|
128
|
+
const h = 4 * r, l = new Uint8Array(n.length);
|
|
129
|
+
for (let u = 0; u < i; u++) {
|
|
130
|
+
const f = (i - 1 - u) * h, d = u * h;
|
|
131
|
+
l.set(n.subarray(f, f + h), d);
|
|
132
|
+
}
|
|
133
|
+
return this.F[t] = l, l;
|
|
99
134
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.F, this.M, 0, t.RGBA, e, null);
|
|
135
|
+
k() {
|
|
136
|
+
for (let t = 0; t < this.A; t++) this.W(t);
|
|
103
137
|
}
|
|
104
138
|
V() {
|
|
105
|
-
const
|
|
106
|
-
t.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const { v: e } = this;
|
|
110
|
-
e.bindTexture(e.TEXTURE_2D, this.$), 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);
|
|
111
|
-
}
|
|
112
|
-
updatePixels(t, e, r) {
|
|
113
|
-
const { v: s } = this;
|
|
114
|
-
s.bindTexture(s.TEXTURE_2D, this.$), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, e, r, 0, s.RGBA, s.UNSIGNED_BYTE, t), s.bindTexture(s.TEXTURE_2D, null);
|
|
115
|
-
}
|
|
116
|
-
resize(t, e) {
|
|
117
|
-
const { v: r } = this;
|
|
118
|
-
this.F = t, this.M = e, this.S = null, r.bindTexture(r.TEXTURE_2D, this.$), this.I(), r.bindTexture(r.TEXTURE_2D, null);
|
|
119
|
-
}
|
|
120
|
-
begin() {
|
|
121
|
-
const { v: t } = this;
|
|
122
|
-
this.D = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.C), t.viewport(0, 0, this.F, this.M), I(t, [0, 0, this.F, this.M]);
|
|
123
|
-
}
|
|
124
|
-
end() {
|
|
125
|
-
if (!this.D) return;
|
|
126
|
-
const { v: t } = this;
|
|
127
|
-
t.bindFramebuffer(t.FRAMEBUFFER, this.D.framebuffer), t.viewport(...this.D.viewport), I(t, this.D.viewport), this.D = null;
|
|
128
|
-
}
|
|
129
|
-
loadPixels() {
|
|
130
|
-
const { v: t } = this;
|
|
131
|
-
this.S || (this.S = new Uint8Array(this.F * this.M * 4)), this.k(() => {
|
|
132
|
-
t.readPixels(0, 0, this.F, this.M, t.RGBA, t.UNSIGNED_BYTE, this.S);
|
|
133
|
-
});
|
|
139
|
+
const t = this.R;
|
|
140
|
+
this.P = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.M), this.F = Array(this.A).fill(null);
|
|
141
|
+
for (let e = 0; e < this.A; e++) t.clearBufferfv(t.COLOR, e, new Float32Array([0, 0, 0, 0]));
|
|
142
|
+
t.viewport(0, 0, this.v, this.C), D(t, [0, 0, this.v, this.C]);
|
|
134
143
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return this.k(() => (i.readPixels(0, 0, this.F, this.M, i.RGBA, i.UNSIGNED_BYTE, o), o));
|
|
140
|
-
}
|
|
141
|
-
if (r === void 0 && s === void 0) {
|
|
142
|
-
(t < 0 || e < 0 || t >= this.F || e >= this.M) && (console.warn("The x and y values passed to Framebuffer.get are outside of its range and will be clamped."), t = Math.max(0, Math.min(t, this.F - 1)), e = Math.max(0, Math.min(e, this.M - 1)));
|
|
143
|
-
const o = new Uint8Array(4);
|
|
144
|
-
return this.k(() => (i.readPixels(t, e, 1, 1, i.RGBA, i.UNSIGNED_BYTE, o), [o[0], o[1], o[2], o[3]]));
|
|
145
|
-
}
|
|
146
|
-
{
|
|
147
|
-
t = Math.max(0, Math.min(t, this.F - 1)), e = Math.max(0, Math.min(e, this.M - 1)), r = Math.max(1, Math.min(r, this.F - t)), s = Math.max(1, Math.min(s, this.M - e));
|
|
148
|
-
const o = new Uint8Array(r * s * 4);
|
|
149
|
-
return this.k(() => (i.readPixels(t, e, r, s, i.RGBA, i.UNSIGNED_BYTE, o), o));
|
|
150
|
-
}
|
|
144
|
+
O() {
|
|
145
|
+
if (!this.P) return;
|
|
146
|
+
const t = this.R;
|
|
147
|
+
t.bindFramebuffer(t.FRAMEBUFFER, this.P.framebuffer), t.viewport(...this.P.viewport), D(t, this.P.viewport), this.P = null;
|
|
151
148
|
}
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
U() {
|
|
150
|
+
const t = this.R;
|
|
151
|
+
this.M && t.deleteFramebuffer(this.M);
|
|
152
|
+
for (const e of this.S) t.deleteTexture(e);
|
|
153
|
+
this.S = [], this.F = [];
|
|
154
154
|
}
|
|
155
|
-
get
|
|
155
|
+
get width() {
|
|
156
|
+
return this.v;
|
|
157
|
+
}
|
|
158
|
+
get height() {
|
|
156
159
|
return this.C;
|
|
157
160
|
}
|
|
158
|
-
get
|
|
161
|
+
get pixels() {
|
|
159
162
|
return this.$;
|
|
160
163
|
}
|
|
161
|
-
get
|
|
162
|
-
return this.
|
|
164
|
+
get options() {
|
|
165
|
+
return { ...this.l };
|
|
163
166
|
}
|
|
164
|
-
get
|
|
167
|
+
get framebuffer() {
|
|
165
168
|
return this.M;
|
|
166
169
|
}
|
|
167
|
-
get
|
|
168
|
-
return this.S;
|
|
170
|
+
get texture() {
|
|
171
|
+
return this.S[0];
|
|
169
172
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
constructor(t, e, r) {
|
|
173
|
-
h(this, "v");
|
|
174
|
-
h(this, "G");
|
|
175
|
-
h(this, "A", /* @__PURE__ */ new Map());
|
|
176
|
-
h(this, "U", /* @__PURE__ */ new Map());
|
|
177
|
-
h(this, "L", 0);
|
|
178
|
-
h(this, "H");
|
|
179
|
-
this.v = t, this.G = this.j(e, r), this.H = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.O();
|
|
173
|
+
get textures() {
|
|
174
|
+
return [...this.S];
|
|
180
175
|
}
|
|
181
|
-
|
|
182
|
-
|
|
176
|
+
get attachmentCount() {
|
|
177
|
+
return this.A;
|
|
178
|
+
}
|
|
179
|
+
getAttachmentPixels(t) {
|
|
180
|
+
return this.F[t] ?? null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
class K {
|
|
184
|
+
constructor(t, e, s) {
|
|
185
|
+
c(this, "R");
|
|
186
|
+
c(this, "j");
|
|
187
|
+
c(this, "H", /* @__PURE__ */ new Map());
|
|
188
|
+
c(this, "q", /* @__PURE__ */ new Map());
|
|
189
|
+
c(this, "N", 0);
|
|
190
|
+
c(this, "X");
|
|
191
|
+
this.R = t, this.j = this.Y(e, s), this.X = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.Z();
|
|
192
|
+
}
|
|
193
|
+
Z() {
|
|
194
|
+
const t = this.R.getProgramParameter(this.j, this.R.ACTIVE_UNIFORMS);
|
|
183
195
|
for (let e = 0; e < t; e++) {
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
const
|
|
187
|
-
|
|
196
|
+
const s = this.R.getActiveUniform(this.j, e);
|
|
197
|
+
if (s) {
|
|
198
|
+
const r = this.R.getUniformLocation(this.j, s.name);
|
|
199
|
+
r && (this.H.set(s.name, r), this.q.set(s.name, s.type));
|
|
188
200
|
}
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
if (this.
|
|
194
|
-
const
|
|
195
|
-
throw Error("Shader program link error: " +
|
|
203
|
+
Y(t, e) {
|
|
204
|
+
const s = this.J(this.R.VERTEX_SHADER, t), r = this.J(this.R.FRAGMENT_SHADER, e), i = this.R.createProgram();
|
|
205
|
+
if (this.R.attachShader(i, s), this.R.attachShader(i, r), this.R.linkProgram(i), !this.R.getProgramParameter(i, this.R.LINK_STATUS)) {
|
|
206
|
+
const n = this.R.getProgramInfoLog(i);
|
|
207
|
+
throw Error("Shader program link error: " + n);
|
|
196
208
|
}
|
|
197
|
-
return this.
|
|
209
|
+
return this.R.deleteShader(s), this.R.deleteShader(r), i;
|
|
198
210
|
}
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
if (this.
|
|
202
|
-
const
|
|
203
|
-
throw this.
|
|
211
|
+
J(t, e) {
|
|
212
|
+
const s = this.R.createShader(t);
|
|
213
|
+
if (this.R.shaderSource(s, e), this.R.compileShader(s), !this.R.getShaderParameter(s, this.R.COMPILE_STATUS)) {
|
|
214
|
+
const r = this.R.getShaderInfoLog(s);
|
|
215
|
+
throw this.R.deleteShader(s), Error("Shader compilation error: " + r);
|
|
204
216
|
}
|
|
205
|
-
return
|
|
217
|
+
return s;
|
|
218
|
+
}
|
|
219
|
+
K() {
|
|
220
|
+
this.R.useProgram(this.j), this.tt();
|
|
206
221
|
}
|
|
207
|
-
|
|
208
|
-
this.
|
|
222
|
+
tt() {
|
|
223
|
+
this.N = 0;
|
|
224
|
+
}
|
|
225
|
+
et(t) {
|
|
226
|
+
for (const [e, s] of Object.entries(t)) this.st(e, s);
|
|
209
227
|
}
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
else if (typeof e == "boolean") this.v.uniform1i(r, e ? 1 : 0);
|
|
228
|
+
st(t, e) {
|
|
229
|
+
const s = this.H.get(t);
|
|
230
|
+
if (s) if (typeof e == "number") this.R.uniform1f(s, e);
|
|
231
|
+
else if (typeof e == "boolean") this.R.uniform1i(s, e ? 1 : 0);
|
|
215
232
|
else if (Array.isArray(e)) switch (e.length) {
|
|
216
233
|
case 2:
|
|
217
|
-
this.
|
|
234
|
+
this.R.uniform2f(s, e[0], e[1]);
|
|
218
235
|
break;
|
|
219
236
|
case 3:
|
|
220
|
-
this.
|
|
237
|
+
this.R.uniform3f(s, e[0], e[1], e[2]);
|
|
221
238
|
break;
|
|
222
239
|
case 4:
|
|
223
|
-
this.
|
|
240
|
+
this.R.uniform4f(s, e[0], e[1], e[2], e[3]);
|
|
224
241
|
break;
|
|
225
242
|
default:
|
|
226
243
|
console.warn(`Unsupported array length ${e.length} for uniform '${t}'`);
|
|
227
244
|
}
|
|
228
245
|
else if (e instanceof WebGLTexture) {
|
|
229
|
-
const
|
|
230
|
-
this.
|
|
231
|
-
} else if (e instanceof
|
|
232
|
-
const
|
|
233
|
-
this.
|
|
246
|
+
const r = this.it();
|
|
247
|
+
this.R.uniform1i(s, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e);
|
|
248
|
+
} else if (e instanceof Y) {
|
|
249
|
+
const r = this.it();
|
|
250
|
+
this.R.uniform1i(s, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e.texture);
|
|
251
|
+
} else if (typeof e == "object" && "texture" in e) {
|
|
252
|
+
const r = this.it();
|
|
253
|
+
this.R.uniform1i(s, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e.texture);
|
|
234
254
|
} else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
|
|
235
255
|
}
|
|
236
|
-
|
|
237
|
-
return this.
|
|
238
|
-
}
|
|
239
|
-
q(t) {
|
|
240
|
-
const e = this.U.get(t);
|
|
241
|
-
return !!e && (e === this.v.INT || e === this.v.INT_VEC2 || e === this.v.INT_VEC3 || e === this.v.INT_VEC4 || e === this.v.SAMPLER_2D || e === this.v.SAMPLER_CUBE);
|
|
242
|
-
}
|
|
243
|
-
get glProgram() {
|
|
244
|
-
return this.G;
|
|
256
|
+
it() {
|
|
257
|
+
return this.N >= this.X && console.warn(`Exceeded maximum texture units (${this.X}). Texture may not render correctly.`), this.N++;
|
|
245
258
|
}
|
|
246
|
-
|
|
247
|
-
this.
|
|
259
|
+
get rt() {
|
|
260
|
+
return this.j;
|
|
248
261
|
}
|
|
249
|
-
|
|
250
|
-
this.
|
|
262
|
+
U() {
|
|
263
|
+
this.R.deleteProgram(this.j);
|
|
251
264
|
}
|
|
252
265
|
}
|
|
253
266
|
class Q {
|
|
254
|
-
constructor(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
this
|
|
267
|
+
constructor() {
|
|
268
|
+
c(this, "nt", 1);
|
|
269
|
+
c(this, "ot", 0);
|
|
270
|
+
c(this, "ht", [0, 0, 0]);
|
|
271
|
+
c(this, "ct", [1, 1, 1, 1]);
|
|
272
|
+
c(this, "lt", [0, 0, 0, 1]);
|
|
273
|
+
c(this, "ut", !1);
|
|
274
|
+
c(this, "ft", !1);
|
|
275
|
+
c(this, "dt", !1);
|
|
276
|
+
c(this, "gt", [0, 0]);
|
|
277
|
+
c(this, "_t", []);
|
|
278
|
+
}
|
|
279
|
+
vt() {
|
|
280
|
+
this._t.push({ lineWeight: this.nt, rotation: this.ot, charRotation: [...this.gt], flipHorizontally: this.ut, flipVertically: this.ft, invert: this.dt, character: [...this.ht], charColor: [...this.ct], cellColor: [...this.lt] });
|
|
281
|
+
}
|
|
282
|
+
xt() {
|
|
283
|
+
const t = this._t.pop();
|
|
284
|
+
t ? (this.nt = t.lineWeight, this.ot = t.rotation, this.gt = t.charRotation, this.ut = t.flipHorizontally, this.ft = t.flipVertically, this.dt = t.invert, this.ht = t.character, this.ct = t.charColor, this.lt = t.cellColor) : console.warn("pop() called without matching push()");
|
|
285
|
+
}
|
|
286
|
+
Ct() {
|
|
287
|
+
this._t = [], this.ot = 0;
|
|
260
288
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const t = this.v;
|
|
264
|
-
this.Z = t.createBuffer(), t.bindBuffer(t.ARRAY_BUFFER, this.Z);
|
|
289
|
+
yt(t) {
|
|
290
|
+
t.lineWeight = this.nt, t.rotation = this.ot, t.character[0] = this.ht[0], t.character[1] = this.ht[1], t.character[2] = this.ht[2], t.charColor[0] = this.ct[0], t.charColor[1] = this.ct[1], t.charColor[2] = this.ct[2], t.charColor[3] = this.ct[3], t.bgColor[0] = this.lt[0], t.bgColor[1] = this.lt[1], t.bgColor[2] = this.lt[2], t.bgColor[3] = this.lt[3], t.flipHorizontally = this.ut, t.flipVertically = this.ft, t.invert = this.dt, t.charRotation[0] = this.gt[0], t.charRotation[1] = this.gt[1];
|
|
265
291
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
let r = this.K.get(e);
|
|
269
|
-
return r || (r = { a_position: t.getAttribLocation(e, "a_position"), a_texCoord: t.getAttribLocation(e, "a_texCoord") }, this.K.set(e, r)), t.enableVertexAttribArray(r.a_position), t.vertexAttribPointer(r.a_position, 2, t.FLOAT, !1, this.J, 0), t.enableVertexAttribArray(r.a_texCoord), t.vertexAttribPointer(r.a_texCoord, 2, t.FLOAT, !1, this.J, 8), { positionLoc: r.a_position, texLoc: r.a_texCoord };
|
|
292
|
+
get lineWeight() {
|
|
293
|
+
return this.nt;
|
|
270
294
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
r.disableVertexAttribArray(t), r.disableVertexAttribArray(e);
|
|
295
|
+
get rotation() {
|
|
296
|
+
return this.ot;
|
|
274
297
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
298
|
+
get character() {
|
|
299
|
+
return this.ht;
|
|
300
|
+
}
|
|
301
|
+
get charColor() {
|
|
302
|
+
return this.ct;
|
|
303
|
+
}
|
|
304
|
+
get bgColor() {
|
|
305
|
+
return this.lt;
|
|
306
|
+
}
|
|
307
|
+
get flipHorizontally() {
|
|
308
|
+
return this.ut;
|
|
309
|
+
}
|
|
310
|
+
get flipVertically() {
|
|
311
|
+
return this.ft;
|
|
312
|
+
}
|
|
313
|
+
get invert() {
|
|
314
|
+
return this.dt;
|
|
315
|
+
}
|
|
316
|
+
get charRotation() {
|
|
317
|
+
return this.gt;
|
|
318
|
+
}
|
|
319
|
+
wt(t) {
|
|
320
|
+
this.nt = Math.abs(t);
|
|
321
|
+
}
|
|
322
|
+
$t(t) {
|
|
323
|
+
this.ot = t;
|
|
324
|
+
}
|
|
325
|
+
bt(t) {
|
|
326
|
+
this.ht = t;
|
|
278
327
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
this.tt(), i.bindBuffer(i.ARRAY_BUFFER, this.Z);
|
|
282
|
-
const o = new Float32Array([t, s, 0, 0, r, s, 1, 0, t, e, 0, 1, t, e, 0, 1, r, s, 1, 0, r, e, 1, 1]);
|
|
283
|
-
i.bufferData(i.ARRAY_BUFFER, o, i.DYNAMIC_DRAW);
|
|
328
|
+
Tt(t, e, s, r = 255) {
|
|
329
|
+
this.ct = [t / 255, e / 255, s / 255, r / 255];
|
|
284
330
|
}
|
|
285
|
-
|
|
286
|
-
this.
|
|
331
|
+
zt(t, e, s, r = 255) {
|
|
332
|
+
this.lt = [t / 255, e / 255, s / 255, r / 255];
|
|
333
|
+
}
|
|
334
|
+
Rt(t) {
|
|
335
|
+
this.ut = t;
|
|
336
|
+
}
|
|
337
|
+
Mt(t) {
|
|
338
|
+
this.ft = t;
|
|
339
|
+
}
|
|
340
|
+
St(t) {
|
|
341
|
+
this.dt = t;
|
|
342
|
+
}
|
|
343
|
+
At(t) {
|
|
344
|
+
const e = 255 * t / 360, s = Math.floor(e) / 255, r = Math.round(e - Math.floor(e));
|
|
345
|
+
this.gt = [s, r];
|
|
287
346
|
}
|
|
288
347
|
}
|
|
289
|
-
|
|
348
|
+
var R = ((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))(R || {});
|
|
349
|
+
class tt {
|
|
290
350
|
constructor(t) {
|
|
291
|
-
|
|
351
|
+
c(this, "R");
|
|
352
|
+
c(this, "Pt", /* @__PURE__ */ new Map());
|
|
353
|
+
this.R = t;
|
|
354
|
+
}
|
|
355
|
+
Ft(t, e, s, r) {
|
|
356
|
+
const i = this.R;
|
|
357
|
+
let n = this.Pt.get(t);
|
|
358
|
+
n || (n = /* @__PURE__ */ new Map(), this.Pt.set(t, n));
|
|
359
|
+
let o = n.get(e) || null;
|
|
360
|
+
if (!o) {
|
|
361
|
+
o = i.createVertexArray(), n.set(e, o), i.bindVertexArray(o), i.bindBuffer(i.ARRAY_BUFFER, r);
|
|
362
|
+
const h = i.getAttribLocation(t, "a_position");
|
|
363
|
+
h !== -1 && (i.enableVertexAttribArray(h), i.vertexAttribPointer(h, s.attributes.position.size, i.FLOAT, !1, s.stride, s.attributes.position.offset), i.vertexAttribDivisor(h, 0));
|
|
364
|
+
const l = i.getAttribLocation(t, "a_texCoord");
|
|
365
|
+
l !== -1 && (i.enableVertexAttribArray(l), i.vertexAttribPointer(l, s.attributes.texCoord.size, i.FLOAT, !1, s.stride, s.attributes.texCoord.offset), i.vertexAttribDivisor(l, 0));
|
|
366
|
+
}
|
|
367
|
+
i.bindVertexArray(o);
|
|
292
368
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
this.it(i.nx, i.ny, o.nx, o.ny);
|
|
296
|
-
const n = this.et();
|
|
297
|
-
this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.rt(n.positionLoc, n.texLoc);
|
|
369
|
+
Gt() {
|
|
370
|
+
this.R.bindVertexArray(null);
|
|
298
371
|
}
|
|
299
|
-
|
|
300
|
-
|
|
372
|
+
U() {
|
|
373
|
+
const t = this.R;
|
|
374
|
+
for (const [, e] of this.Pt) for (const [, s] of e) s && t.deleteVertexArray(s);
|
|
375
|
+
this.Pt.clear();
|
|
301
376
|
}
|
|
302
377
|
}
|
|
303
|
-
class
|
|
378
|
+
class et {
|
|
304
379
|
constructor(t) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
380
|
+
c(this, "Dt");
|
|
381
|
+
c(this, "R");
|
|
382
|
+
this.R = t, this.Dt = new tt(t);
|
|
383
|
+
}
|
|
384
|
+
It(t, e, s) {
|
|
385
|
+
const { shader: r } = t, i = L(this.R) || this.R.getParameter(this.R.VIEWPORT);
|
|
386
|
+
r.et({ u_aspectRatio: i[2] / i[3], u_viewportSize: [i[2], i[3]] });
|
|
387
|
+
const n = (l) => {
|
|
388
|
+
if (!l || !l.Bt()) return;
|
|
389
|
+
const u = l.unitGeometry, f = l.unitBuffer;
|
|
390
|
+
try {
|
|
391
|
+
this.Dt.Ft(r.rt, l.type + "", u, f), l.batch.Lt(r), l.batch.Et(u.primitiveType, u.vertexCount);
|
|
392
|
+
} finally {
|
|
393
|
+
l.batch.Wt(r), this.Dt.Gt(), l.kt();
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
let o = null, h = null;
|
|
397
|
+
for (const l of e) {
|
|
398
|
+
o !== null && l.type !== o && (n(h), o = null, h = null);
|
|
399
|
+
let u = h;
|
|
400
|
+
u && l.type === o || (u = s.get(l.type) || null, h = u, o = l.type), u && u.Vt(l.params, l.state);
|
|
317
401
|
}
|
|
318
|
-
|
|
319
|
-
this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.rt(c.positionLoc, c.texLoc);
|
|
402
|
+
n(h);
|
|
320
403
|
}
|
|
321
404
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
405
|
+
class st {
|
|
406
|
+
constructor() {
|
|
407
|
+
c(this, "Ot", []);
|
|
408
|
+
c(this, "Ut", 1);
|
|
409
|
+
c(this, "jt", 0);
|
|
410
|
+
}
|
|
411
|
+
Ht(t) {
|
|
412
|
+
if (this.jt >= this.Ot.length) {
|
|
413
|
+
const s = { id: this.Ut++, type: t, params: {}, state: { lineWeight: 1, rotation: 0, character: [0, 0, 0], charColor: [1, 1, 1, 1], bgColor: [0, 0, 0, 1], flipHorizontally: !1, flipVertically: !1, invert: !1, charRotation: [0, 0] } };
|
|
414
|
+
this.Ot.push(s);
|
|
415
|
+
}
|
|
416
|
+
const e = this.Ot[this.jt];
|
|
417
|
+
switch (e.id = this.Ut++, e.type = t, t) {
|
|
418
|
+
case R.RECTANGLE:
|
|
419
|
+
case R.ELLIPSE:
|
|
420
|
+
e.params && "width" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0 });
|
|
421
|
+
break;
|
|
422
|
+
case R.ARC:
|
|
423
|
+
e.params && "start" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, start: 0, stop: 0 });
|
|
424
|
+
break;
|
|
425
|
+
case R.LINE:
|
|
426
|
+
e.params && "x2" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, thickness: void 0 });
|
|
427
|
+
break;
|
|
428
|
+
case R.TRIANGLE:
|
|
429
|
+
e.params && "x3" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, x3: 0, y3: 0 });
|
|
430
|
+
break;
|
|
431
|
+
case R.BEZIER_CURVE:
|
|
432
|
+
e.params && "cp2y" in e.params || (e.params = { x1: 0, y1: 0, cp1x: 0, cp1y: 0, cp2x: 0, cp2y: 0, x2: 0, y2: 0, thickness: void 0 });
|
|
433
|
+
break;
|
|
434
|
+
default:
|
|
435
|
+
e.params || (e.params = {});
|
|
436
|
+
}
|
|
437
|
+
return this.jt++, e;
|
|
339
438
|
}
|
|
340
|
-
|
|
341
|
-
|
|
439
|
+
qt(t, e, s, r, i) {
|
|
440
|
+
const n = this.Ht(R.RECTANGLE);
|
|
441
|
+
return n.params.x = t, n.params.y = e, n.params.width = s, n.params.height = r, i.yt(n.state), n.id;
|
|
342
442
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
this.gt = [i, i, i, 1];
|
|
347
|
-
} else if (r !== void 0 && s === void 0) this.gt = [t / 255, e / 255, r / 255, 1];
|
|
348
|
-
else {
|
|
349
|
-
if (r === void 0 || s === void 0) throw Error("Invalid fill parameters. Use fill(gray), fill(r,g,b), or fill(r,g,b,a)");
|
|
350
|
-
this.gt = [t / 255, e / 255, r / 255, s / 255];
|
|
351
|
-
}
|
|
443
|
+
Nt(t, e, s, r, i, n) {
|
|
444
|
+
const o = this.Ht(R.LINE);
|
|
445
|
+
return o.params.x1 = t, o.params.y1 = e, o.params.x2 = s, o.params.y2 = r, o.params.thickness = i, n.yt(o.state), o.id;
|
|
352
446
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
447
|
+
Xt(t, e, s, r, i) {
|
|
448
|
+
const n = this.Ht(R.ELLIPSE);
|
|
449
|
+
return n.params.x = t, n.params.y = e, n.params.width = s, n.params.height = r, i.yt(n.state), n.id;
|
|
450
|
+
}
|
|
451
|
+
Yt(t, e, s, r, i, n, o) {
|
|
452
|
+
const h = this.Ht(R.ARC);
|
|
453
|
+
return h.params.x = t, h.params.y = e, h.params.width = s, h.params.height = r, h.params.start = i, h.params.stop = n, o.yt(h.state), h.id;
|
|
454
|
+
}
|
|
455
|
+
Qt(t, e, s, r, i, n, o) {
|
|
456
|
+
const h = this.Ht(R.TRIANGLE);
|
|
457
|
+
return h.params.x1 = t, h.params.y1 = e, h.params.x2 = s, h.params.y2 = r, h.params.x3 = i, h.params.y3 = n, o.yt(h.state), h.id;
|
|
458
|
+
}
|
|
459
|
+
Zt(t, e, s, r, i, n, o, h, l, u) {
|
|
460
|
+
const f = this.Ht(R.BEZIER_CURVE);
|
|
461
|
+
return f.params.x1 = t, f.params.y1 = e, f.params.cp1x = s, f.params.cp1y = r, f.params.cp2x = i, f.params.cp2y = n, f.params.x2 = o, f.params.y2 = h, f.params.thickness = l, u.yt(f.state), f.id;
|
|
462
|
+
}
|
|
463
|
+
get length() {
|
|
464
|
+
return this.jt;
|
|
465
|
+
}
|
|
466
|
+
get isEmpty() {
|
|
467
|
+
return this.jt === 0;
|
|
468
|
+
}
|
|
469
|
+
Jt() {
|
|
470
|
+
this.jt = 0;
|
|
471
|
+
}
|
|
472
|
+
[Symbol.iterator]() {
|
|
473
|
+
let t = 0;
|
|
474
|
+
const e = this.jt, s = this.Ot;
|
|
475
|
+
return { next: () => t < e ? { value: s[t++], done: !1 } : { value: void 0, done: !0 } };
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const A = class A {
|
|
479
|
+
static Kt(t, e, s = 0) {
|
|
480
|
+
var n, o, h, l, u, f, d, p, g, m;
|
|
481
|
+
const r = e || new Float32Array(A.FLOATS_PER_INSTANCE);
|
|
482
|
+
let i = s;
|
|
483
|
+
return r[i++] = t.position[0], r[i++] = t.position[1], r[i++] = t.size[0], r[i++] = t.size[1], r[i++] = t.character[0], r[i++] = t.character[1], r[i++] = t.character[2], r[i++] = t.primaryColor[0], r[i++] = t.primaryColor[1], r[i++] = t.primaryColor[2], r[i++] = t.primaryColor[3], r[i++] = t.secondaryColor[0], r[i++] = t.secondaryColor[1], r[i++] = t.secondaryColor[2], r[i++] = t.secondaryColor[3], r[i++] = t.rotation[0], r[i++] = t.rotation[1], r[i++] = t.transform[0], r[i++] = t.transform[1], r[i++] = t.transform[2], r[i++] = t.globalRotation, r[i++] = t.rotationCenter[0], r[i++] = t.rotationCenter[1], r[i++] = ((n = t.arcAngles) == null ? void 0 : n[0]) || 0, r[i++] = ((o = t.arcAngles) == null ? void 0 : o[1]) || 0, r[i++] = ((h = t.bezierControlPoint1) == null ? void 0 : h[0]) || 0, r[i++] = ((l = t.bezierControlPoint1) == null ? void 0 : l[1]) || 0, r[i++] = ((u = t.bezierControlPoint2) == null ? void 0 : u[0]) || 0, r[i++] = ((f = t.bezierControlPoint2) == null ? void 0 : f[1]) || 0, r[i++] = ((d = t.bezierStartPoint) == null ? void 0 : d[0]) || 0, r[i++] = ((p = t.bezierStartPoint) == null ? void 0 : p[1]) || 0, r[i++] = ((g = t.bezierEndPoint) == null ? void 0 : g[0]) || 0, r[i++] = ((m = t.bezierEndPoint) == null ? void 0 : m[1]) || 0, r;
|
|
484
|
+
}
|
|
485
|
+
static te(t) {
|
|
486
|
+
const e = t.length * A.FLOATS_PER_INSTANCE, s = new Float32Array(e);
|
|
487
|
+
for (let r = 0; r < t.length; r++) {
|
|
488
|
+
const i = r * A.FLOATS_PER_INSTANCE;
|
|
489
|
+
A.Kt(t[r], s, i);
|
|
361
490
|
}
|
|
491
|
+
return s;
|
|
362
492
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
493
|
+
};
|
|
494
|
+
c(A, "BYTES_PER_INSTANCE", 132), c(A, "FLOATS_PER_INSTANCE", 33);
|
|
495
|
+
let P = A;
|
|
496
|
+
const x = class x {
|
|
497
|
+
};
|
|
498
|
+
c(x, "STRIDE", P.BYTES_PER_INSTANCE), c(x, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 1, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 84, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 92, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 124, divisor: 1 } });
|
|
499
|
+
let M = x;
|
|
500
|
+
class rt {
|
|
501
|
+
constructor(t, e = 1e3, s = 1.5) {
|
|
502
|
+
c(this, "R");
|
|
503
|
+
c(this, "ee", []);
|
|
504
|
+
c(this, "se");
|
|
505
|
+
c(this, "ie");
|
|
506
|
+
c(this, "re", null);
|
|
507
|
+
c(this, "ne", !0);
|
|
508
|
+
c(this, "oe", 0);
|
|
509
|
+
c(this, "ae", /* @__PURE__ */ new Map());
|
|
510
|
+
c(this, "he", null);
|
|
511
|
+
this.R = t, this.se = e, this.ie = s, this.ce();
|
|
512
|
+
}
|
|
513
|
+
Vt(t) {
|
|
514
|
+
const e = this.ee.length;
|
|
515
|
+
return this.ee.push(t), this.ne = !0, e;
|
|
516
|
+
}
|
|
517
|
+
get count() {
|
|
518
|
+
return this.ee.length;
|
|
519
|
+
}
|
|
520
|
+
get isEmpty() {
|
|
521
|
+
return this.ee.length === 0;
|
|
366
522
|
}
|
|
367
|
-
|
|
368
|
-
this.
|
|
523
|
+
clear() {
|
|
524
|
+
this.ee.length = 0, this.ne = !0;
|
|
525
|
+
}
|
|
526
|
+
le(t) {
|
|
527
|
+
if (t <= this.se) return;
|
|
528
|
+
const e = Math.ceil(t * this.ie);
|
|
529
|
+
this.se = e, this.ce(), console.log(`InstanceBatch: Grew buffer capacity to ${e} instances`);
|
|
530
|
+
}
|
|
531
|
+
ce() {
|
|
532
|
+
const t = this.R;
|
|
533
|
+
if (this.re && t.deleteBuffer(this.re), this.re = t.createBuffer(), !this.re) throw Error("Failed to create instance buffer");
|
|
534
|
+
const e = this.se * P.BYTES_PER_INSTANCE;
|
|
535
|
+
t.bindBuffer(t.ARRAY_BUFFER, this.re), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ne = !0, this.oe = 0;
|
|
536
|
+
}
|
|
537
|
+
ue() {
|
|
538
|
+
if (!this.ne || this.ee.length === 0) return;
|
|
539
|
+
const t = this.R, e = this.ee.length;
|
|
540
|
+
this.le(e), (!this.he || this.he.length < e * P.FLOATS_PER_INSTANCE) && (this.he = new Float32Array(e * P.FLOATS_PER_INSTANCE));
|
|
541
|
+
const s = P.te(this.ee);
|
|
542
|
+
t.bindBuffer(t.ARRAY_BUFFER, this.re), e <= this.oe ? t.bufferSubData(t.ARRAY_BUFFER, 0, s) : t.bufferData(t.ARRAY_BUFFER, s, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ne = !1, this.oe = e;
|
|
369
543
|
}
|
|
370
|
-
|
|
371
|
-
|
|
544
|
+
fe(t) {
|
|
545
|
+
let e = this.ae.get(t);
|
|
546
|
+
if (!e) {
|
|
547
|
+
e = /* @__PURE__ */ new Map();
|
|
548
|
+
const s = this.R;
|
|
549
|
+
for (const r in M.ATTRIBUTES) {
|
|
550
|
+
const i = s.getAttribLocation(t, r);
|
|
551
|
+
i !== -1 && e.set(r, i);
|
|
552
|
+
}
|
|
553
|
+
this.ae.set(t, e);
|
|
554
|
+
}
|
|
555
|
+
return e;
|
|
372
556
|
}
|
|
373
|
-
|
|
374
|
-
this.
|
|
557
|
+
Lt(t) {
|
|
558
|
+
if (!this.re || this.ee.length === 0) return;
|
|
559
|
+
const e = this.R, s = t.rt;
|
|
560
|
+
if (!s) return void console.warn("InstanceBatch: Cannot bind attributes - invalid shader program");
|
|
561
|
+
this.ue();
|
|
562
|
+
const r = this.fe(s);
|
|
563
|
+
e.bindBuffer(e.ARRAY_BUFFER, this.re);
|
|
564
|
+
for (const [i, n] of r) {
|
|
565
|
+
const o = M.ATTRIBUTES[i];
|
|
566
|
+
o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
|
|
567
|
+
}
|
|
375
568
|
}
|
|
376
|
-
|
|
377
|
-
|
|
569
|
+
Wt(t) {
|
|
570
|
+
const e = this.R, s = this.fe(t.rt);
|
|
571
|
+
for (const [, r] of s) e.disableVertexAttribArray(r), e.vertexAttribDivisor(r, 0);
|
|
378
572
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
573
|
+
Et(t, e) {
|
|
574
|
+
this.ee.length !== 0 && this.R.drawArraysInstanced(t, 0, e, this.ee.length);
|
|
575
|
+
}
|
|
576
|
+
U() {
|
|
577
|
+
const t = this.R;
|
|
578
|
+
this.re && (t.deleteBuffer(this.re), this.re = null), this.ee.length = 0, this.ae.clear(), this.he = null;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
class F {
|
|
582
|
+
constructor(t, e, s, r) {
|
|
583
|
+
c(this, "R");
|
|
584
|
+
c(this, "de");
|
|
585
|
+
c(this, "pe");
|
|
586
|
+
c(this, "ge");
|
|
587
|
+
c(this, "_e", null);
|
|
588
|
+
this.R = t, this.de = e, this.pe = s, this.ge = r;
|
|
589
|
+
const i = this.R.createBuffer();
|
|
590
|
+
if (!i) throw Error("Failed to create unit geometry buffer");
|
|
591
|
+
this.R.bindBuffer(this.R.ARRAY_BUFFER, i), this.R.bufferData(this.R.ARRAY_BUFFER, this.ge.vertices, this.R.STATIC_DRAW), this.R.bindBuffer(this.R.ARRAY_BUFFER, null), this._e = i;
|
|
592
|
+
}
|
|
593
|
+
get type() {
|
|
594
|
+
return this.pe;
|
|
595
|
+
}
|
|
596
|
+
get unitGeometry() {
|
|
597
|
+
return this.ge;
|
|
598
|
+
}
|
|
599
|
+
get unitBuffer() {
|
|
600
|
+
return this._e;
|
|
601
|
+
}
|
|
602
|
+
get batch() {
|
|
603
|
+
return this.de;
|
|
382
604
|
}
|
|
383
605
|
kt() {
|
|
384
|
-
this.
|
|
606
|
+
this.de.clear();
|
|
385
607
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
return e ? parseInt(e[1], 10) >= 300 : !1;
|
|
608
|
+
Bt() {
|
|
609
|
+
return !this.de.isEmpty;
|
|
389
610
|
}
|
|
390
|
-
|
|
391
|
-
|
|
611
|
+
U() {
|
|
612
|
+
this.de.U(), this._e && (this.R.deleteBuffer(this._e), this._e = null);
|
|
392
613
|
}
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
return new R(this.v, e, t);
|
|
614
|
+
me(t, e, s, r, i) {
|
|
615
|
+
const n = this.ve(t, e, s, r, i.rotation || 0);
|
|
616
|
+
return { position: [t, e], size: [s, r], character: i.character || [0, 0, 0], primaryColor: i.charColor || [1, 1, 1, 1], secondaryColor: i.bgColor || [0, 0, 0, 1], rotation: i.charRotation || [0, 0], transform: [i.invert ? 1 : 0, i.flipHorizontally ? 1 : 0, i.flipVertically ? 1 : 0], globalRotation: n.radians, rotationCenter: [n.centerX, n.centerY] };
|
|
397
617
|
}
|
|
398
|
-
|
|
399
|
-
this.
|
|
618
|
+
xe(t, e) {
|
|
619
|
+
const s = L(this.R) || [0, 0, this.R.canvas.width, this.R.canvas.height];
|
|
620
|
+
return { nx: t / s[2] * 2 - 1, ny: 1 - e / s[3] * 2 };
|
|
400
621
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
return this.Et("u_rotation", m), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p), this.ft.ot(t, e, r, s), void (this.ut = null);
|
|
405
|
-
}
|
|
406
|
-
const i = this.ct;
|
|
407
|
-
let o = 0, n = 0, l = 0, c = 1;
|
|
408
|
-
const u = this.At(t, e, r, s);
|
|
409
|
-
o = u.centerX, n = u.centerY, l = u.radians, c = u.aspectRatio, this._t && (this.yt(i), this.Et("u_color", this.gt), this.Et("u_rotation", l), this.Et("u_center", [o, n]), this.Et("u_aspectRatio", c), this.ft.ot(t, e, r, s)), this.bt && this.xt > 0 && (this.yt(i), this.Et("u_color", this.vt), this.Et("u_rotation", l), this.Et("u_center", [o, n]), this.Et("u_aspectRatio", c), this.ft.nt(t, e, r, s, this.xt)), this.ut = null;
|
|
410
|
-
}
|
|
411
|
-
Ut(t, e, r, s) {
|
|
412
|
-
if (this.ut !== null) {
|
|
413
|
-
const g = (t + r) / 2, C = (e + s) / 2, v = Math.abs(r - t) || 1, b = Math.abs(s - e) || 1, { centerX: T, centerY: E, radians: M, aspectRatio: F } = this.At(g - v / 2, C - b / 2, v, b);
|
|
414
|
-
this.Et("u_rotation", M), this.Et("u_center", [T, E]), this.Et("u_aspectRatio", F);
|
|
415
|
-
const A = this.xt > 0 ? this.xt : 1;
|
|
416
|
-
return this.dt.ht(t, e, r, s, A), void (this.ut = null);
|
|
417
|
-
}
|
|
418
|
-
if (!this.bt || this.xt <= 0) return;
|
|
419
|
-
const i = this.ct, o = (t + r) / 2, n = (e + s) / 2, l = Math.abs(r - t) || 1, c = Math.abs(s - e) || 1, u = this.wt !== 0;
|
|
420
|
-
let f = 0, d = 0, m = 0, p = 1;
|
|
421
|
-
if (u) {
|
|
422
|
-
const g = this.At(o - l / 2, n - c / 2, l, c);
|
|
423
|
-
f = g.centerX, d = g.centerY, m = g.radians, p = g.aspectRatio;
|
|
424
|
-
}
|
|
425
|
-
this.yt(i), this.Et("u_color", this.vt), u && (this.Et("u_rotation", m), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p)), this.dt.ht(t, e, r, s, this.xt);
|
|
622
|
+
Ce(t, e, s) {
|
|
623
|
+
const r = this.xe(e, s);
|
|
624
|
+
t.rotationCenter = [r.nx, r.ny];
|
|
426
625
|
}
|
|
427
|
-
|
|
428
|
-
const
|
|
429
|
-
return { centerX: (t +
|
|
626
|
+
ve(t, e, s, r, i) {
|
|
627
|
+
const n = L(this.R) || [0, 0, this.R.canvas.width, this.R.canvas.height], o = n[2], h = n[3];
|
|
628
|
+
return { centerX: (t + s / 2) / o * 2 - 1, centerY: 1 - (e + r / 2) / h * 2, radians: -i * Math.PI / 180, aspectRatio: o / h };
|
|
430
629
|
}
|
|
431
|
-
|
|
432
|
-
|
|
630
|
+
}
|
|
631
|
+
const it = { vertices: 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]), vertexCount: 6, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
632
|
+
class nt extends F {
|
|
633
|
+
constructor(t, e) {
|
|
634
|
+
super(t, e, R.RECTANGLE, it);
|
|
433
635
|
}
|
|
434
|
-
|
|
435
|
-
this.
|
|
636
|
+
Vt(t, e) {
|
|
637
|
+
const s = this.me(t.x, t.y, t.width, t.height, e);
|
|
638
|
+
return this.de.Vt(s);
|
|
436
639
|
}
|
|
437
|
-
|
|
438
|
-
|
|
640
|
+
}
|
|
641
|
+
const ot = { vertices: 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]), vertexCount: 6, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
642
|
+
class at extends F {
|
|
643
|
+
constructor(t, e) {
|
|
644
|
+
super(t, e, R.LINE, ot);
|
|
645
|
+
}
|
|
646
|
+
Vt(t, e) {
|
|
647
|
+
const s = t.x2 - t.x1, r = t.y2 - t.y1, i = Math.hypot(s, r), n = Math.atan2(r, s), o = t.thickness || e.lineWeight || 1, h = t.x1 + s / 2, l = t.y1 + r / 2, u = h - i / 2, f = l, d = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotation: (e.rotation || 0) + 180 * n / Math.PI, lineWeight: o }, p = this.me(u, f, i, o, d);
|
|
648
|
+
return this.Ce(p, h, l), this.de.Vt(p);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
const ht = { vertices: function(a = 32) {
|
|
652
|
+
const t = [], e = 2 * Math.PI / a;
|
|
653
|
+
for (let s = 0; s < a; s++) {
|
|
654
|
+
const r = s * e, i = (s + 1) % a * e, n = Math.cos(r), o = Math.sin(r), h = 0.5 * (n + 1), l = 0.5 * (o + 1), u = Math.cos(i), f = Math.sin(i), d = 0.5 * (u + 1), p = 0.5 * (f + 1);
|
|
655
|
+
t.push(0, 0, 0.5, 0.5, n, o, h, l, u, f, d, p);
|
|
656
|
+
}
|
|
657
|
+
return new Float32Array(t);
|
|
658
|
+
}(32), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
659
|
+
class ct extends F {
|
|
660
|
+
constructor(t, e) {
|
|
661
|
+
super(t, e, R.ELLIPSE, ht);
|
|
662
|
+
}
|
|
663
|
+
Vt(t, e) {
|
|
664
|
+
const s = this.me(t.x, t.y, t.width, t.height, e);
|
|
665
|
+
return this.Ce(s, t.x, t.y), this.de.Vt(s);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
let lt = { vertices: function(a) {
|
|
669
|
+
const t = [];
|
|
670
|
+
for (let e = 0; e < a; e++) {
|
|
671
|
+
const s = e / a, r = (e + 1) / a;
|
|
672
|
+
t.push(s, 0, s, 0, s, 1, s, 1, r, 1, r, 1);
|
|
673
|
+
}
|
|
674
|
+
return new Float32Array(t);
|
|
675
|
+
}(32), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
676
|
+
class ut extends F {
|
|
677
|
+
constructor(t, e) {
|
|
678
|
+
super(t, e, R.ARC, lt);
|
|
439
679
|
}
|
|
440
|
-
|
|
441
|
-
|
|
680
|
+
Vt(t, e) {
|
|
681
|
+
const s = t.x - t.width / 2, r = t.y - t.height / 2, i = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.me(s, r, t.width, t.height, e);
|
|
682
|
+
return this.Ce(o, t.x, t.y), o.arcAngles = [i, n], this.de.Vt(o);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
const ft = { vertices: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), vertexCount: 3, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
686
|
+
class dt extends F {
|
|
687
|
+
constructor(t, e) {
|
|
688
|
+
super(t, e, R.TRIANGLE, ft);
|
|
689
|
+
}
|
|
690
|
+
Vt(t, e) {
|
|
691
|
+
const s = Math.min(t.x1, t.x2, t.x3), r = Math.max(t.x1, t.x2, t.x3), i = Math.min(t.y1, t.y2, t.y3), n = r - s, o = Math.max(t.y1, t.y2, t.y3) - i, h = this.me(s, i, n, o, e), l = s + 0.5 * n, u = i + o * (1 / 3);
|
|
692
|
+
return this.Ce(h, l, u), this.de.Vt(h);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function W(a, t, e, s, r) {
|
|
696
|
+
const i = 1 - a, n = i * i, o = a * a;
|
|
697
|
+
return n * i * t + 3 * n * a * e + 3 * i * o * s + o * a * r;
|
|
698
|
+
}
|
|
699
|
+
const gt = { vertices: function(a = 16) {
|
|
700
|
+
const t = [];
|
|
701
|
+
for (let e = 0; e < a; e++) {
|
|
702
|
+
const s = e / a, r = (e + 1) / a;
|
|
703
|
+
t.push(s, -0.5, s, 0), t.push(r, -0.5, r, 0), t.push(s, 0.5, s, 1), t.push(s, 0.5, s, 1), t.push(r, -0.5, r, 0), t.push(r, 0.5, r, 1);
|
|
704
|
+
}
|
|
705
|
+
return new Float32Array(t);
|
|
706
|
+
}(16), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
|
|
707
|
+
class pt extends F {
|
|
708
|
+
constructor(t, e) {
|
|
709
|
+
super(t, e, R.BEZIER_CURVE, gt);
|
|
710
|
+
}
|
|
711
|
+
Vt(t, e) {
|
|
712
|
+
const s = e.lineWeight || 1, r = W(0.5, t.x1, t.cp1x, t.cp2x, t.x2), i = W(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, rotation: e.rotation || 0, lineWeight: s }, o = this.me(0, 0, 1, s, n);
|
|
713
|
+
return this.Ce(o, r, i), 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.de.Vt(o);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
class mt {
|
|
717
|
+
constructor(t) {
|
|
718
|
+
c(this, "R");
|
|
719
|
+
c(this, "ye", null);
|
|
720
|
+
c(this, "we", null);
|
|
721
|
+
c(this, "$e", null);
|
|
722
|
+
c(this, "be", /* @__PURE__ */ new Map());
|
|
723
|
+
c(this, "Te");
|
|
724
|
+
c(this, "ze");
|
|
725
|
+
c(this, "Re");
|
|
726
|
+
this.R = t, this.Re = new Q(), this.Te = new et(t), this.ze = new st(), this.we = t.createBuffer(), t.bindBuffer(t.ARRAY_BUFFER, this.we), t.bufferData(t.ARRAY_BUFFER, new Float32Array([-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, -1, 1, 0, 1, 1, 1, 1, -1, 1, 0, 1]), t.STATIC_DRAW), this.$e = t.createBuffer(), this.R.enable(this.R.BLEND), this.R.blendEquation(this.R.FUNC_ADD), this.R.blendFunc(this.R.ONE, this.R.ONE_MINUS_SRC_ALPHA), D(this.R, [0, 0, this.R.canvas.width, this.R.canvas.height]);
|
|
727
|
+
}
|
|
728
|
+
Me(t) {
|
|
729
|
+
let e = this.be.get(t);
|
|
730
|
+
if (e) return e;
|
|
731
|
+
const s = new rt(this.R);
|
|
732
|
+
return e = (0, { [R.RECTANGLE]: () => new nt(this.R, s), [R.LINE]: () => new at(this.R, s), [R.ELLIPSE]: () => new ct(this.R, s), [R.ARC]: () => new ut(this.R, s), [R.TRIANGLE]: () => new dt(this.R, s), [R.BEZIER_CURVE]: () => new pt(this.R, s) }[t])(), this.be.set(t, e), e;
|
|
733
|
+
}
|
|
734
|
+
Se(t) {
|
|
735
|
+
this.ye !== t && (this.ye = t, t.K());
|
|
736
|
+
}
|
|
737
|
+
Ae(t, e) {
|
|
738
|
+
return new K(this.R, t, e);
|
|
739
|
+
}
|
|
740
|
+
Pe(t, e, s, r) {
|
|
741
|
+
var m;
|
|
742
|
+
const i = this.R, n = i.canvas.width, o = i.canvas.height, h = t / n * 2 - 1, l = (t + s) / n * 2 - 1, u = 1 - e / o * 2, f = 1 - (e + r) / o * 2, d = new Float32Array([h, f, l, f, h, u, l, f, l, u, h, u]);
|
|
743
|
+
i.bindBuffer(i.ARRAY_BUFFER, this.$e), i.bufferData(i.ARRAY_BUFFER, d, i.DYNAMIC_DRAW);
|
|
744
|
+
const p = ((m = this.ye) == null ? void 0 : m.rt) || i.getParameter(i.CURRENT_PROGRAM), g = p ? i.getAttribLocation(p, "a_position") : -1;
|
|
745
|
+
g !== -1 && (i.enableVertexAttribArray(g), i.vertexAttribPointer(g, 2, i.FLOAT, !1, 8, 0)), i.drawArrays(i.TRIANGLES, 0, 6), g !== -1 && i.disableVertexAttribArray(g);
|
|
746
|
+
}
|
|
747
|
+
Fe(t, e, s, r) {
|
|
748
|
+
this.ze.qt(t, e, s, r, this.Re);
|
|
749
|
+
}
|
|
750
|
+
Ge(t, e, s, r) {
|
|
751
|
+
this.ze.Nt(t, e, s, r, this.Re.lineWeight, this.Re);
|
|
752
|
+
}
|
|
753
|
+
De(t, e, s, r) {
|
|
754
|
+
this.ze.Xt(t, e, s, r, this.Re);
|
|
755
|
+
}
|
|
756
|
+
Ie(t, e, s, r, i, n) {
|
|
757
|
+
this.ze.Qt(t, e, s, r, i, n, this.Re);
|
|
758
|
+
}
|
|
759
|
+
Be(t, e, s, r, i, n, o, h) {
|
|
760
|
+
const l = this.Re.lineWeight;
|
|
761
|
+
this.ze.Zt(t, e, s, r, i, n, o, h, l, this.Re);
|
|
762
|
+
}
|
|
763
|
+
Le(t, e, s = 1, r = {}) {
|
|
764
|
+
return new Y(this.R, t, e, s, r);
|
|
765
|
+
}
|
|
766
|
+
Ee(t, e, s, r, i, n) {
|
|
767
|
+
this.ze.Yt(t, e, s, r, i, n, this.Re);
|
|
768
|
+
}
|
|
769
|
+
We(t, e = t, s = t, r = 255) {
|
|
770
|
+
this.Jt(t / 255, e / 255, s / 255, r / 255);
|
|
771
|
+
}
|
|
772
|
+
Jt(t = 0, e = 0, s = 0, r = 0) {
|
|
773
|
+
this.R.clearColor(t, e, s, r), this.R.clear(this.R.COLOR_BUFFER_BIT);
|
|
774
|
+
}
|
|
775
|
+
ke() {
|
|
776
|
+
this.R.viewport(0, 0, this.R.canvas.width, this.R.canvas.height), D(this.R, [0, 0, this.R.canvas.width, this.R.canvas.height]);
|
|
442
777
|
}
|
|
443
778
|
get context() {
|
|
444
|
-
return this.
|
|
779
|
+
return this.R;
|
|
780
|
+
}
|
|
781
|
+
get state() {
|
|
782
|
+
return this.Re;
|
|
445
783
|
}
|
|
446
|
-
|
|
447
|
-
this.
|
|
784
|
+
Ve(t) {
|
|
785
|
+
const e = L(this.R) ?? this.R.getParameter(this.R.VIEWPORT), s = { shader: t, gl: this.R, viewport: e }, r = /* @__PURE__ */ new Set();
|
|
786
|
+
for (const i of this.ze) r.add(i.type);
|
|
787
|
+
for (const i of r) this.Me(i);
|
|
788
|
+
this.Te.It(s, this.ze, this.be), this.ze.Jt();
|
|
448
789
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
const c = this.At(e, r, n, l);
|
|
453
|
-
this.Et("u_rotation", c.radians), this.Et("u_center", [c.centerX, c.centerY]), this.Et("u_aspectRatio", c.aspectRatio), this.ft.ot(e, r, n, l), o.bindTexture(o.TEXTURE_2D, null), this.ut = null;
|
|
790
|
+
U() {
|
|
791
|
+
this.R.deleteBuffer(this.we), this.R.deleteBuffer(this.$e), this.ze.Jt();
|
|
792
|
+
for (const t of this.be.values()) t.U();
|
|
454
793
|
}
|
|
455
794
|
}
|
|
456
|
-
const
|
|
457
|
-
const
|
|
458
|
-
for (let
|
|
459
|
-
return
|
|
795
|
+
const y = { readShort: (a, t) => (y.t.uint16[0] = a[t] << 8 | a[t + 1], y.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
|
|
796
|
+
const s = [];
|
|
797
|
+
for (let r = 0; r < e; r++) s.push(y.readUshort(a, t + 2 * r));
|
|
798
|
+
return s;
|
|
460
799
|
}, readUint(a, t) {
|
|
461
|
-
const e =
|
|
462
|
-
return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3],
|
|
800
|
+
const e = y.t.uint8;
|
|
801
|
+
return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], y.t.uint32[0];
|
|
463
802
|
}, readASCII(a, t, e) {
|
|
464
|
-
let
|
|
465
|
-
for (let
|
|
466
|
-
return
|
|
803
|
+
let s = "";
|
|
804
|
+
for (let r = 0; r < e; r++) s += String.fromCharCode(a[t + r]);
|
|
805
|
+
return s;
|
|
467
806
|
}, t: (() => {
|
|
468
807
|
const a = new ArrayBuffer(8);
|
|
469
808
|
return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
|
|
470
|
-
})() },
|
|
471
|
-
const
|
|
809
|
+
})() }, Rt = { parseTab(a, t, e) {
|
|
810
|
+
const s = { tables: [], ids: {}, off: t };
|
|
472
811
|
a = new Uint8Array(a.buffer, t, e), t = 0;
|
|
473
|
-
const
|
|
812
|
+
const r = y, i = r.readUshort, n = i(a, t += 2);
|
|
474
813
|
t += 2;
|
|
475
|
-
const
|
|
476
|
-
for (let
|
|
477
|
-
const
|
|
814
|
+
const o = [];
|
|
815
|
+
for (let h = 0; h < n; h++) {
|
|
816
|
+
const l = i(a, t), u = i(a, t += 2);
|
|
478
817
|
t += 2;
|
|
479
|
-
const f =
|
|
818
|
+
const f = r.readUint(a, t);
|
|
480
819
|
t += 4;
|
|
481
|
-
const d = `p${
|
|
482
|
-
let
|
|
483
|
-
if (
|
|
484
|
-
let
|
|
485
|
-
|
|
486
|
-
const
|
|
487
|
-
|
|
820
|
+
const d = `p${l}e${u}`;
|
|
821
|
+
let p = o.indexOf(f);
|
|
822
|
+
if (p === -1) {
|
|
823
|
+
let g;
|
|
824
|
+
p = s.tables.length, o.push(f);
|
|
825
|
+
const m = i(a, f);
|
|
826
|
+
g = m === 4 ? this.parse4(a, f) : m === 12 ? this.parse12(a, f) : { format: m }, s.tables.push(g);
|
|
488
827
|
}
|
|
489
|
-
|
|
828
|
+
s.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), s.ids[d] = p;
|
|
490
829
|
}
|
|
491
|
-
return
|
|
830
|
+
return s;
|
|
492
831
|
}, parse4(a, t) {
|
|
493
|
-
const e =
|
|
832
|
+
const e = y, s = e.readUshort, r = e.readUshorts, i = t, n = s(a, t += 2);
|
|
494
833
|
t += 2;
|
|
495
|
-
const
|
|
496
|
-
t += 2,
|
|
497
|
-
for (let
|
|
498
|
-
return
|
|
834
|
+
const o = s(a, t += 2) >>> 1, h = { format: 4, searchRange: s(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
|
|
835
|
+
t += 2, h.entrySelector = s(a, t), t += 2, h.rangeShift = s(a, t), t += 2, h.endCount = r(a, t, o), t += 2 * o, t += 2, h.startCount = r(a, t, o), t += 2 * o;
|
|
836
|
+
for (let l = 0; l < o; l++) h.idDelta.push(e.readShort(a, t)), t += 2;
|
|
837
|
+
return h.idRangeOffset = r(a, t, o), t += 2 * o, h.glyphIdArray = r(a, t, i + n - t >> 1), h;
|
|
499
838
|
}, parse12(a, t) {
|
|
500
|
-
const e =
|
|
839
|
+
const e = y.readUint;
|
|
501
840
|
e(a, t += 4), e(a, t += 4);
|
|
502
|
-
const
|
|
841
|
+
const s = e(a, t += 4);
|
|
503
842
|
t += 4;
|
|
504
|
-
const
|
|
505
|
-
for (let i = 0; i < 3 *
|
|
506
|
-
return { format: 12, groups:
|
|
507
|
-
} },
|
|
508
|
-
const
|
|
843
|
+
const r = new Uint32Array(3 * s);
|
|
844
|
+
for (let i = 0; i < 3 * s; i += 3) r[i] = e(a, t + (i << 2)), r[i + 1] = e(a, t + (i << 2) + 4), r[i + 2] = e(a, t + (i << 2) + 8);
|
|
845
|
+
return { format: 12, groups: r };
|
|
846
|
+
} }, xt = { parseTab(a, t, e) {
|
|
847
|
+
const s = y;
|
|
509
848
|
t += 18;
|
|
510
|
-
const
|
|
849
|
+
const r = s.readUshort(a, t);
|
|
511
850
|
t += 2, t += 16;
|
|
512
|
-
const i =
|
|
851
|
+
const i = s.readShort(a, t);
|
|
513
852
|
t += 2;
|
|
514
|
-
const
|
|
853
|
+
const n = s.readShort(a, t);
|
|
515
854
|
t += 2;
|
|
516
|
-
const
|
|
855
|
+
const o = s.readShort(a, t);
|
|
517
856
|
t += 2;
|
|
518
|
-
const
|
|
519
|
-
return t += 2, t += 6, { unitsPerEm:
|
|
520
|
-
} },
|
|
521
|
-
const
|
|
857
|
+
const h = s.readShort(a, t);
|
|
858
|
+
return t += 2, t += 6, { unitsPerEm: r, xMin: i, yMin: n, xMax: o, yMax: h, indexToLocFormat: s.readShort(a, t) };
|
|
859
|
+
} }, Ct = { parseTab(a, t, e) {
|
|
860
|
+
const s = y;
|
|
522
861
|
t += 4;
|
|
523
|
-
const
|
|
524
|
-
for (let
|
|
525
|
-
const
|
|
526
|
-
i[
|
|
862
|
+
const r = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], i = {};
|
|
863
|
+
for (let n = 0; n < r.length; n++) {
|
|
864
|
+
const o = r[n], h = o === "advanceWidthMax" || o === "numberOfHMetrics" ? s.readUshort : s.readShort;
|
|
865
|
+
i[o] = h(a, t + 2 * n);
|
|
527
866
|
}
|
|
528
867
|
return i;
|
|
529
|
-
} },
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
for (; f <
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
if (
|
|
541
|
-
|
|
542
|
-
if (o === 0) for (let l = 0; l < n; l++) i.push(s.readUshort(a, t + (l << 1)) << 1);
|
|
543
|
-
else if (o === 1) for (let l = 0; l < n; l++) i.push(s.readUint(a, t + (l << 2)));
|
|
868
|
+
} }, yt = { parseTab(a, t, e, s) {
|
|
869
|
+
const r = y, i = [], n = [], o = s.maxp.numGlyphs, h = s.hhea.numberOfHMetrics;
|
|
870
|
+
let l = 0, u = 0, f = 0;
|
|
871
|
+
for (; f < h; ) l = r.readUshort(a, t + (f << 2)), u = r.readShort(a, t + (f << 2) + 2), i.push(l), n.push(u), f++;
|
|
872
|
+
for (; f < o; ) i.push(l), n.push(u), f++;
|
|
873
|
+
return { aWidth: i, lsBearing: n };
|
|
874
|
+
} }, G = { cmap: Rt, head: xt, hhea: Ct, maxp: { parseTab(a, t, e) {
|
|
875
|
+
const s = y;
|
|
876
|
+
return s.readUint(a, t), t += 4, { numGlyphs: s.readUshort(a, t) };
|
|
877
|
+
} }, hmtx: yt, loca: { parseTab(a, t, e, s) {
|
|
878
|
+
const r = y, i = [], n = s.head.indexToLocFormat, o = s.maxp.numGlyphs + 1;
|
|
879
|
+
if (n === 0) for (let h = 0; h < o; h++) i.push(r.readUshort(a, t + (h << 1)) << 1);
|
|
880
|
+
else if (n === 1) for (let h = 0; h < o; h++) i.push(r.readUint(a, t + (h << 2)));
|
|
544
881
|
return i;
|
|
545
|
-
} }, glyf: { parseTab(a, t, e,
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
const i = y.findTable(r, "glyf", a.Xt);
|
|
882
|
+
} }, glyf: { parseTab(a, t, e, s) {
|
|
883
|
+
const r = [], i = s.maxp.numGlyphs;
|
|
884
|
+
for (let n = 0; n < i; n++) r.push(null);
|
|
885
|
+
return r;
|
|
886
|
+
}, Oe(a, t) {
|
|
887
|
+
const e = y, s = a.Ue, r = a.loca;
|
|
888
|
+
if (r[t] === r[t + 1]) return null;
|
|
889
|
+
const i = E.findTable(s, "glyf", a.je);
|
|
554
890
|
if (!i) return null;
|
|
555
|
-
let
|
|
556
|
-
const
|
|
557
|
-
if (
|
|
558
|
-
if (
|
|
559
|
-
|
|
560
|
-
for (let d = 0; d <
|
|
561
|
-
const
|
|
562
|
-
if (
|
|
563
|
-
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
for (let d = 0; d <
|
|
567
|
-
const
|
|
568
|
-
if (
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
for (let
|
|
891
|
+
let n = i[0] + r[t];
|
|
892
|
+
const o = {};
|
|
893
|
+
if (o.noc = e.readShort(s, n), n += 2, o.xMin = e.readShort(s, n), n += 2, o.yMin = e.readShort(s, n), n += 2, o.xMax = e.readShort(s, n), n += 2, o.yMax = e.readShort(s, n), n += 2, o.xMin >= o.xMax || o.yMin >= o.yMax) return null;
|
|
894
|
+
if (o.noc > 0) {
|
|
895
|
+
o.endPts = [];
|
|
896
|
+
for (let d = 0; d < o.noc; d++) o.endPts.push(e.readUshort(s, n)), n += 2;
|
|
897
|
+
const h = e.readUshort(s, n);
|
|
898
|
+
if (n += 2, s.length - n < h) return null;
|
|
899
|
+
n += h;
|
|
900
|
+
const l = o.endPts[o.noc - 1] + 1;
|
|
901
|
+
o.flags = [];
|
|
902
|
+
for (let d = 0; d < l; d++) {
|
|
903
|
+
const p = s[n];
|
|
904
|
+
if (n++, o.flags.push(p), 8 & p) {
|
|
905
|
+
const g = s[n];
|
|
906
|
+
n++;
|
|
907
|
+
for (let m = 0; m < g; m++) o.flags.push(p), d++;
|
|
572
908
|
}
|
|
573
909
|
}
|
|
574
|
-
|
|
575
|
-
for (let d = 0; d <
|
|
576
|
-
const
|
|
577
|
-
2 &
|
|
910
|
+
o.xs = [];
|
|
911
|
+
for (let d = 0; d < l; d++) {
|
|
912
|
+
const p = o.flags[d], g = !!(16 & p);
|
|
913
|
+
2 & p ? (o.xs.push(g ? s[n] : -s[n]), n++) : g ? o.xs.push(0) : (o.xs.push(e.readShort(s, n)), n += 2);
|
|
578
914
|
}
|
|
579
|
-
|
|
580
|
-
for (let d = 0; d <
|
|
581
|
-
const
|
|
582
|
-
4 &
|
|
915
|
+
o.ys = [];
|
|
916
|
+
for (let d = 0; d < l; d++) {
|
|
917
|
+
const p = o.flags[d], g = !!(32 & p);
|
|
918
|
+
4 & p ? (o.ys.push(g ? s[n] : -s[n]), n++) : g ? o.ys.push(0) : (o.ys.push(e.readShort(s, n)), n += 2);
|
|
583
919
|
}
|
|
584
920
|
let u = 0, f = 0;
|
|
585
|
-
for (let d = 0; d <
|
|
586
|
-
} else
|
|
587
|
-
return
|
|
588
|
-
} } },
|
|
589
|
-
const i =
|
|
590
|
-
for (const
|
|
591
|
-
const
|
|
592
|
-
if (
|
|
593
|
-
const [u, f] =
|
|
594
|
-
let d =
|
|
595
|
-
d == null && (d = i[
|
|
921
|
+
for (let d = 0; d < l; d++) u += o.xs[d], f += o.ys[d], o.xs[d] = u, o.ys[d] = f;
|
|
922
|
+
} else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
|
|
923
|
+
return o;
|
|
924
|
+
} } }, E = { parse: (a) => [((t, e, s, r) => {
|
|
925
|
+
const i = G, n = { Ue: t, He: e, je: s };
|
|
926
|
+
for (const o in i) {
|
|
927
|
+
const h = o, l = E.findTable(t, h, s);
|
|
928
|
+
if (l) {
|
|
929
|
+
const [u, f] = l;
|
|
930
|
+
let d = r[u];
|
|
931
|
+
d == null && (d = i[h].parseTab(t, u, f, n), r[u] = d), n[h] = d;
|
|
596
932
|
}
|
|
597
933
|
}
|
|
598
|
-
return
|
|
934
|
+
return n;
|
|
599
935
|
})(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
|
|
600
|
-
const
|
|
936
|
+
const s = y, r = s.readUshort(a, e + 4);
|
|
601
937
|
let i = e + 12;
|
|
602
|
-
for (let
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
const
|
|
606
|
-
if (
|
|
938
|
+
for (let n = 0; n < r; n++) {
|
|
939
|
+
const o = s.readASCII(a, i, 4);
|
|
940
|
+
s.readUint(a, i + 4);
|
|
941
|
+
const h = s.readUint(a, i + 8), l = s.readUint(a, i + 12);
|
|
942
|
+
if (o === t) return [h, l];
|
|
607
943
|
i += 16;
|
|
608
944
|
}
|
|
609
945
|
return null;
|
|
610
|
-
}, T:
|
|
611
|
-
class
|
|
946
|
+
}, T: G, B: y };
|
|
947
|
+
class U {
|
|
612
948
|
constructor() {
|
|
613
|
-
|
|
614
|
-
|
|
949
|
+
c(this, "qe", /* @__PURE__ */ new Map());
|
|
950
|
+
c(this, "Ne", /* @__PURE__ */ new Map());
|
|
615
951
|
}
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
if (this.
|
|
619
|
-
const
|
|
620
|
-
if (!
|
|
952
|
+
Xe(t, e) {
|
|
953
|
+
const s = `${this.Ye(t)}_${e}`;
|
|
954
|
+
if (this.qe.has(s)) return this.qe.get(s);
|
|
955
|
+
const r = t.cmap;
|
|
956
|
+
if (!r || !r.tables) return this.qe.set(s, 0), 0;
|
|
621
957
|
let i = 0;
|
|
622
|
-
for (const
|
|
623
|
-
return this.
|
|
958
|
+
for (const n of r.tables) if (n.format === 4 ? i = this.Qe(e, n) : n.format === 12 && (i = this.Ze(e, n)), i > 0) break;
|
|
959
|
+
return this.qe.set(s, i), i;
|
|
624
960
|
}
|
|
625
|
-
|
|
626
|
-
const
|
|
627
|
-
return
|
|
961
|
+
Je(t, e) {
|
|
962
|
+
const s = e.codePointAt(0);
|
|
963
|
+
return s === void 0 ? 0 : this.Xe(t, s);
|
|
628
964
|
}
|
|
629
|
-
|
|
630
|
-
const
|
|
631
|
-
return
|
|
965
|
+
Ke(t, e) {
|
|
966
|
+
const s = t.hmtx;
|
|
967
|
+
return s && s.aWidth && s.aWidth.length !== 0 ? e < s.aWidth.length ? s.aWidth[e] : s.aWidth[s.aWidth.length - 1] : 0;
|
|
632
968
|
}
|
|
633
|
-
|
|
634
|
-
const
|
|
635
|
-
return { ascender:
|
|
969
|
+
ts(t, e) {
|
|
970
|
+
const s = e / t.head.unitsPerEm, r = t.hhea.ascender * s, i = t.hhea.descender * s, n = t.hhea.lineGap * s;
|
|
971
|
+
return { ascender: r, descender: i, lineGap: n, lineHeight: r - i + n, unitsPerEm: t.head.unitsPerEm, scale: s };
|
|
636
972
|
}
|
|
637
|
-
|
|
638
|
-
this.
|
|
973
|
+
es() {
|
|
974
|
+
this.qe.clear(), this.Ne.clear();
|
|
639
975
|
}
|
|
640
|
-
|
|
641
|
-
return `${t.
|
|
976
|
+
Ye(t) {
|
|
977
|
+
return `${t.je}_${t.Ue.length}`;
|
|
642
978
|
}
|
|
643
|
-
|
|
644
|
-
const
|
|
645
|
-
let
|
|
646
|
-
for (let i = 0; i <
|
|
647
|
-
|
|
979
|
+
Qe(t, e) {
|
|
980
|
+
const s = e.endCount.length;
|
|
981
|
+
let r = -1;
|
|
982
|
+
for (let i = 0; i < s; i++) if (t <= e.endCount[i]) {
|
|
983
|
+
r = i;
|
|
648
984
|
break;
|
|
649
985
|
}
|
|
650
|
-
if (
|
|
651
|
-
if (e.idRangeOffset[
|
|
986
|
+
if (r === -1 || t < e.startCount[r]) return 0;
|
|
987
|
+
if (e.idRangeOffset[r] === 0) return t + e.idDelta[r] & 65535;
|
|
652
988
|
{
|
|
653
|
-
const i = e.idRangeOffset[
|
|
989
|
+
const i = e.idRangeOffset[r] / 2 + (t - e.startCount[r]) - (s - r);
|
|
654
990
|
if (i >= 0 && i < e.glyphIdArray.length) {
|
|
655
|
-
const
|
|
656
|
-
return
|
|
991
|
+
const n = e.glyphIdArray[i];
|
|
992
|
+
return n === 0 ? 0 : n + e.idDelta[r] & 65535;
|
|
657
993
|
}
|
|
658
994
|
}
|
|
659
995
|
return 0;
|
|
660
996
|
}
|
|
661
|
-
|
|
662
|
-
const
|
|
663
|
-
for (let
|
|
664
|
-
const i = e.groups[3 *
|
|
665
|
-
if (t >= i && t <=
|
|
997
|
+
Ze(t, e) {
|
|
998
|
+
const s = e.groups.length / 3;
|
|
999
|
+
for (let r = 0; r < s; r++) {
|
|
1000
|
+
const i = e.groups[3 * r], n = e.groups[3 * r + 1], o = e.groups[3 * r + 2];
|
|
1001
|
+
if (t >= i && t <= n) return o + (t - i);
|
|
666
1002
|
}
|
|
667
1003
|
return 0;
|
|
668
1004
|
}
|
|
669
1005
|
}
|
|
670
|
-
class
|
|
1006
|
+
class vt {
|
|
671
1007
|
constructor(t) {
|
|
672
|
-
|
|
673
|
-
this.
|
|
1008
|
+
c(this, "ss");
|
|
1009
|
+
this.ss = t;
|
|
674
1010
|
}
|
|
675
|
-
|
|
676
|
-
var
|
|
1011
|
+
rs(t) {
|
|
1012
|
+
var s;
|
|
677
1013
|
const e = [];
|
|
678
|
-
return (
|
|
679
|
-
if (
|
|
680
|
-
const i = this.
|
|
1014
|
+
return (s = t.cmap) != null && s.tables ? (t.cmap.tables.forEach((r) => {
|
|
1015
|
+
if (r.format === 4) {
|
|
1016
|
+
const i = this.ns(r);
|
|
681
1017
|
e.push(...i);
|
|
682
|
-
} else if (
|
|
683
|
-
const i = this.
|
|
1018
|
+
} else if (r.format === 12) {
|
|
1019
|
+
const i = this.hs(r);
|
|
684
1020
|
e.push(...i);
|
|
685
1021
|
}
|
|
686
1022
|
}), [...new Set(e)]) : [];
|
|
687
1023
|
}
|
|
688
|
-
|
|
689
|
-
return this.
|
|
1024
|
+
cs(t, e) {
|
|
1025
|
+
return this.ss.Je(t, e) > 0;
|
|
690
1026
|
}
|
|
691
|
-
|
|
692
|
-
for (const
|
|
1027
|
+
ls(t, e) {
|
|
1028
|
+
for (const s of e) if (!this.cs(t, s)) return !1;
|
|
693
1029
|
return !0;
|
|
694
1030
|
}
|
|
695
|
-
|
|
696
|
-
return e.filter((
|
|
1031
|
+
us(t, e) {
|
|
1032
|
+
return e.filter((s) => this.cs(t, s));
|
|
697
1033
|
}
|
|
698
|
-
|
|
699
|
-
return t.filter((e) => this.
|
|
1034
|
+
fs(t) {
|
|
1035
|
+
return t.filter((e) => this.ds(e));
|
|
700
1036
|
}
|
|
701
|
-
|
|
1037
|
+
ns(t) {
|
|
702
1038
|
const e = [];
|
|
703
1039
|
if (!(t.startCount && t.endCount && t.idRangeOffset && t.idDelta)) return e;
|
|
704
|
-
for (let
|
|
705
|
-
const
|
|
706
|
-
if (
|
|
707
|
-
for (let
|
|
708
|
-
if (this.
|
|
709
|
-
const
|
|
710
|
-
e.push(
|
|
1040
|
+
for (let s = 0; s < t.startCount.length; s++) {
|
|
1041
|
+
const r = t.startCount[s], i = t.endCount[s];
|
|
1042
|
+
if (r !== 65535 || i !== 65535) {
|
|
1043
|
+
for (let n = r; n <= i; n++)
|
|
1044
|
+
if (this.ps(t, n, s) > 0) try {
|
|
1045
|
+
const o = String.fromCodePoint(n);
|
|
1046
|
+
e.push(o);
|
|
711
1047
|
} catch {
|
|
712
1048
|
}
|
|
713
1049
|
}
|
|
714
1050
|
}
|
|
715
1051
|
return e;
|
|
716
1052
|
}
|
|
717
|
-
|
|
1053
|
+
hs(t) {
|
|
718
1054
|
const e = [];
|
|
719
1055
|
if (!t.groups) return e;
|
|
720
|
-
for (let
|
|
721
|
-
const
|
|
722
|
-
for (let
|
|
723
|
-
if (
|
|
724
|
-
const
|
|
725
|
-
e.push(
|
|
1056
|
+
for (let s = 0; s < t.groups.length; s += 3) {
|
|
1057
|
+
const r = t.groups[s], i = t.groups[s + 1], n = t.groups[s + 2];
|
|
1058
|
+
for (let o = r; o <= i; o++)
|
|
1059
|
+
if (n + (o - r) > 0) try {
|
|
1060
|
+
const h = String.fromCodePoint(o);
|
|
1061
|
+
e.push(h);
|
|
726
1062
|
} catch {
|
|
727
1063
|
}
|
|
728
1064
|
}
|
|
729
1065
|
return e;
|
|
730
1066
|
}
|
|
731
|
-
|
|
732
|
-
if (t.idRangeOffset[
|
|
1067
|
+
ps(t, e, s) {
|
|
1068
|
+
if (t.idRangeOffset[s] === 0) return e + t.idDelta[s] & 65535;
|
|
733
1069
|
{
|
|
734
|
-
const
|
|
735
|
-
if (
|
|
736
|
-
const i = t.glyphIdArray[
|
|
737
|
-
if (i !== 0) return i + t.idDelta[
|
|
1070
|
+
const r = t.idRangeOffset[s] / 2 + (e - t.startCount[s]) - (t.startCount.length - s);
|
|
1071
|
+
if (r >= 0 && t.glyphIdArray && r < t.glyphIdArray.length) {
|
|
1072
|
+
const i = t.glyphIdArray[r];
|
|
1073
|
+
if (i !== 0) return i + t.idDelta[s] & 65535;
|
|
738
1074
|
}
|
|
739
1075
|
}
|
|
740
1076
|
return 0;
|
|
741
1077
|
}
|
|
742
|
-
|
|
1078
|
+
ds(t) {
|
|
743
1079
|
const e = t.codePointAt(0) || 0;
|
|
744
1080
|
return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
|
|
745
1081
|
}
|
|
746
1082
|
}
|
|
747
|
-
class
|
|
1083
|
+
class Tt {
|
|
748
1084
|
constructor() {
|
|
749
|
-
|
|
750
|
-
const t = new
|
|
751
|
-
this.
|
|
1085
|
+
c(this, "gs");
|
|
1086
|
+
const t = new U();
|
|
1087
|
+
this.gs = new vt(t);
|
|
752
1088
|
}
|
|
753
1089
|
extractCharacters(t) {
|
|
754
|
-
return this.
|
|
1090
|
+
return this.gs.rs(t);
|
|
755
1091
|
}
|
|
756
1092
|
filterProblematicCharacters(t) {
|
|
757
|
-
return this.
|
|
1093
|
+
return this.gs.fs(t);
|
|
758
1094
|
}
|
|
759
1095
|
characterExists(t, e) {
|
|
760
|
-
return this.
|
|
1096
|
+
return this.gs.cs(t, e);
|
|
761
1097
|
}
|
|
762
1098
|
allCharactersExist(t, e) {
|
|
763
|
-
return this.
|
|
1099
|
+
return this.gs.ls(t, e);
|
|
764
1100
|
}
|
|
765
1101
|
}
|
|
766
|
-
class
|
|
1102
|
+
class bt {
|
|
767
1103
|
constructor(t) {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
this.
|
|
773
|
-
}
|
|
774
|
-
createTextureAtlas(t, e,
|
|
775
|
-
const i = t.length,
|
|
776
|
-
this
|
|
777
|
-
const f = this.
|
|
778
|
-
return f.
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
this.
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
for (let
|
|
786
|
-
const
|
|
1104
|
+
c(this, "_s");
|
|
1105
|
+
c(this, "vs");
|
|
1106
|
+
c(this, "Cs");
|
|
1107
|
+
c(this, "ws");
|
|
1108
|
+
this.Cs = t, this.ws = new U(), this._s = document.createElement("canvas"), this.vs = this._s.getContext("2d", { willReadFrequently: !0, alpha: !1 });
|
|
1109
|
+
}
|
|
1110
|
+
createTextureAtlas(t, e, s, r) {
|
|
1111
|
+
const i = t.length, n = Math.ceil(Math.sqrt(i)), o = Math.ceil(i / n), h = e.width * n, l = e.height * o, u = typeof r == "object" ? r : null;
|
|
1112
|
+
this.$s(h, l), this.bs(t, e, n, s, u);
|
|
1113
|
+
const f = this.Cs.Le(h, l, 1, { filter: "nearest" });
|
|
1114
|
+
return f.I(this._s), { framebuffer: f, columns: n, rows: o };
|
|
1115
|
+
}
|
|
1116
|
+
$s(t, e) {
|
|
1117
|
+
this._s.width = t, this._s.height = e, this._s.style.width = t + "px", this._s.style.height = t + "px", this.vs.imageSmoothingEnabled = !1, this._s.style.imageRendering = "pixelated", this.vs.fillStyle = "black", this.vs.fillRect(0, 0, t, e), this.vs.textBaseline = "top", this.vs.textAlign = "left", this.vs.fillStyle = "white";
|
|
1118
|
+
}
|
|
1119
|
+
bs(t, e, s, r, i) {
|
|
1120
|
+
const n = r / i.head.unitsPerEm;
|
|
1121
|
+
for (let o = 0; o < t.length; o++) {
|
|
1122
|
+
const h = o % s, l = Math.floor(o / s), u = t[o].character, f = this.Ts(i, u);
|
|
787
1123
|
if (!f) continue;
|
|
788
|
-
const d = u.codePointAt(0) || 0,
|
|
789
|
-
this
|
|
1124
|
+
const d = u.codePointAt(0) || 0, p = this.ws.Xe(i, d), g = this.zs(i, p) * n, m = h * e.width, T = l * e.height, v = m + 0.5 * e.width, b = T + 0.5 * e.height, _ = Math.round(v - 0.5 * e.width), S = Math.round(b - 0.5 * r), j = _ + 0.5 * (e.width - g), H = S + i.hhea.ascender * n;
|
|
1125
|
+
this.Rs(f, j, H, n);
|
|
790
1126
|
}
|
|
791
1127
|
}
|
|
792
|
-
|
|
793
|
-
const
|
|
794
|
-
if (
|
|
795
|
-
if (t.glyf && t.glyf[
|
|
796
|
-
if (
|
|
797
|
-
const i =
|
|
798
|
-
return t.glyf && i && (t.glyf[
|
|
1128
|
+
Ts(t, e) {
|
|
1129
|
+
const s = e.codePointAt(0) || 0, r = this.ws.Xe(t, s);
|
|
1130
|
+
if (r === 0) return null;
|
|
1131
|
+
if (t.glyf && t.glyf[r] !== null) return t.glyf[r];
|
|
1132
|
+
if (E && E.T && E.T.glyf) {
|
|
1133
|
+
const i = E.T.glyf.Oe(t, r);
|
|
1134
|
+
return t.glyf && i && (t.glyf[r] = i), i;
|
|
799
1135
|
}
|
|
800
1136
|
return null;
|
|
801
1137
|
}
|
|
802
|
-
|
|
803
|
-
const
|
|
804
|
-
return
|
|
1138
|
+
zs(t, e) {
|
|
1139
|
+
const s = t.hmtx;
|
|
1140
|
+
return s && s.aWidth ? e < s.aWidth.length ? s.aWidth[e] : s.aWidth[s.aWidth.length - 1] : 0;
|
|
805
1141
|
}
|
|
806
|
-
|
|
1142
|
+
Rs(t, e, s, r) {
|
|
807
1143
|
if (!t || !t.xs || t.noc === 0) return;
|
|
808
|
-
const { xs: i, ys:
|
|
809
|
-
if (!(i &&
|
|
810
|
-
this.
|
|
811
|
-
let
|
|
812
|
-
for (let u = 0; u <
|
|
813
|
-
const f =
|
|
814
|
-
if (!(f <
|
|
815
|
-
if (f >=
|
|
816
|
-
const d = e + i[
|
|
817
|
-
this.
|
|
818
|
-
let
|
|
819
|
-
for (;
|
|
820
|
-
if (1 &
|
|
821
|
-
const
|
|
822
|
-
this.
|
|
1144
|
+
const { xs: i, ys: n, endPts: o, flags: h } = t;
|
|
1145
|
+
if (!(i && n && o && h)) return;
|
|
1146
|
+
this.vs.beginPath();
|
|
1147
|
+
let l = 0;
|
|
1148
|
+
for (let u = 0; u < o.length; u++) {
|
|
1149
|
+
const f = o[u];
|
|
1150
|
+
if (!(f < l)) {
|
|
1151
|
+
if (f >= l) {
|
|
1152
|
+
const d = e + i[l] * r, p = s - n[l] * r;
|
|
1153
|
+
this.vs.moveTo(d, p);
|
|
1154
|
+
let g = l + 1;
|
|
1155
|
+
for (; g <= f; )
|
|
1156
|
+
if (1 & h[g]) {
|
|
1157
|
+
const m = e + i[g] * r, T = s - n[g] * r;
|
|
1158
|
+
this.vs.lineTo(m, T), g++;
|
|
823
1159
|
} else {
|
|
824
|
-
const
|
|
825
|
-
let v =
|
|
826
|
-
if (1 &
|
|
827
|
-
const b = e + i[v] *
|
|
828
|
-
this.
|
|
1160
|
+
const m = e + i[g] * r, T = s - n[g] * r;
|
|
1161
|
+
let v = g + 1 > f ? l : g + 1;
|
|
1162
|
+
if (1 & h[v]) {
|
|
1163
|
+
const b = e + i[v] * r, _ = s - n[v] * r;
|
|
1164
|
+
this.vs.quadraticCurveTo(m, T, b, _), g = v + 1;
|
|
829
1165
|
} else {
|
|
830
|
-
const b = (
|
|
831
|
-
this.
|
|
1166
|
+
const b = (m + (e + i[v] * r)) / 2, _ = (T + (s - n[v] * r)) / 2;
|
|
1167
|
+
this.vs.quadraticCurveTo(m, T, b, _), g = v;
|
|
832
1168
|
}
|
|
833
1169
|
}
|
|
834
|
-
this.
|
|
1170
|
+
this.vs.closePath();
|
|
835
1171
|
}
|
|
836
|
-
|
|
1172
|
+
l = f + 1;
|
|
837
1173
|
}
|
|
838
1174
|
}
|
|
839
|
-
this.
|
|
1175
|
+
this.vs.fill();
|
|
840
1176
|
}
|
|
841
1177
|
}
|
|
842
|
-
class
|
|
1178
|
+
class _t {
|
|
843
1179
|
constructor() {
|
|
844
|
-
|
|
845
|
-
this.
|
|
846
|
-
}
|
|
847
|
-
calculateMaxGlyphDimensions(t, e,
|
|
848
|
-
let
|
|
849
|
-
const i = this.
|
|
850
|
-
for (const
|
|
851
|
-
const
|
|
852
|
-
if (
|
|
853
|
-
const
|
|
854
|
-
|
|
1180
|
+
c(this, "ss");
|
|
1181
|
+
this.ss = new U();
|
|
1182
|
+
}
|
|
1183
|
+
calculateMaxGlyphDimensions(t, e, s) {
|
|
1184
|
+
let r = 0;
|
|
1185
|
+
const i = this.ss.ts(s, e), n = i.lineHeight;
|
|
1186
|
+
for (const o of t) {
|
|
1187
|
+
const h = this.ss.Je(s, o);
|
|
1188
|
+
if (h === 0) continue;
|
|
1189
|
+
const l = this.ss.Ke(s, h) * i.scale;
|
|
1190
|
+
r = Math.max(r, l);
|
|
855
1191
|
}
|
|
856
|
-
return { width: Math.ceil(
|
|
1192
|
+
return { width: Math.ceil(r), height: Math.ceil(n) };
|
|
857
1193
|
}
|
|
858
|
-
getCharacterAdvanceWidth(t, e,
|
|
859
|
-
const
|
|
860
|
-
return this.
|
|
1194
|
+
getCharacterAdvanceWidth(t, e, s) {
|
|
1195
|
+
const r = this.ss.ts(s, e), i = this.ss.Je(s, t);
|
|
1196
|
+
return this.ss.Ke(s, i) * r.scale;
|
|
861
1197
|
}
|
|
862
1198
|
getFontMetrics(t, e) {
|
|
863
|
-
return this.
|
|
1199
|
+
return this.ss.ts(e, t);
|
|
864
1200
|
}
|
|
865
|
-
|
|
866
|
-
this.
|
|
1201
|
+
es() {
|
|
1202
|
+
this.ss.es();
|
|
867
1203
|
}
|
|
868
1204
|
}
|
|
869
|
-
class
|
|
1205
|
+
class Et {
|
|
870
1206
|
constructor() {
|
|
871
|
-
|
|
872
|
-
this.
|
|
1207
|
+
c(this, "ws");
|
|
1208
|
+
this.ws = new U();
|
|
873
1209
|
}
|
|
874
1210
|
createCharacterObjects(t, e) {
|
|
875
|
-
return t.map((
|
|
876
|
-
const i =
|
|
877
|
-
let
|
|
1211
|
+
return t.map((s, r) => {
|
|
1212
|
+
const i = s.codePointAt(0) || 0, n = this.Ms(r);
|
|
1213
|
+
let o = 0;
|
|
878
1214
|
if (e.hmtx && e.hmtx.aWidth) {
|
|
879
|
-
const
|
|
880
|
-
|
|
1215
|
+
const h = this.ws.Xe(e, i);
|
|
1216
|
+
h > 0 && e.hmtx.aWidth[h] !== void 0 && (o = e.hmtx.aWidth[h]);
|
|
881
1217
|
}
|
|
882
|
-
return { character:
|
|
1218
|
+
return { character: s, unicode: i, color: n, advanceWidth: o };
|
|
883
1219
|
});
|
|
884
1220
|
}
|
|
885
|
-
|
|
886
|
-
return [t % 256, Math.floor(t / 256) % 256, Math.floor(t / 65536) % 256];
|
|
1221
|
+
Ms(t) {
|
|
1222
|
+
return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
|
|
887
1223
|
}
|
|
888
|
-
|
|
889
|
-
if (!
|
|
890
|
-
const
|
|
891
|
-
return
|
|
1224
|
+
Ss(t, e) {
|
|
1225
|
+
if (!I._(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
|
|
1226
|
+
const s = e.find((r) => r.character === t);
|
|
1227
|
+
return s ? s.color : [0, 0, 0];
|
|
892
1228
|
}
|
|
893
|
-
|
|
894
|
-
return
|
|
1229
|
+
As(t, e) {
|
|
1230
|
+
return I._(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((s) => this.Ss(s, e) || [0, 0, 0]) : [[0, 0, 0]];
|
|
895
1231
|
}
|
|
896
1232
|
}
|
|
897
|
-
class
|
|
1233
|
+
class At {
|
|
898
1234
|
constructor(t, e = 16) {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
async Ue(t) {
|
|
1235
|
+
c(this, "Ps");
|
|
1236
|
+
c(this, "Fs", []);
|
|
1237
|
+
c(this, "Gs");
|
|
1238
|
+
c(this, "Ds", 16);
|
|
1239
|
+
c(this, "Is", 0);
|
|
1240
|
+
c(this, "Bs", 0);
|
|
1241
|
+
c(this, "Ls", { width: 0, height: 0 });
|
|
1242
|
+
c(this, "Es");
|
|
1243
|
+
c(this, "Ws");
|
|
1244
|
+
c(this, "ks");
|
|
1245
|
+
c(this, "Vs");
|
|
1246
|
+
c(this, "Os");
|
|
1247
|
+
this.Ds = e, this.Ws = new Tt(), this.ks = new bt(t), this.Vs = new _t(), this.Os = new Et();
|
|
1248
|
+
}
|
|
1249
|
+
async Us(t) {
|
|
915
1250
|
let e;
|
|
916
|
-
if (!t) throw new
|
|
1251
|
+
if (!t) throw new C("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
|
|
917
1252
|
{
|
|
918
|
-
const
|
|
919
|
-
if (!
|
|
920
|
-
e = await
|
|
1253
|
+
const s = await fetch(t);
|
|
1254
|
+
if (!s.ok) throw new C(`Failed to load font file: ${s.status} ${s.statusText}`);
|
|
1255
|
+
e = await s.arrayBuffer();
|
|
921
1256
|
}
|
|
922
|
-
await this.
|
|
1257
|
+
await this.js(e), this.Ps = E.parse(e)[0], await this.Hs();
|
|
923
1258
|
}
|
|
924
|
-
|
|
925
|
-
if (t === void 0) return this.
|
|
926
|
-
this.
|
|
927
|
-
const e = this.
|
|
928
|
-
this.
|
|
1259
|
+
qs(t) {
|
|
1260
|
+
if (t === void 0) return this.Ds;
|
|
1261
|
+
this.Ds = t, this.Ls = this.Vs.calculateMaxGlyphDimensions(this.Fs.map((s) => s.character), this.Ds, this.Ps);
|
|
1262
|
+
const e = this.ks.createTextureAtlas(this.Fs, this.Ls, this.Ds, this.Ps);
|
|
1263
|
+
this.Gs = e.framebuffer, this.Is = e.columns, this.Bs = e.rows;
|
|
929
1264
|
}
|
|
930
|
-
async
|
|
1265
|
+
async Ns(t) {
|
|
931
1266
|
try {
|
|
932
1267
|
const e = await fetch(t);
|
|
933
|
-
if (!e.ok) throw new
|
|
934
|
-
const
|
|
935
|
-
await this.
|
|
936
|
-
const
|
|
937
|
-
if (!
|
|
938
|
-
this.
|
|
1268
|
+
if (!e.ok) throw new C(`Failed to load font file: ${e.status} ${e.statusText}`);
|
|
1269
|
+
const s = await e.arrayBuffer();
|
|
1270
|
+
await this.js(s);
|
|
1271
|
+
const r = E.parse(s);
|
|
1272
|
+
if (!r || r.length === 0) throw Error("Failed to parse font file");
|
|
1273
|
+
this.Ps = r[0], await this.Hs();
|
|
939
1274
|
} catch (e) {
|
|
940
|
-
throw new
|
|
1275
|
+
throw new C("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
|
|
941
1276
|
}
|
|
942
1277
|
}
|
|
943
|
-
async
|
|
1278
|
+
async js(t) {
|
|
944
1279
|
const e = Date.now();
|
|
945
|
-
this.
|
|
946
|
-
}
|
|
947
|
-
async He() {
|
|
948
|
-
const t = this.ze.extractCharacters(this.Te), e = this.ze.filterProblematicCharacters(t);
|
|
949
|
-
this.Me = this.Ae.createCharacterObjects(e, this.Te), this.ke = this.Ge.calculateMaxGlyphDimensions(e, this.Se, this.Te);
|
|
950
|
-
const r = this.Ee.createTextureAtlas(this.Me, this.ke, this.Se, this.Te);
|
|
951
|
-
this.De = r.framebuffer, this.Re = r.columns, this.Ve = r.rows;
|
|
1280
|
+
this.Es = new FontFace("CustomFont_" + e, t), await this.Es.load(), document.fonts.add(this.Es);
|
|
952
1281
|
}
|
|
953
|
-
|
|
954
|
-
|
|
1282
|
+
async Hs() {
|
|
1283
|
+
const t = this.Ws.extractCharacters(this.Ps), e = this.Ws.filterProblematicCharacters(t);
|
|
1284
|
+
this.Fs = this.Os.createCharacterObjects(e, this.Ps), this.Ls = this.Vs.calculateMaxGlyphDimensions(e, this.Ds, this.Ps);
|
|
1285
|
+
const s = this.ks.createTextureAtlas(this.Fs, this.Ls, this.Ds, this.Ps);
|
|
1286
|
+
this.Gs = s.framebuffer, this.Is = s.columns, this.Bs = s.rows;
|
|
955
1287
|
}
|
|
956
|
-
|
|
957
|
-
return this.
|
|
1288
|
+
Ss(t) {
|
|
1289
|
+
return this.Os.Ss(t, this.Fs);
|
|
958
1290
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
const e = new Set(this.Me.map((r) => r.character));
|
|
962
|
-
for (const r of t) if (!e.has(r)) return !1;
|
|
963
|
-
return !0;
|
|
1291
|
+
As(t) {
|
|
1292
|
+
return this.Os.As(t, this.Fs);
|
|
964
1293
|
}
|
|
965
|
-
|
|
966
|
-
this.
|
|
1294
|
+
U() {
|
|
1295
|
+
this.Gs.U(), document.fonts.delete(this.Es);
|
|
967
1296
|
}
|
|
968
1297
|
get fontFramebuffer() {
|
|
969
|
-
return this.
|
|
1298
|
+
return this.Gs;
|
|
970
1299
|
}
|
|
971
1300
|
get characters() {
|
|
972
|
-
return this.
|
|
1301
|
+
return this.Fs;
|
|
973
1302
|
}
|
|
974
1303
|
get textureColumns() {
|
|
975
|
-
return this.
|
|
1304
|
+
return this.Is;
|
|
976
1305
|
}
|
|
977
1306
|
get textureRows() {
|
|
978
|
-
return this.
|
|
1307
|
+
return this.Bs;
|
|
979
1308
|
}
|
|
980
1309
|
get maxGlyphDimensions() {
|
|
981
|
-
return this.
|
|
1310
|
+
return this.Ls;
|
|
982
1311
|
}
|
|
983
1312
|
get fontSize() {
|
|
984
|
-
return this.
|
|
1313
|
+
return this.Ds;
|
|
985
1314
|
}
|
|
986
1315
|
get font() {
|
|
987
|
-
return this.
|
|
1316
|
+
return this.Ps;
|
|
988
1317
|
}
|
|
989
1318
|
}
|
|
990
|
-
class
|
|
991
|
-
constructor(t, e,
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
this.F = this.Be * this.Qe, this.M = this.We * this.Ze, this.Ne = Math.floor((this.Ye.width - this.F) / 2), this.Xe = Math.floor((this.Ye.height - this.M) / 2);
|
|
1009
|
-
}
|
|
1010
|
-
Ke(t, e) {
|
|
1011
|
-
this.Qe = t, this.Ze = e, this.kt();
|
|
1012
|
-
}
|
|
1013
|
-
tr(t, e) {
|
|
1014
|
-
this.qe = !0, this.Be = t, this.We = e, this.Je();
|
|
1015
|
-
}
|
|
1016
|
-
er() {
|
|
1017
|
-
this.qe = !1, this.kt();
|
|
1018
|
-
}
|
|
1019
|
-
rr() {
|
|
1020
|
-
this.qe ? this.Je() : this.kt();
|
|
1021
|
-
}
|
|
1022
|
-
sr(t) {
|
|
1023
|
-
if (t === void 0) return this.qe;
|
|
1024
|
-
this.qe = t;
|
|
1319
|
+
class wt {
|
|
1320
|
+
constructor(t, e, s) {
|
|
1321
|
+
c(this, "Xs");
|
|
1322
|
+
c(this, "Ys");
|
|
1323
|
+
c(this, "v");
|
|
1324
|
+
c(this, "C");
|
|
1325
|
+
c(this, "Qs");
|
|
1326
|
+
c(this, "Zs");
|
|
1327
|
+
c(this, "Js");
|
|
1328
|
+
c(this, "Ks");
|
|
1329
|
+
c(this, "ti");
|
|
1330
|
+
this.Js = t, this.Ks = e, this.ti = s, this.Ct();
|
|
1331
|
+
}
|
|
1332
|
+
Ct() {
|
|
1333
|
+
this.Xs = Math.floor(this.Js.width / this.Ks), this.Ys = Math.floor(this.Js.height / this.ti), this.v = this.Xs * this.Ks, this.C = this.Ys * this.ti, this.Qs = Math.floor((this.Js.width - this.v) / 2), this.Zs = Math.floor((this.Js.height - this.C) / 2);
|
|
1334
|
+
}
|
|
1335
|
+
ei(t, e) {
|
|
1336
|
+
this.Ks = t, this.ti = e, this.Ct();
|
|
1025
1337
|
}
|
|
1026
1338
|
get cellWidth() {
|
|
1027
|
-
return this.
|
|
1339
|
+
return this.Ks;
|
|
1028
1340
|
}
|
|
1029
1341
|
get cellHeight() {
|
|
1030
|
-
return this.
|
|
1342
|
+
return this.ti;
|
|
1031
1343
|
}
|
|
1032
1344
|
get cols() {
|
|
1033
|
-
return this.
|
|
1345
|
+
return this.Xs;
|
|
1034
1346
|
}
|
|
1035
1347
|
get rows() {
|
|
1036
|
-
return this.
|
|
1348
|
+
return this.Ys;
|
|
1037
1349
|
}
|
|
1038
1350
|
get width() {
|
|
1039
|
-
return this.
|
|
1351
|
+
return this.v;
|
|
1040
1352
|
}
|
|
1041
1353
|
get height() {
|
|
1042
|
-
return this.
|
|
1354
|
+
return this.C;
|
|
1043
1355
|
}
|
|
1044
1356
|
get offsetX() {
|
|
1045
|
-
return this.
|
|
1357
|
+
return this.Qs;
|
|
1046
1358
|
}
|
|
1047
1359
|
get offsetY() {
|
|
1048
|
-
return this.
|
|
1360
|
+
return this.Zs;
|
|
1049
1361
|
}
|
|
1050
1362
|
}
|
|
1051
|
-
class
|
|
1052
|
-
constructor(t
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
h(this, "onTransformChange");
|
|
1058
|
-
this.ir = t, this.nr = e, this.Ye = this.hr(r.width, r.height), e && this.setupTransformObserver();
|
|
1059
|
-
}
|
|
1060
|
-
hr(t, e) {
|
|
1061
|
-
var s;
|
|
1062
|
-
const r = document.createElement("canvas");
|
|
1063
|
-
if (r.className = "textmodeCanvas", r.style.imageRendering = "pixelated", this.nr) r.width = t || 800, r.height = e || 600, document.body.appendChild(r);
|
|
1064
|
-
else {
|
|
1065
|
-
const i = this.ir.getBoundingClientRect();
|
|
1066
|
-
let o = Math.round(i.width), n = Math.round(i.height);
|
|
1067
|
-
if (this.ir instanceof HTMLVideoElement) {
|
|
1068
|
-
const u = this.ir;
|
|
1069
|
-
(o === 0 || n === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (o = u.videoWidth, n = u.videoHeight);
|
|
1070
|
-
}
|
|
1071
|
-
r.width = o, r.height = n, r.style.position = "absolute", r.style.pointerEvents = "none";
|
|
1072
|
-
const l = window.getComputedStyle(this.ir);
|
|
1073
|
-
let c = parseInt(l.zIndex || "0", 10);
|
|
1074
|
-
isNaN(c) && (c = 0), r.style.zIndex = "" + (c + 1), this.lr(r), (s = this.ir.parentNode) == null || s.insertBefore(r, this.ir.nextSibling);
|
|
1075
|
-
}
|
|
1076
|
-
return r;
|
|
1077
|
-
}
|
|
1078
|
-
lr(t) {
|
|
1079
|
-
const e = this.ir.getBoundingClientRect();
|
|
1080
|
-
let r = this.ir.offsetParent;
|
|
1081
|
-
if (r && r !== document.body) {
|
|
1082
|
-
const s = r.getBoundingClientRect();
|
|
1083
|
-
t.style.top = e.top - s.top + "px", t.style.left = e.left - s.left + "px";
|
|
1084
|
-
} else t.style.top = e.top + window.scrollY + "px", t.style.left = e.left + window.scrollX + "px";
|
|
1363
|
+
class Pt {
|
|
1364
|
+
constructor(t = {}) {
|
|
1365
|
+
c(this, "Js");
|
|
1366
|
+
c(this, "si");
|
|
1367
|
+
c(this, "ii");
|
|
1368
|
+
t.canvas ? (this.Js = t.canvas, this.ii = !1) : (this.Js = this.ri(t.width, t.height), this.ii = !0), this.Js.style.imageRendering = "pixelated";
|
|
1085
1369
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
const r = this.ir.getBoundingClientRect();
|
|
1090
|
-
let s = Math.round(r.width), i = Math.round(r.height);
|
|
1091
|
-
if (this.ir instanceof HTMLVideoElement) {
|
|
1092
|
-
const o = this.ir;
|
|
1093
|
-
(s === 0 || i === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (s = o.videoWidth, i = o.videoHeight);
|
|
1094
|
-
}
|
|
1095
|
-
this.Ye.width = s, this.Ye.height = i, this.lr(this.Ye);
|
|
1096
|
-
}
|
|
1370
|
+
ri(t, e) {
|
|
1371
|
+
const s = document.createElement("canvas");
|
|
1372
|
+
return s.className = "textmodeCanvas", s.style.imageRendering = "pixelated", s.width = t || 800, s.height = e || 600, document.body.appendChild(s), s;
|
|
1097
1373
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
if (!e) throw new w("WebGL context could not be created. Ensure your browser supports WebGL.");
|
|
1101
|
-
return e;
|
|
1374
|
+
L(t, e) {
|
|
1375
|
+
this.Js.width = t ?? this.Js.width, this.Js.height = e ?? this.Js.height;
|
|
1102
1376
|
}
|
|
1103
|
-
|
|
1104
|
-
this.
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
!this.onTransformChange || Math.round(r.width) === this.Ye.width && Math.round(r.height) === this.Ye.height || this.onTransformChange();
|
|
1108
|
-
}
|
|
1109
|
-
}), this.ar.observe(this.Ye);
|
|
1377
|
+
ni() {
|
|
1378
|
+
const t = this.Js.getContext("webgl2", { alpha: !1, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
|
|
1379
|
+
if (!t) throw new C("`textmode.js` requires WebGL2 support.");
|
|
1380
|
+
return t;
|
|
1110
1381
|
}
|
|
1111
|
-
|
|
1112
|
-
this.
|
|
1113
|
-
const t = this.
|
|
1382
|
+
U() {
|
|
1383
|
+
this.si && this.si.disconnect();
|
|
1384
|
+
const t = this.Js.getContext("webgl") || this.Js.getContext("webgl2");
|
|
1114
1385
|
if (t) {
|
|
1115
1386
|
const e = t.getExtension("WEBGL_lose_context");
|
|
1116
1387
|
e && e.loseContext();
|
|
1117
1388
|
}
|
|
1118
|
-
this.
|
|
1389
|
+
this.ii && this.Js.parentNode && this.Js.parentNode.removeChild(this.Js);
|
|
1119
1390
|
}
|
|
1120
1391
|
get canvas() {
|
|
1121
|
-
return this.
|
|
1392
|
+
return this.Js;
|
|
1122
1393
|
}
|
|
1123
1394
|
get width() {
|
|
1124
|
-
return this.
|
|
1395
|
+
return this.Js.width;
|
|
1125
1396
|
}
|
|
1126
1397
|
get height() {
|
|
1127
|
-
return this.
|
|
1398
|
+
return this.Js.height;
|
|
1128
1399
|
}
|
|
1129
1400
|
}
|
|
1130
|
-
class
|
|
1131
|
-
constructor(t
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
this
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
}
|
|
1152
|
-
enable() {
|
|
1153
|
-
this.enabled(!0);
|
|
1154
|
-
}
|
|
1155
|
-
disable() {
|
|
1156
|
-
this.enabled(!1);
|
|
1157
|
-
}
|
|
1158
|
-
P() {
|
|
1159
|
-
this.pr.P(), this.mr.P(), this.gr.P(), this._r.P(), this.vr.P();
|
|
1160
|
-
}
|
|
1161
|
-
get characterFramebuffer() {
|
|
1162
|
-
return this.pr;
|
|
1163
|
-
}
|
|
1164
|
-
get primaryColorFramebuffer() {
|
|
1165
|
-
return this.mr;
|
|
1166
|
-
}
|
|
1167
|
-
get secondaryColorFramebuffer() {
|
|
1168
|
-
return this.gr;
|
|
1169
|
-
}
|
|
1170
|
-
get rotationFramebuffer() {
|
|
1171
|
-
return this._r;
|
|
1172
|
-
}
|
|
1173
|
-
get transformFramebuffer() {
|
|
1174
|
-
return this.vr;
|
|
1175
|
-
}
|
|
1176
|
-
get options() {
|
|
1177
|
-
return this.l;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
class xt {
|
|
1181
|
-
constructor(t, e) {
|
|
1182
|
-
h(this, "C");
|
|
1183
|
-
h(this, "ve");
|
|
1184
|
-
h(this, "br");
|
|
1185
|
-
this.ve = t, this.br = e;
|
|
1186
|
-
const r = Math.max(this.br.length, 1);
|
|
1187
|
-
this.C = this.ve.Lt(r, 1), this.wr();
|
|
1188
|
-
}
|
|
1189
|
-
wr() {
|
|
1190
|
-
const t = this.br.length;
|
|
1191
|
-
this.C.width !== t && this.C.resize(t, 1);
|
|
1192
|
-
const e = new Uint8Array(1 * t * 4);
|
|
1193
|
-
for (let r = 0; r < t; r++) {
|
|
1194
|
-
const s = this.br[r], i = 4 * r;
|
|
1195
|
-
e[i] = s[0], e[i + 1] = s[1], e[i + 2] = s[2], e[i + 3] = 255;
|
|
1196
|
-
}
|
|
1197
|
-
this.C.updatePixels(e, t, 1);
|
|
1198
|
-
}
|
|
1199
|
-
setColors(t) {
|
|
1200
|
-
this.br = t, this.wr();
|
|
1201
|
-
}
|
|
1202
|
-
get colors() {
|
|
1203
|
-
return this.br;
|
|
1204
|
-
}
|
|
1205
|
-
get framebuffer() {
|
|
1206
|
-
return this.C;
|
|
1207
|
-
}
|
|
1208
|
-
get texture() {
|
|
1209
|
-
return this.C.texture;
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
class B extends D {
|
|
1213
|
-
constructor(e, r, s, i = {}) {
|
|
1214
|
-
super(e, r, s, i);
|
|
1215
|
-
h(this, "Cr");
|
|
1216
|
-
this.Cr = new xt(this.ve, this.ur.getCharacterColors(" .:-=+*%@#"));
|
|
1217
|
-
}
|
|
1218
|
-
characters(e) {
|
|
1219
|
-
x.m(this.ur.hasAllCharacters(e), "One or more characters do not exist in the current font.", { method: "characters", providedValue: e }) && (this.l.characters = e, this.Cr.setColors(this.ur.getCharacterColors(e)));
|
|
1220
|
-
}
|
|
1221
|
-
characterColor(e, r, s, i = 255) {
|
|
1222
|
-
const o = this.yr(e, "characterColor", r, s, i);
|
|
1223
|
-
o && (this.l.characterColor = o);
|
|
1224
|
-
}
|
|
1225
|
-
characterColorMode(e) {
|
|
1226
|
-
this.$r(e, "characterColorMode");
|
|
1227
|
-
}
|
|
1228
|
-
cellColor(e, r, s, i = 255) {
|
|
1229
|
-
const o = this.yr(e, "cellColor", r, s, i);
|
|
1230
|
-
o && (this.l.cellColor = o);
|
|
1231
|
-
}
|
|
1232
|
-
cellColorMode(e) {
|
|
1233
|
-
this.$r(e, "cellColorMode");
|
|
1234
|
-
}
|
|
1235
|
-
invert(e) {
|
|
1236
|
-
this.Fr(e, "invert", "Invert");
|
|
1237
|
-
}
|
|
1238
|
-
rotation(e) {
|
|
1239
|
-
if (!x.m(typeof e == "number", "Rotation angle must be a number.", { method: "rotation", providedValue: e })) return;
|
|
1240
|
-
(e %= 360) < 0 && (e += 360);
|
|
1241
|
-
const r = 255 * e / 360, s = Math.floor(r) / 255, i = Math.round(r - s);
|
|
1242
|
-
this.l.rotation = [s, i, 0, 1];
|
|
1243
|
-
}
|
|
1244
|
-
flipHorizontally(e) {
|
|
1245
|
-
this.Fr(e, "flipHorizontally", "Flip horizontally");
|
|
1246
|
-
}
|
|
1247
|
-
flipVertically(e) {
|
|
1248
|
-
this.Fr(e, "flipVertically", "Flip vertically");
|
|
1249
|
-
}
|
|
1250
|
-
yr(e, r, s, i, o = 255) {
|
|
1251
|
-
let n, l, c, u;
|
|
1252
|
-
if (typeof e == "string") {
|
|
1253
|
-
const f = this.Tr(e);
|
|
1254
|
-
if (!f) return x.m(!1, "Invalid hex color format. Use '#FF0000', '#F00', 'FF0000', or 'F00'.", { method: r, providedValue: e }), null;
|
|
1255
|
-
[n, l, c, u] = f;
|
|
1256
|
-
} else if (n = e, l = s !== void 0 ? s : e, c = i !== void 0 ? i : e, u = o, !x.m([n, l, c, u].every((f) => f >= 0 && f <= 255), r.charAt(0).toUpperCase() + r.slice(1) + " color values must be between 0 and 255", { method: r, providedValues: { r: n, g: l, b: c, a: u } })) return null;
|
|
1257
|
-
return [n / 255, l / 255, c / 255, u / 255];
|
|
1258
|
-
}
|
|
1259
|
-
$r(e, r) {
|
|
1260
|
-
x.m(["sampled", "fixed"].includes(e), "Invalid color mode. Must be 'sampled' or 'fixed'.", { method: r, providedValue: e }) && (this.l[r] = e);
|
|
1261
|
-
}
|
|
1262
|
-
Fr(e, r, s) {
|
|
1263
|
-
x.m(typeof e == "boolean" || typeof e == "number" && Number.isInteger(e), s + " must be a boolean value or an integer (0 for false, any other number for true).", { method: r, providedValue: e }) && (this.l[r] = !!e);
|
|
1264
|
-
}
|
|
1265
|
-
Tr(e) {
|
|
1266
|
-
return e = e.replace(/^#/, ""), /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(e) ? (e.length === 3 && (e = e.split("").map((r) => r + r).join("")), [parseInt(e.slice(0, 2), 16), parseInt(e.slice(2, 4), 16), parseInt(e.slice(4, 6), 16), 255]) : null;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
const U = `attribute vec2 a_position;\r
|
|
1270
|
-
attribute vec2 a_texCoord;\r
|
|
1271
|
-
varying vec2 v_uv;\r
|
|
1272
|
-
\r
|
|
1273
|
-
uniform float u_rotation; // rotation angle in radians\r
|
|
1274
|
-
uniform vec2 u_center; // rotation center in normalized coordinates\r
|
|
1275
|
-
uniform float u_aspectRatio; // canvas width / canvas height\r
|
|
1276
|
-
\r
|
|
1277
|
-
mat2 rotate2D(float angle) {\r
|
|
1278
|
-
float s = sin(angle);\r
|
|
1279
|
-
float c = cos(angle);\r
|
|
1280
|
-
return mat2(c, -s, s, c);\r
|
|
1281
|
-
}\r
|
|
1282
|
-
\r
|
|
1283
|
-
void main() {\r
|
|
1284
|
-
v_uv = a_texCoord;\r
|
|
1285
|
-
\r
|
|
1286
|
-
// Use the position directly (it's already in normalized device coordinates)\r
|
|
1287
|
-
vec2 pos = a_position;\r
|
|
1288
|
-
\r
|
|
1289
|
-
// Translate to origin for rotation\r
|
|
1290
|
-
pos -= u_center;\r
|
|
1291
|
-
\r
|
|
1292
|
-
// Correct for aspect ratio: scale X coordinate to make space square\r
|
|
1293
|
-
pos.x *= u_aspectRatio;\r
|
|
1294
|
-
\r
|
|
1295
|
-
// Rotate in corrected space\r
|
|
1296
|
-
// Negate rotation to make positive values rotate clockwise (like p5.js)\r
|
|
1297
|
-
pos = rotate2D(-u_rotation) * pos;\r
|
|
1298
|
-
\r
|
|
1299
|
-
// Restore aspect ratio: scale X coordinate back\r
|
|
1300
|
-
pos.x /= u_aspectRatio;\r
|
|
1301
|
-
\r
|
|
1302
|
-
// Translate back from origin\r
|
|
1303
|
-
pos += u_center;\r
|
|
1304
|
-
\r
|
|
1305
|
-
gl_Position = vec4(pos, 0.0, 1.0);\r
|
|
1306
|
-
}\r
|
|
1307
|
-
`, bt = { enabled: !0, characters: " .:-=+*%@#", characterColor: [1, 1, 1, 1], characterColorMode: "sampled", cellColor: [0, 0, 0, 1], cellColorMode: "fixed", invert: !1, rotation: [0, 0, 0, 255], flipHorizontally: !1, flipVertically: !1, brightnessRange: [0, 255] };
|
|
1308
|
-
class Y extends B {
|
|
1309
|
-
constructor(e, r, s) {
|
|
1310
|
-
super(e, r, s, { ...bt });
|
|
1311
|
-
h(this, "Mr");
|
|
1312
|
-
h(this, "Dr");
|
|
1313
|
-
h(this, "Sr");
|
|
1314
|
-
h(this, "Rr");
|
|
1315
|
-
h(this, "Vr");
|
|
1316
|
-
h(this, "kr");
|
|
1317
|
-
this.Mr = new R(e.context, U, "precision lowp float;uniform sampler2D u_sketchTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec2 cellCenter=(floor(v_uv*u_gridCellDimensions)+vec2(0.5))/u_gridCellDimensions;vec4 color=texture2D(u_sketchTexture,cellCenter);float brightness=dot(color.rgb,vec3(0.299,0.587,0.114));float brightnessValue=brightness*255.0;if(brightnessValue>=u_brightnessRange.x&&brightnessValue<=u_brightnessRange.y){gl_FragColor=color;}else{gl_FragColor=vec4(0.0);}}"), this.Dr = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_fillColor;uniform bool u_useFixedColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){if(u_useFixedColor){gl_FragColor=u_fillColor;}else{gl_FragColor=sampleColor;}}else{gl_FragColor=vec4(0.0);}}"), this.Rr = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform bool u_invert;uniform bool u_flipHorizontally;uniform bool u_flipVertically;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){float invertValue=u_invert ? 1.0 : 0.0;float flipHValue=u_flipHorizontally ? 1.0 : 0.0;float flipVValue=u_flipVertically ? 1.0 : 0.0;gl_FragColor=vec4(invertValue,flipHValue,flipVValue,1.0);}else{gl_FragColor=vec4(0.0);}}"), this.Vr = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_rotationColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){gl_FragColor=u_rotationColor;}else{gl_FragColor=vec4(0.0);}}"), this.Sr = new R(e.context, U, "precision lowp float;uniform sampler2D u_colorSampleFramebuffer;uniform sampler2D u_charPaletteTexture;uniform vec2 u_charPaletteSize;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec4 color=texture2D(u_colorSampleFramebuffer,v_uv);if(color.a==0.0){gl_FragColor=vec4(0.0);return;}float brightness=dot(color.rgb,vec3(0.299,0.587,0.114))*255.0;vec2 range=u_brightnessRange;if(brightness<range.x||brightness>range.y){gl_FragColor=vec4(0.0);return;}float t=(brightness-range.x)/(range.y-range.x);float idx=clamp(floor(t*u_charPaletteSize.x),0.0,u_charPaletteSize.x-1.0);vec3 charColor=texture2D(u_charPaletteTexture,vec2((idx+0.5)/u_charPaletteSize.x,0.0)).rgb;gl_FragColor=vec4(charColor,1.0);}"), this.kr = this.ve.Lt(this.dr.cols, this.dr.rows);
|
|
1318
|
-
}
|
|
1319
|
-
Ir(e) {
|
|
1320
|
-
const r = this.dr.cols, s = this.dr.rows;
|
|
1321
|
-
this.kr.begin(), this.ve.jt(), this.ve.yt(this.Mr), this.ve.Et("u_sketchTexture", e), this.ve.Et("u_gridCellDimensions", [r, s]), this.ve.Et("u_brightnessRange", this.l.brightnessRange), this.ve.Gt(0, 0, r, s), this.kr.end(), this.mr.begin(), this.ve.jt(), this.ve.yt(this.Dr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_fillColor", this.l.characterColor), this.ve.Et("u_useFixedColor", this.l.characterColorMode === "fixed"), this.ve.Gt(0, 0, r, s), this.mr.end(), this.gr.begin(), this.ve.jt(), this.ve.yt(this.Dr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_fillColor", this.l.cellColor), this.ve.Et("u_useFixedColor", this.l.cellColorMode === "fixed"), this.ve.Gt(0, 0, r, s), this.gr.end(), this.vr.begin(), this.ve.jt(), this.ve.yt(this.Rr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_invert", this.l.invert), this.ve.Et("u_flipHorizontally", this.l.flipHorizontally), this.ve.Et("u_flipVertically", this.l.flipVertically), this.ve.Gt(0, 0, r, s), this.vr.end(), this._r.begin(), this.ve.jt(), this.ve.yt(this.Vr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_rotationColor", this.l.rotation), this.ve.Gt(0, 0, r, s), this._r.end(), this.pr.begin(), this.ve.jt(), this.ve.yt(this.Sr), this.ve.Et("u_colorSampleFramebuffer", this.kr), this.ve.Et("u_charPaletteTexture", this.Cr.texture), this.ve.Et("u_charPaletteSize", [this.Cr.colors.length, 1]), this.ve.Et("u_brightnessRange", this.l.brightnessRange), this.ve.Gt(0, 0, r, s), this.pr.end();
|
|
1322
|
-
}
|
|
1323
|
-
rr() {
|
|
1324
|
-
super.rr(), this.kr.resize(this.dr.cols, this.dr.rows);
|
|
1325
|
-
}
|
|
1326
|
-
brightnessRange(e) {
|
|
1327
|
-
x.m(Array.isArray(e) && e.length === 2 && e.every((r) => typeof r == "number" && r >= 0 && r <= 255), "Brightness range must be an array of two numbers between 0 and 255.", { method: "brightnessRange", providedValue: e }) && (this.l.brightnessRange = e);
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
const Bt = Object.freeze(Object.defineProperty({ __proto__: null, TextmodeBrightnessConverter: Y, TextmodeConverter: D, TextmodeFeatureConverter: B }, Symbol.toStringTag, { value: "Module" }));
|
|
1331
|
-
class wt {
|
|
1332
|
-
constructor(t, e, r) {
|
|
1333
|
-
h(this, "ve");
|
|
1334
|
-
h(this, "Te");
|
|
1335
|
-
h(this, "dr");
|
|
1336
|
-
h(this, "Pr");
|
|
1337
|
-
h(this, "zr");
|
|
1338
|
-
h(this, "Er");
|
|
1339
|
-
h(this, "Gr");
|
|
1340
|
-
h(this, "Ar");
|
|
1341
|
-
h(this, "pr");
|
|
1342
|
-
h(this, "mr");
|
|
1343
|
-
h(this, "gr");
|
|
1344
|
-
h(this, "_r");
|
|
1345
|
-
h(this, "vr");
|
|
1346
|
-
this.ve = t, this.Te = e, this.dr = r, this.Ar = this.ve.Pt($, "precision mediump float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D u_primaryColorTexture;uniform sampler2D u_secondaryColorTexture;uniform sampler2D u_transformTexture;uniform sampler2D u_asciiCharacterTexture;uniform sampler2D u_rotationTexture;uniform sampler2D u_captureTexture;uniform vec2 u_captureDimensions;uniform int u_backgroundMode;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){vec2 adjustedCoord=gl_FragCoord.xy/u_gridPixelDimensions;vec2 gridCoord=adjustedCoord*u_gridCellDimensions;vec2 cellCoord=floor(gridCoord);vec2 charIndexTexCoord=(cellCoord+0.5)/u_gridCellDimensions;vec4 primaryColor=texture2D(u_primaryColorTexture,charIndexTexCoord);vec4 secondaryColor=texture2D(u_secondaryColorTexture,charIndexTexCoord);vec4 transformColor=texture2D(u_transformTexture,charIndexTexCoord);bool isInverted=transformColor.r>0.5;bool flipHorizontal=transformColor.g>0.5;bool flipVertical=transformColor.b>0.5;vec4 encodedIndexVec=texture2D(u_asciiCharacterTexture,charIndexTexCoord);if(encodedIndexVec.a<0.01){gl_FragColor=(u_backgroundMode==0)? vec4(0.0):texture2D(u_captureTexture,gl_FragCoord.xy/u_captureDimensions);return;}int charIndex=int(encodedIndexVec.r*255.0+0.5)+int(encodedIndexVec.g*255.0+0.5)*256;int charCol=int(mod(float(charIndex),u_charsetDimensions.x));int charRow=charIndex/int(u_charsetDimensions.x);float flippedRow=(u_charsetDimensions.y-1.0)-float(charRow);vec2 charCoord=vec2(float(charCol),flippedRow)/u_charsetDimensions;vec4 rotationColor=texture2D(u_rotationTexture,charIndexTexCoord);float scaledAngle=rotationColor.r*255.0+rotationColor.g;float rotationAngle=(scaledAngle*360.0/255.0)*0.017453292;vec2 fractionalPart=fract(gridCoord)-0.5;if(flipHorizontal)fractionalPart.x=-fractionalPart.x;if(flipVertical)fractionalPart.y=-fractionalPart.y;fractionalPart=rotate2D(rotationAngle)*fractionalPart+0.5;vec2 cellSize=1.0/u_charsetDimensions;vec2 texCoord=charCoord+fractionalPart*cellSize;vec2 cellMax=charCoord+cellSize;if(any(lessThan(texCoord,charCoord))||any(greaterThan(texCoord,cellMax))){gl_FragColor=isInverted ? primaryColor : secondaryColor;return;}vec4 charTexel=texture2D(u_characterTexture,texCoord);if(isInverted)charTexel.rgb=1.0-charTexel.rgb;gl_FragColor=mix(secondaryColor,primaryColor,charTexel);}"), this.zr = new Y(t, e, r), this.Er = new D(t, e, r), this.Pr = [this.zr, this.Er], this.pr = this.ve.Lt(r.cols, r.rows), this.mr = this.ve.Lt(r.cols, r.rows), this.gr = this.ve.Lt(r.cols, r.rows), this._r = this.ve.Lt(r.cols, r.rows), this.vr = this.ve.Lt(r.cols, r.rows), this.Gr = this.ve.Lt(this.dr.width, this.dr.height);
|
|
1347
|
-
}
|
|
1348
|
-
Ur(t) {
|
|
1349
|
-
for (const r of this.Pr) r.options.enabled && r instanceof B && r.Ir(t);
|
|
1350
|
-
const e = (r, s) => {
|
|
1351
|
-
r.begin(), this.ve.jt();
|
|
1352
|
-
for (const i of this.Pr) i.options.enabled && this.ve.Bt(s(i), 0, 0);
|
|
1353
|
-
r.end();
|
|
1401
|
+
class Ft {
|
|
1402
|
+
constructor(t = 60) {
|
|
1403
|
+
c(this, "oi");
|
|
1404
|
+
c(this, "ai");
|
|
1405
|
+
c(this, "hi", null);
|
|
1406
|
+
c(this, "ci", 0);
|
|
1407
|
+
c(this, "li", !0);
|
|
1408
|
+
c(this, "ui", 0);
|
|
1409
|
+
c(this, "fi", 0);
|
|
1410
|
+
c(this, "di", []);
|
|
1411
|
+
c(this, "pi", 10);
|
|
1412
|
+
c(this, "gi", 0);
|
|
1413
|
+
this.oi = t, this.ai = 1e3 / t;
|
|
1414
|
+
}
|
|
1415
|
+
start(t) {
|
|
1416
|
+
if (!this.li) return;
|
|
1417
|
+
this.ci = performance.now();
|
|
1418
|
+
const e = (s) => {
|
|
1419
|
+
if (!this.li) return void (this.hi = null);
|
|
1420
|
+
const r = s - this.ci;
|
|
1421
|
+
r >= this.ai && (t(), this.ci = s - r % this.ai), this.li && (this.hi = requestAnimationFrame(e));
|
|
1354
1422
|
};
|
|
1355
|
-
|
|
1356
|
-
}
|
|
1357
|
-
add(t) {
|
|
1358
|
-
if (!x.m(t === "brightness" || t === "custom", 'Converter type must be either "brightness" or "custom".', { method: "add", providedValue: t })) return;
|
|
1359
|
-
let e;
|
|
1360
|
-
return e = t === "brightness" ? new Y(this.ve, this.Te, this.dr) : new D(this.ve, this.Te, this.dr), this.Pr.push(e), e;
|
|
1361
|
-
}
|
|
1362
|
-
remove(t) {
|
|
1363
|
-
if (!x.m(t instanceof D, "Parameter must be a TextmodeConverter instance.", { method: "remove", providedValue: t })) return;
|
|
1364
|
-
const e = this.Pr.indexOf(t);
|
|
1365
|
-
x.m(e !== -1, "Converter instance not found in pipeline.", { method: "remove", providedValue: t, convertersCount: this.Pr.length }) && this.Pr.splice(e, 1);
|
|
1366
|
-
}
|
|
1367
|
-
swap(t, e) {
|
|
1368
|
-
const r = (n, l) => {
|
|
1369
|
-
if (typeof n == "number") return x.m(Number.isInteger(n) && n >= 0 && n < this.Pr.length, l + " index must be a valid integer within the converter array bounds.", { method: "swap", providedValue: n, convertersCount: this.Pr.length }) ? n : null;
|
|
1370
|
-
if (n instanceof D) {
|
|
1371
|
-
const c = this.Pr.indexOf(n);
|
|
1372
|
-
return x.m(c !== -1, l + " converter instance not found in pipeline.", { method: "swap", providedValue: n, convertersCount: this.Pr.length }) ? c : null;
|
|
1373
|
-
}
|
|
1374
|
-
return x.m(!1, l + " parameter must be either an integer index or a TextmodeConverter instance.", { method: "swap", providedValue: n }), null;
|
|
1375
|
-
}, s = r(t, "First"), i = r(e, "Second");
|
|
1376
|
-
if (s === null || i === null || !x.m(s !== i, "Cannot swap a converter with itself.", { method: "swap", firstIndex: s, secondIndex: i })) return;
|
|
1377
|
-
const o = this.Pr[s];
|
|
1378
|
-
this.Pr[s] = this.Pr[i], this.Pr[i] = o;
|
|
1379
|
-
}
|
|
1380
|
-
rr() {
|
|
1381
|
-
this.Gr.resize(this.dr.width, this.dr.height);
|
|
1382
|
-
const t = this.dr.cols, e = this.dr.rows;
|
|
1383
|
-
this.pr.resize(t, e), this.mr.resize(t, e), this.gr.resize(t, e), this._r.resize(t, e), this.vr.resize(t, e);
|
|
1384
|
-
for (const r of this.Pr) r.rr();
|
|
1423
|
+
this.hi = requestAnimationFrame(e);
|
|
1385
1424
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1425
|
+
stop() {
|
|
1426
|
+
this.hi && (cancelAnimationFrame(this.hi), this.hi = null);
|
|
1388
1427
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1428
|
+
pause() {
|
|
1429
|
+
this.li && (this.li = !1, this.stop());
|
|
1391
1430
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1431
|
+
resume(t) {
|
|
1432
|
+
this.li || (this.li = !0, this.start(t));
|
|
1394
1433
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
this.
|
|
1434
|
+
frameRate(t, e) {
|
|
1435
|
+
if (t === void 0) return this.ui;
|
|
1436
|
+
this.oi = t, this.ai = 1e3 / t, this.li && e && (this.stop(), this.start(e));
|
|
1398
1437
|
}
|
|
1399
|
-
|
|
1400
|
-
|
|
1438
|
+
measureFrameRate() {
|
|
1439
|
+
const t = performance.now();
|
|
1440
|
+
if (this.fi > 0) {
|
|
1441
|
+
const e = t - this.fi;
|
|
1442
|
+
this.di.push(e), this.di.length > this.pi && this.di.shift();
|
|
1443
|
+
const s = this.di.reduce((r, i) => r + i, 0) / this.di.length;
|
|
1444
|
+
this.ui = 1e3 / s;
|
|
1445
|
+
}
|
|
1446
|
+
this.fi = t;
|
|
1401
1447
|
}
|
|
1402
|
-
get
|
|
1403
|
-
return this.
|
|
1448
|
+
get isLooping() {
|
|
1449
|
+
return this.li;
|
|
1404
1450
|
}
|
|
1405
|
-
get
|
|
1406
|
-
return this.
|
|
1451
|
+
get frameRateLimit() {
|
|
1452
|
+
return this.oi;
|
|
1407
1453
|
}
|
|
1408
|
-
get
|
|
1409
|
-
return this.
|
|
1454
|
+
get currentFrameRate() {
|
|
1455
|
+
return this.ui;
|
|
1410
1456
|
}
|
|
1411
|
-
get
|
|
1412
|
-
return this.
|
|
1457
|
+
get frameCount() {
|
|
1458
|
+
return this.gi;
|
|
1413
1459
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1460
|
+
set frameCount(t) {
|
|
1461
|
+
this.gi = t;
|
|
1416
1462
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1463
|
+
incrementFrame() {
|
|
1464
|
+
this.gi++;
|
|
1419
1465
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1466
|
+
resetFrameCount() {
|
|
1467
|
+
this.gi = 0;
|
|
1422
1468
|
}
|
|
1423
1469
|
}
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1426
|
-
this.
|
|
1470
|
+
const St = (a) => class extends a {
|
|
1471
|
+
rotate(t) {
|
|
1472
|
+
this.Cs.state.$t(t);
|
|
1427
1473
|
}
|
|
1428
|
-
|
|
1429
|
-
this.
|
|
1474
|
+
push() {
|
|
1475
|
+
this.Cs.state.vt();
|
|
1430
1476
|
}
|
|
1431
|
-
|
|
1432
|
-
this.
|
|
1477
|
+
pop() {
|
|
1478
|
+
this.Cs.state.xt();
|
|
1433
1479
|
}
|
|
1434
|
-
|
|
1435
|
-
this.
|
|
1480
|
+
rect(t, e, s = 1, r = 1) {
|
|
1481
|
+
this.Cs.Fe(t, e, s, r);
|
|
1436
1482
|
}
|
|
1437
|
-
|
|
1438
|
-
this.
|
|
1483
|
+
line(t, e, s, r) {
|
|
1484
|
+
this.Cs.Ge(t, e, s, r);
|
|
1439
1485
|
}
|
|
1440
|
-
|
|
1441
|
-
this.
|
|
1486
|
+
lineWeight(t) {
|
|
1487
|
+
this.Cs.state.wt(t);
|
|
1442
1488
|
}
|
|
1443
|
-
|
|
1444
|
-
this.
|
|
1489
|
+
background(t, e = t, s = t, r = 255) {
|
|
1490
|
+
this.Cs.We(t, e, s, r);
|
|
1445
1491
|
}
|
|
1446
|
-
|
|
1447
|
-
this.
|
|
1492
|
+
char(t) {
|
|
1493
|
+
this.Cs.state.bt(this.Ps.Ss(t));
|
|
1448
1494
|
}
|
|
1449
|
-
|
|
1450
|
-
this.
|
|
1495
|
+
charColor(t, e, s, r) {
|
|
1496
|
+
this.Cs.state.Tt(t, e, s, r);
|
|
1451
1497
|
}
|
|
1452
|
-
|
|
1453
|
-
this.
|
|
1498
|
+
cellColor(t, e, s, r) {
|
|
1499
|
+
this.Cs.state.zt(t, e, s, r);
|
|
1454
1500
|
}
|
|
1455
|
-
|
|
1456
|
-
this.
|
|
1501
|
+
flipHorizontally(t) {
|
|
1502
|
+
this.Cs.state.Rt(t);
|
|
1457
1503
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1504
|
+
flipVertically(t) {
|
|
1505
|
+
this.Cs.state.Mt(t);
|
|
1460
1506
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1507
|
+
charRotation(t) {
|
|
1508
|
+
this.Cs.state.At(t);
|
|
1463
1509
|
}
|
|
1464
|
-
|
|
1465
|
-
this.
|
|
1510
|
+
invert(t) {
|
|
1511
|
+
this.Cs.state.St(t);
|
|
1466
1512
|
}
|
|
1467
|
-
|
|
1468
|
-
this.
|
|
1513
|
+
clear() {
|
|
1514
|
+
this.Cs.Jt();
|
|
1469
1515
|
}
|
|
1470
|
-
|
|
1471
|
-
this.
|
|
1516
|
+
ellipse(t, e, s, r) {
|
|
1517
|
+
this.Cs.De(t, e, s / 2, r / 2);
|
|
1472
1518
|
}
|
|
1473
|
-
|
|
1474
|
-
this.
|
|
1519
|
+
triangle(t, e, s, r, i, n) {
|
|
1520
|
+
this.Cs.Ie(t, e, s, r, i, n);
|
|
1521
|
+
}
|
|
1522
|
+
bezierCurve(t, e, s, r, i, n, o, h) {
|
|
1523
|
+
this.Cs.Be(t, e, s, r, i, n, o, h);
|
|
1475
1524
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1525
|
+
arc(t, e, s, r, i, n) {
|
|
1526
|
+
this.Cs.Ee(t, e, s, r, i, n);
|
|
1478
1527
|
}
|
|
1479
1528
|
};
|
|
1480
|
-
class
|
|
1481
|
-
|
|
1482
|
-
const e = t.
|
|
1483
|
-
return
|
|
1529
|
+
class B {
|
|
1530
|
+
_i(t) {
|
|
1531
|
+
const e = t.W(0), s = t.W(1), r = t.W(2), i = t.W(3);
|
|
1532
|
+
return { characterPixels: e, primaryColorPixels: s, secondaryColorPixels: r, transformPixels: t.W(4), rotationPixels: i };
|
|
1484
1533
|
}
|
|
1485
|
-
|
|
1534
|
+
mi(t, e) {
|
|
1486
1535
|
return t[e] + (t[e + 1] << 8);
|
|
1487
1536
|
}
|
|
1488
|
-
|
|
1537
|
+
xi(t, e) {
|
|
1489
1538
|
return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
|
|
1490
1539
|
}
|
|
1491
1540
|
}
|
|
1492
|
-
class
|
|
1493
|
-
|
|
1541
|
+
class O {
|
|
1542
|
+
Ci(t, e) {
|
|
1494
1543
|
return new Blob([t], { type: e });
|
|
1495
1544
|
}
|
|
1496
|
-
|
|
1545
|
+
yi(t, e, s) {
|
|
1497
1546
|
try {
|
|
1498
|
-
const
|
|
1499
|
-
|
|
1500
|
-
} catch (
|
|
1501
|
-
throw console.error("Failed to download file:",
|
|
1547
|
+
const r = this.Ci(t, s), i = URL.createObjectURL(r), n = document.createElement("a");
|
|
1548
|
+
n.href = i, n.download = e, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(i);
|
|
1549
|
+
} catch (r) {
|
|
1550
|
+
throw console.error("Failed to download file:", r), Error("File download failed: " + (r instanceof Error ? r.message : "Unknown error"));
|
|
1502
1551
|
}
|
|
1503
1552
|
}
|
|
1504
|
-
|
|
1553
|
+
wi() {
|
|
1505
1554
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
|
|
1506
1555
|
}
|
|
1507
|
-
|
|
1556
|
+
$i() {
|
|
1508
1557
|
const t = /* @__PURE__ */ new Date();
|
|
1509
1558
|
return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
|
|
1510
1559
|
}
|
|
1511
|
-
|
|
1560
|
+
bi(t) {
|
|
1512
1561
|
return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
|
|
1513
1562
|
}
|
|
1514
|
-
|
|
1515
|
-
return "'textmode-export'-" + this.
|
|
1563
|
+
Ti() {
|
|
1564
|
+
return "'textmode-export'-" + this.wi();
|
|
1516
1565
|
}
|
|
1517
1566
|
}
|
|
1518
|
-
class
|
|
1519
|
-
|
|
1520
|
-
const
|
|
1521
|
-
return { isInverted:
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
return { x: t, y: e, cellX: t *
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
const
|
|
1528
|
-
let
|
|
1529
|
-
for (let i = 0; i < e.rows; i++) for (let
|
|
1530
|
-
const
|
|
1531
|
-
let
|
|
1532
|
-
const f = this.
|
|
1567
|
+
class It extends B {
|
|
1568
|
+
zi(t, e, s) {
|
|
1569
|
+
const r = t[s] === 255, i = t[s + 1] === 255, n = t[s + 2] === 255, o = e[s], h = e[s + 1];
|
|
1570
|
+
return { isInverted: r, flipHorizontal: i, flipVertical: n, rotation: Math.round(360 * (o + h / 255) / 255 * 100) / 100 };
|
|
1571
|
+
}
|
|
1572
|
+
Ri(t, e, s) {
|
|
1573
|
+
return { x: t, y: e, cellX: t * s.cellWidth, cellY: e * s.cellHeight };
|
|
1574
|
+
}
|
|
1575
|
+
Mi(t, e) {
|
|
1576
|
+
const s = [];
|
|
1577
|
+
let r = 0;
|
|
1578
|
+
for (let i = 0; i < e.rows; i++) for (let n = 0; n < e.cols; n++) {
|
|
1579
|
+
const o = 4 * r, h = this.mi(t.characterPixels, o);
|
|
1580
|
+
let l = this.xi(t.primaryColorPixels, o), u = this.xi(t.secondaryColorPixels, o);
|
|
1581
|
+
const f = this.zi(t.transformPixels, t.rotationPixels, o);
|
|
1533
1582
|
if (f.isInverted) {
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1583
|
+
const p = l;
|
|
1584
|
+
l = u, u = p;
|
|
1536
1585
|
}
|
|
1537
|
-
const d = this.
|
|
1538
|
-
|
|
1586
|
+
const d = this.Ri(n, i, e);
|
|
1587
|
+
s.push({ charIndex: h, primaryColor: l, secondaryColor: u, transform: f, position: d }), r++;
|
|
1539
1588
|
}
|
|
1540
|
-
return
|
|
1589
|
+
return s;
|
|
1541
1590
|
}
|
|
1542
1591
|
}
|
|
1543
|
-
class
|
|
1544
|
-
|
|
1545
|
-
const
|
|
1546
|
-
for (const
|
|
1547
|
-
|
|
1548
|
-
|
|
1592
|
+
class Dt {
|
|
1593
|
+
Si(t, e) {
|
|
1594
|
+
const s = t.cmap;
|
|
1595
|
+
for (const r of s.tables) if (r.format === 4) {
|
|
1596
|
+
const i = r;
|
|
1597
|
+
for (let n = 0; n < i.startCount.length; n++) if (e >= i.startCount[n] && e <= i.endCount[n]) {
|
|
1598
|
+
if (i.idRangeOffset[n] === 0) return e + i.idDelta[n] & 65535;
|
|
1549
1599
|
{
|
|
1550
|
-
const o =
|
|
1551
|
-
if (o >= 0 && o <
|
|
1552
|
-
const
|
|
1553
|
-
if (
|
|
1600
|
+
const o = i.idRangeOffset[n] / 2 + (e - i.startCount[n]) - (i.startCount.length - n);
|
|
1601
|
+
if (o >= 0 && o < i.glyphIdArray.length) {
|
|
1602
|
+
const h = i.glyphIdArray[o];
|
|
1603
|
+
if (h !== 0) return h + i.idDelta[n] & 65535;
|
|
1554
1604
|
}
|
|
1555
1605
|
}
|
|
1556
1606
|
}
|
|
1607
|
+
} else if (r.format === 12) {
|
|
1608
|
+
const i = r;
|
|
1609
|
+
for (let n = 0; n < i.groups.length; n += 3) {
|
|
1610
|
+
const o = i.groups[n], h = i.groups[n + 1], l = i.groups[n + 2];
|
|
1611
|
+
if (e >= o && e <= h) return l + (e - o);
|
|
1612
|
+
}
|
|
1557
1613
|
}
|
|
1558
1614
|
return 0;
|
|
1559
1615
|
}
|
|
1560
|
-
|
|
1561
|
-
const
|
|
1562
|
-
return { getBoundingBox: () => ({ x1:
|
|
1616
|
+
Ai(t, e, s, r, i) {
|
|
1617
|
+
const n = i / t.head.unitsPerEm;
|
|
1618
|
+
return { getBoundingBox: () => ({ x1: s + e.xMin * n, y1: r + -e.yMax * n, x2: s + e.xMax * n, y2: r + -e.yMin * n }), toSVG: () => this.Pi(e, s, r, n) };
|
|
1563
1619
|
}
|
|
1564
|
-
|
|
1620
|
+
Pi(t, e, s, r) {
|
|
1565
1621
|
if (!t || !t.xs) return "";
|
|
1566
|
-
const { xs: i, ys:
|
|
1567
|
-
if (!(i &&
|
|
1568
|
-
let
|
|
1569
|
-
for (let f = 0; f <
|
|
1570
|
-
const d =
|
|
1622
|
+
const { xs: i, ys: n, endPts: o, flags: h } = t;
|
|
1623
|
+
if (!(i && n && o && h)) return "";
|
|
1624
|
+
let l = "", u = 0;
|
|
1625
|
+
for (let f = 0; f < o.length; f++) {
|
|
1626
|
+
const d = o[f];
|
|
1571
1627
|
if (!(d < u)) {
|
|
1572
1628
|
if (d >= u) {
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1575
|
-
let
|
|
1576
|
-
for (;
|
|
1577
|
-
if (1 &
|
|
1578
|
-
const
|
|
1579
|
-
|
|
1629
|
+
const p = e + i[u] * r, g = s - n[u] * r;
|
|
1630
|
+
l += `M${p.toFixed(2)},${g.toFixed(2)}`;
|
|
1631
|
+
let m = u + 1;
|
|
1632
|
+
for (; m <= d; )
|
|
1633
|
+
if (1 & h[m]) {
|
|
1634
|
+
const T = e + i[m] * r, v = s - n[m] * r;
|
|
1635
|
+
l += `L${T.toFixed(2)},${v.toFixed(2)}`, m++;
|
|
1580
1636
|
} else {
|
|
1581
|
-
const
|
|
1582
|
-
let b =
|
|
1583
|
-
if (1 &
|
|
1584
|
-
const
|
|
1585
|
-
|
|
1637
|
+
const T = e + i[m] * r, v = s - n[m] * r;
|
|
1638
|
+
let b = m + 1 > d ? u : m + 1;
|
|
1639
|
+
if (1 & h[b]) {
|
|
1640
|
+
const _ = e + i[b] * r, S = s - n[b] * r;
|
|
1641
|
+
l += `Q${T.toFixed(2)},${v.toFixed(2)} ${_.toFixed(2)},${S.toFixed(2)}`, m = b + 1;
|
|
1586
1642
|
} else {
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1643
|
+
const _ = (T + (e + i[b] * r)) / 2, S = (v + (s - n[b] * r)) / 2;
|
|
1644
|
+
l += `Q${T.toFixed(2)},${v.toFixed(2)} ${_.toFixed(2)},${S.toFixed(2)}`, m = b;
|
|
1589
1645
|
}
|
|
1590
1646
|
}
|
|
1591
|
-
|
|
1647
|
+
l += "Z";
|
|
1592
1648
|
}
|
|
1593
1649
|
u = d + 1;
|
|
1594
1650
|
}
|
|
1595
1651
|
}
|
|
1596
|
-
return
|
|
1652
|
+
return l;
|
|
1597
1653
|
}
|
|
1598
|
-
|
|
1599
|
-
const
|
|
1600
|
-
let
|
|
1601
|
-
return e.glyf && e.glyf[
|
|
1654
|
+
Fi(t, e, s, r, i) {
|
|
1655
|
+
const n = t.codePointAt(0) || 0, o = this.Si(e, n);
|
|
1656
|
+
let h = null;
|
|
1657
|
+
return e.glyf && e.glyf[o] !== null ? h = e.glyf[o] : (h = E.T.glyf.Oe(e, o), e.glyf[o] = h), this.Ai(e, h, s, r, i);
|
|
1602
1658
|
}
|
|
1603
|
-
|
|
1604
|
-
const
|
|
1605
|
-
return this.
|
|
1659
|
+
Gi(t, e, s, r, i, n, o, h) {
|
|
1660
|
+
const l = s + (i - h * (o / e.head.unitsPerEm)) / 2, u = r + (n + 0.7 * o) / 2;
|
|
1661
|
+
return this.Fi(t, e, l, u, o).toSVG() || null;
|
|
1606
1662
|
}
|
|
1607
1663
|
}
|
|
1608
|
-
class
|
|
1664
|
+
class Lt {
|
|
1609
1665
|
constructor() {
|
|
1610
|
-
|
|
1611
|
-
this.
|
|
1666
|
+
c(this, "Di");
|
|
1667
|
+
this.Di = new Dt();
|
|
1612
1668
|
}
|
|
1613
|
-
|
|
1669
|
+
Ii(t) {
|
|
1614
1670
|
return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
1615
1671
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
1616
1672
|
<svg width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}"
|
|
@@ -1618,175 +1674,173 @@ class Tt {
|
|
|
1618
1674
|
<title>textmode art generated via textmode.js</title>
|
|
1619
1675
|
<desc>textmode art visualization generated by textmode.js library</desc>`;
|
|
1620
1676
|
}
|
|
1621
|
-
|
|
1677
|
+
Bi() {
|
|
1622
1678
|
return `
|
|
1623
1679
|
</g>
|
|
1624
1680
|
</svg>`;
|
|
1625
1681
|
}
|
|
1626
|
-
|
|
1682
|
+
Li(t, e) {
|
|
1627
1683
|
if (!e.includeBackgroundRectangles) return "";
|
|
1628
|
-
const
|
|
1684
|
+
const s = e.backgroundColor, r = `rgba(${s[0]},${s[1]},${s[2]},${s[3] / 255})`;
|
|
1629
1685
|
return `
|
|
1630
|
-
<rect width="${t.width}" height="${t.height}" fill="${
|
|
1686
|
+
<rect width="${t.width}" height="${t.height}" fill="${r}" />`;
|
|
1631
1687
|
}
|
|
1632
|
-
|
|
1688
|
+
Ei(t) {
|
|
1633
1689
|
return `rgba(${t.r},${t.g},${t.b},${t.a / 255})`;
|
|
1634
1690
|
}
|
|
1635
|
-
|
|
1636
|
-
const { transform:
|
|
1637
|
-
if (
|
|
1638
|
-
const
|
|
1639
|
-
|
|
1691
|
+
Wi(t, e) {
|
|
1692
|
+
const { transform: s, position: r } = t, i = r.cellX + e.cellWidth / 2, n = r.cellY + e.cellHeight / 2, o = [];
|
|
1693
|
+
if (s.flipHorizontal || s.flipVertical) {
|
|
1694
|
+
const h = s.flipHorizontal ? -1 : 1, l = s.flipVertical ? -1 : 1;
|
|
1695
|
+
o.push(`translate(${i} ${n})`), o.push(`scale(${h} ${l})`), o.push(`translate(${-i} ${-n})`);
|
|
1640
1696
|
}
|
|
1641
|
-
return
|
|
1697
|
+
return s.rotation && o.push(`rotate(${s.rotation} ${i} ${n})`), o.length ? ` transform="${o.join(" ")}"` : "";
|
|
1642
1698
|
}
|
|
1643
|
-
|
|
1644
|
-
if (!
|
|
1645
|
-
const { position:
|
|
1646
|
-
return
|
|
1647
|
-
<rect x="${
|
|
1648
|
-
<rect x="${
|
|
1699
|
+
ki(t, e, s) {
|
|
1700
|
+
if (!s.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
|
|
1701
|
+
const { position: r } = t, i = this.Ei(t.secondaryColor);
|
|
1702
|
+
return s.drawMode === "stroke" ? `
|
|
1703
|
+
<rect x="${r.cellX}" y="${r.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${i}" fill="none" stroke-width="${s.strokeWidth}" />` : `
|
|
1704
|
+
<rect x="${r.cellX}" y="${r.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${i}" />`;
|
|
1649
1705
|
}
|
|
1650
|
-
|
|
1651
|
-
const i =
|
|
1706
|
+
Fi(t, e, s, r) {
|
|
1707
|
+
const i = s.characters[t.charIndex];
|
|
1652
1708
|
if (!i) return "";
|
|
1653
|
-
const
|
|
1654
|
-
if (!
|
|
1655
|
-
const
|
|
1656
|
-
return
|
|
1657
|
-
<path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${
|
|
1658
|
-
<path d="${
|
|
1709
|
+
const n = this.Di.Gi(i.character, s.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, s.fontSize, i.advanceWidth);
|
|
1710
|
+
if (!n) return "";
|
|
1711
|
+
const o = this.Ei(t.primaryColor);
|
|
1712
|
+
return r.drawMode === "stroke" ? `
|
|
1713
|
+
<path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${n}" stroke="${o}" stroke-width="${r.strokeWidth}" fill="none" />` : `
|
|
1714
|
+
<path d="${n}" fill="${o}" />`;
|
|
1659
1715
|
}
|
|
1660
|
-
|
|
1716
|
+
Vi(t, e, s, r) {
|
|
1661
1717
|
let i = "";
|
|
1662
|
-
i += this.
|
|
1663
|
-
const
|
|
1664
|
-
return
|
|
1665
|
-
<g${
|
|
1666
|
-
</g>`) : i +=
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
let i = this.
|
|
1670
|
-
i += this.
|
|
1718
|
+
i += this.ki(t, e, r);
|
|
1719
|
+
const n = this.Wi(t, e), o = this.Fi(t, e, s, r);
|
|
1720
|
+
return o && (n ? (i += `
|
|
1721
|
+
<g${n}>`, i += o, i += `
|
|
1722
|
+
</g>`) : i += o), i;
|
|
1723
|
+
}
|
|
1724
|
+
Oi(t, e, s, r) {
|
|
1725
|
+
let i = this.Ii(e);
|
|
1726
|
+
i += this.Li(e, r), i += `
|
|
1671
1727
|
<g id="ascii-cells">`;
|
|
1672
|
-
for (const
|
|
1673
|
-
return i += this.
|
|
1728
|
+
for (const n of t) i += this.Vi(n, e, s, r);
|
|
1729
|
+
return i += this.Bi(), i;
|
|
1674
1730
|
}
|
|
1675
|
-
|
|
1731
|
+
Ui(t) {
|
|
1676
1732
|
return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\n\s*\n/g, `
|
|
1677
1733
|
`).replace(/[ \t]+$/gm, "");
|
|
1678
1734
|
}
|
|
1679
1735
|
}
|
|
1680
|
-
class
|
|
1681
|
-
|
|
1682
|
-
return this.
|
|
1736
|
+
class Mt extends O {
|
|
1737
|
+
ji(t) {
|
|
1738
|
+
return this.Ci(t, "image/svg+xml;charset=utf-8");
|
|
1683
1739
|
}
|
|
1684
|
-
|
|
1685
|
-
this.
|
|
1740
|
+
Hi(t, e) {
|
|
1741
|
+
this.yi(t, this.bi(e) + ".svg", "image/svg+xml;charset=utf-8");
|
|
1686
1742
|
}
|
|
1687
|
-
|
|
1688
|
-
this.
|
|
1743
|
+
qi(t, e) {
|
|
1744
|
+
this.Hi(t, e || this.Ti());
|
|
1689
1745
|
}
|
|
1690
1746
|
}
|
|
1691
|
-
class
|
|
1747
|
+
class N {
|
|
1692
1748
|
constructor() {
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
this.
|
|
1749
|
+
c(this, "Ni");
|
|
1750
|
+
c(this, "Xi");
|
|
1751
|
+
c(this, "Yi");
|
|
1752
|
+
this.Ni = new It(), this.Xi = new Lt(), this.Yi = new Mt();
|
|
1697
1753
|
}
|
|
1698
|
-
|
|
1699
|
-
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0] };
|
|
1754
|
+
Qi(t) {
|
|
1755
|
+
return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.Yi.Ti() };
|
|
1700
1756
|
}
|
|
1701
|
-
|
|
1702
|
-
const
|
|
1703
|
-
return this.
|
|
1757
|
+
Zi(t, e = {}) {
|
|
1758
|
+
const s = this.Ni.Mi(this.Ni._i(t.pipeline), t.grid), r = this.Xi.Oi(s, t.grid, t.font, this.Qi(e));
|
|
1759
|
+
return this.Xi.Ui(r);
|
|
1704
1760
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
this.$s.bs(r, s);
|
|
1761
|
+
qi(t, e = {}) {
|
|
1762
|
+
this.Yi.qi(this.Zi(t, e), e.filename);
|
|
1708
1763
|
}
|
|
1709
1764
|
}
|
|
1710
|
-
class
|
|
1711
|
-
|
|
1712
|
-
var
|
|
1765
|
+
class Ut extends B {
|
|
1766
|
+
Ji(t, e, s, r = " ") {
|
|
1767
|
+
var o;
|
|
1713
1768
|
const i = [];
|
|
1714
|
-
let
|
|
1715
|
-
for (let
|
|
1716
|
-
const
|
|
1769
|
+
let n = 0;
|
|
1770
|
+
for (let h = 0; h < e.rows; h++) {
|
|
1771
|
+
const l = [];
|
|
1717
1772
|
for (let u = 0; u < e.cols; u++) {
|
|
1718
|
-
const f = 4 *
|
|
1719
|
-
|
|
1773
|
+
const f = 4 * n, d = this.mi(t.characterPixels, f), p = ((o = s.characters[d]) == null ? void 0 : o.character) || r;
|
|
1774
|
+
l.push(p), n++;
|
|
1720
1775
|
}
|
|
1721
|
-
i.push(
|
|
1776
|
+
i.push(l);
|
|
1722
1777
|
}
|
|
1723
1778
|
return i;
|
|
1724
1779
|
}
|
|
1725
1780
|
}
|
|
1726
|
-
class
|
|
1727
|
-
|
|
1728
|
-
const
|
|
1781
|
+
class zt {
|
|
1782
|
+
Ki(t, e) {
|
|
1783
|
+
const s = [];
|
|
1729
1784
|
for (const i of t) {
|
|
1730
|
-
let
|
|
1731
|
-
e.preserveTrailingSpaces || (
|
|
1785
|
+
let n = i.join("");
|
|
1786
|
+
e.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")), s.push(n);
|
|
1732
1787
|
}
|
|
1733
|
-
const
|
|
1788
|
+
const r = e.lineEnding === "crlf" ? `\r
|
|
1734
1789
|
` : `
|
|
1735
1790
|
`;
|
|
1736
|
-
return
|
|
1791
|
+
return s.join(r);
|
|
1737
1792
|
}
|
|
1738
1793
|
}
|
|
1739
|
-
class
|
|
1740
|
-
|
|
1741
|
-
const
|
|
1742
|
-
this.
|
|
1794
|
+
class Bt extends O {
|
|
1795
|
+
tr(t, e) {
|
|
1796
|
+
const s = this.er(e);
|
|
1797
|
+
this.yi(t, s, "text/plain;charset=utf-8");
|
|
1743
1798
|
}
|
|
1744
|
-
|
|
1745
|
-
let e = this.
|
|
1746
|
-
return e === ".txt" || e.length <= 4 ? this.
|
|
1799
|
+
er(t) {
|
|
1800
|
+
let e = this.bi(t);
|
|
1801
|
+
return e === ".txt" || e.length <= 4 ? this.Ti() : e;
|
|
1747
1802
|
}
|
|
1748
1803
|
}
|
|
1749
|
-
class
|
|
1804
|
+
class V {
|
|
1750
1805
|
constructor() {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
this.
|
|
1806
|
+
c(this, "Ni");
|
|
1807
|
+
c(this, "Xi");
|
|
1808
|
+
c(this, "Yi");
|
|
1809
|
+
this.Ni = new Ut(), this.Xi = new zt(), this.Yi = new Bt();
|
|
1755
1810
|
}
|
|
1756
|
-
|
|
1757
|
-
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " " };
|
|
1811
|
+
Qi(t) {
|
|
1812
|
+
return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.Yi.Ti() };
|
|
1758
1813
|
}
|
|
1759
|
-
|
|
1760
|
-
const
|
|
1761
|
-
return this.
|
|
1814
|
+
sr(t, e = {}) {
|
|
1815
|
+
const s = this.Qi(e), r = this.Ni.Ji(this.Ni._i(t.pipeline), t.grid, t.font, s.emptyCharacter);
|
|
1816
|
+
return this.Xi.Ki(r, s);
|
|
1762
1817
|
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
this.$s.Ss(r, s);
|
|
1818
|
+
tr(t, e = {}) {
|
|
1819
|
+
this.Yi.tr(this.sr(t, e), e.filename);
|
|
1766
1820
|
}
|
|
1767
1821
|
}
|
|
1768
|
-
class
|
|
1769
|
-
|
|
1770
|
-
const
|
|
1771
|
-
if (e === 1 &&
|
|
1772
|
-
const i = document.createElement("canvas"),
|
|
1773
|
-
return i.width =
|
|
1822
|
+
class Ot extends B {
|
|
1823
|
+
ir(t, e = 1, s = "transparent") {
|
|
1824
|
+
const r = t.canvas;
|
|
1825
|
+
if (e === 1 && s === "transparent") return r;
|
|
1826
|
+
const i = document.createElement("canvas"), n = i.getContext("2d"), o = Math.round(r.width * e), h = Math.round(r.height * e);
|
|
1827
|
+
return i.width = o, i.height = h, s !== "transparent" && (n.fillStyle = s, n.fillRect(0, 0, o, h)), n.imageSmoothingEnabled = !1, n.drawImage(r, 0, 0, r.width, r.height, 0, 0, o, h), i;
|
|
1774
1828
|
}
|
|
1775
1829
|
}
|
|
1776
|
-
class
|
|
1777
|
-
|
|
1778
|
-
const
|
|
1779
|
-
return e.format === "png" ? t.toDataURL(
|
|
1780
|
-
}
|
|
1781
|
-
async
|
|
1782
|
-
return new Promise((
|
|
1783
|
-
const i = this.
|
|
1784
|
-
|
|
1830
|
+
class $t {
|
|
1831
|
+
rr(t, e) {
|
|
1832
|
+
const s = this.nr(e.format);
|
|
1833
|
+
return e.format === "png" ? t.toDataURL(s) : t.toDataURL(s, e.quality);
|
|
1834
|
+
}
|
|
1835
|
+
async ar(t, e) {
|
|
1836
|
+
return new Promise((s, r) => {
|
|
1837
|
+
const i = this.nr(e.format), n = (o) => {
|
|
1838
|
+
o ? s(o) : r(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
|
|
1785
1839
|
};
|
|
1786
|
-
e.format === "png" ? t.toBlob(
|
|
1840
|
+
e.format === "png" ? t.toBlob(n, i) : t.toBlob(n, i, e.quality);
|
|
1787
1841
|
});
|
|
1788
1842
|
}
|
|
1789
|
-
|
|
1843
|
+
nr(t) {
|
|
1790
1844
|
switch (t) {
|
|
1791
1845
|
case "png":
|
|
1792
1846
|
return "image/png";
|
|
@@ -1799,273 +1853,208 @@ class At {
|
|
|
1799
1853
|
}
|
|
1800
1854
|
}
|
|
1801
1855
|
}
|
|
1802
|
-
const
|
|
1803
|
-
class
|
|
1804
|
-
|
|
1805
|
-
this.
|
|
1856
|
+
const Wt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, k = { png: ".png", jpg: ".jpg", webp: ".webp" };
|
|
1857
|
+
class Gt extends O {
|
|
1858
|
+
hr(t, e, s) {
|
|
1859
|
+
this.cr(t, this.bi(e) + k[s]);
|
|
1806
1860
|
}
|
|
1807
|
-
|
|
1808
|
-
const
|
|
1861
|
+
cr(t, e) {
|
|
1862
|
+
const s = URL.createObjectURL(t);
|
|
1809
1863
|
try {
|
|
1810
|
-
const
|
|
1811
|
-
|
|
1864
|
+
const r = document.createElement("a");
|
|
1865
|
+
r.href = s, r.download = e, r.style.display = "none", r.rel = "noopener", document.body.appendChild(r), r.click(), document.body.removeChild(r);
|
|
1812
1866
|
} finally {
|
|
1813
|
-
URL.revokeObjectURL(
|
|
1867
|
+
URL.revokeObjectURL(s);
|
|
1814
1868
|
}
|
|
1815
1869
|
}
|
|
1816
|
-
|
|
1817
|
-
return t in
|
|
1870
|
+
lr(t) {
|
|
1871
|
+
return t in Wt && t in k;
|
|
1818
1872
|
}
|
|
1819
1873
|
}
|
|
1820
|
-
class
|
|
1874
|
+
class Nt {
|
|
1821
1875
|
constructor() {
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
this.
|
|
1876
|
+
c(this, "Ni");
|
|
1877
|
+
c(this, "Xi");
|
|
1878
|
+
c(this, "Yi");
|
|
1879
|
+
this.Ni = new Ot(), this.Xi = new $t(), this.Yi = new Gt();
|
|
1826
1880
|
}
|
|
1827
|
-
|
|
1828
|
-
return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent" };
|
|
1881
|
+
Qi(t) {
|
|
1882
|
+
return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.Yi.Ti() };
|
|
1829
1883
|
}
|
|
1830
|
-
|
|
1831
|
-
if (
|
|
1884
|
+
ur(t) {
|
|
1885
|
+
if (!this.Yi.lr(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
|
|
1832
1886
|
if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
|
|
1833
1887
|
if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
|
|
1834
|
-
t.
|
|
1835
|
-
}
|
|
1836
|
-
Ls(t, e = {}) {
|
|
1837
|
-
const r = this.Fs(e);
|
|
1838
|
-
if (this.Us(r), r.scale === 1 && r.backgroundColor === "transparent") return this.Cs.Is(t.canvas, r);
|
|
1839
|
-
const s = this.ws.ks(t, r.scale, r.backgroundColor);
|
|
1840
|
-
return this.Cs.Is(s, r);
|
|
1888
|
+
t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
|
|
1841
1889
|
}
|
|
1842
|
-
async
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
return await this.Cs.zs(s, r);
|
|
1890
|
+
async ar(t, e) {
|
|
1891
|
+
if (e.scale === 1 && e.backgroundColor === "transparent") return await this.Xi.ar(t.canvas, e);
|
|
1892
|
+
const s = this.Ni.ir(t, e.scale, e.backgroundColor);
|
|
1893
|
+
return await this.Xi.ar(s, e);
|
|
1847
1894
|
}
|
|
1848
|
-
async
|
|
1849
|
-
const
|
|
1850
|
-
this
|
|
1895
|
+
async hr(t, e = {}) {
|
|
1896
|
+
const s = this.Qi(e);
|
|
1897
|
+
this.ur(s);
|
|
1898
|
+
const r = await this.ar(t, s);
|
|
1899
|
+
this.Yi.hr(r, s.filename, s.format);
|
|
1851
1900
|
}
|
|
1852
1901
|
}
|
|
1853
|
-
const
|
|
1902
|
+
const Vt = (a) => class extends a {
|
|
1903
|
+
dr() {
|
|
1904
|
+
this.Cs.Ve(this.pr);
|
|
1905
|
+
}
|
|
1854
1906
|
toString(t = {}) {
|
|
1855
|
-
return new
|
|
1907
|
+
return this.dr(), new V().sr({ pipeline: this.gr, grid: this._r, font: this.Ps }, t);
|
|
1856
1908
|
}
|
|
1857
1909
|
saveStrings(t = {}) {
|
|
1858
|
-
new
|
|
1910
|
+
this.dr(), new V().tr({ pipeline: this.gr, grid: this._r, font: this.Ps }, t);
|
|
1859
1911
|
}
|
|
1860
1912
|
toSVG(t = {}) {
|
|
1861
|
-
return new
|
|
1913
|
+
return this.dr(), new N().Zi(this, t);
|
|
1862
1914
|
}
|
|
1863
1915
|
saveSVG(t = {}) {
|
|
1864
|
-
new
|
|
1916
|
+
this.dr(), new N().qi(this, t);
|
|
1865
1917
|
}
|
|
1866
|
-
async saveCanvas(t
|
|
1867
|
-
await new
|
|
1918
|
+
async saveCanvas(t = {}) {
|
|
1919
|
+
await new Nt().hr(this.Js, t);
|
|
1868
1920
|
}
|
|
1869
|
-
},
|
|
1921
|
+
}, kt = (a) => class extends a {
|
|
1870
1922
|
async loadFont(t) {
|
|
1871
|
-
return this.
|
|
1872
|
-
const e = this.
|
|
1873
|
-
this.
|
|
1923
|
+
return this.Ps.Ns(t).then(() => {
|
|
1924
|
+
const e = this.Ps.maxGlyphDimensions;
|
|
1925
|
+
this._r.ei(e.width, e.height), this.Cs.ke();
|
|
1874
1926
|
});
|
|
1875
1927
|
}
|
|
1876
1928
|
fontSize(t) {
|
|
1877
|
-
if (!
|
|
1878
|
-
this.
|
|
1879
|
-
const e = this.
|
|
1880
|
-
this.
|
|
1929
|
+
if (!I._(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ps.fontSize === t) return;
|
|
1930
|
+
this.Ps.qs(t);
|
|
1931
|
+
const e = this.Ps.maxGlyphDimensions;
|
|
1932
|
+
this._r.ei(e.width, e.height), this.Cs.ke();
|
|
1881
1933
|
}
|
|
1882
|
-
},
|
|
1883
|
-
|
|
1884
|
-
return this.
|
|
1885
|
-
}
|
|
1886
|
-
removeConverter(t) {
|
|
1887
|
-
this.Hs.remove(t);
|
|
1888
|
-
}
|
|
1889
|
-
};
|
|
1890
|
-
class Lt {
|
|
1891
|
-
constructor() {
|
|
1892
|
-
h(this, "ve");
|
|
1893
|
-
h(this, "Te");
|
|
1894
|
-
h(this, "Hs");
|
|
1895
|
-
h(this, "Ye");
|
|
1896
|
-
h(this, "dr");
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
class X extends function(e, ...r) {
|
|
1900
|
-
return r.reduce((s, i) => i(s), e);
|
|
1901
|
-
}(Lt, Ct, $t, It, kt) {
|
|
1902
|
-
constructor(e = null, r = {}) {
|
|
1903
|
-
super();
|
|
1904
|
-
h(this, "ir");
|
|
1905
|
-
h(this, "js");
|
|
1906
|
-
h(this, "ar");
|
|
1907
|
-
h(this, "Os");
|
|
1908
|
-
h(this, "Bs");
|
|
1909
|
-
h(this, "Ws", null);
|
|
1910
|
-
h(this, "Ns", 0);
|
|
1911
|
-
h(this, "Xs");
|
|
1912
|
-
h(this, "qs", !0);
|
|
1913
|
-
h(this, "Ys", 0);
|
|
1914
|
-
h(this, "Qs", 0);
|
|
1915
|
-
h(this, "Zs", 0);
|
|
1916
|
-
h(this, "Js", []);
|
|
1917
|
-
h(this, "Ks", 10);
|
|
1918
|
-
h(this, "ti", !1);
|
|
1919
|
-
h(this, "ei", !1);
|
|
1920
|
-
h(this, "ri", () => {
|
|
1921
|
-
});
|
|
1922
|
-
h(this, "si", () => {
|
|
1923
|
-
});
|
|
1924
|
-
h(this, "ii");
|
|
1925
|
-
this.ir = e, this.ei = e === null, this.Os = r.renderMode ?? "auto", this.Bs = r.frameRate ?? 60, this.Xs = 1e3 / this.Bs;
|
|
1934
|
+
}, Xt = (a) => class extends a {
|
|
1935
|
+
get frameCount() {
|
|
1936
|
+
return this.mr.frameCount;
|
|
1926
1937
|
}
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
let o, n;
|
|
1930
|
-
s.Ye = new vt(s.ir, s.ei, i), s.ve = new ot(s.Ye.cr()), s.ei ? (o = r.width || 800, n = r.height || 600) : (o = s.Ye.width || 800, n = s.Ye.height || 600), s.js = s.ve.Lt(o, n), s.Te = new pt(s.ve, r.fontSize ?? 16), await s.Te.Ue(r.fontSource);
|
|
1931
|
-
const l = s.Te.maxGlyphDimensions;
|
|
1932
|
-
return s.dr = new mt(s.Ye.canvas, l.width, l.height), s.Hs = new wt(s.ve, s.Te, s.dr), s.oi(), s.ni(), s;
|
|
1938
|
+
set frameCount(t) {
|
|
1939
|
+
this.mr.frameCount = t;
|
|
1933
1940
|
}
|
|
1934
|
-
|
|
1935
|
-
this.
|
|
1936
|
-
this.ei ? this.si() : this.ai();
|
|
1937
|
-
}, window.addEventListener("resize", this.ii), window.ResizeObserver && this.ir && !this.ei && (this.ar = new ResizeObserver(() => {
|
|
1938
|
-
this.ai();
|
|
1939
|
-
}), this.ar.observe(this.ir));
|
|
1941
|
+
frameRate(t) {
|
|
1942
|
+
return t === void 0 ? this.mr.currentFrameRate : this.mr.frameRate(t, () => this.vr());
|
|
1940
1943
|
}
|
|
1941
|
-
|
|
1942
|
-
this.
|
|
1944
|
+
noLoop() {
|
|
1945
|
+
this.mr.pause();
|
|
1943
1946
|
}
|
|
1944
|
-
|
|
1945
|
-
this.
|
|
1947
|
+
loop() {
|
|
1948
|
+
this.mr.resume(() => this.vr());
|
|
1946
1949
|
}
|
|
1947
|
-
|
|
1948
|
-
if (
|
|
1949
|
-
this.Ns = performance.now();
|
|
1950
|
-
const e = (r) => {
|
|
1951
|
-
if (!this.qs) return void (this.Ws = null);
|
|
1952
|
-
const s = r - this.Ns;
|
|
1953
|
-
s >= this.Xs && (this.render(), this.Ns = r - s % this.Xs), this.qs && (this.Ws = requestAnimationFrame(e));
|
|
1954
|
-
};
|
|
1955
|
-
this.Ws = requestAnimationFrame(e);
|
|
1956
|
-
}
|
|
1957
|
-
hi() {
|
|
1958
|
-
const e = performance.now();
|
|
1959
|
-
if (this.Qs > 0) {
|
|
1960
|
-
const r = e - this.Qs;
|
|
1961
|
-
this.Js.push(r), this.Js.length > this.Ks && this.Js.shift();
|
|
1962
|
-
const s = this.Js.reduce((i, o) => i + o, 0) / this.Js.length;
|
|
1963
|
-
this.Ys = 1e3 / s;
|
|
1964
|
-
}
|
|
1965
|
-
this.Qs = e;
|
|
1950
|
+
redraw(t = 1) {
|
|
1951
|
+
if (I._(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.vr();
|
|
1966
1952
|
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1953
|
+
isLooping() {
|
|
1954
|
+
return this.mr.isLooping;
|
|
1969
1955
|
}
|
|
1970
|
-
|
|
1971
|
-
|
|
1956
|
+
};
|
|
1957
|
+
class Yt {
|
|
1958
|
+
constructor() {
|
|
1959
|
+
c(this, "Cs");
|
|
1960
|
+
c(this, "Ps");
|
|
1961
|
+
c(this, "Js");
|
|
1962
|
+
c(this, "_r");
|
|
1963
|
+
c(this, "mr");
|
|
1964
|
+
c(this, "pr");
|
|
1965
|
+
c(this, "gr");
|
|
1966
|
+
c(this, "Cr");
|
|
1972
1967
|
}
|
|
1973
|
-
|
|
1974
|
-
if (e === void 0) return this.Ys;
|
|
1975
|
-
this.Bs = e, this.Xs = 1e3 / e, this.Os === "auto" && this.qs && (this.li(), this.ni());
|
|
1968
|
+
vr() {
|
|
1976
1969
|
}
|
|
1977
|
-
|
|
1978
|
-
|
|
1970
|
+
}
|
|
1971
|
+
class jt extends function(e, ...s) {
|
|
1972
|
+
return s.reduce((r, i) => i(r), e);
|
|
1973
|
+
}(Yt, St, Vt, kt, Xt) {
|
|
1974
|
+
constructor(e = {}) {
|
|
1975
|
+
super();
|
|
1976
|
+
c(this, "yr", !1);
|
|
1977
|
+
c(this, "wr", () => {
|
|
1978
|
+
});
|
|
1979
|
+
c(this, "$r", () => {
|
|
1980
|
+
});
|
|
1981
|
+
c(this, "br");
|
|
1982
|
+
this.Js = new Pt(e), this.Cs = new mt(this.Js.ni()), this.Ps = new At(this.Cs, e.fontSize ?? 16), this.mr = new Ft(e.frameRate ?? 60), this.pr = this.Cs.Ae(`#version 300 es
|
|
1983
|
+
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 float 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 u_aspectRatio;uniform vec2 u_viewportSize;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}vec2 evaluateBezier(float t,vec2 p0,vec2 p1,vec2 p2,vec2 p3){float oneMinusT=1.0-t;float oneMinusT2=oneMinusT*oneMinusT;float oneMinusT3=oneMinusT2*oneMinusT;float t2=t*t;float t3=t2*t;return oneMinusT3*p0+3.0*oneMinusT2*t*p1+3.0*oneMinusT*t2*p2+t3*p3;}vec2 evaluateBezierDerivative(float t,vec2 p0,vec2 p1,vec2 p2,vec2 p3){float oneMinusT=1.0-t;float oneMinusT2=oneMinusT*oneMinusT;float t2=t*t;return-3.0*oneMinusT2*p0+3.0*oneMinusT2*p1-6.0*oneMinusT*t*p1+6.0*oneMinusT*t*p2-3.0*t2*p2+3.0*t2*p3;}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 worldPosition;bool isBezierCurve=length(a_instanceBezierCP1)>0.0||length(a_instanceBezierCP2)>0.0||length(a_instanceBezierStart)>0.0||length(a_instanceBezierEnd)>0.0;bool isArc=a_instanceArcAngles.x!=0.0||a_instanceArcAngles.y!=0.0;if(isBezierCurve){float t=a_position.x;float thicknessOffset=a_position.y;vec2 curvePoint=evaluateBezier(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 tangent=evaluateBezierDerivative(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float tangentLength=length(tangent);if(tangentLength>0.0){tangent=tangent/tangentLength;}else{tangent=vec2(1.0,0.0);}vec2 normal=vec2(-tangent.y,tangent.x);float thickness=a_instanceSize.y;vec2 thicknessVector=normal*thicknessOffset*thickness;worldPosition=curvePoint+thicknessVector;}else if(isArc){float startA=a_instanceArcAngles.x;float stopA=a_instanceArcAngles.y;float TWO_PI=6.28318530718;startA=mod(startA,TWO_PI);if(startA<0.0)startA+=TWO_PI;stopA=mod(stopA,TWO_PI);if(stopA<0.0)stopA+=TWO_PI;float cwDelta=startA-stopA;if(cwDelta<=0.0)cwDelta+=TWO_PI;float angle=startA-a_position.x*cwDelta;float r=a_position.y;vec2 local=vec2(cos(angle),sin(angle))*r;vec2 scaledPosition=local*a_instanceSize*0.5+vec2(a_instanceSize.x*0.5,a_instanceSize.y*0.5);worldPosition=scaledPosition+a_instancePosition;}else{vec2 scaledPosition=a_position*a_instanceSize;worldPosition=scaledPosition+a_instancePosition;}vec2 ndc=(worldPosition/u_viewportSize)*2.0-1.0;ndc.y=-ndc.y;if(a_instanceGlobalRotation!=0.0){ndc-=a_instanceRotationCenter;ndc.x*=u_aspectRatio;ndc=rotate2D(-a_instanceGlobalRotation)*ndc;ndc.x/=u_aspectRatio;ndc+=a_instanceRotationCenter;}gl_Position=vec4(ndc,0.0,1.0);}`, `#version 300 es
|
|
1984
|
+
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.0);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.0,1.0);o_transform=vec4(v_transform,1.0);}`), this.Cr = this.Cs.Ae("attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.0,1.0);}", "precision mediump float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D u_primaryColorTexture;uniform sampler2D u_secondaryColorTexture;uniform sampler2D u_transformTexture;uniform sampler2D u_asciiCharacterTexture;uniform sampler2D u_rotationTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;uniform vec2 u_gridOffsetPixels;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){vec2 adjustedCoord=(gl_FragCoord.xy-u_gridOffsetPixels)/u_gridPixelDimensions;vec2 gridCoord=adjustedCoord*u_gridCellDimensions;vec2 cellCoord=floor(gridCoord);vec2 charIndexTexCoord=(cellCoord+0.5)/u_gridCellDimensions;vec4 primaryColor=texture2D(u_primaryColorTexture,charIndexTexCoord);vec4 secondaryColor=texture2D(u_secondaryColorTexture,charIndexTexCoord);vec4 transformColor=texture2D(u_transformTexture,charIndexTexCoord);bool isInverted=transformColor.r>0.5;bool flipHorizontal=transformColor.g>0.5;bool flipVertical=transformColor.b>0.5;vec4 encodedIndexVec=texture2D(u_asciiCharacterTexture,charIndexTexCoord);int charIndex=int(encodedIndexVec.r*255.0+0.5)+int(encodedIndexVec.g*255.0+0.5)*256;int charCol=int(mod(float(charIndex),u_charsetDimensions.x));int charRow=charIndex/int(u_charsetDimensions.x);float flippedRow=(u_charsetDimensions.y-1.0)-float(charRow);vec2 charCoord=vec2(float(charCol),flippedRow)/u_charsetDimensions;vec4 rotationColor=texture2D(u_rotationTexture,charIndexTexCoord);float scaledAngle=rotationColor.r*255.0+rotationColor.g;float rotationAngle=-(scaledAngle*360.0/255.0)*0.017453292;vec2 fractionalPart=fract(gridCoord)-0.5;if(flipHorizontal)fractionalPart.x=-fractionalPart.x;if(flipVertical)fractionalPart.y=-fractionalPart.y;fractionalPart=rotate2D(rotationAngle)*fractionalPart+0.5;vec2 cellSize=1.0/u_charsetDimensions;vec2 texCoord=charCoord+fractionalPart*cellSize;vec2 cellMax=charCoord+cellSize;if(any(lessThan(texCoord,charCoord))||any(greaterThan(texCoord,cellMax))){gl_FragColor=isInverted ? primaryColor : secondaryColor;return;}vec4 charTexel=texture2D(u_characterTexture,texCoord);if(isInverted)charTexel.rgb=1.0-charTexel.rgb;gl_FragColor=mix(secondaryColor,primaryColor,charTexel);}");
|
|
1979
1985
|
}
|
|
1980
|
-
|
|
1981
|
-
|
|
1986
|
+
static async create(e = {}) {
|
|
1987
|
+
const s = new this(e);
|
|
1988
|
+
await s.Ps.Us(e.fontSource);
|
|
1989
|
+
const r = s.Ps.maxGlyphDimensions;
|
|
1990
|
+
return s._r = new wt(s.Js.canvas, r.width, r.height), s.gr = s.Cs.Le(s._r.cols, s._r.rows, 5), s.Tr(), s.mr.start(() => s.vr()), s;
|
|
1982
1991
|
}
|
|
1983
|
-
|
|
1984
|
-
|
|
1992
|
+
Tr() {
|
|
1993
|
+
this.br = () => {
|
|
1994
|
+
this.$r();
|
|
1995
|
+
}, window.addEventListener("resize", this.br);
|
|
1985
1996
|
}
|
|
1986
|
-
|
|
1987
|
-
|
|
1997
|
+
vr() {
|
|
1998
|
+
this.mr.measureFrameRate(), this.mr.incrementFrame(), this.yr || (this.gr.V(), this.Cs.Se(this.pr), this.wr(), this.Cs.Ve(this.pr), this.gr.O(), this.Cs.We(0), this.Cs.Se(this.Cr), this.Cr.et({ u_characterTexture: this.Ps.fontFramebuffer, u_charsetDimensions: [this.Ps.textureColumns, this.Ps.textureRows], u_asciiCharacterTexture: this.gr.textures[0], u_primaryColorTexture: this.gr.textures[1], u_secondaryColorTexture: this.gr.textures[2], u_transformTexture: this.gr.textures[4], u_rotationTexture: this.gr.textures[3], u_gridCellDimensions: [this._r.cols, this._r.rows], u_gridPixelDimensions: [this._r.width, this._r.height], u_gridOffsetPixels: [this._r.offsetX, this._r.offsetY], u_aspectRatio: this._r.width / this._r.height }), this.Cs.Pe(this._r.offsetX, this._r.offsetY, this._r.width, this._r.height));
|
|
1988
1999
|
}
|
|
1989
2000
|
draw(e) {
|
|
1990
|
-
this.
|
|
2001
|
+
this.wr = e;
|
|
1991
2002
|
}
|
|
1992
2003
|
windowResized(e) {
|
|
1993
|
-
this
|
|
2004
|
+
this.$r = e;
|
|
1994
2005
|
}
|
|
1995
|
-
resizeCanvas(e,
|
|
1996
|
-
this.
|
|
2006
|
+
resizeCanvas(e, s) {
|
|
2007
|
+
this.Js.L(e, s), this._r.Ct(), this.gr.L(this._r.cols, this._r.rows), this.Cs.ke(), this.vr();
|
|
1997
2008
|
}
|
|
1998
2009
|
destroy() {
|
|
1999
|
-
this.
|
|
2010
|
+
this.yr || (this.mr.stop(), window.removeEventListener("resize", this.br), this.Ps.U(), this.Cs.U(), this.yr = !0);
|
|
2000
2011
|
}
|
|
2001
2012
|
get grid() {
|
|
2002
|
-
return this.
|
|
2013
|
+
return this._r;
|
|
2003
2014
|
}
|
|
2004
2015
|
get font() {
|
|
2005
|
-
return this.
|
|
2006
|
-
}
|
|
2007
|
-
get mode() {
|
|
2008
|
-
return this.Os;
|
|
2009
|
-
}
|
|
2010
|
-
get pipeline() {
|
|
2011
|
-
return this.Hs;
|
|
2012
|
-
}
|
|
2013
|
-
get frameCount() {
|
|
2014
|
-
return this.Zs;
|
|
2015
|
-
}
|
|
2016
|
-
get renderer() {
|
|
2017
|
-
return this.ve;
|
|
2018
|
-
}
|
|
2019
|
-
set frameCount(e) {
|
|
2020
|
-
this.Zs = e;
|
|
2016
|
+
return this.Ps;
|
|
2021
2017
|
}
|
|
2022
2018
|
get width() {
|
|
2023
|
-
return this.
|
|
2019
|
+
return this.Js.width;
|
|
2024
2020
|
}
|
|
2025
2021
|
get height() {
|
|
2026
|
-
return this.
|
|
2022
|
+
return this.Js.height;
|
|
2027
2023
|
}
|
|
2028
2024
|
get canvas() {
|
|
2029
|
-
return this.
|
|
2025
|
+
return this.Js.canvas;
|
|
2030
2026
|
}
|
|
2031
2027
|
get isDisposed() {
|
|
2032
|
-
return this.
|
|
2028
|
+
return this.yr;
|
|
2029
|
+
}
|
|
2030
|
+
get drawFramebuffer() {
|
|
2031
|
+
return this.gr;
|
|
2033
2032
|
}
|
|
2034
2033
|
}
|
|
2035
|
-
class
|
|
2034
|
+
class $ {
|
|
2036
2035
|
constructor() {
|
|
2037
|
-
throw new
|
|
2036
|
+
throw new C("Textmode is a static class and cannot be instantiated.");
|
|
2038
2037
|
}
|
|
2039
|
-
static async create(t
|
|
2040
|
-
|
|
2041
|
-
if (typeof e != "object") throw new w("Second parameter must be an options object.");
|
|
2042
|
-
if (t instanceof HTMLCanvasElement || t instanceof HTMLVideoElement) return X.create(t, e);
|
|
2043
|
-
{
|
|
2044
|
-
const r = t || {};
|
|
2045
|
-
return X.create(null, r);
|
|
2046
|
-
}
|
|
2038
|
+
static async create(t) {
|
|
2039
|
+
return jt.create(t);
|
|
2047
2040
|
}
|
|
2048
2041
|
static setErrorLevel(t) {
|
|
2049
|
-
|
|
2042
|
+
I.m(t);
|
|
2050
2043
|
}
|
|
2051
2044
|
static get version() {
|
|
2052
|
-
return "0.
|
|
2045
|
+
return "0.2.0-beta.1";
|
|
2053
2046
|
}
|
|
2054
2047
|
}
|
|
2055
|
-
const
|
|
2048
|
+
const Jt = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), qt = $.create, Zt = $.setErrorLevel, Kt = $.version;
|
|
2056
2049
|
export {
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
Gt as export,
|
|
2068
|
-
Ot as setErrorLevel,
|
|
2069
|
-
O as textmode,
|
|
2070
|
-
Wt as version
|
|
2050
|
+
Pt as TextmodeCanvas,
|
|
2051
|
+
Z as TextmodeErrorLevel,
|
|
2052
|
+
At as TextmodeFont,
|
|
2053
|
+
wt as TextmodeGrid,
|
|
2054
|
+
jt as Textmodifier,
|
|
2055
|
+
qt as create,
|
|
2056
|
+
Jt as export,
|
|
2057
|
+
Zt as setErrorLevel,
|
|
2058
|
+
$ as textmode,
|
|
2059
|
+
Kt as version
|
|
2071
2060
|
};
|