@tsparticles/basic 4.1.3 → 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.3 */
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$1 = 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 = 0, minRadius$1 = 0, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$1 = 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.3";
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 = {}));
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 = {}));
1371
1108
 
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
- }
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;
1123
+ function loadOptions(options, ...sourceOptionsArr) {
1124
+ for (const sourceOptions of sourceOptionsArr) {
1125
+ options.load(sourceOptions);
1418
1126
  }
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
- }
1127
+ }
1128
+
1129
+ function loadProperty(obj, key, value) {
1130
+ if (value !== undefined) {
1131
+ obj[key] = value;
1132
+ }
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);
1430
1188
  }
1431
1189
  }
1432
1190
 
1433
1191
  class ColorAnimation extends AnimationOptions {
1434
1192
  max;
1435
1193
  min;
1436
- offset;
1194
+ offset = 0;
1195
+ sync = true;
1437
1196
  constructor(min, max) {
1438
1197
  super();
1439
1198
  this.min = min;
1440
1199
  this.max = max;
1441
- this.offset = 0;
1442
- this.sync = true;
1443
1200
  }
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
- }
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
- }
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);
2159
1600
  }
2160
1601
  }
2161
1602
 
2162
- class ParticlesOptions {
2163
- bounce;
2164
- effect;
2165
- groups;
2166
- move;
2167
- number;
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,69 +1725,49 @@
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 => {
@@ -2367,44 +1778,18 @@
2367
1778
  this.palette = data.palette;
2368
1779
  this.#importPalette(this.palette);
2369
1780
  }
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;
2407
- }
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
1826
  }
2541
- if (stroke) {
2542
- context.stroke();
2543
- }
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$1, 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$1).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$1).toString()})`;
2742
1999
  }
2743
2000
  function getSdrStyleFromRgb(color, opacity) {
2744
2001
  return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$1).toString()})`;
2745
2002
  }
2746
2003
  function getStyleFromHsl(color, hdr, opacity) {
2747
2004
  const op = opacity ?? defaultOpacity$1, 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$1).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;
@@ -2930,22 +2183,14 @@
2930
2183
  const tsParticles = initEngine();
2931
2184
 
2932
2185
  class Blend {
2933
- enable;
2934
- mode;
2935
- constructor() {
2936
- this.mode = "destination-out";
2937
- this.enable = false;
2938
- }
2186
+ enable = false;
2187
+ mode = "destination-out";
2939
2188
  load(data) {
2940
2189
  if (isNull(data)) {
2941
2190
  return;
2942
2191
  }
2943
- if (data.mode !== undefined) {
2944
- this.mode = data.mode;
2945
- }
2946
- if (data.enable !== undefined) {
2947
- this.enable = data.enable;
2948
- }
2192
+ loadProperty(this, "mode", data.mode);
2193
+ loadProperty(this, "enable", data.enable);
2949
2194
  }
2950
2195
  }
2951
2196
 
@@ -2975,7 +2220,7 @@
2975
2220
  }
2976
2221
 
2977
2222
  async function loadBlendPlugin(engine) {
2978
- engine.checkVersion("4.1.3");
2223
+ engine.checkVersion("4.2.0");
2979
2224
  await engine.pluginManager.register(e => {
2980
2225
  e.pluginManager.addPlugin(new BlendPlugin());
2981
2226
  });
@@ -3012,7 +2257,7 @@
3012
2257
  }
3013
2258
 
3014
2259
  async function loadCircleShape(engine) {
3015
- engine.checkVersion("4.1.3");
2260
+ engine.checkVersion("4.2.0");
3016
2261
  await engine.pluginManager.register(e => {
3017
2262
  e.pluginManager.addShape(["circle"], () => {
3018
2263
  return Promise.resolve(new CircleDrawer());
@@ -3060,7 +2305,7 @@
3060
2305
  }
3061
2306
 
3062
2307
  async function loadHexColorPlugin(engine) {
3063
- engine.checkVersion("4.1.3");
2308
+ engine.checkVersion("4.2.0");
3064
2309
  await engine.pluginManager.register(e => {
3065
2310
  e.pluginManager.addColorManager("hex", new HexColorManager());
3066
2311
  });
@@ -3113,7 +2358,7 @@
3113
2358
  }
3114
2359
 
3115
2360
  async function loadHslColorPlugin(engine) {
3116
- engine.checkVersion("4.1.3");
2361
+ engine.checkVersion("4.2.0");
3117
2362
  await engine.pluginManager.register(e => {
3118
2363
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3119
2364
  });
@@ -3131,55 +2376,161 @@
3131
2376
  }
3132
2377
  loadOptions() {
3133
2378
  }
3134
- needsPlugin() {
3135
- return true;
2379
+ needsPlugin() {
2380
+ return true;
2381
+ }
2382
+ }
2383
+
2384
+ async function loadMovePlugin(engine) {
2385
+ engine.checkVersion("4.2.0");
2386
+ await engine.pluginManager.register(e => {
2387
+ const moveEngine = e, movePluginManager = moveEngine.pluginManager;
2388
+ movePluginManager.initializers.pathGenerators ??= new Map();
2389
+ movePluginManager.pathGenerators ??= new Map();
2390
+ movePluginManager.addPathGenerator = (name, generator) => {
2391
+ movePluginManager.initializers.pathGenerators ??= new Map();
2392
+ movePluginManager.initializers.pathGenerators.set(name, generator);
2393
+ };
2394
+ movePluginManager.getPathGenerators = async (container, force = false) => {
2395
+ movePluginManager.initializers.pathGenerators ??= new Map();
2396
+ movePluginManager.pathGenerators ??= new Map();
2397
+ return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
2398
+ };
2399
+ e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
2400
+ });
2401
+ }
2402
+
2403
+ function checkDestroy(particle, destroyType, value, minValue, maxValue) {
2404
+ switch (destroyType) {
2405
+ case exports.DestroyType.max:
2406
+ if (value >= maxValue) {
2407
+ particle.destroy();
2408
+ }
2409
+ break;
2410
+ case exports.DestroyType.min:
2411
+ if (value <= minValue) {
2412
+ particle.destroy();
2413
+ }
2414
+ break;
2415
+ }
2416
+ }
2417
+ function initParticleNumericAnimationValue(options, pxRatio) {
2418
+ const valueRange = options.value, animationOptions = options.animation, res = {
2419
+ delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
2420
+ enable: animationOptions.enable,
2421
+ value: getRangeValue(options.value) * pxRatio,
2422
+ max: getRangeMax(valueRange) * pxRatio,
2423
+ min: getRangeMin(valueRange) * pxRatio,
2424
+ loops: 0,
2425
+ maxLoops: getRangeValue(animationOptions.count),
2426
+ time: 0,
2427
+ }, decayOffset = 1;
2428
+ if (animationOptions.enable) {
2429
+ res.decay = decayOffset - getRangeValue(animationOptions.decay);
2430
+ switch (animationOptions.mode) {
2431
+ case exports.AnimationMode.increase:
2432
+ res.status = exports.AnimationStatus.increasing;
2433
+ break;
2434
+ case exports.AnimationMode.decrease:
2435
+ res.status = exports.AnimationStatus.decreasing;
2436
+ break;
2437
+ case exports.AnimationMode.random:
2438
+ res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
2439
+ break;
2440
+ }
2441
+ const autoStatus = animationOptions.mode === exports.AnimationMode.auto;
2442
+ switch (animationOptions.startValue) {
2443
+ case exports.StartValueType.min:
2444
+ res.value = res.min;
2445
+ if (autoStatus) {
2446
+ res.status = exports.AnimationStatus.increasing;
2447
+ }
2448
+ break;
2449
+ case exports.StartValueType.max:
2450
+ res.value = res.max;
2451
+ if (autoStatus) {
2452
+ res.status = exports.AnimationStatus.decreasing;
2453
+ }
2454
+ break;
2455
+ case exports.StartValueType.random:
2456
+ default:
2457
+ res.value = randomInRangeValue(res);
2458
+ if (autoStatus) {
2459
+ res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
2460
+ }
2461
+ break;
2462
+ }
2463
+ }
2464
+ res.initialValue = res.value;
2465
+ return res;
2466
+ }
2467
+ function updateAnimation(particle, data, changeDirection, destroyType, delta) {
2468
+ const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
2469
+ if (particle.destroyed ||
2470
+ !data.enable ||
2471
+ ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
2472
+ return;
2473
+ }
2474
+ const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
2475
+ data.time ??= 0;
2476
+ const delayTime = data.delayTime ?? minDelay;
2477
+ if (delayTime > minDelay && data.time < delayTime) {
2478
+ data.time += delta.value;
2479
+ if (data.time < delayTime) {
2480
+ return;
2481
+ }
2482
+ }
2483
+ switch (data.status) {
2484
+ case exports.AnimationStatus.increasing:
2485
+ data.value += velocity;
2486
+ break;
2487
+ case exports.AnimationStatus.decreasing:
2488
+ data.value -= velocity;
2489
+ break;
2490
+ }
2491
+ if (data.velocity && decay !== identity) {
2492
+ data.velocity *= decay;
2493
+ }
2494
+ switch (data.status) {
2495
+ case exports.AnimationStatus.increasing:
2496
+ if (data.value >= maxValue) {
2497
+ {
2498
+ data.status = exports.AnimationStatus.decreasing;
2499
+ }
2500
+ data.loops ??= minLoops;
2501
+ data.loops++;
2502
+ }
2503
+ break;
2504
+ case exports.AnimationStatus.decreasing:
2505
+ if (data.value <= minValue) {
2506
+ {
2507
+ data.status = exports.AnimationStatus.increasing;
2508
+ }
2509
+ data.loops ??= minLoops;
2510
+ data.loops++;
2511
+ }
2512
+ break;
2513
+ }
2514
+ checkDestroy(particle, destroyType, data.value, minValue, maxValue);
2515
+ if (!particle.destroyed) {
2516
+ data.value = clamp(data.value, minValue, maxValue);
3136
2517
  }
3137
2518
  }
3138
2519
 
3139
- async function loadMovePlugin(engine) {
3140
- engine.checkVersion("4.1.3");
3141
- await engine.pluginManager.register(e => {
3142
- const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3143
- movePluginManager.initializers.pathGenerators ??= new Map();
3144
- movePluginManager.pathGenerators ??= new Map();
3145
- movePluginManager.addPathGenerator = (name, generator) => {
3146
- movePluginManager.initializers.pathGenerators ??= new Map();
3147
- movePluginManager.initializers.pathGenerators.set(name, generator);
3148
- };
3149
- movePluginManager.getPathGenerators = async (container, force = false) => {
3150
- movePluginManager.initializers.pathGenerators ??= new Map();
3151
- movePluginManager.pathGenerators ??= new Map();
3152
- return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
3153
- };
3154
- e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
3155
- });
3156
- }
3157
-
3158
2520
  class OpacityAnimation extends RangedAnimationOptions {
3159
- destroy;
3160
- constructor() {
3161
- super();
3162
- this.destroy = exports.DestroyType.none;
3163
- this.speed = 2;
3164
- }
2521
+ destroy = exports.DestroyType.none;
3165
2522
  load(data) {
3166
2523
  super.load(data);
3167
2524
  if (isNull(data)) {
3168
2525
  return;
3169
2526
  }
3170
- if (data.destroy !== undefined) {
3171
- this.destroy = data.destroy;
3172
- }
2527
+ loadProperty(this, "destroy", data.destroy);
3173
2528
  }
3174
2529
  }
3175
2530
 
3176
2531
  class Opacity extends RangedAnimationValueWithRandom {
3177
- animation;
3178
- constructor() {
3179
- super();
3180
- this.animation = new OpacityAnimation();
3181
- this.value = 1;
3182
- }
2532
+ animation = new OpacityAnimation();
2533
+ value = 1;
3183
2534
  load(data) {
3184
2535
  if (isNull(data)) {
3185
2536
  return;
@@ -3223,10 +2574,7 @@
3223
2574
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3224
2575
  }
3225
2576
  loadOptions(options, ...sources) {
3226
- options.opacity ??= new Opacity();
3227
- for (const source of sources) {
3228
- options.opacity.load(source?.opacity);
3229
- }
2577
+ loadOptionProperty(options, "opacity", Opacity, ...sources);
3230
2578
  }
3231
2579
  reset(particle) {
3232
2580
  if (!particle.opacity) {
@@ -3244,7 +2592,7 @@
3244
2592
  }
3245
2593
 
3246
2594
  async function loadOpacityUpdater(engine) {
3247
- engine.checkVersion("4.1.3");
2595
+ engine.checkVersion("4.2.0");
3248
2596
  await engine.pluginManager.register(e => {
3249
2597
  e.pluginManager.addParticleUpdater("opacity", container => {
3250
2598
  return Promise.resolve(new OpacityUpdater(container));
@@ -3252,7 +2600,7 @@
3252
2600
  });
3253
2601
  }
3254
2602
 
3255
- const minVelocity$4 = 0, boundsMin = 0;
2603
+ const boundsMin = 0;
3256
2604
  function bounceHorizontal(data) {
3257
2605
  if ((data.outMode !== exports.OutMode.bounce && data.outMode !== exports.OutMode.split) ||
3258
2606
  (data.direction !== exports.OutModeDirection.left && data.direction !== exports.OutModeDirection.right)) {
@@ -3267,8 +2615,8 @@
3267
2615
  const velocity = data.particle.velocity.x;
3268
2616
  let bounced = false;
3269
2617
  if (data.outOfCanvas &&
3270
- ((data.direction === exports.OutModeDirection.right && velocity > minVelocity$4) ||
3271
- (data.direction === exports.OutModeDirection.left && velocity < minVelocity$4))) {
2618
+ ((data.direction === exports.OutModeDirection.right && velocity > minVelocity) ||
2619
+ (data.direction === exports.OutModeDirection.left && velocity < minVelocity))) {
3272
2620
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3273
2621
  data.particle.velocity.x *= -newVelocity;
3274
2622
  bounced = true;
@@ -3301,8 +2649,8 @@
3301
2649
  const velocity = data.particle.velocity.y;
3302
2650
  let bounced = false;
3303
2651
  if (data.outOfCanvas &&
3304
- ((data.direction === exports.OutModeDirection.bottom && velocity > minVelocity$4) ||
3305
- (data.direction === exports.OutModeDirection.top && velocity < minVelocity$4))) {
2652
+ ((data.direction === exports.OutModeDirection.bottom && velocity > minVelocity) ||
2653
+ (data.direction === exports.OutModeDirection.top && velocity < minVelocity))) {
3306
2654
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3307
2655
  data.particle.velocity.y *= -newVelocity;
3308
2656
  bounced = true;
@@ -3355,7 +2703,6 @@
3355
2703
  }
3356
2704
  }
3357
2705
 
3358
- const minVelocity$3 = 0;
3359
2706
  class DestroyOutMode {
3360
2707
  modes;
3361
2708
  constructor(_container) {
@@ -3374,10 +2721,10 @@
3374
2721
  break;
3375
2722
  case exports.ParticleOutType.inside: {
3376
2723
  const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
3377
- if ((vx < minVelocity$3 && dx > particle.moveCenter.radius) ||
3378
- (vy < minVelocity$3 && dy > particle.moveCenter.radius) ||
3379
- (vx >= minVelocity$3 && dx < -particle.moveCenter.radius) ||
3380
- (vy >= minVelocity$3 && dy < -particle.moveCenter.radius)) {
2724
+ if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
2725
+ (vy < minVelocity && dy > particle.moveCenter.radius) ||
2726
+ (vx >= minVelocity && dx < -particle.moveCenter.radius) ||
2727
+ (vy >= minVelocity && dy < -particle.moveCenter.radius)) {
3381
2728
  return;
3382
2729
  }
3383
2730
  break;
@@ -3387,7 +2734,6 @@
3387
2734
  }
3388
2735
  }
3389
2736
 
3390
- const minVelocity$2 = 0;
3391
2737
  class NoneOutMode {
3392
2738
  modes;
3393
2739
  #container;
@@ -3407,10 +2753,10 @@
3407
2753
  }
3408
2754
  const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3409
2755
  if (!gravityOptions.enable) {
3410
- if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3411
- (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
3412
- (particle.velocity.x > minVelocity$2 && particle.position.x <= canvasSize.width + pRadius) ||
3413
- (particle.velocity.x < minVelocity$2 && particle.position.x >= -pRadius)) {
2756
+ if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
2757
+ (particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
2758
+ (particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
2759
+ (particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
3414
2760
  return;
3415
2761
  }
3416
2762
  if (!isPointInside(particle.position, container.canvas.size, originPoint, pRadius, direction)) {
@@ -3429,7 +2775,7 @@
3429
2775
  }
3430
2776
  }
3431
2777
 
3432
- const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
2778
+ const updateVector = Vector.origin;
3433
2779
  class OutOutMode {
3434
2780
  modes;
3435
2781
  #container;
@@ -3450,10 +2796,10 @@
3450
2796
  updateVector.angle = particle.velocity.angle + Math.PI;
3451
2797
  updateVector.addTo(particle.moveCenter);
3452
2798
  const { dx, dy } = getDistances(particle.position, updateVector);
3453
- if ((vx <= minVelocity$1 && dx >= minDistance) ||
3454
- (vy <= minVelocity$1 && dy >= minDistance) ||
3455
- (vx >= minVelocity$1 && dx <= minDistance) ||
3456
- (vy >= minVelocity$1 && dy <= minDistance)) {
2799
+ if ((vx <= minVelocity && dx >= minDistance) ||
2800
+ (vy <= minVelocity && dy >= minDistance) ||
2801
+ (vx >= minVelocity && dx <= minDistance) ||
2802
+ (vy >= minVelocity && dy <= minDistance)) {
3457
2803
  return;
3458
2804
  }
3459
2805
  particle.position.x = Math.floor(randomInRangeValue({
@@ -3577,21 +2923,21 @@
3577
2923
  this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, exports.OutModeDirection.right);
3578
2924
  this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, exports.OutModeDirection.top);
3579
2925
  }
3580
- #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
2926
+ #addUpdaterIfMissing(particle, outMode, getUpdater) {
3581
2927
  const outModes = particle.options.move.outModes;
3582
2928
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3583
2929
  this.updaters.set(outMode, getUpdater(this.#container));
3584
2930
  }
3585
- };
3586
- #updateOutMode = (particle, delta, outMode, direction) => {
2931
+ }
2932
+ #updateOutMode(particle, delta, outMode, direction) {
3587
2933
  for (const updater of this.updaters.values()) {
3588
2934
  updater.update(particle, direction, delta, outMode);
3589
2935
  }
3590
- };
2936
+ }
3591
2937
  }
3592
2938
 
3593
2939
  async function loadOutModesUpdater(engine) {
3594
- engine.checkVersion("4.1.3");
2940
+ engine.checkVersion("4.2.0");
3595
2941
  await engine.pluginManager.register(e => {
3596
2942
  e.pluginManager.addParticleUpdater("outModes", container => {
3597
2943
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3662,7 +3008,7 @@
3662
3008
  }
3663
3009
 
3664
3010
  async function loadPaintUpdater(engine) {
3665
- engine.checkVersion("4.1.3");
3011
+ engine.checkVersion("4.2.0");
3666
3012
  await engine.pluginManager.register(e => {
3667
3013
  e.pluginManager.addParticleUpdater("paint", container => {
3668
3014
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3717,37 +3063,26 @@
3717
3063
  }
3718
3064
 
3719
3065
  async function loadRgbColorPlugin(engine) {
3720
- engine.checkVersion("4.1.3");
3066
+ engine.checkVersion("4.2.0");
3721
3067
  await engine.pluginManager.register(e => {
3722
3068
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3723
3069
  });
3724
3070
  }
3725
3071
 
3726
3072
  class SizeAnimation extends RangedAnimationOptions {
3727
- destroy;
3728
- constructor() {
3729
- super();
3730
- this.destroy = exports.DestroyType.none;
3731
- this.speed = 5;
3732
- }
3073
+ destroy = exports.DestroyType.none;
3733
3074
  load(data) {
3734
3075
  super.load(data);
3735
3076
  if (isNull(data)) {
3736
3077
  return;
3737
3078
  }
3738
- if (data.destroy !== undefined) {
3739
- this.destroy = data.destroy;
3740
- }
3079
+ loadProperty(this, "destroy", data.destroy);
3741
3080
  }
3742
3081
  }
3743
3082
 
3744
3083
  class Size extends RangedAnimationValueWithRandom {
3745
- animation;
3746
- constructor() {
3747
- super();
3748
- this.animation = new SizeAnimation();
3749
- this.value = 3;
3750
- }
3084
+ animation = new SizeAnimation();
3085
+ value = 3;
3751
3086
  load(data) {
3752
3087
  super.load(data);
3753
3088
  if (isNull(data)) {
@@ -3790,10 +3125,7 @@
3790
3125
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3791
3126
  }
3792
3127
  loadOptions(options, ...sources) {
3793
- options.size ??= new Size();
3794
- for (const source of sources) {
3795
- options.size.load(source?.size);
3796
- }
3128
+ loadOptionProperty(options, "size", Size, ...sources);
3797
3129
  }
3798
3130
  preInit(particle) {
3799
3131
  const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
@@ -3816,7 +3148,7 @@
3816
3148
  }
3817
3149
 
3818
3150
  async function loadSizeUpdater(engine) {
3819
- engine.checkVersion("4.1.3");
3151
+ engine.checkVersion("4.2.0");
3820
3152
  await engine.pluginManager.register(e => {
3821
3153
  e.pluginManager.addParticleUpdater("size", container => {
3822
3154
  return Promise.resolve(new SizeUpdater(container));
@@ -3825,7 +3157,7 @@
3825
3157
  }
3826
3158
 
3827
3159
  async function loadBasic(engine) {
3828
- engine.checkVersion("4.1.3");
3160
+ engine.checkVersion("4.2.0");
3829
3161
  await engine.pluginManager.register(async (e) => {
3830
3162
  await Promise.all([
3831
3163
  loadBlendPlugin(e),
@@ -3900,7 +3232,7 @@
3900
3232
  return;
3901
3233
  }
3902
3234
  this.draw(ctx => {
3903
- clear(ctx, this.#canvasManager.size);
3235
+ ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
3904
3236
  });
3905
3237
  }
3906
3238
  clear() {
@@ -3962,7 +3294,7 @@
3962
3294
  plugin.drawParticleSetup?.(context, particle, delta);
3963
3295
  }
3964
3296
  this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
3965
- drawParticle({
3297
+ this.#drawParticle({
3966
3298
  container,
3967
3299
  context,
3968
3300
  particle,
@@ -3981,7 +3313,7 @@
3981
3313
  drawParticlePlugins(particle, delta) {
3982
3314
  this.draw(ctx => {
3983
3315
  for (const plugin of this.#drawParticlePlugins) {
3984
- drawParticlePlugin(ctx, plugin, particle, delta);
3316
+ this.#drawParticlePlugin(ctx, plugin, particle, delta);
3985
3317
  }
3986
3318
  });
3987
3319
  }
@@ -4081,12 +3413,19 @@
4081
3413
  }
4082
3414
  paintBase(baseColor) {
4083
3415
  this.draw(ctx => {
4084
- paintBase(ctx, this.#canvasManager.size, baseColor);
3416
+ ctx.fillStyle = baseColor ?? "rgba(0,0,0,0)";
3417
+ ctx.fillRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
4085
3418
  });
4086
3419
  }
4087
3420
  paintImage(image, opacity) {
4088
3421
  this.draw(ctx => {
4089
- paintImage(ctx, this.#canvasManager.size, image, opacity);
3422
+ if (!image) {
3423
+ return;
3424
+ }
3425
+ const prevAlpha = ctx.globalAlpha;
3426
+ ctx.globalAlpha = opacity;
3427
+ ctx.drawImage(image, originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
3428
+ ctx.globalAlpha = prevAlpha;
4090
3429
  });
4091
3430
  }
4092
3431
  setContext(context) {
@@ -4100,15 +3439,15 @@
4100
3439
  }
4101
3440
  stop() {
4102
3441
  this.draw(ctx => {
4103
- clear(ctx, this.#canvasManager.size);
3442
+ ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
4104
3443
  });
4105
3444
  }
4106
- #applyPostDrawUpdaters = particle => {
3445
+ #applyPostDrawUpdaters(particle) {
4107
3446
  for (const updater of this.#postDrawUpdaters) {
4108
3447
  updater.afterDraw?.(particle);
4109
3448
  }
4110
- };
4111
- #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
3449
+ }
3450
+ #applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
4112
3451
  for (const updater of this.#preDrawUpdaters) {
4113
3452
  if (updater.getColorStyles) {
4114
3453
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
@@ -4127,8 +3466,114 @@
4127
3466
  }
4128
3467
  updater.beforeDraw?.(particle);
4129
3468
  }
4130
- };
4131
- #getPluginParticleColors = particle => {
3469
+ }
3470
+ #drawAfterEffect(drawer, data) {
3471
+ if (!drawer?.drawAfter) {
3472
+ return;
3473
+ }
3474
+ const { particle } = data;
3475
+ if (!particle.effect) {
3476
+ return;
3477
+ }
3478
+ drawer.drawAfter(data);
3479
+ }
3480
+ #drawBeforeEffect(drawer, data) {
3481
+ if (!drawer?.drawBefore) {
3482
+ return;
3483
+ }
3484
+ const { particle } = data;
3485
+ if (!particle.effect) {
3486
+ return;
3487
+ }
3488
+ drawer.drawBefore(data);
3489
+ }
3490
+ #drawParticle(data) {
3491
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
3492
+ x: pos.x,
3493
+ y: pos.y,
3494
+ };
3495
+ context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
3496
+ if (colorStyles.fill) {
3497
+ context.fillStyle = colorStyles.fill;
3498
+ }
3499
+ const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
3500
+ context.lineWidth = strokeWidth;
3501
+ if (colorStyles.stroke) {
3502
+ context.strokeStyle = colorStyles.stroke;
3503
+ }
3504
+ const drawData = {
3505
+ context,
3506
+ particle,
3507
+ radius,
3508
+ drawRadius: radius * drawScale,
3509
+ opacity,
3510
+ delta,
3511
+ pixelRatio: container.retina.pixelRatio,
3512
+ fill: fillEnabled,
3513
+ stroke: strokeWidth > minStrokeWidth,
3514
+ transformData,
3515
+ position: { ...pos },
3516
+ drawPosition,
3517
+ drawScale,
3518
+ };
3519
+ for (const plugin of container.plugins) {
3520
+ plugin.drawParticleTransform?.(drawData);
3521
+ }
3522
+ const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
3523
+ this.#drawBeforeEffect(effect, drawData);
3524
+ this.#drawShapeBeforeDraw(shape, drawData);
3525
+ this.#drawShape(shape, drawData);
3526
+ this.#drawShapeAfterDraw(shape, drawData);
3527
+ this.#drawAfterEffect(effect, drawData);
3528
+ context.resetTransform();
3529
+ }
3530
+ #drawParticlePlugin(context, plugin, particle, delta) {
3531
+ if (!plugin.drawParticle) {
3532
+ return;
3533
+ }
3534
+ plugin.drawParticle(context, particle, delta);
3535
+ }
3536
+ #drawShape(drawer, data) {
3537
+ if (!drawer) {
3538
+ return;
3539
+ }
3540
+ const { context, fill, particle, stroke } = data;
3541
+ if (!particle.shape) {
3542
+ return;
3543
+ }
3544
+ context.beginPath();
3545
+ drawer.draw(data);
3546
+ if (particle.shapeClose) {
3547
+ context.closePath();
3548
+ }
3549
+ if (fill) {
3550
+ context.fill();
3551
+ }
3552
+ if (stroke) {
3553
+ context.stroke();
3554
+ }
3555
+ }
3556
+ #drawShapeAfterDraw(drawer, data) {
3557
+ if (!drawer?.afterDraw) {
3558
+ return;
3559
+ }
3560
+ const { particle } = data;
3561
+ if (!particle.shape) {
3562
+ return;
3563
+ }
3564
+ drawer.afterDraw(data);
3565
+ }
3566
+ #drawShapeBeforeDraw(drawer, data) {
3567
+ if (!drawer?.beforeDraw) {
3568
+ return;
3569
+ }
3570
+ const { particle } = data;
3571
+ if (!particle.shape) {
3572
+ return;
3573
+ }
3574
+ drawer.beforeDraw(data);
3575
+ }
3576
+ #getPluginParticleColors(particle) {
4132
3577
  let fColor, sColor;
4133
3578
  for (const plugin of this.#colorPlugins) {
4134
3579
  if (!fColor && plugin.particleFillColor) {
@@ -4144,7 +3589,7 @@
4144
3589
  this.#reusablePluginColors[fColorIndex] = fColor;
4145
3590
  this.#reusablePluginColors[sColorIndex] = sColor;
4146
3591
  return this.#reusablePluginColors;
4147
- };
3592
+ }
4148
3593
  }
4149
3594
 
4150
3595
  const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
@@ -4276,6 +3721,7 @@
4276
3721
  obs.observe(element, { attributes: true });
4277
3722
  });
4278
3723
  this.initPlugins();
3724
+ this.#initContext();
4279
3725
  this.render.init();
4280
3726
  }
4281
3727
  initBackground() {
@@ -4285,7 +3731,7 @@
4285
3731
  }
4286
3732
  const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
4287
3733
  if (color) {
4288
- elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
3734
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
4289
3735
  }
4290
3736
  else {
4291
3737
  elementStyle.backgroundColor = "";
@@ -4307,7 +3753,7 @@
4307
3753
  if (this.#generated && this.domElement) {
4308
3754
  this.domElement.remove();
4309
3755
  }
4310
- const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
3756
+ const domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4311
3757
  this.domElement = domCanvas;
4312
3758
  this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4313
3759
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
@@ -4328,26 +3774,6 @@
4328
3774
  const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
4329
3775
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
4330
3776
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
4331
- const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
4332
- this.render.setContextSettings({
4333
- alpha: true,
4334
- colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
4335
- desynchronized: true,
4336
- willReadFrequently: false,
4337
- });
4338
- this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
4339
- this.#safeMutationObserver(obs => {
4340
- obs.disconnect();
4341
- });
4342
- container.retina.init();
4343
- this.initBackground();
4344
- this.#safeMutationObserver(obs => {
4345
- const element = this.domElement;
4346
- if (!element || !(element instanceof Node)) {
4347
- return;
4348
- }
4349
- obs.observe(element, { attributes: true });
4350
- });
4351
3777
  }
4352
3778
  resize() {
4353
3779
  const element = this.domElement;
@@ -4415,12 +3841,30 @@
4415
3841
  await container.refresh();
4416
3842
  }
4417
3843
  }
4418
- #applyResizePlugins = () => {
3844
+ #applyResizePlugins() {
4419
3845
  for (const plugin of this.#resizePlugins) {
4420
3846
  plugin.resize?.();
4421
3847
  }
4422
- };
4423
- #initStyle = () => {
3848
+ }
3849
+ #initContext() {
3850
+ const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
3851
+ safeMatchMedia("(color-gamut: p3)")?.matches &&
3852
+ safeMatchMedia("(dynamic-range: high)")?.matches;
3853
+ this.render.setContextSettings({
3854
+ alpha: true,
3855
+ desynchronized: true,
3856
+ willReadFrequently: false,
3857
+ ...(canSupportHdr
3858
+ ? { colorSpace: "display-p3", colorType: "float16" }
3859
+ : { colorSpace: "srgb" }),
3860
+ });
3861
+ const renderCanvas = this.renderCanvas;
3862
+ if (!renderCanvas) {
3863
+ return;
3864
+ }
3865
+ this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
3866
+ }
3867
+ #initStyle() {
4424
3868
  const element = this.domElement, options = this.#container.actualOptions;
4425
3869
  if (!element) {
4426
3870
  return;
@@ -4441,8 +3885,8 @@
4441
3885
  }
4442
3886
  element.style.setProperty(key, value, "important");
4443
3887
  }
4444
- };
4445
- #repairStyle = () => {
3888
+ }
3889
+ #repairStyle() {
4446
3890
  const element = this.domElement;
4447
3891
  if (!element) {
4448
3892
  return;
@@ -4461,27 +3905,27 @@
4461
3905
  }
4462
3906
  observer.observe(element, { attributes: true });
4463
3907
  });
4464
- };
4465
- #resetOriginalStyle = () => {
3908
+ }
3909
+ #resetOriginalStyle() {
4466
3910
  const element = this.domElement, originalStyle = this.#originalStyle;
4467
3911
  if (!element || !originalStyle) {
4468
3912
  return;
4469
3913
  }
4470
3914
  setStyle(element, originalStyle, true);
4471
- };
4472
- #safeMutationObserver = callback => {
3915
+ }
3916
+ #safeMutationObserver(callback) {
4473
3917
  if (!this.#mutationObserver) {
4474
3918
  return;
4475
3919
  }
4476
3920
  callback(this.#mutationObserver);
4477
- };
4478
- #setFullScreenStyle = () => {
3921
+ }
3922
+ #setFullScreenStyle() {
4479
3923
  const element = this.domElement;
4480
3924
  if (!element) {
4481
3925
  return;
4482
3926
  }
4483
3927
  setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
4484
- };
3928
+ }
4485
3929
  }
4486
3930
 
4487
3931
  class EventListeners {
@@ -4506,7 +3950,7 @@
4506
3950
  removeListeners() {
4507
3951
  this.#manageListeners(false);
4508
3952
  }
4509
- #handleVisibilityChange = () => {
3953
+ #handleVisibilityChange() {
4510
3954
  const container = this.#container, options = container.actualOptions;
4511
3955
  if (!options.pauseOnBlur) {
4512
3956
  return;
@@ -4524,8 +3968,8 @@
4524
3968
  container.draw(true);
4525
3969
  }
4526
3970
  }
4527
- };
4528
- #handleWindowResize = () => {
3971
+ }
3972
+ #handleWindowResize() {
4529
3973
  if (this.#resizeTimeout) {
4530
3974
  clearTimeout(this.#resizeTimeout);
4531
3975
  this.#resizeTimeout = undefined;
@@ -4535,13 +3979,13 @@
4535
3979
  await canvas.windowResize();
4536
3980
  };
4537
3981
  this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
4538
- };
4539
- #manageListeners = add => {
3982
+ }
3983
+ #manageListeners(add) {
4540
3984
  const handlers = this.#handlers;
4541
3985
  this.#manageResize(add);
4542
3986
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
4543
- };
4544
- #manageResize = add => {
3987
+ }
3988
+ #manageResize(add) {
4545
3989
  const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
4546
3990
  if (!options.resize.enable) {
4547
3991
  return;
@@ -4568,7 +4012,7 @@
4568
4012
  });
4569
4013
  this.#resizeObserver.observe(canvasEl);
4570
4014
  }
4571
- };
4015
+ }
4572
4016
  }
4573
4017
 
4574
4018
  function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
@@ -4595,6 +4039,131 @@
4595
4039
  data.setCb(data.radius);
4596
4040
  }
4597
4041
  }
4042
+ function normalizeAngle(angle, modulus) {
4043
+ const normalized = angle % modulus;
4044
+ return normalized < defaultAngle ? normalized + modulus : normalized;
4045
+ }
4046
+ function initParticleState(particle, id, group) {
4047
+ particle.id = id;
4048
+ particle.group = group;
4049
+ particle.justWarped = false;
4050
+ particle.effectClose = true;
4051
+ particle.shapeClose = true;
4052
+ particle.pathRotation = false;
4053
+ particle.lastPathTime = 0;
4054
+ particle.destroyed = false;
4055
+ particle.unbreakable = false;
4056
+ particle.isRotating = false;
4057
+ particle.rotation = 0;
4058
+ particle.misplaced = false;
4059
+ particle.retina = {
4060
+ maxDistance: {},
4061
+ maxSpeed: 0,
4062
+ moveDrift: 0,
4063
+ moveSpeed: 0,
4064
+ sizeAnimationSpeed: 0,
4065
+ };
4066
+ particle.size = {
4067
+ value: 1,
4068
+ max: 1,
4069
+ min: 1,
4070
+ enable: false,
4071
+ };
4072
+ particle.outType = exports.ParticleOutType.normal;
4073
+ particle.ignoresResizeRatio = true;
4074
+ }
4075
+ function resolveParticleOptions(particle, container, pluginManager, overrideOptions) {
4076
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates;
4077
+ particle.effect = itemFromSingleOrMultiple(particlesOptions.effect.type, particle.id, reduceDuplicates);
4078
+ particle.shape = itemFromSingleOrMultiple(particlesOptions.shape.type, particle.id, reduceDuplicates);
4079
+ const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
4080
+ if (overrideOptions) {
4081
+ if (overrideOptions.effect) {
4082
+ const overrideEffectType = overrideOptions.effect.type;
4083
+ if (overrideEffectType && overrideEffectType !== particle.effect) {
4084
+ const effect = itemFromSingleOrMultiple(overrideEffectType, particle.id, reduceDuplicates);
4085
+ if (effect) {
4086
+ particle.effect = effect;
4087
+ }
4088
+ }
4089
+ effectOptions.load(overrideOptions.effect);
4090
+ }
4091
+ if (overrideOptions.shape) {
4092
+ const overrideShapeType = overrideOptions.shape.type;
4093
+ if (overrideShapeType && overrideShapeType !== particle.shape) {
4094
+ const shape = itemFromSingleOrMultiple(overrideShapeType, particle.id, reduceDuplicates);
4095
+ if (shape) {
4096
+ particle.shape = shape;
4097
+ }
4098
+ }
4099
+ shapeOptions.load(overrideOptions.shape);
4100
+ }
4101
+ }
4102
+ if (particle.effect === randomColorValue) {
4103
+ const availableEffects = [...container.effectDrawers.keys()];
4104
+ particle.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
4105
+ }
4106
+ if (particle.shape === randomColorValue) {
4107
+ const availableShapes = [...container.shapeDrawers.keys()];
4108
+ particle.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
4109
+ }
4110
+ particle.effectData = particle.effect
4111
+ ? loadEffectData(particle.effect, effectOptions, particle.id, reduceDuplicates)
4112
+ : undefined;
4113
+ particle.shapeData = particle.shape
4114
+ ? loadShapeData(particle.shape, shapeOptions, particle.id, reduceDuplicates)
4115
+ : undefined;
4116
+ particlesOptions.load(overrideOptions);
4117
+ const effectData = particle.effectData, shapeData = particle.shapeData;
4118
+ if (effectData) {
4119
+ particlesOptions.load(effectData.particles);
4120
+ }
4121
+ if (shapeData) {
4122
+ particlesOptions.load(shapeData.particles);
4123
+ }
4124
+ particle.effectClose = effectData?.close ?? particlesOptions.effect.close;
4125
+ particle.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
4126
+ return particlesOptions;
4127
+ }
4128
+ function initParticleDrawers(particle, container) {
4129
+ let effectDrawer, shapeDrawer;
4130
+ if (particle.effect) {
4131
+ effectDrawer = container.effectDrawers.get(particle.effect);
4132
+ }
4133
+ if (effectDrawer?.loadEffect) {
4134
+ effectDrawer.loadEffect(particle);
4135
+ }
4136
+ if (particle.shape) {
4137
+ shapeDrawer = container.shapeDrawers.get(particle.shape);
4138
+ }
4139
+ if (shapeDrawer?.loadShape) {
4140
+ shapeDrawer.loadShape(particle);
4141
+ }
4142
+ const sideCountFunc = shapeDrawer?.getSidesCount;
4143
+ if (sideCountFunc) {
4144
+ particle.sides = sideCountFunc(particle);
4145
+ }
4146
+ }
4147
+ function runUpdaterPreInit(updaters, particle) {
4148
+ for (const updater of updaters) {
4149
+ updater.preInit?.(particle);
4150
+ }
4151
+ }
4152
+ function runUpdaterInit(updaters, particle) {
4153
+ for (const updater of updaters) {
4154
+ updater.init(particle);
4155
+ }
4156
+ }
4157
+ function runDrawerInit(container, particle) {
4158
+ const shapeDrawer = particle.shape ? container.shapeDrawers.get(particle.shape) : undefined, effectDrawer = particle.effect ? container.effectDrawers.get(particle.effect) : undefined;
4159
+ effectDrawer?.particleInit?.(container, particle);
4160
+ shapeDrawer?.particleInit?.(container, particle);
4161
+ }
4162
+ function runParticleCreatedPlugins(container, particle) {
4163
+ for (const plugin of container.particleCreatedPlugins) {
4164
+ plugin.particleCreated?.(particle);
4165
+ }
4166
+ }
4598
4167
  class Particle {
4599
4168
  backColor;
4600
4169
  bubble;
@@ -4720,94 +4289,20 @@
4720
4289
  const rotateData = this.getRotateData(), rotating = this.isRotating;
4721
4290
  this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4722
4291
  this.#cachedTransform.b = rotating
4723
- ? rotateData.sin * (externalTransform.b ?? identity$1)
4292
+ ? rotateData.sin * (externalTransform.b ?? identity)
4724
4293
  : (externalTransform.b ?? defaultTransform.b);
4725
4294
  this.#cachedTransform.c = rotating
4726
- ? -rotateData.sin * (externalTransform.c ?? identity$1)
4295
+ ? -rotateData.sin * (externalTransform.c ?? identity)
4727
4296
  : (externalTransform.c ?? defaultTransform.c);
4728
4297
  this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4729
4298
  return this.#cachedTransform;
4730
4299
  }
4731
4300
  init(id, position, overrideOptions, group) {
4732
4301
  const container = this.#container;
4733
- this.id = id;
4734
- this.group = group;
4735
- this.justWarped = false;
4736
- this.effectClose = true;
4737
- this.shapeClose = true;
4738
- this.pathRotation = false;
4739
- this.lastPathTime = 0;
4740
- this.destroyed = false;
4741
- this.unbreakable = false;
4742
- this.isRotating = false;
4743
- this.rotation = 0;
4744
- this.misplaced = false;
4745
- this.retina = {
4746
- maxDistance: {},
4747
- maxSpeed: 0,
4748
- moveDrift: 0,
4749
- moveSpeed: 0,
4750
- sizeAnimationSpeed: 0,
4751
- };
4752
- this.size = {
4753
- value: 1,
4754
- max: 1,
4755
- min: 1,
4756
- enable: false,
4757
- };
4758
- this.outType = exports.ParticleOutType.normal;
4759
- this.ignoresResizeRatio = true;
4760
- const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
4761
- this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
4762
- this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
4763
- const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
4764
- if (overrideOptions) {
4765
- if (overrideOptions.effect) {
4766
- const overrideEffectType = overrideOptions.effect.type;
4767
- if (overrideEffectType && overrideEffectType !== this.effect) {
4768
- const effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
4769
- if (effect) {
4770
- this.effect = effect;
4771
- }
4772
- }
4773
- effectOptions.load(overrideOptions.effect);
4774
- }
4775
- if (overrideOptions.shape) {
4776
- const overrideShapeType = overrideOptions.shape.type;
4777
- if (overrideShapeType && overrideShapeType !== this.shape) {
4778
- const shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
4779
- if (shape) {
4780
- this.shape = shape;
4781
- }
4782
- }
4783
- shapeOptions.load(overrideOptions.shape);
4784
- }
4785
- }
4786
- if (this.effect === randomColorValue) {
4787
- const availableEffects = [...this.#container.effectDrawers.keys()];
4788
- this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
4789
- }
4790
- if (this.shape === randomColorValue) {
4791
- const availableShapes = [...this.#container.shapeDrawers.keys()];
4792
- this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
4793
- }
4794
- this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
4795
- this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
4796
- particlesOptions.load(overrideOptions);
4797
- const effectData = this.effectData, shapeData = this.shapeData;
4798
- if (effectData) {
4799
- particlesOptions.load(effectData.particles);
4800
- }
4801
- if (shapeData) {
4802
- particlesOptions.load(shapeData.particles);
4803
- }
4804
- this.effectClose = effectData?.close ?? particlesOptions.effect.close;
4805
- this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
4806
- this.options = particlesOptions;
4302
+ initParticleState(this, id, group);
4303
+ this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
4807
4304
  container.retina.initParticle(this);
4808
- for (const updater of container.particleUpdaters) {
4809
- updater.preInit?.(this);
4810
- }
4305
+ runUpdaterPreInit(container.particleUpdaters, this);
4811
4306
  this.bubble = {
4812
4307
  inRange: false,
4813
4308
  };
@@ -4820,32 +4315,11 @@
4820
4315
  this.velocity = this.initialVelocity.copy();
4821
4316
  this.zIndexFactor = this.position.z / container.zLayers;
4822
4317
  this.sides = 24;
4823
- let effectDrawer, shapeDrawer;
4824
- if (this.effect) {
4825
- effectDrawer = container.effectDrawers.get(this.effect);
4826
- }
4827
- if (effectDrawer?.loadEffect) {
4828
- effectDrawer.loadEffect(this);
4829
- }
4830
- if (this.shape) {
4831
- shapeDrawer = container.shapeDrawers.get(this.shape);
4832
- }
4833
- if (shapeDrawer?.loadShape) {
4834
- shapeDrawer.loadShape(this);
4835
- }
4836
- const sideCountFunc = shapeDrawer?.getSidesCount;
4837
- if (sideCountFunc) {
4838
- this.sides = sideCountFunc(this);
4839
- }
4318
+ initParticleDrawers(this, container);
4840
4319
  this.spawning = false;
4841
- for (const updater of container.particleUpdaters) {
4842
- updater.init(this);
4843
- }
4844
- effectDrawer?.particleInit?.(container, this);
4845
- shapeDrawer?.particleInit?.(container, this);
4846
- for (const plugin of container.particleCreatedPlugins) {
4847
- plugin.particleCreated?.(this);
4848
- }
4320
+ runUpdaterInit(container.particleUpdaters, this);
4321
+ runDrawerInit(container, this);
4322
+ runParticleCreatedPlugins(container, this);
4849
4323
  }
4850
4324
  isInsideCanvas(direction) {
4851
4325
  return this.#getInsideCanvasResult({ direction }).inside;
@@ -4859,15 +4333,15 @@
4859
4333
  }
4860
4334
  const angle = this.roll.angle;
4861
4335
  if (this.roll.horizontal && this.roll.vertical) {
4862
- const normalizedAngle = angle % doublePI, adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + doublePI : normalizedAngle;
4336
+ const adjustedAngle = normalizeAngle(angle, doublePI);
4863
4337
  return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
4864
4338
  }
4865
4339
  if (this.roll.horizontal) {
4866
- const normalizedAngle = (angle + Math.PI * half) % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
4340
+ const adjustedAngle = normalizeAngle(angle + Math.PI * half, doublePI);
4867
4341
  return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
4868
4342
  }
4869
4343
  if (this.roll.vertical) {
4870
- const normalizedAngle = angle % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
4344
+ const adjustedAngle = normalizeAngle(angle, doublePI);
4871
4345
  return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
4872
4346
  }
4873
4347
  return false;
@@ -4880,10 +4354,10 @@
4880
4354
  updater.reset?.(this);
4881
4355
  }
4882
4356
  }
4883
- #calcPosition = (position, zIndex) => {
4357
+ #calcPosition(position, zIndex) {
4884
4358
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
4885
- const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
4886
- while (!signal.aborted) {
4359
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
4360
+ for (;;) {
4887
4361
  for (const plugin of plugins) {
4888
4362
  const pluginPos = plugin.particlePosition?.(posVec, this);
4889
4363
  if (pluginPos) {
@@ -4911,9 +4385,8 @@
4911
4385
  tryCount += tryCountIncrement;
4912
4386
  posVec = undefined;
4913
4387
  }
4914
- return posVec;
4915
- };
4916
- #calculateVelocity = () => {
4388
+ }
4389
+ #calculateVelocity() {
4917
4390
  const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
4918
4391
  if (moveOptions.direction === exports.MoveDirection.inside || moveOptions.direction === exports.MoveDirection.outside) {
4919
4392
  return res;
@@ -4929,8 +4402,8 @@
4929
4402
  res.length *= getRandom();
4930
4403
  }
4931
4404
  return res;
4932
- };
4933
- #fixHorizontal = (pos, radius, outMode) => {
4405
+ }
4406
+ #fixHorizontal(pos, radius, outMode) {
4934
4407
  fixOutMode({
4935
4408
  outMode,
4936
4409
  checkModes: [exports.OutMode.bounce],
@@ -4939,8 +4412,8 @@
4939
4412
  setCb: (value) => (pos.x += value),
4940
4413
  radius,
4941
4414
  });
4942
- };
4943
- #fixVertical = (pos, radius, outMode) => {
4415
+ }
4416
+ #fixVertical(pos, radius, outMode) {
4944
4417
  fixOutMode({
4945
4418
  outMode,
4946
4419
  checkModes: [exports.OutMode.bounce],
@@ -4949,8 +4422,8 @@
4949
4422
  setCb: (value) => (pos.y += value),
4950
4423
  radius,
4951
4424
  });
4952
- };
4953
- #getDefaultInsideCanvasResult = (direction, outMode) => {
4425
+ }
4426
+ #getDefaultInsideCanvasResult(direction, outMode) {
4954
4427
  const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === exports.OutMode.bounce;
4955
4428
  if (direction === exports.OutModeDirection.bottom) {
4956
4429
  return {
@@ -4983,8 +4456,8 @@
4983
4456
  position.x <= canvasSize.width + radius,
4984
4457
  reason: "default",
4985
4458
  };
4986
- };
4987
- #getInsideCanvasCallbackData = (direction, outMode) => {
4459
+ }
4460
+ #getInsideCanvasCallbackData(direction, outMode) {
4988
4461
  return {
4989
4462
  canvasSize: this.#container.canvas.size,
4990
4463
  direction,
@@ -4992,8 +4465,8 @@
4992
4465
  particle: this,
4993
4466
  radius: this.getRadius(),
4994
4467
  };
4995
- };
4996
- #getInsideCanvasResult = (data) => {
4468
+ }
4469
+ #getInsideCanvasResult(data) {
4997
4470
  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;
4998
4471
  if (!shapeCheck && !effectCheck) {
4999
4472
  return defaultResult;
@@ -5008,8 +4481,8 @@
5008
4481
  };
5009
4482
  }
5010
4483
  return shapeResult ?? effectResult ?? defaultResult;
5011
- };
5012
- #getRollColor = color => {
4484
+ }
4485
+ #getRollColor(color) {
5013
4486
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
5014
4487
  return color;
5015
4488
  }
@@ -5023,8 +4496,8 @@
5023
4496
  return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
5024
4497
  }
5025
4498
  return color;
5026
- };
5027
- #initPosition = position => {
4499
+ }
4500
+ #initPosition(position) {
5028
4501
  const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5029
4502
  if (!initialPosition) {
5030
4503
  throw new Error("a valid position cannot be found for particle");
@@ -5047,8 +4520,8 @@
5047
4520
  break;
5048
4521
  }
5049
4522
  this.offset = Vector.origin;
5050
- };
5051
- #normalizeInsideCanvasResult = (result, reason) => {
4523
+ }
4524
+ #normalizeInsideCanvasResult(result, reason) {
5052
4525
  if (typeof result === "boolean") {
5053
4526
  return {
5054
4527
  inside: result,
@@ -5060,7 +4533,7 @@
5060
4533
  margin: result.margin,
5061
4534
  reason: result.reason ?? reason,
5062
4535
  };
5063
- };
4536
+ }
5064
4537
  }
5065
4538
 
5066
4539
  class SpatialHashGrid {
@@ -5413,10 +4886,10 @@
5413
4886
  }
5414
4887
  this.#resizeFactor = undefined;
5415
4888
  }
5416
- #addToPool = (...particles) => {
4889
+ #addToPool(...particles) {
5417
4890
  this.#pool.push(...particles);
5418
- };
5419
- #applyDensity = (options, pluginsCount, group, groupOptions) => {
4891
+ }
4892
+ #applyDensity(options, pluginsCount, group, groupOptions) {
5420
4893
  const numberOptions = options.number;
5421
4894
  if (!numberOptions.density.enable) {
5422
4895
  if (group === undefined) {
@@ -5440,36 +4913,19 @@
5440
4913
  else if (particlesCount > particlesNumber) {
5441
4914
  this.removeQuantity(particlesCount - particlesNumber, group);
5442
4915
  }
5443
- };
5444
- #createBuckets = (zLayers) => {
4916
+ }
4917
+ #createBuckets(zLayers) {
5445
4918
  const bucketCount = Math.max(Math.floor(zLayers), one);
5446
4919
  return Array.from({ length: bucketCount }, () => []);
5447
- };
5448
- #getBucketIndex = (zIndex) => {
4920
+ }
4921
+ #getBucketIndex(zIndex) {
5449
4922
  const maxBucketIndex = this.#zBuckets.length - one;
5450
4923
  if (maxBucketIndex <= minIndex) {
5451
4924
  return minIndex;
5452
4925
  }
5453
4926
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
5454
- };
5455
- #getParticleInsertIndex = (bucket, particleId) => {
5456
- let start = minIndex, end = bucket.length;
5457
- while (start < end) {
5458
- const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
5459
- if (!middleParticle) {
5460
- end = middle;
5461
- continue;
5462
- }
5463
- if (middleParticle.id < particleId) {
5464
- start = middle + one;
5465
- }
5466
- else {
5467
- end = middle;
5468
- }
5469
- }
5470
- return start;
5471
- };
5472
- #initDensityFactor = densityOptions => {
4927
+ }
4928
+ #initDensityFactor(densityOptions) {
5473
4929
  const container = this.#container;
5474
4930
  if (!densityOptions.enable) {
5475
4931
  return defaultDensityFactor;
@@ -5479,16 +4935,16 @@
5479
4935
  return defaultDensityFactor;
5480
4936
  }
5481
4937
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
5482
- };
5483
- #insertParticleIntoBucket = (particle) => {
4938
+ }
4939
+ #insertParticleIntoBucket(particle) {
5484
4940
  const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5485
4941
  if (!bucket) {
5486
4942
  return;
5487
4943
  }
5488
- bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
4944
+ bucket.push(particle);
5489
4945
  this.#particleBuckets.set(particle.id, bucketIndex);
5490
- };
5491
- #removeParticle = (index, group, override) => {
4946
+ }
4947
+ #removeParticle(index, group, override) {
5492
4948
  const particle = this.#array[index];
5493
4949
  if (!particle) {
5494
4950
  return false;
@@ -5504,22 +4960,20 @@
5504
4960
  });
5505
4961
  this.#addToPool(particle);
5506
4962
  return true;
5507
- };
5508
- #removeParticleFromBucket = (particle) => {
4963
+ }
4964
+ #removeParticleFromBucket(particle) {
5509
4965
  const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5510
4966
  if (!bucket) {
5511
4967
  this.#particleBuckets.delete(particle.id);
5512
4968
  return;
5513
4969
  }
5514
- const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
5515
- if (bucket[particleIndex]?.id !== particle.id) {
5516
- this.#particleBuckets.delete(particle.id);
5517
- return;
4970
+ const idx = bucket.findIndex(p => p.id === particle.id);
4971
+ if (idx >= minIndex) {
4972
+ bucket.splice(idx, deleteCount);
5518
4973
  }
5519
- bucket.splice(particleIndex, deleteCount);
5520
4974
  this.#particleBuckets.delete(particle.id);
5521
- };
5522
- #resetBuckets = (zLayers) => {
4975
+ }
4976
+ #resetBuckets(zLayers) {
5523
4977
  const bucketCount = Math.max(Math.floor(zLayers), one);
5524
4978
  if (this.#zBuckets.length !== bucketCount) {
5525
4979
  this.#zBuckets = this.#createBuckets(bucketCount);
@@ -5528,8 +4982,8 @@
5528
4982
  for (const bucket of this.#zBuckets) {
5529
4983
  bucket.length = minIndex;
5530
4984
  }
5531
- };
5532
- #updateParticleBucket = (particle) => {
4985
+ }
4986
+ #updateParticleBucket(particle) {
5533
4987
  const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
5534
4988
  if (currentBucketIndex === undefined) {
5535
4989
  this.#insertParticleIntoBucket(particle);
@@ -5540,9 +4994,9 @@
5540
4994
  }
5541
4995
  const currentBucket = this.#zBuckets[currentBucketIndex];
5542
4996
  if (currentBucket) {
5543
- const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
5544
- if (currentBucket[particleIndex]?.id === particle.id) {
5545
- currentBucket.splice(particleIndex, deleteCount);
4997
+ const idx = currentBucket.findIndex(p => p.id === particle.id);
4998
+ if (idx >= minIndex) {
4999
+ currentBucket.splice(idx, deleteCount);
5546
5000
  }
5547
5001
  }
5548
5002
  const newBucket = this.#zBuckets[newBucketIndex];
@@ -5550,10 +5004,16 @@
5550
5004
  this.#particleBuckets.set(particle.id, newBucketIndex);
5551
5005
  return;
5552
5006
  }
5553
- newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
5007
+ newBucket.push(particle);
5008
+ if (newBucket.length >= double) {
5009
+ const prev = newBucket[newBucket.length - double];
5010
+ if (prev && particle.id < prev.id) {
5011
+ newBucket.sort((a, b) => a.id - b.id);
5012
+ }
5013
+ }
5554
5014
  this.#particleBuckets.set(particle.id, newBucketIndex);
5555
- };
5556
- #updateParticlesPhase1 = (delta) => {
5015
+ }
5016
+ #updateParticlesPhase1(delta) {
5557
5017
  const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
5558
5018
  for (const particle of this.#array) {
5559
5019
  if (resizeFactor && !particle.ignoresResizeRatio) {
@@ -5579,8 +5039,8 @@
5579
5039
  this.grid.insert(particle);
5580
5040
  }
5581
5041
  return particlesToDelete;
5582
- };
5583
- #updateParticlesPhase2 = (delta, particlesToDelete) => {
5042
+ }
5043
+ #updateParticlesPhase2(delta, particlesToDelete) {
5584
5044
  for (const particle of this.#array) {
5585
5045
  if (particle.destroyed) {
5586
5046
  particlesToDelete.add(particle);
@@ -5596,7 +5056,7 @@
5596
5056
  }
5597
5057
  this.#updateParticleBucket(particle);
5598
5058
  }
5599
- };
5059
+ }
5600
5060
  }
5601
5061
 
5602
5062
  class Retina {
@@ -5958,7 +5418,7 @@
5958
5418
  }
5959
5419
  return refresh;
5960
5420
  }
5961
- #nextFrame = (timestamp) => {
5421
+ #nextFrame(timestamp) {
5962
5422
  try {
5963
5423
  if (!this.#smooth &&
5964
5424
  this.#lastFrameTime !== undefined &&
@@ -5986,7 +5446,7 @@
5986
5446
  catch (e) {
5987
5447
  getLogger().error("error in animation loop", e);
5988
5448
  }
5989
- };
5449
+ }
5990
5450
  }
5991
5451
 
5992
5452
  var Container$1 = /*#__PURE__*/Object.freeze({
@@ -6032,7 +5492,7 @@
6032
5492
  BlendPluginInstance: BlendPluginInstance
6033
5493
  });
6034
5494
 
6035
- const minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
5495
+ const moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
6036
5496
  function applyDistance(particle) {
6037
5497
  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;
6038
5498
  if (!hDistance && !vDistance) {
@@ -6264,6 +5724,7 @@
6264
5724
  exports.MoveCenter = MoveCenter;
6265
5725
  exports.MoveGravity = MoveGravity;
6266
5726
  exports.MovePath = MovePath;
5727
+ exports.OptionLoader = OptionLoader;
6267
5728
  exports.Options = Options;
6268
5729
  exports.OptionsColor = OptionsColor;
6269
5730
  exports.OutModes = OutModes;
@@ -6288,9 +5749,7 @@
6288
5749
  exports.alterHsl = alterHsl;
6289
5750
  exports.animate = animate;
6290
5751
  exports.areBoundsInside = areBoundsInside;
6291
- exports.arrayRandomIndex = arrayRandomIndex;
6292
5752
  exports.calcExactPositionOrRandomFromSize = calcExactPositionOrRandomFromSize;
6293
- exports.calcExactPositionOrRandomFromSizeRanged = calcExactPositionOrRandomFromSizeRanged;
6294
5753
  exports.calcPositionFromSize = calcPositionFromSize;
6295
5754
  exports.calcPositionOrRandomFromSize = calcPositionOrRandomFromSize;
6296
5755
  exports.calcPositionOrRandomFromSizeRanged = calcPositionOrRandomFromSizeRanged;
@@ -6302,11 +5761,9 @@
6302
5761
  exports.circleBounce = circleBounce;
6303
5762
  exports.circleBounceDataFromParticle = circleBounceDataFromParticle;
6304
5763
  exports.clamp = clamp;
6305
- exports.clear = clear;
6306
5764
  exports.cloneStyle = cloneStyle;
6307
5765
  exports.collisionVelocity = collisionVelocity;
6308
5766
  exports.colorMix = colorMix;
6309
- exports.colorToHsl = colorToHsl;
6310
5767
  exports.colorToRgb = colorToRgb;
6311
5768
  exports.countOffset = countOffset;
6312
5769
  exports.decayOffset = decayOffset;
@@ -6333,16 +5790,8 @@
6333
5790
  exports.deleteCount = deleteCount;
6334
5791
  exports.double = double;
6335
5792
  exports.doublePI = doublePI;
6336
- exports.drawAfterEffect = drawAfterEffect;
6337
- exports.drawBeforeEffect = drawBeforeEffect;
6338
- exports.drawParticle = drawParticle;
6339
- exports.drawParticlePlugin = drawParticlePlugin;
6340
- exports.drawShape = drawShape;
6341
- exports.drawShapeAfterDraw = drawShapeAfterDraw;
6342
- exports.drawShapeBeforeDraw = drawShapeBeforeDraw;
6343
5793
  exports.empty = empty;
6344
5794
  exports.executeOnSingleOrMultiple = executeOnSingleOrMultiple;
6345
- exports.findItemFromSingleOrMultiple = findItemFromSingleOrMultiple;
6346
5795
  exports.generatedAttribute = generatedAttribute;
6347
5796
  exports.generatedFalse = generatedFalse;
6348
5797
  exports.generatedTrue = generatedTrue;
@@ -6361,23 +5810,21 @@
6361
5810
  exports.getParticleDirectionAngle = getParticleDirectionAngle;
6362
5811
  exports.getPosition = getPosition;
6363
5812
  exports.getRandom = getRandom;
5813
+ exports.getRandomFn = getRandomFn;
6364
5814
  exports.getRandomInRange = getRandomInRange;
6365
5815
  exports.getRandomRgbColor = getRandomRgbColor;
6366
5816
  exports.getRangeMax = getRangeMax;
6367
5817
  exports.getRangeMin = getRangeMin;
6368
5818
  exports.getRangeValue = getRangeValue;
6369
- exports.getSize = getSize;
6370
5819
  exports.getStyleFromHsl = getStyleFromHsl;
6371
5820
  exports.getStyleFromRgb = getStyleFromRgb;
6372
5821
  exports.hMax = hMax;
6373
5822
  exports.hMin = hMin;
6374
5823
  exports.hPhase = hPhase;
6375
5824
  exports.half = half;
6376
- exports.hasMatchMedia = hasMatchMedia;
6377
5825
  exports.hslToRgb = hslToRgb;
6378
5826
  exports.hslaToRgba = hslaToRgba;
6379
- exports.identity = identity$1;
6380
- exports.initParticleNumericAnimationValue = initParticleNumericAnimationValue;
5827
+ exports.identity = identity;
6381
5828
  exports.inverseFactorNumerator = inverseFactorNumerator;
6382
5829
  exports.isArray = isArray;
6383
5830
  exports.isBoolean = isBoolean;
@@ -6395,28 +5842,34 @@
6395
5842
  exports.lMin = lMin;
6396
5843
  exports.lengthOffset = lengthOffset;
6397
5844
  exports.loadBasic = loadBasic;
5845
+ exports.loadExtendProperty = loadExtendProperty;
5846
+ exports.loadLazyProperty = loadLazyProperty;
6398
5847
  exports.loadMinIndex = loadMinIndex;
5848
+ exports.loadNestedProperty = loadNestedProperty;
5849
+ exports.loadOptionProperty = loadOptionProperty;
6399
5850
  exports.loadOptions = loadOptions;
6400
5851
  exports.loadParticlesOptions = loadParticlesOptions;
5852
+ exports.loadProperty = loadProperty;
6401
5853
  exports.loadRandomFactor = loadRandomFactor;
5854
+ exports.loadRangeProperty = loadRangeProperty;
6402
5855
  exports.manageListener = manageListener;
6403
- exports.memoize = memoize;
5856
+ exports.maxNits = maxNits;
6404
5857
  exports.midColorValue = midColorValue;
6405
5858
  exports.millisecondsToSeconds = millisecondsToSeconds;
6406
5859
  exports.minCount = minCount;
5860
+ exports.minDistance = minDistance;
6407
5861
  exports.minFpsLimit = minFpsLimit;
6408
5862
  exports.minIndex = minIndex;
6409
5863
  exports.minLimit = minLimit;
5864
+ exports.minRadius = minRadius$1;
6410
5865
  exports.minStrokeWidth = minStrokeWidth;
6411
- exports.minVelocity = minVelocity$5;
5866
+ exports.minVelocity = minVelocity;
6412
5867
  exports.minZ = minZ;
6413
5868
  exports.minimumSize = minimumSize;
6414
5869
  exports.mix = mix;
6415
5870
  exports.none = none;
6416
5871
  exports.one = one;
6417
5872
  exports.originPoint = originPoint;
6418
- exports.paintBase = paintBase;
6419
- exports.paintImage = paintImage;
6420
5873
  exports.parseAlpha = parseAlpha;
6421
5874
  exports.percentDenominator = percentDenominator;
6422
5875
  exports.phaseNumerator = phaseNumerator;
@@ -6434,7 +5887,6 @@
6434
5887
  exports.sMin = sMin;
6435
5888
  exports.sNormalizedOffset = sNormalizedOffset;
6436
5889
  exports.safeDocument = safeDocument;
6437
- exports.safeIntersectionObserver = safeIntersectionObserver;
6438
5890
  exports.safeMatchMedia = safeMatchMedia;
6439
5891
  exports.safeMutationObserver = safeMutationObserver;
6440
5892
  exports.setAnimationFunctions = setAnimationFunctions;
@@ -6450,14 +5902,13 @@
6450
5902
  exports.triple = triple;
6451
5903
  exports.tryCountIncrement = tryCountIncrement;
6452
5904
  exports.tsParticles = tsParticles;
6453
- exports.updateAnimation = updateAnimation;
6454
5905
  exports.updateColor = updateColor;
6455
5906
  exports.updateColorValue = updateColorValue;
6456
5907
  exports.visibilityChangeEvent = visibilityChangeEvent;
6457
5908
  exports.zIndexFactorOffset = zIndexFactorOffset;
6458
5909
 
6459
5910
  }));
6460
- Object.assign(globalThis.window || globalThis, { loadBasic: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadBasic, loadMinIndex: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadMinIndex, loadOptions: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadOptions, loadParticlesOptions: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadParticlesOptions, loadRandomFactor: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadRandomFactor, tsParticles: (globalThis.__tsParticlesInternals.bundles.basic || {}).tsParticles });
5911
+ Object.assign(globalThis.window || globalThis, { loadBasic: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadBasic, loadExtendProperty: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadExtendProperty, loadLazyProperty: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadLazyProperty, loadMinIndex: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadMinIndex, loadNestedProperty: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadNestedProperty, loadOptionProperty: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadOptionProperty, loadOptions: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadOptions, loadParticlesOptions: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadParticlesOptions, loadProperty: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadProperty, loadRandomFactor: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadRandomFactor, loadRangeProperty: (globalThis.__tsParticlesInternals.bundles.basic || {}).loadRangeProperty, tsParticles: (globalThis.__tsParticlesInternals.bundles.basic || {}).tsParticles });
6461
5912
  globalThis.__tsParticlesInternals = globalThis.__tsParticlesInternals || {};
6462
5913
  if (!globalThis.__tsParticlesInternals.engine || !globalThis.__tsParticlesInternals.engine.tsParticles) {
6463
5914
  globalThis.__tsParticlesInternals.engine = globalThis.__tsParticlesInternals.bundles.basic || {};