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