tsparticles 2.8.0 → 3.0.0-alpha.1

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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v2.8.0
7
+ * v3.0.0-alpha.1
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -59,6 +59,7 @@ __webpack_require__.r(__webpack_exports__);
59
59
  __webpack_require__.d(__webpack_exports__, {
60
60
  "AnimatableColor": () => (/* reexport */ AnimatableColor),
61
61
  "AnimationOptions": () => (/* reexport */ AnimationOptions),
62
+ "AnimationValueWithRandom": () => (/* reexport */ AnimationValueWithRandom),
62
63
  "Background": () => (/* reexport */ Background),
63
64
  "BackgroundMask": () => (/* reexport */ BackgroundMask),
64
65
  "BackgroundMaskCover": () => (/* reexport */ BackgroundMaskCover),
@@ -85,6 +86,7 @@ __webpack_require__.d(__webpack_exports__, {
85
86
  "MoveGravity": () => (/* reexport */ MoveGravity),
86
87
  "MovePath": () => (/* reexport */ MovePath),
87
88
  "MoveTrail": () => (/* reexport */ MoveTrail),
89
+ "MoveTrailFill": () => (/* reexport */ MoveTrailFill),
88
90
  "Opacity": () => (/* reexport */ Opacity),
89
91
  "OpacityAnimation": () => (/* reexport */ OpacityAnimation),
90
92
  "Options": () => (/* reexport */ Options),
@@ -99,6 +101,8 @@ __webpack_require__.d(__webpack_exports__, {
99
101
  "ParticlesOptions": () => (/* reexport */ ParticlesOptions),
100
102
  "Point": () => (/* reexport */ Point),
101
103
  "Range": () => (/* reexport */ Range),
104
+ "RangedAnimationOptions": () => (/* reexport */ RangedAnimationOptions),
105
+ "RangedAnimationValueWithRandom": () => (/* reexport */ RangedAnimationValueWithRandom),
102
106
  "Rectangle": () => (/* reexport */ Rectangle),
103
107
  "ResizeEvent": () => (/* reexport */ ResizeEvent),
104
108
  "Responsive": () => (/* reexport */ Responsive),
@@ -132,6 +136,7 @@ __webpack_require__.d(__webpack_exports__, {
132
136
  "circleBounceDataFromParticle": () => (/* reexport */ circleBounceDataFromParticle),
133
137
  "clamp": () => (/* reexport */ clamp),
134
138
  "clear": () => (/* reexport */ clear),
139
+ "clearCanvas": () => (/* reexport */ clearCanvas),
135
140
  "collisionVelocity": () => (/* reexport */ collisionVelocity),
136
141
  "colorMix": () => (/* reexport */ colorMix),
137
142
  "colorToHsl": () => (/* reexport */ colorToHsl),
@@ -149,6 +154,7 @@ __webpack_require__.d(__webpack_exports__, {
149
154
  "executeOnSingleOrMultiple": () => (/* reexport */ executeOnSingleOrMultiple),
150
155
  "findItemFromSingleOrMultiple": () => (/* reexport */ findItemFromSingleOrMultiple),
151
156
  "generatedAttribute": () => (/* reexport */ generatedAttribute),
157
+ "getContext": () => (/* reexport */ getContext),
152
158
  "getDistance": () => (/* reexport */ getDistance),
153
159
  "getDistances": () => (/* reexport */ getDistances),
154
160
  "getEasing": () => (/* reexport */ getEasing),
@@ -169,6 +175,7 @@ __webpack_require__.d(__webpack_exports__, {
169
175
  "hasMatchMedia": () => (/* reexport */ hasMatchMedia),
170
176
  "hslToRgb": () => (/* reexport */ hslToRgb),
171
177
  "hslaToRgba": () => (/* reexport */ hslaToRgba),
178
+ "initParticleNumericAnimationValue": () => (/* reexport */ initParticleNumericAnimationValue),
172
179
  "isDivModeEnabled": () => (/* reexport */ isDivModeEnabled),
173
180
  "isInArray": () => (/* reexport */ isInArray),
174
181
  "isPointInside": () => (/* reexport */ isPointInside),
@@ -186,8 +193,7 @@ __webpack_require__.d(__webpack_exports__, {
186
193
  "mouseMoveEvent": () => (/* reexport */ mouseMoveEvent),
187
194
  "mouseOutEvent": () => (/* reexport */ mouseOutEvent),
188
195
  "mouseUpEvent": () => (/* reexport */ mouseUpEvent),
189
- "paintBase": () => (/* reexport */ paintBase),
190
- "paintImage": () => (/* reexport */ paintImage),
196
+ "paintCanvas": () => (/* reexport */ paintCanvas),
191
197
  "parseAlpha": () => (/* reexport */ parseAlpha),
192
198
  "randomInRange": () => (/* reexport */ randomInRange),
193
199
  "rangeColorToHsl": () => (/* reexport */ rangeColorToHsl),
@@ -209,50 +215,6 @@ __webpack_require__.d(__webpack_exports__, {
209
215
  "visibilityChangeEvent": () => (/* reexport */ visibilityChangeEvent)
210
216
  });
211
217
 
212
- ;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/EventDispatcher.js
213
- class EventDispatcher {
214
- constructor() {
215
- this._listeners = new Map();
216
- }
217
- addEventListener(type, listener) {
218
- var _a;
219
- this.removeEventListener(type, listener);
220
- if (!this._listeners.get(type)) {
221
- this._listeners.set(type, []);
222
- }
223
- (_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.push(listener);
224
- }
225
- dispatchEvent(type, args) {
226
- var _a;
227
- (_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(handler => handler(args));
228
- }
229
- hasEventListener(type) {
230
- return !!this._listeners.get(type);
231
- }
232
- removeAllEventListeners(type) {
233
- if (!type) {
234
- this._listeners = new Map();
235
- } else {
236
- this._listeners.delete(type);
237
- }
238
- }
239
- removeEventListener(type, listener) {
240
- const arr = this._listeners.get(type);
241
- if (!arr) {
242
- return;
243
- }
244
- const length = arr.length,
245
- idx = arr.indexOf(listener);
246
- if (idx < 0) {
247
- return;
248
- }
249
- if (length === 1) {
250
- this._listeners.delete(type);
251
- } else {
252
- arr.splice(idx, 1);
253
- }
254
- }
255
- }
256
218
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Vector3d.js
257
219
  class Vector3d {
258
220
  constructor(xOrCoords, y, z) {
@@ -750,6 +712,59 @@ function itemFromSingleOrMultiple(obj, index, useIndex) {
750
712
  function findItemFromSingleOrMultiple(obj, callback) {
751
713
  return obj instanceof Array ? obj.find((t, index) => callback(t, index)) : callback(obj, 0) ? obj : undefined;
752
714
  }
715
+ function initParticleNumericAnimationValue(options, pxRatio) {
716
+ const valueRange = options.value,
717
+ animationOptions = options.animation;
718
+ const res = {
719
+ enable: options.animation.enable,
720
+ value: getRangeValue(options.value) * pxRatio,
721
+ max: getRangeMax(valueRange) * pxRatio,
722
+ min: getRangeMin(valueRange) * pxRatio,
723
+ loops: 0,
724
+ maxLoops: getRangeValue(options.animation.count)
725
+ };
726
+ if (animationOptions.enable) {
727
+ res.decay = 1 - getRangeValue(animationOptions.decay);
728
+ let autoStatus = false;
729
+ switch (animationOptions.mode) {
730
+ case "increase":
731
+ res.status = "increasing";
732
+ break;
733
+ case "decrease":
734
+ res.status = "decreasing";
735
+ break;
736
+ case "random":
737
+ res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
738
+ break;
739
+ case "auto":
740
+ autoStatus = true;
741
+ break;
742
+ }
743
+ switch (animationOptions.startValue) {
744
+ case "min":
745
+ res.value = res.min;
746
+ if (autoStatus) {
747
+ res.status = "increasing";
748
+ }
749
+ break;
750
+ case "random":
751
+ res.value = randomInRange(res);
752
+ if (autoStatus) {
753
+ res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
754
+ }
755
+ break;
756
+ case "max":
757
+ default:
758
+ res.value = res.max;
759
+ if (autoStatus) {
760
+ res.status = "decreasing";
761
+ }
762
+ break;
763
+ }
764
+ }
765
+ res.initialValue = res.value;
766
+ return res;
767
+ }
753
768
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/ColorUtils.js
754
769
 
755
770
 
@@ -1033,6 +1048,49 @@ function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
1033
1048
  }
1034
1049
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/CanvasUtils.js
1035
1050
 
1051
+ function paintBase(context, dimension, baseColor) {
1052
+ context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)";
1053
+ context.fillRect(0, 0, dimension.width, dimension.height);
1054
+ }
1055
+ function paintImage(context, dimension, image, opacity) {
1056
+ if (!image) {
1057
+ return;
1058
+ }
1059
+ context.globalAlpha = opacity;
1060
+ context.drawImage(image, 0, 0, dimension.width, dimension.height);
1061
+ context.globalAlpha = 1;
1062
+ }
1063
+ function getContext(canvas) {
1064
+ const context = canvas.getContext("2d");
1065
+ if (!context) {
1066
+ throw new Error("Error tsParticles - No canvas context found");
1067
+ }
1068
+ return context;
1069
+ }
1070
+ function clearCanvas(context, size, options, trailFill, coverColorStyle) {
1071
+ if (options.backgroundMask.enable) {
1072
+ paintCanvas(context, size, options, coverColorStyle);
1073
+ } else {
1074
+ const trail = options.particles.move.trail;
1075
+ if (trail.enable && trail.length > 0 && trailFill) {
1076
+ if (trailFill.color) {
1077
+ paintBase(context, size, getStyleFromRgb(trailFill.color, trailFill.opacity));
1078
+ } else if (trailFill.image) {
1079
+ paintImage(context, size, trailFill.image, trailFill.opacity);
1080
+ }
1081
+ } else {
1082
+ clear(context, size);
1083
+ }
1084
+ }
1085
+ }
1086
+ function paintCanvas(context, size, options, coverColorStyle) {
1087
+ if (options.backgroundMask.enable && coverColorStyle) {
1088
+ clear(context, size);
1089
+ paintBase(context, size, coverColorStyle);
1090
+ } else {
1091
+ paintBase(context, size);
1092
+ }
1093
+ }
1036
1094
  function drawLine(context, begin, end) {
1037
1095
  context.beginPath();
1038
1096
  context.moveTo(begin.x, begin.y);
@@ -1046,18 +1104,6 @@ function drawTriangle(context, p1, p2, p3) {
1046
1104
  context.lineTo(p3.x, p3.y);
1047
1105
  context.closePath();
1048
1106
  }
1049
- function paintBase(context, dimension, baseColor) {
1050
- context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)";
1051
- context.fillRect(0, 0, dimension.width, dimension.height);
1052
- }
1053
- function paintImage(context, dimension, image, opacity) {
1054
- if (!image) {
1055
- return;
1056
- }
1057
- context.globalAlpha = opacity;
1058
- context.drawImage(image, 0, 0, dimension.width, dimension.height);
1059
- context.globalAlpha = 1;
1060
- }
1061
1107
  function clear(context, dimension) {
1062
1108
  context.clearRect(0, 0, dimension.width, dimension.height);
1063
1109
  }
@@ -1211,22 +1257,9 @@ class Canvas {
1211
1257
  return this.container.actualOptions.fullScreen.enable;
1212
1258
  }
1213
1259
  clear() {
1214
- const options = this.container.actualOptions,
1215
- trail = options.particles.move.trail,
1216
- trailFill = this._trailFill;
1217
- if (options.backgroundMask.enable) {
1218
- this.paint();
1219
- } else if (trail.enable && trail.length > 0 && trailFill) {
1220
- if (trailFill.color) {
1221
- this._paintBase(getStyleFromRgb(trailFill.color, trailFill.opacity));
1222
- } else if (trailFill.image) {
1223
- this._paintImage(trailFill.image, trailFill.opacity);
1224
- }
1225
- } else {
1226
- this.draw(ctx => {
1227
- clear(ctx, this.size);
1228
- });
1229
- }
1260
+ this.draw(ctx => {
1261
+ clearCanvas(ctx, this.size, this.container.actualOptions, this._trailFill, this._coverColorStyle);
1262
+ });
1230
1263
  }
1231
1264
  destroy() {
1232
1265
  var _a, _b;
@@ -1314,7 +1347,7 @@ class Canvas {
1314
1347
  }
1315
1348
  async init() {
1316
1349
  var _a;
1317
- this.resize();
1350
+ this._resize();
1318
1351
  this._initStyle();
1319
1352
  this._initCover();
1320
1353
  try {
@@ -1322,57 +1355,18 @@ class Canvas {
1322
1355
  } catch (e) {
1323
1356
  console.error(e);
1324
1357
  }
1325
- this.initBackground();
1358
+ this._initBackground();
1326
1359
  if (this.element) {
1327
1360
  (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.element, {
1328
1361
  attributes: true
1329
1362
  });
1330
1363
  }
1331
- this.initUpdaters();
1332
- this.initPlugins();
1333
- this.paint();
1334
- }
1335
- initBackground() {
1336
- const options = this.container.actualOptions,
1337
- background = options.background,
1338
- element = this.element,
1339
- elementStyle = element === null || element === void 0 ? void 0 : element.style;
1340
- if (!elementStyle) {
1341
- return;
1342
- }
1343
- if (background.color) {
1344
- const color = rangeColorToRgb(background.color);
1345
- elementStyle.backgroundColor = color ? getStyleFromRgb(color, background.opacity) : "";
1346
- } else {
1347
- elementStyle.backgroundColor = "";
1348
- }
1349
- elementStyle.backgroundImage = background.image || "";
1350
- elementStyle.backgroundPosition = background.position || "";
1351
- elementStyle.backgroundRepeat = background.repeat || "";
1352
- elementStyle.backgroundSize = background.size || "";
1353
- }
1354
- initPlugins() {
1355
- this._resizePlugins = [];
1356
- for (const [, plugin] of this.container.plugins) {
1357
- if (plugin.resize) {
1358
- this._resizePlugins.push(plugin);
1359
- }
1360
- if (plugin.particleFillColor || plugin.particleStrokeColor) {
1361
- this._colorPlugins.push(plugin);
1362
- }
1363
- }
1364
- }
1365
- initUpdaters() {
1366
- this._preDrawUpdaters = [];
1367
- this._postDrawUpdaters = [];
1368
- for (const updater of this.container.particles.updaters) {
1369
- if (updater.afterDraw) {
1370
- this._postDrawUpdaters.push(updater);
1371
- }
1372
- if (updater.getColorStyles || updater.getTransformValues || updater.beforeDraw) {
1373
- this._preDrawUpdaters.push(updater);
1374
- }
1375
- }
1364
+ this._initUpdaters();
1365
+ this._initPlugins();
1366
+ this._paint();
1367
+ this.container.updateActualOptions();
1368
+ this._resize();
1369
+ this._initBackground();
1376
1370
  }
1377
1371
  loadCanvas(canvas) {
1378
1372
  var _a, _b;
@@ -1385,53 +1379,18 @@ class Canvas {
1385
1379
  this._originalStyle = deepExtend({}, this.element.style);
1386
1380
  this.size.height = canvas.offsetHeight;
1387
1381
  this.size.width = canvas.offsetWidth;
1388
- this._context = this.element.getContext("2d");
1382
+ this._context = getContext(canvas);
1389
1383
  (_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(this.element, {
1390
1384
  attributes: true
1391
1385
  });
1392
1386
  this.container.retina.init();
1393
- this.initBackground();
1394
- }
1395
- paint() {
1396
- const options = this.container.actualOptions;
1397
- this.draw(ctx => {
1398
- if (options.backgroundMask.enable && options.backgroundMask.cover) {
1399
- clear(ctx, this.size);
1400
- this._paintBase(this._coverColorStyle);
1401
- } else {
1402
- this._paintBase();
1403
- }
1404
- });
1405
- }
1406
- resize() {
1407
- if (!this.element) {
1408
- return;
1409
- }
1410
- const container = this.container,
1411
- pxRatio = container.retina.pixelRatio,
1412
- size = container.canvas.size,
1413
- newSize = {
1414
- width: this.element.offsetWidth * pxRatio,
1415
- height: this.element.offsetHeight * pxRatio
1416
- };
1417
- if (newSize.height === size.height && newSize.width === size.width && newSize.height === this.element.height && newSize.width === this.element.width) {
1418
- return;
1419
- }
1420
- const oldSize = Object.assign({}, size);
1421
- this.element.width = size.width = this.element.offsetWidth * pxRatio;
1422
- this.element.height = size.height = this.element.offsetHeight * pxRatio;
1423
- if (this.container.started) {
1424
- this.resizeFactor = {
1425
- width: size.width / oldSize.width,
1426
- height: size.height / oldSize.height
1427
- };
1428
- }
1387
+ this._initBackground();
1429
1388
  }
1430
1389
  async windowResize() {
1431
1390
  if (!this.element) {
1432
1391
  return;
1433
1392
  }
1434
- this.resize();
1393
+ this._resize();
1435
1394
  const container = this.container,
1436
1395
  needsRefresh = container.updateActualOptions();
1437
1396
  container.particles.setDensity();
@@ -1492,6 +1451,25 @@ class Canvas {
1492
1451
  }
1493
1452
  return [fColor, sColor];
1494
1453
  }
1454
+ _initBackground() {
1455
+ const options = this.container.actualOptions,
1456
+ background = options.background,
1457
+ element = this.element,
1458
+ elementStyle = element === null || element === void 0 ? void 0 : element.style;
1459
+ if (!elementStyle) {
1460
+ return;
1461
+ }
1462
+ if (background.color) {
1463
+ const color = rangeColorToRgb(background.color);
1464
+ elementStyle.backgroundColor = color ? getStyleFromRgb(color, background.opacity) : "";
1465
+ } else {
1466
+ elementStyle.backgroundColor = "";
1467
+ }
1468
+ elementStyle.backgroundImage = background.image || "";
1469
+ elementStyle.backgroundPosition = background.position || "";
1470
+ elementStyle.backgroundRepeat = background.repeat || "";
1471
+ elementStyle.backgroundSize = background.size || "";
1472
+ }
1495
1473
  _initCover() {
1496
1474
  const options = this.container.actualOptions,
1497
1475
  cover = options.backgroundMask.cover,
@@ -1507,6 +1485,17 @@ class Canvas {
1507
1485
  this._coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
1508
1486
  }
1509
1487
  }
1488
+ _initPlugins() {
1489
+ this._resizePlugins = [];
1490
+ for (const [, plugin] of this.container.plugins) {
1491
+ if (plugin.resize) {
1492
+ this._resizePlugins.push(plugin);
1493
+ }
1494
+ if (plugin.particleFillColor || plugin.particleStrokeColor) {
1495
+ this._colorPlugins.push(plugin);
1496
+ }
1497
+ }
1498
+ }
1510
1499
  _initStyle() {
1511
1500
  const element = this.element,
1512
1501
  options = this.container.actualOptions;
@@ -1567,14 +1556,21 @@ class Canvas {
1567
1556
  });
1568
1557
  }
1569
1558
  }
1570
- _paintBase(baseColor) {
1571
- this.draw(ctx => {
1572
- paintBase(ctx, this.size, baseColor);
1573
- });
1559
+ _initUpdaters() {
1560
+ this._preDrawUpdaters = [];
1561
+ this._postDrawUpdaters = [];
1562
+ for (const updater of this.container.particles.updaters) {
1563
+ if (updater.afterDraw) {
1564
+ this._postDrawUpdaters.push(updater);
1565
+ }
1566
+ if (updater.getColorStyles || updater.getTransformValues || updater.beforeDraw) {
1567
+ this._preDrawUpdaters.push(updater);
1568
+ }
1569
+ }
1574
1570
  }
1575
- _paintImage(image, opacity) {
1571
+ _paint() {
1576
1572
  this.draw(ctx => {
1577
- paintImage(ctx, this.size, image, opacity);
1573
+ paintCanvas(ctx, this.size, this.container.actualOptions, this._coverColorStyle);
1578
1574
  });
1579
1575
  }
1580
1576
  _repairStyle() {
@@ -1585,7 +1581,7 @@ class Canvas {
1585
1581
  }
1586
1582
  (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1587
1583
  this._initStyle();
1588
- this.initBackground();
1584
+ this._initBackground();
1589
1585
  (_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(element, {
1590
1586
  attributes: true
1591
1587
  });
@@ -1603,6 +1599,30 @@ class Canvas {
1603
1599
  element.style.width = originalStyle.width;
1604
1600
  element.style.height = originalStyle.height;
1605
1601
  }
1602
+ _resize() {
1603
+ if (!this.element) {
1604
+ return;
1605
+ }
1606
+ const container = this.container,
1607
+ pxRatio = container.retina.pixelRatio,
1608
+ size = container.canvas.size,
1609
+ newSize = {
1610
+ width: this.element.offsetWidth * pxRatio,
1611
+ height: this.element.offsetHeight * pxRatio
1612
+ };
1613
+ if (newSize.height === size.height && newSize.width === size.width && newSize.height === this.element.height && newSize.width === this.element.width) {
1614
+ return;
1615
+ }
1616
+ const oldSize = Object.assign({}, size);
1617
+ this.element.width = size.width = this.element.offsetWidth * pxRatio;
1618
+ this.element.height = size.height = this.element.offsetHeight * pxRatio;
1619
+ if (this.container.started) {
1620
+ this.resizeFactor = {
1621
+ width: size.width / oldSize.width,
1622
+ height: size.height / oldSize.height
1623
+ };
1624
+ }
1625
+ }
1606
1626
  _setFullScreenStyle() {
1607
1627
  const element = this.element;
1608
1628
  if (!element) {
@@ -1641,28 +1661,28 @@ class EventListeners {
1641
1661
  this.container = container;
1642
1662
  this.canPush = true;
1643
1663
  this.handlers = {
1644
- mouseMove: e => this.mouseTouchMove(e),
1645
- touchStart: e => this.mouseTouchMove(e),
1646
- touchMove: e => this.mouseTouchMove(e),
1647
- touchEnd: () => this.mouseTouchFinish(),
1648
- mouseLeave: () => this.mouseTouchFinish(),
1649
- touchCancel: () => this.mouseTouchFinish(),
1650
- touchEndClick: e => this.mouseTouchClick(e),
1651
- mouseUp: e => this.mouseTouchClick(e),
1652
- mouseDown: () => this.mouseDown(),
1653
- visibilityChange: () => this.handleVisibilityChange(),
1654
- themeChange: e => this.handleThemeChange(e),
1655
- oldThemeChange: e => this.handleThemeChange(e),
1656
- resize: () => this.handleWindowResize()
1664
+ mouseMove: e => this._mouseTouchMove(e),
1665
+ touchStart: e => this._mouseTouchMove(e),
1666
+ touchMove: e => this._mouseTouchMove(e),
1667
+ touchEnd: () => this._mouseTouchFinish(),
1668
+ mouseLeave: () => this._mouseTouchFinish(),
1669
+ touchCancel: () => this._mouseTouchFinish(),
1670
+ touchEndClick: e => this._mouseTouchClick(e),
1671
+ mouseUp: e => this._mouseTouchClick(e),
1672
+ mouseDown: () => this._mouseDown(),
1673
+ visibilityChange: () => this._handleVisibilityChange(),
1674
+ themeChange: e => this._handleThemeChange(e),
1675
+ oldThemeChange: e => this._handleThemeChange(e),
1676
+ resize: () => this._handleWindowResize()
1657
1677
  };
1658
1678
  }
1659
1679
  addListeners() {
1660
- this.manageListeners(true);
1680
+ this._manageListeners(true);
1661
1681
  }
1662
1682
  removeListeners() {
1663
- this.manageListeners(false);
1683
+ this._manageListeners(false);
1664
1684
  }
1665
- doMouseTouchClick(e) {
1685
+ _doMouseTouchClick(e) {
1666
1686
  const container = this.container,
1667
1687
  options = container.actualOptions;
1668
1688
  if (this.canPush) {
@@ -1674,16 +1694,16 @@ class EventListeners {
1674
1694
  mouseInteractivity.clickPosition = Object.assign({}, mousePos);
1675
1695
  mouseInteractivity.clickTime = new Date().getTime();
1676
1696
  const onClick = options.interactivity.events.onClick;
1677
- executeOnSingleOrMultiple(onClick.mode, mode => this.handleClickMode(mode));
1697
+ executeOnSingleOrMultiple(onClick.mode, mode => this._handleClickMode(mode));
1678
1698
  }
1679
1699
  if (e.type === "touchend") {
1680
- setTimeout(() => this.mouseTouchFinish(), 500);
1700
+ setTimeout(() => this._mouseTouchFinish(), 500);
1681
1701
  }
1682
1702
  }
1683
- handleClickMode(mode) {
1703
+ _handleClickMode(mode) {
1684
1704
  this.container.handleClickMode(mode);
1685
1705
  }
1686
- handleThemeChange(e) {
1706
+ _handleThemeChange(e) {
1687
1707
  const mediaEvent = e,
1688
1708
  container = this.container,
1689
1709
  options = container.options,
@@ -1694,18 +1714,17 @@ class EventListeners {
1694
1714
  container.loadTheme(themeName);
1695
1715
  }
1696
1716
  }
1697
- handleVisibilityChange() {
1717
+ _handleVisibilityChange() {
1698
1718
  const container = this.container,
1699
1719
  options = container.actualOptions;
1700
- this.mouseTouchFinish();
1720
+ this._mouseTouchFinish();
1701
1721
  if (!options.pauseOnBlur) {
1702
1722
  return;
1703
1723
  }
1704
- if (document === null || document === void 0 ? void 0 : document.hidden) {
1705
- container.pageHidden = true;
1724
+ container.pageHidden = (document === null || document === void 0 ? void 0 : document.hidden) || false;
1725
+ if (container.pageHidden) {
1706
1726
  container.pause();
1707
1727
  } else {
1708
- container.pageHidden = false;
1709
1728
  if (container.getAnimationStatus()) {
1710
1729
  container.play(true);
1711
1730
  } else {
@@ -1713,7 +1732,7 @@ class EventListeners {
1713
1732
  }
1714
1733
  }
1715
1734
  }
1716
- handleWindowResize() {
1735
+ _handleWindowResize() {
1717
1736
  if (this.resizeTimeout) {
1718
1737
  clearTimeout(this.resizeTimeout);
1719
1738
  delete this.resizeTimeout;
@@ -1723,7 +1742,7 @@ class EventListeners {
1723
1742
  return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize();
1724
1743
  }, this.container.actualOptions.interactivity.events.resize.delay * 1000);
1725
1744
  }
1726
- manageListeners(add) {
1745
+ _manageInteractivityEvents(add) {
1727
1746
  var _a;
1728
1747
  const handlers = this.handlers,
1729
1748
  container = this.container,
@@ -1739,18 +1758,6 @@ class EventListeners {
1739
1758
  } else {
1740
1759
  container.interactivity.element = container.canvas.element;
1741
1760
  }
1742
- const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
1743
- if (mediaMatch) {
1744
- if (mediaMatch.addEventListener !== undefined) {
1745
- manageListener(mediaMatch, "change", handlers.themeChange, add);
1746
- } else if (mediaMatch.addListener !== undefined) {
1747
- if (add) {
1748
- mediaMatch.addListener(handlers.oldThemeChange);
1749
- } else {
1750
- mediaMatch.removeListener(handlers.oldThemeChange);
1751
- }
1752
- }
1753
- }
1754
1761
  const interactivityEl = container.interactivity.element;
1755
1762
  if (!interactivityEl) {
1756
1763
  return;
@@ -1773,33 +1780,66 @@ class EventListeners {
1773
1780
  if (container.canvas.element) {
1774
1781
  container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none";
1775
1782
  }
1776
- if (options.interactivity.events.resize) {
1777
- if (typeof ResizeObserver !== "undefined") {
1778
- if (this.resizeObserver && !add) {
1779
- if (container.canvas.element) {
1780
- this.resizeObserver.unobserve(container.canvas.element);
1781
- }
1782
- this.resizeObserver.disconnect();
1783
- delete this.resizeObserver;
1784
- } else if (!this.resizeObserver && add && container.canvas.element) {
1785
- this.resizeObserver = new ResizeObserver(entries => {
1786
- const entry = entries.find(e => e.target === container.canvas.element);
1787
- if (!entry) {
1788
- return;
1789
- }
1790
- this.handleWindowResize();
1791
- });
1792
- this.resizeObserver.observe(container.canvas.element);
1793
- }
1783
+ }
1784
+ _manageListeners(add) {
1785
+ this._manageMediaEvents(add);
1786
+ this._manageInteractivityEvents(add);
1787
+ this._manageResizeEvent(add);
1788
+ this._manageVisibilityEvent(add);
1789
+ }
1790
+ _manageMediaEvents(add) {
1791
+ const handlers = this.handlers,
1792
+ mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
1793
+ if (!mediaMatch) {
1794
+ return;
1795
+ }
1796
+ if (mediaMatch.addEventListener !== undefined) {
1797
+ manageListener(mediaMatch, "change", handlers.themeChange, add);
1798
+ return;
1799
+ }
1800
+ if (mediaMatch.addListener !== undefined) {
1801
+ if (add) {
1802
+ mediaMatch.addListener(handlers.oldThemeChange);
1794
1803
  } else {
1795
- manageListener(window, resizeEvent, handlers.resize, add);
1804
+ mediaMatch.removeListener(handlers.oldThemeChange);
1796
1805
  }
1797
1806
  }
1798
- if (document) {
1799
- manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
1807
+ }
1808
+ _manageResizeEvent(add) {
1809
+ const handlers = this.handlers,
1810
+ container = this.container,
1811
+ options = container.actualOptions;
1812
+ if (!options.interactivity.events.resize) {
1813
+ return;
1814
+ }
1815
+ if (typeof ResizeObserver === "undefined") {
1816
+ manageListener(window, resizeEvent, handlers.resize, add);
1817
+ return;
1818
+ }
1819
+ if (this.resizeObserver && !add) {
1820
+ if (container.canvas.element) {
1821
+ this.resizeObserver.unobserve(container.canvas.element);
1822
+ }
1823
+ this.resizeObserver.disconnect();
1824
+ delete this.resizeObserver;
1825
+ } else if (!this.resizeObserver && add && container.canvas.element) {
1826
+ this.resizeObserver = new ResizeObserver(entries => {
1827
+ const entry = entries.find(e => e.target === container.canvas.element);
1828
+ if (!entry) {
1829
+ return;
1830
+ }
1831
+ this._handleWindowResize();
1832
+ });
1833
+ this.resizeObserver.observe(container.canvas.element);
1800
1834
  }
1801
1835
  }
1802
- mouseDown() {
1836
+ _manageVisibilityEvent(add) {
1837
+ if (!document) {
1838
+ return;
1839
+ }
1840
+ manageListener(document, visibilityChangeEvent, this.handlers.visibilityChange, add);
1841
+ }
1842
+ _mouseDown() {
1803
1843
  const interactivity = this.container.interactivity;
1804
1844
  if (interactivity) {
1805
1845
  const mouse = interactivity.mouse;
@@ -1807,7 +1847,7 @@ class EventListeners {
1807
1847
  mouse.downPosition = mouse.position;
1808
1848
  }
1809
1849
  }
1810
- mouseTouchClick(e) {
1850
+ _mouseTouchClick(e) {
1811
1851
  const container = this.container,
1812
1852
  options = container.actualOptions,
1813
1853
  mouse = container.interactivity.mouse;
@@ -1827,11 +1867,11 @@ class EventListeners {
1827
1867
  }
1828
1868
  }
1829
1869
  if (!handled) {
1830
- this.doMouseTouchClick(e);
1870
+ this._doMouseTouchClick(e);
1831
1871
  }
1832
1872
  mouse.clicking = false;
1833
1873
  }
1834
- mouseTouchFinish() {
1874
+ _mouseTouchFinish() {
1835
1875
  const interactivity = this.container.interactivity;
1836
1876
  if (!interactivity) {
1837
1877
  return;
@@ -1844,7 +1884,7 @@ class EventListeners {
1844
1884
  mouse.inside = false;
1845
1885
  mouse.clicking = false;
1846
1886
  }
1847
- mouseTouchMove(e) {
1887
+ _mouseTouchMove(e) {
1848
1888
  var _a, _b, _c, _d, _e, _f, _g;
1849
1889
  const container = this.container,
1850
1890
  options = container.actualOptions;
@@ -2313,14 +2353,15 @@ class Interactivity {
2313
2353
 
2314
2354
  class ManualParticle {
2315
2355
  load(data) {
2316
- var _a, _b;
2356
+ var _a, _b, _c;
2317
2357
  if (!data) {
2318
2358
  return;
2319
2359
  }
2320
2360
  if (data.position !== undefined) {
2321
2361
  this.position = {
2322
2362
  x: (_a = data.position.x) !== null && _a !== void 0 ? _a : 50,
2323
- y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50
2363
+ y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50,
2364
+ mode: (_c = data.position.mode) !== null && _c !== void 0 ? _c : "percent"
2324
2365
  };
2325
2366
  }
2326
2367
  if (data.options !== undefined) {
@@ -2519,6 +2560,59 @@ class CollisionsOverlap {
2519
2560
  }
2520
2561
  }
2521
2562
  }
2563
+ ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/AnimationOptions.js
2564
+
2565
+ class AnimationOptions {
2566
+ constructor() {
2567
+ this.count = 0;
2568
+ this.enable = false;
2569
+ this.speed = 1;
2570
+ this.decay = 0;
2571
+ this.sync = false;
2572
+ }
2573
+ load(data) {
2574
+ if (!data) {
2575
+ return;
2576
+ }
2577
+ if (data.count !== undefined) {
2578
+ this.count = setRangeValue(data.count);
2579
+ }
2580
+ if (data.enable !== undefined) {
2581
+ this.enable = data.enable;
2582
+ }
2583
+ if (data.speed !== undefined) {
2584
+ this.speed = setRangeValue(data.speed);
2585
+ }
2586
+ if (data.decay !== undefined) {
2587
+ this.decay = setRangeValue(data.decay);
2588
+ }
2589
+ if (data.sync !== undefined) {
2590
+ this.sync = data.sync;
2591
+ }
2592
+ }
2593
+ }
2594
+ class RangedAnimationOptions extends AnimationOptions {
2595
+ constructor() {
2596
+ super();
2597
+ this.mode = "auto";
2598
+ this.startValue = "random";
2599
+ }
2600
+ load(data) {
2601
+ super.load(data);
2602
+ if (!data) {
2603
+ return;
2604
+ }
2605
+ if (data.minimumValue !== undefined) {
2606
+ this.minimumValue = data.minimumValue;
2607
+ }
2608
+ if (data.mode !== undefined) {
2609
+ this.mode = data.mode;
2610
+ }
2611
+ if (data.startValue !== undefined) {
2612
+ this.startValue = data.startValue;
2613
+ }
2614
+ }
2615
+ }
2522
2616
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Random.js
2523
2617
  class Random {
2524
2618
  constructor() {
@@ -2540,6 +2634,8 @@ class Random {
2540
2634
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/ValueWithRandom.js
2541
2635
 
2542
2636
 
2637
+
2638
+
2543
2639
  class ValueWithRandom {
2544
2640
  constructor() {
2545
2641
  this.random = new Random();
@@ -2559,6 +2655,44 @@ class ValueWithRandom {
2559
2655
  }
2560
2656
  }
2561
2657
  }
2658
+ class AnimationValueWithRandom extends ValueWithRandom {
2659
+ constructor() {
2660
+ super();
2661
+ this.animation = new AnimationOptions();
2662
+ }
2663
+ get anim() {
2664
+ return this.animation;
2665
+ }
2666
+ set anim(value) {
2667
+ this.animation = value;
2668
+ }
2669
+ load(data) {
2670
+ var _a;
2671
+ super.load(data);
2672
+ if (!data) {
2673
+ return;
2674
+ }
2675
+ const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
2676
+ if (animation !== undefined) {
2677
+ this.animation.load(animation);
2678
+ }
2679
+ }
2680
+ }
2681
+ class RangedAnimationValueWithRandom extends AnimationValueWithRandom {
2682
+ constructor() {
2683
+ super();
2684
+ this.animation = new RangedAnimationOptions();
2685
+ }
2686
+ load(data) {
2687
+ super.load(data);
2688
+ if (!data) {
2689
+ return;
2690
+ }
2691
+ if (data.animation !== undefined) {
2692
+ this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
2693
+ }
2694
+ }
2695
+ }
2562
2696
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js
2563
2697
 
2564
2698
  class ParticlesBounceFactor extends ValueWithRandom {
@@ -2963,47 +3097,13 @@ class Move {
2963
3097
  }
2964
3098
  }
2965
3099
  }
2966
- ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/AnimationOptions.js
2967
-
2968
- class AnimationOptions {
2969
- constructor() {
2970
- this.count = 0;
2971
- this.enable = false;
2972
- this.speed = 1;
2973
- this.decay = 0;
2974
- this.sync = false;
2975
- }
2976
- load(data) {
2977
- if (!data) {
2978
- return;
2979
- }
2980
- if (data.count !== undefined) {
2981
- this.count = setRangeValue(data.count);
2982
- }
2983
- if (data.enable !== undefined) {
2984
- this.enable = data.enable;
2985
- }
2986
- if (data.speed !== undefined) {
2987
- this.speed = setRangeValue(data.speed);
2988
- }
2989
- if (data.decay !== undefined) {
2990
- this.decay = setRangeValue(data.decay);
2991
- }
2992
- if (data.sync !== undefined) {
2993
- this.sync = data.sync;
2994
- }
2995
- }
2996
- }
2997
3100
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js
2998
3101
 
2999
- class OpacityAnimation extends AnimationOptions {
3102
+ class OpacityAnimation extends RangedAnimationOptions {
3000
3103
  constructor() {
3001
3104
  super();
3002
3105
  this.destroy = "none";
3003
- this.enable = false;
3004
3106
  this.speed = 2;
3005
- this.startValue = "random";
3006
- this.sync = false;
3007
3107
  }
3008
3108
  get opacity_min() {
3009
3109
  return this.minimumValue;
@@ -3012,34 +3112,22 @@ class OpacityAnimation extends AnimationOptions {
3012
3112
  this.minimumValue = value;
3013
3113
  }
3014
3114
  load(data) {
3015
- var _a;
3115
+ if ((data === null || data === void 0 ? void 0 : data.opacity_min) !== undefined && data.minimumValue === undefined) {
3116
+ data.minimumValue = data.opacity_min;
3117
+ }
3118
+ super.load(data);
3016
3119
  if (!data) {
3017
3120
  return;
3018
3121
  }
3019
- super.load(data);
3020
3122
  if (data.destroy !== undefined) {
3021
3123
  this.destroy = data.destroy;
3022
3124
  }
3023
- if (data.enable !== undefined) {
3024
- this.enable = data.enable;
3025
- }
3026
- this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.opacity_min;
3027
- if (data.speed !== undefined) {
3028
- this.speed = data.speed;
3029
- }
3030
- if (data.startValue !== undefined) {
3031
- this.startValue = data.startValue;
3032
- }
3033
- if (data.sync !== undefined) {
3034
- this.sync = data.sync;
3035
- }
3036
3125
  }
3037
3126
  }
3038
3127
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Opacity/Opacity.js
3039
3128
 
3040
3129
 
3041
-
3042
- class Opacity extends ValueWithRandom {
3130
+ class Opacity extends RangedAnimationValueWithRandom {
3043
3131
  constructor() {
3044
3132
  super();
3045
3133
  this.animation = new OpacityAnimation();
@@ -3052,18 +3140,6 @@ class Opacity extends ValueWithRandom {
3052
3140
  set anim(value) {
3053
3141
  this.animation = value;
3054
3142
  }
3055
- load(data) {
3056
- var _a;
3057
- if (!data) {
3058
- return;
3059
- }
3060
- super.load(data);
3061
- const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
3062
- if (animation !== undefined) {
3063
- this.animation.load(animation);
3064
- this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
3065
- }
3066
- }
3067
3143
  }
3068
3144
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Number/ParticlesDensity.js
3069
3145
  class ParticlesDensity {
@@ -3174,106 +3250,45 @@ class Shadow {
3174
3250
  }
3175
3251
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Shape/Shape.js
3176
3252
 
3177
- const charKey = "character",
3178
- charAltKey = "char",
3179
- imageKey = "image",
3180
- imageAltKey = "images",
3181
- polygonKey = "polygon",
3182
- polygonAltKey = "star";
3183
3253
  class Shape {
3184
3254
  constructor() {
3185
3255
  this.options = {};
3186
3256
  this.type = "circle";
3257
+ this.close = true;
3258
+ this.fill = true;
3187
3259
  }
3188
- get character() {
3189
- var _a;
3190
- return (_a = this.options[charKey]) !== null && _a !== void 0 ? _a : this.options[charAltKey];
3191
- }
3192
- set character(value) {
3193
- this.options[charAltKey] = this.options[charKey] = value;
3194
- }
3195
- get custom() {
3196
- return this.options;
3197
- }
3198
- set custom(value) {
3199
- this.options = value;
3200
- }
3201
- get image() {
3202
- var _a;
3203
- return (_a = this.options[imageKey]) !== null && _a !== void 0 ? _a : this.options[imageAltKey];
3204
- }
3205
- set image(value) {
3206
- this.options[imageAltKey] = this.options[imageKey] = value;
3207
- }
3208
- get images() {
3209
- return this.image;
3210
- }
3211
- set images(value) {
3212
- this.image = value;
3213
- }
3214
- get polygon() {
3215
- var _a;
3216
- return (_a = this.options[polygonKey]) !== null && _a !== void 0 ? _a : this.options[polygonAltKey];
3217
- }
3218
- set polygon(value) {
3219
- this.options[polygonAltKey] = this.options[polygonKey] = value;
3220
- }
3221
- get stroke() {
3222
- return [];
3223
- }
3224
- set stroke(_value) {}
3225
3260
  load(data) {
3226
- var _a, _b, _c;
3261
+ var _a;
3227
3262
  if (!data) {
3228
3263
  return;
3229
3264
  }
3230
- const options = (_a = data.options) !== null && _a !== void 0 ? _a : data.custom;
3265
+ if (data.close !== undefined) {
3266
+ this.close = data.close;
3267
+ }
3268
+ if (data.fill !== undefined) {
3269
+ this.fill = data.fill;
3270
+ }
3271
+ const options = data.options;
3231
3272
  if (options !== undefined) {
3232
3273
  for (const shape in options) {
3233
3274
  const item = options[shape];
3234
3275
  if (item) {
3235
- this.options[shape] = deepExtend((_b = this.options[shape]) !== null && _b !== void 0 ? _b : {}, item);
3276
+ this.options[shape] = deepExtend((_a = this.options[shape]) !== null && _a !== void 0 ? _a : {}, item);
3236
3277
  }
3237
3278
  }
3238
3279
  }
3239
- this.loadShape(data.character, charKey, charAltKey, true);
3240
- this.loadShape(data.polygon, polygonKey, polygonAltKey, false);
3241
- this.loadShape((_c = data.image) !== null && _c !== void 0 ? _c : data.images, imageKey, imageAltKey, true);
3242
3280
  if (data.type !== undefined) {
3243
3281
  this.type = data.type;
3244
3282
  }
3245
3283
  }
3246
- loadShape(item, mainKey, altKey, altOverride) {
3247
- var _a, _b;
3248
- if (!item) {
3249
- return;
3250
- }
3251
- const isArray = item instanceof Array;
3252
- const emptyValue = isArray ? [] : {},
3253
- mainDifferentValues = isArray !== this.options[mainKey] instanceof Array,
3254
- altDifferentValues = isArray !== this.options[altKey] instanceof Array;
3255
- if (mainDifferentValues) {
3256
- this.options[mainKey] = emptyValue;
3257
- }
3258
- if (altDifferentValues && altOverride) {
3259
- this.options[altKey] = emptyValue;
3260
- }
3261
- this.options[mainKey] = deepExtend((_a = this.options[mainKey]) !== null && _a !== void 0 ? _a : emptyValue, item);
3262
- if (!this.options[altKey] || altOverride) {
3263
- this.options[altKey] = deepExtend((_b = this.options[altKey]) !== null && _b !== void 0 ? _b : emptyValue, item);
3264
- }
3265
- }
3266
3284
  }
3267
3285
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Size/SizeAnimation.js
3268
3286
 
3269
- class SizeAnimation extends AnimationOptions {
3287
+ class SizeAnimation extends RangedAnimationOptions {
3270
3288
  constructor() {
3271
3289
  super();
3272
3290
  this.destroy = "none";
3273
- this.enable = false;
3274
3291
  this.speed = 5;
3275
- this.startValue = "random";
3276
- this.sync = false;
3277
3292
  }
3278
3293
  get size_min() {
3279
3294
  return this.minimumValue;
@@ -3282,7 +3297,9 @@ class SizeAnimation extends AnimationOptions {
3282
3297
  this.minimumValue = value;
3283
3298
  }
3284
3299
  load(data) {
3285
- var _a;
3300
+ if ((data === null || data === void 0 ? void 0 : data.size_min) !== undefined && data.minimumValue === undefined) {
3301
+ data.minimumValue = data.size_min;
3302
+ }
3286
3303
  super.load(data);
3287
3304
  if (!data) {
3288
3305
  return;
@@ -3290,26 +3307,12 @@ class SizeAnimation extends AnimationOptions {
3290
3307
  if (data.destroy !== undefined) {
3291
3308
  this.destroy = data.destroy;
3292
3309
  }
3293
- if (data.enable !== undefined) {
3294
- this.enable = data.enable;
3295
- }
3296
- this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.size_min;
3297
- if (data.speed !== undefined) {
3298
- this.speed = data.speed;
3299
- }
3300
- if (data.startValue !== undefined) {
3301
- this.startValue = data.startValue;
3302
- }
3303
- if (data.sync !== undefined) {
3304
- this.sync = data.sync;
3305
- }
3306
3310
  }
3307
3311
  }
3308
3312
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Size/Size.js
3309
3313
 
3310
3314
 
3311
-
3312
- class Size extends ValueWithRandom {
3315
+ class Size extends RangedAnimationValueWithRandom {
3313
3316
  constructor() {
3314
3317
  super();
3315
3318
  this.animation = new SizeAnimation();
@@ -3319,20 +3322,8 @@ class Size extends ValueWithRandom {
3319
3322
  get anim() {
3320
3323
  return this.animation;
3321
3324
  }
3322
- set anim(value) {
3323
- this.animation = value;
3324
- }
3325
- load(data) {
3326
- var _a;
3327
- super.load(data);
3328
- if (!data) {
3329
- return;
3330
- }
3331
- const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
3332
- if (animation !== undefined) {
3333
- this.animation.load(animation);
3334
- this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
3335
- }
3325
+ set anim(value) {
3326
+ this.animation = value;
3336
3327
  }
3337
3328
  }
3338
3329
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Stroke.js
@@ -3415,7 +3406,7 @@ class ParticlesOptions {
3415
3406
  this.zIndex = new ZIndex();
3416
3407
  }
3417
3408
  load(data) {
3418
- var _a, _b, _c, _d, _e, _f;
3409
+ var _a, _b, _c, _d;
3419
3410
  if (!data) {
3420
3411
  return;
3421
3412
  }
@@ -3447,9 +3438,9 @@ class ParticlesOptions {
3447
3438
  if (data.interactivity !== undefined) {
3448
3439
  this.interactivity = deepExtend({}, data.interactivity);
3449
3440
  }
3450
- const strokeToLoad = (_e = data.stroke) !== null && _e !== void 0 ? _e : (_f = data.shape) === null || _f === void 0 ? void 0 : _f.stroke;
3451
- if (strokeToLoad) {
3452
- this.stroke = executeOnSingleOrMultiple(strokeToLoad, t => {
3441
+ const stroke = data.stroke;
3442
+ if (stroke) {
3443
+ this.stroke = executeOnSingleOrMultiple(stroke, t => {
3453
3444
  const tmp = new Stroke();
3454
3445
  tmp.load(t);
3455
3446
  return tmp;
@@ -3513,6 +3504,7 @@ class Options {
3513
3504
  this.fpsLimit = 120;
3514
3505
  this.interactivity = new Interactivity(engine, container);
3515
3506
  this.manualParticles = [];
3507
+ this.name = "default";
3516
3508
  this.particles = loadParticlesOptions(this._engine, this._container);
3517
3509
  this.pauseOnBlur = true;
3518
3510
  this.pauseOnOutsideViewport = true;
@@ -3792,7 +3784,7 @@ class Particle {
3792
3784
  return this._getRollColor((_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.strokeColor));
3793
3785
  }
3794
3786
  init(id, position, overrideOptions, group) {
3795
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3787
+ var _a, _b, _c, _d, _e, _f, _g;
3796
3788
  const container = this.container,
3797
3789
  engine = this._engine;
3798
3790
  this.id = id;
@@ -3844,39 +3836,8 @@ class Particle {
3844
3836
  this.pathGenerator.init(container);
3845
3837
  }
3846
3838
  }
3847
- const zIndexValue = getRangeValue(this.options.zIndex.value);
3848
3839
  container.retina.initParticle(this);
3849
- const sizeOptions = this.options.size,
3850
- sizeRange = sizeOptions.value,
3851
- sizeAnimation = sizeOptions.animation;
3852
- this.size = {
3853
- enable: sizeOptions.animation.enable,
3854
- value: getRangeValue(sizeOptions.value) * container.retina.pixelRatio,
3855
- max: getRangeMax(sizeRange) * pxRatio,
3856
- min: getRangeMin(sizeRange) * pxRatio,
3857
- loops: 0,
3858
- maxLoops: getRangeValue(sizeOptions.animation.count)
3859
- };
3860
- if (sizeAnimation.enable) {
3861
- this.size.status = "increasing";
3862
- this.size.decay = 1 - getRangeValue(sizeAnimation.decay);
3863
- switch (sizeAnimation.startValue) {
3864
- case "min":
3865
- this.size.value = this.size.min;
3866
- this.size.status = "increasing";
3867
- break;
3868
- case "random":
3869
- this.size.value = randomInRange(this.size);
3870
- this.size.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
3871
- break;
3872
- case "max":
3873
- default:
3874
- this.size.value = this.size.max;
3875
- this.size.status = "decreasing";
3876
- break;
3877
- }
3878
- }
3879
- this.size.initialValue = this.size.value;
3840
+ this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
3880
3841
  this.bubble = {
3881
3842
  inRange: false
3882
3843
  };
@@ -3884,30 +3845,10 @@ class Particle {
3884
3845
  inRange: false,
3885
3846
  factor: 1
3886
3847
  };
3887
- this.position = this._calcPosition(container, position, clamp(zIndexValue, 0, container.zLayers));
3888
- this.initialPosition = this.position.copy();
3889
- const canvasSize = container.canvas.size,
3890
- moveCenter = Object.assign({}, this.options.move.center),
3891
- isCenterPercent = moveCenter.mode === "percent";
3892
- this.moveCenter = {
3893
- x: moveCenter.x * (isCenterPercent ? canvasSize.width / 100 : 1),
3894
- y: moveCenter.y * (isCenterPercent ? canvasSize.height / 100 : 1),
3895
- radius: (_f = this.options.move.center.radius) !== null && _f !== void 0 ? _f : 0,
3896
- mode: (_g = this.options.move.center.mode) !== null && _g !== void 0 ? _g : "percent"
3897
- };
3898
- this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
3899
- switch (this.options.move.direction) {
3900
- case "inside":
3901
- this.outType = "inside";
3902
- break;
3903
- case "outside":
3904
- this.outType = "outside";
3905
- break;
3906
- }
3848
+ this._initPosition(position);
3907
3849
  this.initialVelocity = this._calculateVelocity();
3908
3850
  this.velocity = this.initialVelocity.copy();
3909
3851
  this.moveDecay = 1 - getRangeValue(this.options.move.decay);
3910
- this.offset = Vector.origin;
3911
3852
  const particles = container.particles;
3912
3853
  particles.needsSort = particles.needsSort || particles.lastZIndex < this.position.z;
3913
3854
  particles.lastZIndex = this.position.z;
@@ -3933,13 +3874,13 @@ class Particle {
3933
3874
  updater.init(this);
3934
3875
  }
3935
3876
  for (const mover of container.particles.movers) {
3936
- (_h = mover.init) === null || _h === void 0 ? void 0 : _h.call(mover, this);
3877
+ (_f = mover.init) === null || _f === void 0 ? void 0 : _f.call(mover, this);
3937
3878
  }
3938
3879
  if (drawer === null || drawer === void 0 ? void 0 : drawer.particleInit) {
3939
3880
  drawer.particleInit(container, this);
3940
3881
  }
3941
3882
  for (const [, plugin] of container.plugins) {
3942
- (_j = plugin.particleCreated) === null || _j === void 0 ? void 0 : _j.call(plugin, this);
3883
+ (_g = plugin.particleCreated) === null || _g === void 0 ? void 0 : _g.call(plugin, this);
3943
3884
  }
3944
3885
  }
3945
3886
  isInsideCanvas() {
@@ -4064,10 +4005,39 @@ class Particle {
4064
4005
  }
4065
4006
  return color;
4066
4007
  }
4008
+ _initPosition(position) {
4009
+ var _a, _b;
4010
+ const container = this.container,
4011
+ zIndexValue = getRangeValue(this.options.zIndex.value);
4012
+ this.position = this._calcPosition(container, position, clamp(zIndexValue, 0, container.zLayers));
4013
+ this.initialPosition = this.position.copy();
4014
+ const canvasSize = container.canvas.size,
4015
+ moveCenter = Object.assign({}, this.options.move.center),
4016
+ isCenterPercent = moveCenter.mode === "percent";
4017
+ this.moveCenter = {
4018
+ x: moveCenter.x * (isCenterPercent ? canvasSize.width / 100 : 1),
4019
+ y: moveCenter.y * (isCenterPercent ? canvasSize.height / 100 : 1),
4020
+ radius: (_a = this.options.move.center.radius) !== null && _a !== void 0 ? _a : 0,
4021
+ mode: (_b = this.options.move.center.mode) !== null && _b !== void 0 ? _b : "percent"
4022
+ };
4023
+ this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
4024
+ switch (this.options.move.direction) {
4025
+ case "inside":
4026
+ this.outType = "inside";
4027
+ break;
4028
+ case "outside":
4029
+ this.outType = "outside";
4030
+ break;
4031
+ }
4032
+ this.offset = Vector.origin;
4033
+ }
4067
4034
  _loadShapeData(shapeOptions, reduceDuplicates) {
4068
4035
  const shapeData = shapeOptions.options[this.shape];
4069
4036
  if (shapeData) {
4070
- return deepExtend({}, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
4037
+ return deepExtend({
4038
+ close: shapeOptions.close,
4039
+ fill: shapeOptions.fill
4040
+ }, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
4071
4041
  }
4072
4042
  }
4073
4043
  }
@@ -4250,10 +4220,10 @@ class Particles {
4250
4220
  const container = this.container,
4251
4221
  options = container.actualOptions;
4252
4222
  for (const particle of options.manualParticles) {
4253
- this.addParticle(calcPositionFromSize({
4223
+ this.addParticle(particle.position ? particle.position.mode === "precise" ? particle.position : calcPositionFromSize({
4254
4224
  size: container.canvas.size,
4255
4225
  position: particle.position
4256
- }), particle.options);
4226
+ }) : undefined, particle.options);
4257
4227
  }
4258
4228
  }
4259
4229
  addParticle(position, overrideOptions, group, initializer) {
@@ -4357,22 +4327,9 @@ class Particles {
4357
4327
  }
4358
4328
  let deleted = 0;
4359
4329
  for (let i = index; deleted < quantity && i < this.count; i++) {
4360
- const particle = this.array[i];
4361
- if (!particle || particle.group !== group) {
4362
- continue;
4330
+ if (this._removeParticle(i--, group, override)) {
4331
+ deleted++;
4363
4332
  }
4364
- particle.destroy(override);
4365
- this.array.splice(i--, 1);
4366
- const zIdx = this.zArray.indexOf(particle);
4367
- this.zArray.splice(zIdx, 1);
4368
- this.pool.push(particle);
4369
- deleted++;
4370
- this._engine.dispatchEvent("particleRemoved", {
4371
- container: this.container,
4372
- data: {
4373
- particle
4374
- }
4375
- });
4376
4333
  }
4377
4334
  }
4378
4335
  removeQuantity(quantity, group) {
@@ -4493,6 +4450,24 @@ class Particles {
4493
4450
  return;
4494
4451
  }
4495
4452
  }
4453
+ _removeParticle(index, group, override) {
4454
+ const particle = this.array[index];
4455
+ if (!particle || particle.group !== group) {
4456
+ return false;
4457
+ }
4458
+ particle.destroy(override);
4459
+ this.array.splice(index, 1);
4460
+ const zIdx = this.zArray.indexOf(particle);
4461
+ this.zArray.splice(zIdx, 1);
4462
+ this.pool.push(particle);
4463
+ this._engine.dispatchEvent("particleRemoved", {
4464
+ container: this.container,
4465
+ data: {
4466
+ particle
4467
+ }
4468
+ });
4469
+ return true;
4470
+ }
4496
4471
  }
4497
4472
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Retina.js
4498
4473
 
@@ -4787,9 +4762,6 @@ class Container {
4787
4762
  }
4788
4763
  this.retina.init();
4789
4764
  await this.canvas.init();
4790
- this.updateActualOptions();
4791
- this.canvas.initBackground();
4792
- this.canvas.resize();
4793
4765
  this.zLayers = this.actualOptions.zLayers;
4794
4766
  this.duration = getRangeValue(this.actualOptions.duration) * 1000;
4795
4767
  this._delay = getRangeValue(this.actualOptions.delay) * 1000;
@@ -4992,158 +4964,48 @@ class Container {
4992
4964
  }
4993
4965
  }
4994
4966
  }
4995
- ;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Loader.js
4996
-
4997
-
4998
-
4999
-
5000
- async function getDataFromUrl(jsonUrl, index) {
5001
- const url = itemFromSingleOrMultiple(jsonUrl, index);
5002
- if (!url) {
5003
- return;
5004
- }
5005
- const response = await fetch(url);
5006
- if (response.ok) {
5007
- return response.json();
5008
- }
5009
- console.error(`tsParticles - Error ${response.status} while retrieving config file`);
5010
- }
5011
- class Loader {
5012
- constructor(engine) {
5013
- this._engine = engine;
4967
+ ;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/EventDispatcher.js
4968
+ class EventDispatcher {
4969
+ constructor() {
4970
+ this._listeners = new Map();
5014
4971
  }
5015
- load(tagId, options, index) {
5016
- const params = {
5017
- index,
5018
- remote: false
5019
- };
5020
- if (typeof tagId === "string") {
5021
- params.tagId = tagId;
5022
- } else {
5023
- params.options = tagId;
5024
- }
5025
- if (typeof options === "number") {
5026
- params.index = options;
5027
- } else {
5028
- params.options = options !== null && options !== void 0 ? options : params.options;
4972
+ addEventListener(type, listener) {
4973
+ var _a;
4974
+ this.removeEventListener(type, listener);
4975
+ if (!this._listeners.get(type)) {
4976
+ this._listeners.set(type, []);
5029
4977
  }
5030
- return this.loadOptions(params);
4978
+ (_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.push(listener);
5031
4979
  }
5032
- async loadJSON(tagId, jsonUrl, index) {
5033
- let url, id;
5034
- if (typeof jsonUrl === "number" || jsonUrl === undefined) {
5035
- url = tagId;
5036
- } else {
5037
- id = tagId;
5038
- url = jsonUrl;
5039
- }
5040
- return this.loadRemoteOptions({
5041
- tagId: id,
5042
- url,
5043
- index,
5044
- remote: true
5045
- });
4980
+ dispatchEvent(type, args) {
4981
+ var _a;
4982
+ (_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(handler => handler(args));
5046
4983
  }
5047
- async loadOptions(params) {
5048
- var _a, _b, _c;
5049
- const tagId = (_a = params.tagId) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(getRandom() * 10000)}`,
5050
- {
5051
- index,
5052
- url: jsonUrl,
5053
- remote
5054
- } = params,
5055
- options = remote ? await getDataFromUrl(jsonUrl, index) : params.options;
5056
- let domContainer = (_b = params.element) !== null && _b !== void 0 ? _b : document.getElementById(tagId);
5057
- if (!domContainer) {
5058
- domContainer = document.createElement("div");
5059
- domContainer.id = tagId;
5060
- (_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
5061
- }
5062
- const currentOptions = itemFromSingleOrMultiple(options, index),
5063
- dom = this._engine.dom(),
5064
- oldIndex = dom.findIndex(v => v.id === tagId);
5065
- if (oldIndex >= 0) {
5066
- const old = this._engine.domItem(oldIndex);
5067
- if (old && !old.destroyed) {
5068
- old.destroy();
5069
- dom.splice(oldIndex, 1);
5070
- }
5071
- }
5072
- let canvasEl;
5073
- if (domContainer.tagName.toLowerCase() === "canvas") {
5074
- canvasEl = domContainer;
5075
- canvasEl.dataset[generatedAttribute] = "false";
5076
- } else {
5077
- const existingCanvases = domContainer.getElementsByTagName("canvas");
5078
- if (existingCanvases.length) {
5079
- canvasEl = existingCanvases[0];
5080
- canvasEl.dataset[generatedAttribute] = "false";
5081
- } else {
5082
- canvasEl = document.createElement("canvas");
5083
- canvasEl.dataset[generatedAttribute] = "true";
5084
- domContainer.appendChild(canvasEl);
5085
- }
5086
- }
5087
- if (!canvasEl.style.width) {
5088
- canvasEl.style.width = "100%";
5089
- }
5090
- if (!canvasEl.style.height) {
5091
- canvasEl.style.height = "100%";
5092
- }
5093
- const newItem = new Container(this._engine, tagId, currentOptions);
5094
- if (oldIndex >= 0) {
5095
- dom.splice(oldIndex, 0, newItem);
4984
+ hasEventListener(type) {
4985
+ return !!this._listeners.get(type);
4986
+ }
4987
+ removeAllEventListeners(type) {
4988
+ if (!type) {
4989
+ this._listeners = new Map();
5096
4990
  } else {
5097
- dom.push(newItem);
4991
+ this._listeners.delete(type);
5098
4992
  }
5099
- newItem.canvas.loadCanvas(canvasEl);
5100
- await newItem.start();
5101
- return newItem;
5102
- }
5103
- async loadRemoteOptions(params) {
5104
- return this.loadOptions(params);
5105
4993
  }
5106
- async set(id, domContainer, options, index) {
5107
- const params = {
5108
- index,
5109
- remote: false
5110
- };
5111
- if (typeof id === "string") {
5112
- params.tagId = id;
5113
- } else {
5114
- params.element = id;
4994
+ removeEventListener(type, listener) {
4995
+ const arr = this._listeners.get(type);
4996
+ if (!arr) {
4997
+ return;
5115
4998
  }
5116
- if (domContainer instanceof HTMLElement) {
5117
- params.element = domContainer;
5118
- } else {
5119
- params.options = domContainer;
4999
+ const length = arr.length,
5000
+ idx = arr.indexOf(listener);
5001
+ if (idx < 0) {
5002
+ return;
5120
5003
  }
5121
- if (typeof options === "number") {
5122
- params.index = options;
5004
+ if (length === 1) {
5005
+ this._listeners.delete(type);
5123
5006
  } else {
5124
- params.options = options !== null && options !== void 0 ? options : params.options;
5007
+ arr.splice(idx, 1);
5125
5008
  }
5126
- return this.loadOptions(params);
5127
- }
5128
- async setJSON(id, domContainer, jsonUrl, index) {
5129
- let url, newId, newIndex, element;
5130
- if (id instanceof HTMLElement) {
5131
- element = id;
5132
- url = domContainer;
5133
- newIndex = jsonUrl;
5134
- } else {
5135
- newId = id;
5136
- element = domContainer;
5137
- url = jsonUrl;
5138
- newIndex = index;
5139
- }
5140
- return this.loadRemoteOptions({
5141
- tagId: newId,
5142
- url,
5143
- index: newIndex,
5144
- element,
5145
- remote: true
5146
- });
5147
5009
  }
5148
5010
  }
5149
5011
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Plugins.js
@@ -5263,14 +5125,46 @@ class Plugins {
5263
5125
 
5264
5126
 
5265
5127
 
5128
+
5129
+
5130
+
5131
+ async function getDataFromUrl(data) {
5132
+ const url = itemFromSingleOrMultiple(data.url, data.index);
5133
+ if (!url) {
5134
+ return data.fallback;
5135
+ }
5136
+ const response = await fetch(url);
5137
+ if (response.ok) {
5138
+ return response.json();
5139
+ }
5140
+ console.error(`tsParticles - Error ${response.status} while retrieving config file`);
5141
+ return data.fallback;
5142
+ }
5266
5143
  class Engine {
5267
5144
  constructor() {
5145
+ this._configs = new Map();
5268
5146
  this._domArray = [];
5269
5147
  this._eventDispatcher = new EventDispatcher();
5270
- this._initialized = false;
5271
- this._loader = new Loader(this);
5272
5148
  this.plugins = new Plugins(this);
5273
5149
  }
5150
+ get configs() {
5151
+ const res = {};
5152
+ for (const [name, config] of this._configs) {
5153
+ res[name] = config;
5154
+ }
5155
+ return res;
5156
+ }
5157
+ addConfig(nameOrConfig, config) {
5158
+ var _a;
5159
+ if (typeof nameOrConfig === "string") {
5160
+ if (config) {
5161
+ config.name = nameOrConfig;
5162
+ this._configs.set(nameOrConfig, config);
5163
+ }
5164
+ } else {
5165
+ this._configs.set((_a = nameOrConfig.name) !== null && _a !== void 0 ? _a : "default", nameOrConfig);
5166
+ }
5167
+ }
5274
5168
  addEventListener(type, listener) {
5275
5169
  this._eventDispatcher.addEventListener(type, listener);
5276
5170
  }
@@ -5327,19 +5221,64 @@ class Engine {
5327
5221
  }
5328
5222
  dom.splice(index, 1);
5329
5223
  }
5330
- init() {
5331
- if (!this._initialized) {
5332
- this._initialized = true;
5224
+ async load(params) {
5225
+ var _a, _b, _c;
5226
+ const id = (_a = params.id) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(getRandom() * 10000)}`,
5227
+ {
5228
+ index,
5229
+ url
5230
+ } = params,
5231
+ options = url ? await getDataFromUrl({
5232
+ fallback: params.options,
5233
+ index,
5234
+ url: url
5235
+ }) : params.options;
5236
+ let domContainer = (_b = params.element) !== null && _b !== void 0 ? _b : document.getElementById(id);
5237
+ if (!domContainer) {
5238
+ domContainer = document.createElement("div");
5239
+ domContainer.id = id;
5240
+ (_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
5333
5241
  }
5334
- }
5335
- async load(tagId, options) {
5336
- return this._loader.load(tagId, options);
5337
- }
5338
- async loadFromArray(tagId, options, index) {
5339
- return this._loader.load(tagId, options, index);
5340
- }
5341
- async loadJSON(tagId, pathConfigJson, index) {
5342
- return this._loader.loadJSON(tagId, pathConfigJson, index);
5242
+ const currentOptions = itemFromSingleOrMultiple(options, index),
5243
+ dom = this.dom(),
5244
+ oldIndex = dom.findIndex(v => v.id === id);
5245
+ if (oldIndex >= 0) {
5246
+ const old = this.domItem(oldIndex);
5247
+ if (old && !old.destroyed) {
5248
+ old.destroy();
5249
+ dom.splice(oldIndex, 1);
5250
+ }
5251
+ }
5252
+ let canvasEl;
5253
+ if (domContainer.tagName.toLowerCase() === "canvas") {
5254
+ canvasEl = domContainer;
5255
+ canvasEl.dataset[generatedAttribute] = "false";
5256
+ } else {
5257
+ const existingCanvases = domContainer.getElementsByTagName("canvas");
5258
+ if (existingCanvases.length) {
5259
+ canvasEl = existingCanvases[0];
5260
+ canvasEl.dataset[generatedAttribute] = "false";
5261
+ } else {
5262
+ canvasEl = document.createElement("canvas");
5263
+ canvasEl.dataset[generatedAttribute] = "true";
5264
+ domContainer.appendChild(canvasEl);
5265
+ }
5266
+ }
5267
+ if (!canvasEl.style.width) {
5268
+ canvasEl.style.width = "100%";
5269
+ }
5270
+ if (!canvasEl.style.height) {
5271
+ canvasEl.style.height = "100%";
5272
+ }
5273
+ const newItem = new Container(this, id, currentOptions);
5274
+ if (oldIndex >= 0) {
5275
+ dom.splice(oldIndex, 0, newItem);
5276
+ } else {
5277
+ dom.push(newItem);
5278
+ }
5279
+ newItem.canvas.loadCanvas(canvasEl);
5280
+ await newItem.start();
5281
+ return newItem;
5343
5282
  }
5344
5283
  async refresh() {
5345
5284
  for (const instance of this.dom()) {
@@ -5349,16 +5288,10 @@ class Engine {
5349
5288
  removeEventListener(type, listener) {
5350
5289
  this._eventDispatcher.removeEventListener(type, listener);
5351
5290
  }
5352
- async set(id, element, options) {
5353
- return this._loader.set(id, element, options);
5354
- }
5355
- async setJSON(id, element, pathConfigJson, index) {
5356
- return this._loader.setJSON(id, element, pathConfigJson, index);
5357
- }
5358
5291
  setOnClickHandler(callback) {
5359
5292
  const dom = this.dom();
5360
5293
  if (!dom.length) {
5361
- throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()");
5294
+ throw new Error("Can only set click handlers after calling tsParticles.load()");
5362
5295
  }
5363
5296
  for (const domItem of dom) {
5364
5297
  domItem.addClickHandler(callback);
@@ -5472,7 +5405,15 @@ const rgbColorManager = new RgbColorManager(),
5472
5405
  addColorManager(rgbColorManager);
5473
5406
  addColorManager(hslColorManager);
5474
5407
  const tsParticles = new Engine();
5475
- tsParticles.init();
5408
+
5409
+
5410
+
5411
+
5412
+
5413
+
5414
+
5415
+
5416
+
5476
5417
 
5477
5418
 
5478
5419
 
@@ -7163,10 +7104,16 @@ async function loadRollUpdater(engine) {
7163
7104
  ;// CONCATENATED MODULE: ../pjs/dist/esm/index.js
7164
7105
  const initPjs = engine => {
7165
7106
  const particlesJS = (tagId, options) => {
7166
- return engine.load(tagId, options);
7107
+ return engine.load({
7108
+ id: tagId,
7109
+ options: options
7110
+ });
7167
7111
  };
7168
7112
  particlesJS.load = (tagId, pathConfigJson, callback) => {
7169
- engine.loadJSON(tagId, pathConfigJson).then(container => {
7113
+ engine.load({
7114
+ id: tagId,
7115
+ url: pathConfigJson
7116
+ }).then(container => {
7170
7117
  if (container) {
7171
7118
  callback(container);
7172
7119
  }
@@ -9683,42 +9630,14 @@ class OpacityUpdater {
9683
9630
  }
9684
9631
  init(particle) {
9685
9632
  const opacityOptions = particle.options.opacity;
9686
- particle.opacity = {
9687
- enable: opacityOptions.animation.enable,
9688
- max: getRangeMax(opacityOptions.value),
9689
- min: getRangeMin(opacityOptions.value),
9690
- value: getRangeValue(opacityOptions.value),
9691
- loops: 0,
9692
- maxLoops: getRangeValue(opacityOptions.animation.count)
9693
- };
9633
+ particle.opacity = initParticleNumericAnimationValue(opacityOptions, 1);
9694
9634
  const opacityAnimation = opacityOptions.animation;
9695
9635
  if (opacityAnimation.enable) {
9696
- particle.opacity.decay = 1 - getRangeValue(opacityAnimation.decay);
9697
- particle.opacity.status = "increasing";
9698
- const opacityRange = opacityOptions.value;
9699
- particle.opacity.min = getRangeMin(opacityRange);
9700
- particle.opacity.max = getRangeMax(opacityRange);
9701
- switch (opacityAnimation.startValue) {
9702
- case "min":
9703
- particle.opacity.value = particle.opacity.min;
9704
- particle.opacity.status = "increasing";
9705
- break;
9706
- case "random":
9707
- particle.opacity.value = randomInRange(particle.opacity);
9708
- particle.opacity.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
9709
- break;
9710
- case "max":
9711
- default:
9712
- particle.opacity.value = particle.opacity.max;
9713
- particle.opacity.status = "decreasing";
9714
- break;
9715
- }
9716
9636
  particle.opacity.velocity = getRangeValue(opacityAnimation.speed) / 100 * this.container.retina.reduceFactor;
9717
9637
  if (!opacityAnimation.sync) {
9718
9638
  particle.opacity.velocity *= getRandom();
9719
9639
  }
9720
9640
  }
9721
- particle.opacity.initialValue = particle.opacity.value;
9722
9641
  }
9723
9642
  isEnabled(particle) {
9724
9643
  var _a, _b, _c, _d;