@tsparticles/particles 4.1.2 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* tsParticles v4.1.2 */
2
+ /* tsParticles v4.2.0 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5
5
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -15,7 +15,7 @@
15
15
  b: 0,
16
16
  c: 0,
17
17
  d: 1,
18
- }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha$1 = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity$5 = 0, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$2 = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity$1 = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
18
+ }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha$1 = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, minDistance$2 = 0, minRadius$1 = 0, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$2 = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, maxNits = 400, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
19
19
 
20
20
  exports.MoveDirection = void 0;
21
21
  (function (MoveDirection) {
@@ -82,11 +82,6 @@
82
82
  div(n) {
83
83
  return Vector3d.create(this.x / n, this.y / n, this.z / n);
84
84
  }
85
- divTo(n) {
86
- this.x /= n;
87
- this.y /= n;
88
- this.z /= n;
89
- }
90
85
  getLengthSq() {
91
86
  return this.x ** squareExp + this.y ** squareExp;
92
87
  }
@@ -176,6 +171,9 @@
176
171
  function setRandom(rnd = Math.random) {
177
172
  _random = rnd;
178
173
  }
174
+ function getRandomFn() {
175
+ return _random;
176
+ }
179
177
  function getRandom() {
180
178
  const min = 0, max = 1;
181
179
  return clamp(_random(), min, max - Number.EPSILON);
@@ -311,13 +309,6 @@
311
309
  y: position?.y ?? getRandom() * size.height,
312
310
  };
313
311
  }
314
- function calcExactPositionOrRandomFromSizeRanged(data) {
315
- const position = {
316
- x: data.position?.x !== undefined ? getRangeValue(data.position.x) : undefined,
317
- y: data.position?.y !== undefined ? getRangeValue(data.position.y) : undefined,
318
- };
319
- return calcExactPositionOrRandomFromSize({ size: data.size, position });
320
- }
321
312
  function parseAlpha(input) {
322
313
  const defaultAlpha = 1;
323
314
  if (!input) {
@@ -326,27 +317,6 @@
326
317
  return input.endsWith("%") ? parseFloat(input) / percentDenominator : parseFloat(input);
327
318
  }
328
319
 
329
- exports.AnimationMode = void 0;
330
- (function (AnimationMode) {
331
- AnimationMode["auto"] = "auto";
332
- AnimationMode["increase"] = "increase";
333
- AnimationMode["decrease"] = "decrease";
334
- AnimationMode["random"] = "random";
335
- })(exports.AnimationMode || (exports.AnimationMode = {}));
336
-
337
- exports.AnimationStatus = void 0;
338
- (function (AnimationStatus) {
339
- AnimationStatus["increasing"] = "increasing";
340
- AnimationStatus["decreasing"] = "decreasing";
341
- })(exports.AnimationStatus || (exports.AnimationStatus = {}));
342
-
343
- exports.DestroyType = void 0;
344
- (function (DestroyType) {
345
- DestroyType["none"] = "none";
346
- DestroyType["max"] = "max";
347
- DestroyType["min"] = "min";
348
- })(exports.DestroyType || (exports.DestroyType = {}));
349
-
350
320
  exports.OutModeDirection = void 0;
351
321
  (function (OutModeDirection) {
352
322
  OutModeDirection["bottom"] = "bottom";
@@ -361,80 +331,7 @@
361
331
  PixelMode["percent"] = "percent";
362
332
  })(exports.PixelMode || (exports.PixelMode = {}));
363
333
 
364
- exports.StartValueType = void 0;
365
- (function (StartValueType) {
366
- StartValueType["max"] = "max";
367
- StartValueType["min"] = "min";
368
- StartValueType["random"] = "random";
369
- })(exports.StartValueType || (exports.StartValueType = {}));
370
-
371
- const minRadius = 0, minMemoizeSize = 0;
372
- function memoize(fn, options) {
373
- const cache = new Map(), maxSize = options?.maxSize, ttlMs = options?.ttlMs, keyFn = options?.keyFn, stableStringify = (obj, seen = new WeakSet()) => {
374
- if (obj === null) {
375
- return "null";
376
- }
377
- const t = typeof obj;
378
- if (t === "undefined") {
379
- return "undefined";
380
- }
381
- if (t === "number" || t === "boolean" || t === "string") {
382
- return JSON.stringify(obj);
383
- }
384
- if (t === "function") {
385
- try {
386
- const fn = obj;
387
- return fn.toString();
388
- }
389
- catch {
390
- return '"[Function]"';
391
- }
392
- }
393
- if (t === "symbol") {
394
- try {
395
- return obj.toString();
396
- }
397
- catch {
398
- return '"[Symbol]"';
399
- }
400
- }
401
- if (Array.isArray(obj)) {
402
- return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
403
- }
404
- if (seen.has(obj)) {
405
- return '"[Circular]"';
406
- }
407
- seen.add(obj);
408
- const keys = Object.keys(obj).sort();
409
- return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
410
- }, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (keyFn ? keyFn(args) : defaultKeyer(args)), ensureBounds = () => {
411
- if (typeof maxSize === "number" && maxSize >= minMemoizeSize) {
412
- while (cache.size > maxSize) {
413
- const firstKey = cache.keys().next().value;
414
- if (firstKey === undefined)
415
- break;
416
- cache.delete(firstKey);
417
- }
418
- }
419
- };
420
- return (...args) => {
421
- const key = makeKey(args), now = Date.now(), entry = cache.get(key);
422
- if (entry !== undefined) {
423
- if (ttlMs && now - entry.ts > ttlMs) {
424
- cache.delete(key);
425
- }
426
- else {
427
- cache.delete(key);
428
- cache.set(key, { value: entry.value, ts: entry.ts });
429
- return entry.value;
430
- }
431
- }
432
- const result = fn(...args);
433
- cache.set(key, { value: result, ts: now });
434
- ensureBounds();
435
- return result;
436
- };
437
- }
334
+ const minRadius = 0;
438
335
  function hasMatchMedia() {
439
336
  return typeof matchMedia !== "undefined";
440
337
  }
@@ -447,12 +344,6 @@
447
344
  }
448
345
  return matchMedia(query);
449
346
  }
450
- function safeIntersectionObserver(callback) {
451
- if (typeof IntersectionObserver === "undefined") {
452
- return;
453
- }
454
- return new IntersectionObserver(callback);
455
- }
456
347
  function safeMutationObserver(callback) {
457
348
  if (typeof MutationObserver === "undefined") {
458
349
  return;
@@ -462,11 +353,8 @@
462
353
  function isInArray(value, array) {
463
354
  return value === array || (isArray(array) && array.includes(value));
464
355
  }
465
- function arrayRandomIndex(array) {
466
- return Math.floor(getRandom() * array.length);
467
- }
468
356
  function itemFromArray(array, index, useIndex = true) {
469
- return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
357
+ return array[index !== undefined && useIndex ? index % array.length : Math.floor(getRandom() * array.length)];
470
358
  }
471
359
  function isPointInside(point, size, offset, radius, direction) {
472
360
  return areBoundsInside(calculateBounds(point, radius ?? minRadius), size, offset, direction);
@@ -570,63 +458,6 @@
570
458
  function itemFromSingleOrMultiple(obj, index, useIndex) {
571
459
  return isArray(obj) ? itemFromArray(obj, index, useIndex) : obj;
572
460
  }
573
- function findItemFromSingleOrMultiple(obj, callback) {
574
- if (isArray(obj)) {
575
- return obj.find((t, index) => callback(t, index));
576
- }
577
- const defaultIndex = 0;
578
- return callback(obj, defaultIndex) ? obj : undefined;
579
- }
580
- function initParticleNumericAnimationValue(options, pxRatio) {
581
- const valueRange = options.value, animationOptions = options.animation, res = {
582
- delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
583
- enable: animationOptions.enable,
584
- value: getRangeValue(options.value) * pxRatio,
585
- max: getRangeMax(valueRange) * pxRatio,
586
- min: getRangeMin(valueRange) * pxRatio,
587
- loops: 0,
588
- maxLoops: getRangeValue(animationOptions.count),
589
- time: 0,
590
- }, decayOffset = 1;
591
- if (animationOptions.enable) {
592
- res.decay = decayOffset - getRangeValue(animationOptions.decay);
593
- switch (animationOptions.mode) {
594
- case exports.AnimationMode.increase:
595
- res.status = exports.AnimationStatus.increasing;
596
- break;
597
- case exports.AnimationMode.decrease:
598
- res.status = exports.AnimationStatus.decreasing;
599
- break;
600
- case exports.AnimationMode.random:
601
- res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
602
- break;
603
- }
604
- const autoStatus = animationOptions.mode === exports.AnimationMode.auto;
605
- switch (animationOptions.startValue) {
606
- case exports.StartValueType.min:
607
- res.value = res.min;
608
- if (autoStatus) {
609
- res.status = exports.AnimationStatus.increasing;
610
- }
611
- break;
612
- case exports.StartValueType.max:
613
- res.value = res.max;
614
- if (autoStatus) {
615
- res.status = exports.AnimationStatus.decreasing;
616
- }
617
- break;
618
- case exports.StartValueType.random:
619
- default:
620
- res.value = randomInRangeValue(res);
621
- if (autoStatus) {
622
- res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
623
- }
624
- break;
625
- }
626
- }
627
- res.initialValue = res.value;
628
- return res;
629
- }
630
461
  function getPositionOrSize(positionOrSize, canvasSize) {
631
462
  const isPercent = positionOrSize.mode === exports.PixelMode.percent;
632
463
  if (!isPercent) {
@@ -650,80 +481,6 @@
650
481
  function getPosition(position, canvasSize) {
651
482
  return getPositionOrSize(position, canvasSize);
652
483
  }
653
- function getSize(size, canvasSize) {
654
- return getPositionOrSize(size, canvasSize);
655
- }
656
- function checkDestroy(particle, destroyType, value, minValue, maxValue) {
657
- switch (destroyType) {
658
- case exports.DestroyType.max:
659
- if (value >= maxValue) {
660
- particle.destroy();
661
- }
662
- break;
663
- case exports.DestroyType.min:
664
- if (value <= minValue) {
665
- particle.destroy();
666
- }
667
- break;
668
- }
669
- }
670
- function updateAnimation(particle, data, changeDirection, destroyType, delta) {
671
- const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
672
- if (particle.destroyed ||
673
- !data.enable ||
674
- ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
675
- return;
676
- }
677
- const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
678
- data.time ??= 0;
679
- if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
680
- data.time += delta.value;
681
- }
682
- if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
683
- return;
684
- }
685
- switch (data.status) {
686
- case exports.AnimationStatus.increasing:
687
- data.value += velocity;
688
- break;
689
- case exports.AnimationStatus.decreasing:
690
- data.value -= velocity;
691
- break;
692
- }
693
- if (data.velocity && decay !== identity) {
694
- data.velocity *= decay;
695
- }
696
- switch (data.status) {
697
- case exports.AnimationStatus.increasing:
698
- if (data.value >= maxValue) {
699
- if (changeDirection) {
700
- data.status = exports.AnimationStatus.decreasing;
701
- }
702
- else {
703
- data.value -= maxValue;
704
- }
705
- data.loops ??= minLoops;
706
- data.loops++;
707
- }
708
- break;
709
- case exports.AnimationStatus.decreasing:
710
- if (data.value <= minValue) {
711
- if (changeDirection) {
712
- data.status = exports.AnimationStatus.increasing;
713
- }
714
- else {
715
- data.value += maxValue;
716
- }
717
- data.loops ??= minLoops;
718
- data.loops++;
719
- }
720
- break;
721
- }
722
- checkDestroy(particle, destroyType, data.value, minValue, maxValue);
723
- if (!particle.destroyed) {
724
- data.value = clamp(data.value, minValue, maxValue);
725
- }
726
- }
727
484
  function cloneStyle(style) {
728
485
  const clonedStyle = safeDocument().createElement("div").style;
729
486
  for (const key in style) {
@@ -745,30 +502,34 @@
745
502
  }
746
503
  return clonedStyle;
747
504
  }
748
- function computeFullScreenStyle(zIndex) {
749
- const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
750
- width: "100%",
751
- height: "100%",
752
- margin: "0",
753
- padding: "0",
754
- borderWidth: "0",
755
- position: "fixed",
756
- zIndex: zIndex.toString(radix),
757
- "z-index": zIndex.toString(radix),
758
- top: "0",
759
- left: "0",
760
- "pointer-events": "none",
761
- };
762
- for (const key in style) {
763
- const value = style[key];
764
- if (value === undefined) {
765
- continue;
505
+ let _cachedZIndex, _cachedStyle;
506
+ function getFullScreenStyle(zIndex) {
507
+ if (_cachedZIndex !== zIndex || !_cachedStyle) {
508
+ _cachedZIndex = zIndex;
509
+ const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
510
+ width: "100%",
511
+ height: "100%",
512
+ margin: "0",
513
+ padding: "0",
514
+ borderWidth: "0",
515
+ position: "fixed",
516
+ zIndex: zIndex.toString(radix),
517
+ "z-index": zIndex.toString(radix),
518
+ top: "0",
519
+ left: "0",
520
+ "pointer-events": "none",
521
+ };
522
+ for (const key in style) {
523
+ const value = style[key];
524
+ if (value === undefined) {
525
+ continue;
526
+ }
527
+ fullScreenStyle.setProperty(key, value);
766
528
  }
767
- fullScreenStyle.setProperty(key, value);
529
+ _cachedStyle = fullScreenStyle;
768
530
  }
769
- return fullScreenStyle;
531
+ return _cachedStyle;
770
532
  }
771
- const getFullScreenStyle = memoize(computeFullScreenStyle);
772
533
  function manageListener(element, event, handler, add, options) {
773
534
  if (add) {
774
535
  let addOptions = { passive: true };
@@ -1118,7 +879,7 @@
1118
879
  return this.#domArray;
1119
880
  }
1120
881
  get version() {
1121
- return "4.1.2";
882
+ return "4.2.0";
1122
883
  }
1123
884
  addEventListener(type, listener) {
1124
885
  this.#eventDispatcher.addEventListener(type, listener);
@@ -1288,6 +1049,14 @@
1288
1049
  RotateDirection["random"] = "random";
1289
1050
  })(exports.RotateDirection || (exports.RotateDirection = {}));
1290
1051
 
1052
+ exports.AnimationMode = void 0;
1053
+ (function (AnimationMode) {
1054
+ AnimationMode["auto"] = "auto";
1055
+ AnimationMode["increase"] = "increase";
1056
+ AnimationMode["decrease"] = "decrease";
1057
+ AnimationMode["random"] = "random";
1058
+ })(exports.AnimationMode || (exports.AnimationMode = {}));
1059
+
1291
1060
  exports.LimitMode = void 0;
1292
1061
  (function (LimitMode) {
1293
1062
  LimitMode["delete"] = "delete";
@@ -1309,6 +1078,13 @@
1309
1078
  AlterType["enlighten"] = "enlighten";
1310
1079
  })(exports.AlterType || (exports.AlterType = {}));
1311
1080
 
1081
+ exports.DestroyType = void 0;
1082
+ (function (DestroyType) {
1083
+ DestroyType["none"] = "none";
1084
+ DestroyType["max"] = "max";
1085
+ DestroyType["min"] = "min";
1086
+ })(exports.DestroyType || (exports.DestroyType = {}));
1087
+
1312
1088
  exports.GradientType = void 0;
1313
1089
  (function (GradientType) {
1314
1090
  GradientType["linear"] = "linear";
@@ -1323,160 +1099,126 @@
1323
1099
  ParticleOutType["outside"] = "outside";
1324
1100
  })(exports.ParticleOutType || (exports.ParticleOutType = {}));
1325
1101
 
1326
- exports.EasingType = void 0;
1327
- (function (EasingType) {
1328
- EasingType["easeInBack"] = "ease-in-back";
1329
- EasingType["easeInBounce"] = "ease-in-bounce";
1330
- EasingType["easeInCirc"] = "ease-in-circ";
1331
- EasingType["easeInCubic"] = "ease-in-cubic";
1332
- EasingType["easeInElastic"] = "ease-in-elastic";
1333
- EasingType["easeInExpo"] = "ease-in-expo";
1334
- EasingType["easeInGaussian"] = "ease-in-gaussian";
1335
- EasingType["easeInLinear"] = "ease-in-linear";
1336
- EasingType["easeInQuad"] = "ease-in-quad";
1337
- EasingType["easeInQuart"] = "ease-in-quart";
1338
- EasingType["easeInQuint"] = "ease-in-quint";
1339
- EasingType["easeInSigmoid"] = "ease-in-sigmoid";
1340
- EasingType["easeInSine"] = "ease-in-sine";
1341
- EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
1342
- EasingType["easeOutBack"] = "ease-out-back";
1343
- EasingType["easeOutBounce"] = "ease-out-bounce";
1344
- EasingType["easeOutCirc"] = "ease-out-circ";
1345
- EasingType["easeOutCubic"] = "ease-out-cubic";
1346
- EasingType["easeOutElastic"] = "ease-out-elastic";
1347
- EasingType["easeOutExpo"] = "ease-out-expo";
1348
- EasingType["easeOutGaussian"] = "ease-out-gaussian";
1349
- EasingType["easeOutLinear"] = "ease-out-linear";
1350
- EasingType["easeOutQuad"] = "ease-out-quad";
1351
- EasingType["easeOutQuart"] = "ease-out-quart";
1352
- EasingType["easeOutQuint"] = "ease-out-quint";
1353
- EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
1354
- EasingType["easeOutSine"] = "ease-out-sine";
1355
- EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
1356
- EasingType["easeInOutBack"] = "ease-in-out-back";
1357
- EasingType["easeInOutBounce"] = "ease-in-out-bounce";
1358
- EasingType["easeInOutCirc"] = "ease-in-out-circ";
1359
- EasingType["easeInOutCubic"] = "ease-in-out-cubic";
1360
- EasingType["easeInOutElastic"] = "ease-in-out-elastic";
1361
- EasingType["easeInOutExpo"] = "ease-in-out-expo";
1362
- EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
1363
- EasingType["easeInOutLinear"] = "ease-in-out-linear";
1364
- EasingType["easeInOutQuad"] = "ease-in-out-quad";
1365
- EasingType["easeInOutQuart"] = "ease-in-out-quart";
1366
- EasingType["easeInOutQuint"] = "ease-in-out-quint";
1367
- EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
1368
- EasingType["easeInOutSine"] = "ease-in-out-sine";
1369
- EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
1370
- })(exports.EasingType || (exports.EasingType = {}));
1371
-
1372
- class AnimationOptions {
1373
- count;
1374
- decay;
1375
- delay;
1376
- enable;
1377
- speed;
1378
- sync;
1379
- constructor() {
1380
- this.count = 0;
1381
- this.enable = false;
1382
- this.speed = 1;
1383
- this.decay = 0;
1384
- this.delay = 0;
1385
- this.sync = false;
1386
- }
1102
+ exports.StartValueType = void 0;
1103
+ (function (StartValueType) {
1104
+ StartValueType["max"] = "max";
1105
+ StartValueType["min"] = "min";
1106
+ StartValueType["random"] = "random";
1107
+ })(exports.StartValueType || (exports.StartValueType = {}));
1108
+
1109
+ exports.AnimationStatus = void 0;
1110
+ (function (AnimationStatus) {
1111
+ AnimationStatus["increasing"] = "increasing";
1112
+ AnimationStatus["decreasing"] = "decreasing";
1113
+ })(exports.AnimationStatus || (exports.AnimationStatus = {}));
1114
+
1115
+ class OptionLoader {
1387
1116
  load(data) {
1388
1117
  if (isNull(data)) {
1389
1118
  return;
1390
1119
  }
1391
- if (data.count !== undefined) {
1392
- this.count = setRangeValue(data.count);
1393
- }
1394
- if (data.enable !== undefined) {
1395
- this.enable = data.enable;
1396
- }
1397
- if (data.speed !== undefined) {
1398
- this.speed = setRangeValue(data.speed);
1399
- }
1400
- if (data.decay !== undefined) {
1401
- this.decay = setRangeValue(data.decay);
1402
- }
1403
- if (data.delay !== undefined) {
1404
- this.delay = setRangeValue(data.delay);
1405
- }
1406
- if (data.sync !== undefined) {
1407
- this.sync = data.sync;
1408
- }
1120
+ this.doLoad(data);
1409
1121
  }
1410
1122
  }
1411
- class RangedAnimationOptions extends AnimationOptions {
1412
- mode;
1413
- startValue;
1414
- constructor() {
1415
- super();
1416
- this.mode = exports.AnimationMode.auto;
1417
- this.startValue = exports.StartValueType.random;
1418
- }
1419
- load(data) {
1420
- super.load(data);
1421
- if (isNull(data)) {
1422
- return;
1423
- }
1424
- if (data.mode !== undefined) {
1425
- this.mode = data.mode;
1426
- }
1427
- if (data.startValue !== undefined) {
1428
- this.startValue = data.startValue;
1429
- }
1123
+ function loadOptions(options, ...sourceOptionsArr) {
1124
+ for (const sourceOptions of sourceOptionsArr) {
1125
+ options.load(sourceOptions);
1430
1126
  }
1431
1127
  }
1432
1128
 
1433
- class ColorAnimation extends AnimationOptions {
1434
- max;
1435
- min;
1436
- offset;
1437
- constructor(min, max) {
1438
- super();
1439
- this.min = min;
1440
- this.max = max;
1441
- this.offset = 0;
1442
- this.sync = true;
1129
+ function loadProperty(obj, key, value) {
1130
+ if (value !== undefined) {
1131
+ obj[key] = value;
1443
1132
  }
1444
- load(data) {
1445
- super.load(data);
1446
- if (isNull(data)) {
1447
- return;
1448
- }
1449
- if (data.max !== undefined) {
1450
- this.max = data.max;
1451
- }
1452
- if (data.min !== undefined) {
1453
- this.min = data.min;
1454
- }
1455
- if (data.offset !== undefined) {
1456
- this.offset = setRangeValue(data.offset);
1457
- }
1133
+ }
1134
+ function loadRangeProperty(obj, key, value) {
1135
+ if (value !== undefined) {
1136
+ obj[key] = setRangeValue(value);
1137
+ }
1138
+ }
1139
+ function loadNestedProperty(obj, key, value) {
1140
+ if (value !== undefined) {
1141
+ obj[key].load(value);
1142
+ }
1143
+ }
1144
+ function loadLazyProperty(obj, key, value, factory) {
1145
+ if (value !== undefined) {
1146
+ const objRecord = obj;
1147
+ objRecord[key] ??= factory();
1148
+ objRecord[key].load(value);
1149
+ }
1150
+ }
1151
+ function loadExtendProperty(obj, key, value) {
1152
+ if (value !== undefined) {
1153
+ obj[key] = deepExtend(obj[key] ?? {}, value);
1154
+ }
1155
+ }
1156
+ function loadOptionProperty(obj, key, optionClass, ...sources) {
1157
+ const objRecord = obj;
1158
+ objRecord[key] ??= new optionClass();
1159
+ const target = objRecord[key];
1160
+ for (const source of sources) {
1161
+ target.load(source?.[key]);
1162
+ }
1163
+ }
1164
+
1165
+ class AnimationOptions extends OptionLoader {
1166
+ count = 0;
1167
+ decay = 0;
1168
+ delay = 0;
1169
+ enable = false;
1170
+ speed = 1;
1171
+ sync = false;
1172
+ doLoad(data) {
1173
+ loadRangeProperty(this, "count", data.count);
1174
+ loadProperty(this, "enable", data.enable);
1175
+ loadRangeProperty(this, "speed", data.speed);
1176
+ loadRangeProperty(this, "decay", data.decay);
1177
+ loadRangeProperty(this, "delay", data.delay);
1178
+ loadProperty(this, "sync", data.sync);
1179
+ }
1180
+ }
1181
+ class RangedAnimationOptions extends AnimationOptions {
1182
+ mode = exports.AnimationMode.auto;
1183
+ startValue = exports.StartValueType.random;
1184
+ doLoad(data) {
1185
+ super.doLoad(data);
1186
+ loadProperty(this, "mode", data.mode);
1187
+ loadProperty(this, "startValue", data.startValue);
1188
+ }
1189
+ }
1190
+
1191
+ class ColorAnimation extends AnimationOptions {
1192
+ max;
1193
+ min;
1194
+ offset = 0;
1195
+ sync = true;
1196
+ constructor(min, max) {
1197
+ super();
1198
+ this.min = min;
1199
+ this.max = max;
1200
+ }
1201
+ doLoad(data) {
1202
+ super.doLoad(data);
1203
+ loadProperty(this, "max", data.max);
1204
+ loadProperty(this, "min", data.min);
1205
+ loadRangeProperty(this, "offset", data.offset);
1458
1206
  }
1459
1207
  }
1460
1208
 
1461
- class HslAnimation {
1209
+ class HslAnimation extends OptionLoader {
1462
1210
  h = new ColorAnimation(hMin, hMax);
1463
1211
  l = new ColorAnimation(lMin, lMax);
1464
1212
  s = new ColorAnimation(sMin, sMax);
1465
- load(data) {
1466
- if (isNull(data)) {
1467
- return;
1468
- }
1213
+ doLoad(data) {
1469
1214
  this.h.load(data.h);
1470
1215
  this.s.load(data.s);
1471
1216
  this.l.load(data.l);
1472
1217
  }
1473
1218
  }
1474
1219
 
1475
- class OptionsColor {
1476
- value;
1477
- constructor() {
1478
- this.value = "";
1479
- }
1220
+ class OptionsColor extends OptionLoader {
1221
+ value = "";
1480
1222
  static create(source, data) {
1481
1223
  const color = new OptionsColor();
1482
1224
  color.load(source);
@@ -1490,10 +1232,7 @@
1490
1232
  }
1491
1233
  return color;
1492
1234
  }
1493
- load(data) {
1494
- if (isNull(data)) {
1495
- return;
1496
- }
1235
+ doLoad(data) {
1497
1236
  if (!isNull(data.value)) {
1498
1237
  this.value = data.value;
1499
1238
  }
@@ -1501,11 +1240,7 @@
1501
1240
  }
1502
1241
 
1503
1242
  class AnimatableColor extends OptionsColor {
1504
- animation;
1505
- constructor() {
1506
- super();
1507
- this.animation = new HslAnimation();
1508
- }
1243
+ animation = new HslAnimation();
1509
1244
  static create(source, data) {
1510
1245
  const color = new AnimatableColor();
1511
1246
  color.load(source);
@@ -1519,11 +1254,8 @@
1519
1254
  }
1520
1255
  return color;
1521
1256
  }
1522
- load(data) {
1523
- super.load(data);
1524
- if (isNull(data)) {
1525
- return;
1526
- }
1257
+ doLoad(data) {
1258
+ super.doLoad(data);
1527
1259
  const colorAnimation = data.animation;
1528
1260
  if (colorAnimation !== undefined) {
1529
1261
  if (colorAnimation.enable === undefined) {
@@ -1536,100 +1268,53 @@
1536
1268
  }
1537
1269
  }
1538
1270
 
1539
- class Background {
1271
+ class Background extends OptionLoader {
1540
1272
  color;
1541
- image;
1542
- opacity;
1543
- position;
1544
- repeat;
1545
- size;
1273
+ image = "";
1274
+ opacity = 1;
1275
+ position = "";
1276
+ repeat = "";
1277
+ size = "";
1546
1278
  constructor() {
1279
+ super();
1547
1280
  this.color = new OptionsColor();
1548
1281
  this.color.value = "";
1549
- this.image = "";
1550
- this.position = "";
1551
- this.repeat = "";
1552
- this.size = "";
1553
- this.opacity = 1;
1554
1282
  }
1555
- load(data) {
1556
- if (isNull(data)) {
1557
- return;
1558
- }
1283
+ doLoad(data) {
1559
1284
  if (data.color !== undefined) {
1560
1285
  this.color = OptionsColor.create(this.color, data.color);
1561
1286
  }
1562
- if (data.image !== undefined) {
1563
- this.image = data.image;
1564
- }
1565
- if (data.position !== undefined) {
1566
- this.position = data.position;
1567
- }
1568
- if (data.repeat !== undefined) {
1569
- this.repeat = data.repeat;
1570
- }
1571
- if (data.size !== undefined) {
1572
- this.size = data.size;
1573
- }
1574
- if (data.opacity !== undefined) {
1575
- this.opacity = data.opacity;
1576
- }
1287
+ loadProperty(this, "image", data.image);
1288
+ loadProperty(this, "position", data.position);
1289
+ loadProperty(this, "repeat", data.repeat);
1290
+ loadProperty(this, "size", data.size);
1291
+ loadProperty(this, "opacity", data.opacity);
1577
1292
  }
1578
1293
  }
1579
1294
 
1580
- class FullScreen {
1581
- enable;
1582
- zIndex;
1583
- constructor() {
1584
- this.enable = true;
1585
- this.zIndex = 0;
1586
- }
1587
- load(data) {
1588
- if (isNull(data)) {
1589
- return;
1590
- }
1591
- if (data.enable !== undefined) {
1592
- this.enable = data.enable;
1593
- }
1594
- if (data.zIndex !== undefined) {
1595
- this.zIndex = data.zIndex;
1596
- }
1295
+ class FullScreen extends OptionLoader {
1296
+ enable = true;
1297
+ zIndex = 0;
1298
+ doLoad(data) {
1299
+ loadProperty(this, "enable", data.enable);
1300
+ loadProperty(this, "zIndex", data.zIndex);
1597
1301
  }
1598
1302
  }
1599
1303
 
1600
- class ResizeEvent {
1601
- delay;
1602
- enable;
1603
- constructor() {
1604
- this.delay = 0.5;
1605
- this.enable = true;
1606
- }
1607
- load(data) {
1608
- if (isNull(data)) {
1609
- return;
1610
- }
1611
- if (data.delay !== undefined) {
1612
- this.delay = data.delay;
1613
- }
1614
- if (data.enable !== undefined) {
1615
- this.enable = data.enable;
1616
- }
1304
+ class ResizeEvent extends OptionLoader {
1305
+ delay = 0.5;
1306
+ enable = true;
1307
+ doLoad(data) {
1308
+ loadProperty(this, "delay", data.delay);
1309
+ loadProperty(this, "enable", data.enable);
1617
1310
  }
1618
1311
  }
1619
1312
 
1620
- class Effect {
1621
- close;
1622
- options;
1623
- type;
1624
- constructor() {
1625
- this.close = true;
1626
- this.options = {};
1627
- this.type = [];
1628
- }
1629
- load(data) {
1630
- if (isNull(data)) {
1631
- return;
1632
- }
1313
+ class Effect extends OptionLoader {
1314
+ close = true;
1315
+ options = {};
1316
+ type = [];
1317
+ doLoad(data) {
1633
1318
  const options = data.options;
1634
1319
  if (options !== undefined) {
1635
1320
  for (const effect in options) {
@@ -1639,128 +1324,62 @@
1639
1324
  }
1640
1325
  }
1641
1326
  }
1642
- if (data.close !== undefined) {
1643
- this.close = data.close;
1644
- }
1645
- if (data.type !== undefined) {
1646
- this.type = data.type;
1647
- }
1327
+ loadProperty(this, "close", data.close);
1328
+ loadProperty(this, "type", data.type);
1648
1329
  }
1649
1330
  }
1650
1331
 
1651
- class Fill {
1332
+ class Fill extends OptionLoader {
1652
1333
  color;
1653
- enable;
1654
- opacity;
1655
- constructor() {
1656
- this.enable = true;
1657
- this.opacity = 1;
1658
- }
1659
- load(data) {
1660
- if (isNull(data)) {
1661
- return;
1662
- }
1334
+ enable = true;
1335
+ opacity = 1;
1336
+ doLoad(data) {
1663
1337
  if (data.color !== undefined) {
1664
1338
  this.color = AnimatableColor.create(this.color, data.color);
1665
1339
  }
1666
- if (data.enable !== undefined) {
1667
- this.enable = data.enable;
1668
- }
1669
- if (data.opacity !== undefined) {
1670
- this.opacity = setRangeValue(data.opacity);
1671
- }
1340
+ loadProperty(this, "enable", data.enable);
1341
+ loadRangeProperty(this, "opacity", data.opacity);
1672
1342
  }
1673
1343
  }
1674
1344
 
1675
- class MoveAngle {
1676
- offset;
1677
- value;
1678
- constructor() {
1679
- this.offset = 0;
1680
- this.value = 90;
1681
- }
1682
- load(data) {
1683
- if (isNull(data)) {
1684
- return;
1685
- }
1686
- if (data.offset !== undefined) {
1687
- this.offset = setRangeValue(data.offset);
1688
- }
1689
- if (data.value !== undefined) {
1690
- this.value = setRangeValue(data.value);
1691
- }
1345
+ class MoveAngle extends OptionLoader {
1346
+ offset = 0;
1347
+ value = 90;
1348
+ doLoad(data) {
1349
+ loadRangeProperty(this, "offset", data.offset);
1350
+ loadRangeProperty(this, "value", data.value);
1692
1351
  }
1693
1352
  }
1694
1353
 
1695
- class MoveCenter {
1696
- mode;
1697
- radius;
1698
- x;
1699
- y;
1700
- constructor() {
1701
- this.x = 50;
1702
- this.y = 50;
1703
- this.mode = exports.PixelMode.percent;
1704
- this.radius = 0;
1705
- }
1706
- load(data) {
1707
- if (isNull(data)) {
1708
- return;
1709
- }
1710
- if (data.x !== undefined) {
1711
- this.x = data.x;
1712
- }
1713
- if (data.y !== undefined) {
1714
- this.y = data.y;
1715
- }
1716
- if (data.mode !== undefined) {
1717
- this.mode = data.mode;
1718
- }
1719
- if (data.radius !== undefined) {
1720
- this.radius = data.radius;
1721
- }
1354
+ class MoveCenter extends OptionLoader {
1355
+ mode = exports.PixelMode.percent;
1356
+ radius = 0;
1357
+ x = 50;
1358
+ y = 50;
1359
+ doLoad(data) {
1360
+ loadProperty(this, "x", data.x);
1361
+ loadProperty(this, "y", data.y);
1362
+ loadProperty(this, "mode", data.mode);
1363
+ loadProperty(this, "radius", data.radius);
1722
1364
  }
1723
1365
  }
1724
1366
 
1725
- class MoveGravity {
1726
- acceleration;
1727
- enable;
1728
- inverse;
1729
- maxSpeed;
1730
- constructor() {
1731
- this.acceleration = 9.81;
1732
- this.enable = false;
1733
- this.inverse = false;
1734
- this.maxSpeed = 50;
1735
- }
1736
- load(data) {
1737
- if (isNull(data)) {
1738
- return;
1739
- }
1740
- if (data.acceleration !== undefined) {
1741
- this.acceleration = setRangeValue(data.acceleration);
1742
- }
1743
- if (data.enable !== undefined) {
1744
- this.enable = data.enable;
1745
- }
1746
- if (data.inverse !== undefined) {
1747
- this.inverse = data.inverse;
1748
- }
1749
- if (data.maxSpeed !== undefined) {
1750
- this.maxSpeed = setRangeValue(data.maxSpeed);
1751
- }
1367
+ class MoveGravity extends OptionLoader {
1368
+ acceleration = 9.81;
1369
+ enable = false;
1370
+ inverse = false;
1371
+ maxSpeed = 50;
1372
+ doLoad(data) {
1373
+ loadRangeProperty(this, "acceleration", data.acceleration);
1374
+ loadProperty(this, "enable", data.enable);
1375
+ loadProperty(this, "inverse", data.inverse);
1376
+ loadRangeProperty(this, "maxSpeed", data.maxSpeed);
1752
1377
  }
1753
1378
  }
1754
1379
 
1755
- class ValueWithRandom {
1756
- value;
1757
- constructor() {
1758
- this.value = 0;
1759
- }
1760
- load(data) {
1761
- if (isNull(data)) {
1762
- return;
1763
- }
1380
+ class ValueWithRandom extends OptionLoader {
1381
+ value = 0;
1382
+ doLoad(data) {
1764
1383
  if (!isNull(data.value)) {
1765
1384
  this.value = setRangeValue(data.value);
1766
1385
  }
@@ -1768,51 +1387,25 @@
1768
1387
  }
1769
1388
  class AnimationValueWithRandom extends ValueWithRandom {
1770
1389
  animation = new AnimationOptions();
1771
- load(data) {
1772
- super.load(data);
1773
- if (isNull(data)) {
1774
- return;
1775
- }
1776
- const animation = data.animation;
1777
- if (animation !== undefined) {
1778
- this.animation.load(animation);
1779
- }
1390
+ doLoad(data) {
1391
+ super.doLoad(data);
1392
+ loadNestedProperty(this, "animation", data.animation);
1780
1393
  }
1781
1394
  }
1782
1395
  class RangedAnimationValueWithRandom extends AnimationValueWithRandom {
1783
- animation;
1784
- constructor() {
1785
- super();
1786
- this.animation = new RangedAnimationOptions();
1787
- }
1788
- load(data) {
1789
- super.load(data);
1790
- }
1396
+ animation = new RangedAnimationOptions();
1791
1397
  }
1792
1398
 
1793
- class MovePath {
1794
- clamp;
1795
- delay;
1796
- enable;
1399
+ class MovePath extends OptionLoader {
1400
+ clamp = true;
1401
+ delay = new ValueWithRandom();
1402
+ enable = false;
1797
1403
  generator;
1798
- options;
1799
- constructor() {
1800
- this.clamp = true;
1801
- this.delay = new ValueWithRandom();
1802
- this.enable = false;
1803
- this.options = {};
1804
- }
1805
- load(data) {
1806
- if (isNull(data)) {
1807
- return;
1808
- }
1809
- if (data.clamp !== undefined) {
1810
- this.clamp = data.clamp;
1811
- }
1404
+ options = {};
1405
+ doLoad(data) {
1406
+ loadProperty(this, "clamp", data.clamp);
1812
1407
  this.delay.load(data.delay);
1813
- if (data.enable !== undefined) {
1814
- this.enable = data.enable;
1815
- }
1408
+ loadProperty(this, "enable", data.enable);
1816
1409
  this.generator = data.generator;
1817
1410
  if (data.options) {
1818
1411
  this.options = deepExtend(this.options, data.options);
@@ -1820,19 +1413,13 @@
1820
1413
  }
1821
1414
  }
1822
1415
 
1823
- class OutModes {
1416
+ class OutModes extends OptionLoader {
1824
1417
  bottom;
1825
- default;
1418
+ default = exports.OutMode.out;
1826
1419
  left;
1827
1420
  right;
1828
1421
  top;
1829
- constructor() {
1830
- this.default = exports.OutMode.out;
1831
- }
1832
- load(data) {
1833
- if (isNull(data)) {
1834
- return;
1835
- }
1422
+ doLoad(data) {
1836
1423
  if (data.default !== undefined) {
1837
1424
  this.default = data.default;
1838
1425
  }
@@ -1843,79 +1430,42 @@
1843
1430
  }
1844
1431
  }
1845
1432
 
1846
- class Spin {
1847
- acceleration;
1848
- enable;
1433
+ class Spin extends OptionLoader {
1434
+ acceleration = 0;
1435
+ enable = false;
1849
1436
  position;
1850
- constructor() {
1851
- this.acceleration = 0;
1852
- this.enable = false;
1853
- }
1854
- load(data) {
1855
- if (isNull(data)) {
1856
- return;
1857
- }
1858
- if (data.acceleration !== undefined) {
1859
- this.acceleration = setRangeValue(data.acceleration);
1860
- }
1861
- if (data.enable !== undefined) {
1862
- this.enable = data.enable;
1863
- }
1437
+ doLoad(data) {
1438
+ loadRangeProperty(this, "acceleration", data.acceleration);
1439
+ loadProperty(this, "enable", data.enable);
1864
1440
  if (data.position) {
1865
1441
  this.position = deepExtend({}, data.position);
1866
1442
  }
1867
1443
  }
1868
1444
  }
1869
1445
 
1870
- class Move {
1871
- angle;
1872
- center;
1873
- decay;
1874
- direction;
1875
- distance;
1876
- drift;
1877
- enable;
1878
- gravity;
1879
- outModes;
1880
- path;
1881
- random;
1882
- size;
1883
- speed;
1884
- spin;
1885
- straight;
1886
- vibrate;
1887
- warp;
1888
- constructor() {
1889
- this.angle = new MoveAngle();
1890
- this.center = new MoveCenter();
1891
- this.decay = 0;
1892
- this.distance = {};
1893
- this.direction = exports.MoveDirection.none;
1894
- this.drift = 0;
1895
- this.enable = false;
1896
- this.gravity = new MoveGravity();
1897
- this.path = new MovePath();
1898
- this.outModes = new OutModes();
1899
- this.random = false;
1900
- this.size = false;
1901
- this.speed = 2;
1902
- this.spin = new Spin();
1903
- this.straight = false;
1904
- this.vibrate = false;
1905
- this.warp = false;
1906
- }
1907
- load(data) {
1908
- if (isNull(data)) {
1909
- return;
1910
- }
1446
+ class Move extends OptionLoader {
1447
+ angle = new MoveAngle();
1448
+ center = new MoveCenter();
1449
+ decay = 0;
1450
+ direction = exports.MoveDirection.none;
1451
+ distance = {};
1452
+ drift = 0;
1453
+ enable = false;
1454
+ gravity = new MoveGravity();
1455
+ outModes = new OutModes();
1456
+ path = new MovePath();
1457
+ random = false;
1458
+ size = false;
1459
+ speed = 2;
1460
+ spin = new Spin();
1461
+ straight = false;
1462
+ vibrate = false;
1463
+ warp = false;
1464
+ doLoad(data) {
1911
1465
  this.angle.load(isNumber(data.angle) ? { value: data.angle } : data.angle);
1912
1466
  this.center.load(data.center);
1913
- if (data.decay !== undefined) {
1914
- this.decay = setRangeValue(data.decay);
1915
- }
1916
- if (data.direction !== undefined) {
1917
- this.direction = data.direction;
1918
- }
1467
+ loadRangeProperty(this, "decay", data.decay);
1468
+ loadProperty(this, "direction", data.direction);
1919
1469
  if (data.distance !== undefined) {
1920
1470
  this.distance = isNumber(data.distance)
1921
1471
  ? {
@@ -1924,12 +1474,8 @@
1924
1474
  }
1925
1475
  : { ...data.distance };
1926
1476
  }
1927
- if (data.drift !== undefined) {
1928
- this.drift = setRangeValue(data.drift);
1929
- }
1930
- if (data.enable !== undefined) {
1931
- this.enable = data.enable;
1932
- }
1477
+ loadRangeProperty(this, "drift", data.drift);
1478
+ loadProperty(this, "enable", data.enable);
1933
1479
  this.gravity.load(data.gravity);
1934
1480
  const outModes = data.outModes;
1935
1481
  if (outModes !== undefined) {
@@ -1943,177 +1489,91 @@
1943
1489
  }
1944
1490
  }
1945
1491
  this.path.load(data.path);
1946
- if (data.random !== undefined) {
1947
- this.random = data.random;
1948
- }
1949
- if (data.size !== undefined) {
1950
- this.size = data.size;
1951
- }
1952
- if (data.speed !== undefined) {
1953
- this.speed = setRangeValue(data.speed);
1954
- }
1492
+ loadProperty(this, "random", data.random);
1493
+ loadProperty(this, "size", data.size);
1494
+ loadRangeProperty(this, "speed", data.speed);
1955
1495
  this.spin.load(data.spin);
1956
- if (data.straight !== undefined) {
1957
- this.straight = data.straight;
1958
- }
1959
- if (data.vibrate !== undefined) {
1960
- this.vibrate = data.vibrate;
1961
- }
1962
- if (data.warp !== undefined) {
1963
- this.warp = data.warp;
1964
- }
1496
+ loadProperty(this, "straight", data.straight);
1497
+ loadProperty(this, "vibrate", data.vibrate);
1498
+ loadProperty(this, "warp", data.warp);
1965
1499
  }
1966
1500
  }
1967
1501
 
1968
- class Stroke {
1502
+ class Stroke extends OptionLoader {
1969
1503
  color;
1970
1504
  opacity;
1971
- width;
1972
- constructor() {
1973
- this.width = 0;
1974
- }
1975
- load(data) {
1976
- if (isNull(data)) {
1977
- return;
1978
- }
1505
+ width = 0;
1506
+ doLoad(data) {
1979
1507
  if (data.color !== undefined) {
1980
1508
  this.color = AnimatableColor.create(this.color, data.color);
1981
1509
  }
1982
- if (data.width !== undefined) {
1983
- this.width = setRangeValue(data.width);
1984
- }
1985
- if (data.opacity !== undefined) {
1986
- this.opacity = setRangeValue(data.opacity);
1987
- }
1510
+ loadRangeProperty(this, "width", data.width);
1511
+ loadRangeProperty(this, "opacity", data.opacity);
1988
1512
  }
1989
1513
  }
1990
1514
 
1991
- class Paint {
1515
+ class Paint extends OptionLoader {
1992
1516
  color;
1993
1517
  fill;
1994
1518
  stroke;
1995
- load(data) {
1996
- if (isNull(data)) {
1997
- return;
1998
- }
1519
+ doLoad(data) {
1999
1520
  if (data.color !== undefined) {
2000
1521
  this.color = AnimatableColor.create(this.color, data.color);
2001
1522
  }
2002
- if (data.fill !== undefined) {
2003
- this.fill ??= new Fill();
2004
- this.fill.load(data.fill);
2005
- }
2006
- if (data.stroke !== undefined) {
2007
- this.stroke ??= new Stroke();
2008
- this.stroke.load(data.stroke);
2009
- }
1523
+ loadLazyProperty(this, "fill", data.fill, () => new Fill());
1524
+ loadLazyProperty(this, "stroke", data.stroke, () => new Stroke());
2010
1525
  }
2011
1526
  }
2012
1527
 
2013
1528
  class ParticlesBounceFactor extends ValueWithRandom {
2014
- constructor() {
2015
- super();
2016
- this.value = 1;
2017
- }
1529
+ value = 1;
2018
1530
  }
2019
1531
 
2020
- class ParticlesBounce {
2021
- horizontal;
2022
- vertical;
2023
- constructor() {
2024
- this.horizontal = new ParticlesBounceFactor();
2025
- this.vertical = new ParticlesBounceFactor();
2026
- }
2027
- load(data) {
2028
- if (isNull(data)) {
2029
- return;
2030
- }
1532
+ class ParticlesBounce extends OptionLoader {
1533
+ horizontal = new ParticlesBounceFactor();
1534
+ vertical = new ParticlesBounceFactor();
1535
+ doLoad(data) {
2031
1536
  this.horizontal.load(data.horizontal);
2032
1537
  this.vertical.load(data.vertical);
2033
1538
  }
2034
1539
  }
2035
1540
 
2036
- class ParticlesDensity {
2037
- enable;
2038
- height;
2039
- width;
2040
- constructor() {
2041
- this.enable = false;
2042
- this.width = 1920;
2043
- this.height = 1080;
2044
- }
2045
- load(data) {
2046
- if (isNull(data)) {
2047
- return;
2048
- }
2049
- if (data.enable !== undefined) {
2050
- this.enable = data.enable;
2051
- }
2052
- const width = data.width;
2053
- if (width !== undefined) {
2054
- this.width = width;
2055
- }
2056
- const height = data.height;
2057
- if (height !== undefined) {
2058
- this.height = height;
2059
- }
1541
+ class ParticlesDensity extends OptionLoader {
1542
+ enable = false;
1543
+ height = 1080;
1544
+ width = 1920;
1545
+ doLoad(data) {
1546
+ loadProperty(this, "enable", data.enable);
1547
+ loadProperty(this, "width", data.width);
1548
+ loadProperty(this, "height", data.height);
2060
1549
  }
2061
1550
  }
2062
1551
 
2063
- class ParticlesNumberLimit {
2064
- mode;
2065
- value;
2066
- constructor() {
2067
- this.mode = exports.LimitMode.delete;
2068
- this.value = 0;
2069
- }
2070
- load(data) {
2071
- if (isNull(data)) {
2072
- return;
2073
- }
2074
- if (data.mode !== undefined) {
2075
- this.mode = data.mode;
2076
- }
2077
- if (data.value !== undefined) {
2078
- this.value = data.value;
2079
- }
1552
+ class ParticlesNumberLimit extends OptionLoader {
1553
+ mode = exports.LimitMode.delete;
1554
+ value = 0;
1555
+ doLoad(data) {
1556
+ loadProperty(this, "mode", data.mode);
1557
+ loadProperty(this, "value", data.value);
2080
1558
  }
2081
1559
  }
2082
1560
 
2083
- class ParticlesNumber {
2084
- density;
2085
- limit;
2086
- value;
2087
- constructor() {
2088
- this.density = new ParticlesDensity();
2089
- this.limit = new ParticlesNumberLimit();
2090
- this.value = 0;
2091
- }
2092
- load(data) {
2093
- if (isNull(data)) {
2094
- return;
2095
- }
1561
+ class ParticlesNumber extends OptionLoader {
1562
+ density = new ParticlesDensity();
1563
+ limit = new ParticlesNumberLimit();
1564
+ value = 0;
1565
+ doLoad(data) {
2096
1566
  this.density.load(data.density);
2097
1567
  this.limit.load(data.limit);
2098
- if (data.value !== undefined) {
2099
- this.value = data.value;
2100
- }
1568
+ loadProperty(this, "value", data.value);
2101
1569
  }
2102
1570
  }
2103
1571
 
2104
- class Shape {
2105
- close;
2106
- options;
2107
- type;
2108
- constructor() {
2109
- this.close = true;
2110
- this.options = {};
2111
- this.type = "circle";
2112
- }
2113
- load(data) {
2114
- if (isNull(data)) {
2115
- return;
2116
- }
1572
+ class Shape extends OptionLoader {
1573
+ close = true;
1574
+ options = {};
1575
+ type = "circle";
1576
+ doLoad(data) {
2117
1577
  const options = data.options;
2118
1578
  if (options !== undefined) {
2119
1579
  for (const shape in options) {
@@ -2123,76 +1583,47 @@
2123
1583
  }
2124
1584
  }
2125
1585
  }
2126
- if (data.close !== undefined) {
2127
- this.close = data.close;
2128
- }
2129
- if (data.type !== undefined) {
2130
- this.type = data.type;
2131
- }
1586
+ loadProperty(this, "close", data.close);
1587
+ loadProperty(this, "type", data.type);
2132
1588
  }
2133
1589
  }
2134
1590
 
2135
1591
  class ZIndex extends ValueWithRandom {
2136
- opacityRate;
2137
- sizeRate;
2138
- velocityRate;
2139
- constructor() {
2140
- super();
2141
- this.opacityRate = 1;
2142
- this.sizeRate = 1;
2143
- this.velocityRate = 1;
2144
- }
2145
- load(data) {
2146
- super.load(data);
2147
- if (isNull(data)) {
2148
- return;
2149
- }
2150
- if (data.opacityRate !== undefined) {
2151
- this.opacityRate = data.opacityRate;
2152
- }
2153
- if (data.sizeRate !== undefined) {
2154
- this.sizeRate = data.sizeRate;
2155
- }
2156
- if (data.velocityRate !== undefined) {
2157
- this.velocityRate = data.velocityRate;
2158
- }
2159
- }
2160
- }
2161
-
2162
- class ParticlesOptions {
2163
- bounce;
2164
- effect;
2165
- groups;
2166
- move;
2167
- number;
1592
+ opacityRate = 1;
1593
+ sizeRate = 1;
1594
+ velocityRate = 1;
1595
+ doLoad(data) {
1596
+ super.doLoad(data);
1597
+ loadProperty(this, "opacityRate", data.opacityRate);
1598
+ loadProperty(this, "sizeRate", data.sizeRate);
1599
+ loadProperty(this, "velocityRate", data.velocityRate);
1600
+ }
1601
+ }
1602
+
1603
+ class ParticlesOptions extends OptionLoader {
1604
+ bounce = new ParticlesBounce();
1605
+ effect = new Effect();
1606
+ groups = {};
1607
+ move = new Move();
1608
+ number = new ParticlesNumber();
2168
1609
  paint;
2169
1610
  palette;
2170
- reduceDuplicates;
2171
- shape;
2172
- zIndex;
1611
+ reduceDuplicates = false;
1612
+ shape = new Shape();
1613
+ zIndex = new ZIndex();
2173
1614
  #container;
2174
1615
  #pluginManager;
2175
1616
  constructor(pluginManager, container) {
1617
+ super();
2176
1618
  this.#pluginManager = pluginManager;
2177
1619
  this.#container = container;
2178
- this.bounce = new ParticlesBounce();
2179
- this.effect = new Effect();
2180
- this.groups = {};
2181
- this.move = new Move();
2182
- this.number = new ParticlesNumber();
2183
1620
  this.paint = new Paint();
2184
1621
  this.paint.color = new AnimatableColor();
2185
1622
  this.paint.color.value = "#fff";
2186
1623
  this.paint.fill = new Fill();
2187
1624
  this.paint.fill.enable = true;
2188
- this.reduceDuplicates = false;
2189
- this.shape = new Shape();
2190
- this.zIndex = new ZIndex();
2191
1625
  }
2192
- load(data) {
2193
- if (isNull(data)) {
2194
- return;
2195
- }
1626
+ doLoad(data) {
2196
1627
  if (data.palette) {
2197
1628
  this.palette = data.palette;
2198
1629
  this.#importPalette(this.palette);
@@ -2250,7 +1681,7 @@
2250
1681
  }
2251
1682
  }
2252
1683
  }
2253
- #importPalette = (palette) => {
1684
+ #importPalette(palette) {
2254
1685
  const paletteData = this.#pluginManager.getPalette(palette);
2255
1686
  if (!paletteData) {
2256
1687
  return;
@@ -2294,117 +1725,71 @@
2294
1725
  mode: paletteData.blendMode,
2295
1726
  },
2296
1727
  });
2297
- };
2298
- }
2299
-
2300
- function loadOptions(options, ...sourceOptionsArr) {
2301
- for (const sourceOptions of sourceOptionsArr) {
2302
- options.load(sourceOptions);
2303
1728
  }
2304
1729
  }
1730
+
2305
1731
  function loadParticlesOptions(pluginManager, container, ...sourceOptionsArr) {
2306
1732
  const options = new ParticlesOptions(pluginManager, container);
2307
1733
  loadOptions(options, ...sourceOptionsArr);
2308
1734
  return options;
2309
1735
  }
2310
1736
 
2311
- class Options {
2312
- autoPlay;
1737
+ class Options extends OptionLoader {
1738
+ autoPlay = true;
2313
1739
  background;
2314
- clear;
2315
- defaultThemes;
2316
- delay;
2317
- detectRetina;
2318
- duration;
2319
- fpsLimit;
1740
+ clear = true;
1741
+ defaultThemes = {};
1742
+ delay = 0;
1743
+ detectRetina = true;
1744
+ duration = 0;
1745
+ fpsLimit = 120;
2320
1746
  fullScreen;
2321
- hdr;
1747
+ hdr = true;
2322
1748
  key;
2323
1749
  name;
2324
1750
  palette;
2325
1751
  particles;
2326
- pauseOnBlur;
2327
- pauseOnOutsideViewport;
1752
+ pauseOnBlur = true;
1753
+ pauseOnOutsideViewport = true;
2328
1754
  preset;
2329
1755
  resize;
2330
- smooth;
2331
- style;
2332
- zLayers;
1756
+ smooth = false;
1757
+ style = {};
1758
+ zLayers = 100;
2333
1759
  #container;
2334
1760
  #pluginManager;
2335
1761
  constructor(pluginManager, container) {
1762
+ super();
2336
1763
  this.#pluginManager = pluginManager;
2337
1764
  this.#container = container;
2338
- this.autoPlay = true;
2339
1765
  this.background = new Background();
2340
- this.clear = true;
2341
- this.defaultThemes = {};
2342
- this.delay = 0;
2343
1766
  this.fullScreen = new FullScreen();
2344
- this.detectRetina = true;
2345
- this.duration = 0;
2346
- this.fpsLimit = 120;
2347
- this.hdr = true;
2348
1767
  this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2349
- this.pauseOnBlur = true;
2350
- this.pauseOnOutsideViewport = true;
2351
1768
  this.resize = new ResizeEvent();
2352
- this.smooth = false;
2353
- this.style = {};
2354
- this.zLayers = 100;
2355
1769
  }
2356
- load(data) {
2357
- if (isNull(data)) {
2358
- return;
2359
- }
1770
+ doLoad(data) {
2360
1771
  if (data.preset !== undefined) {
2361
1772
  this.preset = data.preset;
2362
1773
  executeOnSingleOrMultiple(this.preset, preset => {
2363
1774
  this.#importPreset(preset);
2364
1775
  });
2365
1776
  }
2366
- if (data.palette !== undefined) {
2367
- this.palette = data.palette;
2368
- this.#importPalette(this.palette);
2369
- }
2370
- if (data.autoPlay !== undefined) {
2371
- this.autoPlay = data.autoPlay;
2372
- }
2373
- if (data.clear !== undefined) {
2374
- this.clear = data.clear;
2375
- }
2376
- if (data.key !== undefined) {
2377
- this.key = data.key;
2378
- }
2379
- if (data.name !== undefined) {
2380
- this.name = data.name;
2381
- }
2382
- if (data.delay !== undefined) {
2383
- this.delay = setRangeValue(data.delay);
2384
- }
2385
- const detectRetina = data.detectRetina;
2386
- if (detectRetina !== undefined) {
2387
- this.detectRetina = detectRetina;
2388
- }
2389
- if (data.duration !== undefined) {
2390
- this.duration = setRangeValue(data.duration);
2391
- }
2392
- const fpsLimit = data.fpsLimit;
2393
- if (fpsLimit !== undefined) {
2394
- this.fpsLimit = fpsLimit;
2395
- }
2396
- if (data.hdr !== undefined) {
2397
- this.hdr = data.hdr;
2398
- }
2399
- if (data.pauseOnBlur !== undefined) {
2400
- this.pauseOnBlur = data.pauseOnBlur;
2401
- }
2402
- if (data.pauseOnOutsideViewport !== undefined) {
2403
- this.pauseOnOutsideViewport = data.pauseOnOutsideViewport;
2404
- }
2405
- if (data.zLayers !== undefined) {
2406
- this.zLayers = data.zLayers;
1777
+ if (data.palette !== undefined) {
1778
+ this.palette = data.palette;
1779
+ this.#importPalette(this.palette);
2407
1780
  }
1781
+ loadProperty(this, "autoPlay", data.autoPlay);
1782
+ loadProperty(this, "clear", data.clear);
1783
+ loadProperty(this, "key", data.key);
1784
+ loadProperty(this, "name", data.name);
1785
+ loadRangeProperty(this, "delay", data.delay);
1786
+ loadProperty(this, "detectRetina", data.detectRetina);
1787
+ loadRangeProperty(this, "duration", data.duration);
1788
+ loadProperty(this, "fpsLimit", data.fpsLimit);
1789
+ loadProperty(this, "hdr", data.hdr);
1790
+ loadProperty(this, "pauseOnBlur", data.pauseOnBlur);
1791
+ loadProperty(this, "pauseOnOutsideViewport", data.pauseOnOutsideViewport);
1792
+ loadProperty(this, "zLayers", data.zLayers);
2408
1793
  this.background.load(data.background);
2409
1794
  const fullScreen = data.fullScreen;
2410
1795
  if (isBoolean(fullScreen)) {
@@ -2416,14 +1801,12 @@
2416
1801
  this.particles.load(data.particles);
2417
1802
  this.resize.load(data.resize);
2418
1803
  this.style = deepExtend(this.style, data.style);
2419
- if (data.smooth !== undefined) {
2420
- this.smooth = data.smooth;
2421
- }
1804
+ loadProperty(this, "smooth", data.smooth);
2422
1805
  this.#pluginManager.plugins.forEach(plugin => {
2423
1806
  plugin.loadOptions(this.#container, this, data);
2424
1807
  });
2425
1808
  }
2426
- #importPalette = palette => {
1809
+ #importPalette(palette) {
2427
1810
  const paletteData = this.#pluginManager.getPalette(palette);
2428
1811
  if (!paletteData) {
2429
1812
  return;
@@ -2440,143 +1823,19 @@
2440
1823
  palette,
2441
1824
  },
2442
1825
  });
2443
- };
2444
- #importPreset = preset => {
2445
- this.load(this.#pluginManager.getPreset(preset));
2446
- };
2447
- }
2448
-
2449
- function paintBase(context, dimension, baseColor) {
2450
- context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
2451
- context.fillRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
2452
- }
2453
- function paintImage(context, dimension, image, opacity) {
2454
- if (!image) {
2455
- return;
2456
- }
2457
- const prevAlpha = context.globalAlpha;
2458
- context.globalAlpha = opacity;
2459
- context.drawImage(image, originPoint.x, originPoint.y, dimension.width, dimension.height);
2460
- context.globalAlpha = prevAlpha;
2461
- }
2462
- function clear(context, dimension) {
2463
- context.clearRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
2464
- }
2465
- function drawParticle(data) {
2466
- const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
2467
- x: pos.x,
2468
- y: pos.y,
2469
- };
2470
- context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
2471
- if (colorStyles.fill) {
2472
- context.fillStyle = colorStyles.fill;
2473
- }
2474
- const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
2475
- context.lineWidth = strokeWidth;
2476
- if (colorStyles.stroke) {
2477
- context.strokeStyle = colorStyles.stroke;
2478
- }
2479
- const drawData = {
2480
- context,
2481
- particle,
2482
- radius,
2483
- drawRadius: radius * drawScale,
2484
- opacity,
2485
- delta,
2486
- pixelRatio: container.retina.pixelRatio,
2487
- fill: fillEnabled,
2488
- stroke: strokeWidth > minStrokeWidth,
2489
- transformData,
2490
- position: { ...pos },
2491
- drawPosition,
2492
- drawScale,
2493
- };
2494
- for (const plugin of container.plugins) {
2495
- plugin.drawParticleTransform?.(drawData);
2496
- }
2497
- const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
2498
- drawBeforeEffect(effect, drawData);
2499
- drawShapeBeforeDraw(shape, drawData);
2500
- drawShape(shape, drawData);
2501
- drawShapeAfterDraw(shape, drawData);
2502
- drawAfterEffect(effect, drawData);
2503
- context.resetTransform();
2504
- }
2505
- function drawAfterEffect(drawer, data) {
2506
- if (!drawer?.drawAfter) {
2507
- return;
2508
- }
2509
- const { particle } = data;
2510
- if (!particle.effect) {
2511
- return;
2512
- }
2513
- drawer.drawAfter(data);
2514
- }
2515
- function drawBeforeEffect(drawer, data) {
2516
- if (!drawer?.drawBefore) {
2517
- return;
2518
- }
2519
- const { particle } = data;
2520
- if (!particle.effect) {
2521
- return;
2522
- }
2523
- drawer.drawBefore(data);
2524
- }
2525
- function drawShape(drawer, data) {
2526
- if (!drawer) {
2527
- return;
2528
- }
2529
- const { context, fill, particle, stroke } = data;
2530
- if (!particle.shape) {
2531
- return;
2532
- }
2533
- context.beginPath();
2534
- drawer.draw(data);
2535
- if (particle.shapeClose) {
2536
- context.closePath();
2537
- }
2538
- if (fill) {
2539
- context.fill();
2540
- }
2541
- if (stroke) {
2542
- context.stroke();
2543
1826
  }
2544
- }
2545
- function drawShapeAfterDraw(drawer, data) {
2546
- if (!drawer?.afterDraw) {
2547
- return;
2548
- }
2549
- const { particle } = data;
2550
- if (!particle.shape) {
2551
- return;
2552
- }
2553
- drawer.afterDraw(data);
2554
- }
2555
- function drawShapeBeforeDraw(drawer, data) {
2556
- if (!drawer?.beforeDraw) {
2557
- return;
2558
- }
2559
- const { particle } = data;
2560
- if (!particle.shape) {
2561
- return;
2562
- }
2563
- drawer.beforeDraw(data);
2564
- }
2565
- function drawParticlePlugin(context, plugin, particle, delta) {
2566
- if (!plugin.drawParticle) {
2567
- return;
1827
+ #importPreset(preset) {
1828
+ this.load(this.#pluginManager.getPreset(preset));
2568
1829
  }
2569
- plugin.drawParticle(context, particle, delta);
2570
1830
  }
2571
1831
 
2572
- const styleCache = new Map(), maxCacheSize = 1000, firstIndex = 0, rgbFixedPrecision = 2, hslFixedPrecision = 2;
1832
+ const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, sdrReferenceWhiteNits = 203;
2573
1833
  function getCachedStyle(key, generator) {
2574
1834
  let cached = styleCache.get(key);
2575
1835
  if (!cached) {
2576
1836
  cached = generator();
2577
- if (styleCache.size >= maxCacheSize) {
2578
- const keysToDelete = [...styleCache.keys()].slice(firstIndex, maxCacheSize * half);
2579
- keysToDelete.forEach(k => styleCache.delete(k));
1837
+ if (styleCache.size > maxStyleCacheSize) {
1838
+ styleCache.clear();
2580
1839
  }
2581
1840
  styleCache.set(key, cached);
2582
1841
  }
@@ -2643,10 +1902,6 @@
2643
1902
  }
2644
1903
  return undefined;
2645
1904
  }
2646
- function colorToHsl(pluginManager, color, index, useIndex = true) {
2647
- const rgb = colorToRgb(pluginManager, color, index, useIndex);
2648
- return rgb ? rgbToHsl(rgb) : undefined;
2649
- }
2650
1905
  function rangeColorToHsl(pluginManager, color, index, useIndex = true) {
2651
1906
  const rgb = rangeColorToRgb(pluginManager, color, index, useIndex);
2652
1907
  return rgb ? rgbToHsl(rgb) : undefined;
@@ -2686,34 +1941,35 @@
2686
1941
  function stringToRgb(pluginManager, input) {
2687
1942
  return stringToRgba(pluginManager, input);
2688
1943
  }
1944
+ function hslChannel(temp1, temp2, temp3) {
1945
+ const temp3Min = 0, temp3Max = 1;
1946
+ if (temp3 < temp3Min) {
1947
+ temp3++;
1948
+ }
1949
+ if (temp3 > temp3Max) {
1950
+ temp3--;
1951
+ }
1952
+ if (temp3 * sextuple < temp3Max) {
1953
+ return temp1 + (temp2 - temp1) * sextuple * temp3;
1954
+ }
1955
+ if (temp3 * double < temp3Max) {
1956
+ return temp2;
1957
+ }
1958
+ if (temp3 * triple < temp3Max * double) {
1959
+ const temp3Offset = double / triple;
1960
+ return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
1961
+ }
1962
+ return temp1;
1963
+ }
2689
1964
  function hslToRgb(hsl) {
2690
1965
  const h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax;
2691
1966
  if (s === sMin) {
2692
1967
  const grayscaleValue = Math.round(lNormalized * rgbMax);
2693
1968
  return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
2694
1969
  }
2695
- const channel = (temp1, temp2, temp3) => {
2696
- const temp3Min = 0, temp3Max = 1;
2697
- if (temp3 < temp3Min) {
2698
- temp3++;
2699
- }
2700
- if (temp3 > temp3Max) {
2701
- temp3--;
2702
- }
2703
- if (temp3 * sextuple < temp3Max) {
2704
- return temp1 + (temp2 - temp1) * sextuple * temp3;
2705
- }
2706
- if (temp3 * double < temp3Max) {
2707
- return temp2;
2708
- }
2709
- if (temp3 * triple < temp3Max * double) {
2710
- const temp3Offset = double / triple;
2711
- return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
2712
- }
2713
- return temp1;
2714
- }, temp1 = lNormalized < half
1970
+ const temp1 = lNormalized < half
2715
1971
  ? lNormalized * (sNormalizedOffset + sNormalized)
2716
- : lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseThird = phaseNumerator / triple, red = Math.min(rgbMax, rgbMax * channel(temp2, temp1, hNormalized + phaseThird)), green = Math.min(rgbMax, rgbMax * channel(temp2, temp1, hNormalized)), blue = Math.min(rgbMax, rgbMax * channel(temp2, temp1, hNormalized - phaseThird));
1972
+ : lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseThird = phaseNumerator / triple, red = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized + phaseThird)), green = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized)), blue = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized - phaseThird));
2717
1973
  return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
2718
1974
  }
2719
1975
  function hslaToRgba(hsla) {
@@ -2726,7 +1982,7 @@
2726
1982
  };
2727
1983
  }
2728
1984
  function getRandomRgbColor(min) {
2729
- const fixedMin = min ?? defaultRgbMin, fixedMax = rgbMax + identity$1, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
1985
+ const fixedMin = min ?? defaultRgbMin, fixedMax = rgbMax + identity, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
2730
1986
  return {
2731
1987
  b: getRgbInRangeValue(),
2732
1988
  g: getRgbInRangeValue(),
@@ -2737,21 +1993,18 @@
2737
1993
  const op = opacity ?? defaultOpacity$2, key = `rgb-${color.r.toFixed(rgbFixedPrecision)}-${color.g.toFixed(rgbFixedPrecision)}-${color.b.toFixed(rgbFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
2738
1994
  return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
2739
1995
  }
2740
- function getHdrStyleFromRgb(color, opacity) {
2741
- return `color(display-p3 ${(color.r / rgbMax).toString()} ${(color.g / rgbMax).toString()} ${(color.b / rgbMax).toString()} / ${(opacity ?? defaultOpacity$2).toString()})`;
1996
+ function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
1997
+ const headroom = peakNits / sdrReferenceWhiteNits;
1998
+ return `color(display-p3 ${((color.r / rgbMax) * headroom).toString()} ${((color.g / rgbMax) * headroom).toString()} ${((color.b / rgbMax) * headroom).toString()} / ${(opacity ?? defaultOpacity$2).toString()})`;
2742
1999
  }
2743
2000
  function getSdrStyleFromRgb(color, opacity) {
2744
2001
  return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$2).toString()})`;
2745
2002
  }
2746
2003
  function getStyleFromHsl(color, hdr, opacity) {
2747
2004
  const op = opacity ?? defaultOpacity$2, key = `hsl-${color.h.toFixed(hslFixedPrecision)}-${color.s.toFixed(hslFixedPrecision)}-${color.l.toFixed(hslFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
2748
- return getCachedStyle(key, () => (hdr ? getHdrStyleFromHsl(color, opacity) : getSdrStyleFromHsl(color, opacity)));
2749
- }
2750
- function getHdrStyleFromHsl(color, opacity) {
2751
- return getHdrStyleFromRgb(hslToRgb(color), opacity);
2752
- }
2753
- function getSdrStyleFromHsl(color, opacity) {
2754
- return `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${(opacity ?? defaultOpacity$2).toString()})`;
2005
+ return getCachedStyle(key, () => hdr
2006
+ ? getStyleFromRgb(hslToRgb(color), true, opacity)
2007
+ : `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
2755
2008
  }
2756
2009
  function colorMix(color1, color2, size1, size2) {
2757
2010
  let rgb1 = color1, rgb2 = color2;
@@ -2929,7 +2182,11 @@
2929
2182
 
2930
2183
  const tsParticles = initEngine();
2931
2184
 
2932
- const instances = new Map(), defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity$1 = 1, defaultRadius = 3;
2185
+ const instances = new Map();
2186
+ function deleteParticlesInstance(id) {
2187
+ instances.delete(id);
2188
+ }
2189
+ const defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity$1 = 1, defaultRadius = 3;
2933
2190
  function getDefaultOptions(options, canvas) {
2934
2191
  return {
2935
2192
  fullScreen: {
@@ -2972,7 +2229,10 @@
2972
2229
  return existing;
2973
2230
  }
2974
2231
  if (existing) {
2975
- return existing;
2232
+ if (!existing.destroyed) {
2233
+ return existing;
2234
+ }
2235
+ instances.delete(id);
2976
2236
  }
2977
2237
  const create = async () => {
2978
2238
  const particlesOptions = getDefaultOptions(sourceOptions, canvas), container = await engine.load({ id, element: canvas, options: particlesOptions });
@@ -2980,7 +2240,7 @@
2980
2240
  instances.delete(id);
2981
2241
  return;
2982
2242
  }
2983
- const { ParticlesInstance } = await Promise.resolve().then(function () { return ParticlesInstance$1; }), instance = new ParticlesInstance(container);
2243
+ const { ParticlesInstance } = await Promise.resolve().then(function () { return ParticlesInstance$1; }), instance = new ParticlesInstance(container, id);
2984
2244
  instances.set(id, instance);
2985
2245
  return instance;
2986
2246
  }, createPromise = create();
@@ -2989,22 +2249,14 @@
2989
2249
  }
2990
2250
 
2991
2251
  class Blend {
2992
- enable;
2993
- mode;
2994
- constructor() {
2995
- this.mode = "destination-out";
2996
- this.enable = false;
2997
- }
2252
+ enable = false;
2253
+ mode = "destination-out";
2998
2254
  load(data) {
2999
2255
  if (isNull(data)) {
3000
2256
  return;
3001
2257
  }
3002
- if (data.mode !== undefined) {
3003
- this.mode = data.mode;
3004
- }
3005
- if (data.enable !== undefined) {
3006
- this.enable = data.enable;
3007
- }
2258
+ loadProperty(this, "mode", data.mode);
2259
+ loadProperty(this, "enable", data.enable);
3008
2260
  }
3009
2261
  }
3010
2262
 
@@ -3034,7 +2286,7 @@
3034
2286
  }
3035
2287
 
3036
2288
  async function loadBlendPlugin(engine) {
3037
- engine.checkVersion("4.1.2");
2289
+ engine.checkVersion("4.2.0");
3038
2290
  await engine.pluginManager.register(e => {
3039
2291
  e.pluginManager.addPlugin(new BlendPlugin());
3040
2292
  });
@@ -3071,7 +2323,7 @@
3071
2323
  }
3072
2324
 
3073
2325
  async function loadCircleShape(engine) {
3074
- engine.checkVersion("4.1.2");
2326
+ engine.checkVersion("4.2.0");
3075
2327
  await engine.pluginManager.register(e => {
3076
2328
  e.pluginManager.addShape(["circle"], () => {
3077
2329
  return Promise.resolve(new CircleDrawer());
@@ -3119,7 +2371,7 @@
3119
2371
  }
3120
2372
 
3121
2373
  async function loadHexColorPlugin(engine) {
3122
- engine.checkVersion("4.1.2");
2374
+ engine.checkVersion("4.2.0");
3123
2375
  await engine.pluginManager.register(e => {
3124
2376
  e.pluginManager.addColorManager("hex", new HexColorManager());
3125
2377
  });
@@ -3172,7 +2424,7 @@
3172
2424
  }
3173
2425
 
3174
2426
  async function loadHslColorPlugin(engine) {
3175
- engine.checkVersion("4.1.2");
2427
+ engine.checkVersion("4.2.0");
3176
2428
  await engine.pluginManager.register(e => {
3177
2429
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3178
2430
  });
@@ -3196,7 +2448,7 @@
3196
2448
  }
3197
2449
 
3198
2450
  async function loadMovePlugin(engine) {
3199
- engine.checkVersion("4.1.2");
2451
+ engine.checkVersion("4.2.0");
3200
2452
  await engine.pluginManager.register(e => {
3201
2453
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3202
2454
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3214,31 +2466,137 @@
3214
2466
  });
3215
2467
  }
3216
2468
 
3217
- class OpacityAnimation extends RangedAnimationOptions {
3218
- destroy;
3219
- constructor() {
3220
- super();
3221
- this.destroy = exports.DestroyType.none;
3222
- this.speed = 2;
2469
+ function checkDestroy(particle, destroyType, value, minValue, maxValue) {
2470
+ switch (destroyType) {
2471
+ case exports.DestroyType.max:
2472
+ if (value >= maxValue) {
2473
+ particle.destroy();
2474
+ }
2475
+ break;
2476
+ case exports.DestroyType.min:
2477
+ if (value <= minValue) {
2478
+ particle.destroy();
2479
+ }
2480
+ break;
2481
+ }
2482
+ }
2483
+ function initParticleNumericAnimationValue(options, pxRatio) {
2484
+ const valueRange = options.value, animationOptions = options.animation, res = {
2485
+ delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
2486
+ enable: animationOptions.enable,
2487
+ value: getRangeValue(options.value) * pxRatio,
2488
+ max: getRangeMax(valueRange) * pxRatio,
2489
+ min: getRangeMin(valueRange) * pxRatio,
2490
+ loops: 0,
2491
+ maxLoops: getRangeValue(animationOptions.count),
2492
+ time: 0,
2493
+ }, decayOffset = 1;
2494
+ if (animationOptions.enable) {
2495
+ res.decay = decayOffset - getRangeValue(animationOptions.decay);
2496
+ switch (animationOptions.mode) {
2497
+ case exports.AnimationMode.increase:
2498
+ res.status = exports.AnimationStatus.increasing;
2499
+ break;
2500
+ case exports.AnimationMode.decrease:
2501
+ res.status = exports.AnimationStatus.decreasing;
2502
+ break;
2503
+ case exports.AnimationMode.random:
2504
+ res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
2505
+ break;
2506
+ }
2507
+ const autoStatus = animationOptions.mode === exports.AnimationMode.auto;
2508
+ switch (animationOptions.startValue) {
2509
+ case exports.StartValueType.min:
2510
+ res.value = res.min;
2511
+ if (autoStatus) {
2512
+ res.status = exports.AnimationStatus.increasing;
2513
+ }
2514
+ break;
2515
+ case exports.StartValueType.max:
2516
+ res.value = res.max;
2517
+ if (autoStatus) {
2518
+ res.status = exports.AnimationStatus.decreasing;
2519
+ }
2520
+ break;
2521
+ case exports.StartValueType.random:
2522
+ default:
2523
+ res.value = randomInRangeValue(res);
2524
+ if (autoStatus) {
2525
+ res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
2526
+ }
2527
+ break;
2528
+ }
2529
+ }
2530
+ res.initialValue = res.value;
2531
+ return res;
2532
+ }
2533
+ function updateAnimation(particle, data, changeDirection, destroyType, delta) {
2534
+ const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
2535
+ if (particle.destroyed ||
2536
+ !data.enable ||
2537
+ ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
2538
+ return;
2539
+ }
2540
+ const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
2541
+ data.time ??= 0;
2542
+ const delayTime = data.delayTime ?? minDelay;
2543
+ if (delayTime > minDelay && data.time < delayTime) {
2544
+ data.time += delta.value;
2545
+ if (data.time < delayTime) {
2546
+ return;
2547
+ }
2548
+ }
2549
+ switch (data.status) {
2550
+ case exports.AnimationStatus.increasing:
2551
+ data.value += velocity;
2552
+ break;
2553
+ case exports.AnimationStatus.decreasing:
2554
+ data.value -= velocity;
2555
+ break;
2556
+ }
2557
+ if (data.velocity && decay !== identity) {
2558
+ data.velocity *= decay;
2559
+ }
2560
+ switch (data.status) {
2561
+ case exports.AnimationStatus.increasing:
2562
+ if (data.value >= maxValue) {
2563
+ {
2564
+ data.status = exports.AnimationStatus.decreasing;
2565
+ }
2566
+ data.loops ??= minLoops;
2567
+ data.loops++;
2568
+ }
2569
+ break;
2570
+ case exports.AnimationStatus.decreasing:
2571
+ if (data.value <= minValue) {
2572
+ {
2573
+ data.status = exports.AnimationStatus.increasing;
2574
+ }
2575
+ data.loops ??= minLoops;
2576
+ data.loops++;
2577
+ }
2578
+ break;
2579
+ }
2580
+ checkDestroy(particle, destroyType, data.value, minValue, maxValue);
2581
+ if (!particle.destroyed) {
2582
+ data.value = clamp(data.value, minValue, maxValue);
3223
2583
  }
2584
+ }
2585
+
2586
+ class OpacityAnimation extends RangedAnimationOptions {
2587
+ destroy = exports.DestroyType.none;
3224
2588
  load(data) {
3225
2589
  super.load(data);
3226
2590
  if (isNull(data)) {
3227
2591
  return;
3228
2592
  }
3229
- if (data.destroy !== undefined) {
3230
- this.destroy = data.destroy;
3231
- }
2593
+ loadProperty(this, "destroy", data.destroy);
3232
2594
  }
3233
2595
  }
3234
2596
 
3235
2597
  class Opacity extends RangedAnimationValueWithRandom {
3236
- animation;
3237
- constructor() {
3238
- super();
3239
- this.animation = new OpacityAnimation();
3240
- this.value = 1;
3241
- }
2598
+ animation = new OpacityAnimation();
2599
+ value = 1;
3242
2600
  load(data) {
3243
2601
  if (isNull(data)) {
3244
2602
  return;
@@ -3282,10 +2640,7 @@
3282
2640
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3283
2641
  }
3284
2642
  loadOptions(options, ...sources) {
3285
- options.opacity ??= new Opacity();
3286
- for (const source of sources) {
3287
- options.opacity.load(source?.opacity);
3288
- }
2643
+ loadOptionProperty(options, "opacity", Opacity, ...sources);
3289
2644
  }
3290
2645
  reset(particle) {
3291
2646
  if (!particle.opacity) {
@@ -3303,7 +2658,7 @@
3303
2658
  }
3304
2659
 
3305
2660
  async function loadOpacityUpdater(engine) {
3306
- engine.checkVersion("4.1.2");
2661
+ engine.checkVersion("4.2.0");
3307
2662
  await engine.pluginManager.register(e => {
3308
2663
  e.pluginManager.addParticleUpdater("opacity", container => {
3309
2664
  return Promise.resolve(new OpacityUpdater(container));
@@ -3311,7 +2666,7 @@
3311
2666
  });
3312
2667
  }
3313
2668
 
3314
- const minVelocity$4 = 0, boundsMin = 0;
2669
+ const boundsMin = 0;
3315
2670
  function bounceHorizontal(data) {
3316
2671
  if ((data.outMode !== exports.OutMode.bounce && data.outMode !== exports.OutMode.split) ||
3317
2672
  (data.direction !== exports.OutModeDirection.left && data.direction !== exports.OutModeDirection.right)) {
@@ -3326,8 +2681,8 @@
3326
2681
  const velocity = data.particle.velocity.x;
3327
2682
  let bounced = false;
3328
2683
  if (data.outOfCanvas &&
3329
- ((data.direction === exports.OutModeDirection.right && velocity > minVelocity$4) ||
3330
- (data.direction === exports.OutModeDirection.left && velocity < minVelocity$4))) {
2684
+ ((data.direction === exports.OutModeDirection.right && velocity > minVelocity) ||
2685
+ (data.direction === exports.OutModeDirection.left && velocity < minVelocity))) {
3331
2686
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3332
2687
  data.particle.velocity.x *= -newVelocity;
3333
2688
  bounced = true;
@@ -3360,8 +2715,8 @@
3360
2715
  const velocity = data.particle.velocity.y;
3361
2716
  let bounced = false;
3362
2717
  if (data.outOfCanvas &&
3363
- ((data.direction === exports.OutModeDirection.bottom && velocity > minVelocity$4) ||
3364
- (data.direction === exports.OutModeDirection.top && velocity < minVelocity$4))) {
2718
+ ((data.direction === exports.OutModeDirection.bottom && velocity > minVelocity) ||
2719
+ (data.direction === exports.OutModeDirection.top && velocity < minVelocity))) {
3365
2720
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3366
2721
  data.particle.velocity.y *= -newVelocity;
3367
2722
  bounced = true;
@@ -3414,7 +2769,6 @@
3414
2769
  }
3415
2770
  }
3416
2771
 
3417
- const minVelocity$3 = 0;
3418
2772
  class DestroyOutMode {
3419
2773
  modes;
3420
2774
  constructor(_container) {
@@ -3433,10 +2787,10 @@
3433
2787
  break;
3434
2788
  case exports.ParticleOutType.inside: {
3435
2789
  const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
3436
- if ((vx < minVelocity$3 && dx > particle.moveCenter.radius) ||
3437
- (vy < minVelocity$3 && dy > particle.moveCenter.radius) ||
3438
- (vx >= minVelocity$3 && dx < -particle.moveCenter.radius) ||
3439
- (vy >= minVelocity$3 && dy < -particle.moveCenter.radius)) {
2790
+ if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
2791
+ (vy < minVelocity && dy > particle.moveCenter.radius) ||
2792
+ (vx >= minVelocity && dx < -particle.moveCenter.radius) ||
2793
+ (vy >= minVelocity && dy < -particle.moveCenter.radius)) {
3440
2794
  return;
3441
2795
  }
3442
2796
  break;
@@ -3446,7 +2800,6 @@
3446
2800
  }
3447
2801
  }
3448
2802
 
3449
- const minVelocity$2 = 0;
3450
2803
  class NoneOutMode {
3451
2804
  modes;
3452
2805
  #container;
@@ -3466,10 +2819,10 @@
3466
2819
  }
3467
2820
  const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3468
2821
  if (!gravityOptions.enable) {
3469
- if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3470
- (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
3471
- (particle.velocity.x > minVelocity$2 && particle.position.x <= canvasSize.width + pRadius) ||
3472
- (particle.velocity.x < minVelocity$2 && particle.position.x >= -pRadius)) {
2822
+ if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
2823
+ (particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
2824
+ (particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
2825
+ (particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
3473
2826
  return;
3474
2827
  }
3475
2828
  if (!isPointInside(particle.position, container.canvas.size, originPoint, pRadius, direction)) {
@@ -3488,7 +2841,7 @@
3488
2841
  }
3489
2842
  }
3490
2843
 
3491
- const minVelocity$1 = 0, minDistance$2 = 0, updateVector = Vector.origin;
2844
+ const updateVector = Vector.origin;
3492
2845
  class OutOutMode {
3493
2846
  modes;
3494
2847
  #container;
@@ -3509,10 +2862,10 @@
3509
2862
  updateVector.angle = particle.velocity.angle + Math.PI;
3510
2863
  updateVector.addTo(particle.moveCenter);
3511
2864
  const { dx, dy } = getDistances(particle.position, updateVector);
3512
- if ((vx <= minVelocity$1 && dx >= minDistance$2) ||
3513
- (vy <= minVelocity$1 && dy >= minDistance$2) ||
3514
- (vx >= minVelocity$1 && dx <= minDistance$2) ||
3515
- (vy >= minVelocity$1 && dy <= minDistance$2)) {
2865
+ if ((vx <= minVelocity && dx >= minDistance$2) ||
2866
+ (vy <= minVelocity && dy >= minDistance$2) ||
2867
+ (vx >= minVelocity && dx <= minDistance$2) ||
2868
+ (vy >= minVelocity && dy <= minDistance$2)) {
3516
2869
  return;
3517
2870
  }
3518
2871
  particle.position.x = Math.floor(randomInRangeValue({
@@ -3636,21 +2989,21 @@
3636
2989
  this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, exports.OutModeDirection.right);
3637
2990
  this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, exports.OutModeDirection.top);
3638
2991
  }
3639
- #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
2992
+ #addUpdaterIfMissing(particle, outMode, getUpdater) {
3640
2993
  const outModes = particle.options.move.outModes;
3641
2994
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3642
2995
  this.updaters.set(outMode, getUpdater(this.#container));
3643
2996
  }
3644
- };
3645
- #updateOutMode = (particle, delta, outMode, direction) => {
2997
+ }
2998
+ #updateOutMode(particle, delta, outMode, direction) {
3646
2999
  for (const updater of this.updaters.values()) {
3647
3000
  updater.update(particle, direction, delta, outMode);
3648
3001
  }
3649
- };
3002
+ }
3650
3003
  }
3651
3004
 
3652
3005
  async function loadOutModesUpdater(engine) {
3653
- engine.checkVersion("4.1.2");
3006
+ engine.checkVersion("4.2.0");
3654
3007
  await engine.pluginManager.register(e => {
3655
3008
  e.pluginManager.addParticleUpdater("outModes", container => {
3656
3009
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3721,7 +3074,7 @@
3721
3074
  }
3722
3075
 
3723
3076
  async function loadPaintUpdater(engine) {
3724
- engine.checkVersion("4.1.2");
3077
+ engine.checkVersion("4.2.0");
3725
3078
  await engine.pluginManager.register(e => {
3726
3079
  e.pluginManager.addParticleUpdater("paint", container => {
3727
3080
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3776,37 +3129,26 @@
3776
3129
  }
3777
3130
 
3778
3131
  async function loadRgbColorPlugin(engine) {
3779
- engine.checkVersion("4.1.2");
3132
+ engine.checkVersion("4.2.0");
3780
3133
  await engine.pluginManager.register(e => {
3781
3134
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3782
3135
  });
3783
3136
  }
3784
3137
 
3785
3138
  class SizeAnimation extends RangedAnimationOptions {
3786
- destroy;
3787
- constructor() {
3788
- super();
3789
- this.destroy = exports.DestroyType.none;
3790
- this.speed = 5;
3791
- }
3139
+ destroy = exports.DestroyType.none;
3792
3140
  load(data) {
3793
3141
  super.load(data);
3794
3142
  if (isNull(data)) {
3795
3143
  return;
3796
3144
  }
3797
- if (data.destroy !== undefined) {
3798
- this.destroy = data.destroy;
3799
- }
3145
+ loadProperty(this, "destroy", data.destroy);
3800
3146
  }
3801
3147
  }
3802
3148
 
3803
3149
  class Size extends RangedAnimationValueWithRandom {
3804
- animation;
3805
- constructor() {
3806
- super();
3807
- this.animation = new SizeAnimation();
3808
- this.value = 3;
3809
- }
3150
+ animation = new SizeAnimation();
3151
+ value = 3;
3810
3152
  load(data) {
3811
3153
  super.load(data);
3812
3154
  if (isNull(data)) {
@@ -3849,10 +3191,7 @@
3849
3191
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3850
3192
  }
3851
3193
  loadOptions(options, ...sources) {
3852
- options.size ??= new Size();
3853
- for (const source of sources) {
3854
- options.size.load(source?.size);
3855
- }
3194
+ loadOptionProperty(options, "size", Size, ...sources);
3856
3195
  }
3857
3196
  preInit(particle) {
3858
3197
  const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
@@ -3875,7 +3214,7 @@
3875
3214
  }
3876
3215
 
3877
3216
  async function loadSizeUpdater(engine) {
3878
- engine.checkVersion("4.1.2");
3217
+ engine.checkVersion("4.2.0");
3879
3218
  await engine.pluginManager.register(e => {
3880
3219
  e.pluginManager.addParticleUpdater("size", container => {
3881
3220
  return Promise.resolve(new SizeUpdater(container));
@@ -3884,7 +3223,7 @@
3884
3223
  }
3885
3224
 
3886
3225
  async function loadBasic(engine) {
3887
- engine.checkVersion("4.1.2");
3226
+ engine.checkVersion("4.2.0");
3888
3227
  await engine.pluginManager.register(async (e) => {
3889
3228
  await Promise.all([
3890
3229
  loadBlendPlugin(e),
@@ -3902,22 +3241,14 @@
3902
3241
  }
3903
3242
 
3904
3243
  class ClickEvent {
3905
- enable;
3906
- mode;
3907
- constructor() {
3908
- this.enable = false;
3909
- this.mode = [];
3910
- }
3244
+ enable = false;
3245
+ mode = [];
3911
3246
  load(data) {
3912
3247
  if (isNull(data)) {
3913
3248
  return;
3914
3249
  }
3915
- if (data.enable !== undefined) {
3916
- this.enable = data.enable;
3917
- }
3918
- if (data.mode !== undefined) {
3919
- this.mode = data.mode;
3920
- }
3250
+ loadProperty(this, "enable", data.enable);
3251
+ loadProperty(this, "mode", data.mode);
3921
3252
  }
3922
3253
  }
3923
3254
 
@@ -3928,64 +3259,37 @@
3928
3259
  })(DivType || (DivType = {}));
3929
3260
 
3930
3261
  class DivEvent {
3931
- enable;
3932
- mode;
3933
- selectors;
3934
- type;
3935
- constructor() {
3936
- this.selectors = [];
3937
- this.enable = false;
3938
- this.mode = [];
3939
- this.type = DivType.circle;
3940
- }
3262
+ enable = false;
3263
+ mode = [];
3264
+ selectors = [];
3265
+ type = DivType.circle;
3941
3266
  load(data) {
3942
3267
  if (isNull(data)) {
3943
3268
  return;
3944
3269
  }
3945
- if (data.selectors !== undefined) {
3946
- this.selectors = data.selectors;
3947
- }
3948
- if (data.enable !== undefined) {
3949
- this.enable = data.enable;
3950
- }
3951
- if (data.mode !== undefined) {
3952
- this.mode = data.mode;
3953
- }
3954
- if (data.type !== undefined) {
3955
- this.type = data.type;
3956
- }
3270
+ loadProperty(this, "selectors", data.selectors);
3271
+ loadProperty(this, "enable", data.enable);
3272
+ loadProperty(this, "mode", data.mode);
3273
+ loadProperty(this, "type", data.type);
3957
3274
  }
3958
3275
  }
3959
3276
 
3960
3277
  class HoverEvent {
3961
- enable;
3962
- mode;
3963
- constructor() {
3964
- this.enable = false;
3965
- this.mode = [];
3966
- }
3278
+ enable = false;
3279
+ mode = [];
3967
3280
  load(data) {
3968
3281
  if (isNull(data)) {
3969
3282
  return;
3970
3283
  }
3971
- if (data.enable !== undefined) {
3972
- this.enable = data.enable;
3973
- }
3974
- if (data.mode !== undefined) {
3975
- this.mode = data.mode;
3976
- }
3284
+ loadProperty(this, "enable", data.enable);
3285
+ loadProperty(this, "mode", data.mode);
3977
3286
  }
3978
3287
  }
3979
3288
 
3980
3289
  class Events {
3981
- onClick;
3982
- onDiv;
3983
- onHover;
3984
- constructor() {
3985
- this.onClick = new ClickEvent();
3986
- this.onDiv = new DivEvent();
3987
- this.onHover = new HoverEvent();
3988
- }
3290
+ onClick = new ClickEvent();
3291
+ onDiv = new DivEvent();
3292
+ onHover = new HoverEvent();
3989
3293
  load(data) {
3990
3294
  if (isNull(data)) {
3991
3295
  return;
@@ -4038,12 +3342,10 @@
4038
3342
  }
4039
3343
 
4040
3344
  class Interactivity {
4041
- detectsOn;
4042
- events;
3345
+ detectsOn = InteractivityDetect.window;
3346
+ events = new Events();
4043
3347
  modes;
4044
3348
  constructor(pluginManager, container) {
4045
- this.detectsOn = InteractivityDetect.window;
4046
- this.events = new Events();
4047
3349
  this.modes = new Modes(pluginManager, container);
4048
3350
  }
4049
3351
  load(data) {
@@ -4122,7 +3424,7 @@
4122
3424
  const clickEvent = "click", mouseDownEvent = "pointerdown", mouseUpEvent = "pointerup", mouseLeaveEvent = "pointerleave", mouseMoveEvent = "pointermove", touchStartEvent = "touchstart", touchEndEvent = "touchend", touchMoveEvent = "touchmove", touchCancelEvent = "touchcancel";
4123
3425
 
4124
3426
  async function loadInteractivityPlugin(engine) {
4125
- engine.checkVersion("4.1.2");
3427
+ engine.checkVersion("4.2.0");
4126
3428
  await engine.pluginManager.register(e => {
4127
3429
  const interactivityEngine = e, interactivityPluginManager = interactivityEngine.pluginManager;
4128
3430
  interactivityPluginManager.addPlugin(new InteractivityPlugin(interactivityPluginManager));
@@ -4163,70 +3465,43 @@
4163
3465
  })(CollisionMode || (CollisionMode = {}));
4164
3466
 
4165
3467
  class CollisionsAbsorb {
4166
- speed;
4167
- constructor() {
4168
- this.speed = 2;
4169
- }
3468
+ speed = 2;
4170
3469
  load(data) {
4171
3470
  if (isNull(data)) {
4172
3471
  return;
4173
3472
  }
4174
- if (data.speed !== undefined) {
4175
- this.speed = data.speed;
4176
- }
3473
+ loadProperty(this, "speed", data.speed);
4177
3474
  }
4178
3475
  }
4179
3476
 
4180
3477
  class CollisionsOverlap {
4181
- enable;
4182
- retries;
4183
- constructor() {
4184
- this.enable = true;
4185
- this.retries = 0;
4186
- }
3478
+ enable = true;
3479
+ retries = 0;
4187
3480
  load(data) {
4188
3481
  if (isNull(data)) {
4189
3482
  return;
4190
3483
  }
4191
- if (data.enable !== undefined) {
4192
- this.enable = data.enable;
4193
- }
4194
- if (data.retries !== undefined) {
4195
- this.retries = data.retries;
4196
- }
3484
+ loadProperty(this, "enable", data.enable);
3485
+ loadProperty(this, "retries", data.retries);
4197
3486
  }
4198
3487
  }
4199
3488
 
4200
3489
  class Collisions {
4201
- absorb;
4202
- bounce;
4203
- enable;
4204
- maxSpeed;
4205
- mode;
4206
- overlap;
4207
- constructor() {
4208
- this.absorb = new CollisionsAbsorb();
4209
- this.bounce = new ParticlesBounce();
4210
- this.enable = false;
4211
- this.maxSpeed = 50;
4212
- this.mode = CollisionMode.bounce;
4213
- this.overlap = new CollisionsOverlap();
4214
- }
3490
+ absorb = new CollisionsAbsorb();
3491
+ bounce = new ParticlesBounce();
3492
+ enable = false;
3493
+ maxSpeed = 50;
3494
+ mode = CollisionMode.bounce;
3495
+ overlap = new CollisionsOverlap();
4215
3496
  load(data) {
4216
3497
  if (isNull(data)) {
4217
3498
  return;
4218
3499
  }
4219
3500
  this.absorb.load(data.absorb);
4220
3501
  this.bounce.load(data.bounce);
4221
- if (data.enable !== undefined) {
4222
- this.enable = data.enable;
4223
- }
4224
- if (data.maxSpeed !== undefined) {
4225
- this.maxSpeed = setRangeValue(data.maxSpeed);
4226
- }
4227
- if (data.mode !== undefined) {
4228
- this.mode = data.mode;
4229
- }
3502
+ loadProperty(this, "enable", data.enable);
3503
+ loadRangeProperty(this, "maxSpeed", data.maxSpeed);
3504
+ loadProperty(this, "mode", data.mode);
4230
3505
  this.overlap.load(data.overlap);
4231
3506
  }
4232
3507
  }
@@ -4363,10 +3638,7 @@
4363
3638
  return !!particle.options.collisions?.enable;
4364
3639
  }
4365
3640
  loadParticlesOptions(options, ...sources) {
4366
- options.collisions ??= new Collisions();
4367
- for (const source of sources) {
4368
- options.collisions.load(source?.collisions);
4369
- }
3641
+ loadOptionProperty(options, "collisions", Collisions, ...sources);
4370
3642
  }
4371
3643
  reset() {
4372
3644
  }
@@ -4386,7 +3658,7 @@
4386
3658
  }
4387
3659
 
4388
3660
  async function loadParticlesCollisionsInteraction(engine) {
4389
- engine.checkVersion("4.1.2");
3661
+ engine.checkVersion("4.2.0");
4390
3662
  await engine.pluginManager.register((e) => {
4391
3663
  ensureInteractivityPluginLoaded(e);
4392
3664
  e.pluginManager.addPlugin(new OverlapPlugin());
@@ -4446,38 +3718,27 @@
4446
3718
  }
4447
3719
 
4448
3720
  class LinksShadow {
4449
- blur;
4450
- color;
4451
- enable;
3721
+ blur = 5;
3722
+ color = new OptionsColor();
3723
+ enable = false;
4452
3724
  constructor() {
4453
- this.blur = 5;
4454
- this.color = new OptionsColor();
4455
3725
  this.color.value = "#000";
4456
- this.enable = false;
4457
3726
  }
4458
3727
  load(data) {
4459
3728
  if (isNull(data)) {
4460
3729
  return;
4461
3730
  }
4462
- if (data.blur !== undefined) {
4463
- this.blur = data.blur;
4464
- }
3731
+ loadProperty(this, "blur", data.blur);
4465
3732
  this.color = OptionsColor.create(this.color, data.color);
4466
- if (data.enable !== undefined) {
4467
- this.enable = data.enable;
4468
- }
3733
+ loadProperty(this, "enable", data.enable);
4469
3734
  }
4470
3735
  }
4471
3736
 
4472
3737
  class LinksTriangle {
4473
3738
  color;
4474
- enable;
4475
- frequency;
3739
+ enable = false;
3740
+ frequency = 1;
4476
3741
  opacity;
4477
- constructor() {
4478
- this.enable = false;
4479
- this.frequency = 1;
4480
- }
4481
3742
  load(data) {
4482
3743
  if (isNull(data)) {
4483
3744
  return;
@@ -4485,79 +3746,44 @@
4485
3746
  if (data.color !== undefined) {
4486
3747
  this.color = OptionsColor.create(this.color, data.color);
4487
3748
  }
4488
- if (data.enable !== undefined) {
4489
- this.enable = data.enable;
4490
- }
4491
- if (data.frequency !== undefined) {
4492
- this.frequency = data.frequency;
4493
- }
4494
- if (data.opacity !== undefined) {
4495
- this.opacity = data.opacity;
4496
- }
3749
+ loadProperty(this, "enable", data.enable);
3750
+ loadProperty(this, "frequency", data.frequency);
3751
+ loadProperty(this, "opacity", data.opacity);
4497
3752
  }
4498
3753
  }
4499
3754
 
4500
3755
  class Links {
4501
- blink;
4502
- color;
4503
- consent;
4504
- distance;
4505
- enable;
4506
- frequency;
3756
+ blink = false;
3757
+ color = new OptionsColor();
3758
+ consent = false;
3759
+ distance = 100;
3760
+ enable = false;
3761
+ frequency = 1;
4507
3762
  id;
4508
- opacity;
4509
- shadow;
4510
- triangles;
4511
- warp;
4512
- width;
3763
+ opacity = 1;
3764
+ shadow = new LinksShadow();
3765
+ triangles = new LinksTriangle();
3766
+ warp = false;
3767
+ width = 1;
4513
3768
  constructor() {
4514
- this.blink = false;
4515
- this.color = new OptionsColor();
4516
3769
  this.color.value = "#fff";
4517
- this.consent = false;
4518
- this.distance = 100;
4519
- this.enable = false;
4520
- this.frequency = 1;
4521
- this.opacity = 1;
4522
- this.shadow = new LinksShadow();
4523
- this.triangles = new LinksTriangle();
4524
- this.width = 1;
4525
- this.warp = false;
4526
- }
4527
- load(data) {
4528
- if (isNull(data)) {
4529
- return;
4530
- }
4531
- if (data.id !== undefined) {
4532
- this.id = data.id;
4533
- }
4534
- if (data.blink !== undefined) {
4535
- this.blink = data.blink;
4536
- }
4537
- this.color = OptionsColor.create(this.color, data.color);
4538
- if (data.consent !== undefined) {
4539
- this.consent = data.consent;
4540
- }
4541
- if (data.distance !== undefined) {
4542
- this.distance = data.distance;
4543
- }
4544
- if (data.enable !== undefined) {
4545
- this.enable = data.enable;
4546
- }
4547
- if (data.frequency !== undefined) {
4548
- this.frequency = data.frequency;
4549
- }
4550
- if (data.opacity !== undefined) {
4551
- this.opacity = data.opacity;
3770
+ }
3771
+ load(data) {
3772
+ if (isNull(data)) {
3773
+ return;
4552
3774
  }
3775
+ loadProperty(this, "id", data.id);
3776
+ loadProperty(this, "blink", data.blink);
3777
+ this.color = OptionsColor.create(this.color, data.color);
3778
+ loadProperty(this, "consent", data.consent);
3779
+ loadProperty(this, "distance", data.distance);
3780
+ loadProperty(this, "enable", data.enable);
3781
+ loadProperty(this, "frequency", data.frequency);
3782
+ loadProperty(this, "opacity", data.opacity);
4553
3783
  this.shadow.load(data.shadow);
4554
3784
  this.triangles.load(data.triangles);
4555
- if (data.width !== undefined) {
4556
- this.width = data.width;
4557
- }
4558
- if (data.warp !== undefined) {
4559
- this.warp = data.warp;
4560
- }
3785
+ loadProperty(this, "width", data.width);
3786
+ loadProperty(this, "warp", data.warp);
4561
3787
  }
4562
3788
  }
4563
3789
 
@@ -4633,10 +3859,7 @@
4633
3859
  return !!particle.options.links?.enable;
4634
3860
  }
4635
3861
  loadParticlesOptions(options, ...sources) {
4636
- options.links ??= new Links();
4637
- for (const source of sources) {
4638
- options.links.load(source?.links);
4639
- }
3862
+ loadOptionProperty(options, "links", Links, ...sources);
4640
3863
  }
4641
3864
  reset() {
4642
3865
  }
@@ -4689,7 +3912,7 @@
4689
3912
  }
4690
3913
 
4691
3914
  async function loadParticlesLinksInteraction(engine) {
4692
- engine.checkVersion("4.1.2");
3915
+ engine.checkVersion("4.2.0");
4693
3916
  await engine.pluginManager.register((e) => {
4694
3917
  const pluginManager = e.pluginManager;
4695
3918
  ensureInteractivityPluginLoaded(e);
@@ -4702,7 +3925,7 @@
4702
3925
 
4703
3926
  let initPromise = null;
4704
3927
  async function doInitPlugins(engine) {
4705
- engine.checkVersion("4.1.2");
3928
+ engine.checkVersion("4.2.0");
4706
3929
  await engine.pluginManager.register(async (e) => {
4707
3930
  const loadParticlesInteractivity = async (e) => {
4708
3931
  await loadInteractivityPlugin(e);
@@ -4745,7 +3968,7 @@
4745
3968
  particles.init = async () => {
4746
3969
  await initPlugins(tsParticles);
4747
3970
  };
4748
- particles.version = "4.1.2";
3971
+ particles.version = "4.2.0";
4749
3972
  globalThis.particles = particles;
4750
3973
 
4751
3974
  const globalObject = globalThis;
@@ -4806,7 +4029,7 @@
4806
4029
  return;
4807
4030
  }
4808
4031
  this.draw(ctx => {
4809
- clear(ctx, this.#canvasManager.size);
4032
+ ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
4810
4033
  });
4811
4034
  }
4812
4035
  clear() {
@@ -4868,7 +4091,7 @@
4868
4091
  plugin.drawParticleSetup?.(context, particle, delta);
4869
4092
  }
4870
4093
  this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4871
- drawParticle({
4094
+ this.#drawParticle({
4872
4095
  container,
4873
4096
  context,
4874
4097
  particle,
@@ -4887,7 +4110,7 @@
4887
4110
  drawParticlePlugins(particle, delta) {
4888
4111
  this.draw(ctx => {
4889
4112
  for (const plugin of this.#drawParticlePlugins) {
4890
- drawParticlePlugin(ctx, plugin, particle, delta);
4113
+ this.#drawParticlePlugin(ctx, plugin, particle, delta);
4891
4114
  }
4892
4115
  });
4893
4116
  }
@@ -4987,12 +4210,19 @@
4987
4210
  }
4988
4211
  paintBase(baseColor) {
4989
4212
  this.draw(ctx => {
4990
- paintBase(ctx, this.#canvasManager.size, baseColor);
4213
+ ctx.fillStyle = baseColor ?? "rgba(0,0,0,0)";
4214
+ ctx.fillRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
4991
4215
  });
4992
4216
  }
4993
4217
  paintImage(image, opacity) {
4994
4218
  this.draw(ctx => {
4995
- paintImage(ctx, this.#canvasManager.size, image, opacity);
4219
+ if (!image) {
4220
+ return;
4221
+ }
4222
+ const prevAlpha = ctx.globalAlpha;
4223
+ ctx.globalAlpha = opacity;
4224
+ ctx.drawImage(image, originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
4225
+ ctx.globalAlpha = prevAlpha;
4996
4226
  });
4997
4227
  }
4998
4228
  setContext(context) {
@@ -5006,15 +4236,15 @@
5006
4236
  }
5007
4237
  stop() {
5008
4238
  this.draw(ctx => {
5009
- clear(ctx, this.#canvasManager.size);
4239
+ ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
5010
4240
  });
5011
4241
  }
5012
- #applyPostDrawUpdaters = particle => {
4242
+ #applyPostDrawUpdaters(particle) {
5013
4243
  for (const updater of this.#postDrawUpdaters) {
5014
4244
  updater.afterDraw?.(particle);
5015
4245
  }
5016
- };
5017
- #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4246
+ }
4247
+ #applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
5018
4248
  for (const updater of this.#preDrawUpdaters) {
5019
4249
  if (updater.getColorStyles) {
5020
4250
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
@@ -5033,8 +4263,114 @@
5033
4263
  }
5034
4264
  updater.beforeDraw?.(particle);
5035
4265
  }
5036
- };
5037
- #getPluginParticleColors = particle => {
4266
+ }
4267
+ #drawAfterEffect(drawer, data) {
4268
+ if (!drawer?.drawAfter) {
4269
+ return;
4270
+ }
4271
+ const { particle } = data;
4272
+ if (!particle.effect) {
4273
+ return;
4274
+ }
4275
+ drawer.drawAfter(data);
4276
+ }
4277
+ #drawBeforeEffect(drawer, data) {
4278
+ if (!drawer?.drawBefore) {
4279
+ return;
4280
+ }
4281
+ const { particle } = data;
4282
+ if (!particle.effect) {
4283
+ return;
4284
+ }
4285
+ drawer.drawBefore(data);
4286
+ }
4287
+ #drawParticle(data) {
4288
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
4289
+ x: pos.x,
4290
+ y: pos.y,
4291
+ };
4292
+ context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
4293
+ if (colorStyles.fill) {
4294
+ context.fillStyle = colorStyles.fill;
4295
+ }
4296
+ const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
4297
+ context.lineWidth = strokeWidth;
4298
+ if (colorStyles.stroke) {
4299
+ context.strokeStyle = colorStyles.stroke;
4300
+ }
4301
+ const drawData = {
4302
+ context,
4303
+ particle,
4304
+ radius,
4305
+ drawRadius: radius * drawScale,
4306
+ opacity,
4307
+ delta,
4308
+ pixelRatio: container.retina.pixelRatio,
4309
+ fill: fillEnabled,
4310
+ stroke: strokeWidth > minStrokeWidth,
4311
+ transformData,
4312
+ position: { ...pos },
4313
+ drawPosition,
4314
+ drawScale,
4315
+ };
4316
+ for (const plugin of container.plugins) {
4317
+ plugin.drawParticleTransform?.(drawData);
4318
+ }
4319
+ const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
4320
+ this.#drawBeforeEffect(effect, drawData);
4321
+ this.#drawShapeBeforeDraw(shape, drawData);
4322
+ this.#drawShape(shape, drawData);
4323
+ this.#drawShapeAfterDraw(shape, drawData);
4324
+ this.#drawAfterEffect(effect, drawData);
4325
+ context.resetTransform();
4326
+ }
4327
+ #drawParticlePlugin(context, plugin, particle, delta) {
4328
+ if (!plugin.drawParticle) {
4329
+ return;
4330
+ }
4331
+ plugin.drawParticle(context, particle, delta);
4332
+ }
4333
+ #drawShape(drawer, data) {
4334
+ if (!drawer) {
4335
+ return;
4336
+ }
4337
+ const { context, fill, particle, stroke } = data;
4338
+ if (!particle.shape) {
4339
+ return;
4340
+ }
4341
+ context.beginPath();
4342
+ drawer.draw(data);
4343
+ if (particle.shapeClose) {
4344
+ context.closePath();
4345
+ }
4346
+ if (fill) {
4347
+ context.fill();
4348
+ }
4349
+ if (stroke) {
4350
+ context.stroke();
4351
+ }
4352
+ }
4353
+ #drawShapeAfterDraw(drawer, data) {
4354
+ if (!drawer?.afterDraw) {
4355
+ return;
4356
+ }
4357
+ const { particle } = data;
4358
+ if (!particle.shape) {
4359
+ return;
4360
+ }
4361
+ drawer.afterDraw(data);
4362
+ }
4363
+ #drawShapeBeforeDraw(drawer, data) {
4364
+ if (!drawer?.beforeDraw) {
4365
+ return;
4366
+ }
4367
+ const { particle } = data;
4368
+ if (!particle.shape) {
4369
+ return;
4370
+ }
4371
+ drawer.beforeDraw(data);
4372
+ }
4373
+ #getPluginParticleColors(particle) {
5038
4374
  let fColor, sColor;
5039
4375
  for (const plugin of this.#colorPlugins) {
5040
4376
  if (!fColor && plugin.particleFillColor) {
@@ -5050,7 +4386,7 @@
5050
4386
  this.#reusablePluginColors[fColorIndex] = fColor;
5051
4387
  this.#reusablePluginColors[sColorIndex] = sColor;
5052
4388
  return this.#reusablePluginColors;
5053
- };
4389
+ }
5054
4390
  }
5055
4391
 
5056
4392
  const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
@@ -5182,6 +4518,7 @@
5182
4518
  obs.observe(element, { attributes: true });
5183
4519
  });
5184
4520
  this.initPlugins();
4521
+ this.#initContext();
5185
4522
  this.render.init();
5186
4523
  }
5187
4524
  initBackground() {
@@ -5191,7 +4528,7 @@
5191
4528
  }
5192
4529
  const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
5193
4530
  if (color) {
5194
- elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
4531
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
5195
4532
  }
5196
4533
  else {
5197
4534
  elementStyle.backgroundColor = "";
@@ -5213,7 +4550,7 @@
5213
4550
  if (this.#generated && this.domElement) {
5214
4551
  this.domElement.remove();
5215
4552
  }
5216
- const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4553
+ const domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
5217
4554
  this.domElement = domCanvas;
5218
4555
  this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
5219
4556
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
@@ -5234,26 +4571,6 @@
5234
4571
  const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
5235
4572
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
5236
4573
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
5237
- const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
5238
- this.render.setContextSettings({
5239
- alpha: true,
5240
- colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
5241
- desynchronized: true,
5242
- willReadFrequently: false,
5243
- });
5244
- this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
5245
- this.#safeMutationObserver(obs => {
5246
- obs.disconnect();
5247
- });
5248
- container.retina.init();
5249
- this.initBackground();
5250
- this.#safeMutationObserver(obs => {
5251
- const element = this.domElement;
5252
- if (!element || !(element instanceof Node)) {
5253
- return;
5254
- }
5255
- obs.observe(element, { attributes: true });
5256
- });
5257
4574
  }
5258
4575
  resize() {
5259
4576
  const element = this.domElement;
@@ -5321,12 +4638,30 @@
5321
4638
  await container.refresh();
5322
4639
  }
5323
4640
  }
5324
- #applyResizePlugins = () => {
4641
+ #applyResizePlugins() {
5325
4642
  for (const plugin of this.#resizePlugins) {
5326
4643
  plugin.resize?.();
5327
4644
  }
5328
- };
5329
- #initStyle = () => {
4645
+ }
4646
+ #initContext() {
4647
+ const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
4648
+ safeMatchMedia("(color-gamut: p3)")?.matches &&
4649
+ safeMatchMedia("(dynamic-range: high)")?.matches;
4650
+ this.render.setContextSettings({
4651
+ alpha: true,
4652
+ desynchronized: true,
4653
+ willReadFrequently: false,
4654
+ ...(canSupportHdr
4655
+ ? { colorSpace: "display-p3", colorType: "float16" }
4656
+ : { colorSpace: "srgb" }),
4657
+ });
4658
+ const renderCanvas = this.renderCanvas;
4659
+ if (!renderCanvas) {
4660
+ return;
4661
+ }
4662
+ this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
4663
+ }
4664
+ #initStyle() {
5330
4665
  const element = this.domElement, options = this.#container.actualOptions;
5331
4666
  if (!element) {
5332
4667
  return;
@@ -5347,8 +4682,8 @@
5347
4682
  }
5348
4683
  element.style.setProperty(key, value, "important");
5349
4684
  }
5350
- };
5351
- #repairStyle = () => {
4685
+ }
4686
+ #repairStyle() {
5352
4687
  const element = this.domElement;
5353
4688
  if (!element) {
5354
4689
  return;
@@ -5367,27 +4702,27 @@
5367
4702
  }
5368
4703
  observer.observe(element, { attributes: true });
5369
4704
  });
5370
- };
5371
- #resetOriginalStyle = () => {
4705
+ }
4706
+ #resetOriginalStyle() {
5372
4707
  const element = this.domElement, originalStyle = this.#originalStyle;
5373
4708
  if (!element || !originalStyle) {
5374
4709
  return;
5375
4710
  }
5376
4711
  setStyle(element, originalStyle, true);
5377
- };
5378
- #safeMutationObserver = callback => {
4712
+ }
4713
+ #safeMutationObserver(callback) {
5379
4714
  if (!this.#mutationObserver) {
5380
4715
  return;
5381
4716
  }
5382
4717
  callback(this.#mutationObserver);
5383
- };
5384
- #setFullScreenStyle = () => {
4718
+ }
4719
+ #setFullScreenStyle() {
5385
4720
  const element = this.domElement;
5386
4721
  if (!element) {
5387
4722
  return;
5388
4723
  }
5389
4724
  setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
5390
- };
4725
+ }
5391
4726
  }
5392
4727
 
5393
4728
  class EventListeners {
@@ -5412,7 +4747,7 @@
5412
4747
  removeListeners() {
5413
4748
  this.#manageListeners(false);
5414
4749
  }
5415
- #handleVisibilityChange = () => {
4750
+ #handleVisibilityChange() {
5416
4751
  const container = this.#container, options = container.actualOptions;
5417
4752
  if (!options.pauseOnBlur) {
5418
4753
  return;
@@ -5430,8 +4765,8 @@
5430
4765
  container.draw(true);
5431
4766
  }
5432
4767
  }
5433
- };
5434
- #handleWindowResize = () => {
4768
+ }
4769
+ #handleWindowResize() {
5435
4770
  if (this.#resizeTimeout) {
5436
4771
  clearTimeout(this.#resizeTimeout);
5437
4772
  this.#resizeTimeout = undefined;
@@ -5441,13 +4776,13 @@
5441
4776
  await canvas.windowResize();
5442
4777
  };
5443
4778
  this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
5444
- };
5445
- #manageListeners = add => {
4779
+ }
4780
+ #manageListeners(add) {
5446
4781
  const handlers = this.#handlers;
5447
4782
  this.#manageResize(add);
5448
4783
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
5449
- };
5450
- #manageResize = add => {
4784
+ }
4785
+ #manageResize(add) {
5451
4786
  const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
5452
4787
  if (!options.resize.enable) {
5453
4788
  return;
@@ -5474,7 +4809,7 @@
5474
4809
  });
5475
4810
  this.#resizeObserver.observe(canvasEl);
5476
4811
  }
5477
- };
4812
+ }
5478
4813
  }
5479
4814
 
5480
4815
  function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
@@ -5501,6 +4836,131 @@
5501
4836
  data.setCb(data.radius);
5502
4837
  }
5503
4838
  }
4839
+ function normalizeAngle(angle, modulus) {
4840
+ const normalized = angle % modulus;
4841
+ return normalized < defaultAngle ? normalized + modulus : normalized;
4842
+ }
4843
+ function initParticleState(particle, id, group) {
4844
+ particle.id = id;
4845
+ particle.group = group;
4846
+ particle.justWarped = false;
4847
+ particle.effectClose = true;
4848
+ particle.shapeClose = true;
4849
+ particle.pathRotation = false;
4850
+ particle.lastPathTime = 0;
4851
+ particle.destroyed = false;
4852
+ particle.unbreakable = false;
4853
+ particle.isRotating = false;
4854
+ particle.rotation = 0;
4855
+ particle.misplaced = false;
4856
+ particle.retina = {
4857
+ maxDistance: {},
4858
+ maxSpeed: 0,
4859
+ moveDrift: 0,
4860
+ moveSpeed: 0,
4861
+ sizeAnimationSpeed: 0,
4862
+ };
4863
+ particle.size = {
4864
+ value: 1,
4865
+ max: 1,
4866
+ min: 1,
4867
+ enable: false,
4868
+ };
4869
+ particle.outType = exports.ParticleOutType.normal;
4870
+ particle.ignoresResizeRatio = true;
4871
+ }
4872
+ function resolveParticleOptions(particle, container, pluginManager, overrideOptions) {
4873
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates;
4874
+ particle.effect = itemFromSingleOrMultiple(particlesOptions.effect.type, particle.id, reduceDuplicates);
4875
+ particle.shape = itemFromSingleOrMultiple(particlesOptions.shape.type, particle.id, reduceDuplicates);
4876
+ const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
4877
+ if (overrideOptions) {
4878
+ if (overrideOptions.effect) {
4879
+ const overrideEffectType = overrideOptions.effect.type;
4880
+ if (overrideEffectType && overrideEffectType !== particle.effect) {
4881
+ const effect = itemFromSingleOrMultiple(overrideEffectType, particle.id, reduceDuplicates);
4882
+ if (effect) {
4883
+ particle.effect = effect;
4884
+ }
4885
+ }
4886
+ effectOptions.load(overrideOptions.effect);
4887
+ }
4888
+ if (overrideOptions.shape) {
4889
+ const overrideShapeType = overrideOptions.shape.type;
4890
+ if (overrideShapeType && overrideShapeType !== particle.shape) {
4891
+ const shape = itemFromSingleOrMultiple(overrideShapeType, particle.id, reduceDuplicates);
4892
+ if (shape) {
4893
+ particle.shape = shape;
4894
+ }
4895
+ }
4896
+ shapeOptions.load(overrideOptions.shape);
4897
+ }
4898
+ }
4899
+ if (particle.effect === randomColorValue) {
4900
+ const availableEffects = [...container.effectDrawers.keys()];
4901
+ particle.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
4902
+ }
4903
+ if (particle.shape === randomColorValue) {
4904
+ const availableShapes = [...container.shapeDrawers.keys()];
4905
+ particle.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
4906
+ }
4907
+ particle.effectData = particle.effect
4908
+ ? loadEffectData(particle.effect, effectOptions, particle.id, reduceDuplicates)
4909
+ : undefined;
4910
+ particle.shapeData = particle.shape
4911
+ ? loadShapeData(particle.shape, shapeOptions, particle.id, reduceDuplicates)
4912
+ : undefined;
4913
+ particlesOptions.load(overrideOptions);
4914
+ const effectData = particle.effectData, shapeData = particle.shapeData;
4915
+ if (effectData) {
4916
+ particlesOptions.load(effectData.particles);
4917
+ }
4918
+ if (shapeData) {
4919
+ particlesOptions.load(shapeData.particles);
4920
+ }
4921
+ particle.effectClose = effectData?.close ?? particlesOptions.effect.close;
4922
+ particle.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
4923
+ return particlesOptions;
4924
+ }
4925
+ function initParticleDrawers(particle, container) {
4926
+ let effectDrawer, shapeDrawer;
4927
+ if (particle.effect) {
4928
+ effectDrawer = container.effectDrawers.get(particle.effect);
4929
+ }
4930
+ if (effectDrawer?.loadEffect) {
4931
+ effectDrawer.loadEffect(particle);
4932
+ }
4933
+ if (particle.shape) {
4934
+ shapeDrawer = container.shapeDrawers.get(particle.shape);
4935
+ }
4936
+ if (shapeDrawer?.loadShape) {
4937
+ shapeDrawer.loadShape(particle);
4938
+ }
4939
+ const sideCountFunc = shapeDrawer?.getSidesCount;
4940
+ if (sideCountFunc) {
4941
+ particle.sides = sideCountFunc(particle);
4942
+ }
4943
+ }
4944
+ function runUpdaterPreInit(updaters, particle) {
4945
+ for (const updater of updaters) {
4946
+ updater.preInit?.(particle);
4947
+ }
4948
+ }
4949
+ function runUpdaterInit(updaters, particle) {
4950
+ for (const updater of updaters) {
4951
+ updater.init(particle);
4952
+ }
4953
+ }
4954
+ function runDrawerInit(container, particle) {
4955
+ const shapeDrawer = particle.shape ? container.shapeDrawers.get(particle.shape) : undefined, effectDrawer = particle.effect ? container.effectDrawers.get(particle.effect) : undefined;
4956
+ effectDrawer?.particleInit?.(container, particle);
4957
+ shapeDrawer?.particleInit?.(container, particle);
4958
+ }
4959
+ function runParticleCreatedPlugins(container, particle) {
4960
+ for (const plugin of container.particleCreatedPlugins) {
4961
+ plugin.particleCreated?.(particle);
4962
+ }
4963
+ }
5504
4964
  class Particle {
5505
4965
  backColor;
5506
4966
  bubble;
@@ -5626,88 +5086,20 @@
5626
5086
  const rotateData = this.getRotateData(), rotating = this.isRotating;
5627
5087
  this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
5628
5088
  this.#cachedTransform.b = rotating
5629
- ? rotateData.sin * (externalTransform.b ?? identity$1)
5089
+ ? rotateData.sin * (externalTransform.b ?? identity)
5630
5090
  : (externalTransform.b ?? defaultTransform.b);
5631
5091
  this.#cachedTransform.c = rotating
5632
- ? -rotateData.sin * (externalTransform.c ?? identity$1)
5092
+ ? -rotateData.sin * (externalTransform.c ?? identity)
5633
5093
  : (externalTransform.c ?? defaultTransform.c);
5634
5094
  this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
5635
5095
  return this.#cachedTransform;
5636
5096
  }
5637
5097
  init(id, position, overrideOptions, group) {
5638
5098
  const container = this.#container;
5639
- this.id = id;
5640
- this.group = group;
5641
- this.justWarped = false;
5642
- this.effectClose = true;
5643
- this.shapeClose = true;
5644
- this.pathRotation = false;
5645
- this.lastPathTime = 0;
5646
- this.destroyed = false;
5647
- this.unbreakable = false;
5648
- this.isRotating = false;
5649
- this.rotation = 0;
5650
- this.misplaced = false;
5651
- this.retina = {
5652
- maxDistance: {},
5653
- maxSpeed: 0,
5654
- moveDrift: 0,
5655
- moveSpeed: 0,
5656
- sizeAnimationSpeed: 0,
5657
- };
5658
- this.size = {
5659
- value: 1,
5660
- max: 1,
5661
- min: 1,
5662
- enable: false,
5663
- };
5664
- this.outType = exports.ParticleOutType.normal;
5665
- this.ignoresResizeRatio = true;
5666
- const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
5667
- this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
5668
- this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
5669
- const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
5670
- if (overrideOptions) {
5671
- if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
5672
- const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
5673
- if (effect) {
5674
- this.effect = effect;
5675
- effectOptions.load(overrideOptions.effect);
5676
- }
5677
- }
5678
- if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
5679
- const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
5680
- if (shape) {
5681
- this.shape = shape;
5682
- shapeOptions.load(overrideOptions.shape);
5683
- }
5684
- }
5685
- }
5686
- if (this.effect === randomColorValue) {
5687
- const availableEffects = [...this.#container.effectDrawers.keys()];
5688
- this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
5689
- }
5690
- if (this.shape === randomColorValue) {
5691
- const availableShapes = [...this.#container.shapeDrawers.keys()];
5692
- this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
5693
- }
5694
- this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
5695
- this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
5696
- particlesOptions.load(overrideOptions);
5697
- const effectData = this.effectData, shapeData = this.shapeData;
5698
- if (effectData) {
5699
- particlesOptions.load(effectData.particles);
5700
- }
5701
- if (shapeData) {
5702
- particlesOptions.load(shapeData.particles);
5703
- }
5704
- this.effectClose = effectData?.close ?? particlesOptions.effect.close;
5705
- this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
5706
- this.options = particlesOptions;
5099
+ initParticleState(this, id, group);
5100
+ this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
5707
5101
  container.retina.initParticle(this);
5708
- for (const updater of container.particleUpdaters) {
5709
- updater.preInit?.(this);
5710
- }
5102
+ runUpdaterPreInit(container.particleUpdaters, this);
5711
5103
  this.bubble = {
5712
5104
  inRange: false,
5713
5105
  };
@@ -5720,32 +5112,11 @@
5720
5112
  this.velocity = this.initialVelocity.copy();
5721
5113
  this.zIndexFactor = this.position.z / container.zLayers;
5722
5114
  this.sides = 24;
5723
- let effectDrawer, shapeDrawer;
5724
- if (this.effect) {
5725
- effectDrawer = container.effectDrawers.get(this.effect);
5726
- }
5727
- if (effectDrawer?.loadEffect) {
5728
- effectDrawer.loadEffect(this);
5729
- }
5730
- if (this.shape) {
5731
- shapeDrawer = container.shapeDrawers.get(this.shape);
5732
- }
5733
- if (shapeDrawer?.loadShape) {
5734
- shapeDrawer.loadShape(this);
5735
- }
5736
- const sideCountFunc = shapeDrawer?.getSidesCount;
5737
- if (sideCountFunc) {
5738
- this.sides = sideCountFunc(this);
5739
- }
5115
+ initParticleDrawers(this, container);
5740
5116
  this.spawning = false;
5741
- for (const updater of container.particleUpdaters) {
5742
- updater.init(this);
5743
- }
5744
- effectDrawer?.particleInit?.(container, this);
5745
- shapeDrawer?.particleInit?.(container, this);
5746
- for (const plugin of container.particleCreatedPlugins) {
5747
- plugin.particleCreated?.(this);
5748
- }
5117
+ runUpdaterInit(container.particleUpdaters, this);
5118
+ runDrawerInit(container, this);
5119
+ runParticleCreatedPlugins(container, this);
5749
5120
  }
5750
5121
  isInsideCanvas(direction) {
5751
5122
  return this.#getInsideCanvasResult({ direction }).inside;
@@ -5759,15 +5130,15 @@
5759
5130
  }
5760
5131
  const angle = this.roll.angle;
5761
5132
  if (this.roll.horizontal && this.roll.vertical) {
5762
- const normalizedAngle = angle % doublePI, adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + doublePI : normalizedAngle;
5133
+ const adjustedAngle = normalizeAngle(angle, doublePI);
5763
5134
  return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
5764
5135
  }
5765
5136
  if (this.roll.horizontal) {
5766
- const normalizedAngle = (angle + Math.PI * half) % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
5137
+ const adjustedAngle = normalizeAngle(angle + Math.PI * half, doublePI);
5767
5138
  return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
5768
5139
  }
5769
5140
  if (this.roll.vertical) {
5770
- const normalizedAngle = angle % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
5141
+ const adjustedAngle = normalizeAngle(angle, doublePI);
5771
5142
  return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
5772
5143
  }
5773
5144
  return false;
@@ -5780,10 +5151,10 @@
5780
5151
  updater.reset?.(this);
5781
5152
  }
5782
5153
  }
5783
- #calcPosition = (position, zIndex) => {
5154
+ #calcPosition(position, zIndex) {
5784
5155
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
5785
- const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5786
- while (!signal.aborted) {
5156
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
5157
+ for (;;) {
5787
5158
  for (const plugin of plugins) {
5788
5159
  const pluginPos = plugin.particlePosition?.(posVec, this);
5789
5160
  if (pluginPos) {
@@ -5811,9 +5182,8 @@
5811
5182
  tryCount += tryCountIncrement;
5812
5183
  posVec = undefined;
5813
5184
  }
5814
- return posVec;
5815
- };
5816
- #calculateVelocity = () => {
5185
+ }
5186
+ #calculateVelocity() {
5817
5187
  const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
5818
5188
  if (moveOptions.direction === exports.MoveDirection.inside || moveOptions.direction === exports.MoveDirection.outside) {
5819
5189
  return res;
@@ -5829,8 +5199,8 @@
5829
5199
  res.length *= getRandom();
5830
5200
  }
5831
5201
  return res;
5832
- };
5833
- #fixHorizontal = (pos, radius, outMode) => {
5202
+ }
5203
+ #fixHorizontal(pos, radius, outMode) {
5834
5204
  fixOutMode({
5835
5205
  outMode,
5836
5206
  checkModes: [exports.OutMode.bounce],
@@ -5839,8 +5209,8 @@
5839
5209
  setCb: (value) => (pos.x += value),
5840
5210
  radius,
5841
5211
  });
5842
- };
5843
- #fixVertical = (pos, radius, outMode) => {
5212
+ }
5213
+ #fixVertical(pos, radius, outMode) {
5844
5214
  fixOutMode({
5845
5215
  outMode,
5846
5216
  checkModes: [exports.OutMode.bounce],
@@ -5849,8 +5219,8 @@
5849
5219
  setCb: (value) => (pos.y += value),
5850
5220
  radius,
5851
5221
  });
5852
- };
5853
- #getDefaultInsideCanvasResult = (direction, outMode) => {
5222
+ }
5223
+ #getDefaultInsideCanvasResult(direction, outMode) {
5854
5224
  const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === exports.OutMode.bounce;
5855
5225
  if (direction === exports.OutModeDirection.bottom) {
5856
5226
  return {
@@ -5883,8 +5253,8 @@
5883
5253
  position.x <= canvasSize.width + radius,
5884
5254
  reason: "default",
5885
5255
  };
5886
- };
5887
- #getInsideCanvasCallbackData = (direction, outMode) => {
5256
+ }
5257
+ #getInsideCanvasCallbackData(direction, outMode) {
5888
5258
  return {
5889
5259
  canvasSize: this.#container.canvas.size,
5890
5260
  direction,
@@ -5892,8 +5262,8 @@
5892
5262
  particle: this,
5893
5263
  radius: this.getRadius(),
5894
5264
  };
5895
- };
5896
- #getInsideCanvasResult = (data) => {
5265
+ }
5266
+ #getInsideCanvasResult(data) {
5897
5267
  const defaultResult = this.#getDefaultInsideCanvasResult(data.direction, data.outMode), container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined, effectDrawer = this.effect ? container.effectDrawers.get(this.effect) : undefined, shapeCheck = shapeDrawer?.isInsideCanvas, effectCheck = effectDrawer?.isInsideCanvas;
5898
5268
  if (!shapeCheck && !effectCheck) {
5899
5269
  return defaultResult;
@@ -5908,8 +5278,8 @@
5908
5278
  };
5909
5279
  }
5910
5280
  return shapeResult ?? effectResult ?? defaultResult;
5911
- };
5912
- #getRollColor = color => {
5281
+ }
5282
+ #getRollColor(color) {
5913
5283
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
5914
5284
  return color;
5915
5285
  }
@@ -5923,8 +5293,8 @@
5923
5293
  return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
5924
5294
  }
5925
5295
  return color;
5926
- };
5927
- #initPosition = position => {
5296
+ }
5297
+ #initPosition(position) {
5928
5298
  const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5929
5299
  if (!initialPosition) {
5930
5300
  throw new Error("a valid position cannot be found for particle");
@@ -5947,8 +5317,8 @@
5947
5317
  break;
5948
5318
  }
5949
5319
  this.offset = Vector.origin;
5950
- };
5951
- #normalizeInsideCanvasResult = (result, reason) => {
5320
+ }
5321
+ #normalizeInsideCanvasResult(result, reason) {
5952
5322
  if (typeof result === "boolean") {
5953
5323
  return {
5954
5324
  inside: result,
@@ -5960,7 +5330,7 @@
5960
5330
  margin: result.margin,
5961
5331
  reason: result.reason ?? reason,
5962
5332
  };
5963
- };
5333
+ }
5964
5334
  }
5965
5335
 
5966
5336
  class SpatialHashGrid {
@@ -6313,10 +5683,10 @@
6313
5683
  }
6314
5684
  this.#resizeFactor = undefined;
6315
5685
  }
6316
- #addToPool = (...particles) => {
5686
+ #addToPool(...particles) {
6317
5687
  this.#pool.push(...particles);
6318
- };
6319
- #applyDensity = (options, pluginsCount, group, groupOptions) => {
5688
+ }
5689
+ #applyDensity(options, pluginsCount, group, groupOptions) {
6320
5690
  const numberOptions = options.number;
6321
5691
  if (!numberOptions.density.enable) {
6322
5692
  if (group === undefined) {
@@ -6340,36 +5710,19 @@
6340
5710
  else if (particlesCount > particlesNumber) {
6341
5711
  this.removeQuantity(particlesCount - particlesNumber, group);
6342
5712
  }
6343
- };
6344
- #createBuckets = (zLayers) => {
5713
+ }
5714
+ #createBuckets(zLayers) {
6345
5715
  const bucketCount = Math.max(Math.floor(zLayers), one);
6346
5716
  return Array.from({ length: bucketCount }, () => []);
6347
- };
6348
- #getBucketIndex = (zIndex) => {
5717
+ }
5718
+ #getBucketIndex(zIndex) {
6349
5719
  const maxBucketIndex = this.#zBuckets.length - one;
6350
5720
  if (maxBucketIndex <= minIndex) {
6351
5721
  return minIndex;
6352
5722
  }
6353
5723
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
6354
- };
6355
- #getParticleInsertIndex = (bucket, particleId) => {
6356
- let start = minIndex, end = bucket.length;
6357
- while (start < end) {
6358
- const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
6359
- if (!middleParticle) {
6360
- end = middle;
6361
- continue;
6362
- }
6363
- if (middleParticle.id < particleId) {
6364
- start = middle + one;
6365
- }
6366
- else {
6367
- end = middle;
6368
- }
6369
- }
6370
- return start;
6371
- };
6372
- #initDensityFactor = densityOptions => {
5724
+ }
5725
+ #initDensityFactor(densityOptions) {
6373
5726
  const container = this.#container;
6374
5727
  if (!densityOptions.enable) {
6375
5728
  return defaultDensityFactor;
@@ -6379,16 +5732,16 @@
6379
5732
  return defaultDensityFactor;
6380
5733
  }
6381
5734
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
6382
- };
6383
- #insertParticleIntoBucket = (particle) => {
5735
+ }
5736
+ #insertParticleIntoBucket(particle) {
6384
5737
  const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
6385
5738
  if (!bucket) {
6386
5739
  return;
6387
5740
  }
6388
- bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
5741
+ bucket.push(particle);
6389
5742
  this.#particleBuckets.set(particle.id, bucketIndex);
6390
- };
6391
- #removeParticle = (index, group, override) => {
5743
+ }
5744
+ #removeParticle(index, group, override) {
6392
5745
  const particle = this.#array[index];
6393
5746
  if (!particle) {
6394
5747
  return false;
@@ -6404,22 +5757,20 @@
6404
5757
  });
6405
5758
  this.#addToPool(particle);
6406
5759
  return true;
6407
- };
6408
- #removeParticleFromBucket = (particle) => {
5760
+ }
5761
+ #removeParticleFromBucket(particle) {
6409
5762
  const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
6410
5763
  if (!bucket) {
6411
5764
  this.#particleBuckets.delete(particle.id);
6412
5765
  return;
6413
5766
  }
6414
- const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
6415
- if (bucket[particleIndex]?.id !== particle.id) {
6416
- this.#particleBuckets.delete(particle.id);
6417
- return;
5767
+ const idx = bucket.findIndex(p => p.id === particle.id);
5768
+ if (idx >= minIndex) {
5769
+ bucket.splice(idx, deleteCount);
6418
5770
  }
6419
- bucket.splice(particleIndex, deleteCount);
6420
5771
  this.#particleBuckets.delete(particle.id);
6421
- };
6422
- #resetBuckets = (zLayers) => {
5772
+ }
5773
+ #resetBuckets(zLayers) {
6423
5774
  const bucketCount = Math.max(Math.floor(zLayers), one);
6424
5775
  if (this.#zBuckets.length !== bucketCount) {
6425
5776
  this.#zBuckets = this.#createBuckets(bucketCount);
@@ -6428,8 +5779,8 @@
6428
5779
  for (const bucket of this.#zBuckets) {
6429
5780
  bucket.length = minIndex;
6430
5781
  }
6431
- };
6432
- #updateParticleBucket = (particle) => {
5782
+ }
5783
+ #updateParticleBucket(particle) {
6433
5784
  const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
6434
5785
  if (currentBucketIndex === undefined) {
6435
5786
  this.#insertParticleIntoBucket(particle);
@@ -6440,9 +5791,9 @@
6440
5791
  }
6441
5792
  const currentBucket = this.#zBuckets[currentBucketIndex];
6442
5793
  if (currentBucket) {
6443
- const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
6444
- if (currentBucket[particleIndex]?.id === particle.id) {
6445
- currentBucket.splice(particleIndex, deleteCount);
5794
+ const idx = currentBucket.findIndex(p => p.id === particle.id);
5795
+ if (idx >= minIndex) {
5796
+ currentBucket.splice(idx, deleteCount);
6446
5797
  }
6447
5798
  }
6448
5799
  const newBucket = this.#zBuckets[newBucketIndex];
@@ -6450,10 +5801,16 @@
6450
5801
  this.#particleBuckets.set(particle.id, newBucketIndex);
6451
5802
  return;
6452
5803
  }
6453
- newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
5804
+ newBucket.push(particle);
5805
+ if (newBucket.length >= double) {
5806
+ const prev = newBucket[newBucket.length - double];
5807
+ if (prev && particle.id < prev.id) {
5808
+ newBucket.sort((a, b) => a.id - b.id);
5809
+ }
5810
+ }
6454
5811
  this.#particleBuckets.set(particle.id, newBucketIndex);
6455
- };
6456
- #updateParticlesPhase1 = (delta) => {
5812
+ }
5813
+ #updateParticlesPhase1(delta) {
6457
5814
  const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
6458
5815
  for (const particle of this.#array) {
6459
5816
  if (resizeFactor && !particle.ignoresResizeRatio) {
@@ -6479,8 +5836,8 @@
6479
5836
  this.grid.insert(particle);
6480
5837
  }
6481
5838
  return particlesToDelete;
6482
- };
6483
- #updateParticlesPhase2 = (delta, particlesToDelete) => {
5839
+ }
5840
+ #updateParticlesPhase2(delta, particlesToDelete) {
6484
5841
  for (const particle of this.#array) {
6485
5842
  if (particle.destroyed) {
6486
5843
  particlesToDelete.add(particle);
@@ -6496,7 +5853,7 @@
6496
5853
  }
6497
5854
  this.#updateParticleBucket(particle);
6498
5855
  }
6499
- };
5856
+ }
6500
5857
  }
6501
5858
 
6502
5859
  class Retina {
@@ -6858,7 +6215,7 @@
6858
6215
  }
6859
6216
  return refresh;
6860
6217
  }
6861
- #nextFrame = (timestamp) => {
6218
+ #nextFrame(timestamp) {
6862
6219
  try {
6863
6220
  if (!this.#smooth &&
6864
6221
  this.#lastFrameTime !== undefined &&
@@ -6886,7 +6243,7 @@
6886
6243
  catch (e) {
6887
6244
  getLogger().error("error in animation loop", e);
6888
6245
  }
6889
- };
6246
+ }
6890
6247
  }
6891
6248
 
6892
6249
  var Container$1 = /*#__PURE__*/Object.freeze({
@@ -6896,8 +6253,17 @@
6896
6253
 
6897
6254
  class ParticlesInstance {
6898
6255
  #container;
6899
- constructor(container) {
6256
+ #id;
6257
+ constructor(container, id) {
6900
6258
  this.#container = container;
6259
+ this.#id = id;
6260
+ }
6261
+ get destroyed() {
6262
+ return this.#container.destroyed;
6263
+ }
6264
+ destroy() {
6265
+ this.#container.destroy();
6266
+ deleteParticlesInstance(this.#id);
6901
6267
  }
6902
6268
  pause() {
6903
6269
  this.#container.pause();
@@ -6953,7 +6319,7 @@
6953
6319
  BlendPluginInstance: BlendPluginInstance
6954
6320
  });
6955
6321
 
6956
- const minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
6322
+ const moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
6957
6323
  function applyDistance(particle) {
6958
6324
  const initialPosition = particle.initialPosition, { dx, dy } = getDistances(initialPosition, particle.position), dxFixed = Math.abs(dx), dyFixed = Math.abs(dy), { maxDistance } = particle.retina, hDistance = maxDistance.horizontal, vDistance = maxDistance.vertical;
6959
6325
  if (!hDistance && !vDistance) {
@@ -7228,7 +6594,7 @@
7228
6594
  removeListeners() {
7229
6595
  this.#manageListeners(false);
7230
6596
  }
7231
- #doMouseTouchClick = e => {
6597
+ #doMouseTouchClick(e) {
7232
6598
  const container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions;
7233
6599
  if (this.#canPush) {
7234
6600
  const mouseInteractivity = interactionManager.interactivityData.mouse, mousePos = mouseInteractivity.position;
@@ -7250,11 +6616,11 @@
7250
6616
  this.#mouseTouchFinish();
7251
6617
  }, touchDelay);
7252
6618
  }
7253
- };
7254
- #handleVisibilityChange = () => {
6619
+ }
6620
+ #handleVisibilityChange() {
7255
6621
  this.#mouseTouchFinish();
7256
- };
7257
- #manageInteractivityListeners = add => {
6622
+ }
6623
+ #manageInteractivityListeners(add) {
7258
6624
  const handlers = this.#handlers, container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions, interactivityEl = interactionManager.interactivityData.element;
7259
6625
  if (!interactivityEl) {
7260
6626
  return;
@@ -7285,8 +6651,8 @@
7285
6651
  }
7286
6652
  manageListener(interactivityEl, mouseLeaveEvent, handlers.mouseLeave, add);
7287
6653
  manageListener(interactivityEl, touchCancelEvent, handlers.touchCancel, add);
7288
- };
7289
- #manageListeners = add => {
6654
+ }
6655
+ #manageListeners(add) {
7290
6656
  const handlers = this.#handlers, container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions, detectType = options.interactivity?.detectsOn, canvasEl = container.canvas.domElement;
7291
6657
  if (detectType === InteractivityDetect.window) {
7292
6658
  interactionManager.interactivityData.element = safeDocument();
@@ -7299,13 +6665,13 @@
7299
6665
  }
7300
6666
  this.#manageInteractivityListeners(add);
7301
6667
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
7302
- };
7303
- #mouseDown = () => {
6668
+ }
6669
+ #mouseDown() {
7304
6670
  const { interactivityData } = this.#interactionManager, { mouse } = interactivityData;
7305
6671
  mouse.clicking = true;
7306
6672
  mouse.downPosition = mouse.position;
7307
- };
7308
- #mouseTouchClick = e => {
6673
+ }
6674
+ #mouseTouchClick(e) {
7309
6675
  const container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions, { mouse } = interactionManager.interactivityData;
7310
6676
  mouse.inside = true;
7311
6677
  let handled = false;
@@ -7323,8 +6689,8 @@
7323
6689
  this.#doMouseTouchClick(e);
7324
6690
  }
7325
6691
  mouse.clicking = false;
7326
- };
7327
- #mouseTouchFinish = () => {
6692
+ }
6693
+ #mouseTouchFinish() {
7328
6694
  const { interactivityData } = this.#interactionManager, { mouse } = interactivityData;
7329
6695
  delete mouse.position;
7330
6696
  delete mouse.clickPosition;
@@ -7332,8 +6698,8 @@
7332
6698
  interactivityData.status = mouseLeaveEvent;
7333
6699
  mouse.inside = false;
7334
6700
  mouse.clicking = false;
7335
- };
7336
- #mouseTouchMove = e => {
6701
+ }
6702
+ #mouseTouchMove(e) {
7337
6703
  const container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions, interactivity = interactionManager.interactivityData, canvasEl = container.canvas.domElement;
7338
6704
  if (!interactivity.element) {
7339
6705
  return;
@@ -7395,31 +6761,37 @@
7395
6761
  }
7396
6762
  interactivity.mouse.position = pos;
7397
6763
  interactivity.status = mouseMoveEvent;
7398
- };
7399
- #touchEnd = e => {
6764
+ }
6765
+ #touchEnd(e) {
7400
6766
  const evt = e, touches = Array.from(evt.changedTouches);
7401
6767
  for (const touch of touches) {
7402
6768
  this.#touches.delete(touch.identifier);
7403
6769
  }
7404
6770
  this.#mouseTouchFinish();
7405
- };
7406
- #touchEndClick = e => {
6771
+ }
6772
+ #touchEndClick(e) {
7407
6773
  const evt = e, touches = Array.from(evt.changedTouches);
7408
6774
  for (const touch of touches) {
7409
6775
  this.#touches.delete(touch.identifier);
7410
6776
  }
7411
6777
  this.#mouseTouchClick(e);
7412
- };
7413
- #touchStart = e => {
6778
+ }
6779
+ #touchStart(e) {
7414
6780
  const evt = e, touches = Array.from(evt.changedTouches);
7415
6781
  for (const touch of touches) {
7416
6782
  this.#touches.set(touch.identifier, performance.now());
7417
6783
  }
7418
6784
  this.#mouseTouchMove(e);
7419
- };
6785
+ }
7420
6786
  }
7421
6787
 
7422
6788
  const clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0;
6789
+ function safeIntersectionObserver(callback) {
6790
+ if (typeof IntersectionObserver === "undefined") {
6791
+ return;
6792
+ }
6793
+ return new IntersectionObserver(callback);
6794
+ }
7423
6795
  class InteractionManager {
7424
6796
  interactivityData;
7425
6797
  #clickHandlers;
@@ -7622,7 +6994,7 @@
7622
6994
  const container = this.#container;
7623
6995
  container.particles.grid.setCellSize(maxTotalDistance * container.retina.pixelRatio);
7624
6996
  }
7625
- #intersectionManager = entries => {
6997
+ #intersectionManager(entries) {
7626
6998
  const container = this.#container;
7627
6999
  if (container.destroyed || !container.actualOptions.pauseOnOutsideViewport) {
7628
7000
  return;
@@ -7638,7 +7010,7 @@
7638
7010
  container.pause();
7639
7011
  }
7640
7012
  }
7641
- };
7013
+ }
7642
7014
  }
7643
7015
 
7644
7016
  class InteractivityPluginInstance {
@@ -7712,7 +7084,7 @@
7712
7084
  checkParticlePosition(particle, position, tryCount) {
7713
7085
  return !this.#hasOverlaps(particle, position, tryCount);
7714
7086
  }
7715
- #hasOverlaps = (particle, pos, tryCount) => {
7087
+ #hasOverlaps(particle, pos, tryCount) {
7716
7088
  const collisionsOptions = particle.options.collisions;
7717
7089
  if (!collisionsOptions?.enable) {
7718
7090
  return false;
@@ -7726,7 +7098,7 @@
7726
7098
  throw new Error(`Particle is overlapping and can't be placed`);
7727
7099
  }
7728
7100
  return !!this.#container.particles.find(p => getDistance(pos, p.position) < particle.getRadius() + p.getRadius());
7729
- };
7101
+ }
7730
7102
  }
7731
7103
 
7732
7104
  var OverlapPluginInstance$1 = /*#__PURE__*/Object.freeze({
@@ -7931,6 +7303,7 @@
7931
7303
  exports.MoveCenter = MoveCenter;
7932
7304
  exports.MoveGravity = MoveGravity;
7933
7305
  exports.MovePath = MovePath;
7306
+ exports.OptionLoader = OptionLoader;
7934
7307
  exports.Options = Options;
7935
7308
  exports.OptionsColor = OptionsColor;
7936
7309
  exports.OutModes = OutModes;
@@ -7955,9 +7328,7 @@
7955
7328
  exports.alterHsl = alterHsl;
7956
7329
  exports.animate = animate;
7957
7330
  exports.areBoundsInside = areBoundsInside;
7958
- exports.arrayRandomIndex = arrayRandomIndex;
7959
7331
  exports.calcExactPositionOrRandomFromSize = calcExactPositionOrRandomFromSize;
7960
- exports.calcExactPositionOrRandomFromSizeRanged = calcExactPositionOrRandomFromSizeRanged;
7961
7332
  exports.calcPositionFromSize = calcPositionFromSize;
7962
7333
  exports.calcPositionOrRandomFromSize = calcPositionOrRandomFromSize;
7963
7334
  exports.calcPositionOrRandomFromSizeRanged = calcPositionOrRandomFromSizeRanged;
@@ -7969,11 +7340,9 @@
7969
7340
  exports.circleBounce = circleBounce;
7970
7341
  exports.circleBounceDataFromParticle = circleBounceDataFromParticle;
7971
7342
  exports.clamp = clamp;
7972
- exports.clear = clear;
7973
7343
  exports.cloneStyle = cloneStyle;
7974
7344
  exports.collisionVelocity = collisionVelocity;
7975
7345
  exports.colorMix = colorMix;
7976
- exports.colorToHsl = colorToHsl;
7977
7346
  exports.colorToRgb = colorToRgb;
7978
7347
  exports.countOffset = countOffset;
7979
7348
  exports.decayOffset = decayOffset;
@@ -8000,16 +7369,8 @@
8000
7369
  exports.deleteCount = deleteCount;
8001
7370
  exports.double = double;
8002
7371
  exports.doublePI = doublePI;
8003
- exports.drawAfterEffect = drawAfterEffect;
8004
- exports.drawBeforeEffect = drawBeforeEffect;
8005
- exports.drawParticle = drawParticle;
8006
- exports.drawParticlePlugin = drawParticlePlugin;
8007
- exports.drawShape = drawShape;
8008
- exports.drawShapeAfterDraw = drawShapeAfterDraw;
8009
- exports.drawShapeBeforeDraw = drawShapeBeforeDraw;
8010
7372
  exports.empty = empty;
8011
7373
  exports.executeOnSingleOrMultiple = executeOnSingleOrMultiple;
8012
- exports.findItemFromSingleOrMultiple = findItemFromSingleOrMultiple;
8013
7374
  exports.generatedAttribute = generatedAttribute;
8014
7375
  exports.generatedFalse = generatedFalse;
8015
7376
  exports.generatedTrue = generatedTrue;
@@ -8028,23 +7389,21 @@
8028
7389
  exports.getParticleDirectionAngle = getParticleDirectionAngle;
8029
7390
  exports.getPosition = getPosition;
8030
7391
  exports.getRandom = getRandom;
7392
+ exports.getRandomFn = getRandomFn;
8031
7393
  exports.getRandomInRange = getRandomInRange;
8032
7394
  exports.getRandomRgbColor = getRandomRgbColor;
8033
7395
  exports.getRangeMax = getRangeMax;
8034
7396
  exports.getRangeMin = getRangeMin;
8035
7397
  exports.getRangeValue = getRangeValue;
8036
- exports.getSize = getSize;
8037
7398
  exports.getStyleFromHsl = getStyleFromHsl;
8038
7399
  exports.getStyleFromRgb = getStyleFromRgb;
8039
7400
  exports.hMax = hMax;
8040
7401
  exports.hMin = hMin;
8041
7402
  exports.hPhase = hPhase;
8042
7403
  exports.half = half;
8043
- exports.hasMatchMedia = hasMatchMedia;
8044
7404
  exports.hslToRgb = hslToRgb;
8045
7405
  exports.hslaToRgba = hslaToRgba;
8046
- exports.identity = identity$1;
8047
- exports.initParticleNumericAnimationValue = initParticleNumericAnimationValue;
7406
+ exports.identity = identity;
8048
7407
  exports.inverseFactorNumerator = inverseFactorNumerator;
8049
7408
  exports.isArray = isArray;
8050
7409
  exports.isBoolean = isBoolean;
@@ -8061,28 +7420,34 @@
8061
7420
  exports.lMax = lMax;
8062
7421
  exports.lMin = lMin;
8063
7422
  exports.lengthOffset = lengthOffset;
7423
+ exports.loadExtendProperty = loadExtendProperty;
7424
+ exports.loadLazyProperty = loadLazyProperty;
8064
7425
  exports.loadMinIndex = loadMinIndex;
7426
+ exports.loadNestedProperty = loadNestedProperty;
7427
+ exports.loadOptionProperty = loadOptionProperty;
8065
7428
  exports.loadOptions = loadOptions;
8066
7429
  exports.loadParticlesOptions = loadParticlesOptions;
7430
+ exports.loadProperty = loadProperty;
8067
7431
  exports.loadRandomFactor = loadRandomFactor;
7432
+ exports.loadRangeProperty = loadRangeProperty;
8068
7433
  exports.manageListener = manageListener;
8069
- exports.memoize = memoize;
7434
+ exports.maxNits = maxNits;
8070
7435
  exports.midColorValue = midColorValue;
8071
7436
  exports.millisecondsToSeconds = millisecondsToSeconds;
8072
7437
  exports.minCount = minCount;
7438
+ exports.minDistance = minDistance$2;
8073
7439
  exports.minFpsLimit = minFpsLimit;
8074
7440
  exports.minIndex = minIndex;
8075
7441
  exports.minLimit = minLimit;
7442
+ exports.minRadius = minRadius$1;
8076
7443
  exports.minStrokeWidth = minStrokeWidth;
8077
- exports.minVelocity = minVelocity$5;
7444
+ exports.minVelocity = minVelocity;
8078
7445
  exports.minZ = minZ;
8079
7446
  exports.minimumSize = minimumSize;
8080
7447
  exports.mix = mix;
8081
7448
  exports.none = none;
8082
7449
  exports.one = one;
8083
7450
  exports.originPoint = originPoint;
8084
- exports.paintBase = paintBase;
8085
- exports.paintImage = paintImage;
8086
7451
  exports.parseAlpha = parseAlpha;
8087
7452
  exports.particles = particles;
8088
7453
  exports.percentDenominator = percentDenominator;
@@ -8101,7 +7466,6 @@
8101
7466
  exports.sMin = sMin;
8102
7467
  exports.sNormalizedOffset = sNormalizedOffset;
8103
7468
  exports.safeDocument = safeDocument;
8104
- exports.safeIntersectionObserver = safeIntersectionObserver;
8105
7469
  exports.safeMatchMedia = safeMatchMedia;
8106
7470
  exports.safeMutationObserver = safeMutationObserver;
8107
7471
  exports.setAnimationFunctions = setAnimationFunctions;
@@ -8117,14 +7481,13 @@
8117
7481
  exports.triple = triple;
8118
7482
  exports.tryCountIncrement = tryCountIncrement;
8119
7483
  exports.tsParticles = tsParticles;
8120
- exports.updateAnimation = updateAnimation;
8121
7484
  exports.updateColor = updateColor;
8122
7485
  exports.updateColorValue = updateColorValue;
8123
7486
  exports.visibilityChangeEvent = visibilityChangeEvent;
8124
7487
  exports.zIndexFactorOffset = zIndexFactorOffset;
8125
7488
 
8126
7489
  }));
8127
- Object.assign(globalThis.window || globalThis, { loadMinIndex: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadMinIndex, loadOptions: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadOptions, loadParticlesOptions: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadParticlesOptions, loadRandomFactor: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadRandomFactor, tsParticles: (globalThis.__tsParticlesInternals.bundles.particles || {}).tsParticles });
7490
+ Object.assign(globalThis.window || globalThis, { loadExtendProperty: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadExtendProperty, loadLazyProperty: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadLazyProperty, loadMinIndex: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadMinIndex, loadNestedProperty: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadNestedProperty, loadOptionProperty: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadOptionProperty, loadOptions: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadOptions, loadParticlesOptions: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadParticlesOptions, loadProperty: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadProperty, loadRandomFactor: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadRandomFactor, loadRangeProperty: (globalThis.__tsParticlesInternals.bundles.particles || {}).loadRangeProperty, tsParticles: (globalThis.__tsParticlesInternals.bundles.particles || {}).tsParticles });
8128
7491
  globalThis.__tsParticlesInternals = globalThis.__tsParticlesInternals || {};
8129
7492
  if (!globalThis.__tsParticlesInternals.engine || !globalThis.__tsParticlesInternals.engine.tsParticles) {
8130
7493
  globalThis.__tsParticlesInternals.engine = globalThis.__tsParticlesInternals.bundles.particles || {};