@d3p1/img2pxl 1.18.3 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/img2pxl.js CHANGED
@@ -1,13 +1,13 @@
1
- var ge = Object.defineProperty;
1
+ var Te = Object.defineProperty;
2
2
  var pe = (o) => {
3
3
  throw TypeError(o);
4
4
  };
5
- var Me = (o, e, t) => e in o ? ge(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
5
+ var Me = (o, e, t) => e in o ? Te(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
6
6
  var q = (o, e, t) => Me(o, typeof e != "symbol" ? e + "" : e, t), G = (o, e, t) => e.has(o) || pe("Cannot " + t);
7
7
  var i = (o, e, t) => (G(o, e, "read from private field"), t ? t.call(o) : e.get(o)), a = (o, e, t) => e.has(o) ? pe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), l = (o, e, t, s) => (G(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), n = (o, e, t) => (G(o, e, "access private method"), t);
8
- import { Pane as je } from "tweakpane";
8
+ import { Pane as ke } from "tweakpane";
9
9
  import * as V from "three";
10
- class ke {
10
+ class je {
11
11
  constructor() {
12
12
  this._previousTime = 0, this._currentTime = 0, this._startTime = B(), this._delta = 0, this._elapsed = 0, this._timescale = 1, this._usePageVisibilityAPI = typeof document < "u" && document.hidden !== void 0, this._usePageVisibilityAPI === !0 && (this._pageVisibilityHandler = Je.bind(this), document.addEventListener("visibilitychange", this._pageVisibilityHandler, !1));
13
13
  }
@@ -397,7 +397,7 @@ void main() {
397
397
 
398
398
  #include <tonemapping_fragment>
399
399
  #include <colorspace_fragment>
400
- }`, x, L, O, F, Ke, H, A, qe;
400
+ }`, x, L, g, F, Ke, H, A, qe;
401
401
  let Ge = (qe = class {
402
402
  /**
403
403
  * Constructor
@@ -426,8 +426,8 @@ let Ge = (qe = class {
426
426
  /**
427
427
  * @type {Pane}
428
428
  */
429
- a(this, O);
430
- l(this, L, e), l(this, O, t), n(this, F, Ke).call(this, s, r, m, h);
429
+ a(this, g);
430
+ l(this, L, e), l(this, g, t), n(this, F, Ke).call(this, s, r, m, h);
431
431
  }
432
432
  /**
433
433
  * Enable debug mode
@@ -435,7 +435,7 @@ let Ge = (qe = class {
435
435
  * @returns {void}
436
436
  */
437
437
  debug() {
438
- const e = i(this, O).addFolder({
438
+ const e = i(this, g).addFolder({
439
439
  title: "Image Resolution"
440
440
  });
441
441
  e.addBinding(
@@ -450,7 +450,7 @@ let Ge = (qe = class {
450
450
  { min: 0, max: this.points.geometry.parameters.height, step: 1 }
451
451
  ).on("change", (s) => {
452
452
  s.last && n(this, F, H).call(this, this.points.geometry.parameters.widthSegments, s.value);
453
- }), i(this, O).addFolder({ title: "Image Pixel" }).addBinding(
453
+ }), i(this, g).addFolder({ title: "Image Pixel" }).addBinding(
454
454
  { size: this.points.material.uniforms.uPointSize.value },
455
455
  "size",
456
456
  { min: 1, max: 100, step: 1 }
@@ -466,7 +466,7 @@ let Ge = (qe = class {
466
466
  dispose() {
467
467
  this.points.geometry.dispose(), this.points.material.dispose(), i(this, x).dispose();
468
468
  }
469
- }, x = new WeakMap(), L = new WeakMap(), O = new WeakMap(), F = new WeakSet(), /**
469
+ }, x = new WeakMap(), L = new WeakMap(), g = new WeakMap(), F = new WeakSet(), /**
470
470
  * Init points
471
471
  *
472
472
  * @param {string} imageSrc
@@ -524,7 +524,7 @@ A = function(e, t, s = null) {
524
524
  );
525
525
  return r.setIndex(null), r.deleteAttribute("normal"), s && (r.attributes = { ...s, ...r.attributes }), r;
526
526
  }, qe);
527
- var R, T, g, b, Xe, Fe, be, Ze;
527
+ var R, O, T, b, Xe, Fe, be, Ze;
528
528
  class Be {
529
529
  /**
530
530
  * Constructor
@@ -557,11 +557,11 @@ class Be {
557
557
  /**
558
558
  * @type {Function}
559
559
  */
560
- a(this, T);
560
+ a(this, O);
561
561
  /**
562
562
  * @type {Function}
563
563
  */
564
- a(this, g);
564
+ a(this, T);
565
565
  this.canvas = t, this.coord = new V.Vector2(void 0, void 0), l(this, R, e), n(this, b, be).call(this);
566
566
  }
567
567
  /**
@@ -601,7 +601,7 @@ class Be {
601
601
  this.canvas.dispose(), n(this, b, Ze).call(this);
602
602
  }
603
603
  }
604
- R = new WeakMap(), T = new WeakMap(), g = new WeakMap(), b = new WeakSet(), /**
604
+ R = new WeakMap(), O = new WeakMap(), T = new WeakMap(), b = new WeakSet(), /**
605
605
  * Process pointer move
606
606
  *
607
607
  * @param {PointerEvent} e
@@ -629,12 +629,12 @@ Fe = function() {
629
629
  * working between the raycaster and image points
630
630
  */
631
631
  be = function() {
632
- this.raycaster = new V.Raycaster(), l(this, T, n(this, b, Xe).bind(this)), i(this, R).renderer.domElement.addEventListener(
632
+ this.raycaster = new V.Raycaster(), l(this, O, n(this, b, Xe).bind(this)), i(this, R).renderer.domElement.addEventListener(
633
633
  "pointermove",
634
- i(this, T)
635
- ), l(this, g, n(this, b, Fe).bind(this)), i(this, R).renderer.domElement.addEventListener(
634
+ i(this, O)
635
+ ), l(this, T, n(this, b, Fe).bind(this)), i(this, R).renderer.domElement.addEventListener(
636
636
  "pointerleave",
637
- i(this, g)
637
+ i(this, T)
638
638
  ), this.raycasterPlane = new V.Mesh(
639
639
  new V.PlaneGeometry(
640
640
  i(this, R).width,
@@ -650,13 +650,13 @@ be = function() {
650
650
  Ze = function() {
651
651
  i(this, R).renderer.domElement.removeEventListener(
652
652
  "pointermove",
653
- i(this, T)
653
+ i(this, O)
654
654
  ), i(this, R).renderer.domElement.removeEventListener(
655
655
  "pointerleave",
656
- i(this, g)
656
+ i(this, T)
657
657
  ), this.raycasterPlane.geometry.dispose(), this.raycasterPlane.material.dispose();
658
658
  };
659
- var M, c, j, S, k, f, Se, ye, Pe, ze, _;
659
+ var M, c, k, S, j, f, Se, ye, Pe, ze, _;
660
660
  class He {
661
661
  /**
662
662
  * Constructor
@@ -693,7 +693,7 @@ class He {
693
693
  * select which vertices/points/pixels
694
694
  * should be displaced
695
695
  */
696
- a(this, j);
696
+ a(this, k);
697
697
  /**
698
698
  * @type {number}
699
699
  * @note This value defines how many pixels are affected by the
@@ -707,8 +707,8 @@ class He {
707
707
  * pointer trailing effect on the
708
708
  * pixels' displacement
709
709
  */
710
- a(this, k);
711
- l(this, M, e), l(this, k, h), n(this, f, Pe).call(this, t, s), n(this, f, ze).call(this, r, m);
710
+ a(this, j);
711
+ l(this, M, e), l(this, j, h), n(this, f, Pe).call(this, t, s), n(this, f, ze).call(this, r, m);
712
712
  }
713
713
  /**
714
714
  * Update
@@ -734,7 +734,7 @@ class He {
734
734
  max: 1,
735
735
  step: 0.01
736
736
  }).on("change", (s) => n(this, f, _).call(this, s.value)), e.addBinding(
737
- { trailing: i(this, k) },
737
+ { trailing: i(this, j) },
738
738
  "trailing",
739
739
  {
740
740
  min: 0,
@@ -756,7 +756,7 @@ class He {
756
756
  this.texture.dispose();
757
757
  }
758
758
  }
759
- M = new WeakMap(), c = new WeakMap(), j = new WeakMap(), S = new WeakMap(), k = new WeakMap(), f = new WeakSet(), /**
759
+ M = new WeakMap(), c = new WeakMap(), k = new WeakMap(), S = new WeakMap(), j = new WeakMap(), f = new WeakSet(), /**
760
760
  * Draw
761
761
  *
762
762
  * @param {number} dx
@@ -767,7 +767,7 @@ M = new WeakMap(), c = new WeakMap(), j = new WeakMap(), S = new WeakMap(), k =
767
767
  */
768
768
  Se = function(e, t) {
769
769
  e -= i(this, S) / 2, t -= i(this, S) / 2, i(this, c).save(), i(this, c).globalCompositeOperation = "lighten", i(this, c).drawImage(
770
- i(this, j),
770
+ i(this, k),
771
771
  e,
772
772
  t,
773
773
  i(this, S),
@@ -782,7 +782,7 @@ Se = function(e, t) {
782
782
  * That is why it is required to clear the canvas with black color
783
783
  */
784
784
  ye = function() {
785
- i(this, c).save(), i(this, c).globalAlpha = i(this, k), i(this, c).fillStyle = "#000", i(this, c).fillRect(0, 0, this.element.width, this.element.height), i(this, c).restore();
785
+ i(this, c).save(), i(this, c).globalAlpha = i(this, j), i(this, c).fillStyle = "#000", i(this, c).fillRect(0, 0, this.element.width, this.element.height), i(this, c).restore();
786
786
  }, /**
787
787
  * Init canvas texture used to detect pointer location and
788
788
  * displace points
@@ -806,7 +806,7 @@ Pe = function(e, t) {
806
806
  * a white image that will indicate which pixels should be displaced
807
807
  */
808
808
  ze = function(e, t) {
809
- l(this, j, new Image()), i(this, j).src = e, n(this, f, _).call(this, t);
809
+ l(this, k, new Image()), i(this, k).src = e, n(this, f, _).call(this, t);
810
810
  }, /**
811
811
  * Process pointer image size
812
812
  *
@@ -957,7 +957,7 @@ we = function(e) {
957
957
  );
958
958
  l(this, D, e);
959
959
  };
960
- var P, u, z, y, w, E, I, C, d, $, ee, Ne, ie, xe, Le, Oe, Te;
960
+ var P, u, z, y, w, E, I, C, d, $, ee, Ne, ie, xe, Le, ge, Oe;
961
961
  class si {
962
962
  /**
963
963
  * Constructor
@@ -1085,7 +1085,12 @@ class si {
1085
1085
  * @returns {void}
1086
1086
  */
1087
1087
  debug() {
1088
- i(this, w) || (n(this, d, ie).call(this), l(this, w, !0));
1088
+ i(this, w) || (n(this, d, ie).call(this), i(this, P).debug(), this.debugManager.addButton({
1089
+ title: "Copy"
1090
+ }).on("click", () => {
1091
+ const t = this.debugManager.exportState();
1092
+ console.log(t);
1093
+ }), l(this, w, !0));
1089
1094
  }
1090
1095
  /**
1091
1096
  * Dispose
@@ -1105,7 +1110,7 @@ $ = function() {
1105
1110
  this.rendererManager = new Ee(
1106
1111
  i(this, u).currentImage.width,
1107
1112
  i(this, u).currentImage.height
1108
- ), l(this, z, new ke()), n(this, d, Oe).call(this), n(this, d, Le).call(this), i(this, y).containerSelector && n(this, d, Te).call(this, i(this, y).containerSelector), l(this, I, n(this, d, Ne).bind(this)), window.addEventListener("keydown", i(this, I)), i(this, w) ? n(this, d, ie).call(this) : n(this, d, xe).call(this), l(this, C, () => {
1113
+ ), l(this, z, new je()), n(this, d, ge).call(this), n(this, d, Le).call(this), i(this, y).containerSelector && n(this, d, Oe).call(this, i(this, y).containerSelector), l(this, I, n(this, d, Ne).bind(this)), window.addEventListener("keydown", i(this, I)), i(this, w) ? n(this, d, ie).call(this) : n(this, d, xe).call(this), l(this, C, () => {
1109
1114
  i(this, u).update() && (this.dispose(), n(this, d, $).call(this));
1110
1115
  }), window.addEventListener("resize", i(this, C)), n(this, d, ee).call(this);
1111
1116
  }, /**
@@ -1130,7 +1135,7 @@ Ne = function(e) {
1130
1135
  * @returns {void}
1131
1136
  */
1132
1137
  ie = function() {
1133
- i(this, P).debug(), this.debugManager.element.style.display = "block";
1138
+ this.debugManager.element.style.display = "block";
1134
1139
  }, /**
1135
1140
  * Disable debug
1136
1141
  *
@@ -1178,15 +1183,15 @@ Le = function() {
1178
1183
  *
1179
1184
  * @returns {void}
1180
1185
  */
1181
- Oe = function() {
1182
- this.debugManager = new je();
1186
+ ge = function() {
1187
+ this.debugManager = new ke();
1183
1188
  }, /**
1184
1189
  * Init DOM
1185
1190
  *
1186
1191
  * @param {string} containerSelector
1187
1192
  * @returns {void}
1188
1193
  */
1189
- Te = function(e) {
1194
+ Oe = function(e) {
1190
1195
  const t = document.querySelector(e);
1191
1196
  t == null || t.appendChild(this.rendererManager.renderer.domElement), t == null || t.appendChild(this.debugManager.element);
1192
1197
  };