@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,8 +1,9 @@
1
1
  import { getLogger, getPosition } from "../Utils/Utils.js";
2
2
  import { InteractionManager } from "./Utils/InteractionManager.js";
3
+ import { Particle } from "./Particle.js";
3
4
  import { Point } from "./Utils/Point.js";
4
5
  import { QuadTree } from "./Utils/QuadTree.js";
5
- import { Rectangle } from "./Utils/Rectangle.js";
6
+ import { Rectangle } from "./Utils/Ranges.js";
6
7
  import { errorPrefix } from "./Utils/Constants.js";
7
8
  const qTreeCapacity = 4, squareExp = 2, defaultRemoveQuantity = 1;
8
9
  const qTreeRectangle = (canvasSize) => {
@@ -16,7 +17,7 @@ export class Particles {
16
17
  this._pool.push(particle);
17
18
  }
18
19
  };
19
- this._applyDensity = async (options, manualCount, group) => {
20
+ this._applyDensity = (options, manualCount, group) => {
20
21
  const numberOptions = options.number;
21
22
  if (!options.number.density?.enable) {
22
23
  if (group === undefined) {
@@ -35,7 +36,7 @@ export class Particles {
35
36
  this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
36
37
  }
37
38
  if (particlesCount < particlesNumber) {
38
- await this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
39
+ this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
39
40
  }
40
41
  else if (particlesCount > particlesNumber) {
41
42
  this.removeQuantity(particlesCount - particlesNumber, group);
@@ -49,14 +50,13 @@ export class Particles {
49
50
  const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
50
51
  return (canvas.width * canvas.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp);
51
52
  };
52
- this._pushParticle = async (position, overrideOptions, group, initializer) => {
53
+ this._pushParticle = (position, overrideOptions, group, initializer) => {
53
54
  try {
54
55
  let particle = this._pool.pop();
55
56
  if (!particle) {
56
- const { Particle } = await import("./Particle.js");
57
57
  particle = new Particle(this._engine, this._container);
58
58
  }
59
- await particle.init(this._nextId, position, overrideOptions, group);
59
+ particle.init(this._nextId, position, overrideOptions, group);
60
60
  let canAdd = true;
61
61
  if (initializer) {
62
62
  canAdd = initializer(particle);
@@ -117,13 +117,13 @@ export class Particles {
117
117
  get count() {
118
118
  return this._array.length;
119
119
  }
120
- async addManualParticles() {
120
+ addManualParticles() {
121
121
  const container = this._container, options = container.actualOptions;
122
122
  for (const particle of options.manualParticles) {
123
- await this.addParticle(particle.position ? getPosition(particle.position, container.canvas.size) : undefined, particle.options);
123
+ this.addParticle(particle.position ? getPosition(particle.position, container.canvas.size) : undefined, particle.options);
124
124
  }
125
125
  }
126
- async addParticle(position, overrideOptions, group, initializer) {
126
+ addParticle(position, overrideOptions, group, initializer) {
127
127
  const limitOptions = this._container.actualOptions.particles.number.limit, limit = group === undefined ? this._limit : this._groupLimits.get(group) ?? this._limit, currentCount = this.count, minLimit = 0;
128
128
  if (limit > minLimit) {
129
129
  if (limitOptions.mode === "delete") {
@@ -138,7 +138,7 @@ export class Particles {
138
138
  }
139
139
  }
140
140
  }
141
- return await this._pushParticle(position, overrideOptions, group, initializer);
141
+ return this._pushParticle(position, overrideOptions, group, initializer);
142
142
  }
143
143
  clear() {
144
144
  this._array = [];
@@ -151,15 +151,15 @@ export class Particles {
151
151
  this.movers = [];
152
152
  this.updaters = [];
153
153
  }
154
- async draw(delta) {
154
+ draw(delta) {
155
155
  const container = this._container, canvas = container.canvas;
156
156
  canvas.clear();
157
- await this.update(delta);
157
+ this.update(delta);
158
158
  for (const [, plugin] of container.plugins) {
159
- await canvas.drawPlugin(plugin, delta);
159
+ canvas.drawPlugin(plugin, delta);
160
160
  }
161
161
  for (const p of this._zArray) {
162
- await p.draw(delta);
162
+ p.draw(delta);
163
163
  }
164
164
  }
165
165
  filter(condition) {
@@ -188,17 +188,17 @@ export class Particles {
188
188
  break;
189
189
  }
190
190
  }
191
- await this.addManualParticles();
191
+ this.addManualParticles();
192
192
  if (!handled) {
193
193
  const particlesOptions = options.particles, groups = particlesOptions.groups;
194
194
  for (const group in groups) {
195
195
  const groupOptions = groups[group];
196
196
  for (let i = this.count, j = 0; j < groupOptions.number?.value && i < particlesOptions.number.value; i++, j++) {
197
- await this.addParticle(undefined, groupOptions, group);
197
+ this.addParticle(undefined, groupOptions, group);
198
198
  }
199
199
  }
200
200
  for (let i = this.count; i < particlesOptions.number.value; i++) {
201
- await this.addParticle();
201
+ this.addParticle();
202
202
  }
203
203
  }
204
204
  }
@@ -211,18 +211,18 @@ export class Particles {
211
211
  this.updaters = await this._engine.getUpdaters(container, true);
212
212
  await this._interactionManager.init();
213
213
  for (const [, pathGenerator] of container.pathGenerators) {
214
- await pathGenerator.init(container);
214
+ pathGenerator.init(container);
215
215
  }
216
216
  }
217
- async push(nb, mouse, overrideOptions, group) {
217
+ push(nb, mouse, overrideOptions, group) {
218
218
  for (let i = 0; i < nb; i++) {
219
- await this.addParticle(mouse?.position, overrideOptions, group);
219
+ this.addParticle(mouse?.position, overrideOptions, group);
220
220
  }
221
221
  }
222
222
  async redraw() {
223
223
  this.clear();
224
224
  await this.init();
225
- await this.draw({ value: 0, factor: 0 });
225
+ this.draw({ value: 0, factor: 0 });
226
226
  }
227
227
  remove(particle, group, override) {
228
228
  this.removeAt(this._array.indexOf(particle), undefined, group, override);
@@ -243,12 +243,12 @@ export class Particles {
243
243
  const defaultIndex = 0;
244
244
  this.removeAt(defaultIndex, quantity, group);
245
245
  }
246
- async setDensity() {
246
+ setDensity() {
247
247
  const options = this._container.actualOptions, groups = options.particles.groups, manualCount = 0;
248
248
  for (const group in groups) {
249
- await this._applyDensity(groups[group], manualCount, group);
249
+ this._applyDensity(groups[group], manualCount, group);
250
250
  }
251
- await this._applyDensity(options.particles, options.manualParticles.length);
251
+ this._applyDensity(options.particles, options.manualParticles.length);
252
252
  }
253
253
  setLastZIndex(zIndex) {
254
254
  this._lastZIndex = zIndex;
@@ -257,14 +257,14 @@ export class Particles {
257
257
  setResizeFactor(factor) {
258
258
  this._resizeFactor = factor;
259
259
  }
260
- async update(delta) {
260
+ update(delta) {
261
261
  const container = this._container, particlesToDelete = new Set();
262
262
  this.quadTree = new QuadTree(qTreeRectangle(container.canvas.size), qTreeCapacity);
263
263
  for (const [, pathGenerator] of container.pathGenerators) {
264
264
  pathGenerator.update();
265
265
  }
266
266
  for (const [, plugin] of container.plugins) {
267
- await plugin.update?.(delta);
267
+ plugin.update?.(delta);
268
268
  }
269
269
  const resizeFactor = this._resizeFactor;
270
270
  for (const particle of this._array) {
@@ -284,7 +284,7 @@ export class Particles {
284
284
  }
285
285
  for (const mover of this.movers) {
286
286
  if (mover.isEnabled(particle)) {
287
- await mover.move(particle, delta);
287
+ mover.move(particle, delta);
288
288
  }
289
289
  }
290
290
  if (particle.destroyed) {
@@ -307,13 +307,13 @@ export class Particles {
307
307
  }
308
308
  this._addToPool(...particlesToDelete);
309
309
  }
310
- await this._interactionManager.externalInteract(delta);
310
+ this._interactionManager.externalInteract(delta);
311
311
  for (const particle of this._array) {
312
312
  for (const updater of this.updaters) {
313
- await updater.update(particle, delta);
313
+ updater.update(particle, delta);
314
314
  }
315
315
  if (!particle.destroyed && !particle.spawning) {
316
- await this._interactionManager.particlesInteract(particle, delta);
316
+ this._interactionManager.particlesInteract(particle, delta);
317
317
  }
318
318
  }
319
319
  delete this._resizeFactor;
@@ -1,5 +1,6 @@
1
- import { executeOnSingleOrMultiple, isBoolean, safeMatchMedia } from "../../Utils/Utils.js";
1
+ import { executeOnSingleOrMultiple, safeMatchMedia } from "../../Utils/Utils.js";
2
2
  import { millisecondsToSeconds, mouseDownEvent, mouseLeaveEvent, mouseMoveEvent, mouseOutEvent, mouseUpEvent, resizeEvent, touchCancelEvent, touchEndEvent, touchMoveEvent, touchStartEvent, visibilityChangeEvent, } from "./Constants.js";
3
+ import { isBoolean } from "../../Utils/TypeUtils.js";
3
4
  const double = 2;
4
5
  function manageListener(element, event, handler, add, options) {
5
6
  if (add) {
@@ -56,10 +57,10 @@ export class EventListeners {
56
57
  else {
57
58
  container.pageHidden = false;
58
59
  if (container.animationStatus) {
59
- container.play(true);
60
+ void container.play(true);
60
61
  }
61
62
  else {
62
- container.draw(true);
63
+ void container.draw(true);
63
64
  }
64
65
  }
65
66
  };
@@ -6,10 +6,10 @@ export class InteractionManager {
6
6
  this._externalInteractors = [];
7
7
  this._particleInteractors = [];
8
8
  }
9
- async externalInteract(delta) {
9
+ externalInteract(delta) {
10
10
  for (const interactor of this._externalInteractors) {
11
11
  if (interactor.isEnabled()) {
12
- await interactor.interact(delta);
12
+ interactor.interact(delta);
13
13
  }
14
14
  }
15
15
  }
@@ -34,13 +34,13 @@ export class InteractionManager {
34
34
  interactor.init();
35
35
  }
36
36
  }
37
- async particlesInteract(particle, delta) {
37
+ particlesInteract(particle, delta) {
38
38
  for (const interactor of this._externalInteractors) {
39
39
  interactor.clear(particle, delta);
40
40
  }
41
41
  for (const interactor of this._particleInteractors) {
42
42
  if (interactor.isEnabled(particle)) {
43
- await interactor.interact(particle, delta);
43
+ interactor.interact(particle, delta);
44
44
  }
45
45
  }
46
46
  }
@@ -1,5 +1,4 @@
1
- import { Circle } from "./Circle.js";
2
- import { Rectangle } from "./Rectangle.js";
1
+ import { Circle, Rectangle } from "./Ranges.js";
3
2
  import { getDistance } from "../../Utils/NumberUtils.js";
4
3
  const half = 0.5, double = 2, subdivideCount = 4;
5
4
  export class QuadTree {
@@ -31,8 +30,8 @@ export class QuadTree {
31
30
  }
32
31
  return this._subs.some((sub) => sub.insert(point));
33
32
  }
34
- query(range, check, found) {
35
- const res = found ?? [];
33
+ query(range, check) {
34
+ const res = [];
36
35
  if (!range.intersects(this.rectangle)) {
37
36
  return [];
38
37
  }
@@ -46,7 +45,7 @@ export class QuadTree {
46
45
  }
47
46
  if (this._divided) {
48
47
  for (const sub of this._subs) {
49
- sub.query(range, check, res);
48
+ res.push(...sub.query(range, check));
50
49
  }
51
50
  }
52
51
  return res;
@@ -0,0 +1,55 @@
1
+ import { getDistance } from "../../Utils/NumberUtils.js";
2
+ const squareExp = 2;
3
+ export class BaseRange {
4
+ constructor(x, y, type) {
5
+ this.position = {
6
+ x: x,
7
+ y: y,
8
+ };
9
+ this.type = type;
10
+ }
11
+ }
12
+ export class Circle extends BaseRange {
13
+ constructor(x, y, radius) {
14
+ super(x, y, "circle");
15
+ this.radius = radius;
16
+ }
17
+ contains(point) {
18
+ return getDistance(point, this.position) <= this.radius;
19
+ }
20
+ intersects(range) {
21
+ 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;
22
+ if (range instanceof Circle || range.type === "circle") {
23
+ const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
24
+ return rSum > dist;
25
+ }
26
+ else if (range instanceof Rectangle || range.type === "rectangle") {
27
+ const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
28
+ return (edges <= r ** squareExp ||
29
+ (distPos.x <= r + width && distPos.y <= r + height) ||
30
+ distPos.x <= width ||
31
+ distPos.y <= height);
32
+ }
33
+ return false;
34
+ }
35
+ }
36
+ export class Rectangle extends BaseRange {
37
+ constructor(x, y, width, height) {
38
+ super(x, y, "rectangle");
39
+ this.size = {
40
+ height: height,
41
+ width: width,
42
+ };
43
+ }
44
+ contains(point) {
45
+ const w = this.size.width, h = this.size.height, pos = this.position;
46
+ return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
47
+ }
48
+ intersects(range) {
49
+ if (range instanceof Circle) {
50
+ return range.intersects(this);
51
+ }
52
+ 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;
53
+ return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
54
+ }
55
+ }
@@ -1,5 +1,5 @@
1
1
  import { errorPrefix } from "./Constants.js";
2
- import { isNumber } from "../../Utils/Utils.js";
2
+ import { isNumber } from "../../Utils/TypeUtils.js";
3
3
  const origin = {
4
4
  x: 0,
5
5
  y: 0,
@@ -107,3 +107,17 @@ export class Vector3d {
107
107
  this.z -= v.z;
108
108
  }
109
109
  }
110
+ export class Vector extends Vector3d {
111
+ constructor(xOrCoords, y) {
112
+ super(xOrCoords, y, origin.z);
113
+ }
114
+ static get origin() {
115
+ return Vector.create(origin.x, origin.y);
116
+ }
117
+ static clone(source) {
118
+ return Vector.create(source.x, source.y);
119
+ }
120
+ static create(x, y) {
121
+ return new Vector(x, y);
122
+ }
123
+ }
@@ -1,4 +1,4 @@
1
- import { isArray, isString } from "../../Utils/Utils.js";
1
+ import { isArray, isString } from "../../Utils/TypeUtils.js";
2
2
  import { HslAnimation } from "./HslAnimation.js";
3
3
  import { OptionsColor } from "./OptionsColor.js";
4
4
  export class AnimatableColor extends OptionsColor {
@@ -1,5 +1,5 @@
1
1
  import { BackgroundMaskCover } from "./BackgroundMaskCover.js";
2
- import { isString } from "../../../Utils/Utils.js";
2
+ import { isString } from "../../../Utils/TypeUtils.js";
3
3
  export class BackgroundMask {
4
4
  constructor() {
5
5
  this.composite = "destination-out";
@@ -1,4 +1,4 @@
1
- import { deepExtend, executeOnSingleOrMultiple, isBoolean, safeMatchMedia } from "../../Utils/Utils.js";
1
+ import { deepExtend, executeOnSingleOrMultiple, safeMatchMedia } from "../../Utils/Utils.js";
2
2
  import { Background } from "./Background/Background.js";
3
3
  import { BackgroundMask } from "./BackgroundMask/BackgroundMask.js";
4
4
  import { FullScreen } from "./FullScreen/FullScreen.js";
@@ -6,6 +6,7 @@ import { Interactivity } from "./Interactivity/Interactivity.js";
6
6
  import { ManualParticle } from "./ManualParticle.js";
7
7
  import { Responsive } from "./Responsive.js";
8
8
  import { Theme } from "./Theme/Theme.js";
9
+ import { isBoolean } from "../../Utils/TypeUtils.js";
9
10
  import { loadParticlesOptions } from "../../Utils/OptionsUtils.js";
10
11
  import { setRangeValue } from "../../Utils/NumberUtils.js";
11
12
  export class Options {
@@ -1,4 +1,4 @@
1
- import { isArray, isString } from "../../Utils/Utils.js";
1
+ import { isArray, isString } from "../../Utils/TypeUtils.js";
2
2
  export class OptionsColor {
3
3
  constructor() {
4
4
  this.value = "";
@@ -1,4 +1,4 @@
1
- import { isNumber, isObject } from "../../../../Utils/Utils.js";
1
+ import { isNumber, isObject } from "../../../../Utils/TypeUtils.js";
2
2
  import { MoveAngle } from "./MoveAngle.js";
3
3
  import { MoveAttract } from "./MoveAttract.js";
4
4
  import { MoveCenter } from "./MoveCenter.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -21,7 +21,7 @@ export function paintImage(context, dimension, image, opacity) {
21
21
  export function clear(context, dimension) {
22
22
  context.clearRect(origin.x, origin.y, dimension.width, dimension.height);
23
23
  }
24
- export async function drawParticle(data) {
24
+ export function drawParticle(data) {
25
25
  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 = {
26
26
  sin: Math.sin(angle),
27
27
  cos: Math.cos(angle),
@@ -60,13 +60,13 @@ export async function drawParticle(data) {
60
60
  transformData,
61
61
  strokeWidth,
62
62
  };
63
- await drawShape(drawData);
64
- await drawShapeAfterDraw(drawData);
65
- await drawEffect(drawData);
63
+ drawShape(drawData);
64
+ drawShapeAfterDraw(drawData);
65
+ drawEffect(drawData);
66
66
  context.globalCompositeOperation = "source-over";
67
67
  context.resetTransform();
68
68
  }
69
- export async function drawEffect(data) {
69
+ export function drawEffect(data) {
70
70
  const { container, context, particle, radius, opacity, delta, transformData } = data;
71
71
  if (!particle.effect) {
72
72
  return;
@@ -75,7 +75,7 @@ export async function drawEffect(data) {
75
75
  if (!drawer) {
76
76
  return;
77
77
  }
78
- await drawer.draw({
78
+ drawer.draw({
79
79
  context,
80
80
  particle,
81
81
  radius,
@@ -85,7 +85,7 @@ export async function drawEffect(data) {
85
85
  transformData: { ...transformData },
86
86
  });
87
87
  }
88
- export async function drawShape(data) {
88
+ export function drawShape(data) {
89
89
  const { container, context, particle, radius, opacity, delta, strokeWidth, transformData } = data, minStrokeWidth = 0;
90
90
  if (!particle.shape) {
91
91
  return;
@@ -95,7 +95,7 @@ export async function drawShape(data) {
95
95
  return;
96
96
  }
97
97
  context.beginPath();
98
- await drawer.draw({
98
+ drawer.draw({
99
99
  context,
100
100
  particle,
101
101
  radius,
@@ -114,7 +114,7 @@ export async function drawShape(data) {
114
114
  context.fill();
115
115
  }
116
116
  }
117
- export async function drawShapeAfterDraw(data) {
117
+ export function drawShapeAfterDraw(data) {
118
118
  const { container, context, particle, radius, opacity, delta, transformData } = data;
119
119
  if (!particle.shape) {
120
120
  return;
@@ -123,7 +123,7 @@ export async function drawShapeAfterDraw(data) {
123
123
  if (!drawer?.afterDraw) {
124
124
  return;
125
125
  }
126
- await drawer.afterDraw({
126
+ drawer.afterDraw({
127
127
  context,
128
128
  particle,
129
129
  radius,
@@ -133,17 +133,17 @@ export async function drawShapeAfterDraw(data) {
133
133
  transformData: { ...transformData },
134
134
  });
135
135
  }
136
- export async function drawPlugin(context, plugin, delta) {
136
+ export function drawPlugin(context, plugin, delta) {
137
137
  if (!plugin.draw) {
138
138
  return;
139
139
  }
140
- await plugin.draw(context, delta);
140
+ plugin.draw(context, delta);
141
141
  }
142
- export async function drawParticlePlugin(context, plugin, particle, delta) {
142
+ export function drawParticlePlugin(context, plugin, particle, delta) {
143
143
  if (!plugin.drawParticle) {
144
144
  return;
145
145
  }
146
- await plugin.drawParticle(context, particle, delta);
146
+ plugin.drawParticle(context, particle, delta);
147
147
  }
148
148
  export function alterHsl(color, type, value) {
149
149
  const lFactor = 1;
@@ -1,6 +1,7 @@
1
1
  import { clamp, getRandom, getRangeMax, getRangeMin, getRangeValue, mix, randomInRange, setRangeValue, } from "./NumberUtils.js";
2
- import { isArray, isString, itemFromArray } from "./Utils.js";
2
+ import { isArray, isString } from "./TypeUtils.js";
3
3
  import { millisecondsToSeconds, percentDenominator } from "../Core/Utils/Constants.js";
4
+ import { itemFromArray } from "./Utils.js";
4
5
  const randomColorValue = "random", midColorValue = "mid", colorManagers = new Map();
5
6
  export function addColorManager(manager) {
6
7
  colorManagers.set(manager.key, manager);
@@ -1,5 +1,5 @@
1
- import { Vector } from "../Core/Utils/Vector.js";
2
- import { isNumber } from "./Utils.js";
1
+ import { Vector } from "../Core/Utils/Vectors.js";
2
+ import { isNumber } from "./TypeUtils.js";
3
3
  import { percentDenominator } from "../Core/Utils/Constants.js";
4
4
  let _random = Math.random;
5
5
  const easings = new Map(), double = 2, doublePI = Math.PI * double;
@@ -0,0 +1,18 @@
1
+ export function isBoolean(arg) {
2
+ return typeof arg === "boolean";
3
+ }
4
+ export function isString(arg) {
5
+ return typeof arg === "string";
6
+ }
7
+ export function isNumber(arg) {
8
+ return typeof arg === "number";
9
+ }
10
+ export function isFunction(arg) {
11
+ return typeof arg === "function";
12
+ }
13
+ export function isObject(arg) {
14
+ return typeof arg === "object" && arg !== null;
15
+ }
16
+ export function isArray(arg) {
17
+ return Array.isArray(arg);
18
+ }
@@ -1,6 +1,7 @@
1
1
  import { clamp, collisionVelocity, getDistances, getRandom, getRangeMax, getRangeMin, getRangeValue, randomInRange, } from "./NumberUtils.js";
2
2
  import { halfRandom, millisecondsToSeconds, percentDenominator } from "../Core/Utils/Constants.js";
3
- import { Vector } from "../Core/Utils/Vector.js";
3
+ import { isArray, isObject } from "./TypeUtils.js";
4
+ import { Vector } from "../Core/Utils/Vectors.js";
4
5
  const _logger = {
5
6
  debug: console.debug,
6
7
  error: console.error,
@@ -332,24 +333,6 @@ export function getPosition(position, canvasSize) {
332
333
  export function getSize(size, canvasSize) {
333
334
  return getPositionOrSize(size, canvasSize);
334
335
  }
335
- export function isBoolean(arg) {
336
- return typeof arg === "boolean";
337
- }
338
- export function isString(arg) {
339
- return typeof arg === "string";
340
- }
341
- export function isNumber(arg) {
342
- return typeof arg === "number";
343
- }
344
- export function isFunction(arg) {
345
- return typeof arg === "function";
346
- }
347
- export function isObject(arg) {
348
- return typeof arg === "object" && arg !== null;
349
- }
350
- export function isArray(arg) {
351
- return Array.isArray(arg);
352
- }
353
336
  function checkDestroy(particle, destroyType, value, minValue, maxValue) {
354
337
  switch (destroyType) {
355
338
  case "max":
package/esm/exports.js CHANGED
@@ -1,12 +1,9 @@
1
- export * from "./Core/Utils/Circle.js";
2
1
  export * from "./Core/Utils/Constants.js";
3
2
  export * from "./Core/Utils/ExternalInteractorBase.js";
4
3
  export * from "./Core/Utils/ParticlesInteractorBase.js";
5
4
  export * from "./Core/Utils/Point.js";
6
- export * from "./Core/Utils/Range.js";
7
- export * from "./Core/Utils/Rectangle.js";
8
- export * from "./Core/Utils/Vector.js";
9
- export * from "./Core/Utils/Vector3d.js";
5
+ export * from "./Core/Utils/Ranges.js";
6
+ export * from "./Core/Utils/Vectors.js";
10
7
  export * from "./Enums/Directions/MoveDirection.js";
11
8
  export * from "./Enums/Directions/RotateDirection.js";
12
9
  export * from "./Enums/Directions/OutModeDirection.js";
@@ -86,3 +83,4 @@ export * from "./Utils/NumberUtils.js";
86
83
  export * from "./Utils/OptionsUtils.js";
87
84
  export * from "./Utils/RgbColorManager.js";
88
85
  export * from "./Utils/Utils.js";
86
+ export * from "./Utils/TypeUtils.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/engine",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
5
5
  "homepage": "https://particles.js.org",
6
6
  "scripts": {
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/engine [31 Jan 2024 at 09:47]</title>
6
+ <title>@tsparticles/engine [27 Feb 2024 at 12:13]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>