textmode.js 0.1.4-beta.5 → 0.1.4-beta.8

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.
@@ -1,12 +1,12 @@
1
1
  var se = Object.defineProperty;
2
- var ae = (l, e, t) => e in l ? se(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var n = (l, e, t) => ae(l, typeof e != "symbol" ? e + "" : e, t);
2
+ var ae = (h, e, t) => e in h ? se(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
3
+ var o = (h, e, t) => ae(h, typeof e != "symbol" ? e + "" : e, t);
4
4
  class F extends Error {
5
5
  constructor(t, r, i = {}) {
6
6
  const s = F.createFormattedMessage(t, i);
7
7
  super(s);
8
- n(this, "originalError");
9
- n(this, "context");
8
+ o(this, "originalError");
9
+ o(this, "context");
10
10
  this.name = "TextmodeError", this.originalError = r, this.context = i;
11
11
  }
12
12
  /**
@@ -19,9 +19,9 @@ class F extends Error {
19
19
 
20
20
  📋 Context:`;
21
21
  for (const [s, a] of Object.entries(r)) {
22
- const o = F.formatValue(a);
22
+ const n = F.formatValue(a);
23
23
  i += `
24
- - ${s}: ${o}`;
24
+ - ${s}: ${n}`;
25
25
  }
26
26
  }
27
27
  return i += `
@@ -46,10 +46,10 @@ class F extends Error {
46
46
  return String(t);
47
47
  }
48
48
  }
49
- var oe = /* @__PURE__ */ ((l) => (l[l.SILENT = 0] = "SILENT", l[l.WARNING = 1] = "WARNING", l[l.ERROR = 2] = "ERROR", l[l.THROW = 3] = "THROW", l))(oe || {});
49
+ var ne = /* @__PURE__ */ ((h) => (h[h.SILENT = 0] = "SILENT", h[h.WARNING = 1] = "WARNING", h[h.ERROR = 2] = "ERROR", h[h.THROW = 3] = "THROW", h))(ne || {});
50
50
  const E = class E {
51
51
  constructor() {
52
- n(this, "_options", {
52
+ o(this, "_options", {
53
53
  globalLevel: 3
54
54
  /* THROW */
55
55
  });
@@ -103,19 +103,19 @@ const E = class E {
103
103
  this._options.globalLevel = e;
104
104
  }
105
105
  };
106
- n(E, "_instance", null);
106
+ o(E, "_instance", null);
107
107
  let $ = E;
108
108
  const x = $.getInstance();
109
- class ne {
109
+ class oe {
110
110
  constructor(e, t, r = t, i = {}) {
111
- n(this, "gl");
112
- n(this, "_framebuffer");
113
- n(this, "_texture");
114
- n(this, "_width");
115
- n(this, "_height");
116
- n(this, "options");
117
- n(this, "previousState", null);
118
- n(this, "_pixels", null);
111
+ o(this, "gl");
112
+ o(this, "_framebuffer");
113
+ o(this, "_texture");
114
+ o(this, "_width");
115
+ o(this, "_height");
116
+ o(this, "options");
117
+ o(this, "previousState", null);
118
+ o(this, "_pixels", null);
119
119
  this.gl = e, this._width = t, this._height = r, this.options = {
120
120
  filter: "nearest",
121
121
  wrap: "clamp",
@@ -189,16 +189,16 @@ class ne {
189
189
  get(e, t, r, i) {
190
190
  const { gl: s } = this;
191
191
  if (e === void 0 && t === void 0) {
192
- const a = new Uint8Array(this._width * this._height * 4), o = s.getParameter(s.FRAMEBUFFER_BINDING);
193
- return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(0, 0, this._width, this._height, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, o), a;
192
+ const a = new Uint8Array(this._width * this._height * 4), n = s.getParameter(s.FRAMEBUFFER_BINDING);
193
+ return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(0, 0, this._width, this._height, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, n), a;
194
194
  } else if (r === void 0 && i === void 0) {
195
195
  (e < 0 || t < 0 || e >= this._width || t >= this._height) && (console.warn("The x and y values passed to Framebuffer.get are outside of its range and will be clamped."), e = Math.max(0, Math.min(e, this._width - 1)), t = Math.max(0, Math.min(t, this._height - 1)));
196
- const a = new Uint8Array(4), o = s.getParameter(s.FRAMEBUFFER_BINDING);
197
- return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(e, t, 1, 1, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, o), [a[0], a[1], a[2], a[3]];
196
+ const a = new Uint8Array(4), n = s.getParameter(s.FRAMEBUFFER_BINDING);
197
+ return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(e, t, 1, 1, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, n), [a[0], a[1], a[2], a[3]];
198
198
  } else {
199
199
  e = Math.max(0, Math.min(e, this._width - 1)), t = Math.max(0, Math.min(t, this._height - 1)), r = Math.max(1, Math.min(r, this._width - e)), i = Math.max(1, Math.min(i, this._height - t));
200
- const a = new Uint8Array(r * i * 4), o = s.getParameter(s.FRAMEBUFFER_BINDING);
201
- return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(e, t, r, i, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, o), a;
200
+ const a = new Uint8Array(r * i * 4), n = s.getParameter(s.FRAMEBUFFER_BINDING);
201
+ return s.bindFramebuffer(s.FRAMEBUFFER, this._framebuffer), s.readPixels(e, t, r, i, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, n), a;
202
202
  }
203
203
  }
204
204
  /**
@@ -227,26 +227,26 @@ class ne {
227
227
  }
228
228
  class Q {
229
229
  constructor(e, t, r) {
230
- n(this, "gl");
231
- n(this, "x");
232
- n(this, "y");
230
+ o(this, "gl");
231
+ o(this, "x");
232
+ o(this, "y");
233
233
  this.gl = e, this.x = t, this.y = r;
234
234
  }
235
235
  }
236
236
  class M {
237
237
  constructor(e, t, r, i, s) {
238
238
  /** The WebGL rendering context */
239
- n(this, "gl");
239
+ o(this, "gl");
240
240
  /** The vertex buffer containing position and texture coordinates */
241
- n(this, "vertexBuffer");
241
+ o(this, "vertexBuffer");
242
242
  /** The number of vertices in this geometry (always 6 for two triangles) */
243
- n(this, "vertexCount", 6);
243
+ o(this, "vertexCount", 6);
244
244
  /** Bytes per vertex: depends on position format (vec2 vs vec3) */
245
- n(this, "bytesPerVertex");
245
+ o(this, "bytesPerVertex");
246
246
  this.gl = e, this.bytesPerVertex = 16;
247
- const a = e.getParameter(e.VIEWPORT), o = a[2], h = a[3], c = e.getParameter(e.FRAMEBUFFER_BINDING) !== null, u = t / o * 2 - 1, d = (t + i) / o * 2 - 1;
247
+ const a = e.getParameter(e.VIEWPORT), n = a[2], l = a[3], c = e.getParameter(e.FRAMEBUFFER_BINDING) !== null, u = t / n * 2 - 1, d = (t + i) / n * 2 - 1;
248
248
  let f, g;
249
- c ? (f = r / h * 2 - 1, g = (r + s) / h * 2 - 1) : (f = 1 - r / h * 2, g = 1 - (r + s) / h * 2);
249
+ c ? (f = r / l * 2 - 1, g = (r + s) / l * 2 - 1) : (f = 1 - r / l * 2, g = 1 - (r + s) / l * 2);
250
250
  let _, p, b, C;
251
251
  _ = u, b = d, p = f, C = g;
252
252
  const v = this.generateVertices(_, p, b, C);
@@ -300,11 +300,11 @@ class M {
300
300
  this.gl.enableVertexAttribArray(t), this.gl.vertexAttribPointer(t, 2, this.gl.FLOAT, !1, this.bytesPerVertex, 0), this.gl.enableVertexAttribArray(r), this.gl.vertexAttribPointer(r, 2, this.gl.FLOAT, !1, this.bytesPerVertex, 8), this.gl.drawArrays(this.gl.TRIANGLES, 0, this.vertexCount), this.gl.disableVertexAttribArray(t), this.gl.disableVertexAttribArray(r);
301
301
  }
302
302
  }
303
- class le extends Q {
303
+ class he extends Q {
304
304
  constructor(t, r, i, s, a) {
305
305
  super(t, r, i);
306
- n(this, "width");
307
- n(this, "height");
306
+ o(this, "width");
307
+ o(this, "height");
308
308
  this.width = s, this.height = a;
309
309
  }
310
310
  /**
@@ -324,24 +324,24 @@ class le extends Q {
324
324
  r.render(), i.render(), s.render(), a.render();
325
325
  }
326
326
  }
327
- class he {
327
+ class le {
328
328
  constructor(e, t, r, i, s, a) {
329
329
  /** The WebGL rendering context */
330
- n(this, "gl");
330
+ o(this, "gl");
331
331
  /** The vertex buffer containing position and texture coordinates */
332
- n(this, "vertexBuffer");
332
+ o(this, "vertexBuffer");
333
333
  /** The number of vertices in this geometry (always 6 for two triangles) */
334
- n(this, "vertexCount", 6);
334
+ o(this, "vertexCount", 6);
335
335
  /** Bytes per vertex: vec2+vec2 = 16 bytes */
336
- n(this, "bytesPerVertex");
336
+ o(this, "bytesPerVertex");
337
337
  this.gl = e, this.bytesPerVertex = 16;
338
- const o = e.getParameter(e.VIEWPORT), h = o[2], c = o[3], u = e.getParameter(e.FRAMEBUFFER_BINDING) !== null, d = i - t, f = s - r, g = Math.sqrt(d * d + f * f);
338
+ const n = e.getParameter(e.VIEWPORT), l = n[2], c = n[3], u = e.getParameter(e.FRAMEBUFFER_BINDING) !== null, d = i - t, f = s - r, g = Math.sqrt(d * d + f * f);
339
339
  if (g === 0) {
340
340
  const ie = this.generateVertices(0, 0, 0, 0);
341
341
  this.vertexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, ie, e.STATIC_DRAW);
342
342
  return;
343
343
  }
344
- const _ = d / g, b = -(f / g), C = _, v = a / 2, w = t + b * v, A = r + C * v, R = t - b * v, S = r - C * v, P = i + b * v, D = s + C * v, Z = i - b * v, W = s - C * v, J = w / h * 2 - 1, K = R / h * 2 - 1, ee = P / h * 2 - 1, te = Z / h * 2 - 1;
344
+ const _ = d / g, b = -(f / g), C = _, v = a / 2, w = t + b * v, A = r + C * v, R = t - b * v, S = r - C * v, P = i + b * v, D = s + C * v, Z = i - b * v, W = s - C * v, J = w / l * 2 - 1, K = R / l * 2 - 1, ee = P / l * 2 - 1, te = Z / l * 2 - 1;
345
345
  let B, G, V, k;
346
346
  u ? (B = A / c * 2 - 1, G = S / c * 2 - 1, V = D / c * 2 - 1, k = W / c * 2 - 1) : (B = 1 - A / c * 2, G = 1 - S / c * 2, V = 1 - D / c * 2, k = 1 - W / c * 2);
347
347
  const re = this.generateLineVertices(
@@ -399,7 +399,7 @@ class he {
399
399
  * Uses the four corners calculated based on line direction and thickness
400
400
  * @private
401
401
  */
402
- generateLineVertices(e, t, r, i, s, a, o, h) {
402
+ generateLineVertices(e, t, r, i, s, a, n, l) {
403
403
  return new Float32Array([
404
404
  e,
405
405
  t,
@@ -421,8 +421,8 @@ class he {
421
421
  0,
422
422
  1,
423
423
  // corner2 (start - perpendicular)
424
- o,
425
- h,
424
+ n,
425
+ l,
426
426
  1,
427
427
  1,
428
428
  // corner4 (end - perpendicular)
@@ -446,8 +446,8 @@ class he {
446
446
  class ce extends Q {
447
447
  constructor(t, r, i, s, a) {
448
448
  super(t, r, i);
449
- n(this, "x2");
450
- n(this, "y2");
449
+ o(this, "x2");
450
+ o(this, "y2");
451
451
  this.x2 = s, this.y2 = a;
452
452
  }
453
453
  /**
@@ -462,16 +462,16 @@ class ce extends Q {
462
462
  */
463
463
  renderStroke(t) {
464
464
  if (t <= 0) return;
465
- new he(this.gl, this.x, this.y, this.x2, this.y2, t).render();
465
+ new le(this.gl, this.x, this.y, this.x2, this.y2, t).render();
466
466
  }
467
467
  }
468
468
  class y {
469
469
  constructor(e, t, r) {
470
- n(this, "gl");
471
- n(this, "program");
472
- n(this, "uniformLocations", /* @__PURE__ */ new Map());
473
- n(this, "attributeLocations", /* @__PURE__ */ new Map());
474
- n(this, "textureUnitCounter", 0);
470
+ o(this, "gl");
471
+ o(this, "program");
472
+ o(this, "uniformLocations", /* @__PURE__ */ new Map());
473
+ o(this, "attributeLocations", /* @__PURE__ */ new Map());
474
+ o(this, "textureUnitCounter", 0);
475
475
  this.gl = e, this.program = this.createProgram(t, r), this.cacheLocations();
476
476
  }
477
477
  createProgram(e, t) {
@@ -615,22 +615,22 @@ class y {
615
615
  var T = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;uniform float u_rotation;uniform vec2 u_center;uniform float u_aspectRatio;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_uv=a_texCoord;vec2 pos=a_position;pos-=u_center;pos.x*=u_aspectRatio;pos=rotate2D(-u_rotation)*pos;pos.x/=u_aspectRatio;pos+=u_center;gl_Position=vec4(pos,0.0,1.0);}", ue = "precision lowp float;uniform sampler2D u_texture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(u_texture,v_uv);}", de = "precision lowp float;uniform vec4 u_color;void main(){gl_FragColor=u_color;}";
616
616
  class fe {
617
617
  constructor(e) {
618
- n(this, "gl");
619
- n(this, "imageShader");
620
- n(this, "solidColorShader");
621
- n(this, "currentShader", null);
618
+ o(this, "gl");
619
+ o(this, "imageShader");
620
+ o(this, "solidColorShader");
621
+ o(this, "currentShader", null);
622
622
  // Fill state management - default: white fill enabled
623
- n(this, "currentFillColor", [1, 1, 1, 1]);
624
- n(this, "fillMode", !0);
623
+ o(this, "currentFillColor", [1, 1, 1, 1]);
624
+ o(this, "fillMode", !0);
625
625
  // Stroke state management - default: black stroke enabled, weight 1
626
- n(this, "currentStrokeColor", [0, 0, 0, 1]);
627
- n(this, "currentStrokeWeight", 1);
628
- n(this, "strokeMode", !0);
626
+ o(this, "currentStrokeColor", [0, 0, 0, 1]);
627
+ o(this, "currentStrokeWeight", 1);
628
+ o(this, "strokeMode", !0);
629
629
  // Transformation state management
630
- n(this, "currentRotation", 0);
630
+ o(this, "currentRotation", 0);
631
631
  // in degrees
632
632
  // State stack for push/pop functionality
633
- n(this, "stateStack", []);
633
+ o(this, "stateStack", []);
634
634
  this.gl = e, this.imageShader = new y(this.gl, T, ue), this.solidColorShader = new y(this.gl, T, de), this.gl.enable(this.gl.BLEND), this.gl.blendEquation(this.gl.FUNC_ADD), this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
635
635
  }
636
636
  /**
@@ -747,7 +747,7 @@ class fe {
747
747
  * Draw a rectangle with the current fill and/or stroke settings
748
748
  */
749
749
  rect(e, t, r, i) {
750
- const s = new le(this.gl, e, t, r, i);
750
+ const s = new he(this.gl, e, t, r, i);
751
751
  if (this.currentShader !== null) {
752
752
  if (this.currentRotation !== 0) {
753
753
  const { centerX: d, centerY: f, radians: g, aspectRatio: _ } = this.calculateRotationParams(e, t, r, i);
@@ -757,8 +757,8 @@ class fe {
757
757
  s.renderFill(), this.currentShader = null;
758
758
  return;
759
759
  }
760
- const a = this.solidColorShader, { centerX: o, centerY: h, radians: c, aspectRatio: u } = this.calculateRotationParams(e, t, r, i);
761
- this.fillMode && (this.shader(a), this.setUniform("u_color", this.currentFillColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [o, h]), this.setUniform("u_aspectRatio", u), s.renderFill()), this.strokeMode && (this.shader(a), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [o, h]), this.setUniform("u_aspectRatio", u), s.renderStroke(this.currentStrokeWeight)), this.currentShader = null;
760
+ const a = this.solidColorShader, { centerX: n, centerY: l, radians: c, aspectRatio: u } = this.calculateRotationParams(e, t, r, i);
761
+ this.fillMode && (this.shader(a), this.setUniform("u_color", this.currentFillColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [n, l]), this.setUniform("u_aspectRatio", u), s.renderFill()), this.strokeMode && (this.shader(a), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", c), this.setUniform("u_center", [n, l]), this.setUniform("u_aspectRatio", u), s.renderStroke(this.currentStrokeWeight)), this.currentShader = null;
762
762
  }
763
763
  /**
764
764
  * Draw a line from (x1, y1) to (x2, y2) with the current stroke settings.
@@ -780,24 +780,24 @@ class fe {
780
780
  s.renderStroke(this.currentStrokeWeight), this.currentShader = null;
781
781
  return;
782
782
  }
783
- const a = this.solidColorShader, o = (e + r) / 2, h = (t + i) / 2, c = Math.abs(r - e), u = Math.abs(i - t), { centerX: d, centerY: f, radians: g, aspectRatio: _ } = this.calculateRotationParams(o - c / 2, h - u / 2, c, u);
783
+ const a = this.solidColorShader, n = (e + r) / 2, l = (t + i) / 2, c = Math.abs(r - e), u = Math.abs(i - t), { centerX: d, centerY: f, radians: g, aspectRatio: _ } = this.calculateRotationParams(n - c / 2, l - u / 2, c, u);
784
784
  this.shader(a), this.setUniform("u_color", this.currentStrokeColor), this.setUniform("u_rotation", g), this.setUniform("u_center", [d, f]), this.setUniform("u_aspectRatio", _), s.renderStroke(this.currentStrokeWeight), this.currentShader = null;
785
785
  }
786
786
  /**
787
787
  * Calculate rotation parameters for built-in shaders (NDC coordinates)
788
788
  */
789
789
  calculateRotationParams(e, t, r, i) {
790
- const s = this.gl.getParameter(this.gl.VIEWPORT), a = s[2], o = s[3], h = a / o, c = this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING) !== null, u = e + r / 2, d = t + i / 2, f = u / a * 2 - 1;
790
+ const s = this.gl.getParameter(this.gl.VIEWPORT), a = s[2], n = s[3], l = a / n, c = this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING) !== null, u = e + r / 2, d = t + i / 2, f = u / a * 2 - 1;
791
791
  let g;
792
- c ? g = d / o * 2 - 1 : g = 1 - d / o * 2;
792
+ c ? g = d / n * 2 - 1 : g = 1 - d / n * 2;
793
793
  const _ = this.currentRotation * Math.PI / 180;
794
- return { centerX: f, centerY: g, radians: _, aspectRatio: h };
794
+ return { centerX: f, centerY: g, radians: _, aspectRatio: l };
795
795
  }
796
796
  /**
797
797
  * Create a new framebuffer
798
798
  */
799
799
  createFramebuffer(e, t, r = {}) {
800
- return new ne(this.gl, e, t, r);
800
+ return new oe(this.gl, e, t, r);
801
801
  }
802
802
  /**
803
803
  * Fill the current framebuffer with a solid color
@@ -835,18 +835,18 @@ class fe {
835
835
  */
836
836
  image(e, t, r, i, s) {
837
837
  this.shader(this.imageShader), this.setUniform("u_texture", e.texture);
838
- const { centerX: a, centerY: o, radians: h, aspectRatio: c } = this.calculateRotationParams(
838
+ const { centerX: a, centerY: n, radians: l, aspectRatio: c } = this.calculateRotationParams(
839
839
  t,
840
840
  r,
841
841
  i ?? e.width,
842
842
  s ?? e.height
843
843
  );
844
- this.setUniform("u_rotation", h), this.setUniform("u_center", [a, o]), this.setUniform("u_aspectRatio", c), this.rect(t, r, i ?? e.width, s ?? e.height);
844
+ this.setUniform("u_rotation", l), this.setUniform("u_center", [a, n]), this.setUniform("u_aspectRatio", c), this.rect(t, r, i ?? e.width, s ?? e.height);
845
845
  }
846
846
  }
847
847
  var m = {};
848
- m.parse = function(l) {
849
- var e = function(s, a, o, h) {
848
+ m.parse = function(h) {
849
+ var e = function(s, a, n, l) {
850
850
  var c = m.T, u = {
851
851
  cmap: c.cmap,
852
852
  head: c.head,
@@ -855,119 +855,119 @@ m.parse = function(l) {
855
855
  hmtx: c.hmtx,
856
856
  loca: c.loca,
857
857
  glyf: c.glyf
858
- }, d = { _data: s, _index: a, _offset: o };
858
+ }, d = { _data: s, _index: a, _offset: n };
859
859
  for (var f in u) {
860
- var g = m.findTable(s, f, o);
860
+ var g = m.findTable(s, f, n);
861
861
  if (g) {
862
- var _ = g[0], p = h[_];
863
- p == null && (p = u[f].parseTab(s, _, g[1], d)), d[f] = h[_] = p;
862
+ var _ = g[0], p = l[_];
863
+ p == null && (p = u[f].parseTab(s, _, g[1], d)), d[f] = l[_] = p;
864
864
  }
865
865
  }
866
866
  return d;
867
- }, t = new Uint8Array(l), r = {}, i = e(t, 0, 0, r);
867
+ }, t = new Uint8Array(h), r = {}, i = e(t, 0, 0, r);
868
868
  return [i];
869
869
  };
870
- m.findTable = function(l, e, t) {
871
- for (var r = m.B, i = r.readUshort(l, t + 4), s = t + 12, a = 0; a < i; a++) {
872
- var o = r.readASCII(l, s, 4);
873
- r.readUint(l, s + 4);
874
- var h = r.readUint(l, s + 8), c = r.readUint(l, s + 12);
875
- if (o == e) return [h, c];
870
+ m.findTable = function(h, e, t) {
871
+ for (var r = m.B, i = r.readUshort(h, t + 4), s = t + 12, a = 0; a < i; a++) {
872
+ var n = r.readASCII(h, s, 4);
873
+ r.readUint(h, s + 4);
874
+ var l = r.readUint(h, s + 8), c = r.readUint(h, s + 12);
875
+ if (n == e) return [l, c];
876
876
  s += 16;
877
877
  }
878
878
  return null;
879
879
  };
880
880
  m.T = {};
881
881
  m.B = {
882
- readShort: function(l, e) {
882
+ readShort: function(h, e) {
883
883
  var t = m.B.t.uint16;
884
- return t[0] = l[e] << 8 | l[e + 1], m.B.t.int16[0];
884
+ return t[0] = h[e] << 8 | h[e + 1], m.B.t.int16[0];
885
885
  },
886
- readUshort: function(l, e) {
887
- return l[e] << 8 | l[e + 1];
886
+ readUshort: function(h, e) {
887
+ return h[e] << 8 | h[e + 1];
888
888
  },
889
- readUshorts: function(l, e, t) {
889
+ readUshorts: function(h, e, t) {
890
890
  for (var r = [], i = 0; i < t; i++)
891
- r.push(m.B.readUshort(l, e + i * 2));
891
+ r.push(m.B.readUshort(h, e + i * 2));
892
892
  return r;
893
893
  },
894
- readUint: function(l, e) {
894
+ readUint: function(h, e) {
895
895
  var t = m.B.t.uint8;
896
- return t[3] = l[e], t[2] = l[e + 1], t[1] = l[e + 2], t[0] = l[e + 3], m.B.t.uint32[0];
896
+ return t[3] = h[e], t[2] = h[e + 1], t[1] = h[e + 2], t[0] = h[e + 3], m.B.t.uint32[0];
897
897
  },
898
- readASCII: function(l, e, t) {
899
- for (var r = "", i = 0; i < t; i++) r += String.fromCharCode(l[e + i]);
898
+ readASCII: function(h, e, t) {
899
+ for (var r = "", i = 0; i < t; i++) r += String.fromCharCode(h[e + i]);
900
900
  return r;
901
901
  },
902
902
  // Simplified typed array buffer - only what's needed
903
903
  t: function() {
904
- var l = new ArrayBuffer(8);
904
+ var h = new ArrayBuffer(8);
905
905
  return {
906
- uint8: new Uint8Array(l),
907
- int16: new Int16Array(l),
908
- uint16: new Uint16Array(l),
909
- uint32: new Uint32Array(l)
906
+ uint8: new Uint8Array(h),
907
+ int16: new Int16Array(h),
908
+ uint16: new Uint16Array(h),
909
+ uint32: new Uint32Array(h)
910
910
  };
911
911
  }()
912
912
  };
913
913
  m.T.cmap = {
914
- parseTab: function(l, e, t) {
914
+ parseTab: function(h, e, t) {
915
915
  var r = { tables: [], ids: {}, off: e };
916
- l = new Uint8Array(l.buffer, e, t), e = 0;
916
+ h = new Uint8Array(h.buffer, e, t), e = 0;
917
917
  var i = m.B, s = i.readUshort, a = m.T.cmap;
918
- s(l, e), e += 2;
919
- var o = s(l, e);
918
+ s(h, e), e += 2;
919
+ var n = s(h, e);
920
920
  e += 2;
921
- for (var h = [], c = 0; c < o; c++) {
922
- var u = s(l, e);
921
+ for (var l = [], c = 0; c < n; c++) {
922
+ var u = s(h, e);
923
923
  e += 2;
924
- var d = s(l, e);
924
+ var d = s(h, e);
925
925
  e += 2;
926
- var f = i.readUint(l, e);
926
+ var f = i.readUint(h, e);
927
927
  e += 4;
928
- var g = "p" + u + "e" + d, _ = h.indexOf(f);
928
+ var g = "p" + u + "e" + d, _ = l.indexOf(f);
929
929
  if (_ == -1) {
930
930
  _ = r.tables.length;
931
931
  var p = {};
932
- h.push(f);
933
- var b = p.format = s(l, f);
934
- b == 4 ? p = a.parse4(l, f, p) : b == 12 && (p = a.parse12(l, f, p)), r.tables.push(p);
932
+ l.push(f);
933
+ var b = p.format = s(h, f);
934
+ b == 4 ? p = a.parse4(h, f, p) : b == 12 && (p = a.parse12(h, f, p)), r.tables.push(p);
935
935
  }
936
936
  r.ids[g] != null && console.log("multiple tables for one platform+encoding: " + g), r.ids[g] = _;
937
937
  }
938
938
  return r;
939
939
  },
940
- parse4: function(l, e, t) {
940
+ parse4: function(h, e, t) {
941
941
  var r = m.B, i = r.readUshort, s = r.readUshorts, a = e;
942
942
  e += 2;
943
- var o = i(l, e);
944
- e += 2, i(l, e), e += 2;
945
- var h = i(l, e);
943
+ var n = i(h, e);
944
+ e += 2, i(h, e), e += 2;
945
+ var l = i(h, e);
946
946
  e += 2;
947
- var c = h >>> 1;
948
- t.searchRange = i(l, e), e += 2, t.entrySelector = i(l, e), e += 2, t.rangeShift = i(l, e), e += 2, t.endCount = s(l, e, c), e += c * 2, e += 2, t.startCount = s(l, e, c), e += c * 2, t.idDelta = [];
947
+ var c = l >>> 1;
948
+ t.searchRange = i(h, e), e += 2, t.entrySelector = i(h, e), e += 2, t.rangeShift = i(h, e), e += 2, t.endCount = s(h, e, c), e += c * 2, e += 2, t.startCount = s(h, e, c), e += c * 2, t.idDelta = [];
949
949
  for (var u = 0; u < c; u++)
950
- t.idDelta.push(r.readShort(l, e)), e += 2;
951
- return t.idRangeOffset = s(l, e, c), e += c * 2, t.glyphIdArray = s(l, e, a + o - e >> 1), t;
950
+ t.idDelta.push(r.readShort(h, e)), e += 2;
951
+ return t.idRangeOffset = s(h, e, c), e += c * 2, t.glyphIdArray = s(h, e, a + n - e >> 1), t;
952
952
  },
953
- parse12: function(l, e, t) {
953
+ parse12: function(h, e, t) {
954
954
  var r = m.B, i = r.readUint;
955
- e += 4, i(l, e), e += 4, i(l, e), e += 4;
956
- var s = i(l, e) * 3;
955
+ e += 4, i(h, e), e += 4, i(h, e), e += 4;
956
+ var s = i(h, e) * 3;
957
957
  e += 4;
958
- for (var a = t.groups = new Uint32Array(s), o = 0; o < s; o += 3)
959
- a[o] = i(l, e + (o << 2)), a[o + 1] = i(l, e + (o << 2) + 4), a[o + 2] = i(l, e + (o << 2) + 8);
958
+ for (var a = t.groups = new Uint32Array(s), n = 0; n < s; n += 3)
959
+ a[n] = i(h, e + (n << 2)), a[n + 1] = i(h, e + (n << 2) + 4), a[n + 2] = i(h, e + (n << 2) + 8);
960
960
  return t;
961
961
  }
962
962
  };
963
963
  m.T.head = {
964
- parseTab: function(l, e, t) {
964
+ parseTab: function(h, e, t) {
965
965
  var r = m.B, i = {};
966
- return e += 18, i.unitsPerEm = r.readUshort(l, e), e += 2, e += 16, i.xMin = r.readShort(l, e), e += 2, i.yMin = r.readShort(l, e), e += 2, i.xMax = r.readShort(l, e), e += 2, i.yMax = r.readShort(l, e), e += 2, e += 6, i.indexToLocFormat = r.readShort(l, e), i;
966
+ return e += 18, i.unitsPerEm = r.readUshort(h, e), e += 2, e += 16, i.xMin = r.readShort(h, e), e += 2, i.yMin = r.readShort(h, e), e += 2, i.xMax = r.readShort(h, e), e += 2, i.yMax = r.readShort(h, e), e += 2, e += 6, i.indexToLocFormat = r.readShort(h, e), i;
967
967
  }
968
968
  };
969
969
  m.T.hhea = {
970
- parseTab: function(l, e, t) {
970
+ parseTab: function(h, e, t) {
971
971
  var r = m.B, i = {};
972
972
  e += 4;
973
973
  for (var s = [
@@ -988,75 +988,75 @@ m.T.hhea = {
988
988
  "metricDataFormat",
989
989
  "numberOfHMetrics"
990
990
  ], a = 0; a < s.length; a++) {
991
- var o = s[a], h = o == "advanceWidthMax" || o == "numberOfHMetrics" ? r.readUshort : r.readShort;
992
- i[o] = h(l, e + a * 2);
991
+ var n = s[a], l = n == "advanceWidthMax" || n == "numberOfHMetrics" ? r.readUshort : r.readShort;
992
+ i[n] = l(h, e + a * 2);
993
993
  }
994
994
  return i;
995
995
  }
996
996
  };
997
997
  m.T.hmtx = {
998
- parseTab: function(l, e, t, r) {
999
- for (var i = m.B, s = [], a = [], o = r.maxp.numGlyphs, h = r.hhea.numberOfHMetrics, c = 0, u = 0, d = 0; d < h; )
1000
- c = i.readUshort(l, e + (d << 2)), u = i.readShort(l, e + (d << 2) + 2), s.push(c), a.push(u), d++;
1001
- for (; d < o; )
998
+ parseTab: function(h, e, t, r) {
999
+ for (var i = m.B, s = [], a = [], n = r.maxp.numGlyphs, l = r.hhea.numberOfHMetrics, c = 0, u = 0, d = 0; d < l; )
1000
+ c = i.readUshort(h, e + (d << 2)), u = i.readShort(h, e + (d << 2) + 2), s.push(c), a.push(u), d++;
1001
+ for (; d < n; )
1002
1002
  s.push(c), a.push(u), d++;
1003
1003
  return { aWidth: s, lsBearing: a };
1004
1004
  }
1005
1005
  };
1006
1006
  m.T.maxp = {
1007
- parseTab: function(l, e, t) {
1007
+ parseTab: function(h, e, t) {
1008
1008
  var r = m.B, i = r.readUshort, s = {};
1009
- return r.readUint(l, e), e += 4, s.numGlyphs = i(l, e), e += 2, s;
1009
+ return r.readUint(h, e), e += 4, s.numGlyphs = i(h, e), e += 2, s;
1010
1010
  }
1011
1011
  };
1012
1012
  m.T.loca = {
1013
- parseTab: function(l, e, t, r) {
1014
- var i = m.B, s = [], a = r.head.indexToLocFormat, o = r.maxp.numGlyphs + 1;
1015
- if (a == 0) for (var h = 0; h < o; h++) s.push(i.readUshort(l, e + (h << 1)) << 1);
1016
- if (a == 1) for (var h = 0; h < o; h++) s.push(i.readUint(l, e + (h << 2)));
1013
+ parseTab: function(h, e, t, r) {
1014
+ var i = m.B, s = [], a = r.head.indexToLocFormat, n = r.maxp.numGlyphs + 1;
1015
+ if (a == 0) for (var l = 0; l < n; l++) s.push(i.readUshort(h, e + (l << 1)) << 1);
1016
+ if (a == 1) for (var l = 0; l < n; l++) s.push(i.readUint(h, e + (l << 2)));
1017
1017
  return s;
1018
1018
  }
1019
1019
  };
1020
1020
  m.T.glyf = {
1021
- parseTab: function(l, e, t, r) {
1021
+ parseTab: function(h, e, t, r) {
1022
1022
  for (var i = [], s = r.maxp.numGlyphs, a = 0; a < s; a++) i.push(null);
1023
1023
  return i;
1024
1024
  },
1025
- _parseGlyf: function(l, e) {
1026
- var t = m.B, r = l._data, i = l.loca;
1025
+ _parseGlyf: function(h, e) {
1026
+ var t = m.B, r = h._data, i = h.loca;
1027
1027
  if (i[e] == i[e + 1]) return null;
1028
- var s = m.findTable(r, "glyf", l._offset)[0] + i[e], a = {};
1028
+ var s = m.findTable(r, "glyf", h._offset)[0] + i[e], a = {};
1029
1029
  if (a.noc = t.readShort(r, s), s += 2, a.xMin = t.readShort(r, s), s += 2, a.yMin = t.readShort(r, s), s += 2, a.xMax = t.readShort(r, s), s += 2, a.yMax = t.readShort(r, s), s += 2, a.xMin >= a.xMax || a.yMin >= a.yMax) return null;
1030
1030
  if (a.noc > 0) {
1031
1031
  a.endPts = [];
1032
- for (var o = 0; o < a.noc; o++)
1032
+ for (var n = 0; n < a.noc; n++)
1033
1033
  a.endPts.push(t.readUshort(r, s)), s += 2;
1034
- var h = t.readUshort(r, s);
1035
- if (s += 2, r.length - s < h) return null;
1036
- s += h;
1034
+ var l = t.readUshort(r, s);
1035
+ if (s += 2, r.length - s < l) return null;
1036
+ s += l;
1037
1037
  var c = a.endPts[a.noc - 1] + 1;
1038
1038
  a.flags = [];
1039
- for (var o = 0; o < c; o++) {
1039
+ for (var n = 0; n < c; n++) {
1040
1040
  var u = r[s];
1041
1041
  if (s++, a.flags.push(u), u & 8) {
1042
1042
  var d = r[s];
1043
1043
  s++;
1044
1044
  for (var f = 0; f < d; f++)
1045
- a.flags.push(u), o++;
1045
+ a.flags.push(u), n++;
1046
1046
  }
1047
1047
  }
1048
1048
  a.xs = [];
1049
- for (var o = 0; o < c; o++) {
1050
- var g = (a.flags[o] & 2) != 0, _ = (a.flags[o] & 16) != 0;
1049
+ for (var n = 0; n < c; n++) {
1050
+ var g = (a.flags[n] & 2) != 0, _ = (a.flags[n] & 16) != 0;
1051
1051
  g ? (a.xs.push(_ ? r[s] : -r[s]), s++) : _ ? a.xs.push(0) : (a.xs.push(t.readShort(r, s)), s += 2);
1052
1052
  }
1053
1053
  a.ys = [];
1054
- for (var o = 0; o < c; o++) {
1055
- var g = (a.flags[o] & 4) != 0, _ = (a.flags[o] & 32) != 0;
1054
+ for (var n = 0; n < c; n++) {
1055
+ var g = (a.flags[n] & 4) != 0, _ = (a.flags[n] & 32) != 0;
1056
1056
  g ? (a.ys.push(_ ? r[s] : -r[s]), s++) : _ ? a.ys.push(0) : (a.ys.push(t.readShort(r, s)), s += 2);
1057
1057
  }
1058
- for (var p = 0, b = 0, o = 0; o < c; o++)
1059
- p += a.xs[o], b += a.ys[o], a.xs[o] = p, a.ys[o] = b;
1058
+ for (var p = 0, b = 0, n = 0; n < c; n++)
1059
+ p += a.xs[n], b += a.ys[n], a.xs[n] = p, a.ys[n] = b;
1060
1060
  } else
1061
1061
  a.parts = [];
1062
1062
  return a;
@@ -1096,8 +1096,8 @@ class me {
1096
1096
  if (!(i === 65535 && s === 65535)) {
1097
1097
  for (let a = i; a <= s; a++)
1098
1098
  if (this._calculateGlyphIndexFormat4(e, a, r) > 0) {
1099
- const h = String.fromCodePoint(a);
1100
- t.push(h);
1099
+ const l = String.fromCodePoint(a);
1100
+ t.push(l);
1101
1101
  }
1102
1102
  }
1103
1103
  }
@@ -1114,9 +1114,9 @@ class me {
1114
1114
  return t;
1115
1115
  for (let r = 0; r < e.groups.length; r += 3) {
1116
1116
  const i = e.groups[r], s = e.groups[r + 1], a = e.groups[r + 2];
1117
- for (let o = i; o <= s; o++)
1118
- if (a + (o - i) > 0) {
1119
- const c = String.fromCodePoint(o);
1117
+ for (let n = i; n <= s; n++)
1118
+ if (a + (n - i) > 0) {
1119
+ const c = String.fromCodePoint(n);
1120
1120
  t.push(c);
1121
1121
  }
1122
1122
  }
@@ -1166,9 +1166,9 @@ class ge {
1166
1166
  * @param renderer The WebGL renderer instance
1167
1167
  */
1168
1168
  constructor(e) {
1169
- n(this, "_textureCanvas");
1170
- n(this, "_textureContext");
1171
- n(this, "_renderer");
1169
+ o(this, "_textureCanvas");
1170
+ o(this, "_textureContext");
1171
+ o(this, "_renderer");
1172
1172
  this._renderer = e, this._textureCanvas = document.createElement("canvas"), this._textureContext = this._textureCanvas.getContext("2d", { willReadFrequently: !0, alpha: !1 });
1173
1173
  }
1174
1174
  /**
@@ -1180,13 +1180,13 @@ class ge {
1180
1180
  * @returns Object containing framebuffer, columns, and rows
1181
1181
  */
1182
1182
  createTextureAtlas(e, t, r, i) {
1183
- const s = e.length, a = Math.ceil(Math.sqrt(s)), o = Math.ceil(s / a), h = t.width * a, c = t.height * o;
1184
- this._setupCanvas(h, c, r, i), this._renderCharactersToCanvas(e, t, a, r), this._applyBlackWhiteThreshold();
1185
- const u = this._renderer.createFramebuffer(h, c, { filter: "nearest" });
1183
+ const s = e.length, a = Math.ceil(Math.sqrt(s)), n = Math.ceil(s / a), l = t.width * a, c = t.height * n;
1184
+ this._setupCanvas(l, c, r, i), this._renderCharactersToCanvas(e, t, a, r), this._applyBlackWhiteThreshold();
1185
+ const u = this._renderer.createFramebuffer(l, c, { filter: "nearest" });
1186
1186
  return u.update(this._textureCanvas), {
1187
1187
  framebuffer: u,
1188
1188
  columns: a,
1189
- rows: o
1189
+ rows: n
1190
1190
  };
1191
1191
  }
1192
1192
  /**
@@ -1210,7 +1210,7 @@ class ge {
1210
1210
  */
1211
1211
  _renderCharactersToCanvas(e, t, r, i) {
1212
1212
  for (let s = 0; s < e.length; s++) {
1213
- const a = s % r, o = Math.floor(s / r), h = a * t.width + t.width * 0.5, c = o * t.height + t.height * 0.5, u = Math.round(h - t.width * 0.5), d = Math.round(c - i * 0.5);
1213
+ const a = s % r, n = Math.floor(s / r), l = a * t.width + t.width * 0.5, c = n * t.height + t.height * 0.5, u = Math.round(l - t.width * 0.5), d = Math.round(c - i * 0.5);
1214
1214
  this._textureContext.fillText(e[s].character, u, d);
1215
1215
  }
1216
1216
  }
@@ -1223,8 +1223,8 @@ class ge {
1223
1223
  _applyBlackWhiteThreshold(e = 128) {
1224
1224
  const t = this._textureContext.getImageData(0, 0, this._textureCanvas.width, this._textureCanvas.height), r = t.data;
1225
1225
  for (let i = 0; i < r.length; i += 4) {
1226
- const s = 0.299 * r[i] + 0.587 * r[i + 1] + 0.114 * r[i + 2], a = e + 32, o = s > a ? 255 : 0;
1227
- r[i] = o, r[i + 1] = o, r[i + 2] = o;
1226
+ const s = 0.299 * r[i] + 0.587 * r[i + 1] + 0.114 * r[i + 2], a = e + 32, n = s > a ? 255 : 0;
1227
+ r[i] = n, r[i + 1] = n, r[i + 2] = n;
1228
1228
  }
1229
1229
  this._textureContext.putImageData(t, 0, 0);
1230
1230
  }
@@ -1234,8 +1234,8 @@ class pe {
1234
1234
  * Creates a new MetricsCalculation instance.
1235
1235
  */
1236
1236
  constructor() {
1237
- n(this, "_tempCanvas");
1238
- n(this, "_tempContext");
1237
+ o(this, "_tempCanvas");
1238
+ o(this, "_tempContext");
1239
1239
  this._tempCanvas = document.createElement("canvas"), this._tempContext = this._tempCanvas.getContext("2d");
1240
1240
  }
1241
1241
  /**
@@ -1250,8 +1250,8 @@ class pe {
1250
1250
  this._tempContext.font = `${t}px ${r}`;
1251
1251
  let i = 0, s = 0;
1252
1252
  for (const a of e) {
1253
- const o = this._tempContext.measureText(a), h = o.width, c = o.actualBoundingBoxAscent + o.actualBoundingBoxDescent;
1254
- h > 0 && (i = Math.max(i, h), s = Math.max(s, c));
1253
+ const n = this._tempContext.measureText(a), l = n.width, c = n.actualBoundingBoxAscent + n.actualBoundingBoxDescent;
1254
+ l > 0 && (i = Math.max(i, l), s = Math.max(s, c));
1255
1255
  }
1256
1256
  return {
1257
1257
  width: Math.ceil(i),
@@ -1269,16 +1269,16 @@ class _e {
1269
1269
  createCharacterObjects(e, t) {
1270
1270
  return e.map((r, i) => {
1271
1271
  const s = r.codePointAt(0) || 0, a = this._generateCharacterColor(i);
1272
- let o = 0;
1272
+ let n = 0;
1273
1273
  if (t.hmtx && t.hmtx.aWidth) {
1274
- const h = this._getGlyphIndex(t, s);
1275
- h > 0 && t.hmtx.aWidth[h] !== void 0 && (o = t.hmtx.aWidth[h]);
1274
+ const l = this._getGlyphIndex(t, s);
1275
+ l > 0 && t.hmtx.aWidth[l] !== void 0 && (n = t.hmtx.aWidth[l]);
1276
1276
  }
1277
1277
  return {
1278
1278
  character: r,
1279
1279
  unicode: s,
1280
1280
  color: a,
1281
- advanceWidth: o
1281
+ advanceWidth: n
1282
1282
  };
1283
1283
  });
1284
1284
  }
@@ -1301,9 +1301,9 @@ class _e {
1301
1301
  {
1302
1302
  const a = i.idRangeOffset[s] / 2 + (t - i.startCount[s]) - (i.startCount.length - s);
1303
1303
  if (a >= 0 && a < i.glyphIdArray.length) {
1304
- const o = i.glyphIdArray[a];
1305
- if (o !== 0)
1306
- return o + i.idDelta[s] & 65535;
1304
+ const n = i.glyphIdArray[a];
1305
+ if (n !== 0)
1306
+ return n + i.idDelta[s] & 65535;
1307
1307
  }
1308
1308
  }
1309
1309
  }
@@ -1357,20 +1357,20 @@ class xe {
1357
1357
  * @ignore
1358
1358
  */
1359
1359
  constructor(e, t = 16) {
1360
- n(this, "_font");
1361
- n(this, "_characters", []);
1362
- n(this, "_fontFramebuffer");
1363
- n(this, "_fontSize", 16);
1364
- n(this, "_textureColumns", 0);
1365
- n(this, "_textureRows", 0);
1366
- n(this, "_maxGlyphDimensions", { width: 0, height: 0 });
1367
- n(this, "_fontFace");
1368
- n(this, "_fontFamilyName", "UrsaFont");
1360
+ o(this, "_font");
1361
+ o(this, "_characters", []);
1362
+ o(this, "_fontFramebuffer");
1363
+ o(this, "_fontSize", 16);
1364
+ o(this, "_textureColumns", 0);
1365
+ o(this, "_textureRows", 0);
1366
+ o(this, "_maxGlyphDimensions", { width: 0, height: 0 });
1367
+ o(this, "_fontFace");
1368
+ o(this, "_fontFamilyName", "UrsaFont");
1369
1369
  // Component classes
1370
- n(this, "_characterExtractor");
1371
- n(this, "_textureAtlas");
1372
- n(this, "_metricsCalculator");
1373
- n(this, "_characterColorMapper");
1370
+ o(this, "_characterExtractor");
1371
+ o(this, "_textureAtlas");
1372
+ o(this, "_metricsCalculator");
1373
+ o(this, "_characterColorMapper");
1374
1374
  this._fontSize = t, this._characterExtractor = new me(), this._textureAtlas = new ge(e), this._metricsCalculator = new pe(), this._characterColorMapper = new _e();
1375
1375
  }
1376
1376
  /**
@@ -1535,25 +1535,25 @@ class ve {
1535
1535
  */
1536
1536
  constructor(e, t, r) {
1537
1537
  /** The number of columns in the grid. */
1538
- n(this, "_cols");
1538
+ o(this, "_cols");
1539
1539
  /** The number of rows in the grid. */
1540
- n(this, "_rows");
1540
+ o(this, "_rows");
1541
1541
  /** The total width of the grid in pixels. */
1542
- n(this, "_width");
1542
+ o(this, "_width");
1543
1543
  /** The total height of the grid in pixels. */
1544
- n(this, "_height");
1544
+ o(this, "_height");
1545
1545
  /** The offset to the outer canvas on the x-axis when centering the grid. */
1546
- n(this, "_offsetX");
1546
+ o(this, "_offsetX");
1547
1547
  /** The offset to the outer canvas on the y-axis when centering the grid. */
1548
- n(this, "_offsetY");
1548
+ o(this, "_offsetY");
1549
1549
  /** Whether the grid dimensions are fixed, or responsive based on the canvas dimensions. */
1550
- n(this, "_fixedDimensions", !1);
1550
+ o(this, "_fixedDimensions", !1);
1551
1551
  /** The canvas element used to determine the grid dimensions. */
1552
- n(this, "_canvas");
1552
+ o(this, "_canvas");
1553
1553
  /** The width of each cell in the grid. */
1554
- n(this, "_cellWidth");
1554
+ o(this, "_cellWidth");
1555
1555
  /** The height of each cell in the grid. */
1556
- n(this, "_cellHeight");
1556
+ o(this, "_cellHeight");
1557
1557
  this._canvas = e, this._cellWidth = t, this._cellHeight = r, this.reset();
1558
1558
  }
1559
1559
  /**
@@ -1664,9 +1664,9 @@ class ve {
1664
1664
  }
1665
1665
  class be {
1666
1666
  constructor(e, t = !1, r = {}) {
1667
- n(this, "_canvas");
1668
- n(this, "captureSource");
1669
- n(this, "_isStandalone");
1667
+ o(this, "_canvas");
1668
+ o(this, "captureSource");
1669
+ o(this, "_isStandalone");
1670
1670
  this.captureSource = e, this._isStandalone = t, this._canvas = this.createCanvas(r.width, r.height);
1671
1671
  }
1672
1672
  createCanvas(e, t) {
@@ -1676,14 +1676,14 @@ class be {
1676
1676
  r.width = e || 800, r.height = t || 600, document.body.appendChild(r);
1677
1677
  else {
1678
1678
  const s = this.captureSource.getBoundingClientRect();
1679
- let a = Math.round(s.width), o = Math.round(s.height);
1679
+ let a = Math.round(s.width), n = Math.round(s.height);
1680
1680
  if (this.captureSource instanceof HTMLVideoElement) {
1681
1681
  const u = this.captureSource;
1682
- (a === 0 || o === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (a = u.videoWidth, o = u.videoHeight);
1682
+ (a === 0 || n === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (a = u.videoWidth, n = u.videoHeight);
1683
1683
  }
1684
- r.width = a, r.height = o, r.style.position = "absolute", r.style.pointerEvents = "none";
1685
- const h = window.getComputedStyle(this.captureSource);
1686
- let c = parseInt(h.zIndex || "0", 10);
1684
+ r.width = a, r.height = n, r.style.position = "absolute", r.style.pointerEvents = "none";
1685
+ const l = window.getComputedStyle(this.captureSource);
1686
+ let c = parseInt(l.zIndex || "0", 10);
1687
1687
  isNaN(c) && (c = 0), r.style.zIndex = (c + 1).toString(), this.positionOverlayCanvas(r), (i = this.captureSource.parentNode) == null || i.insertBefore(r, this.captureSource.nextSibling);
1688
1688
  }
1689
1689
  return r;
@@ -1762,15 +1762,15 @@ class U {
1762
1762
  * @ignore
1763
1763
  */
1764
1764
  constructor(e, t, r, i = {}) {
1765
- n(this, "renderer");
1766
- n(this, "fontManager");
1767
- n(this, "grid");
1768
- n(this, "_characterFramebuffer");
1769
- n(this, "_primaryColorFramebuffer");
1770
- n(this, "_secondaryColorFramebuffer");
1771
- n(this, "_rotationFramebuffer");
1772
- n(this, "_transformFramebuffer");
1773
- n(this, "_options");
1765
+ o(this, "renderer");
1766
+ o(this, "fontManager");
1767
+ o(this, "grid");
1768
+ o(this, "_characterFramebuffer");
1769
+ o(this, "_primaryColorFramebuffer");
1770
+ o(this, "_secondaryColorFramebuffer");
1771
+ o(this, "_rotationFramebuffer");
1772
+ o(this, "_transformFramebuffer");
1773
+ o(this, "_options");
1774
1774
  this.renderer = e, this.fontManager = t, this.grid = r, this._options = i, this._characterFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows), this._primaryColorFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows), this._secondaryColorFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows), this._rotationFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows), this._transformFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows);
1775
1775
  }
1776
1776
  /**
@@ -1839,9 +1839,9 @@ class Ce {
1839
1839
  */
1840
1840
  constructor(e, t) {
1841
1841
  /** The framebuffer used to store the color palette. */
1842
- n(this, "_framebuffer");
1843
- n(this, "_renderer");
1844
- n(this, "_colors");
1842
+ o(this, "_framebuffer");
1843
+ o(this, "_renderer");
1844
+ o(this, "_colors");
1845
1845
  this._renderer = e, this._colors = t;
1846
1846
  const r = Math.max(this._colors.length, 1);
1847
1847
  this._framebuffer = this._renderer.createFramebuffer(r, 1), this._updateFramebuffer();
@@ -1889,7 +1889,7 @@ class Ce {
1889
1889
  class H extends U {
1890
1890
  constructor(t, r, i, s = {}) {
1891
1891
  super(t, r, i, s);
1892
- n(this, "palette");
1892
+ o(this, "palette");
1893
1893
  this.palette = new Ce(this.renderer, this.fontManager.getCharacterColors(" .:-=+*%@#"));
1894
1894
  }
1895
1895
  /**
@@ -1912,7 +1912,7 @@ class H extends U {
1912
1912
  * @param a Alpha component (0-255).
1913
1913
  */
1914
1914
  characterColor(t, r, i, s = 255) {
1915
- let a, o, h, c;
1915
+ let a, n, l, c;
1916
1916
  if (typeof t == "string") {
1917
1917
  const u = this.parseHexColor(t);
1918
1918
  if (!u) {
@@ -1923,14 +1923,14 @@ class H extends U {
1923
1923
  );
1924
1924
  return;
1925
1925
  }
1926
- [a, o, h, c] = u;
1927
- } else if (a = t, o = r !== void 0 ? r : t, h = i !== void 0 ? i : t, c = s, !x.validate(
1928
- [a, o, h, c].every((u) => u >= 0 && u <= 255),
1926
+ [a, n, l, c] = u;
1927
+ } else if (a = t, n = r !== void 0 ? r : t, l = i !== void 0 ? i : t, c = s, !x.validate(
1928
+ [a, n, l, c].every((u) => u >= 0 && u <= 255),
1929
1929
  "Character color values must be between 0 and 255",
1930
- { method: "characterColor", providedValues: { r: a, g: o, b: h, a: c } }
1930
+ { method: "characterColor", providedValues: { r: a, g: n, b: l, a: c } }
1931
1931
  ))
1932
1932
  return;
1933
- this._options.characterColor = [a, o, h, c];
1933
+ this._options.characterColor = [a / 255, n / 255, l / 255, c / 255];
1934
1934
  }
1935
1935
  /**
1936
1936
  * Sets the character color mode.
@@ -1954,7 +1954,7 @@ class H extends U {
1954
1954
  * @param a Alpha component (0-255).
1955
1955
  */
1956
1956
  cellColor(t, r, i, s = 255) {
1957
- let a, o, h, c;
1957
+ let a, n, l, c;
1958
1958
  if (typeof t == "string") {
1959
1959
  const u = this.parseHexColor(t);
1960
1960
  if (!u) {
@@ -1965,14 +1965,14 @@ class H extends U {
1965
1965
  );
1966
1966
  return;
1967
1967
  }
1968
- [a, o, h, c] = u;
1969
- } else if (a = t, o = r !== void 0 ? r : t, h = i !== void 0 ? i : t, c = s, !x.validate(
1970
- [a, o, h, c].every((u) => u >= 0 && u <= 255),
1968
+ [a, n, l, c] = u;
1969
+ } else if (a = t, n = r !== void 0 ? r : t, l = i !== void 0 ? i : t, c = s, !x.validate(
1970
+ [a, n, l, c].every((u) => u >= 0 && u <= 255),
1971
1971
  "Cell color values must be between 0 and 255",
1972
- { method: "cellColor", providedValues: { r: a, g: o, b: h, a: c } }
1972
+ { method: "cellColor", providedValues: { r: a, g: n, b: l, a: c } }
1973
1973
  ))
1974
1974
  return;
1975
- this._options.cellColor = [a, o, h, c];
1975
+ this._options.cellColor = [a / 255, n / 255, l / 255, c / 255];
1976
1976
  }
1977
1977
  /**
1978
1978
  * Sets the cell color mode.
@@ -2055,11 +2055,13 @@ const Re = {
2055
2055
  /** Characters used for brightness mapping (from darkest to brightest) */
2056
2056
  characters: " .:-=+*%@#",
2057
2057
  /** Color of the ASCII characters. Only used when `characterColorMode` is set to `fixed` */
2058
- characterColor: [255, 255, 255, 255],
2058
+ characterColor: [1, 1, 1, 1],
2059
+ // White
2059
2060
  /** Character color mode */
2060
2061
  characterColorMode: "sampled",
2061
2062
  /** Cell background color. Only used when `characterColorMode` is set to `fixed` */
2062
- cellColor: [0, 0, 0, 255],
2063
+ cellColor: [0, 0, 0, 1],
2064
+ // Black
2063
2065
  /** Background color mode */
2064
2066
  cellColorMode: "fixed",
2065
2067
  /** Swap the cells ASCII character colors with it's cell background colors */
@@ -2083,16 +2085,16 @@ class L extends H {
2083
2085
  */
2084
2086
  constructor(t, r, i) {
2085
2087
  super(t, r, i, { ...Re });
2086
- n(this, "sampleShader");
2087
- n(this, "colorFillShader");
2088
- n(this, "charMappingShader");
2089
- n(this, "transformFillShader");
2090
- n(this, "rotationFillShader");
2091
- n(this, "sampleFramebuffer");
2088
+ o(this, "sampleShader");
2089
+ o(this, "colorFillShader");
2090
+ o(this, "charMappingShader");
2091
+ o(this, "transformFillShader");
2092
+ o(this, "rotationFillShader");
2093
+ o(this, "sampleFramebuffer");
2092
2094
  this.sampleShader = new y(t.context, T, Fe), this.colorFillShader = new y(t.context, T, we), this.transformFillShader = new y(t.context, T, ye), this.rotationFillShader = new y(t.context, T, Te), this.charMappingShader = new y(t.context, T, Se), this.sampleFramebuffer = this.renderer.createFramebuffer(this.grid.cols, this.grid.rows);
2093
2095
  }
2094
2096
  convert(t) {
2095
- this.sampleFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.sampleShader), this.renderer.setUniform("u_sketchTexture", t), this.renderer.setUniform("u_gridCellDimensions", [this.grid.cols, this.grid.rows]), this.renderer.setUniform("u_brightnessRange", this._options.brightnessRange), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this.sampleFramebuffer.end(), console.log("this.options.characterColor:", this._options.characterColor), this._primaryColorFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.colorFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_fillColor", this._options.characterColor), this.renderer.setUniform("u_useFixedColor", this._options.characterColorMode === "fixed"), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._primaryColorFramebuffer.end(), this._secondaryColorFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.colorFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_fillColor", this._options.cellColor), this.renderer.setUniform("u_useFixedColor", this._options.cellColorMode === "fixed"), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._secondaryColorFramebuffer.end(), this._transformFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.transformFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_invert", this._options.invert), this.renderer.setUniform("u_flipHorizontally", this._options.flipHorizontally), this.renderer.setUniform("u_flipVertically", this._options.flipVertically), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._transformFramebuffer.end(), this._rotationFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.rotationFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_rotationColor", this._options.rotation), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._rotationFramebuffer.end(), this._characterFramebuffer.begin(), this.renderer.clear(0, 0, 0, 0), this.renderer.shader(this.charMappingShader), this.renderer.setUniform("u_colorSampleFramebuffer", this.sampleFramebuffer.texture), this.renderer.setUniform("u_charPaletteTexture", this.palette.texture), this.renderer.setUniform("u_charPaletteSize", [this.palette.colors.length, 1]), this.renderer.setUniform("u_brightnessRange", this._options.brightnessRange), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._characterFramebuffer.end();
2097
+ this.sampleFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.sampleShader), this.renderer.setUniform("u_sketchTexture", t), this.renderer.setUniform("u_gridCellDimensions", [this.grid.cols, this.grid.rows]), this.renderer.setUniform("u_brightnessRange", this._options.brightnessRange), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this.sampleFramebuffer.end(), this._primaryColorFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.colorFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_fillColor", this._options.characterColor), this.renderer.setUniform("u_useFixedColor", this._options.characterColorMode === "fixed"), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._primaryColorFramebuffer.end(), this._secondaryColorFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.colorFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_fillColor", this._options.cellColor), this.renderer.setUniform("u_useFixedColor", this._options.cellColorMode === "fixed"), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._secondaryColorFramebuffer.end(), this._transformFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.transformFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_invert", this._options.invert), this.renderer.setUniform("u_flipHorizontally", this._options.flipHorizontally), this.renderer.setUniform("u_flipVertically", this._options.flipVertically), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._transformFramebuffer.end(), this._rotationFramebuffer.begin(), this.renderer.clear(), this.renderer.shader(this.rotationFillShader), this.renderer.setUniform("u_sampleTexture", this.sampleFramebuffer.texture), this.renderer.setUniform("u_rotationColor", this._options.rotation), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._rotationFramebuffer.end(), this._characterFramebuffer.begin(), this.renderer.clear(0, 0, 0, 0), this.renderer.shader(this.charMappingShader), this.renderer.setUniform("u_colorSampleFramebuffer", this.sampleFramebuffer.texture), this.renderer.setUniform("u_charPaletteTexture", this.palette.texture), this.renderer.setUniform("u_charPaletteSize", [this.palette.colors.length, 1]), this.renderer.setUniform("u_brightnessRange", this._options.brightnessRange), this.renderer.rect(0, 0, this.grid.cols, this.grid.rows), this._characterFramebuffer.end();
2096
2098
  }
2097
2099
  resize() {
2098
2100
  super.resize(), this.sampleFramebuffer.resize(this.grid.cols, this.grid.rows);
@@ -2128,17 +2130,17 @@ class Ue {
2128
2130
  * @ignore
2129
2131
  */
2130
2132
  constructor(e, t, r) {
2131
- n(this, "renderer");
2132
- n(this, "font");
2133
- n(this, "grid");
2134
- n(this, "converters");
2135
- n(this, "_resultFramebuffer");
2136
- n(this, "_asciiShader");
2137
- n(this, "_characterFramebuffer");
2138
- n(this, "_primaryColorFramebuffer");
2139
- n(this, "_secondaryColorFramebuffer");
2140
- n(this, "_rotationFramebuffer");
2141
- n(this, "_transformFramebuffer");
2133
+ o(this, "renderer");
2134
+ o(this, "font");
2135
+ o(this, "grid");
2136
+ o(this, "converters");
2137
+ o(this, "_resultFramebuffer");
2138
+ o(this, "_asciiShader");
2139
+ o(this, "_characterFramebuffer");
2140
+ o(this, "_primaryColorFramebuffer");
2141
+ o(this, "_secondaryColorFramebuffer");
2142
+ o(this, "_rotationFramebuffer");
2143
+ o(this, "_transformFramebuffer");
2142
2144
  this.renderer = e, this.font = t, this.grid = r, this._asciiShader = this.renderer.createShader(T, Ee), this.converters = [
2143
2145
  { name: "brightness", converter: new L(e, t, r) },
2144
2146
  { name: "custom", converter: new U(e, t, r) }
@@ -2305,13 +2307,13 @@ class X {
2305
2307
  * @returns Object containing all pixel data arrays
2306
2308
  */
2307
2309
  extractFramebufferData(e) {
2308
- const t = e.get("brightness"), r = t == null ? void 0 : t.characterFramebuffer, i = t == null ? void 0 : t.primaryColorFramebuffer, s = t == null ? void 0 : t.secondaryColorFramebuffer, a = t == null ? void 0 : t.transformFramebuffer, o = t == null ? void 0 : t.rotationFramebuffer;
2309
- return r == null || r.loadPixels(), i == null || i.loadPixels(), s == null || s.loadPixels(), a == null || a.loadPixels(), o == null || o.loadPixels(), {
2310
+ const t = e.get("brightness"), r = t == null ? void 0 : t.characterFramebuffer, i = t == null ? void 0 : t.primaryColorFramebuffer, s = t == null ? void 0 : t.secondaryColorFramebuffer, a = t == null ? void 0 : t.transformFramebuffer, n = t == null ? void 0 : t.rotationFramebuffer;
2311
+ return r == null || r.loadPixels(), i == null || i.loadPixels(), s == null || s.loadPixels(), a == null || a.loadPixels(), n == null || n.loadPixels(), {
2310
2312
  characterPixels: (r == null ? void 0 : r.pixels) || new Uint8Array(0),
2311
2313
  primaryColorPixels: (i == null ? void 0 : i.pixels) || new Uint8Array(0),
2312
2314
  secondaryColorPixels: (s == null ? void 0 : s.pixels) || new Uint8Array(0),
2313
2315
  transformPixels: (a == null ? void 0 : a.pixels) || new Uint8Array(0),
2314
- rotationPixels: (o == null ? void 0 : o.pixels) || new Uint8Array(0)
2316
+ rotationPixels: (n == null ? void 0 : n.pixels) || new Uint8Array(0)
2315
2317
  };
2316
2318
  }
2317
2319
  /**
@@ -2340,7 +2342,7 @@ class X {
2340
2342
  };
2341
2343
  }
2342
2344
  }
2343
- class N {
2345
+ class O {
2344
2346
  /**
2345
2347
  * Creates a downloadable blob from content
2346
2348
  * @param content The content to include in the blob
@@ -2406,10 +2408,10 @@ class Ae extends X {
2406
2408
  * @returns Transform data object
2407
2409
  */
2408
2410
  extractTransformData(e, t, r) {
2409
- const i = e[r], s = e[r + 1], a = e[r + 2], o = i === 255, h = s === 255, c = a === 255, u = t[r], d = t[r + 1], f = u + d / 255, g = Math.round(f * 360 / 255 * 100) / 100;
2411
+ const i = e[r], s = e[r + 1], a = e[r + 2], n = i === 255, l = s === 255, c = a === 255, u = t[r], d = t[r + 1], f = u + d / 255, g = Math.round(f * 360 / 255 * 100) / 100;
2410
2412
  return {
2411
- isInverted: o,
2412
- flipHorizontal: h,
2413
+ isInverted: n,
2414
+ flipHorizontal: l,
2413
2415
  flipVertical: c,
2414
2416
  rotation: g
2415
2417
  };
@@ -2441,15 +2443,15 @@ class Ae extends X {
2441
2443
  let i = 0;
2442
2444
  for (let s = 0; s < t.rows; s++)
2443
2445
  for (let a = 0; a < t.cols; a++) {
2444
- const o = i * 4, h = this.getCharacterIndex(
2446
+ const n = i * 4, l = this.getCharacterIndex(
2445
2447
  e.characterPixels,
2446
- o
2448
+ n
2447
2449
  );
2448
- let c = this.pixelsToRGBA(e.primaryColorPixels, o), u = this.pixelsToRGBA(e.secondaryColorPixels, o);
2450
+ let c = this.pixelsToRGBA(e.primaryColorPixels, n), u = this.pixelsToRGBA(e.secondaryColorPixels, n);
2449
2451
  const d = this.extractTransformData(
2450
2452
  e.transformPixels,
2451
2453
  e.rotationPixels,
2452
- o
2454
+ n
2453
2455
  );
2454
2456
  if (d.isInverted) {
2455
2457
  const g = c;
@@ -2457,7 +2459,7 @@ class Ae extends X {
2457
2459
  }
2458
2460
  const f = this.calculateCellPosition(a, s, t);
2459
2461
  r.push({
2460
- charIndex: h,
2462
+ charIndex: l,
2461
2463
  primaryColor: c,
2462
2464
  secondaryColor: u,
2463
2465
  transform: d,
@@ -2486,9 +2488,9 @@ class Me {
2486
2488
  {
2487
2489
  const a = i.idRangeOffset[s] / 2 + (t - i.startCount[s]) - (i.startCount.length - s);
2488
2490
  if (a >= 0 && a < i.glyphIdArray.length) {
2489
- const o = i.glyphIdArray[a];
2490
- if (o !== 0)
2491
- return o + i.idDelta[s] & 65535;
2491
+ const n = i.glyphIdArray[a];
2492
+ if (n !== 0)
2493
+ return n + i.idDelta[s] & 65535;
2492
2494
  }
2493
2495
  }
2494
2496
  }
@@ -2538,24 +2540,24 @@ class Me {
2538
2540
  */
2539
2541
  glyphToSVGPath(e, t, r, i) {
2540
2542
  if (!e || !e.xs) return "";
2541
- const { xs: s, ys: a, endPts: o, flags: h } = e;
2542
- if (!s || !a || !o || !h) return "";
2543
+ const { xs: s, ys: a, endPts: n, flags: l } = e;
2544
+ if (!s || !a || !n || !l) return "";
2543
2545
  let c = "", u = 0;
2544
- for (let d = 0; d < o.length; d++) {
2545
- const f = o[d];
2546
+ for (let d = 0; d < n.length; d++) {
2547
+ const f = n[d];
2546
2548
  if (!(f < u)) {
2547
2549
  if (f >= u) {
2548
2550
  const g = t + s[u] * i, _ = r - a[u] * i;
2549
2551
  c += `M${g.toFixed(2)},${_.toFixed(2)}`;
2550
2552
  let p = u + 1;
2551
2553
  for (; p <= f; )
2552
- if ((h[p] & 1) !== 0) {
2554
+ if ((l[p] & 1) !== 0) {
2553
2555
  const C = t + s[p] * i, v = r - a[p] * i;
2554
2556
  c += `L${C.toFixed(2)},${v.toFixed(2)}`, p++;
2555
2557
  } else {
2556
2558
  const C = t + s[p] * i, v = r - a[p] * i;
2557
2559
  let w = p + 1 > f ? u : p + 1;
2558
- if ((h[w] & 1) !== 0) {
2560
+ if ((l[w] & 1) !== 0) {
2559
2561
  const R = t + s[w] * i, S = r - a[w] * i;
2560
2562
  c += `Q${C.toFixed(2)},${v.toFixed(2)} ${R.toFixed(2)},${S.toFixed(2)}`, p = w + 1;
2561
2563
  } else {
@@ -2581,16 +2583,16 @@ class Me {
2581
2583
  */
2582
2584
  generateCharacterPath(e, t, r, i, s) {
2583
2585
  try {
2584
- const a = e.codePointAt(0) || 0, o = this.getGlyphIndex(t, a);
2585
- if (o === 0)
2586
+ const a = e.codePointAt(0) || 0, n = this.getGlyphIndex(t, a);
2587
+ if (n === 0)
2586
2588
  return this.createEmptyPath();
2587
- let h = null;
2589
+ let l = null;
2588
2590
  try {
2589
- t.glyf && t.glyf[o] !== null ? h = t.glyf[o] : m && m.T && m.T.glyf && m.T.glyf._parseGlyf && (h = m.T.glyf._parseGlyf(t, o), t.glyf && h && (t.glyf[o] = h));
2591
+ t.glyf && t.glyf[n] !== null ? l = t.glyf[n] : m && m.T && m.T.glyf && m.T.glyf._parseGlyf && (l = m.T.glyf._parseGlyf(t, n), t.glyf && l && (t.glyf[n] = l));
2590
2592
  } catch (c) {
2591
- console.warn(`Failed to parse glyph ${o}:`, c);
2593
+ console.warn(`Failed to parse glyph ${n}:`, c);
2592
2594
  }
2593
- return h ? this.createGlyphPath(t, h, r, i, s) : this.createEmptyPath();
2595
+ return l ? this.createGlyphPath(t, l, r, i, s) : this.createEmptyPath();
2594
2596
  } catch (a) {
2595
2597
  return console.warn(`Failed to generate path for character "${e}":`, a), this.createEmptyPath();
2596
2598
  }
@@ -2607,10 +2609,10 @@ class Me {
2607
2609
  * @param advanceWidth Character advance width
2608
2610
  * @returns SVG path data string or null if generation fails
2609
2611
  */
2610
- generatePositionedCharacterPath(e, t, r, i, s, a, o, h) {
2612
+ generatePositionedCharacterPath(e, t, r, i, s, a, n, l) {
2611
2613
  try {
2612
- const c = o / t.head.unitsPerEm, u = h * c, d = r + (s - u) / 2, f = i + (a + o * 0.7) / 2;
2613
- return this.generateCharacterPath(e, t, d, f, o).toSVG() || null;
2614
+ const c = n / t.head.unitsPerEm, u = l * c, d = r + (s - u) / 2, f = i + (a + n * 0.7) / 2;
2615
+ return this.generateCharacterPath(e, t, d, f, n).toSVG() || null;
2614
2616
  } catch (c) {
2615
2617
  return console.warn(`Failed to generate positioned character path for "${e}":`, c), null;
2616
2618
  }
@@ -2618,7 +2620,7 @@ class Me {
2618
2620
  }
2619
2621
  class De {
2620
2622
  constructor() {
2621
- n(this, "pathGenerator");
2623
+ o(this, "pathGenerator");
2622
2624
  this.pathGenerator = new Me();
2623
2625
  }
2624
2626
  /**
@@ -2671,12 +2673,12 @@ class De {
2671
2673
  * @returns Transform attribute string or empty string
2672
2674
  */
2673
2675
  generateTransformAttribute(e, t) {
2674
- const { transform: r, position: i } = e, s = i.cellX + t.cellWidth / 2, a = i.cellY + t.cellHeight / 2, o = [];
2676
+ const { transform: r, position: i } = e, s = i.cellX + t.cellWidth / 2, a = i.cellY + t.cellHeight / 2, n = [];
2675
2677
  if (r.flipHorizontal || r.flipVertical) {
2676
- const h = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
2677
- o.push(`translate(${s} ${a})`), o.push(`scale(${h} ${c})`), o.push(`translate(${-s} ${-a})`);
2678
+ const l = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
2679
+ n.push(`translate(${s} ${a})`), n.push(`scale(${l} ${c})`), n.push(`translate(${-s} ${-a})`);
2678
2680
  }
2679
- return r.rotation && o.push(`rotate(${r.rotation} ${s} ${a})`), o.length ? ` transform="${o.join(" ")}"` : "";
2681
+ return r.rotation && n.push(`rotate(${r.rotation} ${s} ${a})`), n.length ? ` transform="${n.join(" ")}"` : "";
2680
2682
  }
2681
2683
  /**
2682
2684
  * Generates background rectangle for a cell
@@ -2717,10 +2719,10 @@ class De {
2717
2719
  );
2718
2720
  if (!a)
2719
2721
  return "";
2720
- const o = this.rgbaToColorString(e.primaryColor);
2722
+ const n = this.rgbaToColorString(e.primaryColor);
2721
2723
  return i.drawMode === "stroke" ? `
2722
- <path id="${`path-${e.charIndex}-${e.position.cellX}-${e.position.cellY}`.replace(/\./g, "-")}" d="${a}" stroke="${o}" stroke-width="${i.strokeWidth}" fill="none" />` : `
2723
- <path d="${a}" fill="${o}" />`;
2724
+ <path id="${`path-${e.charIndex}-${e.position.cellX}-${e.position.cellY}`.replace(/\./g, "-")}" d="${a}" stroke="${n}" stroke-width="${i.strokeWidth}" fill="none" />` : `
2725
+ <path d="${a}" fill="${n}" />`;
2724
2726
  }
2725
2727
  /**
2726
2728
  * Generates complete SVG content for a single cell
@@ -2733,10 +2735,10 @@ class De {
2733
2735
  generateCellContent(e, t, r, i) {
2734
2736
  let s = "";
2735
2737
  s += this.generateCellBackground(e, t, i);
2736
- const a = this.generateTransformAttribute(e, t), o = this.generateCharacterPath(e, t, r, i);
2737
- return o && (a ? (s += `
2738
- <g${a}>`, s += o, s += `
2739
- </g>`) : s += o), s;
2738
+ const a = this.generateTransformAttribute(e, t), n = this.generateCharacterPath(e, t, r, i);
2739
+ return n && (a ? (s += `
2740
+ <g${a}>`, s += n, s += `
2741
+ </g>`) : s += n), s;
2740
2742
  }
2741
2743
  /**
2742
2744
  * Generates the complete SVG content from cell data
@@ -2764,7 +2766,7 @@ class De {
2764
2766
  `).replace(/[ \t]+$/gm, "");
2765
2767
  }
2766
2768
  }
2767
- class Ie extends N {
2769
+ class Ie extends O {
2768
2770
  /**
2769
2771
  * Creates a downloadable blob from SVG content
2770
2772
  * @param svgContent The SVG content string
@@ -2796,9 +2798,9 @@ class Ie extends N {
2796
2798
  }
2797
2799
  class Y {
2798
2800
  constructor() {
2799
- n(this, "dataExtractor");
2800
- n(this, "contentGenerator");
2801
- n(this, "fileHandler");
2801
+ o(this, "dataExtractor");
2802
+ o(this, "contentGenerator");
2803
+ o(this, "fileHandler");
2802
2804
  this.dataExtractor = new Ae(), this.contentGenerator = new De(), this.fileHandler = new Ie();
2803
2805
  }
2804
2806
  /**
@@ -2856,16 +2858,16 @@ class Pe extends X {
2856
2858
  * @returns 2D array of characters (rows x columns)
2857
2859
  */
2858
2860
  extractCharacterGrid(e, t, r, i = " ") {
2859
- var o;
2861
+ var n;
2860
2862
  const s = [];
2861
2863
  let a = 0;
2862
- for (let h = 0; h < t.rows; h++) {
2864
+ for (let l = 0; l < t.rows; l++) {
2863
2865
  const c = [];
2864
2866
  for (let u = 0; u < t.cols; u++) {
2865
2867
  const d = a * 4, f = this.getCharacterIndex(
2866
2868
  e.characterPixels,
2867
2869
  d
2868
- ), g = ((o = r.characters[f]) == null ? void 0 : o.character) || i;
2870
+ ), g = ((n = r.characters[f]) == null ? void 0 : n.character) || i;
2869
2871
  c.push(g), a++;
2870
2872
  }
2871
2873
  s.push(c);
@@ -2892,7 +2894,7 @@ class Be {
2892
2894
  return r.join(i);
2893
2895
  }
2894
2896
  }
2895
- class Ge extends N {
2897
+ class Ge extends O {
2896
2898
  /**
2897
2899
  * Saves TXT content as a downloadable file
2898
2900
  * @param content The TXT content to save
@@ -2918,9 +2920,9 @@ class Ge extends N {
2918
2920
  }
2919
2921
  class j {
2920
2922
  constructor() {
2921
- n(this, "dataExtractor");
2922
- n(this, "contentGenerator");
2923
- n(this, "fileHandler");
2923
+ o(this, "dataExtractor");
2924
+ o(this, "contentGenerator");
2925
+ o(this, "fileHandler");
2924
2926
  this.dataExtractor = new Pe(), this.contentGenerator = new Be(), this.fileHandler = new Ge();
2925
2927
  }
2926
2928
  /**
@@ -2979,8 +2981,8 @@ class Ve extends X {
2979
2981
  const i = e.canvas;
2980
2982
  if (t === 1 && r === "transparent")
2981
2983
  return i;
2982
- const s = document.createElement("canvas"), a = s.getContext("2d"), o = Math.round(i.width * t), h = Math.round(i.height * t);
2983
- return s.width = o, s.height = h, r !== "transparent" && (a.fillStyle = r, a.fillRect(0, 0, o, h)), a.imageSmoothingEnabled = !1, a.drawImage(
2984
+ const s = document.createElement("canvas"), a = s.getContext("2d"), n = Math.round(i.width * t), l = Math.round(i.height * t);
2985
+ return s.width = n, s.height = l, r !== "transparent" && (a.fillStyle = r, a.fillRect(0, 0, n, l)), a.imageSmoothingEnabled = !1, a.drawImage(
2984
2986
  i,
2985
2987
  0,
2986
2988
  0,
@@ -2988,8 +2990,8 @@ class Ve extends X {
2988
2990
  i.height,
2989
2991
  0,
2990
2992
  0,
2991
- o,
2992
- h
2993
+ n,
2994
+ l
2993
2995
  ), s;
2994
2996
  }
2995
2997
  }
@@ -3012,8 +3014,8 @@ class ke {
3012
3014
  */
3013
3015
  async generateImageBlob(e, t) {
3014
3016
  return new Promise((r, i) => {
3015
- const s = this.getMimeType(t.format), a = (o) => {
3016
- o ? r(o) : i(new Error(`Failed to generate ${t.format.toUpperCase()} blob`));
3017
+ const s = this.getMimeType(t.format), a = (n) => {
3018
+ n ? r(n) : i(new Error(`Failed to generate ${t.format.toUpperCase()} blob`));
3017
3019
  };
3018
3020
  t.format === "png" ? e.toBlob(a, s) : e.toBlob(a, s, t.quality);
3019
3021
  });
@@ -3045,7 +3047,7 @@ const q = {
3045
3047
  jpg: ".jpg",
3046
3048
  webp: ".webp"
3047
3049
  };
3048
- class ze extends N {
3050
+ class ze extends O {
3049
3051
  /**
3050
3052
  * Saves image content as a downloadable file
3051
3053
  * @param content The image content (data URL or blob)
@@ -3110,9 +3112,9 @@ class ze extends N {
3110
3112
  }
3111
3113
  class $e {
3112
3114
  constructor() {
3113
- n(this, "dataExtractor");
3114
- n(this, "contentGenerator");
3115
- n(this, "fileHandler");
3115
+ o(this, "dataExtractor");
3116
+ o(this, "contentGenerator");
3117
+ o(this, "fileHandler");
3116
3118
  this.dataExtractor = new Ve(), this.contentGenerator = new ke(), this.fileHandler = new ze();
3117
3119
  }
3118
3120
  /**
@@ -3199,37 +3201,38 @@ class $e {
3199
3201
  class I {
3200
3202
  constructor(e = null, t = {}) {
3201
3203
  /** The element to capture content from (optional for standalone mode) */
3202
- n(this, "captureSource");
3204
+ o(this, "captureSource");
3203
3205
  /** Our WebGL overlay canvas manager */
3204
- n(this, "textmodeCanvas");
3206
+ o(this, "textmodeCanvas");
3205
3207
  /** Core WebGL renderer */
3206
- n(this, "_renderer");
3207
- n(this, "_canvasFramebuffer");
3208
- n(this, "_font");
3209
- n(this, "_grid");
3210
- n(this, "resizeObserver");
3208
+ o(this, "_renderer");
3209
+ o(this, "_canvasFramebuffer");
3210
+ o(this, "_font");
3211
+ o(this, "_grid");
3212
+ o(this, "resizeObserver");
3211
3213
  // Auto-rendering properties
3212
- n(this, "_mode");
3213
- n(this, "_frameRateLimit");
3214
- n(this, "animationFrameId", null);
3215
- n(this, "lastFrameTime", 0);
3216
- n(this, "frameInterval");
3217
- n(this, "_isLooping", !0);
3218
- n(this, "_frameRate", 0);
3219
- n(this, "lastRenderTime", 0);
3220
- n(this, "_frameCount", 0);
3214
+ o(this, "_mode");
3215
+ o(this, "_frameRateLimit");
3216
+ o(this, "animationFrameId", null);
3217
+ o(this, "lastFrameTime", 0);
3218
+ o(this, "frameInterval");
3219
+ o(this, "_isLooping", !0);
3220
+ o(this, "_frameRate", 0);
3221
+ o(this, "lastRenderTime", 0);
3222
+ o(this, "_frameCount", 0);
3221
3223
  // Frame rate measurement smoothing
3222
- n(this, "frameTimeHistory", []);
3223
- n(this, "frameTimeHistorySize", 10);
3224
- n(this, "_pipeline");
3225
- n(this, "_isDisposed", !1);
3224
+ o(this, "frameTimeHistory", []);
3225
+ o(this, "frameTimeHistorySize", 10);
3226
+ o(this, "_pipeline");
3227
+ o(this, "_isDisposed", !1);
3226
3228
  // Standalone canvas properties
3227
- n(this, "_standalone", !1);
3228
- n(this, "_drawCallback", () => {
3229
+ o(this, "_standalone", !1);
3230
+ o(this, "_drawCallback", () => {
3229
3231
  });
3230
- n(this, "_resizedCallback", () => {
3232
+ o(this, "_resizedCallback", () => {
3231
3233
  });
3232
- n(this, "_windowResizeListener", null);
3234
+ o(this, "_windowResizeListener", null);
3235
+ o(this, "_printDebug", !1);
3233
3236
  this.captureSource = e, this._standalone = e === null, this._mode = t.renderMode ?? "auto", this._frameRateLimit = t.frameRate ?? 60, this.frameInterval = 1e3 / this._frameRateLimit;
3234
3237
  }
3235
3238
  /**
@@ -3243,8 +3246,8 @@ class I {
3243
3246
  r.textmodeCanvas = new be(r.captureSource, r._standalone, i), r._renderer = new fe(r.textmodeCanvas.getWebGLContext());
3244
3247
  let s, a;
3245
3248
  r._standalone ? (s = t.width || 800, a = t.height || 600) : (s = r.textmodeCanvas.width || 800, a = r.textmodeCanvas.height || 600), r._canvasFramebuffer = r._renderer.createFramebuffer(s, a), r._font = new xe(r._renderer, t.fontSize ?? 16), await r._font.initialize(t.fontSource);
3246
- const o = r._font.maxGlyphDimensions;
3247
- return r._grid = new ve(r.textmodeCanvas.canvas, o.width, o.height), r._pipeline = new Ue(r._renderer, r._font, r._grid), r.setupEventListeners(), r.startAutoRendering(), r;
3249
+ const n = r._font.maxGlyphDimensions;
3250
+ return r._grid = new ve(r.textmodeCanvas.canvas, n.width, n.height), r._pipeline = new Ue(r._renderer, r._font, r._grid), r.setupEventListeners(), r.startAutoRendering(), r;
3248
3251
  }
3249
3252
  setupEventListeners() {
3250
3253
  this._windowResizeListener = () => {
@@ -3479,7 +3482,10 @@ class I {
3479
3482
  console.warn("Cannot complete render: Pipeline or renderer has been disposed");
3480
3483
  return;
3481
3484
  }
3482
- this._pipeline.render(this._canvasFramebuffer), this._pipeline.hasEnabledConverters() ? this._renderer && this._pipeline.texture && this._grid && (this._renderer.background(0), this._renderer.image(this._pipeline.texture, this._grid.offsetX, this._grid.offsetY, this._pipeline.texture.width, this._pipeline.texture.height)) : this._renderer && this._canvasFramebuffer && this._grid && (this._renderer.clear(), this._renderer.image(this._canvasFramebuffer, this._grid.offsetX, this._grid.offsetY, this._canvasFramebuffer.width, this._canvasFramebuffer.height));
3485
+ if (this._pipeline.render(this._canvasFramebuffer), this._pipeline.hasEnabledConverters() ? (this._renderer.background(0), this._renderer.image(this._pipeline.texture, this._grid.offsetX, this._grid.offsetY, this._pipeline.texture.width, this._pipeline.texture.height)) : (this._renderer.clear(), this._renderer.image(this._canvasFramebuffer, this._grid.offsetX, this._grid.offsetY, this._canvasFramebuffer.width, this._canvasFramebuffer.height)), this._printDebug) {
3486
+ let e = 0;
3487
+ this._renderer.image(this._pipeline.characterFramebuffer, e, 0, this._pipeline.characterFramebuffer.width, this._pipeline.characterFramebuffer.height), e += this._pipeline.characterFramebuffer.width, this._renderer.image(this._pipeline.primaryColorFramebuffer, e, 0, this._pipeline.primaryColorFramebuffer.width, this._pipeline.primaryColorFramebuffer.height), e += this._pipeline.primaryColorFramebuffer.width, this._renderer.image(this._pipeline.secondaryColorFramebuffer, e, 0, this._pipeline.secondaryColorFramebuffer.width, this._pipeline.secondaryColorFramebuffer.height), e += this._pipeline.secondaryColorFramebuffer.width, this._renderer.image(this._pipeline.transformFramebuffer, e, 0, this._pipeline.transformFramebuffer.width, this._pipeline.transformFramebuffer.height), e += this._pipeline.transformFramebuffer.width, this._renderer.image(this._pipeline.rotationFramebuffer, e, 0, this._pipeline.rotationFramebuffer.width, this._pipeline.rotationFramebuffer.height);
3488
+ }
3483
3489
  }
3484
3490
  resize() {
3485
3491
  this.textmodeCanvas.resize(), this._canvasFramebuffer.resize(this.textmodeCanvas.width, this.textmodeCanvas.height), this._grid.resize(), this._pipeline.resize(), this._renderer.resetViewport(), this._mode !== "manual" && this.render();
@@ -4228,6 +4234,9 @@ class I {
4228
4234
  }, this._resizedCallback = () => {
4229
4235
  }, this.animationFrameId = null, this.lastFrameTime = 0, this.lastRenderTime = 0, this._frameCount = 0, this._frameRate = 0, this.frameTimeHistory = [], this._isLooping = !1;
4230
4236
  }
4237
+ debug(e) {
4238
+ this._printDebug = e;
4239
+ }
4231
4240
  /** Get the current grid object used for rendering. */
4232
4241
  get grid() {
4233
4242
  return this._grid;
@@ -4264,7 +4273,7 @@ class I {
4264
4273
  return this._isDisposed;
4265
4274
  }
4266
4275
  }
4267
- class O {
4276
+ class N {
4268
4277
  /**
4269
4278
  * Create a {@link Textmodifier} instance for textmode rendering.
4270
4279
  *
@@ -4354,7 +4363,7 @@ class O {
4354
4363
  * ```
4355
4364
  */
4356
4365
  static get version() {
4357
- return "0.1.4-beta.5";
4366
+ return "0.1.4-beta.8";
4358
4367
  }
4359
4368
  constructor() {
4360
4369
  throw new Error("Textmode is a static class and cannot be instantiated.");
@@ -4362,19 +4371,19 @@ class O {
4362
4371
  }
4363
4372
  const Xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4364
4373
  __proto__: null
4365
- }, Symbol.toStringTag, { value: "Module" })), Ne = O.create, Oe = O.setErrorLevel, We = O.version;
4374
+ }, Symbol.toStringTag, { value: "Module" })), Oe = N.create, Ne = N.setErrorLevel, We = N.version;
4366
4375
  export {
4367
4376
  be as TextmodeCanvas,
4368
4377
  Ue as TextmodeConversionPipeline,
4369
- oe as TextmodeErrorLevel,
4378
+ ne as TextmodeErrorLevel,
4370
4379
  xe as TextmodeFont,
4371
4380
  ve as TextmodeGrid,
4372
4381
  I as Textmodifier,
4373
4382
  He as converters,
4374
- Ne as create,
4375
- O as default,
4383
+ Oe as create,
4384
+ N as default,
4376
4385
  Xe as export,
4377
- Oe as setErrorLevel,
4378
- O as textmode,
4386
+ Ne as setErrorLevel,
4387
+ N as textmode,
4379
4388
  We as version
4380
4389
  };