@litecanvas/utils 0.14.0 → 0.16.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/README.md CHANGED
@@ -49,4 +49,5 @@ const pos = vec(0, 0)
49
49
  - **Actor**: class to represent game entities. [Usage & Docs](https://github.com/litecanvas/utils/tree/main/src/actor)
50
50
  - **Grid**: class to handle retangular grid areas. [Usage & Docs](https://github.com/litecanvas/utils/tree/main/src/grid)
51
51
  - **Collision** utilities. [Usage & Docs](https://github.com/litecanvas/utils/tree/main/src/collision)
52
- - And [some math utilities](https://github.com/litecanvas/utils/tree/main/src/math)
52
+ - **Tween** to create animations. [Usage & Docs](https://github.com/litecanvas/utils/tree/main/src/tween)
53
+ - And some [math utilities](https://github.com/litecanvas/utils/tree/main/src/math)...
package/dist/actor.js CHANGED
@@ -60,11 +60,11 @@
60
60
  globalThis.zzfxV = 1;
61
61
 
62
62
  // src/actor/index.js
63
- var ANCHOR_CENTER = vec(0.5, 0.5);
64
- var ANCHOR_TOP_LEFT = vec(0, 0);
65
- var ANCHOR_TOP_RIGHT = vec(1, 0);
66
- var ANCHOR_BOT_LEFT = vec(0, 1);
67
- var ANCHOR_BOT_RIGHT = vec(1, 1);
63
+ var ANCHOR_CENTER = /* @__PURE__ */ vec(0.5, 0.5);
64
+ var ANCHOR_TOP_LEFT = /* @__PURE__ */ vec(0, 0);
65
+ var ANCHOR_TOP_RIGHT = /* @__PURE__ */ vec(1, 0);
66
+ var ANCHOR_BOT_LEFT = /* @__PURE__ */ vec(0, 1);
67
+ var ANCHOR_BOT_RIGHT = /* @__PURE__ */ vec(1, 1);
68
68
  var Actor = class {
69
69
  /** @type {Image|HTMLCanvasElement|OffscreenCanvas} */
70
70
  sprite;
@@ -74,6 +74,10 @@
74
74
  _o;
75
75
  /** @type {Vector} The actor scale */
76
76
  _s;
77
+ /** @type {boolean} */
78
+ flipX = false;
79
+ /** @type {boolean} */
80
+ flipY = false;
77
81
  /** @type {number} The actor angle (in radians) */
78
82
  angle = 0;
79
83
  /** @type {number} The actor opacity */
@@ -146,6 +150,26 @@
146
150
  get scale() {
147
151
  return this._s;
148
152
  }
153
+ /**
154
+ * Sets the actor scale
155
+ *
156
+ * @param {number} x
157
+ * @param {number} [y]
158
+ */
159
+ scaleTo(x, y = x) {
160
+ this._s.x = x;
161
+ this._s.y = y;
162
+ }
163
+ /**
164
+ * Multiplies the actor scale
165
+ *
166
+ * @param {number} x
167
+ * @param {number} [y]
168
+ */
169
+ scaleBy(x, y = x) {
170
+ this._s.x *= x;
171
+ this._s.y *= y;
172
+ }
149
173
  /**
150
174
  * @returns {number[]}
151
175
  */
@@ -157,16 +181,16 @@
157
181
  return [x, y, w, h];
158
182
  }
159
183
  /**
160
- * Update the transformation matrix, sets the opacity and draw the actor sprite image.
184
+ * Draw the actor
161
185
  *
162
186
  * @param {LitecanvasInstance} [litecanvas]
163
187
  */
164
- draw(litecanvas = globalThis) {
188
+ draw(litecanvas = globalThis, saveContext = true) {
165
189
  if (this.hidden || this.opacity <= 0) return;
166
- litecanvas.push();
190
+ if (saveContext) litecanvas.push();
167
191
  this.transform(litecanvas);
168
192
  this.drawImage(litecanvas);
169
- litecanvas.pop();
193
+ if (saveContext) litecanvas.pop();
170
194
  }
171
195
  /**
172
196
  * @param {LitecanvasInstance} litecanvas
@@ -174,16 +198,20 @@
174
198
  transform(litecanvas) {
175
199
  litecanvas.translate(this.pos.x, this.pos.y);
176
200
  litecanvas.rotate(this.angle);
177
- litecanvas.scale(this._s.x, this._s.y);
201
+ litecanvas.scale(
202
+ (this.flipX ? -1 : 1) * this._s.x,
203
+ (this.flipY ? -1 : 1) * this._s.y
204
+ );
178
205
  }
179
206
  /**
180
207
  * @param {LitecanvasInstance} litecanvas
181
208
  */
182
- drawImage(litecanvas) {
183
- const anchorX = this.sprite.width * this.anchor.x;
184
- const anchorY = this.sprite.height * this.anchor.y;
185
- litecanvas.alpha(this.opacity);
186
- litecanvas.image(-anchorX, -anchorY, this.sprite);
209
+ drawImage(litecanvas, alpha = true) {
210
+ const anchor = this.anchor;
211
+ const x = -this.sprite.width * (this.flipX ? 1 - anchor.x : anchor.x);
212
+ const y = -this.sprite.height * (this.flipY ? 1 - anchor.y : anchor.y);
213
+ if (alpha) litecanvas.alpha(this.opacity);
214
+ litecanvas.image(x, y, this.sprite);
187
215
  }
188
216
  };
189
217
 
package/dist/actor.min.js CHANGED
@@ -1 +1 @@
1
- (()=>{var p=Object.defineProperty;var u=(e,t)=>{for(var o in t)p(e,o,{get:t[o],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=()=>{for(let e in globalThis.utils)e!=="global"&&(globalThis[e]=globalThis.utils[e])};var a={};u(a,{ANCHOR_BOT_LEFT:()=>x,ANCHOR_BOT_RIGHT:()=>g,ANCHOR_CENTER:()=>d,ANCHOR_TOP_LEFT:()=>c,ANCHOR_TOP_RIGHT:()=>y,Actor:()=>i});var _=2*Math.PI,n=class{x;y;constructor(t=0,o=t){this.x=t,this.y=o}toString(){return`Vector (${this.x}, ${this.y})`}},h=e=>e instanceof n,r=(e=0,t=e)=>(h(e)&&(t=e.y,e=e.x),new n(e,t));globalThis.zzfxV=1;var d=r(.5,.5),c=r(0,0),y=r(1,0),x=r(0,1),g=r(1,1),i=class{sprite;pos;_o;_s;angle=0;opacity=1;hidden=!1;constructor(t,o,s=c){this.sprite=t,this.pos=o||r(0),this._o=r(s),this._s=r(1,1)}set x(t){this.pos.x=t}get x(){return this.pos.x}set y(t){this.pos.y=t}get y(){return this.pos.y}set anchor(t){this._o.x=t.x,this._o.y=t.y}get anchor(){return this._o}get width(){return this.sprite.width*this._s.x}get height(){return this.sprite.height*this._s.y}get scale(){return this._s}getBounds(t=!0){let o=this.sprite.width*(t?this._s.x:1),s=this.sprite.height*(t?this._s.y:1),l=this.pos.x-o*this.anchor.x,f=this.pos.y-s*this.anchor.y;return[l,f,o,s]}draw(t=globalThis){this.hidden||this.opacity<=0||(t.push(),this.transform(t),this.drawImage(t),t.pop())}transform(t){t.translate(this.pos.x,this.pos.y),t.rotate(this.angle),t.scale(this._s.x,this._s.y)}drawImage(t){let o=this.sprite.width*this.anchor.x,s=this.sprite.height*this.anchor.y;t.alpha(this.opacity),t.image(-o,-s,this.sprite)}};globalThis.utils=Object.assign(globalThis.utils||{},a);})();
1
+ (()=>{var p=Object.defineProperty;var u=(o,t)=>{for(var e in t)p(o,e,{get:t[e],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=()=>{for(let o in globalThis.utils)o!=="global"&&(globalThis[o]=globalThis.utils[o])};var l={};u(l,{ANCHOR_BOT_LEFT:()=>x,ANCHOR_BOT_RIGHT:()=>g,ANCHOR_CENTER:()=>y,ANCHOR_TOP_LEFT:()=>f,ANCHOR_TOP_RIGHT:()=>d,Actor:()=>c});var T=2*Math.PI,n=class{x;y;constructor(t=0,e=t){this.x=t,this.y=e}toString(){return`Vector (${this.x}, ${this.y})`}},h=o=>o instanceof n,r=(o=0,t=o)=>(h(o)&&(t=o.y,o=o.x),new n(o,t));globalThis.zzfxV=1;var y=r(.5,.5),f=r(0,0),d=r(1,0),x=r(0,1),g=r(1,1),c=class{sprite;pos;_o;_s;flipX=!1;flipY=!1;angle=0;opacity=1;hidden=!1;constructor(t,e,s=f){this.sprite=t,this.pos=e||r(0),this._o=r(s),this._s=r(1,1)}set x(t){this.pos.x=t}get x(){return this.pos.x}set y(t){this.pos.y=t}get y(){return this.pos.y}set anchor(t){this._o.x=t.x,this._o.y=t.y}get anchor(){return this._o}get width(){return this.sprite.width*this._s.x}get height(){return this.sprite.height*this._s.y}get scale(){return this._s}scaleTo(t,e=t){this._s.x=t,this._s.y=e}scaleBy(t,e=t){this._s.x*=t,this._s.y*=e}getBounds(t=!0){let e=this.sprite.width*(t?this._s.x:1),s=this.sprite.height*(t?this._s.y:1),i=this.pos.x-e*this.anchor.x,a=this.pos.y-s*this.anchor.y;return[i,a,e,s]}draw(t=globalThis,e=!0){this.hidden||this.opacity<=0||(e&&t.push(),this.transform(t),this.drawImage(t),e&&t.pop())}transform(t){t.translate(this.pos.x,this.pos.y),t.rotate(this.angle),t.scale((this.flipX?-1:1)*this._s.x,(this.flipY?-1:1)*this._s.y)}drawImage(t,e=!0){let s=this.anchor,i=-this.sprite.width*(this.flipX?1-s.x:s.x),a=-this.sprite.height*(this.flipY?1-s.y:s.y);e&&t.alpha(this.opacity),t.image(i,a,this.sprite)}};globalThis.utils=Object.assign(globalThis.utils||{},l);})();
package/dist/all.js CHANGED
@@ -23,21 +23,36 @@
23
23
  ANCHOR_TOP_LEFT: () => ANCHOR_TOP_LEFT,
24
24
  ANCHOR_TOP_RIGHT: () => ANCHOR_TOP_RIGHT,
25
25
  Actor: () => Actor,
26
+ BACK_IN: () => BACK_IN,
27
+ BACK_IN_OUT: () => BACK_IN_OUT,
28
+ BACK_OUT: () => BACK_OUT,
29
+ BOUNCE_IN: () => BOUNCE_IN,
30
+ BOUNCE_IN_OUT: () => BOUNCE_IN_OUT,
31
+ BOUNCE_OUT: () => BOUNCE_OUT,
26
32
  Camera: () => Camera,
27
33
  DOWN: () => DOWN,
34
+ EASE_IN: () => EASE_IN,
35
+ EASE_IN_OUT: () => EASE_IN_OUT,
36
+ EASE_OUT: () => EASE_OUT,
37
+ ELASTIC_IN: () => ELASTIC_IN,
38
+ ELASTIC_IN_OUT: () => ELASTIC_IN_OUT,
39
+ ELASTIC_OUT: () => ELASTIC_OUT,
28
40
  Grid: () => Grid,
29
41
  LEFT: () => LEFT,
42
+ LINEAR: () => LINEAR,
30
43
  ONE: () => ONE,
31
44
  RIGHT: () => RIGHT,
32
45
  TypedGrid: () => TypedGrid,
33
46
  UP: () => UP,
34
47
  Vector: () => Vector,
35
48
  ZERO: () => ZERO,
49
+ advance: () => advance_default,
36
50
  diff: () => diff_default,
37
51
  fract: () => fract_default,
38
52
  intersection: () => intersection_default,
39
53
  range: () => range_default,
40
54
  resolve: () => resolve_default,
55
+ tween: () => tween,
41
56
  vec: () => vec,
42
57
  vecAbs: () => vecAbs,
43
58
  vecAdd: () => vecAdd,
@@ -591,8 +606,8 @@
591
606
  if (isVector(x)) {
592
607
  return vecDiv(v, x.x, x.y);
593
608
  }
594
- v.x /= x;
595
- v.y /= y;
609
+ v.x /= x || 1;
610
+ v.y /= y || 1;
596
611
  return v;
597
612
  };
598
613
  var vecRotate = (v, radians) => {
@@ -691,11 +706,11 @@
691
706
  globalThis.zzfxV = 1;
692
707
 
693
708
  // src/actor/index.js
694
- var ANCHOR_CENTER = vec(0.5, 0.5);
695
- var ANCHOR_TOP_LEFT = vec(0, 0);
696
- var ANCHOR_TOP_RIGHT = vec(1, 0);
697
- var ANCHOR_BOT_LEFT = vec(0, 1);
698
- var ANCHOR_BOT_RIGHT = vec(1, 1);
709
+ var ANCHOR_CENTER = /* @__PURE__ */ vec(0.5, 0.5);
710
+ var ANCHOR_TOP_LEFT = /* @__PURE__ */ vec(0, 0);
711
+ var ANCHOR_TOP_RIGHT = /* @__PURE__ */ vec(1, 0);
712
+ var ANCHOR_BOT_LEFT = /* @__PURE__ */ vec(0, 1);
713
+ var ANCHOR_BOT_RIGHT = /* @__PURE__ */ vec(1, 1);
699
714
  var Actor = class {
700
715
  /** @type {Image|HTMLCanvasElement|OffscreenCanvas} */
701
716
  sprite;
@@ -705,6 +720,10 @@
705
720
  _o;
706
721
  /** @type {Vector} The actor scale */
707
722
  _s;
723
+ /** @type {boolean} */
724
+ flipX = false;
725
+ /** @type {boolean} */
726
+ flipY = false;
708
727
  /** @type {number} The actor angle (in radians) */
709
728
  angle = 0;
710
729
  /** @type {number} The actor opacity */
@@ -777,6 +796,26 @@
777
796
  get scale() {
778
797
  return this._s;
779
798
  }
799
+ /**
800
+ * Sets the actor scale
801
+ *
802
+ * @param {number} x
803
+ * @param {number} [y]
804
+ */
805
+ scaleTo(x, y = x) {
806
+ this._s.x = x;
807
+ this._s.y = y;
808
+ }
809
+ /**
810
+ * Multiplies the actor scale
811
+ *
812
+ * @param {number} x
813
+ * @param {number} [y]
814
+ */
815
+ scaleBy(x, y = x) {
816
+ this._s.x *= x;
817
+ this._s.y *= y;
818
+ }
780
819
  /**
781
820
  * @returns {number[]}
782
821
  */
@@ -788,16 +827,16 @@
788
827
  return [x, y, w, h];
789
828
  }
790
829
  /**
791
- * Update the transformation matrix, sets the opacity and draw the actor sprite image.
830
+ * Draw the actor
792
831
  *
793
832
  * @param {LitecanvasInstance} [litecanvas]
794
833
  */
795
- draw(litecanvas = globalThis) {
834
+ draw(litecanvas = globalThis, saveContext = true) {
796
835
  if (this.hidden || this.opacity <= 0) return;
797
- litecanvas.push();
836
+ if (saveContext) litecanvas.push();
798
837
  this.transform(litecanvas);
799
838
  this.drawImage(litecanvas);
800
- litecanvas.pop();
839
+ if (saveContext) litecanvas.pop();
801
840
  }
802
841
  /**
803
842
  * @param {LitecanvasInstance} litecanvas
@@ -805,16 +844,20 @@
805
844
  transform(litecanvas) {
806
845
  litecanvas.translate(this.pos.x, this.pos.y);
807
846
  litecanvas.rotate(this.angle);
808
- litecanvas.scale(this._s.x, this._s.y);
847
+ litecanvas.scale(
848
+ (this.flipX ? -1 : 1) * this._s.x,
849
+ (this.flipY ? -1 : 1) * this._s.y
850
+ );
809
851
  }
810
852
  /**
811
853
  * @param {LitecanvasInstance} litecanvas
812
854
  */
813
- drawImage(litecanvas) {
814
- const anchorX = this.sprite.width * this.anchor.x;
815
- const anchorY = this.sprite.height * this.anchor.y;
816
- litecanvas.alpha(this.opacity);
817
- litecanvas.image(-anchorX, -anchorY, this.sprite);
855
+ drawImage(litecanvas, alpha = true) {
856
+ const anchor = this.anchor;
857
+ const x = -this.sprite.width * (this.flipX ? 1 - anchor.x : anchor.x);
858
+ const y = -this.sprite.height * (this.flipY ? 1 - anchor.y : anchor.y);
859
+ if (alpha) litecanvas.alpha(this.opacity);
860
+ litecanvas.image(x, y, this.sprite);
818
861
  }
819
862
  };
820
863
 
@@ -830,6 +873,165 @@
830
873
  // src/math/range.js
831
874
  var range_default = (size) => Array.from(Array(size).keys());
832
875
 
876
+ // src/math/advance.js
877
+ var advance_default = advance = (position, velocity, acceleration, deltaTime = 1) => {
878
+ if (acceleration) {
879
+ velocity.x += acceleration.x * deltaTime;
880
+ velocity.y += acceleration.y * deltaTime;
881
+ }
882
+ position.x += velocity.x * deltaTime;
883
+ position.y += velocity.y * deltaTime;
884
+ };
885
+
886
+ // src/tween/index.js
887
+ var HALF_PI = Math.PI / 2;
888
+ var tween = (object, prop, toValue, duration = 1, easing = LINEAR) => {
889
+ return new TweenController(object, prop, toValue, duration, easing);
890
+ };
891
+ var LINEAR = (n) => n;
892
+ var EASE_IN = (n) => n * n;
893
+ var EASE_OUT = (n) => -n * (n - 2);
894
+ var EASE_IN_OUT = (n) => {
895
+ if (n < 0.5) {
896
+ return 2 * n * n;
897
+ }
898
+ return -2 * n * n + 4 * n - 1;
899
+ };
900
+ var BACK_IN = (n) => n * n * n - n * Math.sin(n * Math.PI);
901
+ var BACK_OUT = (n) => {
902
+ let a = 1 - n;
903
+ return 1 - (a * a * a - a * Math.sin(a * Math.PI));
904
+ };
905
+ var BACK_IN_OUT = (n) => {
906
+ if (n < 0.5) {
907
+ let a2 = 2 * n;
908
+ return 0.5 * (a2 * a2 * a2 - a2 * Math.sin(a2 * Math.PI));
909
+ }
910
+ let a = 1 - (2 * n - 1);
911
+ return 0.5 * (1 - (a * a * a - a * Math.sin(n * Math.PI))) + 0.5;
912
+ };
913
+ var ELASTIC_IN = (n) => {
914
+ return Math.sin(13 * HALF_PI * n) * Math.pow(2, 10 * (n - 1));
915
+ };
916
+ var ELASTIC_OUT = (n) => {
917
+ return Math.sin(-13 * HALF_PI * (n + 1)) * Math.pow(2, -10 * n) + 1;
918
+ };
919
+ var ELASTIC_IN_OUT = (n) => {
920
+ if (n < 0.5) {
921
+ let a2 = Math.sin(13 * HALF_PI * (2 * n));
922
+ let b2 = Math.pow(2, 10 * (2 * n - 1));
923
+ return 0.5 * a2 * b2;
924
+ }
925
+ let a = Math.sin(-13 * HALF_PI * (2 * n - 1 + 1));
926
+ let b = Math.pow(2, -10 * (2 * n - 1));
927
+ return 0.5 * (a * b + 2);
928
+ };
929
+ var BOUNCE_IN = (n) => 1 - BOUNCE_OUT(1 - n);
930
+ var BOUNCE_OUT = (n) => {
931
+ if (n < 4 / 11) {
932
+ return 121 * n * n / 16;
933
+ } else if (n < 8 / 11) {
934
+ return 363 / 40 * n * n - 99 / 10 * n + 17 / 5;
935
+ } else if (n < 9 / 10) {
936
+ return 4356 / 361 * n * n - 35442 / 1805 * n + 16061 / 1805;
937
+ }
938
+ return 54 / 5 * n * n - 513 / 25 * n + 268 / 25;
939
+ };
940
+ var BOUNCE_IN_OUT = (n) => {
941
+ if (n < 0.5) {
942
+ return 0.5 * BOUNCE_IN(n * 2);
943
+ }
944
+ return 0.5 * BOUNCE_OUT(n * 2 - 1) + 0.5;
945
+ };
946
+ var TweenController = class {
947
+ /** @type {boolean} */
948
+ running = false;
949
+ /** @type {*} */
950
+ _o;
951
+ /** @type {string} */
952
+ _p;
953
+ /** @type {number} */
954
+ _x;
955
+ /** @type {number} */
956
+ _d;
957
+ /** @type {(x: number) => number} */
958
+ _e;
959
+ /** @type {Function[]} */
960
+ _cb = [];
961
+ /** @type {number} */
962
+ _t = 0;
963
+ /** @type {Function} */
964
+ _u = 0;
965
+ /** @type {LitecanvasInstance} */
966
+ _lc;
967
+ /**
968
+ * @param {*} object
969
+ * @param {string} prop
970
+ * @param {number} toValue
971
+ * @param {number} duration
972
+ * @param {(x: number) => number} easing
973
+ */
974
+ constructor(object, prop, toValue, duration, easing) {
975
+ this._o = object;
976
+ this._p = prop;
977
+ this._x = toValue;
978
+ this._d = duration;
979
+ this._e = easing;
980
+ }
981
+ /**
982
+ *
983
+ * @param {LitecanvasInstance} engine
984
+ */
985
+ start(engine = globalThis) {
986
+ if (!this.running) {
987
+ this.stop();
988
+ }
989
+ const fromValue = this._o[this._p] || 0;
990
+ this._lc = engine;
991
+ this._u = engine.listen("update", (dt) => {
992
+ this._o[this._p] = engine.lerp(
993
+ fromValue,
994
+ this._x,
995
+ this._e(this._t / this._d)
996
+ );
997
+ this._t += dt;
998
+ if (this._t >= this._d) {
999
+ this._o[this._p] = this._x;
1000
+ this.stop();
1001
+ }
1002
+ });
1003
+ this.running = true;
1004
+ return this;
1005
+ }
1006
+ /**
1007
+ * @param {Function} callback
1008
+ */
1009
+ onEnd(callback) {
1010
+ this._cb.push(callback);
1011
+ }
1012
+ /**
1013
+ * @param {boolean} completed if `false` don't call the `onEnd()` registered callbacks.
1014
+ * @returns
1015
+ */
1016
+ stop(completed = true) {
1017
+ if (!this.running || !this._u) return;
1018
+ this.running = false;
1019
+ this._u();
1020
+ if (completed) {
1021
+ for (const callback of this._cb) {
1022
+ callback(this._o);
1023
+ }
1024
+ }
1025
+ }
1026
+ reset() {
1027
+ this._cb.length = 0;
1028
+ this.stop();
1029
+ }
1030
+ get progress() {
1031
+ return this.running ? this._t / this._d : 0;
1032
+ }
1033
+ };
1034
+
833
1035
  // src/_web.js
834
1036
  globalThis.utils = Object.assign(globalThis.utils || {}, src_exports);
835
1037
  })();
package/dist/all.min.js CHANGED
@@ -1,3 +1,3 @@
1
- (()=>{var U=Object.defineProperty;var $=(e,t)=>{for(var s in t)U(e,s,{get:t[s],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=()=>{for(let e in globalThis.utils)e!=="global"&&(globalThis[e]=globalThis.utils[e])};var k={};$(k,{ANCHOR_BOT_LEFT:()=>mt,ANCHOR_BOT_RIGHT:()=>Tt,ANCHOR_CENTER:()=>yt,ANCHOR_TOP_LEFT:()=>F,ANCHOR_TOP_RIGHT:()=>_t,Actor:()=>D,Camera:()=>u,DOWN:()=>xt,Grid:()=>y,LEFT:()=>gt,ONE:()=>ut,RIGHT:()=>dt,TypedGrid:()=>E,UP:()=>pt,Vector:()=>p,ZERO:()=>B,diff:()=>G,fract:()=>j,intersection:()=>g,range:()=>z,resolve:()=>S,vec:()=>n,vecAbs:()=>rt,vecAdd:()=>b,vecAngle:()=>tt,vecAngleBetween:()=>et,vecCeil:()=>nt,vecClamp:()=>ct,vecCross:()=>st,vecDist:()=>Q,vecDist2:()=>v,vecDiv:()=>_,vecDot:()=>W,vecEq:()=>H,vecFloor:()=>at,vecIsZero:()=>ft,vecLerp:()=>it,vecLimit:()=>K,vecMag:()=>R,vecMag2:()=>Y,vecMove:()=>lt,vecMult:()=>d,vecNorm:()=>A,vecRand:()=>ot,vecReflect:()=>Z,vecRotate:()=>q,vecRound:()=>ht,vecSet:()=>P,vecSetMag:()=>J,vecSub:()=>I,wave:()=>V});var g=(e,t,s,i,o,r,a,h)=>{let c=Math.max(e,o),C=Math.min(e+s,o+a)-c,x=Math.max(t,r),m=Math.min(t+i,r+h)-x;return[c,x,C,m]};var S=(e,t,s,i,o,r,a,h)=>{let[c,C,x,m]=g(e,t,s,i,o,r,a,h),f="",T=e,w=t;return x<m?e<o?(f="right",T=o-s):(f="left",T=o+a):t<r?(f="bottom",w=r-i):(f="top",w=r+h),{direction:f,x:T,y:w}};var u=class{_engine=null;x=0;y=0;ox=0;oy=0;width=0;height=0;rotation=0;scale=1;_shake={x:0,y:0,removeListener:null};constructor(t=null,s=0,i=0,o=null,r=null){this._engine=t||globalThis,this.ox=s,this.oy=i,this.resize(o||this._engine.WIDTH-s,r||this._engine.HEIGHT-i),this.x=this.width/2,this.y=this.height/2}resize(t,s){this.width=t,this.height=s,this._engine.emit("camera-resized",this)}start(t=!1){this._engine.push(),t&&this._engine.cliprect(this.ox,this.oy,this.width,this.height);let s=this.ox+this.width/2,i=this.oy+this.height/2;this._engine.translate(s,i),this._engine.scale(this.scale),this._engine.rotate(this.rotation),this._engine.translate(-this.x+this._shake.x,-this.y+this._shake.y)}end(){this._engine.pop()}lookAt(t,s){this.x=t,this.y=s}move(t,s){this.x+=t,this.y+=s}zoom(t){this.scale*=t}zoomTo(t){this.scale=t}rotate(t){this.rotation+=t}rotateTo(t){this.rotation=t}getWorldPoint(t,s,i={}){let o=Math.cos(-this.rotation),r=Math.sin(-this.rotation);return t=(t-this.width/2-this.ox)/this.scale,s=(s-this.height/2-this.oy)/this.scale,i.x=o*t-r*s+this.x,i.y=r*t+o*s+this.y,i}getCameraPoint(t,s,i={}){let o=Math.cos(-this.rotation),r=Math.sin(-this.rotation);return t=t-this.x,s=s-this.y,t=o*t-r*s,s=r*t+o*s,i.x=t*this.scale+this.width/2+this.ox,i.y=s*this.scale+this.height/2+this.oy,i}getBounds(){return[this.ox,this.oy,this.width,this.height]}viewing(t,s,i,o){let r=this.width/2-this.x,a=this.height/2-this.y,h=this.width/this.scale,c=this.height/this.scale;return this._engine.colrect(t,s,i,o,r,a,h,c)}shake(t=1,s=.3){this.shaking||(this._shake.removeListener=this._engine.listen("update",i=>{this._shake.x=this._engine.randi(-t,t),this._shake.y=this._engine.randi(-t,t),s-=i,s<=0&&this.unshake()}))}unshake(){this.shaking&&(this._shake.removeListener(),this._shake.removeListener=null,this._shake.x=this._shake.y=0)}get shaking(){return this._shake.removeListener!==null}};var y=class e{_w;_h;_c;constructor(t,s,i=[]){this._w=Math.max(1,~~t),this._h=Math.max(1,~~s),this._c=i}clear(){this.forEach((t,s)=>this.set(t,s,void 0))}get width(){return this._w}get height(){return this._h}set(t,s,i){this._c[this.pointToIndex(t,s)]=i}get(t,s){return this._c[this.pointToIndex(t,s)]}has(t,s){return this.get(t,s)!=null}get length(){return this._w*this._h}pointToIndex(t,s){return this.clampX(~~t)+this.clampY(~~s)*this._w}indexToPointX(t){return t%this._w}indexToPointY(t){return Math.floor(t/this._w)}forEach(t,s=!1){let i=s?this.length-1:0,o=s?-1:this.length,r=s?-1:1;for(;i!==o;){let a=this.indexToPointX(i),h=this.indexToPointY(i),c=this._c[i];if(t(a,h,c,this)===!1)break;i+=r}}fill(t){this.forEach((s,i)=>{this.set(s,i,t)})}clone(){return e.fromArray(this._w,this._h,this._c)}clampX(t){return O(t,0,this._w-1)}clampY(t){return O(t,0,this._h-1)}toArray(){return this._c.slice()}toString(t=" ",s=!0){if(!s)return this._c.join(t);let i=[];return this.forEach((o,r,a)=>{i[r]=i[r]||"",i[r]+=a+t}),i.join(`
2
- `)}},E=class e extends y{constructor(t,s,i=Uint8Array){super(t,s,null),this._c=new i(this._w*this._h)}has(t,s){return this.get(t,s)!==0}clone(){let t=new e(this._w,this._h,this._c.constructor);return this.forEach((s,i,o)=>{t.set(s,i,o)}),t}};function O(e,t,s){return e<t?t:e>s?s:e}var M=Math.sqrt,X=Math.cos,L=Math.sin,N=2*Math.PI,p=class{x;y;constructor(t=0,s=t){this.x=t,this.y=s}toString(){return`Vector (${this.x}, ${this.y})`}},l=e=>e instanceof p,n=(e=0,t=e)=>(l(e)&&(t=e.y,e=e.x),new p(e,t)),H=(e,t,s=t)=>l(t)?H(e,t.x,t.y):e.x===t&&e.y===s,P=(e,t,s=t)=>(l(t)?P(e,t.x,t.y):(e.x=t,e.y=s),e),b=(e,t,s=t)=>l(t)?b(e,t.x,t.y):(e.x+=t,e.y+=s,e),I=(e,t,s=t)=>l(t)?I(e,t.x,t.y):(e.x-=t,e.y-=s,e),d=(e,t,s=t)=>l(t)?d(e,t.x,t.y):(e.x*=t,e.y*=s,e),_=(e,t,s=t)=>l(t)?_(e,t.x,t.y):(e.x/=t,e.y/=s,e),q=(e,t)=>{let s=X(t),i=L(t);return e.x=s*e.x-i*e.y,e.y=i*e.x+s*e.y,e},Z=(e,t)=>{let s=A(n(t));return I(e,d(s,2*W(e,s)))},J=(e,t)=>(A(e),d(e,t),e),R=e=>M(e.x*e.x+e.y*e.y),Y=e=>e.x*e.x+e.y*e.y,A=e=>{let t=R(e);return t>0&&_(e,t),e},K=(e,t=1)=>{let s=Y(e);return s>t*t&&(_(e,M(s)),d(e,t)),e},Q=(e,t)=>{let s=e.x-t.x,i=e.y-t.y;return M(s*s+i*i)},v=(e,t)=>{let s=e.x-t.x,i=e.y-t.y;return s*s+i*i},tt=e=>Math.atan2(e.y,e.x),et=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),W=(e,t)=>e.x*t.x+e.y*t.y,st=(e,t)=>e.x*t.y-e.y*t.x,it=(e,t,s)=>(e.x+=(t.x-e.x)*s||0,e.y+=(t.y-e.y)*s||0,e),ot=(e=1,t=e,s=globalThis.rand||Math.random)=>{let i=s()*N,o=s()*(t-e)+e;return n(X(i)*o,L(i)*o)},rt=e=>(e.x=Math.abs(e.x),e.y=Math.abs(e.y),e),nt=e=>(e.x=Math.ceil(e.x),e.y=Math.ceil(e.y),e),at=e=>(e.x=Math.floor(e.x),e.y=Math.floor(e.y),e),ht=e=>(e.x=Math.round(e.x),e.y=Math.round(e.y),e),ct=(e,t,s)=>(e.x<t.x&&(e.x=t.x),e.x>s.x&&(e.x=s.x),e.y<t.y&&(e.y=t.y),e.y>s.y&&(e.y=s.y),e),lt=(e,t,s=1)=>b(e,t.x*s,t.y*s),ft=e=>H(e,B),B=n(0,0),ut=n(1,1),pt=n(0,-1),dt=n(1,0),xt=n(0,1),gt=n(-1,0);globalThis.zzfxV=1;var yt=n(.5,.5),F=n(0,0),_t=n(1,0),mt=n(0,1),Tt=n(1,1),D=class{sprite;pos;_o;_s;angle=0;opacity=1;hidden=!1;constructor(t,s,i=F){this.sprite=t,this.pos=s||n(0),this._o=n(i),this._s=n(1,1)}set x(t){this.pos.x=t}get x(){return this.pos.x}set y(t){this.pos.y=t}get y(){return this.pos.y}set anchor(t){this._o.x=t.x,this._o.y=t.y}get anchor(){return this._o}get width(){return this.sprite.width*this._s.x}get height(){return this.sprite.height*this._s.y}get scale(){return this._s}getBounds(t=!0){let s=this.sprite.width*(t?this._s.x:1),i=this.sprite.height*(t?this._s.y:1),o=this.pos.x-s*this.anchor.x,r=this.pos.y-i*this.anchor.y;return[o,r,s,i]}draw(t=globalThis){this.hidden||this.opacity<=0||(t.push(),this.transform(t),this.drawImage(t),t.pop())}transform(t){t.translate(this.pos.x,this.pos.y),t.rotate(this.angle),t.scale(this._s.x,this._s.y)}drawImage(t){let s=this.sprite.width*this.anchor.x,i=this.sprite.height*this.anchor.y;t.alpha(this.opacity),t.image(-s,-i,this.sprite)}};var G=(e,t)=>Math.abs(t-e)||0;var V=(e,t,s,i=Math.sin)=>e+(i(s)+1)/2*(t-e);var j=e=>e%1||0;var z=e=>Array.from(Array(e).keys());globalThis.utils=Object.assign(globalThis.utils||{},k);})();
1
+ (()=>{var J=Object.defineProperty;var Q=(t,e)=>{for(var s in e)J(t,s,{get:e[s],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=()=>{for(let t in globalThis.utils)t!=="global"&&(globalThis[t]=globalThis.utils[t])};var k={};Q(k,{ANCHOR_BOT_LEFT:()=>bt,ANCHOR_BOT_RIGHT:()=>At,ANCHOR_CENTER:()=>Mt,ANCHOR_TOP_LEFT:()=>G,ANCHOR_TOP_RIGHT:()=>It,Actor:()=>C,BACK_IN:()=>St,BACK_IN_OUT:()=>Pt,BACK_OUT:()=>kt,BOUNCE_IN:()=>Z,BOUNCE_IN_OUT:()=>Yt,BOUNCE_OUT:()=>S,Camera:()=>u,DOWN:()=>wt,EASE_IN:()=>Ot,EASE_IN_OUT:()=>Dt,EASE_OUT:()=>Ct,ELASTIC_IN:()=>Lt,ELASTIC_IN_OUT:()=>Rt,ELASTIC_OUT:()=>Xt,Grid:()=>g,LEFT:()=>Et,LINEAR:()=>K,ONE:()=>yt,RIGHT:()=>Tt,TypedGrid:()=>M,UP:()=>mt,Vector:()=>p,ZERO:()=>F,advance:()=>q,diff:()=>V,fract:()=>z,intersection:()=>d,range:()=>$,resolve:()=>L,tween:()=>Ht,vec:()=>n,vecAbs:()=>ft,vecAdd:()=>A,vecAngle:()=>nt,vecAngleBetween:()=>ht,vecCeil:()=>ut,vecClamp:()=>xt,vecCross:()=>at,vecDist:()=>rt,vecDist2:()=>ot,vecDiv:()=>y,vecDot:()=>N,vecEq:()=>b,vecFloor:()=>pt,vecIsZero:()=>gt,vecLerp:()=>ct,vecLimit:()=>it,vecMag:()=>U,vecMag2:()=>W,vecMove:()=>dt,vecMult:()=>_,vecNorm:()=>O,vecRand:()=>lt,vecReflect:()=>et,vecRotate:()=>tt,vecRound:()=>_t,vecSet:()=>B,vecSetMag:()=>st,vecSub:()=>H,wave:()=>j});var d=(t,e,s,i,r,o,h,a)=>{let c=Math.max(t,r),P=Math.min(t+s,r+h)-c,x=Math.max(e,o),T=Math.min(e+i,o+a)-x;return[c,x,P,T]};var L=(t,e,s,i,r,o,h,a)=>{let[c,P,x,T]=d(t,e,s,i,r,o,h,a),f="",w=t,E=e;return x<T?t<r?(f="right",w=r-s):(f="left",w=r+h):e<o?(f="bottom",E=o-i):(f="top",E=o+a),{direction:f,x:w,y:E}};var u=class{_engine=null;x=0;y=0;ox=0;oy=0;width=0;height=0;rotation=0;scale=1;_shake={x:0,y:0,removeListener:null};constructor(e=null,s=0,i=0,r=null,o=null){this._engine=e||globalThis,this.ox=s,this.oy=i,this.resize(r||this._engine.WIDTH-s,o||this._engine.HEIGHT-i),this.x=this.width/2,this.y=this.height/2}resize(e,s){this.width=e,this.height=s,this._engine.emit("camera-resized",this)}start(e=!1){this._engine.push(),e&&this._engine.cliprect(this.ox,this.oy,this.width,this.height);let s=this.ox+this.width/2,i=this.oy+this.height/2;this._engine.translate(s,i),this._engine.scale(this.scale),this._engine.rotate(this.rotation),this._engine.translate(-this.x+this._shake.x,-this.y+this._shake.y)}end(){this._engine.pop()}lookAt(e,s){this.x=e,this.y=s}move(e,s){this.x+=e,this.y+=s}zoom(e){this.scale*=e}zoomTo(e){this.scale=e}rotate(e){this.rotation+=e}rotateTo(e){this.rotation=e}getWorldPoint(e,s,i={}){let r=Math.cos(-this.rotation),o=Math.sin(-this.rotation);return e=(e-this.width/2-this.ox)/this.scale,s=(s-this.height/2-this.oy)/this.scale,i.x=r*e-o*s+this.x,i.y=o*e+r*s+this.y,i}getCameraPoint(e,s,i={}){let r=Math.cos(-this.rotation),o=Math.sin(-this.rotation);return e=e-this.x,s=s-this.y,e=r*e-o*s,s=o*e+r*s,i.x=e*this.scale+this.width/2+this.ox,i.y=s*this.scale+this.height/2+this.oy,i}getBounds(){return[this.ox,this.oy,this.width,this.height]}viewing(e,s,i,r){let o=this.width/2-this.x,h=this.height/2-this.y,a=this.width/this.scale,c=this.height/this.scale;return this._engine.colrect(e,s,i,r,o,h,a,c)}shake(e=1,s=.3){this.shaking||(this._shake.removeListener=this._engine.listen("update",i=>{this._shake.x=this._engine.randi(-e,e),this._shake.y=this._engine.randi(-e,e),s-=i,s<=0&&this.unshake()}))}unshake(){this.shaking&&(this._shake.removeListener(),this._shake.removeListener=null,this._shake.x=this._shake.y=0)}get shaking(){return this._shake.removeListener!==null}};var g=class t{_w;_h;_c;constructor(e,s,i=[]){this._w=Math.max(1,~~e),this._h=Math.max(1,~~s),this._c=i}clear(){this.forEach((e,s)=>this.set(e,s,void 0))}get width(){return this._w}get height(){return this._h}set(e,s,i){this._c[this.pointToIndex(e,s)]=i}get(e,s){return this._c[this.pointToIndex(e,s)]}has(e,s){return this.get(e,s)!=null}get length(){return this._w*this._h}pointToIndex(e,s){return this.clampX(~~e)+this.clampY(~~s)*this._w}indexToPointX(e){return e%this._w}indexToPointY(e){return Math.floor(e/this._w)}forEach(e,s=!1){let i=s?this.length-1:0,r=s?-1:this.length,o=s?-1:1;for(;i!==r;){let h=this.indexToPointX(i),a=this.indexToPointY(i),c=this._c[i];if(e(h,a,c,this)===!1)break;i+=o}}fill(e){this.forEach((s,i)=>{this.set(s,i,e)})}clone(){return t.fromArray(this._w,this._h,this._c)}clampX(e){return X(e,0,this._w-1)}clampY(e){return X(e,0,this._h-1)}toArray(){return this._c.slice()}toString(e=" ",s=!0){if(!s)return this._c.join(e);let i=[];return this.forEach((r,o,h)=>{i[o]=i[o]||"",i[o]+=h+e}),i.join(`
2
+ `)}},M=class t extends g{constructor(e,s,i=Uint8Array){super(e,s,null),this._c=new i(this._w*this._h)}has(e,s){return this.get(e,s)!==0}clone(){let e=new t(this._w,this._h,this._c.constructor);return this.forEach((s,i,r)=>{e.set(s,i,r)}),e}};function X(t,e,s){return t<e?e:t>s?s:t}var I=Math.sqrt,R=Math.cos,Y=Math.sin,v=2*Math.PI,p=class{x;y;constructor(e=0,s=e){this.x=e,this.y=s}toString(){return`Vector (${this.x}, ${this.y})`}},l=t=>t instanceof p,n=(t=0,e=t)=>(l(t)&&(e=t.y,t=t.x),new p(t,e)),b=(t,e,s=e)=>l(e)?b(t,e.x,e.y):t.x===e&&t.y===s,B=(t,e,s=e)=>(l(e)?B(t,e.x,e.y):(t.x=e,t.y=s),t),A=(t,e,s=e)=>l(e)?A(t,e.x,e.y):(t.x+=e,t.y+=s,t),H=(t,e,s=e)=>l(e)?H(t,e.x,e.y):(t.x-=e,t.y-=s,t),_=(t,e,s=e)=>l(e)?_(t,e.x,e.y):(t.x*=e,t.y*=s,t),y=(t,e,s=e)=>l(e)?y(t,e.x,e.y):(t.x/=e||1,t.y/=s||1,t),tt=(t,e)=>{let s=R(e),i=Y(e);return t.x=s*t.x-i*t.y,t.y=i*t.x+s*t.y,t},et=(t,e)=>{let s=O(n(e));return H(t,_(s,2*N(t,s)))},st=(t,e)=>(O(t),_(t,e),t),U=t=>I(t.x*t.x+t.y*t.y),W=t=>t.x*t.x+t.y*t.y,O=t=>{let e=U(t);return e>0&&y(t,e),t},it=(t,e=1)=>{let s=W(t);return s>e*e&&(y(t,I(s)),_(t,e)),t},rt=(t,e)=>{let s=t.x-e.x,i=t.y-e.y;return I(s*s+i*i)},ot=(t,e)=>{let s=t.x-e.x,i=t.y-e.y;return s*s+i*i},nt=t=>Math.atan2(t.y,t.x),ht=(t,e)=>Math.atan2(e.y-t.y,e.x-t.x),N=(t,e)=>t.x*e.x+t.y*e.y,at=(t,e)=>t.x*e.y-t.y*e.x,ct=(t,e,s)=>(t.x+=(e.x-t.x)*s||0,t.y+=(e.y-t.y)*s||0,t),lt=(t=1,e=t,s=globalThis.rand||Math.random)=>{let i=s()*v,r=s()*(e-t)+t;return n(R(i)*r,Y(i)*r)},ft=t=>(t.x=Math.abs(t.x),t.y=Math.abs(t.y),t),ut=t=>(t.x=Math.ceil(t.x),t.y=Math.ceil(t.y),t),pt=t=>(t.x=Math.floor(t.x),t.y=Math.floor(t.y),t),_t=t=>(t.x=Math.round(t.x),t.y=Math.round(t.y),t),xt=(t,e,s)=>(t.x<e.x&&(t.x=e.x),t.x>s.x&&(t.x=s.x),t.y<e.y&&(t.y=e.y),t.y>s.y&&(t.y=s.y),t),dt=(t,e,s=1)=>A(t,e.x*s,e.y*s),gt=t=>b(t,F),F=n(0,0),yt=n(1,1),mt=n(0,-1),Tt=n(1,0),wt=n(0,1),Et=n(-1,0);globalThis.zzfxV=1;var Mt=n(.5,.5),G=n(0,0),It=n(1,0),bt=n(0,1),At=n(1,1),C=class{sprite;pos;_o;_s;flipX=!1;flipY=!1;angle=0;opacity=1;hidden=!1;constructor(e,s,i=G){this.sprite=e,this.pos=s||n(0),this._o=n(i),this._s=n(1,1)}set x(e){this.pos.x=e}get x(){return this.pos.x}set y(e){this.pos.y=e}get y(){return this.pos.y}set anchor(e){this._o.x=e.x,this._o.y=e.y}get anchor(){return this._o}get width(){return this.sprite.width*this._s.x}get height(){return this.sprite.height*this._s.y}get scale(){return this._s}scaleTo(e,s=e){this._s.x=e,this._s.y=s}scaleBy(e,s=e){this._s.x*=e,this._s.y*=s}getBounds(e=!0){let s=this.sprite.width*(e?this._s.x:1),i=this.sprite.height*(e?this._s.y:1),r=this.pos.x-s*this.anchor.x,o=this.pos.y-i*this.anchor.y;return[r,o,s,i]}draw(e=globalThis,s=!0){this.hidden||this.opacity<=0||(s&&e.push(),this.transform(e),this.drawImage(e),s&&e.pop())}transform(e){e.translate(this.pos.x,this.pos.y),e.rotate(this.angle),e.scale((this.flipX?-1:1)*this._s.x,(this.flipY?-1:1)*this._s.y)}drawImage(e,s=!0){let i=this.anchor,r=-this.sprite.width*(this.flipX?1-i.x:i.x),o=-this.sprite.height*(this.flipY?1-i.y:i.y);s&&e.alpha(this.opacity),e.image(r,o,this.sprite)}};var V=(t,e)=>Math.abs(e-t)||0;var j=(t,e,s,i=Math.sin)=>t+(i(s)+1)/2*(e-t);var z=t=>t%1||0;var $=t=>Array.from(Array(t).keys());var q=advance=(t,e,s,i=1)=>{s&&(e.x+=s.x*i,e.y+=s.y*i),t.x+=e.x*i,t.y+=e.y*i};var m=Math.PI/2,Ht=(t,e,s,i=1,r=K)=>new D(t,e,s,i,r),K=t=>t,Ot=t=>t*t,Ct=t=>-t*(t-2),Dt=t=>t<.5?2*t*t:-2*t*t+4*t-1,St=t=>t*t*t-t*Math.sin(t*Math.PI),kt=t=>{let e=1-t;return 1-(e*e*e-e*Math.sin(e*Math.PI))},Pt=t=>{if(t<.5){let s=2*t;return .5*(s*s*s-s*Math.sin(s*Math.PI))}let e=1-(2*t-1);return .5*(1-(e*e*e-e*Math.sin(t*Math.PI)))+.5},Lt=t=>Math.sin(13*m*t)*Math.pow(2,10*(t-1)),Xt=t=>Math.sin(-13*m*(t+1))*Math.pow(2,-10*t)+1,Rt=t=>{if(t<.5){let i=Math.sin(13*m*(2*t)),r=Math.pow(2,10*(2*t-1));return .5*i*r}let e=Math.sin(-13*m*(2*t-1+1)),s=Math.pow(2,-10*(2*t-1));return .5*(e*s+2)},Z=t=>1-S(1-t),S=t=>t<4/11?121*t*t/16:t<8/11?363/40*t*t-99/10*t+17/5:t<9/10?4356/361*t*t-35442/1805*t+16061/1805:54/5*t*t-513/25*t+268/25,Yt=t=>t<.5?.5*Z(t*2):.5*S(t*2-1)+.5,D=class{running=!1;_o;_p;_x;_d;_e;_cb=[];_t=0;_u=0;_lc;constructor(e,s,i,r,o){this._o=e,this._p=s,this._x=i,this._d=r,this._e=o}start(e=globalThis){this.running||this.stop();let s=this._o[this._p]||0;return this._lc=e,this._u=e.listen("update",i=>{this._o[this._p]=e.lerp(s,this._x,this._e(this._t/this._d)),this._t+=i,this._t>=this._d&&(this._o[this._p]=this._x,this.stop())}),this.running=!0,this}onEnd(e){this._cb.push(e)}stop(e=!0){if(!(!this.running||!this._u)&&(this.running=!1,this._u(),e))for(let s of this._cb)s(this._o)}reset(){this._cb.length=0,this.stop()}get progress(){return this.running?this._t/this._d:0}};globalThis.utils=Object.assign(globalThis.utils||{},k);})();
3
3
  /*! @litecanvas/utils by Luiz Bills | MIT Licensed */
package/dist/math.js CHANGED
@@ -17,6 +17,7 @@
17
17
  // src/math/index.js
18
18
  var math_exports = {};
19
19
  __export(math_exports, {
20
+ advance: () => advance_default,
20
21
  diff: () => diff_default,
21
22
  fract: () => fract_default,
22
23
  range: () => range_default,
@@ -35,6 +36,19 @@
35
36
  // src/math/range.js
36
37
  var range_default = (size) => Array.from(Array(size).keys());
37
38
 
39
+ // src/vector/index.js
40
+ var PI2 = 2 * Math.PI;
41
+
42
+ // src/math/advance.js
43
+ var advance_default = advance = (position, velocity, acceleration, deltaTime = 1) => {
44
+ if (acceleration) {
45
+ velocity.x += acceleration.x * deltaTime;
46
+ velocity.y += acceleration.y * deltaTime;
47
+ }
48
+ position.x += velocity.x * deltaTime;
49
+ position.y += velocity.y * deltaTime;
50
+ };
51
+
38
52
  // src/math/_web.js
39
53
  globalThis.utils = Object.assign(globalThis.utils || {}, math_exports);
40
54
  })();
package/dist/math.min.js CHANGED
@@ -1 +1 @@
1
- (()=>{var u=Object.defineProperty;var b=(l,a)=>{for(var t in a)u(l,t,{get:a[t],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=()=>{for(let l in globalThis.utils)l!=="global"&&(globalThis[l]=globalThis.utils[l])};var o={};b(o,{diff:()=>s,fract:()=>r,range:()=>e,wave:()=>i});var s=(l,a)=>Math.abs(a-l)||0;var i=(l,a,t,f=Math.sin)=>l+(f(t)+1)/2*(a-l);var r=l=>l%1||0;var e=l=>Array.from(Array(l).keys());globalThis.utils=Object.assign(globalThis.utils||{},o);})();
1
+ (()=>{var a=Object.defineProperty;var p=(t,o)=>{for(var r in o)a(t,r,{get:o[r],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=()=>{for(let t in globalThis.utils)t!=="global"&&(globalThis[t]=globalThis.utils[t])};var s={};p(s,{advance:()=>u,diff:()=>n,fract:()=>x,range:()=>y,wave:()=>c});var n=(t,o)=>Math.abs(o-t)||0;var c=(t,o,r,e=Math.sin)=>t+(e(r)+1)/2*(o-t);var x=t=>t%1||0;var y=t=>Array.from(Array(t).keys());var d=2*Math.PI;var u=advance=(t,o,r,e=1)=>{r&&(o.x+=r.x*e,o.y+=r.y*e),t.x+=o.x*e,t.y+=o.y*e};globalThis.utils=Object.assign(globalThis.utils||{},s);})();