@tsparticles/engine 4.0.0-alpha.25 → 4.0.0-alpha.26

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 (80) hide show
  1. package/622.min.js +1 -0
  2. package/README.md +2 -2
  3. package/browser/Core/Engine.js +1 -18
  4. package/browser/Core/Particle.js +2 -23
  5. package/browser/Core/Particles.js +0 -23
  6. package/browser/Core/Utils/Ranges.js +2 -2
  7. package/browser/Core/Utils/Vectors.js +10 -7
  8. package/browser/Options/Classes/Particles/Move/Move.js +0 -4
  9. package/browser/Utils/CanvasUtils.js +29 -32
  10. package/browser/Utils/MathUtils.js +8 -1
  11. package/browser/Utils/Utils.js +10 -14
  12. package/browser/exports.js +0 -1
  13. package/cjs/Core/Engine.js +1 -18
  14. package/cjs/Core/Particle.js +2 -23
  15. package/cjs/Core/Particles.js +0 -23
  16. package/cjs/Core/Utils/Ranges.js +2 -2
  17. package/cjs/Core/Utils/Vectors.js +10 -7
  18. package/cjs/Options/Classes/Particles/Move/Move.js +0 -4
  19. package/cjs/Utils/CanvasUtils.js +29 -32
  20. package/cjs/Utils/MathUtils.js +8 -1
  21. package/cjs/Utils/Utils.js +10 -14
  22. package/cjs/exports.js +0 -1
  23. package/dist_browser_Core_Container_js.js +3 -3
  24. package/esm/Core/Engine.js +1 -18
  25. package/esm/Core/Particle.js +2 -23
  26. package/esm/Core/Particles.js +0 -23
  27. package/esm/Core/Utils/Ranges.js +2 -2
  28. package/esm/Core/Utils/Vectors.js +10 -7
  29. package/esm/Options/Classes/Particles/Move/Move.js +0 -4
  30. package/esm/Utils/CanvasUtils.js +29 -32
  31. package/esm/Utils/MathUtils.js +8 -1
  32. package/esm/Utils/Utils.js +10 -14
  33. package/esm/exports.js +0 -1
  34. package/package.json +1 -1
  35. package/report.html +1 -1
  36. package/scripts/install.js +2 -2
  37. package/tsparticles.engine.js +10 -20
  38. package/tsparticles.engine.min.js +2 -2
  39. package/types/Core/Engine.d.ts +1 -9
  40. package/types/Core/Particle.d.ts +0 -4
  41. package/types/Core/Particles.d.ts +0 -5
  42. package/types/Core/Utils/Vectors.d.ts +6 -6
  43. package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
  44. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
  45. package/types/Types/EngineInitializers.d.ts +0 -6
  46. package/types/Utils/CanvasUtils.d.ts +6 -7
  47. package/types/Utils/MathUtils.d.ts +2 -0
  48. package/types/export-types.d.ts +0 -3
  49. package/types/exports.d.ts +0 -1
  50. package/umd/Core/Engine.js +1 -18
  51. package/umd/Core/Particle.js +3 -24
  52. package/umd/Core/Particles.js +0 -23
  53. package/umd/Core/Utils/Ranges.js +1 -1
  54. package/umd/Core/Utils/Vectors.js +10 -7
  55. package/umd/Options/Classes/Particles/Move/Move.js +1 -5
  56. package/umd/Utils/CanvasUtils.js +29 -32
  57. package/umd/Utils/MathUtils.js +10 -1
  58. package/umd/Utils/Utils.js +10 -14
  59. package/umd/exports.js +1 -2
  60. package/152.min.js +0 -1
  61. package/browser/Core/Interfaces/IMovePathGenerator.js +0 -1
  62. package/browser/Core/Interfaces/IParticleMover.js +0 -1
  63. package/browser/Options/Classes/Particles/Move/MoveAttract.js +0 -36
  64. package/browser/Options/Interfaces/Particles/Move/IMoveAttract.js +0 -1
  65. package/cjs/Core/Interfaces/IMovePathGenerator.js +0 -1
  66. package/cjs/Core/Interfaces/IParticleMover.js +0 -1
  67. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +0 -36
  68. package/cjs/Options/Interfaces/Particles/Move/IMoveAttract.js +0 -1
  69. package/esm/Core/Interfaces/IMovePathGenerator.js +0 -1
  70. package/esm/Core/Interfaces/IParticleMover.js +0 -1
  71. package/esm/Options/Classes/Particles/Move/MoveAttract.js +0 -36
  72. package/esm/Options/Interfaces/Particles/Move/IMoveAttract.js +0 -1
  73. package/types/Core/Interfaces/IMovePathGenerator.d.ts +0 -9
  74. package/types/Core/Interfaces/IParticleMover.d.ts +0 -7
  75. package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -12
  76. package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -7
  77. package/umd/Core/Interfaces/IMovePathGenerator.js +0 -12
  78. package/umd/Core/Interfaces/IParticleMover.js +0 -12
  79. package/umd/Options/Classes/Particles/Move/MoveAttract.js +0 -50
  80. package/umd/Options/Interfaces/Particles/Move/IMoveAttract.js +0 -12
@@ -4,7 +4,7 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Utils/Vectors.js", "../Utils/ColorUtils.js", "../Utils/MathUtils.js", "./Utils/Constants.js", "../Utils/Utils.js", "../Enums/Types/EventType.js", "../Enums/Directions/MoveDirection.js", "../Enums/Modes/OutMode.js", "../Enums/Types/ParticleOutType.js", "../Utils/OptionsUtils.js"], factory);
7
+ define(["require", "exports", "./Utils/Vectors.js", "../Utils/ColorUtils.js", "../Utils/MathUtils.js", "../Utils/Utils.js", "./Utils/Constants.js", "../Enums/Types/EventType.js", "../Enums/Directions/MoveDirection.js", "../Enums/Modes/OutMode.js", "../Enums/Types/ParticleOutType.js", "../Utils/OptionsUtils.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -13,8 +13,8 @@
13
13
  const Vectors_js_1 = require("./Utils/Vectors.js");
14
14
  const ColorUtils_js_1 = require("../Utils/ColorUtils.js");
15
15
  const MathUtils_js_1 = require("../Utils/MathUtils.js");
16
- const Constants_js_1 = require("./Utils/Constants.js");
17
16
  const Utils_js_1 = require("../Utils/Utils.js");
17
+ const Constants_js_1 = require("./Utils/Constants.js");
18
18
  const EventType_js_1 = require("../Enums/Types/EventType.js");
19
19
  const MoveDirection_js_1 = require("../Enums/Directions/MoveDirection.js");
20
20
  const OutMode_js_1 = require("../Enums/Modes/OutMode.js");
@@ -66,13 +66,10 @@
66
66
  lastPathTime;
67
67
  misplaced;
68
68
  moveCenter;
69
- moveDecay;
70
69
  offset;
71
70
  opacity;
72
71
  options;
73
72
  outType;
74
- pathDelay;
75
- pathGenerator;
76
73
  pathRotation;
77
74
  position;
78
75
  randomIndexData;
@@ -117,7 +114,7 @@
117
114
  this.destroyed = true;
118
115
  this.bubble.inRange = false;
119
116
  this.slow.inRange = false;
120
- const container = this.container, pathGenerator = this.pathGenerator, shapeDrawer = this.shape ? container.particles.shapeDrawers.get(this.shape) : undefined;
117
+ const container = this.container, shapeDrawer = this.shape ? container.particles.shapeDrawers.get(this.shape) : undefined;
121
118
  shapeDrawer?.particleDestroy?.(this);
122
119
  for (const plugin of container.particleDestroyedPlugins) {
123
120
  plugin.particleDestroyed?.(this, override);
@@ -125,7 +122,6 @@
125
122
  for (const updater of container.particles.updaters) {
126
123
  updater.particleDestroyed?.(this, override);
127
124
  }
128
- pathGenerator?.reset(this);
129
125
  this._engine.dispatchEvent(EventType_js_1.EventType.particleDestroyed, {
130
126
  container: this.container,
131
127
  data: {
@@ -247,19 +243,6 @@
247
243
  this.shapeFill = shapeData?.fill ?? particlesOptions.shape.fill;
248
244
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
249
245
  this.options = particlesOptions;
250
- const pathOptions = this.options.move.path;
251
- this.pathDelay = (0, MathUtils_js_1.getRangeValue)(pathOptions.delay.value) * Constants_js_1.millisecondsToSeconds;
252
- if (pathOptions.generator) {
253
- let pathGenerator = this.container.particles.pathGenerators.get(pathOptions.generator);
254
- if (!pathGenerator) {
255
- pathGenerator = this.container.particles.availablePathGenerators.get(pathOptions.generator);
256
- if (pathGenerator) {
257
- this.container.particles.pathGenerators.set(pathOptions.generator, pathGenerator);
258
- pathGenerator.init();
259
- }
260
- }
261
- this.pathGenerator = pathGenerator;
262
- }
263
246
  container.retina.initParticle(this);
264
247
  this.size = (0, Utils_js_1.initParticleNumericAnimationValue)(this.options.size, pxRatio);
265
248
  this.bubble = {
@@ -272,7 +255,6 @@
272
255
  this._initPosition(position);
273
256
  this.initialVelocity = this._calculateVelocity();
274
257
  this.velocity = this.initialVelocity.copy();
275
- this.moveDecay = Constants_js_1.decayOffset - (0, MathUtils_js_1.getRangeValue)(this.options.move.decay);
276
258
  const particles = container.particles;
277
259
  particles.setLastZIndex(this.position.z);
278
260
  this.zIndexFactor = this.position.z / container.zLayers;
@@ -298,9 +280,6 @@
298
280
  for (const updater of particles.updaters) {
299
281
  updater.init(this);
300
282
  }
301
- for (const mover of particles.movers) {
302
- mover.init(this);
303
- }
304
283
  effectDrawer?.particleInit?.(container, this);
305
284
  shapeDrawer?.particleInit?.(container, this);
306
285
  for (const plugin of container.particleCreatedPlugins) {
@@ -18,12 +18,9 @@
18
18
  const LogUtils_js_1 = require("../Utils/LogUtils.js");
19
19
  const OptionsUtils_js_1 = require("../Utils/OptionsUtils.js");
20
20
  class Particles {
21
- availablePathGenerators;
22
21
  checkParticlePositionPlugins;
23
22
  effectDrawers;
24
23
  grid;
25
- movers;
26
- pathGenerators;
27
24
  shapeDrawers;
28
25
  updaters;
29
26
  _array;
@@ -57,9 +54,6 @@
57
54
  this._maxZIndex = 0;
58
55
  this.grid = new SpatialHashGrid_js_1.SpatialHashGrid(Constants_js_1.spatialHashGridCellSize);
59
56
  this.effectDrawers = new Map();
60
- this.movers = [];
61
- this.availablePathGenerators = new Map();
62
- this.pathGenerators = new Map();
63
57
  this.shapeDrawers = new Map();
64
58
  this.updaters = [];
65
59
  this.checkParticlePositionPlugins = [];
@@ -135,9 +129,6 @@
135
129
  this._pool.length = 0;
136
130
  this._zArray = [];
137
131
  this.effectDrawers = new Map();
138
- this.movers = [];
139
- this.availablePathGenerators = new Map();
140
- this.pathGenerators = new Map();
141
132
  this.shapeDrawers = new Map();
142
133
  this.updaters = [];
143
134
  this.checkParticlePositionPlugins = [];
@@ -229,14 +220,8 @@
229
220
  async initPlugins() {
230
221
  const container = this._container;
231
222
  this.effectDrawers = await this._engine.getEffectDrawers(container, true);
232
- this.movers = await this._engine.getMovers(container, true);
233
- this.availablePathGenerators = await this._engine.getPathGenerators(container, true);
234
- this.pathGenerators = new Map();
235
223
  this.shapeDrawers = await this._engine.getShapeDrawers(container, true);
236
224
  this.updaters = await this._engine.getUpdaters(container, true);
237
- for (const pathGenerator of this.pathGenerators.values()) {
238
- pathGenerator.init();
239
- }
240
225
  }
241
226
  push(nb, position, overrideOptions, group) {
242
227
  for (let i = 0; i < nb; i++) {
@@ -293,9 +278,6 @@
293
278
  update(delta) {
294
279
  const particlesToDelete = new Set();
295
280
  this.grid.clear();
296
- for (const pathGenerator of this.pathGenerators.values()) {
297
- pathGenerator.update();
298
- }
299
281
  for (const plugin of this._updatePlugins) {
300
282
  plugin.update?.(delta);
301
283
  }
@@ -317,11 +299,6 @@
317
299
  }
318
300
  plugin.particleUpdate?.(particle, delta);
319
301
  }
320
- for (const mover of this.movers) {
321
- if (mover.isEnabled(particle)) {
322
- mover.move(particle, delta);
323
- }
324
- }
325
302
  if (particle.destroyed) {
326
303
  particlesToDelete.add(particle);
327
304
  continue;
@@ -32,7 +32,7 @@
32
32
  this.radius = radius;
33
33
  }
34
34
  contains(point) {
35
- return (0, MathUtils_js_1.getDistance)(point, this.position) <= this.radius;
35
+ return (0, MathUtils_js_1.checkDistance)(point, this.position, this.radius);
36
36
  }
37
37
  intersects(range) {
38
38
  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;
@@ -11,6 +11,9 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Vector = exports.Vector3d = void 0;
13
13
  const Constants_js_1 = require("./Constants.js");
14
+ function getZ(source) {
15
+ return "z" in source ? source.z : Constants_js_1.originPoint.z;
16
+ }
14
17
  class Vector3d {
15
18
  x;
16
19
  y;
@@ -36,21 +39,21 @@
36
39
  this._updateFromAngle(this.angle, length);
37
40
  }
38
41
  static clone(source) {
39
- return Vector3d.create(source.x, source.y, source.z);
42
+ return Vector3d.create(source.x, source.y, getZ(source));
40
43
  }
41
44
  static create(x, y, z) {
42
45
  if (typeof x === "number") {
43
46
  return new Vector3d(x, y ?? Constants_js_1.originPoint.y, z ?? Constants_js_1.originPoint.z);
44
47
  }
45
- return new Vector3d(x.x, x.y, Object.hasOwn(x, "z") ? x.z : Constants_js_1.originPoint.z);
48
+ return new Vector3d(x.x, x.y, getZ(x));
46
49
  }
47
50
  add(v) {
48
- return Vector3d.create(this.x + v.x, this.y + v.y, this.z + v.z);
51
+ return Vector3d.create(this.x + v.x, this.y + v.y, this.z + getZ(v));
49
52
  }
50
53
  addTo(v) {
51
54
  this.x += v.x;
52
55
  this.y += v.y;
53
- this.z += v.z;
56
+ this.z += getZ(v);
54
57
  }
55
58
  copy() {
56
59
  return Vector3d.clone(this);
@@ -86,15 +89,15 @@
86
89
  setTo(c) {
87
90
  this.x = c.x;
88
91
  this.y = c.y;
89
- this.z = "z" in c ? c.z : Constants_js_1.originPoint.z;
92
+ this.z = getZ(c);
90
93
  }
91
94
  sub(v) {
92
- return Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z);
95
+ return Vector3d.create(this.x - v.x, this.y - v.y, this.z - getZ(v));
93
96
  }
94
97
  subFrom(v) {
95
98
  this.x -= v.x;
96
99
  this.y -= v.y;
97
- this.z -= v.z;
100
+ this.z -= getZ(v);
98
101
  }
99
102
  _updateFromAngle(angle, length) {
100
103
  this.x = Math.cos(angle) * length;
@@ -4,7 +4,7 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "../../../../Enums/Directions/MoveDirection.js", "../../../../Utils/TypeUtils.js", "./MoveAngle.js", "./MoveAttract.js", "./MoveCenter.js", "./MoveGravity.js", "./Path/MovePath.js", "./OutModes.js", "./Spin.js", "../../../../Utils/MathUtils.js"], factory);
7
+ define(["require", "exports", "../../../../Enums/Directions/MoveDirection.js", "../../../../Utils/TypeUtils.js", "./MoveAngle.js", "./MoveCenter.js", "./MoveGravity.js", "./Path/MovePath.js", "./OutModes.js", "./Spin.js", "../../../../Utils/MathUtils.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -13,7 +13,6 @@
13
13
  const MoveDirection_js_1 = require("../../../../Enums/Directions/MoveDirection.js");
14
14
  const TypeUtils_js_1 = require("../../../../Utils/TypeUtils.js");
15
15
  const MoveAngle_js_1 = require("./MoveAngle.js");
16
- const MoveAttract_js_1 = require("./MoveAttract.js");
17
16
  const MoveCenter_js_1 = require("./MoveCenter.js");
18
17
  const MoveGravity_js_1 = require("./MoveGravity.js");
19
18
  const MovePath_js_1 = require("./Path/MovePath.js");
@@ -22,7 +21,6 @@
22
21
  const MathUtils_js_1 = require("../../../../Utils/MathUtils.js");
23
22
  class Move {
24
23
  angle;
25
- attract;
26
24
  center;
27
25
  decay;
28
26
  direction;
@@ -41,7 +39,6 @@
41
39
  warp;
42
40
  constructor() {
43
41
  this.angle = new MoveAngle_js_1.MoveAngle();
44
- this.attract = new MoveAttract_js_1.MoveAttract();
45
42
  this.center = new MoveCenter_js_1.MoveCenter();
46
43
  this.decay = 0;
47
44
  this.distance = {};
@@ -64,7 +61,6 @@
64
61
  return;
65
62
  }
66
63
  this.angle.load((0, TypeUtils_js_1.isNumber)(data.angle) ? { value: data.angle } : data.angle);
67
- this.attract.load(data.attract);
68
64
  this.center.load(data.center);
69
65
  if (data.decay !== undefined) {
70
66
  this.decay = (0, MathUtils_js_1.setRangeValue)(data.decay);
@@ -28,15 +28,16 @@
28
28
  if (!image) {
29
29
  return;
30
30
  }
31
+ const prevAlpha = context.globalAlpha;
31
32
  context.globalAlpha = opacity;
32
33
  context.drawImage(image, Constants_js_1.originPoint.x, Constants_js_1.originPoint.y, dimension.width, dimension.height);
33
- context.globalAlpha = 1;
34
+ context.globalAlpha = prevAlpha;
34
35
  }
35
36
  function clear(context, dimension) {
36
37
  context.clearRect(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y, dimension.width, dimension.height);
37
38
  }
38
39
  function drawParticle(data) {
39
- const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = Constants_js_1.defaultZoom, drawPosition = {
40
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container.particles, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = Constants_js_1.defaultZoom, drawPosition = {
40
41
  x: pos.x,
41
42
  y: pos.y,
42
43
  };
@@ -67,42 +68,40 @@
67
68
  for (const plugin of container.plugins) {
68
69
  plugin.drawParticleTransform?.(drawData);
69
70
  }
70
- drawBeforeEffect(container, drawData);
71
- drawShapeBeforeDraw(container, drawData);
72
- drawShape(container, drawData);
73
- drawShapeAfterDraw(container, drawData);
74
- drawAfterEffect(container, drawData);
71
+ const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
72
+ drawBeforeEffect(effect, drawData);
73
+ drawShapeBeforeDraw(shape, drawData);
74
+ drawShape(shape, drawData);
75
+ drawShapeAfterDraw(shape, drawData);
76
+ drawAfterEffect(effect, drawData);
75
77
  context.resetTransform();
76
78
  }
77
- function drawAfterEffect(container, data) {
79
+ function drawAfterEffect(drawer, data) {
80
+ if (!drawer?.drawAfter) {
81
+ return;
82
+ }
78
83
  const { particle } = data;
79
84
  if (!particle.effect) {
80
85
  return;
81
86
  }
82
- const drawer = container.particles.effectDrawers.get(particle.effect), drawFunc = drawer?.drawAfter;
83
- if (!drawFunc) {
87
+ drawer.drawAfter(data);
88
+ }
89
+ function drawBeforeEffect(drawer, data) {
90
+ if (!drawer?.drawBefore) {
84
91
  return;
85
92
  }
86
- drawFunc(data);
87
- }
88
- function drawBeforeEffect(container, data) {
89
93
  const { particle } = data;
90
94
  if (!particle.effect) {
91
95
  return;
92
96
  }
93
- const drawer = container.particles.effectDrawers.get(particle.effect);
94
- if (!drawer?.drawBefore) {
95
- return;
96
- }
97
97
  drawer.drawBefore(data);
98
98
  }
99
- function drawShape(container, data) {
100
- const { context, particle, stroke } = data;
101
- if (!particle.shape) {
99
+ function drawShape(drawer, data) {
100
+ if (!drawer) {
102
101
  return;
103
102
  }
104
- const drawer = container.particles.shapeDrawers.get(particle.shape);
105
- if (!drawer) {
103
+ const { context, particle, stroke } = data;
104
+ if (!particle.shape) {
106
105
  return;
107
106
  }
108
107
  context.beginPath();
@@ -117,26 +116,24 @@
117
116
  context.fill();
118
117
  }
119
118
  }
120
- function drawShapeAfterDraw(container, data) {
121
- const { particle } = data;
122
- if (!particle.shape) {
123
- return;
124
- }
125
- const drawer = container.particles.shapeDrawers.get(particle.shape);
119
+ function drawShapeAfterDraw(drawer, data) {
126
120
  if (!drawer?.afterDraw) {
127
121
  return;
128
122
  }
129
- drawer.afterDraw(data);
130
- }
131
- function drawShapeBeforeDraw(container, data) {
132
123
  const { particle } = data;
133
124
  if (!particle.shape) {
134
125
  return;
135
126
  }
136
- const drawer = container.particles.shapeDrawers.get(particle.shape);
127
+ drawer.afterDraw(data);
128
+ }
129
+ function drawShapeBeforeDraw(drawer, data) {
137
130
  if (!drawer?.beforeDraw) {
138
131
  return;
139
132
  }
133
+ const { particle } = data;
134
+ if (!particle.shape) {
135
+ return;
136
+ }
140
137
  drawer.beforeDraw(data);
141
138
  }
142
139
  function drawParticlePlugin(context, plugin, particle, delta) {
@@ -23,7 +23,9 @@
23
23
  exports.getRangeMax = getRangeMax;
24
24
  exports.setRangeValue = setRangeValue;
25
25
  exports.getDistances = getDistances;
26
+ exports.getDistanceSq = getDistanceSq;
26
27
  exports.getDistance = getDistance;
28
+ exports.checkDistance = checkDistance;
27
29
  exports.degToRad = degToRad;
28
30
  exports.getParticleDirectionAngle = getParticleDirectionAngle;
29
31
  exports.getParticleBaseVelocity = getParticleBaseVelocity;
@@ -105,8 +107,15 @@
105
107
  const dx = pointA.x - pointB.x, dy = pointA.y - pointB.y;
106
108
  return { dx: dx, dy: dy, distance: Math.hypot(dx, dy) };
107
109
  }
110
+ function getDistanceSq(pointA, pointB) {
111
+ const dx = pointA.x - pointB.x, dy = pointA.y - pointB.y;
112
+ return dx * dx + dy * dy;
113
+ }
108
114
  function getDistance(pointA, pointB) {
109
- return getDistances(pointA, pointB).distance;
115
+ return Math.sqrt(getDistanceSq(pointA, pointB));
116
+ }
117
+ function checkDistance(pointA, pointB, distance) {
118
+ return getDistanceSq(pointA, pointB) <= distance * distance;
110
119
  }
111
120
  function degToRad(degrees) {
112
121
  return degrees * degToRadFactor;
@@ -120,33 +120,29 @@
120
120
  }
121
121
  function deepExtend(destination, ...sources) {
122
122
  for (const source of sources) {
123
- if (source === undefined || source === null) {
123
+ if ((0, TypeUtils_js_1.isNull)(source)) {
124
124
  continue;
125
125
  }
126
126
  if (!(0, TypeUtils_js_1.isObject)(source)) {
127
127
  destination = source;
128
128
  continue;
129
129
  }
130
- const sourceIsArray = Array.isArray(source);
131
- if (sourceIsArray) {
130
+ if (Array.isArray(source)) {
132
131
  if (!Array.isArray(destination)) {
133
132
  destination = [];
134
133
  }
135
134
  }
136
- else {
137
- if (!(0, TypeUtils_js_1.isObject)(destination) || Array.isArray(destination)) {
138
- destination = {};
139
- }
135
+ else if (!(0, TypeUtils_js_1.isObject)(destination) || Array.isArray(destination)) {
136
+ destination = {};
140
137
  }
141
- for (const key in source) {
142
- if (key === "__proto__") {
138
+ for (const key of Object.keys(source)) {
139
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
143
140
  continue;
144
141
  }
145
- const sourceDict = source, value = sourceDict[key], destDict = destination;
146
- destDict[key] =
147
- (0, TypeUtils_js_1.isObject)(value) && Array.isArray(value)
148
- ? value.map(v => deepExtend(destDict[key], v))
149
- : deepExtend(destDict[key], value);
142
+ const sourceDict = source, destDict = destination, value = sourceDict[key];
143
+ destDict[key] = Array.isArray(value)
144
+ ? value.map(v => deepExtend(undefined, v))
145
+ : deepExtend(destDict[key], value);
150
146
  }
151
147
  }
152
148
  return destination;
package/umd/exports.js CHANGED
@@ -18,7 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  if (v !== undefined) module.exports = v;
19
19
  }
20
20
  else if (typeof define === "function" && define.amd) {
21
- define(["require", "exports", "./Core/Utils/Constants.js", "./Core/Utils/Ranges.js", "./Core/Utils/Vectors.js", "./Enums/Directions/MoveDirection.js", "./Enums/Directions/RotateDirection.js", "./Enums/Directions/OutModeDirection.js", "./Enums/Modes/AnimationMode.js", "./Enums/Modes/LimitMode.js", "./Enums/Modes/OutMode.js", "./Enums/Modes/PixelMode.js", "./Enums/Types/AlterType.js", "./Enums/Types/DestroyType.js", "./Enums/Types/GradientType.js", "./Enums/Types/ParticleOutType.js", "./Enums/Types/StartValueType.js", "./Enums/Types/EasingType.js", "./Enums/Types/EventType.js", "./Enums/AnimationStatus.js", "./Options/Classes/AnimatableColor.js", "./Options/Classes/AnimationOptions.js", "./Options/Classes/Background/Background.js", "./Options/Classes/ColorAnimation.js", "./Options/Classes/FullScreen/FullScreen.js", "./Options/Classes/HslAnimation.js", "./Options/Classes/Options.js", "./Options/Classes/OptionsColor.js", "./Options/Classes/Particles/Bounce/ParticlesBounce.js", "./Options/Classes/Particles/Bounce/ParticlesBounceFactor.js", "./Options/Classes/Particles/ParticlesOptions.js", "./Options/Classes/Particles/Stroke.js", "./Options/Classes/Particles/Move/MoveAttract.js", "./Options/Classes/Particles/Move/Move.js", "./Options/Classes/Particles/Move/MoveAngle.js", "./Options/Classes/Particles/Move/MoveCenter.js", "./Options/Classes/Particles/Move/MoveGravity.js", "./Options/Classes/Particles/Move/OutModes.js", "./Options/Classes/Particles/Move/Path/MovePath.js", "./Options/Classes/Particles/Move/Spin.js", "./Options/Classes/Particles/Number/ParticlesNumber.js", "./Options/Classes/Particles/Number/ParticlesNumberLimit.js", "./Options/Classes/Particles/Number/ParticlesDensity.js", "./Options/Classes/Particles/Opacity/Opacity.js", "./Options/Classes/Particles/Opacity/OpacityAnimation.js", "./Options/Classes/Particles/Shape/Shape.js", "./Options/Classes/Particles/Size/Size.js", "./Options/Classes/Particles/Size/SizeAnimation.js", "./Options/Classes/Particles/ZIndex/ZIndex.js", "./Options/Classes/ResizeEvent.js", "./Options/Classes/ValueWithRandom.js", "./Utils/CanvasUtils.js", "./Utils/ColorUtils.js", "./Utils/LogUtils.js", "./Utils/MathUtils.js", "./Utils/OptionsUtils.js", "./Utils/Utils.js", "./Utils/TypeUtils.js"], factory);
21
+ define(["require", "exports", "./Core/Utils/Constants.js", "./Core/Utils/Ranges.js", "./Core/Utils/Vectors.js", "./Enums/Directions/MoveDirection.js", "./Enums/Directions/RotateDirection.js", "./Enums/Directions/OutModeDirection.js", "./Enums/Modes/AnimationMode.js", "./Enums/Modes/LimitMode.js", "./Enums/Modes/OutMode.js", "./Enums/Modes/PixelMode.js", "./Enums/Types/AlterType.js", "./Enums/Types/DestroyType.js", "./Enums/Types/GradientType.js", "./Enums/Types/ParticleOutType.js", "./Enums/Types/StartValueType.js", "./Enums/Types/EasingType.js", "./Enums/Types/EventType.js", "./Enums/AnimationStatus.js", "./Options/Classes/AnimatableColor.js", "./Options/Classes/AnimationOptions.js", "./Options/Classes/Background/Background.js", "./Options/Classes/ColorAnimation.js", "./Options/Classes/FullScreen/FullScreen.js", "./Options/Classes/HslAnimation.js", "./Options/Classes/Options.js", "./Options/Classes/OptionsColor.js", "./Options/Classes/Particles/Bounce/ParticlesBounce.js", "./Options/Classes/Particles/Bounce/ParticlesBounceFactor.js", "./Options/Classes/Particles/ParticlesOptions.js", "./Options/Classes/Particles/Stroke.js", "./Options/Classes/Particles/Move/Move.js", "./Options/Classes/Particles/Move/MoveAngle.js", "./Options/Classes/Particles/Move/MoveCenter.js", "./Options/Classes/Particles/Move/MoveGravity.js", "./Options/Classes/Particles/Move/OutModes.js", "./Options/Classes/Particles/Move/Path/MovePath.js", "./Options/Classes/Particles/Move/Spin.js", "./Options/Classes/Particles/Number/ParticlesNumber.js", "./Options/Classes/Particles/Number/ParticlesNumberLimit.js", "./Options/Classes/Particles/Number/ParticlesDensity.js", "./Options/Classes/Particles/Opacity/Opacity.js", "./Options/Classes/Particles/Opacity/OpacityAnimation.js", "./Options/Classes/Particles/Shape/Shape.js", "./Options/Classes/Particles/Size/Size.js", "./Options/Classes/Particles/Size/SizeAnimation.js", "./Options/Classes/Particles/ZIndex/ZIndex.js", "./Options/Classes/ResizeEvent.js", "./Options/Classes/ValueWithRandom.js", "./Utils/CanvasUtils.js", "./Utils/ColorUtils.js", "./Utils/LogUtils.js", "./Utils/MathUtils.js", "./Utils/OptionsUtils.js", "./Utils/Utils.js", "./Utils/TypeUtils.js"], factory);
22
22
  }
23
23
  })(function (require, exports) {
24
24
  "use strict";
@@ -53,7 +53,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
53
53
  __exportStar(require("./Options/Classes/Particles/Bounce/ParticlesBounceFactor.js"), exports);
54
54
  __exportStar(require("./Options/Classes/Particles/ParticlesOptions.js"), exports);
55
55
  __exportStar(require("./Options/Classes/Particles/Stroke.js"), exports);
56
- __exportStar(require("./Options/Classes/Particles/Move/MoveAttract.js"), exports);
57
56
  __exportStar(require("./Options/Classes/Particles/Move/Move.js"), exports);
58
57
  __exportStar(require("./Options/Classes/Particles/Move/MoveAngle.js"), exports);
59
58
  __exportStar(require("./Options/Classes/Particles/Move/MoveCenter.js"), exports);
package/152.min.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[152],{8152(t,i,e){e.d(i,{Container:()=>R});var s=e(3251),a=e(7555),r=e(2409),n=e(5925),o=e(6706);function h(t,i,e=!1){if(!i)return;let s=t.style,a=new Set;for(let t=0;t<s.length;t++){let i=s.item(t);i&&a.add(i)}for(let t=0;t<i.length;t++){let e=i.item(t);e&&a.add(e)}for(let t of a){let a=i.getPropertyValue(t);a?s.setProperty(t,a,e?"important":""):s.removeProperty(t)}}class l{container;element;size;zoom=a.Pf;_canvasClearPlugins;_canvasPaintPlugins;_canvasSettings;_clearDrawPlugins;_colorPlugins;_context;_drawParticlePlugins;_drawParticlesCleanupPlugins;_drawParticlesSetupPlugins;_drawPlugins;_drawSettingsCleanupPlugins;_drawSettingsSetupPlugins;_engine;_generated;_mutationObserver;_originalStyle;_pointerEvents;_postDrawUpdaters;_preDrawUpdaters;_resizePlugins;_reusableColorStyles={};_reusablePluginColors=[void 0,void 0];_reusableTransform={};_standardSize;_zoomCenter;constructor(t,i){this.container=t,this._engine=i,this._standardSize={height:0,width:0};const e=t.retina.pixelRatio,s=this._standardSize;this.size={height:s.height*e,width:s.width*e},this._context=null,this._generated=!1,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this._pointerEvents="none"}get settings(){return this._canvasSettings}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}canvasClear(){this.container.actualOptions.clear&&this.draw(t=>{(0,r.IU)(t,this.size)})}clear(){let t=!1;for(let i of this._canvasClearPlugins)if(t=i.canvasClear?.()??!1)break;t||this.canvasClear()}destroy(){if(this.stop(),this._generated){let t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[]}draw(t){let i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;let e=t.getRadius();if(e<=a.w2)return;let s=t.getFillColor(),n=t.getStrokeColor()??s,[h,l]=this._getPluginParticleColors(t);if(h??=s,l??=n,!h&&!l)return;let c=this.container,d=t.options.zIndex,p=a.RV-t.zIndexFactor,{opacity:u,strokeOpacity:_}=t.getOpacity(),g=this._reusableTransform,f=this._reusableColorStyles,P=h?(0,o.LC)(h,c.hdr,u):void 0,m=l?(0,o.LC)(l,c.hdr,_):P;g.a=g.b=g.c=g.d=void 0,f.fill=P,f.stroke=m,this.draw(s=>{for(let e of this._drawParticlesSetupPlugins)e.drawParticleSetup?.(s,t,i);for(let a of(this._applyPreDrawUpdaters(s,t,e,u,f,g),(0,r.p0)({container:c,context:s,particle:t,delta:i,colorStyles:f,radius:e*p**d.sizeRate,opacity:u,transform:g}),this._applyPostDrawUpdaters(t),this._drawParticlesCleanupPlugins))a.drawParticleCleanup?.(s,t,i)})}drawParticlePlugins(t,i){this.draw(e=>{for(let s of this._drawParticlePlugins)(0,r.Wb)(e,s,t,i)})}drawParticles(t){let{particles:i}=this.container;this.clear(),i.update(t),this.draw(e=>{for(let i of this._drawSettingsSetupPlugins)i.drawSettingsSetup?.(e,t);for(let i of this._drawPlugins)i.draw?.(e,t);for(let s of(i.drawParticles(t),this._clearDrawPlugins))s.clearDraw?.(e,t);for(let i of this._drawSettingsCleanupPlugins)i.drawSettingsCleanup?.(e,t)})}getZoomCenter(){let t=this.container.retina.pixelRatio,{width:i,height:e}=this.size;return this._zoomCenter?this._zoomCenter:{x:i*a.MX/t,y:e*a.MX/t}}init(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=(0,n.tG)(t=>{for(let i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()}),this.resize(),this._initStyle(),this.initBackground(),this._safeMutationObserver(t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})}),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){let{container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;let s=e.style,a=(0,o.BN)(this._engine,i.color);a?s.backgroundColor=(0,o.xx)(a,t.hdr,i.opacity):s.backgroundColor="",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){for(let t of(this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesSetupPlugins=[],this._drawParticlesCleanupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this.container.plugins))t.resize&&this._resizePlugins.push(t),(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t),t.canvasClear&&this._canvasClearPlugins.push(t),t.canvasPaint&&this._canvasPaintPlugins.push(t),t.drawParticle&&this._drawParticlePlugins.push(t),t.drawParticleSetup&&this._drawParticlesSetupPlugins.push(t),t.drawParticleCleanup&&this._drawParticlesCleanupPlugins.push(t),t.draw&&this._drawPlugins.push(t),t.drawSettingsSetup&&this._drawSettingsSetupPlugins.push(t),t.drawSettingsCleanup&&this._drawSettingsCleanupPlugins.push(t),t.clearDraw&&this._clearDrawPlugins.push(t)}initUpdaters(){for(let t of(this._preDrawUpdaters=[],this._postDrawUpdaters=[],this.container.particles.updaters))t.afterDraw&&this._postDrawUpdaters.push(t),(t.getColorStyles??t.getTransformValues??t.beforeDraw)&&this._preDrawUpdaters.push(t)}loadCanvas(t){this._generated&&this.element&&this.element.remove();let i=this.container;this._generated=a.eb in t.dataset?"true"===t.dataset[a.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,n.td)(this.element.style);let e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;let s=this.container.retina.pixelRatio,r=this.size;t.height=r.height=e.height*s,t.width=r.width=e.width*s;let o=(0,n.lV)("(color-gamut: p3)");this._canvasSettings={alpha:!0,colorSpace:o?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1},this._context=this.element.getContext("2d",this._canvasSettings),this._safeMutationObserver(t=>{t.disconnect()}),i.retina.init(),this.initBackground(),this._safeMutationObserver(t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})})}paint(){let t=!1;for(let i of this._canvasPaintPlugins)if(t=i.canvasPaint?.()??!1)break;t||this.paintBase()}paintBase(t){this.draw(i=>{(0,r.Sn)(i,this.size,t)})}paintImage(t,i){this.draw(e=>{(0,r.Md)(e,this.size,t,i)})}resize(){if(!this.element)return!1;let t=this.container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,a={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&a.height===this.element.height&&a.width===this.element.width)return!1;let r={...i};i.height=e.height,i.width=e.width;let n=this.size;return this.element.width=n.width=a.width,this.element.height=n.height=a.height,this.container.started&&t.particles.setResizeFactor({width:i.width/r.width,height:i.height/r.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}setZoom(t,i){this.zoom=t,this._zoomCenter=i}stop(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=void 0,this.draw(t=>{(0,r.IU)(t,this.size)})}async windowResize(){if(!this.element||!this.resize())return;let t=this.container,i=t.updateActualOptions();t.particles.setDensity(),this._applyResizePlugins(),i&&await t.refresh()}_applyPostDrawUpdaters=t=>{for(let i of this._postDrawUpdaters)i.afterDraw?.(t)};_applyPreDrawUpdaters=(t,i,e,s,r,n)=>{for(let o of this._preDrawUpdaters){if(o.getColorStyles){let{fill:a,stroke:n}=o.getColorStyles(i,t,e,s);a&&(r.fill=a),n&&(r.stroke=n)}if(o.getTransformValues){let t=o.getTransformValues(i);for(let i in t)!function(t,i,e){let s=i[e];void 0!==s&&(t[e]=(t[e]??a.zs)*s)}(n,t,i)}o.beforeDraw?.(i)}};_applyResizePlugins=()=>{for(let t of this._resizePlugins)t.resize?.()};_getPluginParticleColors=t=>{let i,e;for(let s of this._colorPlugins)if(!i&&s.particleFillColor&&(i=(0,o.R5)(this._engine,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,o.R5)(this._engine,s.particleStrokeColor(t))),i&&e)break;return this._reusablePluginColors[0]=i,this._reusablePluginColors[1]=e,this._reusablePluginColors};_initStyle=()=>{let t=this.element,i=this.container.actualOptions;if(t)for(let e in this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle(),i.style){if(!e||!Object.hasOwn(i.style,e))continue;let s=i.style[e];s&&t.style.setProperty(e,s,"important")}};_repairStyle=()=>{let t=this.element;if(!t)return;this._safeMutationObserver(t=>{t.disconnect()}),this._initStyle(),this.initBackground();let i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver(i=>{t instanceof Node&&i.observe(t,{attributes:!0})})};_resetOriginalStyle=()=>{let t=this.element,i=this._originalStyle;t&&i&&h(t,i,!0)};_safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)};_setFullScreenStyle=()=>{let t=this.element;t&&h(t,(0,n.hJ)(this.container.actualOptions.fullScreen.zIndex),!0)}}class c{container;_handlers;_resizeObserver;_resizeTimeout;constructor(t){this.container=t,this._handlers={visibilityChange:()=>{this._handleVisibilityChange()},resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}_handleVisibilityChange=()=>{let t=this.container;t.actualOptions.pauseOnBlur&&((0,n.T5)().hidden?(t.pageHidden=!0,t.pause()):(t.pageHidden=!1,t.animationStatus?t.play(!0):t.draw(!0)))};_handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);let t=async()=>{let t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout(()=>void t(),this.container.actualOptions.resize.delay*a.Xu)};_manageListeners=t=>{let i=this._handlers;this._manageResize(t),(0,n.Kp)(document,a.nK,i.visibilityChange,t,!1)};_manageResize=t=>{let i=this._handlers,e=this.container;if(!e.actualOptions.resize.enable)return;if("u"<typeof ResizeObserver)return void(0,n.Kp)(globalThis,a.NF,i.resize,t);let s=e.canvas.element;this._resizeObserver&&!t?(s&&this._resizeObserver.unobserve(s),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&s&&(this._resizeObserver=new ResizeObserver(t=>{t.find(t=>t.target===s)&&this._handleWindowResize()}),this._resizeObserver.observe(s))}}var d=e(5581),p=e(1802),u=e(7176),_=e(6826),g=e(3712),f=e(1675),P=e(7051),m=e(3109);function y(t){if(!(0,n.hn)(t.outMode,t.checkModes))return;let i=t.radius*a.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class w{container;backColor;bubble;color;destroyed;direction;effect;effectClose;effectData;effectFill;group;id;ignoresResizeRatio;initialPosition;initialVelocity;isRotating;lastPathTime;misplaced;moveCenter;moveDecay;offset;opacity;options;outType;pathDelay;pathGenerator;pathRotation;position;randomIndexData;retina;roll;rotation;shape;shapeClose;shapeData;shapeFill;sides;size;slow;spawning;strokeColor;strokeOpacity;strokeWidth;unbreakable;velocity;zIndexFactor;_cachedOpacityData={opacity:a.hv,strokeOpacity:a.hv};_cachedPosition=_.p.origin;_cachedRotateData={sin:0,cos:0};_cachedTransform={a:1,b:0,c:0,d:1};_engine;constructor(t,i){this.container=i,this._engine=t}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;let i=this.container,e=this.pathGenerator,s=this.shape?i.particles.shapeDrawers.get(this.shape):void 0;for(let e of(s?.particleDestroy?.(this),i.particleDestroyedPlugins))e.particleDestroyed?.(this,t);for(let e of i.particles.updaters)e.particleDestroyed?.(this,t);e?.reset(this),this._engine.dispatchEvent(d.B.particleDestroyed,{container:this.container,data:{particle:this}})}draw(t){let i=this.container.canvas;i.drawParticlePlugins(this,t),i.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:a.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.color))}getMass(){return this.getRadius()**a.dm*Math.PI*a.MX}getOpacity(){let t=this.options.zIndex,i=a.RV-this.zIndexFactor,e=i**t.opacityRate,r=this.bubble.opacity??(0,s.VG)(this.opacity?.value??a.hv),n=this.strokeOpacity??r;return this._cachedOpacityData.opacity=r*e,this._cachedOpacityData.strokeOpacity=n*e,this._cachedOpacityData}getPosition(){return this._cachedPosition.x=this.position.x+this.offset.x,this._cachedPosition.y=this.position.y+this.offset.y,this._cachedPosition.z=this.position.z,this._cachedPosition}getRadius(){return this.bubble.radius??this.size.value}getRotateData(){let t=this.getAngle();return this._cachedRotateData.sin=Math.sin(t),this._cachedRotateData.cos=Math.cos(t),this._cachedRotateData}getStrokeColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.strokeColor))}getTransformData(t){let i=this.getRotateData(),e=this.isRotating;return this._cachedTransform.a=i.cos*(t.a??a.Ug.a),this._cachedTransform.b=e?i.sin*(t.b??a.D_):t.b??a.Ug.b,this._cachedTransform.c=e?-i.sin*(t.c??a.D_):t.c??a.Ug.c,this._cachedTransform.d=i.cos*(t.d??a.Ug.d),this._cachedTransform}init(t,i,e,r){var o,h,l,c;let d,p,u,_,g=this.container;this.id=t,this.group=r,this.effectClose=!0,this.effectFill=!0,this.shapeClose=!0,this.shapeFill=!0,this.pathRotation=!1,this.lastPathTime=0,this.destroyed=!1,this.unbreakable=!1,this.isRotating=!1,this.rotation=0,this.misplaced=!1,this.retina={maxDistance:{}},this.outType=P.x.normal,this.ignoresResizeRatio=!0;let f=g.retina.pixelRatio,y=g.actualOptions,w=(0,m.y)(this._engine,g,y.particles),v=w.reduceDuplicates,z=w.effect.type,b=w.shape.type;this.effect=(0,n.TA)(z,this.id,v),this.shape=(0,n.TA)(b,this.id,v);let S=w.effect,C=w.shape;if(e){if(e.effect?.type){let t=e.effect.type,i=(0,n.TA)(t,this.id,v);i&&(this.effect=i,S.load(e.effect))}if(e.shape?.type){let t=e.shape.type,i=(0,n.TA)(t,this.id,v);i&&(this.shape=i,C.load(e.shape))}}if(this.effect===a.mR){let t=[...this.container.particles.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===a.mR){let t=[...this.container.particles.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?(o=this.effect,h=this.id,u=S.options[o],(0,n.zw)({close:S.close,fill:S.fill},(0,n.TA)(u,h,v))):void 0,this.shapeData=this.shape?(l=this.shape,c=this.id,_=C.options[l],(0,n.zw)({close:C.close,fill:C.fill},(0,n.TA)(_,c,v))):void 0,w.load(e);let x=this.effectData;x&&w.load(x.particles);let D=this.shapeData;D&&w.load(D.particles),this.effectFill=x?.fill??w.effect.fill,this.effectClose=x?.close??w.effect.close,this.shapeFill=D?.fill??w.shape.fill,this.shapeClose=D?.close??w.shape.close,this.options=w;let R=this.options.move.path;if(this.pathDelay=(0,s.VG)(R.delay.value)*a.Xu,R.generator){let t=this.container.particles.pathGenerators.get(R.generator);!t&&(t=this.container.particles.availablePathGenerators.get(R.generator))&&(this.container.particles.pathGenerators.set(R.generator,t),t.init()),this.pathGenerator=t}g.retina.initParticle(this),this.size=(0,n.Xs)(this.options.size,f),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(i),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy(),this.moveDecay=a.WH-(0,s.VG)(this.options.move.decay);let O=g.particles;O.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/g.zLayers,this.sides=24,this.effect&&(d=g.particles.effectDrawers.get(this.effect)),d?.loadEffect&&d.loadEffect(this),this.shape&&(p=g.particles.shapeDrawers.get(this.shape)),p?.loadShape&&p.loadShape(this);let M=p?.getSidesCount;for(let t of(M&&(this.sides=M(this)),this.spawning=!1,O.updaters))t.init(this);for(let t of O.movers)t.init(this);for(let t of(d?.particleInit?.(g,this),p?.particleInit?.(g,this),g.particleCreatedPlugins))t.particleCreated?.(this)}isInsideCanvas(){let t=this.getRadius(),i=this.container.canvas.size,e=this.position;return e.x>=-t&&e.y>=-t&&e.y<=i.height+t&&e.x<=i.width+t}isShowingBack(){if(!this.roll)return!1;let t=this.roll.angle;if(this.roll.horizontal&&this.roll.vertical){let i=t%a.R1,e=i<a.tA?i+a.R1:i;return e>=Math.PI*a.MX&&e<Math.PI*a.Nu*a.MX}if(this.roll.horizontal){let i=(t+Math.PI*a.MX)%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}if(this.roll.vertical){let i=t%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}return!1}isVisible(){return!this.destroyed&&!this.spawning&&this.isInsideCanvas()}reset(){for(let t of this.container.particles.updaters)t.reset?.(this)}_calcPosition=(t,i)=>{let e=a.rq,r=t?_.p.create(t.x,t.y,i):void 0,n=this.container,o=n.particlePositionPlugins,h=this.options.move.outModes,l=this.getRadius(),c=n.canvas.size,{signal:d}=new AbortController;for(;!d.aborted;){for(let t of o){let e=t.particlePosition?.(r,this);if(e)return _.p.create(e.x,e.y,i)}let t=(0,s.Nx)({size:c,position:r}),d=_.p.create(t.x,t.y,i);this._fixHorizontal(d,l,h.left??h.default),this._fixHorizontal(d,l,h.right??h.default),this._fixVertical(d,l,h.top??h.default),this._fixVertical(d,l,h.bottom??h.default);let p=!0;for(let t of n.particles.checkParticlePositionPlugins)if(!(p=t.checkParticlePosition?.(this,d,e)??!0))break;if(p)return d;e+=a.Eo,r=void 0}return r};_calculateVelocity=()=>{let t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===g.F.inside||i.direction===g.F.outside)return t;let e=(0,s.pu)((0,s.VG)(i.angle.value)),r=(0,s.pu)((0,s.VG)(i.angle.offset)),n={left:r-e*a.MX,right:r+e*a.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(n.left,n.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t};_fixHorizontal=(t,i,e)=>{y({outMode:e,checkModes:[f.Y.bounce],coord:t.x,maxCoord:this.container.canvas.size.width,setCb:i=>t.x+=i,radius:i})};_fixVertical=(t,i,e)=>{y({outMode:e,checkModes:[f.Y.bounce],coord:t.y,maxCoord:this.container.canvas.size.height,setCb:i=>t.y+=i,radius:i})};_getRollColor=t=>t&&this.roll&&(this.backColor||this.roll.alter)&&this.isShowingBack()?this.backColor?this.backColor:this.roll.alter?(0,o.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t;_initPosition=t=>{let i=this.container,e=(0,s.VG)(this.options.zIndex.value),r=this._calcPosition(t,(0,s.qE)(e,a.X_,i.zLayers));if(!r)throw Error("a valid position cannot be found for particle");this.position=r,this.initialPosition=this.position.copy();let o=i.canvas.size;switch(this.moveCenter={...(0,n.E9)(this.options.move.center,o),radius:this.options.move.center.radius,mode:this.options.move.center.mode},this.direction=(0,s.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case g.F.inside:this.outType=P.x.inside;break;case g.F.outside:this.outType=P.x.outside}this.offset=_.M.origin}}var v=e(8738);class z{_cellSize;_cells=new Map;_pendingCellSize;constructor(t){this._cellSize=t}clear(){this._cells.clear();let t=this._pendingCellSize;t&&(this._cellSize=t),this._pendingCellSize=void 0}insert(t){let{x:i,y:e}=t.getPosition(),s=this._cellKeyFromCoords(i,e);this._cells.has(s)||this._cells.set(s,[]),this._cells.get(s)?.push(t)}query(t,i,e=[]){let s=this._getRangeBounds(t);if(!s)return e;let a=Math.floor(s.minX/this._cellSize),r=Math.floor(s.maxX/this._cellSize),n=Math.floor(s.minY/this._cellSize),o=Math.floor(s.maxY/this._cellSize);for(let s=a;s<=r;s++)for(let a=n;a<=o;a++){let r=`${s}_${a}`,n=this._cells.get(r);if(n)for(let s of n)(!i||i(s))&&t.contains(s.getPosition())&&e.push(s)}return e}queryCircle(t,i,e,s=[]){return this.query(new v.jl(t.x,t.y,i),e,s)}queryRectangle(t,i,e,s=[]){return this.query(new v.M_(t.x,t.y,i.width,i.height),e,s)}setCellSize(t){this._pendingCellSize=t}_cellKeyFromCoords(t,i){let e=Math.floor(t/this._cellSize),s=Math.floor(i/this._cellSize);return`${e}_${s}`}_getRangeBounds(t){if(t instanceof v.jl){let i=t.radius,{x:e,y:s}=t.position;return{minX:e-i,maxX:e+i,minY:s-i,maxY:s+i}}if(t instanceof v.M_){let{x:i,y:e}=t.position,{width:s,height:a}=t.size;return{minX:i,maxX:i+s,minY:e,maxY:e+a}}return null}}var b=e(8041);class S{availablePathGenerators;checkParticlePositionPlugins;effectDrawers;grid;movers;pathGenerators;shapeDrawers;updaters;_array;_container;_engine;_groupLimits;_limit;_maxZIndex;_minZIndex;_needsSort;_nextId;_particleResetPlugins;_particleUpdatePlugins;_pool;_postParticleUpdatePlugins;_postUpdatePlugins;_resizeFactor;_updatePlugins;_zArray;constructor(t,i){this._engine=t,this._container=i,this._nextId=0,this._array=[],this._zArray=[],this._pool=[],this._limit=0,this._groupLimits=new Map,this._needsSort=!1,this._minZIndex=0,this._maxZIndex=0,this.grid=new z(a.iX),this.effectDrawers=new Map,this.movers=[],this.availablePathGenerators=new Map,this.pathGenerators=new Map,this.shapeDrawers=new Map,this.updaters=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}get count(){return this._array.length}addParticle(t,i,e,s){let r=this._container.actualOptions.particles.number.limit.mode,n=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,o=this.count;if(n>a.ou)switch(r){case u.d.delete:{let t=o+a.nq-n;t>a.wM&&this.removeQuantity(t);break}case u.d.wait:if(o>=n)return}try{let a=this._pool.pop()??new w(this._engine,this._container);a.init(this._nextId,t,i,e);let r=!0;if(s&&(r=s(a)),!r)return void this._pool.push(a);return this._array.push(a),this._zArray.push(a),this._nextId++,this._engine.dispatchEvent(d.B.particleAdded,{container:this._container,data:{particle:a}}),a}catch(t){(0,b.t)().warning(`error adding particle: ${t}`)}}clear(){this._array=[],this._zArray=[]}destroy(){let t=this._container;for(let[,i]of this.effectDrawers)i.destroy?.(t);for(let[,i]of this.shapeDrawers)i.destroy?.(t);this._array=[],this._pool.length=0,this._zArray=[],this.effectDrawers=new Map,this.movers=[],this.availablePathGenerators=new Map,this.pathGenerators=new Map,this.shapeDrawers=new Map,this.updaters=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}drawParticles(t){for(let i of this._zArray)i.draw(t)}filter(t){return this._array.filter(t)}find(t){return this._array.find(t)}get(t){return this._array[t]}async init(){let t=this._container,i=t.actualOptions;for(let i of(this._minZIndex=0,this._maxZIndex=0,this._needsSort=!1,this.checkParticlePositionPlugins=[],this._updatePlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._particleResetPlugins=[],this._postParticleUpdatePlugins=[],this.grid=new z(a.iX*t.retina.pixelRatio),t.plugins))i.redrawInit&&await i.redrawInit(),i.checkParticlePosition&&this.checkParticlePositionPlugins.push(i),i.update&&this._updatePlugins.push(i),i.particleUpdate&&this._particleUpdatePlugins.push(i),i.postUpdate&&this._postUpdatePlugins.push(i),i.particleReset&&this._particleResetPlugins.push(i),i.postParticleUpdate&&this._postParticleUpdatePlugins.push(i);for(let i of(await this.initPlugins(),this.effectDrawers.values()))await i.init?.(t);for(let i of this.shapeDrawers.values())await i.init?.(t);let e=!1;for(let i of t.plugins)if(e=i.particlesInitialization?.()??e)break;if(!e){let t=i.particles,e=t.groups;for(let i in e){let s=e[i];if(s)for(let e=this.count,a=0;a<s.number.value&&e<t.number.value;e++,a++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}async initPlugins(){let t=this._container;for(let i of(this.effectDrawers=await this._engine.getEffectDrawers(t,!0),this.movers=await this._engine.getMovers(t,!0),this.availablePathGenerators=await this._engine.getPathGenerators(t,!0),this.pathGenerators=new Map,this.shapeDrawers=await this._engine.getShapeDrawers(t,!0),this.updaters=await this._engine.getUpdaters(t,!0),this.pathGenerators.values()))i.init()}push(t,i,e,s){for(let a=0;a<t;a++)this.addParticle(i,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=a.xd,e,s){if(t<a.z9||t>this.count)return;let r=0;for(let a=t;r<i&&a<this.count;a++)this._removeParticle(a,e,s)&&(a--,r++)}removeQuantity(t,i){this.removeAt(a.z9,t,i)}setDensity(){let t=this._container.actualOptions,i=t.particles.groups,e=0;for(let t of this._container.plugins)t.particlesDensityCount&&(e+=t.particlesDensityCount());for(let t in i){let s=i[t];if(!s)continue;let a=(0,m.y)(this._engine,this._container,s);this._applyDensity(a,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._needsSort||=t>=this._maxZIndex||t>this._minZIndex&&t<this._maxZIndex}setResizeFactor(t){this._resizeFactor=t}update(t){let i=new Set;for(let t of(this.grid.clear(),this.pathGenerators.values()))t.update();for(let i of this._updatePlugins)i.update?.(t);let e=this._resizeFactor;for(let s of this._array){for(let t of(e&&!s.ignoresResizeRatio&&(s.position.x*=e.width,s.position.y*=e.height,s.initialPosition.x*=e.width,s.initialPosition.y*=e.height),s.ignoresResizeRatio=!1,this._particleResetPlugins))t.particleReset?.(s);for(let i of this._particleUpdatePlugins){if(s.destroyed)break;i.particleUpdate?.(s,t)}for(let i of this.movers)i.isEnabled(s)&&i.move(s,t);if(s.destroyed){i.add(s);continue}this.grid.insert(s)}if(i.size){let t=t=>!i.has(t);for(let e of(this._array=this.filter(t),this._zArray=this._zArray.filter(t),i))this._engine.dispatchEvent(d.B.particleRemoved,{container:this._container,data:{particle:e}});this._addToPool(...i)}for(let i of this._postUpdatePlugins)i.postUpdate?.(t);for(let i of this._array){for(let e of this.updaters)e.update(i,t);if(!i.destroyed&&!i.spawning)for(let e of this._postParticleUpdatePlugins)e.postParticleUpdate?.(i,t)}if(delete this._resizeFactor,this._needsSort){let t=this._zArray;t.sort((t,i)=>i.position.z-t.position.z||t.id-i.id);let i=t[a.z9],e=t[t.length-a.K3];if(!i||!e)return;this._maxZIndex=i.position.z,this._minZIndex=e.position.z,this._needsSort=!1}}_addToPool=(...t)=>{this._pool.push(...t)};_applyDensity=(t,i,e,s)=>{let r=t.number;if(!r.density.enable)return void(void 0===e?this._limit=r.limit.value:(s?.number.limit.value??r.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??r.limit.value));let n=this._initDensityFactor(r.density),o=r.value,h=r.limit.value>a.ou?r.limit.value:o,l=Math.min(o,h)*n+i,c=Math.min(this.count,this.filter(t=>t.group===e).length);void 0===e?this._limit=r.limit.value*n:this._groupLimits.set(e,r.limit.value*n),c<l?this.push(Math.abs(l-c),void 0,t,e):c>l&&this.removeQuantity(c-l,e)};_initDensityFactor=t=>{let i=this._container;if(!i.canvas.element||!t.enable)return a.lA;let e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**a.dm)};_removeParticle=(t,i,e)=>{let s=this._array[t];if(!s||s.group!==i)return!1;let r=this._zArray.indexOf(s);return this._array.splice(t,a.LD),this._zArray.splice(r,a.LD),s.destroy(e),this._engine.dispatchEvent(d.B.particleRemoved,{container:this._container,data:{particle:s}}),this._addToPool(s),!0}}class C{container;maxSpeed;pixelRatio;reduceFactor;sizeAnimationSpeed;constructor(t){this.container=t,this.pixelRatio=a.$x,this.reduceFactor=a.Zp}init(){let t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:a.$x,this.reduceFactor=a.Zp;let e=this.pixelRatio,r=t.canvas;if(r.element){let t=r.element;r.size.width=t.offsetWidth*e,r.size.height=t.offsetHeight*e}let n=i.particles,o=n.move;this.maxSpeed=(0,s.VG)(o.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,s.VG)(n.size.animation.speed)*e}initParticle(t){let i=t.options,e=this.pixelRatio,a=i.move,r=a.distance,n=t.retina;n.moveDrift=(0,s.VG)(a.drift)*e,n.moveSpeed=(0,s.VG)(a.speed)*e,n.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;let o=n.maxDistance;o.horizontal=void 0!==r.horizontal?r.horizontal*e:void 0,o.vertical=void 0!==r.vertical?r.vertical*e:void 0,n.maxSpeed=(0,s.VG)(a.gravity.maxSpeed)*e}}function x(t){return!t.destroyed}function D(t,i,...e){let s=new p.J(t,i);return(0,m.Z)(s,...e),s}class R{actualOptions;canvas;destroyed;fpsLimit;hdr;id;pageHidden;particleCreatedPlugins;particleDestroyedPlugins;particlePositionPlugins;particles;plugins;retina;started;zLayers;_delay;_delayTimeout;_delta={value:0,factor:0};_drawAnimationFrame;_duration;_engine;_eventListeners;_firstStart;_initialSourceOptions;_lastFrameTime;_lifeTime;_options;_paused;_smooth;_sourceOptions;constructor(t,i,e){this._engine=t,this.id=Symbol(i),this.fpsLimit=120,this.hdr=!1,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._sourceOptions=e,this._initialSourceOptions=e,this.retina=new C(this),this.canvas=new l(this,this._engine),this.particles=new S(this._engine,this),this.plugins=[],this.particleDestroyedPlugins=[],this.particleCreatedPlugins=[],this.particlePositionPlugins=[],this._options=D(this._engine,this),this.actualOptions=D(this._engine,this),this._eventListeners=new c(this),this._engine.dispatchEvent(d.B.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&x(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addLifeTime(t){this._lifeTime+=t}alive(){return!this._duration||this._lifeTime<=this._duration}destroy(t=!0){if(x(this)){for(let t of(this.stop(),this.particles.destroy(),this.canvas.destroy(),this.plugins))t.destroy?.();if(this.plugins.length=0,this._engine.clearPlugins(this),this.destroyed=!0,t){let t=this._engine.items,i=t.indexOf(this);i>=a.vF&&t.splice(i,a.JC)}this._engine.dispatchEvent(d.B.containerDestroyed,{container:this})}}draw(t){if(!x(this))return;let i=t;this._drawAnimationFrame=(0,s.i0)(t=>{i&&(this._lastFrameTime=void 0,i=!1),this._nextFrame(t)})}async export(t,i={}){for(let e of this.plugins){if(!e.export)continue;let s=await e.export(t,i);if(s.supported)return s.blob}(0,b.t)().error(`Export plugin with type ${t} not found`)}async init(){if(!x(this))return;let t=new Map;for(let i of this._engine.plugins){let e=await i.getPlugin(this);e.preInit&&await e.preInit(),t.set(i,e)}for(let[i,e]of(await this.particles.initPlugins(),this._options=D(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=D(this._engine,this,this._options),this.plugins.length=0,this.particleDestroyedPlugins.length=0,this.particleCreatedPlugins.length=0,this.particlePositionPlugins.length=0,t))i.needsPlugin(this.actualOptions)&&(this.plugins.push(e),e.particleCreated&&this.particleCreatedPlugins.push(e),e.particleDestroyed&&this.particleDestroyedPlugins.push(e),e.particlePosition&&this.particlePositionPlugins.push(e));this.retina.init(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();let{delay:i,duration:e,fpsLimit:r,hdr:n,smooth:o,zLayers:h}=this.actualOptions;for(let t of(this.hdr=n,this.zLayers=h,this._duration=(0,s.VG)(e)*a.Xu,this._delay=(0,s.VG)(i)*a.Xu,this._lifeTime=0,this.fpsLimit=r>a.DN?r:a.i8,this._smooth=o,this.plugins))await t.init?.();for(let t of(await this.particles.init(),this._engine.dispatchEvent(d.B.containerInit,{container:this}),this.particles.setDensity(),this.plugins))t.particlesSetup?.();this._engine.dispatchEvent(d.B.particlesSetup,{container:this})}pause(){if(x(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(let t of this.plugins)t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(d.B.containerPaused,{container:this})}}play(t){if(!x(this))return;let i=this._paused||t;if(this._firstStart&&!this.actualOptions.autoPlay){this._firstStart=!1;return}if(this._paused&&(this._paused=!1),i)for(let t of this.plugins)t.play&&t.play();this._engine.dispatchEvent(d.B.containerPlay,{container:this}),this.draw(i??!1)}async refresh(){if(x(this))return this.stop(),this.start()}async reset(t){if(x(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=D(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=D(this._engine,this,this._options),this.refresh()}async start(){x(this)&&!this.started&&(await this.init(),this.started=!0,await new Promise(t=>{let i=async()=>{for(let t of(this._eventListeners.addListeners(),this.plugins))await t.start?.();this._engine.dispatchEvent(d.B.containerStarted,{container:this}),this.play(),t()};this._delayTimeout=setTimeout(()=>void i(),this._delay)}))}stop(){if(x(this)&&this.started){for(let t of(this._delayTimeout&&(clearTimeout(this._delayTimeout),delete this._delayTimeout),this._firstStart=!0,this.started=!1,this._eventListeners.removeListeners(),this.pause(),this.particles.clear(),this.canvas.stop(),this.plugins))t.stop?.();this.particleCreatedPlugins.length=0,this.particleDestroyedPlugins.length=0,this.particlePositionPlugins.length=0,this._sourceOptions=this._options,this._engine.dispatchEvent(d.B.containerStopped,{container:this})}}updateActualOptions(){let t=!1;for(let i of this.plugins)i.updateActualOptions&&(t=i.updateActualOptions()||t);return t}_nextFrame=t=>{try{if(!this._smooth&&void 0!==this._lastFrameTime&&t<this._lastFrameTime+a.Xu/this.fpsLimit||(this._lastFrameTime??=t,!function(t,i,e=a.z$,s=!1){t.value=i,t.factor=s?a.z$/e:a.z$*i/a.Xu}(this._delta,t-this._lastFrameTime,this.fpsLimit,this._smooth),this.addLifeTime(this._delta.value),this._lastFrameTime=t,this._delta.value>a.Xu))return void this.draw(!1);if(this.canvas.drawParticles(this._delta),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,b.t)().error("error in animation loop",t)}}}}}]);
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,36 +0,0 @@
1
- import { isNull } from "../../../../Utils/TypeUtils.js";
2
- import { setRangeValue } from "../../../../Utils/MathUtils.js";
3
- export class MoveAttract {
4
- distance;
5
- enable;
6
- rotate;
7
- constructor() {
8
- this.distance = 200;
9
- this.enable = false;
10
- this.rotate = {
11
- x: 3000,
12
- y: 3000,
13
- };
14
- }
15
- load(data) {
16
- if (isNull(data)) {
17
- return;
18
- }
19
- if (data.distance !== undefined) {
20
- this.distance = setRangeValue(data.distance);
21
- }
22
- if (data.enable !== undefined) {
23
- this.enable = data.enable;
24
- }
25
- if (data.rotate) {
26
- const rotateX = data.rotate.x;
27
- if (rotateX !== undefined) {
28
- this.rotate.x = rotateX;
29
- }
30
- const rotateY = data.rotate.y;
31
- if (rotateY !== undefined) {
32
- this.rotate.y = rotateY;
33
- }
34
- }
35
- }
36
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};