@tsparticles/engine 3.2.0 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/373.min.js +1 -1
  2. package/373.min.js.LICENSE.txt +1 -1
  3. package/438.min.js +1 -1
  4. package/438.min.js.LICENSE.txt +1 -1
  5. package/browser/Core/Container.js +1 -1
  6. package/browser/Core/Engine.js +1 -1
  7. package/browser/Core/Particle.js +1 -2
  8. package/browser/Core/Particles.js +1 -1
  9. package/browser/Core/Utils/EventListeners.js +4 -3
  10. package/browser/Core/Utils/QuadTree.js +4 -5
  11. package/browser/Core/Utils/Ranges.js +55 -0
  12. package/browser/Core/Utils/{Vector3d.js → Vectors.js} +15 -1
  13. package/browser/Options/Classes/AnimatableColor.js +1 -1
  14. package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +1 -1
  15. package/browser/Options/Classes/Options.js +2 -1
  16. package/browser/Options/Classes/OptionsColor.js +1 -1
  17. package/browser/Options/Classes/Particles/Move/Move.js +1 -1
  18. package/browser/Types/RangeType.js +1 -0
  19. package/browser/Utils/ColorUtils.js +2 -1
  20. package/browser/Utils/NumberUtils.js +2 -2
  21. package/browser/Utils/TypeUtils.js +18 -0
  22. package/browser/Utils/Utils.js +2 -19
  23. package/browser/exports.js +3 -5
  24. package/cjs/Core/Container.js +1 -1
  25. package/cjs/Core/Engine.js +1 -1
  26. package/cjs/Core/Particle.js +4 -5
  27. package/cjs/Core/Particles.js +2 -2
  28. package/cjs/Core/Utils/EventListeners.js +4 -3
  29. package/cjs/Core/Utils/QuadTree.js +7 -8
  30. package/cjs/Core/Utils/Ranges.js +61 -0
  31. package/cjs/Core/Utils/{Vector3d.js → Vectors.js} +18 -3
  32. package/cjs/Options/Classes/AnimatableColor.js +2 -2
  33. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +2 -2
  34. package/cjs/Options/Classes/Options.js +2 -1
  35. package/cjs/Options/Classes/OptionsColor.js +2 -2
  36. package/cjs/Options/Classes/Particles/Move/Move.js +4 -4
  37. package/cjs/Types/RangeType.js +2 -0
  38. package/cjs/Utils/ColorUtils.js +9 -8
  39. package/cjs/Utils/NumberUtils.js +9 -9
  40. package/cjs/Utils/TypeUtils.js +27 -0
  41. package/cjs/Utils/Utils.js +13 -36
  42. package/cjs/exports.js +3 -5
  43. package/dist_browser_Core_Container_js.js +5 -5
  44. package/dist_browser_Core_Particle_js.js +2 -2
  45. package/esm/Core/Container.js +1 -1
  46. package/esm/Core/Engine.js +1 -1
  47. package/esm/Core/Particle.js +1 -2
  48. package/esm/Core/Particles.js +1 -1
  49. package/esm/Core/Utils/EventListeners.js +4 -3
  50. package/esm/Core/Utils/QuadTree.js +4 -5
  51. package/esm/Core/Utils/Ranges.js +55 -0
  52. package/esm/Core/Utils/{Vector3d.js → Vectors.js} +15 -1
  53. package/esm/Options/Classes/AnimatableColor.js +1 -1
  54. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +1 -1
  55. package/esm/Options/Classes/Options.js +2 -1
  56. package/esm/Options/Classes/OptionsColor.js +1 -1
  57. package/esm/Options/Classes/Particles/Move/Move.js +1 -1
  58. package/esm/Types/RangeType.js +1 -0
  59. package/esm/Utils/ColorUtils.js +2 -1
  60. package/esm/Utils/NumberUtils.js +2 -2
  61. package/esm/Utils/TypeUtils.js +18 -0
  62. package/esm/Utils/Utils.js +2 -19
  63. package/esm/exports.js +3 -5
  64. package/package.json +1 -1
  65. package/report.html +1 -1
  66. package/tsparticles.engine.js +30 -50
  67. package/tsparticles.engine.min.js +1 -1
  68. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  69. package/types/Core/Interfaces/ICircleBouncer.d.ts +1 -1
  70. package/types/Core/Interfaces/IMovePathGenerator.d.ts +1 -1
  71. package/types/Core/Particle.d.ts +1 -2
  72. package/types/Core/Utils/QuadTree.d.ts +2 -3
  73. package/types/Core/Utils/Ranges.d.ts +21 -0
  74. package/types/Core/Utils/{Vector3d.d.ts → Vectors.d.ts} +6 -0
  75. package/types/Types/RangeType.d.ts +4 -0
  76. package/types/Utils/NumberUtils.d.ts +1 -1
  77. package/types/Utils/TypeUtils.d.ts +6 -0
  78. package/types/Utils/Utils.d.ts +0 -6
  79. package/types/exports.d.ts +3 -5
  80. package/umd/Core/Container.js +1 -1
  81. package/umd/Core/Engine.js +1 -1
  82. package/umd/Core/Particle.js +5 -6
  83. package/umd/Core/Particles.js +3 -3
  84. package/umd/Core/Utils/EventListeners.js +5 -4
  85. package/umd/Core/Utils/QuadTree.js +8 -9
  86. package/umd/Core/Utils/Ranges.js +71 -0
  87. package/umd/Core/Utils/{Vector3d.js → Vectors.js} +19 -4
  88. package/umd/Options/Classes/AnimatableColor.js +3 -3
  89. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +3 -3
  90. package/umd/Options/Classes/Options.js +3 -2
  91. package/umd/Options/Classes/OptionsColor.js +3 -3
  92. package/umd/Options/Classes/Particles/Move/Move.js +5 -5
  93. package/umd/{Core/Utils/Range.js → Types/RangeType.js} +0 -10
  94. package/umd/Utils/ColorUtils.js +10 -9
  95. package/umd/Utils/NumberUtils.js +10 -10
  96. package/umd/Utils/TypeUtils.js +37 -0
  97. package/umd/Utils/Utils.js +14 -37
  98. package/umd/exports.js +4 -6
  99. package/browser/Core/Utils/Circle.js +0 -28
  100. package/browser/Core/Utils/Range.js +0 -8
  101. package/browser/Core/Utils/Rectangle.js +0 -22
  102. package/browser/Core/Utils/Vector.js +0 -20
  103. package/cjs/Core/Utils/Circle.js +0 -32
  104. package/cjs/Core/Utils/Range.js +0 -12
  105. package/cjs/Core/Utils/Rectangle.js +0 -26
  106. package/cjs/Core/Utils/Vector.js +0 -24
  107. package/esm/Core/Utils/Circle.js +0 -28
  108. package/esm/Core/Utils/Range.js +0 -8
  109. package/esm/Core/Utils/Rectangle.js +0 -22
  110. package/esm/Core/Utils/Vector.js +0 -20
  111. package/types/Core/Utils/Circle.d.ts +0 -8
  112. package/types/Core/Utils/Range.d.ts +0 -7
  113. package/types/Core/Utils/Rectangle.d.ts +0 -9
  114. package/types/Core/Utils/Vector.d.ts +0 -8
  115. package/umd/Core/Utils/Circle.js +0 -42
  116. package/umd/Core/Utils/Rectangle.js +0 -36
  117. package/umd/Core/Utils/Vector.js +0 -34
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QuadTree = void 0;
4
- const Circle_js_1 = require("./Circle.js");
5
- const Rectangle_js_1 = require("./Rectangle.js");
4
+ const Ranges_js_1 = require("./Ranges.js");
6
5
  const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
7
6
  const half = 0.5, double = 2, subdivideCount = 4;
8
7
  class QuadTree {
@@ -13,7 +12,7 @@ class QuadTree {
13
12
  const { x, y } = this.rectangle.position, { width, height } = this.rectangle.size, { capacity } = this;
14
13
  for (let i = 0; i < subdivideCount; i++) {
15
14
  const fixedIndex = i % double;
16
- this._subs.push(new QuadTree(new Rectangle_js_1.Rectangle(x + width * half * fixedIndex, y + height * half * (Math.round(i * half) - fixedIndex), width * half, height * half), capacity));
15
+ this._subs.push(new QuadTree(new Ranges_js_1.Rectangle(x + width * half * fixedIndex, y + height * half * (Math.round(i * half) - fixedIndex), width * half, height * half), capacity));
17
16
  }
18
17
  this._divided = true;
19
18
  };
@@ -34,8 +33,8 @@ class QuadTree {
34
33
  }
35
34
  return this._subs.some((sub) => sub.insert(point));
36
35
  }
37
- query(range, check, found) {
38
- const res = found ?? [];
36
+ query(range, check) {
37
+ const res = [];
39
38
  if (!range.intersects(this.rectangle)) {
40
39
  return [];
41
40
  }
@@ -49,16 +48,16 @@ class QuadTree {
49
48
  }
50
49
  if (this._divided) {
51
50
  for (const sub of this._subs) {
52
- sub.query(range, check, res);
51
+ res.push(...sub.query(range, check));
53
52
  }
54
53
  }
55
54
  return res;
56
55
  }
57
56
  queryCircle(position, radius, check) {
58
- return this.query(new Circle_js_1.Circle(position.x, position.y, radius), check);
57
+ return this.query(new Ranges_js_1.Circle(position.x, position.y, radius), check);
59
58
  }
60
59
  queryRectangle(position, size, check) {
61
- return this.query(new Rectangle_js_1.Rectangle(position.x, position.y, size.width, size.height), check);
60
+ return this.query(new Ranges_js_1.Rectangle(position.x, position.y, size.width, size.height), check);
62
61
  }
63
62
  }
64
63
  exports.QuadTree = QuadTree;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Rectangle = exports.Circle = exports.BaseRange = void 0;
4
+ const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
5
+ const squareExp = 2;
6
+ class BaseRange {
7
+ constructor(x, y, type) {
8
+ this.position = {
9
+ x: x,
10
+ y: y,
11
+ };
12
+ this.type = type;
13
+ }
14
+ }
15
+ exports.BaseRange = BaseRange;
16
+ class Circle extends BaseRange {
17
+ constructor(x, y, radius) {
18
+ super(x, y, "circle");
19
+ this.radius = radius;
20
+ }
21
+ contains(point) {
22
+ return (0, NumberUtils_js_1.getDistance)(point, this.position) <= this.radius;
23
+ }
24
+ intersects(range) {
25
+ const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
26
+ if (range instanceof Circle || range.type === "circle") {
27
+ const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
28
+ return rSum > dist;
29
+ }
30
+ else if (range instanceof Rectangle || range.type === "rectangle") {
31
+ const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
32
+ return (edges <= r ** squareExp ||
33
+ (distPos.x <= r + width && distPos.y <= r + height) ||
34
+ distPos.x <= width ||
35
+ distPos.y <= height);
36
+ }
37
+ return false;
38
+ }
39
+ }
40
+ exports.Circle = Circle;
41
+ class Rectangle extends BaseRange {
42
+ constructor(x, y, width, height) {
43
+ super(x, y, "rectangle");
44
+ this.size = {
45
+ height: height,
46
+ width: width,
47
+ };
48
+ }
49
+ contains(point) {
50
+ const w = this.size.width, h = this.size.height, pos = this.position;
51
+ return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
52
+ }
53
+ intersects(range) {
54
+ if (range instanceof Circle) {
55
+ return range.intersects(this);
56
+ }
57
+ const w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position, size2 = range instanceof Rectangle ? range.size : { width: 0, height: 0 }, w2 = size2.width, h2 = size2.height;
58
+ return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
59
+ }
60
+ }
61
+ exports.Rectangle = Rectangle;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vector3d = void 0;
3
+ exports.Vector = exports.Vector3d = void 0;
4
4
  const Constants_js_1 = require("./Constants.js");
5
- const Utils_js_1 = require("../../Utils/Utils.js");
5
+ const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
6
6
  const origin = {
7
7
  x: 0,
8
8
  y: 0,
@@ -14,7 +14,7 @@ class Vector3d {
14
14
  this.x = Math.cos(angle) * length;
15
15
  this.y = Math.sin(angle) * length;
16
16
  };
17
- if (!(0, Utils_js_1.isNumber)(xOrCoords) && xOrCoords) {
17
+ if (!(0, TypeUtils_js_1.isNumber)(xOrCoords) && xOrCoords) {
18
18
  this.x = xOrCoords.x;
19
19
  this.y = xOrCoords.y;
20
20
  const coords3d = xOrCoords;
@@ -111,3 +111,18 @@ class Vector3d {
111
111
  }
112
112
  }
113
113
  exports.Vector3d = Vector3d;
114
+ class Vector extends Vector3d {
115
+ constructor(xOrCoords, y) {
116
+ super(xOrCoords, y, origin.z);
117
+ }
118
+ static get origin() {
119
+ return Vector.create(origin.x, origin.y);
120
+ }
121
+ static clone(source) {
122
+ return Vector.create(source.x, source.y);
123
+ }
124
+ static create(x, y) {
125
+ return new Vector(x, y);
126
+ }
127
+ }
128
+ exports.Vector = Vector;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AnimatableColor = void 0;
4
- const Utils_js_1 = require("../../Utils/Utils.js");
4
+ const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
5
5
  const HslAnimation_js_1 = require("./HslAnimation.js");
6
6
  const OptionsColor_js_1 = require("./OptionsColor.js");
7
7
  class AnimatableColor extends OptionsColor_js_1.OptionsColor {
@@ -13,7 +13,7 @@ class AnimatableColor extends OptionsColor_js_1.OptionsColor {
13
13
  const color = new AnimatableColor();
14
14
  color.load(source);
15
15
  if (data !== undefined) {
16
- if ((0, Utils_js_1.isString)(data) || (0, Utils_js_1.isArray)(data)) {
16
+ if ((0, TypeUtils_js_1.isString)(data) || (0, TypeUtils_js_1.isArray)(data)) {
17
17
  color.load({ value: data });
18
18
  }
19
19
  else {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BackgroundMask = void 0;
4
4
  const BackgroundMaskCover_js_1 = require("./BackgroundMaskCover.js");
5
- const Utils_js_1 = require("../../../Utils/Utils.js");
5
+ const TypeUtils_js_1 = require("../../../Utils/TypeUtils.js");
6
6
  class BackgroundMask {
7
7
  constructor() {
8
8
  this.composite = "destination-out";
@@ -17,7 +17,7 @@ class BackgroundMask {
17
17
  this.composite = data.composite;
18
18
  }
19
19
  if (data.cover !== undefined) {
20
- const cover = data.cover, color = ((0, Utils_js_1.isString)(data.cover) ? { color: data.cover } : data.cover);
20
+ const cover = data.cover, color = ((0, TypeUtils_js_1.isString)(data.cover) ? { color: data.cover } : data.cover);
21
21
  this.cover.load(cover.color !== undefined || cover.image !== undefined ? cover : { color: color });
22
22
  }
23
23
  if (data.enable !== undefined) {
@@ -9,6 +9,7 @@ const Interactivity_js_1 = require("./Interactivity/Interactivity.js");
9
9
  const ManualParticle_js_1 = require("./ManualParticle.js");
10
10
  const Responsive_js_1 = require("./Responsive.js");
11
11
  const Theme_js_1 = require("./Theme/Theme.js");
12
+ const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
12
13
  const OptionsUtils_js_1 = require("../../Utils/OptionsUtils.js");
13
14
  const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
14
15
  class Options {
@@ -87,7 +88,7 @@ class Options {
87
88
  }
88
89
  this.background.load(data.background);
89
90
  const fullScreen = data.fullScreen;
90
- if ((0, Utils_js_1.isBoolean)(fullScreen)) {
91
+ if ((0, TypeUtils_js_1.isBoolean)(fullScreen)) {
91
92
  this.fullScreen.enable = fullScreen;
92
93
  }
93
94
  else {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OptionsColor = void 0;
4
- const Utils_js_1 = require("../../Utils/Utils.js");
4
+ const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
5
5
  class OptionsColor {
6
6
  constructor() {
7
7
  this.value = "";
@@ -10,7 +10,7 @@ class OptionsColor {
10
10
  const color = new OptionsColor();
11
11
  color.load(source);
12
12
  if (data !== undefined) {
13
- if ((0, Utils_js_1.isString)(data) || (0, Utils_js_1.isArray)(data)) {
13
+ if ((0, TypeUtils_js_1.isString)(data) || (0, TypeUtils_js_1.isArray)(data)) {
14
14
  color.load({ value: data });
15
15
  }
16
16
  else {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Move = void 0;
4
- const Utils_js_1 = require("../../../../Utils/Utils.js");
4
+ const TypeUtils_js_1 = require("../../../../Utils/TypeUtils.js");
5
5
  const MoveAngle_js_1 = require("./MoveAngle.js");
6
6
  const MoveAttract_js_1 = require("./MoveAttract.js");
7
7
  const MoveCenter_js_1 = require("./MoveCenter.js");
@@ -37,7 +37,7 @@ class Move {
37
37
  if (!data) {
38
38
  return;
39
39
  }
40
- this.angle.load((0, Utils_js_1.isNumber)(data.angle) ? { value: data.angle } : data.angle);
40
+ this.angle.load((0, TypeUtils_js_1.isNumber)(data.angle) ? { value: data.angle } : data.angle);
41
41
  this.attract.load(data.attract);
42
42
  this.center.load(data.center);
43
43
  if (data.decay !== undefined) {
@@ -47,7 +47,7 @@ class Move {
47
47
  this.direction = data.direction;
48
48
  }
49
49
  if (data.distance !== undefined) {
50
- this.distance = (0, Utils_js_1.isNumber)(data.distance)
50
+ this.distance = (0, TypeUtils_js_1.isNumber)(data.distance)
51
51
  ? {
52
52
  horizontal: data.distance,
53
53
  vertical: data.distance,
@@ -63,7 +63,7 @@ class Move {
63
63
  this.gravity.load(data.gravity);
64
64
  const outModes = data.outModes;
65
65
  if (outModes !== undefined) {
66
- if ((0, Utils_js_1.isObject)(outModes)) {
66
+ if ((0, TypeUtils_js_1.isObject)(outModes)) {
67
67
  this.outModes.load(outModes);
68
68
  }
69
69
  else {
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateColor = exports.updateColorValue = exports.getHslAnimationFromHsl = exports.getHslFromAnimation = exports.getLinkRandomColor = exports.getLinkColor = exports.colorMix = exports.getStyleFromHsl = exports.getStyleFromRgb = exports.getRandomRgbColor = exports.hslaToRgba = exports.hslToRgb = exports.stringToRgb = exports.stringToAlpha = exports.rgbToHsl = exports.rangeColorToHsl = exports.colorToHsl = exports.colorToRgb = exports.rangeColorToRgb = exports.addColorManager = void 0;
4
4
  const NumberUtils_js_1 = require("./NumberUtils.js");
5
- const Utils_js_1 = require("./Utils.js");
5
+ const TypeUtils_js_1 = require("./TypeUtils.js");
6
6
  const Constants_js_1 = require("../Core/Utils/Constants.js");
7
+ const Utils_js_1 = require("./Utils.js");
7
8
  const randomColorValue = "random", midColorValue = "mid", colorManagers = new Map();
8
9
  function addColorManager(manager) {
9
10
  colorManagers.set(manager.key, manager);
@@ -33,11 +34,11 @@ function rangeColorToRgb(input, index, useIndex = true) {
33
34
  if (!input) {
34
35
  return;
35
36
  }
36
- const color = (0, Utils_js_1.isString)(input) ? { value: input } : input;
37
- if ((0, Utils_js_1.isString)(color.value)) {
37
+ const color = (0, TypeUtils_js_1.isString)(input) ? { value: input } : input;
38
+ if ((0, TypeUtils_js_1.isString)(color.value)) {
38
39
  return colorToRgb(color.value, index, useIndex);
39
40
  }
40
- if ((0, Utils_js_1.isArray)(color.value)) {
41
+ if ((0, TypeUtils_js_1.isArray)(color.value)) {
41
42
  return rangeColorToRgb({
42
43
  value: (0, Utils_js_1.itemFromArray)(color.value, index, useIndex),
43
44
  });
@@ -54,11 +55,11 @@ function colorToRgb(input, index, useIndex = true) {
54
55
  if (!input) {
55
56
  return;
56
57
  }
57
- const color = (0, Utils_js_1.isString)(input) ? { value: input } : input;
58
- if ((0, Utils_js_1.isString)(color.value)) {
58
+ const color = (0, TypeUtils_js_1.isString)(input) ? { value: input } : input;
59
+ if ((0, TypeUtils_js_1.isString)(color.value)) {
59
60
  return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(color.value);
60
61
  }
61
- if ((0, Utils_js_1.isArray)(color.value)) {
62
+ if ((0, TypeUtils_js_1.isArray)(color.value)) {
62
63
  return colorToRgb({
63
64
  value: (0, Utils_js_1.itemFromArray)(color.value, index, useIndex),
64
65
  });
@@ -211,7 +212,7 @@ function getLinkColor(p1, p2, linkColor) {
211
212
  }
212
213
  exports.getLinkColor = getLinkColor;
213
214
  function getLinkRandomColor(optColor, blink, consent) {
214
- const color = (0, Utils_js_1.isString)(optColor) ? optColor : optColor.value;
215
+ const color = (0, TypeUtils_js_1.isString)(optColor) ? optColor : optColor.value;
215
216
  if (color === randomColorValue) {
216
217
  if (consent) {
217
218
  return rangeColorToRgb({
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseAlpha = exports.calcExactPositionOrRandomFromSizeRanged = exports.calcExactPositionOrRandomFromSize = exports.calcPositionOrRandomFromSizeRanged = exports.calcPositionOrRandomFromSize = exports.calcPositionFromSize = exports.collisionVelocity = exports.getParticleBaseVelocity = exports.getParticleDirectionAngle = exports.degToRad = exports.getDistance = exports.getDistances = exports.setRangeValue = exports.getRangeMax = exports.getRangeMin = exports.getRangeValue = exports.randomInRange = exports.mix = exports.clamp = exports.getRandom = exports.setRandom = exports.getEasing = exports.addEasing = void 0;
4
- const Vector_js_1 = require("../Core/Utils/Vector.js");
5
- const Utils_js_1 = require("./Utils.js");
4
+ const Vectors_js_1 = require("../Core/Utils/Vectors.js");
5
+ const TypeUtils_js_1 = require("./TypeUtils.js");
6
6
  const Constants_js_1 = require("../Core/Utils/Constants.js");
7
7
  let _random = Math.random;
8
8
  const easings = new Map(), double = 2, doublePI = Math.PI * double;
@@ -44,19 +44,19 @@ function randomInRange(r) {
44
44
  }
45
45
  exports.randomInRange = randomInRange;
46
46
  function getRangeValue(value) {
47
- return (0, Utils_js_1.isNumber)(value) ? value : randomInRange(value);
47
+ return (0, TypeUtils_js_1.isNumber)(value) ? value : randomInRange(value);
48
48
  }
49
49
  exports.getRangeValue = getRangeValue;
50
50
  function getRangeMin(value) {
51
- return (0, Utils_js_1.isNumber)(value) ? value : value.min;
51
+ return (0, TypeUtils_js_1.isNumber)(value) ? value : value.min;
52
52
  }
53
53
  exports.getRangeMin = getRangeMin;
54
54
  function getRangeMax(value) {
55
- return (0, Utils_js_1.isNumber)(value) ? value : value.max;
55
+ return (0, TypeUtils_js_1.isNumber)(value) ? value : value.max;
56
56
  }
57
57
  exports.getRangeMax = getRangeMax;
58
58
  function setRangeValue(source, value) {
59
- if (source === value || (value === undefined && (0, Utils_js_1.isNumber)(source))) {
59
+ if (source === value || (value === undefined && (0, TypeUtils_js_1.isNumber)(source))) {
60
60
  return source;
61
61
  }
62
62
  const min = getRangeMin(source), max = getRangeMax(source);
@@ -83,7 +83,7 @@ function degToRad(degrees) {
83
83
  }
84
84
  exports.degToRad = degToRad;
85
85
  function getParticleDirectionAngle(direction, position, center) {
86
- if ((0, Utils_js_1.isNumber)(direction)) {
86
+ if ((0, TypeUtils_js_1.isNumber)(direction)) {
87
87
  return degToRad(direction);
88
88
  }
89
89
  const empty = 0, half = 0.5, quarter = 0.25, threeQuarter = half + quarter;
@@ -114,7 +114,7 @@ function getParticleDirectionAngle(direction, position, center) {
114
114
  }
115
115
  exports.getParticleDirectionAngle = getParticleDirectionAngle;
116
116
  function getParticleBaseVelocity(direction) {
117
- const baseVelocity = Vector_js_1.Vector.origin;
117
+ const baseVelocity = Vectors_js_1.Vector.origin;
118
118
  baseVelocity.length = 1;
119
119
  baseVelocity.angle = direction;
120
120
  return baseVelocity;
@@ -122,7 +122,7 @@ function getParticleBaseVelocity(direction) {
122
122
  exports.getParticleBaseVelocity = getParticleBaseVelocity;
123
123
  function collisionVelocity(v1, v2, m1, m2) {
124
124
  const double = 2;
125
- return Vector_js_1.Vector.create((v1.x * (m1 - m2)) / (m1 + m2) + (v2.x * double * m2) / (m1 + m2), v1.y);
125
+ return Vectors_js_1.Vector.create((v1.x * (m1 - m2)) / (m1 + m2) + (v2.x * double * m2) / (m1 + m2), v1.y);
126
126
  }
127
127
  exports.collisionVelocity = collisionVelocity;
128
128
  function calcPositionFromSize(data) {
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isArray = exports.isObject = exports.isFunction = exports.isNumber = exports.isString = exports.isBoolean = void 0;
4
+ function isBoolean(arg) {
5
+ return typeof arg === "boolean";
6
+ }
7
+ exports.isBoolean = isBoolean;
8
+ function isString(arg) {
9
+ return typeof arg === "string";
10
+ }
11
+ exports.isString = isString;
12
+ function isNumber(arg) {
13
+ return typeof arg === "number";
14
+ }
15
+ exports.isNumber = isNumber;
16
+ function isFunction(arg) {
17
+ return typeof arg === "function";
18
+ }
19
+ exports.isFunction = isFunction;
20
+ function isObject(arg) {
21
+ return typeof arg === "object" && arg !== null;
22
+ }
23
+ exports.isObject = isObject;
24
+ function isArray(arg) {
25
+ return Array.isArray(arg);
26
+ }
27
+ exports.isArray = isArray;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateAnimation = exports.isArray = exports.isObject = exports.isFunction = exports.isNumber = exports.isString = exports.isBoolean = exports.getSize = exports.getPosition = exports.initParticleNumericAnimationValue = exports.findItemFromSingleOrMultiple = exports.itemFromSingleOrMultiple = exports.executeOnSingleOrMultiple = exports.rectBounce = exports.circleBounce = exports.circleBounceDataFromParticle = exports.divMode = exports.singleDivModeExecute = exports.divModeExecute = exports.isDivModeEnabled = exports.deepExtend = exports.calculateBounds = exports.areBoundsInside = exports.isPointInside = exports.itemFromArray = exports.arrayRandomIndex = exports.loadFont = exports.isInArray = exports.safeMutationObserver = exports.safeIntersectionObserver = exports.safeMatchMedia = exports.hasMatchMedia = exports.isSsr = exports.getLogger = exports.setLogger = void 0;
3
+ exports.updateAnimation = exports.getSize = exports.getPosition = exports.initParticleNumericAnimationValue = exports.findItemFromSingleOrMultiple = exports.itemFromSingleOrMultiple = exports.executeOnSingleOrMultiple = exports.rectBounce = exports.circleBounce = exports.circleBounceDataFromParticle = exports.divMode = exports.singleDivModeExecute = exports.divModeExecute = exports.isDivModeEnabled = exports.deepExtend = exports.calculateBounds = exports.areBoundsInside = exports.isPointInside = exports.itemFromArray = exports.arrayRandomIndex = exports.loadFont = exports.isInArray = exports.safeMutationObserver = exports.safeIntersectionObserver = exports.safeMatchMedia = exports.hasMatchMedia = exports.isSsr = exports.getLogger = exports.setLogger = void 0;
4
4
  const NumberUtils_js_1 = require("./NumberUtils.js");
5
5
  const Constants_js_1 = require("../Core/Utils/Constants.js");
6
- const Vector_js_1 = require("../Core/Utils/Vector.js");
6
+ const TypeUtils_js_1 = require("./TypeUtils.js");
7
+ const Vectors_js_1 = require("../Core/Utils/Vectors.js");
7
8
  const _logger = {
8
9
  debug: console.debug,
9
10
  error: console.error,
@@ -44,7 +45,7 @@ function checkSelector(element, selectors) {
44
45
  const res = executeOnSingleOrMultiple(selectors, (selector) => {
45
46
  return element.matches(selector);
46
47
  });
47
- return isArray(res) ? res.some((t) => t) : res;
48
+ return (0, TypeUtils_js_1.isArray)(res) ? res.some((t) => t) : res;
48
49
  }
49
50
  function isSsr() {
50
51
  return typeof window === "undefined" || !window || typeof window.document === "undefined" || !window.document;
@@ -77,7 +78,7 @@ function safeMutationObserver(callback) {
77
78
  exports.safeMutationObserver = safeMutationObserver;
78
79
  function isInArray(value, array) {
79
80
  const invalidIndex = -1;
80
- return value === array || (isArray(array) && array.indexOf(value) > invalidIndex);
81
+ return value === array || ((0, TypeUtils_js_1.isArray)(array) && array.indexOf(value) > invalidIndex);
81
82
  }
82
83
  exports.isInArray = isInArray;
83
84
  async function loadFont(font, weight) {
@@ -132,15 +133,15 @@ function deepExtend(destination, ...sources) {
132
133
  if (source === undefined || source === null) {
133
134
  continue;
134
135
  }
135
- if (!isObject(source)) {
136
+ if (!(0, TypeUtils_js_1.isObject)(source)) {
136
137
  destination = source;
137
138
  continue;
138
139
  }
139
140
  const sourceIsArray = Array.isArray(source);
140
- if (sourceIsArray && (isObject(destination) || !destination || !Array.isArray(destination))) {
141
+ if (sourceIsArray && ((0, TypeUtils_js_1.isObject)(destination) || !destination || !Array.isArray(destination))) {
141
142
  destination = [];
142
143
  }
143
- else if (!sourceIsArray && (isObject(destination) || !destination || Array.isArray(destination))) {
144
+ else if (!sourceIsArray && ((0, TypeUtils_js_1.isObject)(destination) || !destination || Array.isArray(destination))) {
144
145
  destination = {};
145
146
  }
146
147
  for (const key in source) {
@@ -149,7 +150,7 @@ function deepExtend(destination, ...sources) {
149
150
  }
150
151
  const sourceDict = source, value = sourceDict[key], destDict = destination;
151
152
  destDict[key] =
152
- isObject(value) && Array.isArray(value)
153
+ (0, TypeUtils_js_1.isObject)(value) && Array.isArray(value)
153
154
  ? value.map((v) => deepExtend(destDict[key], v))
154
155
  : deepExtend(destDict[key], value);
155
156
  }
@@ -192,7 +193,7 @@ function circleBounceDataFromParticle(p) {
192
193
  radius: p.getRadius(),
193
194
  mass: p.getMass(),
194
195
  velocity: p.velocity,
195
- factor: Vector_js_1.Vector.create((0, NumberUtils_js_1.getRangeValue)(p.options.bounce.horizontal.value), (0, NumberUtils_js_1.getRangeValue)(p.options.bounce.vertical.value)),
196
+ factor: Vectors_js_1.Vector.create((0, NumberUtils_js_1.getRangeValue)(p.options.bounce.horizontal.value), (0, NumberUtils_js_1.getRangeValue)(p.options.bounce.vertical.value)),
196
197
  };
197
198
  }
198
199
  exports.circleBounceDataFromParticle = circleBounceDataFromParticle;
@@ -269,15 +270,15 @@ function rectBounce(particle, divBounds) {
269
270
  exports.rectBounce = rectBounce;
270
271
  function executeOnSingleOrMultiple(obj, callback) {
271
272
  const defaultIndex = 0;
272
- return isArray(obj) ? obj.map((item, index) => callback(item, index)) : callback(obj, defaultIndex);
273
+ return (0, TypeUtils_js_1.isArray)(obj) ? obj.map((item, index) => callback(item, index)) : callback(obj, defaultIndex);
273
274
  }
274
275
  exports.executeOnSingleOrMultiple = executeOnSingleOrMultiple;
275
276
  function itemFromSingleOrMultiple(obj, index, useIndex) {
276
- return isArray(obj) ? itemFromArray(obj, index, useIndex) : obj;
277
+ return (0, TypeUtils_js_1.isArray)(obj) ? itemFromArray(obj, index, useIndex) : obj;
277
278
  }
278
279
  exports.itemFromSingleOrMultiple = itemFromSingleOrMultiple;
279
280
  function findItemFromSingleOrMultiple(obj, callback) {
280
- if (isArray(obj)) {
281
+ if ((0, TypeUtils_js_1.isArray)(obj)) {
281
282
  return obj.find((t, index) => callback(t, index));
282
283
  }
283
284
  const defaultIndex = 0;
@@ -363,30 +364,6 @@ function getSize(size, canvasSize) {
363
364
  return getPositionOrSize(size, canvasSize);
364
365
  }
365
366
  exports.getSize = getSize;
366
- function isBoolean(arg) {
367
- return typeof arg === "boolean";
368
- }
369
- exports.isBoolean = isBoolean;
370
- function isString(arg) {
371
- return typeof arg === "string";
372
- }
373
- exports.isString = isString;
374
- function isNumber(arg) {
375
- return typeof arg === "number";
376
- }
377
- exports.isNumber = isNumber;
378
- function isFunction(arg) {
379
- return typeof arg === "function";
380
- }
381
- exports.isFunction = isFunction;
382
- function isObject(arg) {
383
- return typeof arg === "object" && arg !== null;
384
- }
385
- exports.isObject = isObject;
386
- function isArray(arg) {
387
- return Array.isArray(arg);
388
- }
389
- exports.isArray = isArray;
390
367
  function checkDestroy(particle, destroyType, value, minValue, maxValue) {
391
368
  switch (destroyType) {
392
369
  case "max":
package/cjs/exports.js CHANGED
@@ -14,15 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Core/Utils/Circle.js"), exports);
18
17
  __exportStar(require("./Core/Utils/Constants.js"), exports);
19
18
  __exportStar(require("./Core/Utils/ExternalInteractorBase.js"), exports);
20
19
  __exportStar(require("./Core/Utils/ParticlesInteractorBase.js"), exports);
21
20
  __exportStar(require("./Core/Utils/Point.js"), exports);
22
- __exportStar(require("./Core/Utils/Range.js"), exports);
23
- __exportStar(require("./Core/Utils/Rectangle.js"), exports);
24
- __exportStar(require("./Core/Utils/Vector.js"), exports);
25
- __exportStar(require("./Core/Utils/Vector3d.js"), exports);
21
+ __exportStar(require("./Core/Utils/Ranges.js"), exports);
22
+ __exportStar(require("./Core/Utils/Vectors.js"), exports);
26
23
  __exportStar(require("./Enums/Directions/MoveDirection.js"), exports);
27
24
  __exportStar(require("./Enums/Directions/RotateDirection.js"), exports);
28
25
  __exportStar(require("./Enums/Directions/OutModeDirection.js"), exports);
@@ -102,3 +99,4 @@ __exportStar(require("./Utils/NumberUtils.js"), exports);
102
99
  __exportStar(require("./Utils/OptionsUtils.js"), exports);
103
100
  __exportStar(require("./Utils/RgbColorManager.js"), exports);
104
101
  __exportStar(require("./Utils/Utils.js"), exports);
102
+ __exportStar(require("./Utils/TypeUtils.js"), exports);