@tsparticles/engine 3.2.1 → 3.3.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.
Files changed (144) hide show
  1. package/174.min.js +2 -0
  2. package/174.min.js.LICENSE.txt +1 -0
  3. package/browser/Core/Canvas.js +9 -9
  4. package/browser/Core/Container.js +7 -7
  5. package/browser/Core/Engine.js +1 -1
  6. package/browser/Core/Particle.js +12 -13
  7. package/browser/Core/Particles.js +30 -30
  8. package/browser/Core/Utils/EventListeners.js +4 -3
  9. package/browser/Core/Utils/InteractionManager.js +4 -4
  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/CanvasUtils.js +14 -14
  20. package/browser/Utils/ColorUtils.js +2 -1
  21. package/browser/Utils/NumberUtils.js +2 -2
  22. package/browser/Utils/TypeUtils.js +18 -0
  23. package/browser/Utils/Utils.js +2 -19
  24. package/browser/exports.js +3 -5
  25. package/cjs/Core/Canvas.js +9 -9
  26. package/cjs/Core/Container.js +7 -7
  27. package/cjs/Core/Engine.js +2 -25
  28. package/cjs/Core/Particle.js +15 -16
  29. package/cjs/Core/Particles.js +32 -55
  30. package/cjs/Core/Utils/EventListeners.js +4 -3
  31. package/cjs/Core/Utils/InteractionManager.js +4 -4
  32. package/cjs/Core/Utils/QuadTree.js +7 -8
  33. package/cjs/Core/Utils/Ranges.js +61 -0
  34. package/cjs/Core/Utils/{Vector3d.js → Vectors.js} +18 -3
  35. package/cjs/Options/Classes/AnimatableColor.js +2 -2
  36. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +2 -2
  37. package/cjs/Options/Classes/Options.js +2 -1
  38. package/cjs/Options/Classes/OptionsColor.js +2 -2
  39. package/cjs/Options/Classes/Particles/Move/Move.js +4 -4
  40. package/cjs/Types/RangeType.js +2 -0
  41. package/cjs/Utils/CanvasUtils.js +14 -14
  42. package/cjs/Utils/ColorUtils.js +9 -8
  43. package/cjs/Utils/NumberUtils.js +9 -9
  44. package/cjs/Utils/TypeUtils.js +27 -0
  45. package/cjs/Utils/Utils.js +13 -36
  46. package/cjs/exports.js +3 -5
  47. package/dist_browser_Core_Container_js.js +17 -7
  48. package/esm/Core/Canvas.js +9 -9
  49. package/esm/Core/Container.js +7 -7
  50. package/esm/Core/Engine.js +1 -1
  51. package/esm/Core/Particle.js +12 -13
  52. package/esm/Core/Particles.js +30 -30
  53. package/esm/Core/Utils/EventListeners.js +4 -3
  54. package/esm/Core/Utils/InteractionManager.js +4 -4
  55. package/esm/Core/Utils/QuadTree.js +4 -5
  56. package/esm/Core/Utils/Ranges.js +55 -0
  57. package/esm/Core/Utils/{Vector3d.js → Vectors.js} +15 -1
  58. package/esm/Options/Classes/AnimatableColor.js +1 -1
  59. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +1 -1
  60. package/esm/Options/Classes/Options.js +2 -1
  61. package/esm/Options/Classes/OptionsColor.js +1 -1
  62. package/esm/Options/Classes/Particles/Move/Move.js +1 -1
  63. package/esm/Types/RangeType.js +1 -0
  64. package/esm/Utils/CanvasUtils.js +14 -14
  65. package/esm/Utils/ColorUtils.js +2 -1
  66. package/esm/Utils/NumberUtils.js +2 -2
  67. package/esm/Utils/TypeUtils.js +18 -0
  68. package/esm/Utils/Utils.js +2 -19
  69. package/esm/exports.js +3 -5
  70. package/package.json +1 -1
  71. package/report.html +1 -1
  72. package/tsparticles.engine.js +32 -52
  73. package/tsparticles.engine.min.js +1 -1
  74. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  75. package/types/Core/Canvas.d.ts +4 -4
  76. package/types/Core/Interfaces/ICircleBouncer.d.ts +1 -1
  77. package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -4
  78. package/types/Core/Interfaces/IEffectDrawer.d.ts +3 -3
  79. package/types/Core/Interfaces/IExternalInteractor.d.ts +1 -1
  80. package/types/Core/Interfaces/IMovePathGenerator.d.ts +3 -3
  81. package/types/Core/Interfaces/IParticleMover.d.ts +2 -2
  82. package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -2
  83. package/types/Core/Interfaces/IParticlesInteractor.d.ts +1 -1
  84. package/types/Core/Interfaces/IShapeDrawer.d.ts +4 -4
  85. package/types/Core/Particle.d.ts +3 -4
  86. package/types/Core/Particles.d.ts +7 -7
  87. package/types/Core/Utils/ExternalInteractorBase.d.ts +1 -1
  88. package/types/Core/Utils/InteractionManager.d.ts +2 -2
  89. package/types/Core/Utils/ParticlesInteractorBase.d.ts +1 -1
  90. package/types/Core/Utils/QuadTree.d.ts +2 -3
  91. package/types/Core/Utils/Ranges.d.ts +21 -0
  92. package/types/Core/Utils/{Vector3d.d.ts → Vectors.d.ts} +6 -0
  93. package/types/Types/RangeType.d.ts +4 -0
  94. package/types/Utils/CanvasUtils.d.ts +6 -6
  95. package/types/Utils/NumberUtils.d.ts +1 -1
  96. package/types/Utils/TypeUtils.d.ts +6 -0
  97. package/types/Utils/Utils.d.ts +0 -6
  98. package/types/exports.d.ts +3 -5
  99. package/umd/Core/Canvas.js +9 -9
  100. package/umd/Core/Container.js +7 -7
  101. package/umd/Core/Engine.js +1 -1
  102. package/umd/Core/Particle.js +16 -17
  103. package/umd/Core/Particles.js +33 -57
  104. package/umd/Core/Utils/EventListeners.js +5 -4
  105. package/umd/Core/Utils/InteractionManager.js +4 -4
  106. package/umd/Core/Utils/QuadTree.js +8 -9
  107. package/umd/Core/Utils/Ranges.js +71 -0
  108. package/umd/Core/Utils/{Vector3d.js → Vectors.js} +19 -4
  109. package/umd/Options/Classes/AnimatableColor.js +3 -3
  110. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +3 -3
  111. package/umd/Options/Classes/Options.js +3 -2
  112. package/umd/Options/Classes/OptionsColor.js +3 -3
  113. package/umd/Options/Classes/Particles/Move/Move.js +5 -5
  114. package/umd/{Core/Utils/Range.js → Types/RangeType.js} +0 -10
  115. package/umd/Utils/CanvasUtils.js +14 -14
  116. package/umd/Utils/ColorUtils.js +10 -9
  117. package/umd/Utils/NumberUtils.js +10 -10
  118. package/umd/Utils/TypeUtils.js +37 -0
  119. package/umd/Utils/Utils.js +14 -37
  120. package/umd/exports.js +4 -6
  121. package/373.min.js +0 -2
  122. package/373.min.js.LICENSE.txt +0 -1
  123. package/438.min.js +0 -2
  124. package/438.min.js.LICENSE.txt +0 -1
  125. package/browser/Core/Utils/Circle.js +0 -28
  126. package/browser/Core/Utils/Range.js +0 -8
  127. package/browser/Core/Utils/Rectangle.js +0 -22
  128. package/browser/Core/Utils/Vector.js +0 -20
  129. package/cjs/Core/Utils/Circle.js +0 -32
  130. package/cjs/Core/Utils/Range.js +0 -12
  131. package/cjs/Core/Utils/Rectangle.js +0 -26
  132. package/cjs/Core/Utils/Vector.js +0 -24
  133. package/dist_browser_Core_Particle_js.js +0 -32
  134. package/esm/Core/Utils/Circle.js +0 -28
  135. package/esm/Core/Utils/Range.js +0 -8
  136. package/esm/Core/Utils/Rectangle.js +0 -22
  137. package/esm/Core/Utils/Vector.js +0 -20
  138. package/types/Core/Utils/Circle.d.ts +0 -8
  139. package/types/Core/Utils/Range.d.ts +0 -7
  140. package/types/Core/Utils/Rectangle.d.ts +0 -9
  141. package/types/Core/Utils/Vector.d.ts +0 -8
  142. package/umd/Core/Utils/Circle.js +0 -42
  143. package/umd/Core/Utils/Rectangle.js +0 -36
  144. package/umd/Core/Utils/Vector.js +0 -34
@@ -1,39 +1,17 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.Particles = void 0;
27
4
  const Utils_js_1 = require("../Utils/Utils.js");
28
5
  const InteractionManager_js_1 = require("./Utils/InteractionManager.js");
6
+ const Particle_js_1 = require("./Particle.js");
29
7
  const Point_js_1 = require("./Utils/Point.js");
30
8
  const QuadTree_js_1 = require("./Utils/QuadTree.js");
31
- const Rectangle_js_1 = require("./Utils/Rectangle.js");
9
+ const Ranges_js_1 = require("./Utils/Ranges.js");
32
10
  const Constants_js_1 = require("./Utils/Constants.js");
33
11
  const qTreeCapacity = 4, squareExp = 2, defaultRemoveQuantity = 1;
34
12
  const qTreeRectangle = (canvasSize) => {
35
13
  const { height, width } = canvasSize, posOffset = -0.25, sizeFactor = 1.5;
36
- return new Rectangle_js_1.Rectangle(posOffset * width, posOffset * height, sizeFactor * width, sizeFactor * height);
14
+ return new Ranges_js_1.Rectangle(posOffset * width, posOffset * height, sizeFactor * width, sizeFactor * height);
37
15
  };
38
16
  class Particles {
39
17
  constructor(engine, container) {
@@ -42,7 +20,7 @@ class Particles {
42
20
  this._pool.push(particle);
43
21
  }
44
22
  };
45
- this._applyDensity = async (options, manualCount, group) => {
23
+ this._applyDensity = (options, manualCount, group) => {
46
24
  const numberOptions = options.number;
47
25
  if (!options.number.density?.enable) {
48
26
  if (group === undefined) {
@@ -61,7 +39,7 @@ class Particles {
61
39
  this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
62
40
  }
63
41
  if (particlesCount < particlesNumber) {
64
- await this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
42
+ this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
65
43
  }
66
44
  else if (particlesCount > particlesNumber) {
67
45
  this.removeQuantity(particlesCount - particlesNumber, group);
@@ -75,14 +53,13 @@ class Particles {
75
53
  const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
76
54
  return (canvas.width * canvas.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp);
77
55
  };
78
- this._pushParticle = async (position, overrideOptions, group, initializer) => {
56
+ this._pushParticle = (position, overrideOptions, group, initializer) => {
79
57
  try {
80
58
  let particle = this._pool.pop();
81
59
  if (!particle) {
82
- const { Particle } = await Promise.resolve().then(() => __importStar(require("./Particle.js")));
83
- particle = new Particle(this._engine, this._container);
60
+ particle = new Particle_js_1.Particle(this._engine, this._container);
84
61
  }
85
- await particle.init(this._nextId, position, overrideOptions, group);
62
+ particle.init(this._nextId, position, overrideOptions, group);
86
63
  let canAdd = true;
87
64
  if (initializer) {
88
65
  canAdd = initializer(particle);
@@ -143,13 +120,13 @@ class Particles {
143
120
  get count() {
144
121
  return this._array.length;
145
122
  }
146
- async addManualParticles() {
123
+ addManualParticles() {
147
124
  const container = this._container, options = container.actualOptions;
148
125
  for (const particle of options.manualParticles) {
149
- await this.addParticle(particle.position ? (0, Utils_js_1.getPosition)(particle.position, container.canvas.size) : undefined, particle.options);
126
+ this.addParticle(particle.position ? (0, Utils_js_1.getPosition)(particle.position, container.canvas.size) : undefined, particle.options);
150
127
  }
151
128
  }
152
- async addParticle(position, overrideOptions, group, initializer) {
129
+ addParticle(position, overrideOptions, group, initializer) {
153
130
  const limitOptions = this._container.actualOptions.particles.number.limit, limit = group === undefined ? this._limit : this._groupLimits.get(group) ?? this._limit, currentCount = this.count, minLimit = 0;
154
131
  if (limit > minLimit) {
155
132
  if (limitOptions.mode === "delete") {
@@ -164,7 +141,7 @@ class Particles {
164
141
  }
165
142
  }
166
143
  }
167
- return await this._pushParticle(position, overrideOptions, group, initializer);
144
+ return this._pushParticle(position, overrideOptions, group, initializer);
168
145
  }
169
146
  clear() {
170
147
  this._array = [];
@@ -177,15 +154,15 @@ class Particles {
177
154
  this.movers = [];
178
155
  this.updaters = [];
179
156
  }
180
- async draw(delta) {
157
+ draw(delta) {
181
158
  const container = this._container, canvas = container.canvas;
182
159
  canvas.clear();
183
- await this.update(delta);
160
+ this.update(delta);
184
161
  for (const [, plugin] of container.plugins) {
185
- await canvas.drawPlugin(plugin, delta);
162
+ canvas.drawPlugin(plugin, delta);
186
163
  }
187
164
  for (const p of this._zArray) {
188
- await p.draw(delta);
165
+ p.draw(delta);
189
166
  }
190
167
  }
191
168
  filter(condition) {
@@ -214,17 +191,17 @@ class Particles {
214
191
  break;
215
192
  }
216
193
  }
217
- await this.addManualParticles();
194
+ this.addManualParticles();
218
195
  if (!handled) {
219
196
  const particlesOptions = options.particles, groups = particlesOptions.groups;
220
197
  for (const group in groups) {
221
198
  const groupOptions = groups[group];
222
199
  for (let i = this.count, j = 0; j < groupOptions.number?.value && i < particlesOptions.number.value; i++, j++) {
223
- await this.addParticle(undefined, groupOptions, group);
200
+ this.addParticle(undefined, groupOptions, group);
224
201
  }
225
202
  }
226
203
  for (let i = this.count; i < particlesOptions.number.value; i++) {
227
- await this.addParticle();
204
+ this.addParticle();
228
205
  }
229
206
  }
230
207
  }
@@ -237,18 +214,18 @@ class Particles {
237
214
  this.updaters = await this._engine.getUpdaters(container, true);
238
215
  await this._interactionManager.init();
239
216
  for (const [, pathGenerator] of container.pathGenerators) {
240
- await pathGenerator.init(container);
217
+ pathGenerator.init(container);
241
218
  }
242
219
  }
243
- async push(nb, mouse, overrideOptions, group) {
220
+ push(nb, mouse, overrideOptions, group) {
244
221
  for (let i = 0; i < nb; i++) {
245
- await this.addParticle(mouse?.position, overrideOptions, group);
222
+ this.addParticle(mouse?.position, overrideOptions, group);
246
223
  }
247
224
  }
248
225
  async redraw() {
249
226
  this.clear();
250
227
  await this.init();
251
- await this.draw({ value: 0, factor: 0 });
228
+ this.draw({ value: 0, factor: 0 });
252
229
  }
253
230
  remove(particle, group, override) {
254
231
  this.removeAt(this._array.indexOf(particle), undefined, group, override);
@@ -269,12 +246,12 @@ class Particles {
269
246
  const defaultIndex = 0;
270
247
  this.removeAt(defaultIndex, quantity, group);
271
248
  }
272
- async setDensity() {
249
+ setDensity() {
273
250
  const options = this._container.actualOptions, groups = options.particles.groups, manualCount = 0;
274
251
  for (const group in groups) {
275
- await this._applyDensity(groups[group], manualCount, group);
252
+ this._applyDensity(groups[group], manualCount, group);
276
253
  }
277
- await this._applyDensity(options.particles, options.manualParticles.length);
254
+ this._applyDensity(options.particles, options.manualParticles.length);
278
255
  }
279
256
  setLastZIndex(zIndex) {
280
257
  this._lastZIndex = zIndex;
@@ -283,14 +260,14 @@ class Particles {
283
260
  setResizeFactor(factor) {
284
261
  this._resizeFactor = factor;
285
262
  }
286
- async update(delta) {
263
+ update(delta) {
287
264
  const container = this._container, particlesToDelete = new Set();
288
265
  this.quadTree = new QuadTree_js_1.QuadTree(qTreeRectangle(container.canvas.size), qTreeCapacity);
289
266
  for (const [, pathGenerator] of container.pathGenerators) {
290
267
  pathGenerator.update();
291
268
  }
292
269
  for (const [, plugin] of container.plugins) {
293
- await plugin.update?.(delta);
270
+ plugin.update?.(delta);
294
271
  }
295
272
  const resizeFactor = this._resizeFactor;
296
273
  for (const particle of this._array) {
@@ -310,7 +287,7 @@ class Particles {
310
287
  }
311
288
  for (const mover of this.movers) {
312
289
  if (mover.isEnabled(particle)) {
313
- await mover.move(particle, delta);
290
+ mover.move(particle, delta);
314
291
  }
315
292
  }
316
293
  if (particle.destroyed) {
@@ -333,13 +310,13 @@ class Particles {
333
310
  }
334
311
  this._addToPool(...particlesToDelete);
335
312
  }
336
- await this._interactionManager.externalInteract(delta);
313
+ this._interactionManager.externalInteract(delta);
337
314
  for (const particle of this._array) {
338
315
  for (const updater of this.updaters) {
339
- await updater.update(particle, delta);
316
+ updater.update(particle, delta);
340
317
  }
341
318
  if (!particle.destroyed && !particle.spawning) {
342
- await this._interactionManager.particlesInteract(particle, delta);
319
+ this._interactionManager.particlesInteract(particle, delta);
343
320
  }
344
321
  }
345
322
  delete this._resizeFactor;
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventListeners = void 0;
4
4
  const Utils_js_1 = require("../../Utils/Utils.js");
5
5
  const Constants_js_1 = require("./Constants.js");
6
+ const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
6
7
  const double = 2;
7
8
  function manageListener(element, event, handler, add, options) {
8
9
  if (add) {
9
10
  let addOptions = { passive: true };
10
- if ((0, Utils_js_1.isBoolean)(options)) {
11
+ if ((0, TypeUtils_js_1.isBoolean)(options)) {
11
12
  addOptions.capture = options;
12
13
  }
13
14
  else if (options !== undefined) {
@@ -59,10 +60,10 @@ class EventListeners {
59
60
  else {
60
61
  container.pageHidden = false;
61
62
  if (container.animationStatus) {
62
- container.play(true);
63
+ void container.play(true);
63
64
  }
64
65
  else {
65
- container.draw(true);
66
+ void container.draw(true);
66
67
  }
67
68
  }
68
69
  };
@@ -9,10 +9,10 @@ class InteractionManager {
9
9
  this._externalInteractors = [];
10
10
  this._particleInteractors = [];
11
11
  }
12
- async externalInteract(delta) {
12
+ externalInteract(delta) {
13
13
  for (const interactor of this._externalInteractors) {
14
14
  if (interactor.isEnabled()) {
15
- await interactor.interact(delta);
15
+ interactor.interact(delta);
16
16
  }
17
17
  }
18
18
  }
@@ -37,13 +37,13 @@ class InteractionManager {
37
37
  interactor.init();
38
38
  }
39
39
  }
40
- async particlesInteract(particle, delta) {
40
+ particlesInteract(particle, delta) {
41
41
  for (const interactor of this._externalInteractors) {
42
42
  interactor.clear(particle, delta);
43
43
  }
44
44
  for (const interactor of this._particleInteractors) {
45
45
  if (interactor.isEnabled(particle)) {
46
- await interactor.interact(particle, delta);
46
+ interactor.interact(particle, delta);
47
47
  }
48
48
  }
49
49
  }
@@ -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 });
@@ -28,7 +28,7 @@ function clear(context, dimension) {
28
28
  context.clearRect(origin.x, origin.y, dimension.width, dimension.height);
29
29
  }
30
30
  exports.clear = clear;
31
- async function drawParticle(data) {
31
+ function drawParticle(data) {
32
32
  const { container, context, particle, delta, colorStyles, backgroundMask, composite, radius, opacity, shadow, transform, } = data, pos = particle.getPosition(), defaultAngle = 0, angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : defaultAngle), rotateData = {
33
33
  sin: Math.sin(angle),
34
34
  cos: Math.cos(angle),
@@ -67,14 +67,14 @@ async function drawParticle(data) {
67
67
  transformData,
68
68
  strokeWidth,
69
69
  };
70
- await drawShape(drawData);
71
- await drawShapeAfterDraw(drawData);
72
- await drawEffect(drawData);
70
+ drawShape(drawData);
71
+ drawShapeAfterDraw(drawData);
72
+ drawEffect(drawData);
73
73
  context.globalCompositeOperation = "source-over";
74
74
  context.resetTransform();
75
75
  }
76
76
  exports.drawParticle = drawParticle;
77
- async function drawEffect(data) {
77
+ function drawEffect(data) {
78
78
  const { container, context, particle, radius, opacity, delta, transformData } = data;
79
79
  if (!particle.effect) {
80
80
  return;
@@ -83,7 +83,7 @@ async function drawEffect(data) {
83
83
  if (!drawer) {
84
84
  return;
85
85
  }
86
- await drawer.draw({
86
+ drawer.draw({
87
87
  context,
88
88
  particle,
89
89
  radius,
@@ -94,7 +94,7 @@ async function drawEffect(data) {
94
94
  });
95
95
  }
96
96
  exports.drawEffect = drawEffect;
97
- async function drawShape(data) {
97
+ function drawShape(data) {
98
98
  const { container, context, particle, radius, opacity, delta, strokeWidth, transformData } = data, minStrokeWidth = 0;
99
99
  if (!particle.shape) {
100
100
  return;
@@ -104,7 +104,7 @@ async function drawShape(data) {
104
104
  return;
105
105
  }
106
106
  context.beginPath();
107
- await drawer.draw({
107
+ drawer.draw({
108
108
  context,
109
109
  particle,
110
110
  radius,
@@ -124,7 +124,7 @@ async function drawShape(data) {
124
124
  }
125
125
  }
126
126
  exports.drawShape = drawShape;
127
- async function drawShapeAfterDraw(data) {
127
+ function drawShapeAfterDraw(data) {
128
128
  const { container, context, particle, radius, opacity, delta, transformData } = data;
129
129
  if (!particle.shape) {
130
130
  return;
@@ -133,7 +133,7 @@ async function drawShapeAfterDraw(data) {
133
133
  if (!drawer?.afterDraw) {
134
134
  return;
135
135
  }
136
- await drawer.afterDraw({
136
+ drawer.afterDraw({
137
137
  context,
138
138
  particle,
139
139
  radius,
@@ -144,18 +144,18 @@ async function drawShapeAfterDraw(data) {
144
144
  });
145
145
  }
146
146
  exports.drawShapeAfterDraw = drawShapeAfterDraw;
147
- async function drawPlugin(context, plugin, delta) {
147
+ function drawPlugin(context, plugin, delta) {
148
148
  if (!plugin.draw) {
149
149
  return;
150
150
  }
151
- await plugin.draw(context, delta);
151
+ plugin.draw(context, delta);
152
152
  }
153
153
  exports.drawPlugin = drawPlugin;
154
- async function drawParticlePlugin(context, plugin, particle, delta) {
154
+ function drawParticlePlugin(context, plugin, particle, delta) {
155
155
  if (!plugin.drawParticle) {
156
156
  return;
157
157
  }
158
- await plugin.drawParticle(context, particle, delta);
158
+ plugin.drawParticle(context, particle, delta);
159
159
  }
160
160
  exports.drawParticlePlugin = drawParticlePlugin;
161
161
  function alterHsl(color, type, value) {