@tsparticles/fireworks 4.1.2 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* tsParticles v4.1.2 */
2
+ /* tsParticles v4.2.0 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5
5
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -15,7 +15,7 @@
15
15
  b: 0,
16
16
  c: 0,
17
17
  d: 1,
18
- }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha$1 = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity$5 = 0, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$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$2 = 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 = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, maxNits = 400, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
19
19
 
20
20
  exports.MoveDirection = void 0;
21
21
  (function (MoveDirection) {
@@ -82,11 +82,6 @@
82
82
  div(n) {
83
83
  return Vector3d.create(this.x / n, this.y / n, this.z / n);
84
84
  }
85
- divTo(n) {
86
- this.x /= n;
87
- this.y /= n;
88
- this.z /= n;
89
- }
90
85
  getLengthSq() {
91
86
  return this.x ** squareExp + this.y ** squareExp;
92
87
  }
@@ -176,6 +171,9 @@
176
171
  function setRandom(rnd = Math.random) {
177
172
  _random = rnd;
178
173
  }
174
+ function getRandomFn() {
175
+ return _random;
176
+ }
179
177
  function getRandom() {
180
178
  const min = 0, max = 1;
181
179
  return clamp(_random(), min, max - Number.EPSILON);
@@ -311,13 +309,6 @@
311
309
  y: position?.y ?? getRandom() * size.height,
312
310
  };
313
311
  }
314
- function calcExactPositionOrRandomFromSizeRanged(data) {
315
- const position = {
316
- x: data.position?.x !== undefined ? getRangeValue(data.position.x) : undefined,
317
- y: data.position?.y !== undefined ? getRangeValue(data.position.y) : undefined,
318
- };
319
- return calcExactPositionOrRandomFromSize({ size: data.size, position });
320
- }
321
312
  function parseAlpha(input) {
322
313
  const defaultAlpha = 1;
323
314
  if (!input) {
@@ -326,27 +317,6 @@
326
317
  return input.endsWith("%") ? parseFloat(input) / percentDenominator : parseFloat(input);
327
318
  }
328
319
 
329
- exports.AnimationMode = void 0;
330
- (function (AnimationMode) {
331
- AnimationMode["auto"] = "auto";
332
- AnimationMode["increase"] = "increase";
333
- AnimationMode["decrease"] = "decrease";
334
- AnimationMode["random"] = "random";
335
- })(exports.AnimationMode || (exports.AnimationMode = {}));
336
-
337
- exports.AnimationStatus = void 0;
338
- (function (AnimationStatus) {
339
- AnimationStatus["increasing"] = "increasing";
340
- AnimationStatus["decreasing"] = "decreasing";
341
- })(exports.AnimationStatus || (exports.AnimationStatus = {}));
342
-
343
- exports.DestroyType = void 0;
344
- (function (DestroyType) {
345
- DestroyType["none"] = "none";
346
- DestroyType["max"] = "max";
347
- DestroyType["min"] = "min";
348
- })(exports.DestroyType || (exports.DestroyType = {}));
349
-
350
320
  exports.OutModeDirection = void 0;
351
321
  (function (OutModeDirection) {
352
322
  OutModeDirection["bottom"] = "bottom";
@@ -361,80 +331,7 @@
361
331
  PixelMode["percent"] = "percent";
362
332
  })(exports.PixelMode || (exports.PixelMode = {}));
363
333
 
364
- exports.StartValueType = void 0;
365
- (function (StartValueType) {
366
- StartValueType["max"] = "max";
367
- StartValueType["min"] = "min";
368
- StartValueType["random"] = "random";
369
- })(exports.StartValueType || (exports.StartValueType = {}));
370
-
371
- const minRadius = 0, minMemoizeSize = 0;
372
- function memoize(fn, options) {
373
- const cache = new Map(), maxSize = options?.maxSize, ttlMs = options?.ttlMs, keyFn = options?.keyFn, stableStringify = (obj, seen = new WeakSet()) => {
374
- if (obj === null) {
375
- return "null";
376
- }
377
- const t = typeof obj;
378
- if (t === "undefined") {
379
- return "undefined";
380
- }
381
- if (t === "number" || t === "boolean" || t === "string") {
382
- return JSON.stringify(obj);
383
- }
384
- if (t === "function") {
385
- try {
386
- const fn = obj;
387
- return fn.toString();
388
- }
389
- catch {
390
- return '"[Function]"';
391
- }
392
- }
393
- if (t === "symbol") {
394
- try {
395
- return obj.toString();
396
- }
397
- catch {
398
- return '"[Symbol]"';
399
- }
400
- }
401
- if (Array.isArray(obj)) {
402
- return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
403
- }
404
- if (seen.has(obj)) {
405
- return '"[Circular]"';
406
- }
407
- seen.add(obj);
408
- const keys = Object.keys(obj).sort();
409
- return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
410
- }, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (keyFn ? keyFn(args) : defaultKeyer(args)), ensureBounds = () => {
411
- if (typeof maxSize === "number" && maxSize >= minMemoizeSize) {
412
- while (cache.size > maxSize) {
413
- const firstKey = cache.keys().next().value;
414
- if (firstKey === undefined)
415
- break;
416
- cache.delete(firstKey);
417
- }
418
- }
419
- };
420
- return (...args) => {
421
- const key = makeKey(args), now = Date.now(), entry = cache.get(key);
422
- if (entry !== undefined) {
423
- if (ttlMs && now - entry.ts > ttlMs) {
424
- cache.delete(key);
425
- }
426
- else {
427
- cache.delete(key);
428
- cache.set(key, { value: entry.value, ts: entry.ts });
429
- return entry.value;
430
- }
431
- }
432
- const result = fn(...args);
433
- cache.set(key, { value: result, ts: now });
434
- ensureBounds();
435
- return result;
436
- };
437
- }
334
+ const minRadius = 0;
438
335
  function hasMatchMedia() {
439
336
  return typeof matchMedia !== "undefined";
440
337
  }
@@ -447,12 +344,6 @@
447
344
  }
448
345
  return matchMedia(query);
449
346
  }
450
- function safeIntersectionObserver(callback) {
451
- if (typeof IntersectionObserver === "undefined") {
452
- return;
453
- }
454
- return new IntersectionObserver(callback);
455
- }
456
347
  function safeMutationObserver(callback) {
457
348
  if (typeof MutationObserver === "undefined") {
458
349
  return;
@@ -462,11 +353,8 @@
462
353
  function isInArray(value, array) {
463
354
  return value === array || (isArray(array) && array.includes(value));
464
355
  }
465
- function arrayRandomIndex(array) {
466
- return Math.floor(getRandom() * array.length);
467
- }
468
356
  function itemFromArray(array, index, useIndex = true) {
469
- return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
357
+ return array[index !== undefined && useIndex ? index % array.length : Math.floor(getRandom() * array.length)];
470
358
  }
471
359
  function isPointInside(point, size, offset, radius, direction) {
472
360
  return areBoundsInside(calculateBounds(point, radius ?? minRadius), size, offset, direction);
@@ -570,63 +458,6 @@
570
458
  function itemFromSingleOrMultiple(obj, index, useIndex) {
571
459
  return isArray(obj) ? itemFromArray(obj, index, useIndex) : obj;
572
460
  }
573
- function findItemFromSingleOrMultiple(obj, callback) {
574
- if (isArray(obj)) {
575
- return obj.find((t, index) => callback(t, index));
576
- }
577
- const defaultIndex = 0;
578
- return callback(obj, defaultIndex) ? obj : undefined;
579
- }
580
- function initParticleNumericAnimationValue(options, pxRatio) {
581
- const valueRange = options.value, animationOptions = options.animation, res = {
582
- delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
583
- enable: animationOptions.enable,
584
- value: getRangeValue(options.value) * pxRatio,
585
- max: getRangeMax(valueRange) * pxRatio,
586
- min: getRangeMin(valueRange) * pxRatio,
587
- loops: 0,
588
- maxLoops: getRangeValue(animationOptions.count),
589
- time: 0,
590
- }, decayOffset = 1;
591
- if (animationOptions.enable) {
592
- res.decay = decayOffset - getRangeValue(animationOptions.decay);
593
- switch (animationOptions.mode) {
594
- case exports.AnimationMode.increase:
595
- res.status = exports.AnimationStatus.increasing;
596
- break;
597
- case exports.AnimationMode.decrease:
598
- res.status = exports.AnimationStatus.decreasing;
599
- break;
600
- case exports.AnimationMode.random:
601
- res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
602
- break;
603
- }
604
- const autoStatus = animationOptions.mode === exports.AnimationMode.auto;
605
- switch (animationOptions.startValue) {
606
- case exports.StartValueType.min:
607
- res.value = res.min;
608
- if (autoStatus) {
609
- res.status = exports.AnimationStatus.increasing;
610
- }
611
- break;
612
- case exports.StartValueType.max:
613
- res.value = res.max;
614
- if (autoStatus) {
615
- res.status = exports.AnimationStatus.decreasing;
616
- }
617
- break;
618
- case exports.StartValueType.random:
619
- default:
620
- res.value = randomInRangeValue(res);
621
- if (autoStatus) {
622
- res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
623
- }
624
- break;
625
- }
626
- }
627
- res.initialValue = res.value;
628
- return res;
629
- }
630
461
  function getPositionOrSize(positionOrSize, canvasSize) {
631
462
  const isPercent = positionOrSize.mode === exports.PixelMode.percent;
632
463
  if (!isPercent) {
@@ -650,80 +481,6 @@
650
481
  function getPosition(position, canvasSize) {
651
482
  return getPositionOrSize(position, canvasSize);
652
483
  }
653
- function getSize(size, canvasSize) {
654
- return getPositionOrSize(size, canvasSize);
655
- }
656
- function checkDestroy(particle, destroyType, value, minValue, maxValue) {
657
- switch (destroyType) {
658
- case exports.DestroyType.max:
659
- if (value >= maxValue) {
660
- particle.destroy();
661
- }
662
- break;
663
- case exports.DestroyType.min:
664
- if (value <= minValue) {
665
- particle.destroy();
666
- }
667
- break;
668
- }
669
- }
670
- function updateAnimation(particle, data, changeDirection, destroyType, delta) {
671
- const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
672
- if (particle.destroyed ||
673
- !data.enable ||
674
- ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
675
- return;
676
- }
677
- const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
678
- data.time ??= 0;
679
- if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
680
- data.time += delta.value;
681
- }
682
- if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
683
- return;
684
- }
685
- switch (data.status) {
686
- case exports.AnimationStatus.increasing:
687
- data.value += velocity;
688
- break;
689
- case exports.AnimationStatus.decreasing:
690
- data.value -= velocity;
691
- break;
692
- }
693
- if (data.velocity && decay !== identity) {
694
- data.velocity *= decay;
695
- }
696
- switch (data.status) {
697
- case exports.AnimationStatus.increasing:
698
- if (data.value >= maxValue) {
699
- if (changeDirection) {
700
- data.status = exports.AnimationStatus.decreasing;
701
- }
702
- else {
703
- data.value -= maxValue;
704
- }
705
- data.loops ??= minLoops;
706
- data.loops++;
707
- }
708
- break;
709
- case exports.AnimationStatus.decreasing:
710
- if (data.value <= minValue) {
711
- if (changeDirection) {
712
- data.status = exports.AnimationStatus.increasing;
713
- }
714
- else {
715
- data.value += maxValue;
716
- }
717
- data.loops ??= minLoops;
718
- data.loops++;
719
- }
720
- break;
721
- }
722
- checkDestroy(particle, destroyType, data.value, minValue, maxValue);
723
- if (!particle.destroyed) {
724
- data.value = clamp(data.value, minValue, maxValue);
725
- }
726
- }
727
484
  function cloneStyle(style) {
728
485
  const clonedStyle = safeDocument().createElement("div").style;
729
486
  for (const key in style) {
@@ -745,30 +502,34 @@
745
502
  }
746
503
  return clonedStyle;
747
504
  }
748
- function computeFullScreenStyle(zIndex) {
749
- const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
750
- width: "100%",
751
- height: "100%",
752
- margin: "0",
753
- padding: "0",
754
- borderWidth: "0",
755
- position: "fixed",
756
- zIndex: zIndex.toString(radix),
757
- "z-index": zIndex.toString(radix),
758
- top: "0",
759
- left: "0",
760
- "pointer-events": "none",
761
- };
762
- for (const key in style) {
763
- const value = style[key];
764
- if (value === undefined) {
765
- continue;
505
+ let _cachedZIndex, _cachedStyle;
506
+ function getFullScreenStyle(zIndex) {
507
+ if (_cachedZIndex !== zIndex || !_cachedStyle) {
508
+ _cachedZIndex = zIndex;
509
+ const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
510
+ width: "100%",
511
+ height: "100%",
512
+ margin: "0",
513
+ padding: "0",
514
+ borderWidth: "0",
515
+ position: "fixed",
516
+ zIndex: zIndex.toString(radix),
517
+ "z-index": zIndex.toString(radix),
518
+ top: "0",
519
+ left: "0",
520
+ "pointer-events": "none",
521
+ };
522
+ for (const key in style) {
523
+ const value = style[key];
524
+ if (value === undefined) {
525
+ continue;
526
+ }
527
+ fullScreenStyle.setProperty(key, value);
766
528
  }
767
- fullScreenStyle.setProperty(key, value);
529
+ _cachedStyle = fullScreenStyle;
768
530
  }
769
- return fullScreenStyle;
531
+ return _cachedStyle;
770
532
  }
771
- const getFullScreenStyle = memoize(computeFullScreenStyle);
772
533
  function manageListener(element, event, handler, add, options) {
773
534
  if (add) {
774
535
  let addOptions = { passive: true };
@@ -1118,7 +879,7 @@
1118
879
  return this.#domArray;
1119
880
  }
1120
881
  get version() {
1121
- return "4.1.2";
882
+ return "4.2.0";
1122
883
  }
1123
884
  addEventListener(type, listener) {
1124
885
  this.#eventDispatcher.addEventListener(type, listener);
@@ -1288,6 +1049,14 @@
1288
1049
  RotateDirection["random"] = "random";
1289
1050
  })(exports.RotateDirection || (exports.RotateDirection = {}));
1290
1051
 
1052
+ exports.AnimationMode = void 0;
1053
+ (function (AnimationMode) {
1054
+ AnimationMode["auto"] = "auto";
1055
+ AnimationMode["increase"] = "increase";
1056
+ AnimationMode["decrease"] = "decrease";
1057
+ AnimationMode["random"] = "random";
1058
+ })(exports.AnimationMode || (exports.AnimationMode = {}));
1059
+
1291
1060
  exports.LimitMode = void 0;
1292
1061
  (function (LimitMode) {
1293
1062
  LimitMode["delete"] = "delete";
@@ -1309,6 +1078,13 @@
1309
1078
  AlterType["enlighten"] = "enlighten";
1310
1079
  })(exports.AlterType || (exports.AlterType = {}));
1311
1080
 
1081
+ exports.DestroyType = void 0;
1082
+ (function (DestroyType) {
1083
+ DestroyType["none"] = "none";
1084
+ DestroyType["max"] = "max";
1085
+ DestroyType["min"] = "min";
1086
+ })(exports.DestroyType || (exports.DestroyType = {}));
1087
+
1312
1088
  exports.GradientType = void 0;
1313
1089
  (function (GradientType) {
1314
1090
  GradientType["linear"] = "linear";
@@ -1323,160 +1099,126 @@
1323
1099
  ParticleOutType["outside"] = "outside";
1324
1100
  })(exports.ParticleOutType || (exports.ParticleOutType = {}));
1325
1101
 
1326
- exports.EasingType = void 0;
1327
- (function (EasingType) {
1328
- EasingType["easeInBack"] = "ease-in-back";
1329
- EasingType["easeInBounce"] = "ease-in-bounce";
1330
- EasingType["easeInCirc"] = "ease-in-circ";
1331
- EasingType["easeInCubic"] = "ease-in-cubic";
1332
- EasingType["easeInElastic"] = "ease-in-elastic";
1333
- EasingType["easeInExpo"] = "ease-in-expo";
1334
- EasingType["easeInGaussian"] = "ease-in-gaussian";
1335
- EasingType["easeInLinear"] = "ease-in-linear";
1336
- EasingType["easeInQuad"] = "ease-in-quad";
1337
- EasingType["easeInQuart"] = "ease-in-quart";
1338
- EasingType["easeInQuint"] = "ease-in-quint";
1339
- EasingType["easeInSigmoid"] = "ease-in-sigmoid";
1340
- EasingType["easeInSine"] = "ease-in-sine";
1341
- EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
1342
- EasingType["easeOutBack"] = "ease-out-back";
1343
- EasingType["easeOutBounce"] = "ease-out-bounce";
1344
- EasingType["easeOutCirc"] = "ease-out-circ";
1345
- EasingType["easeOutCubic"] = "ease-out-cubic";
1346
- EasingType["easeOutElastic"] = "ease-out-elastic";
1347
- EasingType["easeOutExpo"] = "ease-out-expo";
1348
- EasingType["easeOutGaussian"] = "ease-out-gaussian";
1349
- EasingType["easeOutLinear"] = "ease-out-linear";
1350
- EasingType["easeOutQuad"] = "ease-out-quad";
1351
- EasingType["easeOutQuart"] = "ease-out-quart";
1352
- EasingType["easeOutQuint"] = "ease-out-quint";
1353
- EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
1354
- EasingType["easeOutSine"] = "ease-out-sine";
1355
- EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
1356
- EasingType["easeInOutBack"] = "ease-in-out-back";
1357
- EasingType["easeInOutBounce"] = "ease-in-out-bounce";
1358
- EasingType["easeInOutCirc"] = "ease-in-out-circ";
1359
- EasingType["easeInOutCubic"] = "ease-in-out-cubic";
1360
- EasingType["easeInOutElastic"] = "ease-in-out-elastic";
1361
- EasingType["easeInOutExpo"] = "ease-in-out-expo";
1362
- EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
1363
- EasingType["easeInOutLinear"] = "ease-in-out-linear";
1364
- EasingType["easeInOutQuad"] = "ease-in-out-quad";
1365
- EasingType["easeInOutQuart"] = "ease-in-out-quart";
1366
- EasingType["easeInOutQuint"] = "ease-in-out-quint";
1367
- EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
1368
- EasingType["easeInOutSine"] = "ease-in-out-sine";
1369
- EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
1370
- })(exports.EasingType || (exports.EasingType = {}));
1371
-
1372
- class AnimationOptions {
1373
- count;
1374
- decay;
1375
- delay;
1376
- enable;
1377
- speed;
1378
- sync;
1379
- constructor() {
1380
- this.count = 0;
1381
- this.enable = false;
1382
- this.speed = 1;
1383
- this.decay = 0;
1384
- this.delay = 0;
1385
- this.sync = false;
1386
- }
1102
+ exports.StartValueType = void 0;
1103
+ (function (StartValueType) {
1104
+ StartValueType["max"] = "max";
1105
+ StartValueType["min"] = "min";
1106
+ StartValueType["random"] = "random";
1107
+ })(exports.StartValueType || (exports.StartValueType = {}));
1108
+
1109
+ exports.AnimationStatus = void 0;
1110
+ (function (AnimationStatus) {
1111
+ AnimationStatus["increasing"] = "increasing";
1112
+ AnimationStatus["decreasing"] = "decreasing";
1113
+ })(exports.AnimationStatus || (exports.AnimationStatus = {}));
1114
+
1115
+ class OptionLoader {
1387
1116
  load(data) {
1388
1117
  if (isNull(data)) {
1389
1118
  return;
1390
1119
  }
1391
- if (data.count !== undefined) {
1392
- this.count = setRangeValue(data.count);
1393
- }
1394
- if (data.enable !== undefined) {
1395
- this.enable = data.enable;
1396
- }
1397
- if (data.speed !== undefined) {
1398
- this.speed = setRangeValue(data.speed);
1399
- }
1400
- if (data.decay !== undefined) {
1401
- this.decay = setRangeValue(data.decay);
1402
- }
1403
- if (data.delay !== undefined) {
1404
- this.delay = setRangeValue(data.delay);
1405
- }
1406
- if (data.sync !== undefined) {
1407
- this.sync = data.sync;
1408
- }
1120
+ this.doLoad(data);
1409
1121
  }
1410
1122
  }
1411
- class RangedAnimationOptions extends AnimationOptions {
1412
- mode;
1413
- startValue;
1414
- constructor() {
1415
- super();
1416
- this.mode = exports.AnimationMode.auto;
1417
- this.startValue = exports.StartValueType.random;
1418
- }
1419
- load(data) {
1420
- super.load(data);
1421
- if (isNull(data)) {
1422
- return;
1423
- }
1424
- if (data.mode !== undefined) {
1425
- this.mode = data.mode;
1426
- }
1427
- if (data.startValue !== undefined) {
1428
- this.startValue = data.startValue;
1429
- }
1123
+ function loadOptions(options, ...sourceOptionsArr) {
1124
+ for (const sourceOptions of sourceOptionsArr) {
1125
+ options.load(sourceOptions);
1430
1126
  }
1431
1127
  }
1432
1128
 
1433
- class ColorAnimation extends AnimationOptions {
1434
- max;
1435
- min;
1436
- offset;
1437
- constructor(min, max) {
1438
- super();
1439
- this.min = min;
1440
- this.max = max;
1441
- this.offset = 0;
1442
- this.sync = true;
1129
+ function loadProperty(obj, key, value) {
1130
+ if (value !== undefined) {
1131
+ obj[key] = value;
1443
1132
  }
1444
- load(data) {
1445
- super.load(data);
1446
- if (isNull(data)) {
1447
- return;
1448
- }
1449
- if (data.max !== undefined) {
1450
- this.max = data.max;
1451
- }
1452
- if (data.min !== undefined) {
1453
- this.min = data.min;
1454
- }
1455
- if (data.offset !== undefined) {
1456
- this.offset = setRangeValue(data.offset);
1457
- }
1133
+ }
1134
+ function loadRangeProperty(obj, key, value) {
1135
+ if (value !== undefined) {
1136
+ obj[key] = setRangeValue(value);
1137
+ }
1138
+ }
1139
+ function loadNestedProperty(obj, key, value) {
1140
+ if (value !== undefined) {
1141
+ obj[key].load(value);
1142
+ }
1143
+ }
1144
+ function loadLazyProperty(obj, key, value, factory) {
1145
+ if (value !== undefined) {
1146
+ const objRecord = obj;
1147
+ objRecord[key] ??= factory();
1148
+ objRecord[key].load(value);
1149
+ }
1150
+ }
1151
+ function loadExtendProperty(obj, key, value) {
1152
+ if (value !== undefined) {
1153
+ obj[key] = deepExtend(obj[key] ?? {}, value);
1154
+ }
1155
+ }
1156
+ function loadOptionProperty(obj, key, optionClass, ...sources) {
1157
+ const objRecord = obj;
1158
+ objRecord[key] ??= new optionClass();
1159
+ const target = objRecord[key];
1160
+ for (const source of sources) {
1161
+ target.load(source?.[key]);
1458
1162
  }
1459
1163
  }
1460
1164
 
1461
- class HslAnimation {
1165
+ class AnimationOptions extends OptionLoader {
1166
+ count = 0;
1167
+ decay = 0;
1168
+ delay = 0;
1169
+ enable = false;
1170
+ speed = 1;
1171
+ sync = false;
1172
+ doLoad(data) {
1173
+ loadRangeProperty(this, "count", data.count);
1174
+ loadProperty(this, "enable", data.enable);
1175
+ loadRangeProperty(this, "speed", data.speed);
1176
+ loadRangeProperty(this, "decay", data.decay);
1177
+ loadRangeProperty(this, "delay", data.delay);
1178
+ loadProperty(this, "sync", data.sync);
1179
+ }
1180
+ }
1181
+ class RangedAnimationOptions extends AnimationOptions {
1182
+ mode = exports.AnimationMode.auto;
1183
+ startValue = exports.StartValueType.random;
1184
+ doLoad(data) {
1185
+ super.doLoad(data);
1186
+ loadProperty(this, "mode", data.mode);
1187
+ loadProperty(this, "startValue", data.startValue);
1188
+ }
1189
+ }
1190
+
1191
+ class ColorAnimation extends AnimationOptions {
1192
+ max;
1193
+ min;
1194
+ offset = 0;
1195
+ sync = true;
1196
+ constructor(min, max) {
1197
+ super();
1198
+ this.min = min;
1199
+ this.max = max;
1200
+ }
1201
+ doLoad(data) {
1202
+ super.doLoad(data);
1203
+ loadProperty(this, "max", data.max);
1204
+ loadProperty(this, "min", data.min);
1205
+ loadRangeProperty(this, "offset", data.offset);
1206
+ }
1207
+ }
1208
+
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
- this.limit.load(data.limit);
2098
- if (data.value !== undefined) {
2099
- this.value = data.value;
2100
- }
2101
- }
2102
- }
2103
-
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
- }
1567
+ this.limit.load(data.limit);
1568
+ loadProperty(this, "value", data.value);
1569
+ }
1570
+ }
1571
+
1572
+ class Shape extends OptionLoader {
1573
+ close = true;
1574
+ options = {};
1575
+ type = "circle";
1576
+ doLoad(data) {
2117
1577
  const options = data.options;
2118
1578
  if (options !== undefined) {
2119
1579
  for (const shape in options) {
@@ -2123,76 +1583,47 @@
2123
1583
  }
2124
1584
  }
2125
1585
  }
2126
- if (data.close !== undefined) {
2127
- this.close = data.close;
2128
- }
2129
- if (data.type !== undefined) {
2130
- this.type = data.type;
2131
- }
1586
+ loadProperty(this, "close", data.close);
1587
+ loadProperty(this, "type", data.type);
2132
1588
  }
2133
1589
  }
2134
1590
 
2135
1591
  class ZIndex extends ValueWithRandom {
2136
- opacityRate;
2137
- sizeRate;
2138
- velocityRate;
2139
- constructor() {
2140
- super();
2141
- this.opacityRate = 1;
2142
- this.sizeRate = 1;
2143
- this.velocityRate = 1;
2144
- }
2145
- load(data) {
2146
- super.load(data);
2147
- if (isNull(data)) {
2148
- return;
2149
- }
2150
- if (data.opacityRate !== undefined) {
2151
- this.opacityRate = data.opacityRate;
2152
- }
2153
- if (data.sizeRate !== undefined) {
2154
- this.sizeRate = data.sizeRate;
2155
- }
2156
- if (data.velocityRate !== undefined) {
2157
- this.velocityRate = data.velocityRate;
2158
- }
2159
- }
2160
- }
2161
-
2162
- class ParticlesOptions {
2163
- bounce;
2164
- effect;
2165
- groups;
2166
- move;
2167
- number;
1592
+ opacityRate = 1;
1593
+ sizeRate = 1;
1594
+ velocityRate = 1;
1595
+ doLoad(data) {
1596
+ super.doLoad(data);
1597
+ loadProperty(this, "opacityRate", data.opacityRate);
1598
+ loadProperty(this, "sizeRate", data.sizeRate);
1599
+ loadProperty(this, "velocityRate", data.velocityRate);
1600
+ }
1601
+ }
1602
+
1603
+ class ParticlesOptions extends OptionLoader {
1604
+ bounce = new ParticlesBounce();
1605
+ effect = new Effect();
1606
+ groups = {};
1607
+ move = new Move();
1608
+ number = new ParticlesNumber();
2168
1609
  paint;
2169
1610
  palette;
2170
- reduceDuplicates;
2171
- shape;
2172
- zIndex;
1611
+ reduceDuplicates = false;
1612
+ shape = new Shape();
1613
+ zIndex = new ZIndex();
2173
1614
  #container;
2174
1615
  #pluginManager;
2175
1616
  constructor(pluginManager, container) {
1617
+ super();
2176
1618
  this.#pluginManager = pluginManager;
2177
1619
  this.#container = container;
2178
- this.bounce = new ParticlesBounce();
2179
- this.effect = new Effect();
2180
- this.groups = {};
2181
- this.move = new Move();
2182
- this.number = new ParticlesNumber();
2183
1620
  this.paint = new Paint();
2184
1621
  this.paint.color = new AnimatableColor();
2185
1622
  this.paint.color.value = "#fff";
2186
1623
  this.paint.fill = new Fill();
2187
1624
  this.paint.fill.enable = true;
2188
- this.reduceDuplicates = false;
2189
- this.shape = new Shape();
2190
- this.zIndex = new ZIndex();
2191
1625
  }
2192
- load(data) {
2193
- if (isNull(data)) {
2194
- return;
2195
- }
1626
+ doLoad(data) {
2196
1627
  if (data.palette) {
2197
1628
  this.palette = data.palette;
2198
1629
  this.#importPalette(this.palette);
@@ -2250,7 +1681,7 @@
2250
1681
  }
2251
1682
  }
2252
1683
  }
2253
- #importPalette = (palette) => {
1684
+ #importPalette(palette) {
2254
1685
  const paletteData = this.#pluginManager.getPalette(palette);
2255
1686
  if (!paletteData) {
2256
1687
  return;
@@ -2294,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
- }
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
1826
  }
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$2, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
1985
+ const fixedMin = min ?? defaultRgbMin, fixedMax = rgbMax + identity$1, 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;
@@ -3002,9 +2255,6 @@
3002
2255
  if (isNull(data)) {
3003
2256
  return;
3004
2257
  }
3005
- if (data.background !== undefined) {
3006
- this.background = data.background;
3007
- }
3008
2258
  if (data.colors !== undefined) {
3009
2259
  if (isArray(data.colors)) {
3010
2260
  this.colors = [...data.colors];
@@ -3013,34 +2263,22 @@
3013
2263
  this.colors = data.colors;
3014
2264
  }
3015
2265
  }
3016
- if (data.brightness !== undefined) {
3017
- this.brightness = setRangeValue(data.brightness);
3018
- }
3019
- if (data.gravity !== undefined) {
3020
- this.gravity = setRangeValue(data.gravity);
3021
- }
3022
- if (data.minHeight !== undefined) {
3023
- this.minHeight = setRangeValue(data.minHeight);
3024
- }
3025
- if (data.rate !== undefined) {
3026
- this.rate = setRangeValue(data.rate);
3027
- }
3028
- if (data.saturation !== undefined) {
3029
- this.saturation = setRangeValue(data.saturation);
3030
- }
3031
- if (data.sounds !== undefined) {
3032
- this.sounds = data.sounds;
3033
- }
3034
- if (data.speed !== undefined) {
3035
- this.speed = setRangeValue(data.speed);
3036
- }
3037
- if (data.splitCount !== undefined) {
3038
- this.splitCount = setRangeValue(data.splitCount);
3039
- }
2266
+ loadProperty(this, "background", data.background);
2267
+ loadRangeProperty(this, "brightness", data.brightness);
2268
+ loadRangeProperty(this, "gravity", data.gravity);
2269
+ loadRangeProperty(this, "minHeight", data.minHeight);
2270
+ loadRangeProperty(this, "rate", data.rate);
2271
+ loadRangeProperty(this, "saturation", data.saturation);
2272
+ loadProperty(this, "sounds", data.sounds);
2273
+ loadRangeProperty(this, "speed", data.speed);
2274
+ loadRangeProperty(this, "splitCount", data.splitCount);
3040
2275
  }
3041
2276
  }
3042
2277
 
3043
2278
  const instances = new Map();
2279
+ function deleteFireworksInstance(id) {
2280
+ instances.delete(id);
2281
+ }
3044
2282
  const explodeSoundCheck = (args) => {
3045
2283
  const data = args.data;
3046
2284
  return data?.particle?.options.move.gravity.enable ?? false;
@@ -3216,7 +2454,10 @@
3216
2454
  return existing;
3217
2455
  }
3218
2456
  if (existing) {
3219
- return existing;
2457
+ if (!existing.destroyed) {
2458
+ return existing;
2459
+ }
2460
+ instances.delete(id);
3220
2461
  }
3221
2462
  const create = async () => {
3222
2463
  const options = new FireworkOptions();
@@ -3226,7 +2467,7 @@
3226
2467
  instances.delete(id);
3227
2468
  return;
3228
2469
  }
3229
- const { FireworksInstance } = await Promise.resolve().then(function () { return FireworksInstance$1; }), instance = new FireworksInstance(container);
2470
+ const { FireworksInstance } = await Promise.resolve().then(function () { return FireworksInstance$1; }), instance = new FireworksInstance(container, id);
3230
2471
  instances.set(id, instance);
3231
2472
  return instance;
3232
2473
  }, createPromise = create();
@@ -3235,22 +2476,14 @@
3235
2476
  }
3236
2477
 
3237
2478
  class Blend {
3238
- enable;
3239
- mode;
3240
- constructor() {
3241
- this.mode = "destination-out";
3242
- this.enable = false;
3243
- }
2479
+ enable = false;
2480
+ mode = "destination-out";
3244
2481
  load(data) {
3245
2482
  if (isNull(data)) {
3246
2483
  return;
3247
2484
  }
3248
- if (data.mode !== undefined) {
3249
- this.mode = data.mode;
3250
- }
3251
- if (data.enable !== undefined) {
3252
- this.enable = data.enable;
3253
- }
2485
+ loadProperty(this, "mode", data.mode);
2486
+ loadProperty(this, "enable", data.enable);
3254
2487
  }
3255
2488
  }
3256
2489
 
@@ -3280,7 +2513,7 @@
3280
2513
  }
3281
2514
 
3282
2515
  async function loadBlendPlugin(engine) {
3283
- engine.checkVersion("4.1.2");
2516
+ engine.checkVersion("4.2.0");
3284
2517
  await engine.pluginManager.register(e => {
3285
2518
  e.pluginManager.addPlugin(new BlendPlugin());
3286
2519
  });
@@ -3317,7 +2550,7 @@
3317
2550
  }
3318
2551
 
3319
2552
  async function loadCircleShape(engine) {
3320
- engine.checkVersion("4.1.2");
2553
+ engine.checkVersion("4.2.0");
3321
2554
  await engine.pluginManager.register(e => {
3322
2555
  e.pluginManager.addShape(["circle"], () => {
3323
2556
  return Promise.resolve(new CircleDrawer());
@@ -3365,7 +2598,7 @@
3365
2598
  }
3366
2599
 
3367
2600
  async function loadHexColorPlugin(engine) {
3368
- engine.checkVersion("4.1.2");
2601
+ engine.checkVersion("4.2.0");
3369
2602
  await engine.pluginManager.register(e => {
3370
2603
  e.pluginManager.addColorManager("hex", new HexColorManager());
3371
2604
  });
@@ -3395,96 +2628,208 @@
3395
2628
  if (!("h" in hslColor) || !("s" in hslColor) || !("l" in hslColor)) {
3396
2629
  return;
3397
2630
  }
3398
- return hslToRgb({
3399
- h: getRangeValue(hslColor.h),
3400
- l: getRangeValue(hslColor.l),
3401
- s: getRangeValue(hslColor.s),
3402
- });
2631
+ return hslToRgb({
2632
+ h: getRangeValue(hslColor.h),
2633
+ l: getRangeValue(hslColor.l),
2634
+ s: getRangeValue(hslColor.s),
2635
+ });
2636
+ }
2637
+ parseString(input) {
2638
+ if (!this.accepts(input)) {
2639
+ return;
2640
+ }
2641
+ const result = hslRegex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
2642
+ return result
2643
+ ? hslaToRgba({
2644
+ a: result.length > minLength ? parseAlpha(result[HslIndexes.a]) : defaultAlpha,
2645
+ h: Number.parseInt(result[HslIndexes.h] ?? "0", radix),
2646
+ l: Number.parseInt(result[HslIndexes.l] ?? "0", radix),
2647
+ s: Number.parseInt(result[HslIndexes.s] ?? "0", radix),
2648
+ })
2649
+ : undefined;
2650
+ }
2651
+ }
2652
+
2653
+ async function loadHslColorPlugin(engine) {
2654
+ engine.checkVersion("4.2.0");
2655
+ await engine.pluginManager.register(e => {
2656
+ e.pluginManager.addColorManager("hsl", new HslColorManager());
2657
+ });
2658
+ }
2659
+
2660
+ class MovePlugin {
2661
+ id = "move";
2662
+ #pluginManager;
2663
+ constructor(pluginManager) {
2664
+ this.#pluginManager = pluginManager;
2665
+ }
2666
+ async getPlugin(container) {
2667
+ const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
2668
+ return new MovePluginInstance(this.#pluginManager, container);
2669
+ }
2670
+ loadOptions() {
2671
+ }
2672
+ needsPlugin() {
2673
+ return true;
2674
+ }
2675
+ }
2676
+
2677
+ async function loadMovePlugin(engine) {
2678
+ engine.checkVersion("4.2.0");
2679
+ await engine.pluginManager.register(e => {
2680
+ const moveEngine = e, movePluginManager = moveEngine.pluginManager;
2681
+ movePluginManager.initializers.pathGenerators ??= new Map();
2682
+ movePluginManager.pathGenerators ??= new Map();
2683
+ movePluginManager.addPathGenerator = (name, generator) => {
2684
+ movePluginManager.initializers.pathGenerators ??= new Map();
2685
+ movePluginManager.initializers.pathGenerators.set(name, generator);
2686
+ };
2687
+ movePluginManager.getPathGenerators = async (container, force = false) => {
2688
+ movePluginManager.initializers.pathGenerators ??= new Map();
2689
+ movePluginManager.pathGenerators ??= new Map();
2690
+ return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
2691
+ };
2692
+ e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
2693
+ });
2694
+ }
2695
+
2696
+ function checkDestroy(particle, destroyType, value, minValue, maxValue) {
2697
+ switch (destroyType) {
2698
+ case exports.DestroyType.max:
2699
+ if (value >= maxValue) {
2700
+ particle.destroy();
2701
+ }
2702
+ break;
2703
+ case exports.DestroyType.min:
2704
+ if (value <= minValue) {
2705
+ particle.destroy();
2706
+ }
2707
+ break;
2708
+ }
2709
+ }
2710
+ function initParticleNumericAnimationValue(options, pxRatio) {
2711
+ const valueRange = options.value, animationOptions = options.animation, res = {
2712
+ delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
2713
+ enable: animationOptions.enable,
2714
+ value: getRangeValue(options.value) * pxRatio,
2715
+ max: getRangeMax(valueRange) * pxRatio,
2716
+ min: getRangeMin(valueRange) * pxRatio,
2717
+ loops: 0,
2718
+ maxLoops: getRangeValue(animationOptions.count),
2719
+ time: 0,
2720
+ }, decayOffset = 1;
2721
+ if (animationOptions.enable) {
2722
+ res.decay = decayOffset - getRangeValue(animationOptions.decay);
2723
+ switch (animationOptions.mode) {
2724
+ case exports.AnimationMode.increase:
2725
+ res.status = exports.AnimationStatus.increasing;
2726
+ break;
2727
+ case exports.AnimationMode.decrease:
2728
+ res.status = exports.AnimationStatus.decreasing;
2729
+ break;
2730
+ case exports.AnimationMode.random:
2731
+ res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
2732
+ break;
2733
+ }
2734
+ const autoStatus = animationOptions.mode === exports.AnimationMode.auto;
2735
+ switch (animationOptions.startValue) {
2736
+ case exports.StartValueType.min:
2737
+ res.value = res.min;
2738
+ if (autoStatus) {
2739
+ res.status = exports.AnimationStatus.increasing;
2740
+ }
2741
+ break;
2742
+ case exports.StartValueType.max:
2743
+ res.value = res.max;
2744
+ if (autoStatus) {
2745
+ res.status = exports.AnimationStatus.decreasing;
2746
+ }
2747
+ break;
2748
+ case exports.StartValueType.random:
2749
+ default:
2750
+ res.value = randomInRangeValue(res);
2751
+ if (autoStatus) {
2752
+ res.status = getRandom() >= half ? exports.AnimationStatus.increasing : exports.AnimationStatus.decreasing;
2753
+ }
2754
+ break;
2755
+ }
3403
2756
  }
3404
- parseString(input) {
3405
- if (!this.accepts(input)) {
2757
+ res.initialValue = res.value;
2758
+ return res;
2759
+ }
2760
+ function updateAnimation(particle, data, changeDirection, destroyType, delta) {
2761
+ const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
2762
+ if (particle.destroyed ||
2763
+ !data.enable ||
2764
+ ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
2765
+ return;
2766
+ }
2767
+ const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
2768
+ data.time ??= 0;
2769
+ const delayTime = data.delayTime ?? minDelay;
2770
+ if (delayTime > minDelay && data.time < delayTime) {
2771
+ data.time += delta.value;
2772
+ if (data.time < delayTime) {
3406
2773
  return;
3407
2774
  }
3408
- const result = hslRegex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
3409
- return result
3410
- ? hslaToRgba({
3411
- a: result.length > minLength ? parseAlpha(result[HslIndexes.a]) : defaultAlpha,
3412
- h: Number.parseInt(result[HslIndexes.h] ?? "0", radix),
3413
- l: Number.parseInt(result[HslIndexes.l] ?? "0", radix),
3414
- s: Number.parseInt(result[HslIndexes.s] ?? "0", radix),
3415
- })
3416
- : undefined;
3417
2775
  }
3418
- }
3419
-
3420
- async function loadHslColorPlugin(engine) {
3421
- engine.checkVersion("4.1.2");
3422
- await engine.pluginManager.register(e => {
3423
- e.pluginManager.addColorManager("hsl", new HslColorManager());
3424
- });
3425
- }
3426
-
3427
- class MovePlugin {
3428
- id = "move";
3429
- #pluginManager;
3430
- constructor(pluginManager) {
3431
- this.#pluginManager = pluginManager;
2776
+ switch (data.status) {
2777
+ case exports.AnimationStatus.increasing:
2778
+ data.value += velocity;
2779
+ break;
2780
+ case exports.AnimationStatus.decreasing:
2781
+ data.value -= velocity;
2782
+ break;
3432
2783
  }
3433
- async getPlugin(container) {
3434
- const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
3435
- return new MovePluginInstance(this.#pluginManager, container);
2784
+ if (data.velocity && decay !== identity) {
2785
+ data.velocity *= decay;
3436
2786
  }
3437
- loadOptions() {
2787
+ switch (data.status) {
2788
+ case exports.AnimationStatus.increasing:
2789
+ if (data.value >= maxValue) {
2790
+ if (changeDirection) {
2791
+ data.status = exports.AnimationStatus.decreasing;
2792
+ }
2793
+ else {
2794
+ data.value -= maxValue;
2795
+ }
2796
+ data.loops ??= minLoops;
2797
+ data.loops++;
2798
+ }
2799
+ break;
2800
+ case exports.AnimationStatus.decreasing:
2801
+ if (data.value <= minValue) {
2802
+ if (changeDirection) {
2803
+ data.status = exports.AnimationStatus.increasing;
2804
+ }
2805
+ else {
2806
+ data.value += maxValue;
2807
+ }
2808
+ data.loops ??= minLoops;
2809
+ data.loops++;
2810
+ }
2811
+ break;
3438
2812
  }
3439
- needsPlugin() {
3440
- return true;
2813
+ checkDestroy(particle, destroyType, data.value, minValue, maxValue);
2814
+ if (!particle.destroyed) {
2815
+ data.value = clamp(data.value, minValue, maxValue);
3441
2816
  }
3442
2817
  }
3443
2818
 
3444
- async function loadMovePlugin(engine) {
3445
- engine.checkVersion("4.1.2");
3446
- await engine.pluginManager.register(e => {
3447
- const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3448
- movePluginManager.initializers.pathGenerators ??= new Map();
3449
- movePluginManager.pathGenerators ??= new Map();
3450
- movePluginManager.addPathGenerator = (name, generator) => {
3451
- movePluginManager.initializers.pathGenerators ??= new Map();
3452
- movePluginManager.initializers.pathGenerators.set(name, generator);
3453
- };
3454
- movePluginManager.getPathGenerators = async (container, force = false) => {
3455
- movePluginManager.initializers.pathGenerators ??= new Map();
3456
- movePluginManager.pathGenerators ??= new Map();
3457
- return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
3458
- };
3459
- e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
3460
- });
3461
- }
3462
-
3463
2819
  class OpacityAnimation extends RangedAnimationOptions {
3464
- destroy;
3465
- constructor() {
3466
- super();
3467
- this.destroy = exports.DestroyType.none;
3468
- this.speed = 2;
3469
- }
2820
+ destroy = exports.DestroyType.none;
3470
2821
  load(data) {
3471
2822
  super.load(data);
3472
2823
  if (isNull(data)) {
3473
2824
  return;
3474
2825
  }
3475
- if (data.destroy !== undefined) {
3476
- this.destroy = data.destroy;
3477
- }
2826
+ loadProperty(this, "destroy", data.destroy);
3478
2827
  }
3479
2828
  }
3480
2829
 
3481
2830
  class Opacity extends RangedAnimationValueWithRandom {
3482
- animation;
3483
- constructor() {
3484
- super();
3485
- this.animation = new OpacityAnimation();
3486
- this.value = 1;
3487
- }
2831
+ animation = new OpacityAnimation();
2832
+ value = 1;
3488
2833
  load(data) {
3489
2834
  if (isNull(data)) {
3490
2835
  return;
@@ -3528,10 +2873,7 @@
3528
2873
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3529
2874
  }
3530
2875
  loadOptions(options, ...sources) {
3531
- options.opacity ??= new Opacity();
3532
- for (const source of sources) {
3533
- options.opacity.load(source?.opacity);
3534
- }
2876
+ loadOptionProperty(options, "opacity", Opacity, ...sources);
3535
2877
  }
3536
2878
  reset(particle) {
3537
2879
  if (!particle.opacity) {
@@ -3549,7 +2891,7 @@
3549
2891
  }
3550
2892
 
3551
2893
  async function loadOpacityUpdater(engine) {
3552
- engine.checkVersion("4.1.2");
2894
+ engine.checkVersion("4.2.0");
3553
2895
  await engine.pluginManager.register(e => {
3554
2896
  e.pluginManager.addParticleUpdater("opacity", container => {
3555
2897
  return Promise.resolve(new OpacityUpdater(container));
@@ -3557,7 +2899,7 @@
3557
2899
  });
3558
2900
  }
3559
2901
 
3560
- const minVelocity$4 = 0, boundsMin = 0;
2902
+ const boundsMin = 0;
3561
2903
  function bounceHorizontal(data) {
3562
2904
  if ((data.outMode !== exports.OutMode.bounce && data.outMode !== exports.OutMode.split) ||
3563
2905
  (data.direction !== exports.OutModeDirection.left && data.direction !== exports.OutModeDirection.right)) {
@@ -3572,8 +2914,8 @@
3572
2914
  const velocity = data.particle.velocity.x;
3573
2915
  let bounced = false;
3574
2916
  if (data.outOfCanvas &&
3575
- ((data.direction === exports.OutModeDirection.right && velocity > minVelocity$4) ||
3576
- (data.direction === exports.OutModeDirection.left && velocity < minVelocity$4))) {
2917
+ ((data.direction === exports.OutModeDirection.right && velocity > minVelocity) ||
2918
+ (data.direction === exports.OutModeDirection.left && velocity < minVelocity))) {
3577
2919
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3578
2920
  data.particle.velocity.x *= -newVelocity;
3579
2921
  bounced = true;
@@ -3606,8 +2948,8 @@
3606
2948
  const velocity = data.particle.velocity.y;
3607
2949
  let bounced = false;
3608
2950
  if (data.outOfCanvas &&
3609
- ((data.direction === exports.OutModeDirection.bottom && velocity > minVelocity$4) ||
3610
- (data.direction === exports.OutModeDirection.top && velocity < minVelocity$4))) {
2951
+ ((data.direction === exports.OutModeDirection.bottom && velocity > minVelocity) ||
2952
+ (data.direction === exports.OutModeDirection.top && velocity < minVelocity))) {
3611
2953
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3612
2954
  data.particle.velocity.y *= -newVelocity;
3613
2955
  bounced = true;
@@ -3660,7 +3002,6 @@
3660
3002
  }
3661
3003
  }
3662
3004
 
3663
- const minVelocity$3 = 0;
3664
3005
  class DestroyOutMode {
3665
3006
  modes;
3666
3007
  constructor(_container) {
@@ -3679,10 +3020,10 @@
3679
3020
  break;
3680
3021
  case exports.ParticleOutType.inside: {
3681
3022
  const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
3682
- if ((vx < minVelocity$3 && dx > particle.moveCenter.radius) ||
3683
- (vy < minVelocity$3 && dy > particle.moveCenter.radius) ||
3684
- (vx >= minVelocity$3 && dx < -particle.moveCenter.radius) ||
3685
- (vy >= minVelocity$3 && dy < -particle.moveCenter.radius)) {
3023
+ if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
3024
+ (vy < minVelocity && dy > particle.moveCenter.radius) ||
3025
+ (vx >= minVelocity && dx < -particle.moveCenter.radius) ||
3026
+ (vy >= minVelocity && dy < -particle.moveCenter.radius)) {
3686
3027
  return;
3687
3028
  }
3688
3029
  break;
@@ -3692,7 +3033,6 @@
3692
3033
  }
3693
3034
  }
3694
3035
 
3695
- const minVelocity$2 = 0;
3696
3036
  class NoneOutMode {
3697
3037
  modes;
3698
3038
  #container;
@@ -3712,10 +3052,10 @@
3712
3052
  }
3713
3053
  const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3714
3054
  if (!gravityOptions.enable) {
3715
- if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3716
- (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
3717
- (particle.velocity.x > minVelocity$2 && particle.position.x <= canvasSize.width + pRadius) ||
3718
- (particle.velocity.x < minVelocity$2 && particle.position.x >= -pRadius)) {
3055
+ if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
3056
+ (particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
3057
+ (particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
3058
+ (particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
3719
3059
  return;
3720
3060
  }
3721
3061
  if (!isPointInside(particle.position, container.canvas.size, originPoint, pRadius, direction)) {
@@ -3734,7 +3074,7 @@
3734
3074
  }
3735
3075
  }
3736
3076
 
3737
- const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
3077
+ const updateVector = Vector.origin;
3738
3078
  class OutOutMode {
3739
3079
  modes;
3740
3080
  #container;
@@ -3755,10 +3095,10 @@
3755
3095
  updateVector.angle = particle.velocity.angle + Math.PI;
3756
3096
  updateVector.addTo(particle.moveCenter);
3757
3097
  const { dx, dy } = getDistances(particle.position, updateVector);
3758
- if ((vx <= minVelocity$1 && dx >= minDistance) ||
3759
- (vy <= minVelocity$1 && dy >= minDistance) ||
3760
- (vx >= minVelocity$1 && dx <= minDistance) ||
3761
- (vy >= minVelocity$1 && dy <= minDistance)) {
3098
+ if ((vx <= minVelocity && dx >= minDistance) ||
3099
+ (vy <= minVelocity && dy >= minDistance) ||
3100
+ (vx >= minVelocity && dx <= minDistance) ||
3101
+ (vy >= minVelocity && dy <= minDistance)) {
3762
3102
  return;
3763
3103
  }
3764
3104
  particle.position.x = Math.floor(randomInRangeValue({
@@ -3882,21 +3222,21 @@
3882
3222
  this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, exports.OutModeDirection.right);
3883
3223
  this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, exports.OutModeDirection.top);
3884
3224
  }
3885
- #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3225
+ #addUpdaterIfMissing(particle, outMode, getUpdater) {
3886
3226
  const outModes = particle.options.move.outModes;
3887
3227
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3888
3228
  this.updaters.set(outMode, getUpdater(this.#container));
3889
3229
  }
3890
- };
3891
- #updateOutMode = (particle, delta, outMode, direction) => {
3230
+ }
3231
+ #updateOutMode(particle, delta, outMode, direction) {
3892
3232
  for (const updater of this.updaters.values()) {
3893
3233
  updater.update(particle, direction, delta, outMode);
3894
3234
  }
3895
- };
3235
+ }
3896
3236
  }
3897
3237
 
3898
3238
  async function loadOutModesUpdater(engine) {
3899
- engine.checkVersion("4.1.2");
3239
+ engine.checkVersion("4.2.0");
3900
3240
  await engine.pluginManager.register(e => {
3901
3241
  e.pluginManager.addParticleUpdater("outModes", container => {
3902
3242
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3967,7 +3307,7 @@
3967
3307
  }
3968
3308
 
3969
3309
  async function loadPaintUpdater(engine) {
3970
- engine.checkVersion("4.1.2");
3310
+ engine.checkVersion("4.2.0");
3971
3311
  await engine.pluginManager.register(e => {
3972
3312
  e.pluginManager.addParticleUpdater("paint", container => {
3973
3313
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -4022,37 +3362,26 @@
4022
3362
  }
4023
3363
 
4024
3364
  async function loadRgbColorPlugin(engine) {
4025
- engine.checkVersion("4.1.2");
3365
+ engine.checkVersion("4.2.0");
4026
3366
  await engine.pluginManager.register(e => {
4027
3367
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
4028
3368
  });
4029
3369
  }
4030
3370
 
4031
3371
  class SizeAnimation extends RangedAnimationOptions {
4032
- destroy;
4033
- constructor() {
4034
- super();
4035
- this.destroy = exports.DestroyType.none;
4036
- this.speed = 5;
4037
- }
3372
+ destroy = exports.DestroyType.none;
4038
3373
  load(data) {
4039
3374
  super.load(data);
4040
3375
  if (isNull(data)) {
4041
3376
  return;
4042
3377
  }
4043
- if (data.destroy !== undefined) {
4044
- this.destroy = data.destroy;
4045
- }
3378
+ loadProperty(this, "destroy", data.destroy);
4046
3379
  }
4047
3380
  }
4048
3381
 
4049
3382
  class Size extends RangedAnimationValueWithRandom {
4050
- animation;
4051
- constructor() {
4052
- super();
4053
- this.animation = new SizeAnimation();
4054
- this.value = 3;
4055
- }
3383
+ animation = new SizeAnimation();
3384
+ value = 3;
4056
3385
  load(data) {
4057
3386
  super.load(data);
4058
3387
  if (isNull(data)) {
@@ -4095,10 +3424,7 @@
4095
3424
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
4096
3425
  }
4097
3426
  loadOptions(options, ...sources) {
4098
- options.size ??= new Size();
4099
- for (const source of sources) {
4100
- options.size.load(source?.size);
4101
- }
3427
+ loadOptionProperty(options, "size", Size, ...sources);
4102
3428
  }
4103
3429
  preInit(particle) {
4104
3430
  const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
@@ -4121,7 +3447,7 @@
4121
3447
  }
4122
3448
 
4123
3449
  async function loadSizeUpdater(engine) {
4124
- engine.checkVersion("4.1.2");
3450
+ engine.checkVersion("4.2.0");
4125
3451
  await engine.pluginManager.register(e => {
4126
3452
  e.pluginManager.addParticleUpdater("size", container => {
4127
3453
  return Promise.resolve(new SizeUpdater(container));
@@ -4130,7 +3456,7 @@
4130
3456
  }
4131
3457
 
4132
3458
  async function loadBasic(engine) {
4133
- engine.checkVersion("4.1.2");
3459
+ engine.checkVersion("4.2.0");
4134
3460
  await engine.pluginManager.register(async (e) => {
4135
3461
  await Promise.all([
4136
3462
  loadBlendPlugin(e),
@@ -4156,18 +3482,10 @@
4156
3482
  if (isNull(data)) {
4157
3483
  return;
4158
3484
  }
4159
- if (data.bottom !== undefined) {
4160
- this.bottom = setRangeValue(data.bottom);
4161
- }
4162
- if (data.left !== undefined) {
4163
- this.left = setRangeValue(data.left);
4164
- }
4165
- if (data.right !== undefined) {
4166
- this.right = setRangeValue(data.right);
4167
- }
4168
- if (data.top !== undefined) {
4169
- this.top = setRangeValue(data.top);
4170
- }
3485
+ loadRangeProperty(this, "bottom", data.bottom);
3486
+ loadRangeProperty(this, "left", data.left);
3487
+ loadRangeProperty(this, "right", data.right);
3488
+ loadRangeProperty(this, "top", data.top);
4171
3489
  }
4172
3490
  }
4173
3491
 
@@ -4179,55 +3497,35 @@
4179
3497
  })(DestroyMode || (DestroyMode = {}));
4180
3498
 
4181
3499
  class Explode {
4182
- maxSizeFactor;
4183
- speed;
4184
- constructor() {
4185
- this.maxSizeFactor = 3;
4186
- this.speed = 2;
4187
- }
3500
+ maxSizeFactor = 3;
3501
+ speed = 2;
4188
3502
  load(data) {
4189
3503
  if (isNull(data)) {
4190
3504
  return;
4191
3505
  }
4192
- if (data.maxSizeFactor !== undefined) {
4193
- this.maxSizeFactor = data.maxSizeFactor;
4194
- }
4195
- if (data.speed !== undefined) {
4196
- this.speed = data.speed;
4197
- }
3506
+ loadProperty(this, "maxSizeFactor", data.maxSizeFactor);
3507
+ loadProperty(this, "speed", data.speed);
4198
3508
  }
4199
3509
  }
4200
3510
 
4201
3511
  class SplitFactor extends ValueWithRandom {
4202
- constructor() {
4203
- super();
4204
- this.value = 3;
4205
- }
3512
+ value = 3;
4206
3513
  }
4207
3514
 
4208
3515
  class SplitRate extends ValueWithRandom {
4209
- constructor() {
4210
- super();
4211
- this.value = { min: 4, max: 9 };
4212
- }
3516
+ value = { min: 4, max: 9 };
4213
3517
  }
4214
3518
 
4215
3519
  class Split {
4216
- count;
4217
- factor;
3520
+ count = 1;
3521
+ factor = new SplitFactor();
4218
3522
  fillColor;
4219
3523
  fillColorOffset;
4220
3524
  particles;
4221
- rate;
4222
- sizeOffset;
3525
+ rate = new SplitRate();
3526
+ sizeOffset = true;
4223
3527
  strokeColor;
4224
3528
  strokeColorOffset;
4225
- constructor() {
4226
- this.count = 1;
4227
- this.factor = new SplitFactor();
4228
- this.rate = new SplitRate();
4229
- this.sizeOffset = true;
4230
- }
4231
3529
  load(data) {
4232
3530
  if (isNull(data)) {
4233
3531
  return;
@@ -4238,17 +3536,13 @@
4238
3536
  if (data.strokeColor !== undefined) {
4239
3537
  this.strokeColor = OptionsColor.create(this.strokeColor, data.strokeColor);
4240
3538
  }
4241
- if (data.count !== undefined) {
4242
- this.count = data.count;
4243
- }
3539
+ loadProperty(this, "count", data.count);
4244
3540
  this.factor.load(data.factor);
4245
3541
  this.rate.load(data.rate);
4246
3542
  this.particles = executeOnSingleOrMultiple(data.particles, particles => {
4247
3543
  return deepExtend({}, particles);
4248
3544
  });
4249
- if (data.sizeOffset !== undefined) {
4250
- this.sizeOffset = data.sizeOffset;
4251
- }
3545
+ loadProperty(this, "sizeOffset", data.sizeOffset);
4252
3546
  if (data.fillColorOffset) {
4253
3547
  this.fillColorOffset = this.fillColorOffset ?? {};
4254
3548
  if (data.fillColorOffset.h !== undefined) {
@@ -4277,16 +3571,10 @@
4277
3571
  }
4278
3572
 
4279
3573
  class Destroy {
4280
- bounds;
4281
- explode;
4282
- mode;
4283
- split;
4284
- constructor() {
4285
- this.bounds = new DestroyBounds();
4286
- this.explode = new Explode();
4287
- this.mode = DestroyMode.none;
4288
- this.split = new Split();
4289
- }
3574
+ bounds = new DestroyBounds();
3575
+ explode = new Explode();
3576
+ mode = DestroyMode.none;
3577
+ split = new Split();
4290
3578
  load(data) {
4291
3579
  if (isNull(data)) {
4292
3580
  return;
@@ -4347,7 +3635,7 @@
4347
3635
  mode: exports.PixelMode.precise,
4348
3636
  },
4349
3637
  });
4350
- const factor = identity$2 / getRangeValue(splitOptions.factor.value), sizeOptions = splitParticleOptions["size"];
3638
+ const factor = identity$1 / getRangeValue(splitOptions.factor.value), sizeOptions = splitParticleOptions["size"];
4351
3639
  if (sizeOptions) {
4352
3640
  if (isNumber(sizeOptions.value)) {
4353
3641
  sizeOptions.value *= factor;
@@ -4434,10 +3722,7 @@
4434
3722
  return !destroyParticle.destroyed || !!destroyParticle.exploding;
4435
3723
  }
4436
3724
  loadOptions(options, ...sources) {
4437
- options.destroy ??= new Destroy();
4438
- for (const source of sources) {
4439
- options.destroy.load(source?.destroy);
4440
- }
3725
+ loadOptionProperty(options, "destroy", Destroy, ...sources);
4441
3726
  }
4442
3727
  particleDestroyed(particle, override) {
4443
3728
  if (override) {
@@ -4502,7 +3787,7 @@
4502
3787
  }
4503
3788
 
4504
3789
  async function loadDestroyUpdater(engine) {
4505
- engine.checkVersion("4.1.2");
3790
+ engine.checkVersion("4.2.0");
4506
3791
  await engine.pluginManager.register(e => {
4507
3792
  e.pluginManager.addParticleUpdater("destroy", container => {
4508
3793
  return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
@@ -4514,78 +3799,46 @@
4514
3799
  count;
4515
3800
  delay;
4516
3801
  duration;
4517
- wait;
4518
- constructor() {
4519
- this.wait = false;
4520
- }
3802
+ wait = false;
4521
3803
  load(data) {
4522
3804
  if (isNull(data)) {
4523
3805
  return;
4524
3806
  }
4525
- if (data.count !== undefined) {
4526
- this.count = data.count;
4527
- }
4528
- if (data.delay !== undefined) {
4529
- this.delay = setRangeValue(data.delay);
4530
- }
4531
- if (data.duration !== undefined) {
4532
- this.duration = setRangeValue(data.duration);
4533
- }
4534
- if (data.wait !== undefined) {
4535
- this.wait = data.wait;
4536
- }
3807
+ loadProperty(this, "count", data.count);
3808
+ loadRangeProperty(this, "delay", data.delay);
3809
+ loadRangeProperty(this, "duration", data.duration);
3810
+ loadProperty(this, "wait", data.wait);
4537
3811
  }
4538
3812
  }
4539
3813
 
4540
3814
  class EmitterRate {
4541
- delay;
4542
- quantity;
4543
- constructor() {
4544
- this.quantity = 1;
4545
- this.delay = 0.1;
4546
- }
3815
+ delay = 0.1;
3816
+ quantity = 1;
4547
3817
  load(data) {
4548
3818
  if (isNull(data)) {
4549
3819
  return;
4550
3820
  }
4551
- if (data.quantity !== undefined) {
4552
- this.quantity = setRangeValue(data.quantity);
4553
- }
4554
- if (data.delay !== undefined) {
4555
- this.delay = setRangeValue(data.delay);
4556
- }
3821
+ loadRangeProperty(this, "quantity", data.quantity);
3822
+ loadRangeProperty(this, "delay", data.delay);
4557
3823
  }
4558
3824
  }
4559
3825
 
4560
3826
  class EmitterShapeReplace {
4561
- color;
4562
- opacity;
4563
- constructor() {
4564
- this.color = false;
4565
- this.opacity = false;
4566
- }
3827
+ color = false;
3828
+ opacity = false;
4567
3829
  load(data) {
4568
3830
  if (isNull(data)) {
4569
3831
  return;
4570
3832
  }
4571
- if (data.color !== undefined) {
4572
- this.color = data.color;
4573
- }
4574
- if (data.opacity !== undefined) {
4575
- this.opacity = data.opacity;
4576
- }
3833
+ loadProperty(this, "color", data.color);
3834
+ loadProperty(this, "opacity", data.opacity);
4577
3835
  }
4578
3836
  }
4579
3837
 
4580
3838
  class EmitterShape {
4581
- options;
4582
- replace;
4583
- type;
4584
- constructor() {
4585
- this.options = {};
4586
- this.replace = new EmitterShapeReplace();
4587
- this.type = "square";
4588
- }
3839
+ options = {};
3840
+ replace = new EmitterShapeReplace();
3841
+ type = "square";
4589
3842
  load(data) {
4590
3843
  if (isNull(data)) {
4591
3844
  return;
@@ -4594,34 +3847,21 @@
4594
3847
  this.options = deepExtend({}, data.options ?? {});
4595
3848
  }
4596
3849
  this.replace.load(data.replace);
4597
- if (data.type !== undefined) {
4598
- this.type = data.type;
4599
- }
3850
+ loadProperty(this, "type", data.type);
4600
3851
  }
4601
3852
  }
4602
3853
 
4603
3854
  class EmitterSize {
4604
- height;
4605
- mode;
4606
- width;
4607
- constructor() {
4608
- this.mode = exports.PixelMode.percent;
4609
- this.height = 0;
4610
- this.width = 0;
4611
- }
3855
+ height = 0;
3856
+ mode = exports.PixelMode.percent;
3857
+ width = 0;
4612
3858
  load(data) {
4613
3859
  if (isNull(data)) {
4614
3860
  return;
4615
3861
  }
4616
- if (data.mode !== undefined) {
4617
- this.mode = data.mode;
4618
- }
4619
- if (data.height !== undefined) {
4620
- this.height = data.height;
4621
- }
4622
- if (data.width !== undefined) {
4623
- this.width = data.width;
4624
- }
3862
+ loadProperty(this, "mode", data.mode);
3863
+ loadProperty(this, "height", data.height);
3864
+ loadProperty(this, "width", data.width);
4625
3865
  }
4626
3866
  }
4627
3867
 
@@ -4644,50 +3884,35 @@
4644
3884
  }
4645
3885
 
4646
3886
  class Emitter {
4647
- autoPlay;
3887
+ autoPlay = true;
4648
3888
  direction;
4649
3889
  domId;
4650
- fill;
4651
- life;
3890
+ fill = true;
3891
+ life = new EmitterLife();
4652
3892
  name;
4653
3893
  particles;
4654
3894
  position;
4655
- rate;
4656
- shape;
3895
+ rate = new EmitterRate();
3896
+ shape = new EmitterShape();
4657
3897
  size;
4658
- spawn;
3898
+ spawn = new EmitterSpawn();
4659
3899
  spawnFillColor;
4660
3900
  spawnStrokeColor;
4661
- startCount;
4662
- constructor() {
4663
- this.autoPlay = true;
4664
- this.fill = true;
4665
- this.life = new EmitterLife();
4666
- this.rate = new EmitterRate();
4667
- this.shape = new EmitterShape();
4668
- this.spawn = new EmitterSpawn();
4669
- this.startCount = 0;
4670
- }
3901
+ startCount = 0;
4671
3902
  load(data) {
4672
3903
  if (isNull(data)) {
4673
3904
  return;
4674
3905
  }
4675
- if (data.autoPlay !== undefined) {
4676
- this.autoPlay = data.autoPlay;
4677
- }
3906
+ loadProperty(this, "autoPlay", data.autoPlay);
4678
3907
  if (data.size !== undefined) {
4679
3908
  this.size ??= new EmitterSize();
4680
3909
  this.size.load(data.size);
4681
3910
  }
4682
- if (data.direction !== undefined) {
4683
- this.direction = data.direction;
4684
- }
4685
- this.domId = data.domId;
4686
- if (data.fill !== undefined) {
4687
- this.fill = data.fill;
4688
- }
3911
+ loadProperty(this, "direction", data.direction);
3912
+ loadProperty(this, "domId", data.domId);
3913
+ loadProperty(this, "fill", data.fill);
4689
3914
  this.life.load(data.life);
4690
- this.name = data.name;
3915
+ loadProperty(this, "name", data.name);
4691
3916
  this.particles = executeOnSingleOrMultiple(data.particles, particles => {
4692
3917
  return deepExtend({}, particles);
4693
3918
  });
@@ -4711,9 +3936,7 @@
4711
3936
  this.spawnStrokeColor ??= new AnimatableColor();
4712
3937
  this.spawnStrokeColor.load(data.spawnStrokeColor);
4713
3938
  }
4714
- if (data.startCount !== undefined) {
4715
- this.startCount = data.startCount;
4716
- }
3939
+ loadProperty(this, "startCount", data.startCount);
4717
3940
  }
4718
3941
  }
4719
3942
 
@@ -4795,7 +4018,7 @@
4795
4018
  })(EmitterClickMode || (EmitterClickMode = {}));
4796
4019
 
4797
4020
  async function loadEmittersPluginSimple(engine) {
4798
- engine.checkVersion("4.1.2");
4021
+ engine.checkVersion("4.2.0");
4799
4022
  await engine.pluginManager.register(async (e) => {
4800
4023
  const instancesManager = await getEmittersInstancesManager(e);
4801
4024
  await addEmittersShapesManager(e);
@@ -4883,7 +4106,7 @@
4883
4106
  }
4884
4107
 
4885
4108
  async function loadEmittersShapeSquare(engine) {
4886
- engine.checkVersion("4.1.2");
4109
+ engine.checkVersion("4.2.0");
4887
4110
  await engine.pluginManager.register((e) => {
4888
4111
  ensureEmittersPluginLoaded(e);
4889
4112
  e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
@@ -4891,55 +4114,36 @@
4891
4114
  }
4892
4115
 
4893
4116
  class LifeDelay extends ValueWithRandom {
4894
- sync;
4895
- constructor() {
4896
- super();
4897
- this.sync = false;
4898
- }
4117
+ sync = false;
4899
4118
  load(data) {
4900
4119
  if (isNull(data)) {
4901
4120
  return;
4902
4121
  }
4903
4122
  super.load(data);
4904
- if (data.sync !== undefined) {
4905
- this.sync = data.sync;
4906
- }
4123
+ loadProperty(this, "sync", data.sync);
4907
4124
  }
4908
4125
  }
4909
4126
 
4910
4127
  class LifeDuration extends ValueWithRandom {
4911
- sync;
4912
- constructor() {
4913
- super();
4914
- this.sync = false;
4915
- }
4128
+ sync = false;
4916
4129
  load(data) {
4917
4130
  if (isNull(data)) {
4918
4131
  return;
4919
4132
  }
4920
4133
  super.load(data);
4921
- if (data.sync !== undefined) {
4922
- this.sync = data.sync;
4923
- }
4134
+ loadProperty(this, "sync", data.sync);
4924
4135
  }
4925
4136
  }
4926
4137
 
4927
4138
  class Life {
4928
- count;
4929
- delay;
4930
- duration;
4931
- constructor() {
4932
- this.count = 0;
4933
- this.delay = new LifeDelay();
4934
- this.duration = new LifeDuration();
4935
- }
4139
+ count = 0;
4140
+ delay = new LifeDelay();
4141
+ duration = new LifeDuration();
4936
4142
  load(data) {
4937
4143
  if (isNull(data)) {
4938
4144
  return;
4939
4145
  }
4940
- if (data.count !== undefined) {
4941
- this.count = data.count;
4942
- }
4146
+ loadProperty(this, "count", data.count);
4943
4147
  this.delay.load(data.delay);
4944
4148
  this.duration.load(data.duration);
4945
4149
  }
@@ -4998,7 +4202,7 @@
4998
4202
  }
4999
4203
  }
5000
4204
 
5001
- const noTime = 0, identity$1 = 1, infiniteValue = -1;
4205
+ const noTime = 0, identity = 1, infiniteValue = -1;
5002
4206
  class LifeUpdater {
5003
4207
  #container;
5004
4208
  constructor(container) {
@@ -5009,7 +4213,7 @@
5009
4213
  if (!lifeOptions) {
5010
4214
  return;
5011
4215
  }
5012
- const delayFactor = lifeOptions.delay.sync ? identity$1 : getRandom(), durationFactor = lifeOptions.duration.sync ? identity$1 : getRandom();
4216
+ const delayFactor = lifeOptions.delay.sync ? identity : getRandom(), durationFactor = lifeOptions.duration.sync ? identity : getRandom();
5013
4217
  particle.life = {
5014
4218
  delay: container.retina.reduceFactor
5015
4219
  ? ((getRangeValue(lifeOptions.delay.value) * delayFactor) / container.retina.reduceFactor) *
@@ -5035,10 +4239,7 @@
5035
4239
  return !particle.destroyed;
5036
4240
  }
5037
4241
  loadOptions(options, ...sources) {
5038
- options.life ??= new Life();
5039
- for (const source of sources) {
5040
- options.life.load(source?.life);
5041
- }
4242
+ loadOptionProperty(options, "life", Life, ...sources);
5042
4243
  }
5043
4244
  update(particle, delta) {
5044
4245
  if (!this.isEnabled(particle) || !particle.life) {
@@ -5049,7 +4250,7 @@
5049
4250
  }
5050
4251
 
5051
4252
  async function loadLifeUpdater(engine) {
5052
- engine.checkVersion("4.1.2");
4253
+ engine.checkVersion("4.2.0");
5053
4254
  await engine.pluginManager.register(e => {
5054
4255
  e.pluginManager.addParticleUpdater("life", container => {
5055
4256
  return Promise.resolve(new LifeUpdater(container));
@@ -5075,65 +4276,40 @@
5075
4276
  }
5076
4277
 
5077
4278
  async function loadLineShape(engine) {
5078
- engine.checkVersion("4.1.2");
4279
+ engine.checkVersion("4.2.0");
5079
4280
  await engine.pluginManager.register(e => {
5080
4281
  e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
5081
4282
  });
5082
4283
  }
5083
4284
 
5084
4285
  class RotateAnimation {
5085
- decay;
5086
- enable;
5087
- speed;
5088
- sync;
5089
- constructor() {
5090
- this.enable = false;
5091
- this.speed = 0;
5092
- this.decay = 0;
5093
- this.sync = false;
5094
- }
4286
+ decay = 0;
4287
+ enable = false;
4288
+ speed = 0;
4289
+ sync = false;
5095
4290
  load(data) {
5096
4291
  if (isNull(data)) {
5097
4292
  return;
5098
4293
  }
5099
- if (data.enable !== undefined) {
5100
- this.enable = data.enable;
5101
- }
5102
- if (data.speed !== undefined) {
5103
- this.speed = setRangeValue(data.speed);
5104
- }
5105
- if (data.decay !== undefined) {
5106
- this.decay = setRangeValue(data.decay);
5107
- }
5108
- if (data.sync !== undefined) {
5109
- this.sync = data.sync;
5110
- }
4294
+ loadProperty(this, "enable", data.enable);
4295
+ loadRangeProperty(this, "speed", data.speed);
4296
+ loadRangeProperty(this, "decay", data.decay);
4297
+ loadProperty(this, "sync", data.sync);
5111
4298
  }
5112
4299
  }
5113
4300
 
5114
4301
  class Rotate extends ValueWithRandom {
5115
- animation;
5116
- direction;
5117
- path;
5118
- constructor() {
5119
- super();
5120
- this.animation = new RotateAnimation();
5121
- this.direction = exports.RotateDirection.clockwise;
5122
- this.path = false;
5123
- this.value = 0;
5124
- }
4302
+ animation = new RotateAnimation();
4303
+ direction = exports.RotateDirection.clockwise;
4304
+ path = false;
5125
4305
  load(data) {
5126
4306
  if (isNull(data)) {
5127
4307
  return;
5128
4308
  }
5129
4309
  super.load(data);
5130
- if (data.direction !== undefined) {
5131
- this.direction = data.direction;
5132
- }
4310
+ loadProperty(this, "direction", data.direction);
5133
4311
  this.animation.load(data.animation);
5134
- if (data.path !== undefined) {
5135
- this.path = data.path;
5136
- }
4312
+ loadProperty(this, "path", data.path);
5137
4313
  }
5138
4314
  }
5139
4315
 
@@ -5171,7 +4347,7 @@
5171
4347
  }
5172
4348
  const rotateAnimation = rotateOptions.animation;
5173
4349
  if (rotateAnimation.enable) {
5174
- particle.rotate.decay = identity$2 - getRangeValue(rotateAnimation.decay);
4350
+ particle.rotate.decay = identity$1 - getRangeValue(rotateAnimation.decay);
5175
4351
  particle.rotate.velocity =
5176
4352
  (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.#container.retina.reduceFactor;
5177
4353
  if (!rotateAnimation.sync) {
@@ -5188,10 +4364,7 @@
5188
4364
  return !particle.destroyed && !particle.spawning && (!!rotate.value || rotate.animation.enable || rotate.path);
5189
4365
  }
5190
4366
  loadOptions(options, ...sources) {
5191
- options.rotate ??= new Rotate();
5192
- for (const source of sources) {
5193
- options.rotate.load(source?.rotate);
5194
- }
4367
+ loadOptionProperty(options, "rotate", Rotate, ...sources);
5195
4368
  }
5196
4369
  update(particle, delta) {
5197
4370
  if (!this.isEnabled(particle)) {
@@ -5207,7 +4380,7 @@
5207
4380
  }
5208
4381
 
5209
4382
  async function loadRotateUpdater(engine) {
5210
- engine.checkVersion("4.1.2");
4383
+ engine.checkVersion("4.2.0");
5211
4384
  await engine.pluginManager.register(e => {
5212
4385
  e.pluginManager.addParticleUpdater("rotate", container => {
5213
4386
  return Promise.resolve(new RotateUpdater(container));
@@ -5218,20 +4391,14 @@
5218
4391
  const mouseDownEvent = "pointerdown", touchStartEvent = "touchstart";
5219
4392
 
5220
4393
  class SoundsAudio {
5221
- loop;
5222
- source;
5223
- constructor() {
5224
- this.loop = false;
5225
- this.source = "";
5226
- }
4394
+ loop = false;
4395
+ source = "";
5227
4396
  load(data) {
5228
4397
  if (isNull(data)) {
5229
4398
  return;
5230
4399
  }
5231
4400
  if (isObject(data)) {
5232
- if (data.loop !== undefined) {
5233
- this.loop = data.loop;
5234
- }
4401
+ loadProperty(this, "loop", data.loop);
5235
4402
  if (data.source !== undefined) {
5236
4403
  this.source = data.source;
5237
4404
  }
@@ -5243,41 +4410,26 @@
5243
4410
  }
5244
4411
 
5245
4412
  class SoundsNote {
5246
- duration;
5247
- value;
5248
- constructor() {
5249
- this.duration = 500;
5250
- this.value = [];
5251
- }
4413
+ duration = 500;
4414
+ value = [];
5252
4415
  load(data) {
5253
4416
  if (isNull(data)) {
5254
4417
  return;
5255
4418
  }
5256
- if (data.duration !== undefined) {
5257
- this.duration = data.duration;
5258
- }
5259
- if (data.value !== undefined) {
5260
- this.value = data.value;
5261
- }
4419
+ loadProperty(this, "duration", data.duration);
4420
+ loadProperty(this, "value", data.value);
5262
4421
  }
5263
4422
  }
5264
4423
 
5265
4424
  class SoundsMelody {
5266
- loop;
5267
- melodies;
5268
- notes;
5269
- constructor() {
5270
- this.loop = false;
5271
- this.melodies = [];
5272
- this.notes = [];
5273
- }
4425
+ loop = false;
4426
+ melodies = [];
4427
+ notes = [];
5274
4428
  load(data) {
5275
4429
  if (isNull(data)) {
5276
4430
  return;
5277
4431
  }
5278
- if (data.loop !== undefined) {
5279
- this.loop = data.loop;
5280
- }
4432
+ loadProperty(this, "loop", data.loop);
5281
4433
  if (data.melodies !== undefined) {
5282
4434
  this.melodies = data.melodies.map(s => {
5283
4435
  const tmp = new SoundsMelody();
@@ -5297,21 +4449,15 @@
5297
4449
 
5298
4450
  class SoundsEvent {
5299
4451
  audio;
5300
- event;
4452
+ event = [];
5301
4453
  filter;
5302
4454
  melodies;
5303
- notes;
5304
- constructor() {
5305
- this.event = [];
5306
- this.notes = [];
5307
- }
4455
+ notes = [];
5308
4456
  load(data) {
5309
4457
  if (isNull(data)) {
5310
4458
  return;
5311
4459
  }
5312
- if (data.event !== undefined) {
5313
- this.event = data.event;
5314
- }
4460
+ loadProperty(this, "event", data.event);
5315
4461
  if (data.audio !== undefined) {
5316
4462
  if (isArray(data.audio)) {
5317
4463
  this.audio = data.audio.map(s => {
@@ -5354,32 +4500,19 @@
5354
4500
  }
5355
4501
 
5356
4502
  class SoundsIcon {
5357
- height;
4503
+ height = 24;
5358
4504
  path;
5359
- style;
4505
+ style = "";
5360
4506
  svg;
5361
- width;
5362
- constructor() {
5363
- this.width = 24;
5364
- this.height = 24;
5365
- this.style = "";
5366
- }
4507
+ width = 24;
5367
4508
  load(data) {
5368
4509
  if (isNull(data)) {
5369
4510
  return;
5370
4511
  }
5371
- if (data.path !== undefined) {
5372
- this.path = data.path;
5373
- }
5374
- if (data.svg !== undefined) {
5375
- this.svg = data.svg;
5376
- }
5377
- if (data.width !== undefined) {
5378
- this.width = data.width;
5379
- }
5380
- if (data.height !== undefined) {
5381
- this.height = data.height;
5382
- }
4512
+ loadProperty(this, "path", data.path);
4513
+ loadProperty(this, "svg", data.svg);
4514
+ loadProperty(this, "width", data.width);
4515
+ loadProperty(this, "height", data.height);
5383
4516
  }
5384
4517
  }
5385
4518
 
@@ -5436,9 +4569,7 @@
5436
4569
  if (isNull(data)) {
5437
4570
  return;
5438
4571
  }
5439
- if (data.enable !== undefined) {
5440
- this.enable = data.enable;
5441
- }
4572
+ loadProperty(this, "enable", data.enable);
5442
4573
  this.mute.load(data.mute);
5443
4574
  this.unmute.load(data.unmute);
5444
4575
  this.volumeDown.load(data.volumeDown);
@@ -5447,30 +4578,18 @@
5447
4578
  }
5448
4579
 
5449
4580
  class SoundsVolume {
5450
- max;
5451
- min;
5452
- step;
5453
- value;
5454
- constructor() {
5455
- this.value = 100;
5456
- this.max = 100;
5457
- this.min = 0;
5458
- this.step = 10;
5459
- }
4581
+ max = 100;
4582
+ min = 0;
4583
+ step = 10;
4584
+ value = 100;
5460
4585
  load(data) {
5461
4586
  if (isNull(data)) {
5462
4587
  return;
5463
4588
  }
5464
4589
  if (isObject(data)) {
5465
- if (data.max !== undefined) {
5466
- this.max = data.max;
5467
- }
5468
- if (data.min !== undefined) {
5469
- this.min = data.min;
5470
- }
5471
- if (data.step !== undefined) {
5472
- this.step = data.step;
5473
- }
4590
+ loadProperty(this, "max", data.max);
4591
+ loadProperty(this, "min", data.min);
4592
+ loadProperty(this, "step", data.step);
5474
4593
  if (data.value !== undefined) {
5475
4594
  this.value = data.value;
5476
4595
  }
@@ -5480,30 +4599,19 @@
5480
4599
  }
5481
4600
  }
5482
4601
  }
5483
-
5484
- class Sounds {
5485
- autoPlay;
5486
- enable;
5487
- events;
5488
- icons;
5489
- volume;
5490
- constructor() {
5491
- this.autoPlay = true;
5492
- this.enable = false;
5493
- this.events = [];
5494
- this.icons = new SoundsIcons();
5495
- this.volume = new SoundsVolume();
5496
- }
4602
+
4603
+ class Sounds {
4604
+ autoPlay = true;
4605
+ enable = false;
4606
+ events = [];
4607
+ icons = new SoundsIcons();
4608
+ volume = new SoundsVolume();
5497
4609
  load(data) {
5498
4610
  if (isNull(data)) {
5499
4611
  return;
5500
4612
  }
5501
- if (data.autoPlay !== undefined) {
5502
- this.autoPlay = data.autoPlay;
5503
- }
5504
- if (data.enable !== undefined) {
5505
- this.enable = data.enable;
5506
- }
4613
+ loadProperty(this, "autoPlay", data.autoPlay);
4614
+ loadProperty(this, "enable", data.enable);
5507
4615
  if (data.events !== undefined) {
5508
4616
  this.events = data.events.map(t => {
5509
4617
  const event = new SoundsEvent();
@@ -5588,7 +4696,7 @@
5588
4696
  }
5589
4697
 
5590
4698
  async function loadSoundsPlugin(engine) {
5591
- engine.checkVersion("4.1.2");
4699
+ engine.checkVersion("4.2.0");
5592
4700
  await engine.pluginManager.register(e => {
5593
4701
  e.pluginManager.addPlugin(new SoundsPlugin(e));
5594
4702
  });
@@ -5596,7 +4704,7 @@
5596
4704
 
5597
4705
  let initPromise = null;
5598
4706
  async function doInitPlugins(engine) {
5599
- engine.checkVersion("4.1.2");
4707
+ engine.checkVersion("4.2.0");
5600
4708
  await engine.pluginManager.register(async (e) => {
5601
4709
  const loadEmittersForFireworks = async (e) => {
5602
4710
  await loadEmittersPluginSimple(e);
@@ -5643,7 +4751,7 @@
5643
4751
  fireworks.init = async () => {
5644
4752
  await initPlugins(tsParticles);
5645
4753
  };
5646
- fireworks.version = "4.1.2";
4754
+ fireworks.version = "4.2.0";
5647
4755
  globalThis.fireworks = fireworks;
5648
4756
 
5649
4757
  const globalObject = globalThis;
@@ -5704,7 +4812,7 @@
5704
4812
  return;
5705
4813
  }
5706
4814
  this.draw(ctx => {
5707
- clear(ctx, this.#canvasManager.size);
4815
+ ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
5708
4816
  });
5709
4817
  }
5710
4818
  clear() {
@@ -5766,7 +4874,7 @@
5766
4874
  plugin.drawParticleSetup?.(context, particle, delta);
5767
4875
  }
5768
4876
  this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
5769
- drawParticle({
4877
+ this.#drawParticle({
5770
4878
  container,
5771
4879
  context,
5772
4880
  particle,
@@ -5785,7 +4893,7 @@
5785
4893
  drawParticlePlugins(particle, delta) {
5786
4894
  this.draw(ctx => {
5787
4895
  for (const plugin of this.#drawParticlePlugins) {
5788
- drawParticlePlugin(ctx, plugin, particle, delta);
4896
+ this.#drawParticlePlugin(ctx, plugin, particle, delta);
5789
4897
  }
5790
4898
  });
5791
4899
  }
@@ -5885,12 +4993,19 @@
5885
4993
  }
5886
4994
  paintBase(baseColor) {
5887
4995
  this.draw(ctx => {
5888
- paintBase(ctx, this.#canvasManager.size, baseColor);
4996
+ ctx.fillStyle = baseColor ?? "rgba(0,0,0,0)";
4997
+ ctx.fillRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
5889
4998
  });
5890
4999
  }
5891
5000
  paintImage(image, opacity) {
5892
5001
  this.draw(ctx => {
5893
- paintImage(ctx, this.#canvasManager.size, image, opacity);
5002
+ if (!image) {
5003
+ return;
5004
+ }
5005
+ const prevAlpha = ctx.globalAlpha;
5006
+ ctx.globalAlpha = opacity;
5007
+ ctx.drawImage(image, originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
5008
+ ctx.globalAlpha = prevAlpha;
5894
5009
  });
5895
5010
  }
5896
5011
  setContext(context) {
@@ -5904,15 +5019,15 @@
5904
5019
  }
5905
5020
  stop() {
5906
5021
  this.draw(ctx => {
5907
- clear(ctx, this.#canvasManager.size);
5022
+ ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
5908
5023
  });
5909
5024
  }
5910
- #applyPostDrawUpdaters = particle => {
5025
+ #applyPostDrawUpdaters(particle) {
5911
5026
  for (const updater of this.#postDrawUpdaters) {
5912
5027
  updater.afterDraw?.(particle);
5913
5028
  }
5914
- };
5915
- #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
5029
+ }
5030
+ #applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
5916
5031
  for (const updater of this.#preDrawUpdaters) {
5917
5032
  if (updater.getColorStyles) {
5918
5033
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
@@ -5931,8 +5046,114 @@
5931
5046
  }
5932
5047
  updater.beforeDraw?.(particle);
5933
5048
  }
5934
- };
5935
- #getPluginParticleColors = particle => {
5049
+ }
5050
+ #drawAfterEffect(drawer, data) {
5051
+ if (!drawer?.drawAfter) {
5052
+ return;
5053
+ }
5054
+ const { particle } = data;
5055
+ if (!particle.effect) {
5056
+ return;
5057
+ }
5058
+ drawer.drawAfter(data);
5059
+ }
5060
+ #drawBeforeEffect(drawer, data) {
5061
+ if (!drawer?.drawBefore) {
5062
+ return;
5063
+ }
5064
+ const { particle } = data;
5065
+ if (!particle.effect) {
5066
+ return;
5067
+ }
5068
+ drawer.drawBefore(data);
5069
+ }
5070
+ #drawParticle(data) {
5071
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
5072
+ x: pos.x,
5073
+ y: pos.y,
5074
+ };
5075
+ context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
5076
+ if (colorStyles.fill) {
5077
+ context.fillStyle = colorStyles.fill;
5078
+ }
5079
+ const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
5080
+ context.lineWidth = strokeWidth;
5081
+ if (colorStyles.stroke) {
5082
+ context.strokeStyle = colorStyles.stroke;
5083
+ }
5084
+ const drawData = {
5085
+ context,
5086
+ particle,
5087
+ radius,
5088
+ drawRadius: radius * drawScale,
5089
+ opacity,
5090
+ delta,
5091
+ pixelRatio: container.retina.pixelRatio,
5092
+ fill: fillEnabled,
5093
+ stroke: strokeWidth > minStrokeWidth,
5094
+ transformData,
5095
+ position: { ...pos },
5096
+ drawPosition,
5097
+ drawScale,
5098
+ };
5099
+ for (const plugin of container.plugins) {
5100
+ plugin.drawParticleTransform?.(drawData);
5101
+ }
5102
+ const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
5103
+ this.#drawBeforeEffect(effect, drawData);
5104
+ this.#drawShapeBeforeDraw(shape, drawData);
5105
+ this.#drawShape(shape, drawData);
5106
+ this.#drawShapeAfterDraw(shape, drawData);
5107
+ this.#drawAfterEffect(effect, drawData);
5108
+ context.resetTransform();
5109
+ }
5110
+ #drawParticlePlugin(context, plugin, particle, delta) {
5111
+ if (!plugin.drawParticle) {
5112
+ return;
5113
+ }
5114
+ plugin.drawParticle(context, particle, delta);
5115
+ }
5116
+ #drawShape(drawer, data) {
5117
+ if (!drawer) {
5118
+ return;
5119
+ }
5120
+ const { context, fill, particle, stroke } = data;
5121
+ if (!particle.shape) {
5122
+ return;
5123
+ }
5124
+ context.beginPath();
5125
+ drawer.draw(data);
5126
+ if (particle.shapeClose) {
5127
+ context.closePath();
5128
+ }
5129
+ if (fill) {
5130
+ context.fill();
5131
+ }
5132
+ if (stroke) {
5133
+ context.stroke();
5134
+ }
5135
+ }
5136
+ #drawShapeAfterDraw(drawer, data) {
5137
+ if (!drawer?.afterDraw) {
5138
+ return;
5139
+ }
5140
+ const { particle } = data;
5141
+ if (!particle.shape) {
5142
+ return;
5143
+ }
5144
+ drawer.afterDraw(data);
5145
+ }
5146
+ #drawShapeBeforeDraw(drawer, data) {
5147
+ if (!drawer?.beforeDraw) {
5148
+ return;
5149
+ }
5150
+ const { particle } = data;
5151
+ if (!particle.shape) {
5152
+ return;
5153
+ }
5154
+ drawer.beforeDraw(data);
5155
+ }
5156
+ #getPluginParticleColors(particle) {
5936
5157
  let fColor, sColor;
5937
5158
  for (const plugin of this.#colorPlugins) {
5938
5159
  if (!fColor && plugin.particleFillColor) {
@@ -5948,7 +5169,7 @@
5948
5169
  this.#reusablePluginColors[fColorIndex] = fColor;
5949
5170
  this.#reusablePluginColors[sColorIndex] = sColor;
5950
5171
  return this.#reusablePluginColors;
5951
- };
5172
+ }
5952
5173
  }
5953
5174
 
5954
5175
  const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
@@ -6080,6 +5301,7 @@
6080
5301
  obs.observe(element, { attributes: true });
6081
5302
  });
6082
5303
  this.initPlugins();
5304
+ this.#initContext();
6083
5305
  this.render.init();
6084
5306
  }
6085
5307
  initBackground() {
@@ -6089,7 +5311,7 @@
6089
5311
  }
6090
5312
  const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
6091
5313
  if (color) {
6092
- elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
5314
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
6093
5315
  }
6094
5316
  else {
6095
5317
  elementStyle.backgroundColor = "";
@@ -6111,7 +5333,7 @@
6111
5333
  if (this.#generated && this.domElement) {
6112
5334
  this.domElement.remove();
6113
5335
  }
6114
- const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
5336
+ const domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
6115
5337
  this.domElement = domCanvas;
6116
5338
  this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
6117
5339
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
@@ -6132,26 +5354,6 @@
6132
5354
  const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
6133
5355
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
6134
5356
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
6135
- const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
6136
- this.render.setContextSettings({
6137
- alpha: true,
6138
- colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
6139
- desynchronized: true,
6140
- willReadFrequently: false,
6141
- });
6142
- this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
6143
- this.#safeMutationObserver(obs => {
6144
- obs.disconnect();
6145
- });
6146
- container.retina.init();
6147
- this.initBackground();
6148
- this.#safeMutationObserver(obs => {
6149
- const element = this.domElement;
6150
- if (!element || !(element instanceof Node)) {
6151
- return;
6152
- }
6153
- obs.observe(element, { attributes: true });
6154
- });
6155
5357
  }
6156
5358
  resize() {
6157
5359
  const element = this.domElement;
@@ -6219,12 +5421,30 @@
6219
5421
  await container.refresh();
6220
5422
  }
6221
5423
  }
6222
- #applyResizePlugins = () => {
5424
+ #applyResizePlugins() {
6223
5425
  for (const plugin of this.#resizePlugins) {
6224
5426
  plugin.resize?.();
6225
5427
  }
6226
- };
6227
- #initStyle = () => {
5428
+ }
5429
+ #initContext() {
5430
+ const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
5431
+ safeMatchMedia("(color-gamut: p3)")?.matches &&
5432
+ safeMatchMedia("(dynamic-range: high)")?.matches;
5433
+ this.render.setContextSettings({
5434
+ alpha: true,
5435
+ desynchronized: true,
5436
+ willReadFrequently: false,
5437
+ ...(canSupportHdr
5438
+ ? { colorSpace: "display-p3", colorType: "float16" }
5439
+ : { colorSpace: "srgb" }),
5440
+ });
5441
+ const renderCanvas = this.renderCanvas;
5442
+ if (!renderCanvas) {
5443
+ return;
5444
+ }
5445
+ this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
5446
+ }
5447
+ #initStyle() {
6228
5448
  const element = this.domElement, options = this.#container.actualOptions;
6229
5449
  if (!element) {
6230
5450
  return;
@@ -6245,8 +5465,8 @@
6245
5465
  }
6246
5466
  element.style.setProperty(key, value, "important");
6247
5467
  }
6248
- };
6249
- #repairStyle = () => {
5468
+ }
5469
+ #repairStyle() {
6250
5470
  const element = this.domElement;
6251
5471
  if (!element) {
6252
5472
  return;
@@ -6265,27 +5485,27 @@
6265
5485
  }
6266
5486
  observer.observe(element, { attributes: true });
6267
5487
  });
6268
- };
6269
- #resetOriginalStyle = () => {
5488
+ }
5489
+ #resetOriginalStyle() {
6270
5490
  const element = this.domElement, originalStyle = this.#originalStyle;
6271
5491
  if (!element || !originalStyle) {
6272
5492
  return;
6273
5493
  }
6274
5494
  setStyle(element, originalStyle, true);
6275
- };
6276
- #safeMutationObserver = callback => {
5495
+ }
5496
+ #safeMutationObserver(callback) {
6277
5497
  if (!this.#mutationObserver) {
6278
5498
  return;
6279
5499
  }
6280
5500
  callback(this.#mutationObserver);
6281
- };
6282
- #setFullScreenStyle = () => {
5501
+ }
5502
+ #setFullScreenStyle() {
6283
5503
  const element = this.domElement;
6284
5504
  if (!element) {
6285
5505
  return;
6286
5506
  }
6287
5507
  setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
6288
- };
5508
+ }
6289
5509
  }
6290
5510
 
6291
5511
  class EventListeners {
@@ -6310,7 +5530,7 @@
6310
5530
  removeListeners() {
6311
5531
  this.#manageListeners(false);
6312
5532
  }
6313
- #handleVisibilityChange = () => {
5533
+ #handleVisibilityChange() {
6314
5534
  const container = this.#container, options = container.actualOptions;
6315
5535
  if (!options.pauseOnBlur) {
6316
5536
  return;
@@ -6328,8 +5548,8 @@
6328
5548
  container.draw(true);
6329
5549
  }
6330
5550
  }
6331
- };
6332
- #handleWindowResize = () => {
5551
+ }
5552
+ #handleWindowResize() {
6333
5553
  if (this.#resizeTimeout) {
6334
5554
  clearTimeout(this.#resizeTimeout);
6335
5555
  this.#resizeTimeout = undefined;
@@ -6339,13 +5559,13 @@
6339
5559
  await canvas.windowResize();
6340
5560
  };
6341
5561
  this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
6342
- };
6343
- #manageListeners = add => {
5562
+ }
5563
+ #manageListeners(add) {
6344
5564
  const handlers = this.#handlers;
6345
5565
  this.#manageResize(add);
6346
5566
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
6347
- };
6348
- #manageResize = add => {
5567
+ }
5568
+ #manageResize(add) {
6349
5569
  const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
6350
5570
  if (!options.resize.enable) {
6351
5571
  return;
@@ -6372,7 +5592,7 @@
6372
5592
  });
6373
5593
  this.#resizeObserver.observe(canvasEl);
6374
5594
  }
6375
- };
5595
+ }
6376
5596
  }
6377
5597
 
6378
5598
  function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
@@ -6399,6 +5619,131 @@
6399
5619
  data.setCb(data.radius);
6400
5620
  }
6401
5621
  }
5622
+ function normalizeAngle(angle, modulus) {
5623
+ const normalized = angle % modulus;
5624
+ return normalized < defaultAngle ? normalized + modulus : normalized;
5625
+ }
5626
+ function initParticleState(particle, id, group) {
5627
+ particle.id = id;
5628
+ particle.group = group;
5629
+ particle.justWarped = false;
5630
+ particle.effectClose = true;
5631
+ particle.shapeClose = true;
5632
+ particle.pathRotation = false;
5633
+ particle.lastPathTime = 0;
5634
+ particle.destroyed = false;
5635
+ particle.unbreakable = false;
5636
+ particle.isRotating = false;
5637
+ particle.rotation = 0;
5638
+ particle.misplaced = false;
5639
+ particle.retina = {
5640
+ maxDistance: {},
5641
+ maxSpeed: 0,
5642
+ moveDrift: 0,
5643
+ moveSpeed: 0,
5644
+ sizeAnimationSpeed: 0,
5645
+ };
5646
+ particle.size = {
5647
+ value: 1,
5648
+ max: 1,
5649
+ min: 1,
5650
+ enable: false,
5651
+ };
5652
+ particle.outType = exports.ParticleOutType.normal;
5653
+ particle.ignoresResizeRatio = true;
5654
+ }
5655
+ function resolveParticleOptions(particle, container, pluginManager, overrideOptions) {
5656
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates;
5657
+ particle.effect = itemFromSingleOrMultiple(particlesOptions.effect.type, particle.id, reduceDuplicates);
5658
+ particle.shape = itemFromSingleOrMultiple(particlesOptions.shape.type, particle.id, reduceDuplicates);
5659
+ const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
5660
+ if (overrideOptions) {
5661
+ if (overrideOptions.effect) {
5662
+ const overrideEffectType = overrideOptions.effect.type;
5663
+ if (overrideEffectType && overrideEffectType !== particle.effect) {
5664
+ const effect = itemFromSingleOrMultiple(overrideEffectType, particle.id, reduceDuplicates);
5665
+ if (effect) {
5666
+ particle.effect = effect;
5667
+ }
5668
+ }
5669
+ effectOptions.load(overrideOptions.effect);
5670
+ }
5671
+ if (overrideOptions.shape) {
5672
+ const overrideShapeType = overrideOptions.shape.type;
5673
+ if (overrideShapeType && overrideShapeType !== particle.shape) {
5674
+ const shape = itemFromSingleOrMultiple(overrideShapeType, particle.id, reduceDuplicates);
5675
+ if (shape) {
5676
+ particle.shape = shape;
5677
+ }
5678
+ }
5679
+ shapeOptions.load(overrideOptions.shape);
5680
+ }
5681
+ }
5682
+ if (particle.effect === randomColorValue) {
5683
+ const availableEffects = [...container.effectDrawers.keys()];
5684
+ particle.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
5685
+ }
5686
+ if (particle.shape === randomColorValue) {
5687
+ const availableShapes = [...container.shapeDrawers.keys()];
5688
+ particle.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
5689
+ }
5690
+ particle.effectData = particle.effect
5691
+ ? loadEffectData(particle.effect, effectOptions, particle.id, reduceDuplicates)
5692
+ : undefined;
5693
+ particle.shapeData = particle.shape
5694
+ ? loadShapeData(particle.shape, shapeOptions, particle.id, reduceDuplicates)
5695
+ : undefined;
5696
+ particlesOptions.load(overrideOptions);
5697
+ const effectData = particle.effectData, shapeData = particle.shapeData;
5698
+ if (effectData) {
5699
+ particlesOptions.load(effectData.particles);
5700
+ }
5701
+ if (shapeData) {
5702
+ particlesOptions.load(shapeData.particles);
5703
+ }
5704
+ particle.effectClose = effectData?.close ?? particlesOptions.effect.close;
5705
+ particle.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
5706
+ return particlesOptions;
5707
+ }
5708
+ function initParticleDrawers(particle, container) {
5709
+ let effectDrawer, shapeDrawer;
5710
+ if (particle.effect) {
5711
+ effectDrawer = container.effectDrawers.get(particle.effect);
5712
+ }
5713
+ if (effectDrawer?.loadEffect) {
5714
+ effectDrawer.loadEffect(particle);
5715
+ }
5716
+ if (particle.shape) {
5717
+ shapeDrawer = container.shapeDrawers.get(particle.shape);
5718
+ }
5719
+ if (shapeDrawer?.loadShape) {
5720
+ shapeDrawer.loadShape(particle);
5721
+ }
5722
+ const sideCountFunc = shapeDrawer?.getSidesCount;
5723
+ if (sideCountFunc) {
5724
+ particle.sides = sideCountFunc(particle);
5725
+ }
5726
+ }
5727
+ function runUpdaterPreInit(updaters, particle) {
5728
+ for (const updater of updaters) {
5729
+ updater.preInit?.(particle);
5730
+ }
5731
+ }
5732
+ function runUpdaterInit(updaters, particle) {
5733
+ for (const updater of updaters) {
5734
+ updater.init(particle);
5735
+ }
5736
+ }
5737
+ function runDrawerInit(container, particle) {
5738
+ const shapeDrawer = particle.shape ? container.shapeDrawers.get(particle.shape) : undefined, effectDrawer = particle.effect ? container.effectDrawers.get(particle.effect) : undefined;
5739
+ effectDrawer?.particleInit?.(container, particle);
5740
+ shapeDrawer?.particleInit?.(container, particle);
5741
+ }
5742
+ function runParticleCreatedPlugins(container, particle) {
5743
+ for (const plugin of container.particleCreatedPlugins) {
5744
+ plugin.particleCreated?.(particle);
5745
+ }
5746
+ }
6402
5747
  class Particle {
6403
5748
  backColor;
6404
5749
  bubble;
@@ -6524,88 +5869,20 @@
6524
5869
  const rotateData = this.getRotateData(), rotating = this.isRotating;
6525
5870
  this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
6526
5871
  this.#cachedTransform.b = rotating
6527
- ? rotateData.sin * (externalTransform.b ?? identity$2)
5872
+ ? rotateData.sin * (externalTransform.b ?? identity$1)
6528
5873
  : (externalTransform.b ?? defaultTransform.b);
6529
5874
  this.#cachedTransform.c = rotating
6530
- ? -rotateData.sin * (externalTransform.c ?? identity$2)
5875
+ ? -rotateData.sin * (externalTransform.c ?? identity$1)
6531
5876
  : (externalTransform.c ?? defaultTransform.c);
6532
5877
  this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
6533
5878
  return this.#cachedTransform;
6534
5879
  }
6535
5880
  init(id, position, overrideOptions, group) {
6536
5881
  const container = this.#container;
6537
- this.id = id;
6538
- this.group = group;
6539
- this.justWarped = false;
6540
- this.effectClose = true;
6541
- this.shapeClose = true;
6542
- this.pathRotation = false;
6543
- this.lastPathTime = 0;
6544
- this.destroyed = false;
6545
- this.unbreakable = false;
6546
- this.isRotating = false;
6547
- this.rotation = 0;
6548
- this.misplaced = false;
6549
- this.retina = {
6550
- maxDistance: {},
6551
- maxSpeed: 0,
6552
- moveDrift: 0,
6553
- moveSpeed: 0,
6554
- sizeAnimationSpeed: 0,
6555
- };
6556
- this.size = {
6557
- value: 1,
6558
- max: 1,
6559
- min: 1,
6560
- enable: false,
6561
- };
6562
- this.outType = exports.ParticleOutType.normal;
6563
- this.ignoresResizeRatio = true;
6564
- const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
6565
- this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
6566
- this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
6567
- const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
6568
- if (overrideOptions) {
6569
- if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
6570
- const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
6571
- if (effect) {
6572
- this.effect = effect;
6573
- effectOptions.load(overrideOptions.effect);
6574
- }
6575
- }
6576
- if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
6577
- const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
6578
- if (shape) {
6579
- this.shape = shape;
6580
- shapeOptions.load(overrideOptions.shape);
6581
- }
6582
- }
6583
- }
6584
- if (this.effect === randomColorValue) {
6585
- const availableEffects = [...this.#container.effectDrawers.keys()];
6586
- this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
6587
- }
6588
- if (this.shape === randomColorValue) {
6589
- const availableShapes = [...this.#container.shapeDrawers.keys()];
6590
- this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
6591
- }
6592
- this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
6593
- this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
6594
- particlesOptions.load(overrideOptions);
6595
- const effectData = this.effectData, shapeData = this.shapeData;
6596
- if (effectData) {
6597
- particlesOptions.load(effectData.particles);
6598
- }
6599
- if (shapeData) {
6600
- particlesOptions.load(shapeData.particles);
6601
- }
6602
- this.effectClose = effectData?.close ?? particlesOptions.effect.close;
6603
- this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
6604
- this.options = particlesOptions;
5882
+ initParticleState(this, id, group);
5883
+ this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
6605
5884
  container.retina.initParticle(this);
6606
- for (const updater of container.particleUpdaters) {
6607
- updater.preInit?.(this);
6608
- }
5885
+ runUpdaterPreInit(container.particleUpdaters, this);
6609
5886
  this.bubble = {
6610
5887
  inRange: false,
6611
5888
  };
@@ -6618,32 +5895,11 @@
6618
5895
  this.velocity = this.initialVelocity.copy();
6619
5896
  this.zIndexFactor = this.position.z / container.zLayers;
6620
5897
  this.sides = 24;
6621
- let effectDrawer, shapeDrawer;
6622
- if (this.effect) {
6623
- effectDrawer = container.effectDrawers.get(this.effect);
6624
- }
6625
- if (effectDrawer?.loadEffect) {
6626
- effectDrawer.loadEffect(this);
6627
- }
6628
- if (this.shape) {
6629
- shapeDrawer = container.shapeDrawers.get(this.shape);
6630
- }
6631
- if (shapeDrawer?.loadShape) {
6632
- shapeDrawer.loadShape(this);
6633
- }
6634
- const sideCountFunc = shapeDrawer?.getSidesCount;
6635
- if (sideCountFunc) {
6636
- this.sides = sideCountFunc(this);
6637
- }
5898
+ initParticleDrawers(this, container);
6638
5899
  this.spawning = false;
6639
- for (const updater of container.particleUpdaters) {
6640
- updater.init(this);
6641
- }
6642
- effectDrawer?.particleInit?.(container, this);
6643
- shapeDrawer?.particleInit?.(container, this);
6644
- for (const plugin of container.particleCreatedPlugins) {
6645
- plugin.particleCreated?.(this);
6646
- }
5900
+ runUpdaterInit(container.particleUpdaters, this);
5901
+ runDrawerInit(container, this);
5902
+ runParticleCreatedPlugins(container, this);
6647
5903
  }
6648
5904
  isInsideCanvas(direction) {
6649
5905
  return this.#getInsideCanvasResult({ direction }).inside;
@@ -6657,15 +5913,15 @@
6657
5913
  }
6658
5914
  const angle = this.roll.angle;
6659
5915
  if (this.roll.horizontal && this.roll.vertical) {
6660
- const normalizedAngle = angle % doublePI, adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + doublePI : normalizedAngle;
5916
+ const adjustedAngle = normalizeAngle(angle, doublePI);
6661
5917
  return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
6662
5918
  }
6663
5919
  if (this.roll.horizontal) {
6664
- const normalizedAngle = (angle + Math.PI * half) % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
5920
+ const adjustedAngle = normalizeAngle(angle + Math.PI * half, doublePI);
6665
5921
  return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
6666
5922
  }
6667
5923
  if (this.roll.vertical) {
6668
- const normalizedAngle = angle % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
5924
+ const adjustedAngle = normalizeAngle(angle, doublePI);
6669
5925
  return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
6670
5926
  }
6671
5927
  return false;
@@ -6678,10 +5934,10 @@
6678
5934
  updater.reset?.(this);
6679
5935
  }
6680
5936
  }
6681
- #calcPosition = (position, zIndex) => {
5937
+ #calcPosition(position, zIndex) {
6682
5938
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
6683
- const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
6684
- while (!signal.aborted) {
5939
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
5940
+ for (;;) {
6685
5941
  for (const plugin of plugins) {
6686
5942
  const pluginPos = plugin.particlePosition?.(posVec, this);
6687
5943
  if (pluginPos) {
@@ -6709,9 +5965,8 @@
6709
5965
  tryCount += tryCountIncrement;
6710
5966
  posVec = undefined;
6711
5967
  }
6712
- return posVec;
6713
- };
6714
- #calculateVelocity = () => {
5968
+ }
5969
+ #calculateVelocity() {
6715
5970
  const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
6716
5971
  if (moveOptions.direction === exports.MoveDirection.inside || moveOptions.direction === exports.MoveDirection.outside) {
6717
5972
  return res;
@@ -6727,8 +5982,8 @@
6727
5982
  res.length *= getRandom();
6728
5983
  }
6729
5984
  return res;
6730
- };
6731
- #fixHorizontal = (pos, radius, outMode) => {
5985
+ }
5986
+ #fixHorizontal(pos, radius, outMode) {
6732
5987
  fixOutMode({
6733
5988
  outMode,
6734
5989
  checkModes: [exports.OutMode.bounce],
@@ -6737,8 +5992,8 @@
6737
5992
  setCb: (value) => (pos.x += value),
6738
5993
  radius,
6739
5994
  });
6740
- };
6741
- #fixVertical = (pos, radius, outMode) => {
5995
+ }
5996
+ #fixVertical(pos, radius, outMode) {
6742
5997
  fixOutMode({
6743
5998
  outMode,
6744
5999
  checkModes: [exports.OutMode.bounce],
@@ -6747,8 +6002,8 @@
6747
6002
  setCb: (value) => (pos.y += value),
6748
6003
  radius,
6749
6004
  });
6750
- };
6751
- #getDefaultInsideCanvasResult = (direction, outMode) => {
6005
+ }
6006
+ #getDefaultInsideCanvasResult(direction, outMode) {
6752
6007
  const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === exports.OutMode.bounce;
6753
6008
  if (direction === exports.OutModeDirection.bottom) {
6754
6009
  return {
@@ -6781,8 +6036,8 @@
6781
6036
  position.x <= canvasSize.width + radius,
6782
6037
  reason: "default",
6783
6038
  };
6784
- };
6785
- #getInsideCanvasCallbackData = (direction, outMode) => {
6039
+ }
6040
+ #getInsideCanvasCallbackData(direction, outMode) {
6786
6041
  return {
6787
6042
  canvasSize: this.#container.canvas.size,
6788
6043
  direction,
@@ -6790,8 +6045,8 @@
6790
6045
  particle: this,
6791
6046
  radius: this.getRadius(),
6792
6047
  };
6793
- };
6794
- #getInsideCanvasResult = (data) => {
6048
+ }
6049
+ #getInsideCanvasResult(data) {
6795
6050
  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;
6796
6051
  if (!shapeCheck && !effectCheck) {
6797
6052
  return defaultResult;
@@ -6806,8 +6061,8 @@
6806
6061
  };
6807
6062
  }
6808
6063
  return shapeResult ?? effectResult ?? defaultResult;
6809
- };
6810
- #getRollColor = color => {
6064
+ }
6065
+ #getRollColor(color) {
6811
6066
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
6812
6067
  return color;
6813
6068
  }
@@ -6821,8 +6076,8 @@
6821
6076
  return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
6822
6077
  }
6823
6078
  return color;
6824
- };
6825
- #initPosition = position => {
6079
+ }
6080
+ #initPosition(position) {
6826
6081
  const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
6827
6082
  if (!initialPosition) {
6828
6083
  throw new Error("a valid position cannot be found for particle");
@@ -6845,8 +6100,8 @@
6845
6100
  break;
6846
6101
  }
6847
6102
  this.offset = Vector.origin;
6848
- };
6849
- #normalizeInsideCanvasResult = (result, reason) => {
6103
+ }
6104
+ #normalizeInsideCanvasResult(result, reason) {
6850
6105
  if (typeof result === "boolean") {
6851
6106
  return {
6852
6107
  inside: result,
@@ -6858,7 +6113,7 @@
6858
6113
  margin: result.margin,
6859
6114
  reason: result.reason ?? reason,
6860
6115
  };
6861
- };
6116
+ }
6862
6117
  }
6863
6118
 
6864
6119
  class SpatialHashGrid {
@@ -7211,10 +6466,10 @@
7211
6466
  }
7212
6467
  this.#resizeFactor = undefined;
7213
6468
  }
7214
- #addToPool = (...particles) => {
6469
+ #addToPool(...particles) {
7215
6470
  this.#pool.push(...particles);
7216
- };
7217
- #applyDensity = (options, pluginsCount, group, groupOptions) => {
6471
+ }
6472
+ #applyDensity(options, pluginsCount, group, groupOptions) {
7218
6473
  const numberOptions = options.number;
7219
6474
  if (!numberOptions.density.enable) {
7220
6475
  if (group === undefined) {
@@ -7238,36 +6493,19 @@
7238
6493
  else if (particlesCount > particlesNumber) {
7239
6494
  this.removeQuantity(particlesCount - particlesNumber, group);
7240
6495
  }
7241
- };
7242
- #createBuckets = (zLayers) => {
6496
+ }
6497
+ #createBuckets(zLayers) {
7243
6498
  const bucketCount = Math.max(Math.floor(zLayers), one);
7244
6499
  return Array.from({ length: bucketCount }, () => []);
7245
- };
7246
- #getBucketIndex = (zIndex) => {
6500
+ }
6501
+ #getBucketIndex(zIndex) {
7247
6502
  const maxBucketIndex = this.#zBuckets.length - one;
7248
6503
  if (maxBucketIndex <= minIndex) {
7249
6504
  return minIndex;
7250
6505
  }
7251
6506
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
7252
- };
7253
- #getParticleInsertIndex = (bucket, particleId) => {
7254
- let start = minIndex, end = bucket.length;
7255
- while (start < end) {
7256
- const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
7257
- if (!middleParticle) {
7258
- end = middle;
7259
- continue;
7260
- }
7261
- if (middleParticle.id < particleId) {
7262
- start = middle + one;
7263
- }
7264
- else {
7265
- end = middle;
7266
- }
7267
- }
7268
- return start;
7269
- };
7270
- #initDensityFactor = densityOptions => {
6507
+ }
6508
+ #initDensityFactor(densityOptions) {
7271
6509
  const container = this.#container;
7272
6510
  if (!densityOptions.enable) {
7273
6511
  return defaultDensityFactor;
@@ -7277,16 +6515,16 @@
7277
6515
  return defaultDensityFactor;
7278
6516
  }
7279
6517
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
7280
- };
7281
- #insertParticleIntoBucket = (particle) => {
6518
+ }
6519
+ #insertParticleIntoBucket(particle) {
7282
6520
  const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
7283
6521
  if (!bucket) {
7284
6522
  return;
7285
6523
  }
7286
- bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
6524
+ bucket.push(particle);
7287
6525
  this.#particleBuckets.set(particle.id, bucketIndex);
7288
- };
7289
- #removeParticle = (index, group, override) => {
6526
+ }
6527
+ #removeParticle(index, group, override) {
7290
6528
  const particle = this.#array[index];
7291
6529
  if (!particle) {
7292
6530
  return false;
@@ -7302,22 +6540,20 @@
7302
6540
  });
7303
6541
  this.#addToPool(particle);
7304
6542
  return true;
7305
- };
7306
- #removeParticleFromBucket = (particle) => {
6543
+ }
6544
+ #removeParticleFromBucket(particle) {
7307
6545
  const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
7308
6546
  if (!bucket) {
7309
6547
  this.#particleBuckets.delete(particle.id);
7310
6548
  return;
7311
6549
  }
7312
- const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
7313
- if (bucket[particleIndex]?.id !== particle.id) {
7314
- this.#particleBuckets.delete(particle.id);
7315
- return;
6550
+ const idx = bucket.findIndex(p => p.id === particle.id);
6551
+ if (idx >= minIndex) {
6552
+ bucket.splice(idx, deleteCount);
7316
6553
  }
7317
- bucket.splice(particleIndex, deleteCount);
7318
6554
  this.#particleBuckets.delete(particle.id);
7319
- };
7320
- #resetBuckets = (zLayers) => {
6555
+ }
6556
+ #resetBuckets(zLayers) {
7321
6557
  const bucketCount = Math.max(Math.floor(zLayers), one);
7322
6558
  if (this.#zBuckets.length !== bucketCount) {
7323
6559
  this.#zBuckets = this.#createBuckets(bucketCount);
@@ -7326,8 +6562,8 @@
7326
6562
  for (const bucket of this.#zBuckets) {
7327
6563
  bucket.length = minIndex;
7328
6564
  }
7329
- };
7330
- #updateParticleBucket = (particle) => {
6565
+ }
6566
+ #updateParticleBucket(particle) {
7331
6567
  const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
7332
6568
  if (currentBucketIndex === undefined) {
7333
6569
  this.#insertParticleIntoBucket(particle);
@@ -7338,9 +6574,9 @@
7338
6574
  }
7339
6575
  const currentBucket = this.#zBuckets[currentBucketIndex];
7340
6576
  if (currentBucket) {
7341
- const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
7342
- if (currentBucket[particleIndex]?.id === particle.id) {
7343
- currentBucket.splice(particleIndex, deleteCount);
6577
+ const idx = currentBucket.findIndex(p => p.id === particle.id);
6578
+ if (idx >= minIndex) {
6579
+ currentBucket.splice(idx, deleteCount);
7344
6580
  }
7345
6581
  }
7346
6582
  const newBucket = this.#zBuckets[newBucketIndex];
@@ -7348,10 +6584,16 @@
7348
6584
  this.#particleBuckets.set(particle.id, newBucketIndex);
7349
6585
  return;
7350
6586
  }
7351
- newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
6587
+ newBucket.push(particle);
6588
+ if (newBucket.length >= double) {
6589
+ const prev = newBucket[newBucket.length - double];
6590
+ if (prev && particle.id < prev.id) {
6591
+ newBucket.sort((a, b) => a.id - b.id);
6592
+ }
6593
+ }
7352
6594
  this.#particleBuckets.set(particle.id, newBucketIndex);
7353
- };
7354
- #updateParticlesPhase1 = (delta) => {
6595
+ }
6596
+ #updateParticlesPhase1(delta) {
7355
6597
  const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
7356
6598
  for (const particle of this.#array) {
7357
6599
  if (resizeFactor && !particle.ignoresResizeRatio) {
@@ -7377,8 +6619,8 @@
7377
6619
  this.grid.insert(particle);
7378
6620
  }
7379
6621
  return particlesToDelete;
7380
- };
7381
- #updateParticlesPhase2 = (delta, particlesToDelete) => {
6622
+ }
6623
+ #updateParticlesPhase2(delta, particlesToDelete) {
7382
6624
  for (const particle of this.#array) {
7383
6625
  if (particle.destroyed) {
7384
6626
  particlesToDelete.add(particle);
@@ -7394,7 +6636,7 @@
7394
6636
  }
7395
6637
  this.#updateParticleBucket(particle);
7396
6638
  }
7397
- };
6639
+ }
7398
6640
  }
7399
6641
 
7400
6642
  class Retina {
@@ -7756,7 +6998,7 @@
7756
6998
  }
7757
6999
  return refresh;
7758
7000
  }
7759
- #nextFrame = (timestamp) => {
7001
+ #nextFrame(timestamp) {
7760
7002
  try {
7761
7003
  if (!this.#smooth &&
7762
7004
  this.#lastFrameTime !== undefined &&
@@ -7784,7 +7026,7 @@
7784
7026
  catch (e) {
7785
7027
  getLogger().error("error in animation loop", e);
7786
7028
  }
7787
- };
7029
+ }
7788
7030
  }
7789
7031
 
7790
7032
  var Container$1 = /*#__PURE__*/Object.freeze({
@@ -7794,8 +7036,17 @@
7794
7036
 
7795
7037
  class FireworksInstance {
7796
7038
  #container;
7797
- constructor(container) {
7039
+ #id;
7040
+ constructor(container, id) {
7798
7041
  this.#container = container;
7042
+ this.#id = id;
7043
+ }
7044
+ get destroyed() {
7045
+ return this.#container.destroyed;
7046
+ }
7047
+ destroy() {
7048
+ this.#container.destroy();
7049
+ deleteFireworksInstance(this.#id);
7799
7050
  }
7800
7051
  pause() {
7801
7052
  this.#container.pause();
@@ -7851,7 +7102,7 @@
7851
7102
  BlendPluginInstance: BlendPluginInstance
7852
7103
  });
7853
7104
 
7854
- const minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
7105
+ const moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
7855
7106
  function applyDistance(particle) {
7856
7107
  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;
7857
7108
  if (!hDistance && !vDistance) {
@@ -7884,7 +7135,7 @@
7884
7135
  }
7885
7136
  function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {
7886
7137
  applyPath(particle, delta);
7887
- const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;
7138
+ const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity$1 : identity$1;
7888
7139
  if (moveDrift && moveSpeed) {
7889
7140
  particle.velocity.x += (moveDrift * delta.factor) / (moveSpeedFactor * moveSpeed);
7890
7141
  }
@@ -7904,7 +7155,7 @@
7904
7155
  particle.velocity.y = velocity.y / moveSpeed;
7905
7156
  }
7906
7157
  }
7907
- const zIndexOptions = particle.options.zIndex, zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;
7158
+ const zIndexOptions = particle.options.zIndex, zVelocityFactor = (identity$1 - particle.zIndexFactor) ** zIndexOptions.velocityRate;
7908
7159
  velocity.multTo(zVelocityFactor);
7909
7160
  velocity.multTo(reduceFactor);
7910
7161
  const { position } = particle;
@@ -7930,13 +7181,13 @@
7930
7181
  const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height), halfMaxSize = maxCanvasSize * half;
7931
7182
  if (particle.spin.radius > halfMaxSize) {
7932
7183
  particle.spin.radius = halfMaxSize;
7933
- particle.spin.acceleration *= -identity;
7184
+ particle.spin.acceleration *= -identity$1;
7934
7185
  }
7935
7186
  else if (particle.spin.radius < minSpinRadius) {
7936
7187
  particle.spin.radius = minSpinRadius;
7937
- particle.spin.acceleration *= -identity;
7188
+ particle.spin.acceleration *= -identity$1;
7938
7189
  }
7939
- particle.spin.angle += moveSpeed * spinFactor * (identity - particle.spin.radius / maxCanvasSize);
7190
+ particle.spin.angle += moveSpeed * spinFactor * (identity$1 - particle.spin.radius / maxCanvasSize);
7940
7191
  }
7941
7192
  function applyPath(particle, delta) {
7942
7193
  const particlesOptions = particle.options, pathOptions = particlesOptions.move.path, pathEnabled = pathOptions.enable;
@@ -7953,13 +7204,13 @@
7953
7204
  particle.velocity.addTo(path);
7954
7205
  }
7955
7206
  if (pathOptions.clamp) {
7956
- particle.velocity.x = clamp(particle.velocity.x, -identity, identity);
7957
- particle.velocity.y = clamp(particle.velocity.y, -identity, identity);
7207
+ particle.velocity.x = clamp(particle.velocity.x, -identity$1, identity$1);
7208
+ particle.velocity.y = clamp(particle.velocity.y, -identity$1, identity$1);
7958
7209
  }
7959
7210
  particle.lastPathTime -= pathDelay;
7960
7211
  }
7961
7212
  function getProximitySpeedFactor(particle) {
7962
- return particle.slow.inRange ? particle.slow.factor : identity;
7213
+ return particle.slow.inRange ? particle.slow.factor : identity$1;
7963
7214
  }
7964
7215
  function initSpin(container, particle) {
7965
7216
  const options = particle.options, spinOptions = options.move.spin;
@@ -8415,22 +7666,22 @@
8415
7666
  this.#volume += soundsOptions.volume.step;
8416
7667
  await this.#updateVolume();
8417
7668
  }
8418
- #addBuffer = audioCtx => {
7669
+ #addBuffer(audioCtx) {
8419
7670
  const buffer = audioCtx.createBufferSource();
8420
7671
  this.#audioSources.push(buffer);
8421
7672
  return buffer;
8422
- };
8423
- #addOscillator = audioCtx => {
7673
+ }
7674
+ #addOscillator(audioCtx) {
8424
7675
  const oscillator = audioCtx.createOscillator();
8425
7676
  this.#audioSources.push(oscillator);
8426
7677
  return oscillator;
8427
- };
7678
+ }
8428
7679
  #getAudioContext() {
8429
7680
  const container = this.#container;
8430
7681
  container.audioContext ??= new AudioContext();
8431
7682
  return container.audioContext;
8432
7683
  }
8433
- #initEvents = () => {
7684
+ #initEvents() {
8434
7685
  const container = this.#container, soundsOptions = container.actualOptions.sounds;
8435
7686
  if (!soundsOptions?.enable || !container.canvas.domElement) {
8436
7687
  return;
@@ -8487,8 +7738,8 @@
8487
7738
  this.#engine.addEventListener(item, cb);
8488
7739
  });
8489
7740
  }
8490
- };
8491
- #mute = async () => {
7741
+ }
7742
+ async #mute() {
8492
7743
  const container = this.#container, audioContext = this.#getAudioContext();
8493
7744
  for (const source of this.#audioSources) {
8494
7745
  this.#removeAudioSource(source);
@@ -8499,8 +7750,8 @@
8499
7750
  await audioContext.close();
8500
7751
  container.audioContext = undefined;
8501
7752
  this.#container.dispatchEvent(SoundsEventType.mute);
8502
- };
8503
- #playBuffer = audio => {
7753
+ }
7754
+ #playBuffer(audio) {
8504
7755
  const audioBuffer = this.#audioMap.get(audio.source);
8505
7756
  if (!audioBuffer) {
8506
7757
  return;
@@ -8514,8 +7765,8 @@
8514
7765
  source.buffer = audioBuffer;
8515
7766
  source.connect(this.#gain ?? audioCtx.destination);
8516
7767
  source.start();
8517
- };
8518
- #playFrequency = async (frequency, duration) => {
7768
+ }
7769
+ async #playFrequency(frequency, duration) {
8519
7770
  if (!this.#gain || this.#container.muted) {
8520
7771
  return;
8521
7772
  }
@@ -8530,8 +7781,8 @@
8530
7781
  resolve();
8531
7782
  }, duration);
8532
7783
  });
8533
- };
8534
- #playMuteSound = () => {
7784
+ }
7785
+ #playMuteSound() {
8535
7786
  if (this.#container.muted) {
8536
7787
  return;
8537
7788
  }
@@ -8548,8 +7799,8 @@
8548
7799
  oscillator.disconnect();
8549
7800
  gain.disconnect();
8550
7801
  });
8551
- };
8552
- #playNote = async (notes, noteIdx, loop) => {
7802
+ }
7803
+ async #playNote(notes, noteIdx, loop) {
8553
7804
  if (this.#container.muted) {
8554
7805
  return;
8555
7806
  }
@@ -8567,8 +7818,8 @@
8567
7818
  nextNoteIdx = nextNoteIdx % notes.length;
8568
7819
  }
8569
7820
  await this.#playNote(notes, nextNoteIdx, loop);
8570
- };
8571
- #playNoteValue = async (notes, noteIdx, valueIdx) => {
7821
+ }
7822
+ async #playNoteValue(notes, noteIdx, valueIdx) {
8572
7823
  const note = notes[noteIdx];
8573
7824
  if (!note) {
8574
7825
  return;
@@ -8587,14 +7838,14 @@
8587
7838
  catch (e) {
8588
7839
  getLogger().error(e);
8589
7840
  }
8590
- };
8591
- #removeAudioSource = source => {
7841
+ }
7842
+ #removeAudioSource(source) {
8592
7843
  source.stop();
8593
7844
  source.disconnect();
8594
7845
  const deleteCount = 1;
8595
7846
  this.#audioSources.splice(this.#audioSources.indexOf(source), deleteCount);
8596
- };
8597
- #unmute = () => {
7847
+ }
7848
+ #unmute() {
8598
7849
  const container = this.#container, options = container.actualOptions, soundsOptions = options.sounds;
8599
7850
  if (!soundsOptions) {
8600
7851
  return;
@@ -8605,8 +7856,8 @@
8605
7856
  this.#gain = gain;
8606
7857
  this.#initEvents();
8607
7858
  this.#container.dispatchEvent(SoundsEventType.unmute);
8608
- };
8609
- #updateMuteIcons = () => {
7859
+ }
7860
+ #updateMuteIcons() {
8610
7861
  const container = this.#container, soundsOptions = container.actualOptions.sounds;
8611
7862
  if (!soundsOptions?.enable || !soundsOptions.icons.enable) {
8612
7863
  return;
@@ -8618,8 +7869,8 @@
8618
7869
  if (unmuteImg) {
8619
7870
  unmuteImg.style.display = container.muted ? "none" : "block";
8620
7871
  }
8621
- };
8622
- #updateMuteStatus = async () => {
7872
+ }
7873
+ async #updateMuteStatus() {
8623
7874
  const container = this.#container, audioContext = this.#getAudioContext();
8624
7875
  if (container.muted) {
8625
7876
  await audioContext.suspend();
@@ -8630,8 +7881,8 @@
8630
7881
  this.#unmute();
8631
7882
  this.#playMuteSound();
8632
7883
  }
8633
- };
8634
- #updateVolume = async () => {
7884
+ }
7885
+ async #updateVolume() {
8635
7886
  const container = this.#container, soundsOptions = container.actualOptions.sounds;
8636
7887
  if (!soundsOptions?.enable) {
8637
7888
  return;
@@ -8654,7 +7905,7 @@
8654
7905
  if (this.#gain?.gain) {
8655
7906
  this.#gain.gain.value = this.#volume / percentDenominator;
8656
7907
  }
8657
- };
7908
+ }
8658
7909
  }
8659
7910
 
8660
7911
  var SoundsPluginInstance$1 = /*#__PURE__*/Object.freeze({
@@ -8747,7 +7998,13 @@
8747
7998
  this.#paused = !this.options.autoPlay;
8748
7999
  this.#particlesOptions = particlesOptions;
8749
8000
  this.#size = this.#calcSize();
8750
- this.size = getSize(this.#size, this.#container.canvas.size);
8001
+ this.size =
8002
+ this.#size.mode === exports.PixelMode.percent
8003
+ ? {
8004
+ width: (this.#size.width / percentDenominator) * this.#container.canvas.size.width,
8005
+ height: (this.#size.height / percentDenominator) * this.#container.canvas.size.height,
8006
+ }
8007
+ : { width: this.#size.width, height: this.#size.height };
8751
8008
  this.#lifeCount = this.options.life.count ?? defaultLifeCount;
8752
8009
  this.#immortal = this.#lifeCount <= minLifeCount;
8753
8010
  if (this.options.domId) {
@@ -8818,7 +8075,13 @@
8818
8075
  ? initialPosition
8819
8076
  : this.#calcPosition();
8820
8077
  this.#size = this.#calcSize();
8821
- this.size = getSize(this.#size, container.canvas.size);
8078
+ this.size =
8079
+ this.#size.mode === exports.PixelMode.percent
8080
+ ? {
8081
+ width: (this.#size.width / percentDenominator) * container.canvas.size.width,
8082
+ height: (this.#size.height / percentDenominator) * container.canvas.size.height,
8083
+ }
8084
+ : { width: this.#size.width, height: this.#size.height };
8822
8085
  this.#shape?.resize(this.position, this.size);
8823
8086
  }
8824
8087
  update(delta) {
@@ -8918,7 +8181,7 @@
8918
8181
  return size;
8919
8182
  })());
8920
8183
  }
8921
- #destroy = () => {
8184
+ #destroy() {
8922
8185
  this.#mutationObserver?.disconnect();
8923
8186
  this.#mutationObserver = undefined;
8924
8187
  this.#resizeObserver?.disconnect();
@@ -8927,7 +8190,7 @@
8927
8190
  this.#container.dispatchEvent("emitterDestroyed", {
8928
8191
  emitter: this,
8929
8192
  });
8930
- };
8193
+ }
8931
8194
  #emit() {
8932
8195
  if (this.#paused) {
8933
8196
  return;
@@ -8987,7 +8250,7 @@
8987
8250
  }
8988
8251
  }
8989
8252
  }
8990
- #prepareToDie = () => {
8253
+ #prepareToDie() {
8991
8254
  if (this.#paused) {
8992
8255
  return;
8993
8256
  }
@@ -8995,8 +8258,8 @@
8995
8258
  if ((this.#lifeCount > minLifeCount || this.#immortal) && duration !== undefined && duration > minDuration) {
8996
8259
  this.#duration = duration * millisecondsToSeconds;
8997
8260
  }
8998
- };
8999
- #setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
8261
+ }
8262
+ #setColorAnimation(animation, initValue, maxValue, factor = defaultColorAnimationFactor) {
9000
8263
  const container = this.#container;
9001
8264
  if (!animation.enable) {
9002
8265
  return initValue;
@@ -9005,7 +8268,7 @@
9005
8268
  ? (delay * millisecondsToSeconds) / container.retina.reduceFactor
9006
8269
  : Infinity, colorSpeed = getRangeValue(animation.speed);
9007
8270
  return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * factor) % maxValue;
9008
- };
8271
+ }
9009
8272
  }
9010
8273
 
9011
8274
  var EmitterInstance$1 = /*#__PURE__*/Object.freeze({
@@ -9028,6 +8291,7 @@
9028
8291
  exports.MoveCenter = MoveCenter;
9029
8292
  exports.MoveGravity = MoveGravity;
9030
8293
  exports.MovePath = MovePath;
8294
+ exports.OptionLoader = OptionLoader;
9031
8295
  exports.Options = Options;
9032
8296
  exports.OptionsColor = OptionsColor;
9033
8297
  exports.OutModes = OutModes;
@@ -9052,9 +8316,7 @@
9052
8316
  exports.alterHsl = alterHsl;
9053
8317
  exports.animate = animate;
9054
8318
  exports.areBoundsInside = areBoundsInside;
9055
- exports.arrayRandomIndex = arrayRandomIndex;
9056
8319
  exports.calcExactPositionOrRandomFromSize = calcExactPositionOrRandomFromSize;
9057
- exports.calcExactPositionOrRandomFromSizeRanged = calcExactPositionOrRandomFromSizeRanged;
9058
8320
  exports.calcPositionFromSize = calcPositionFromSize;
9059
8321
  exports.calcPositionOrRandomFromSize = calcPositionOrRandomFromSize;
9060
8322
  exports.calcPositionOrRandomFromSizeRanged = calcPositionOrRandomFromSizeRanged;
@@ -9066,11 +8328,9 @@
9066
8328
  exports.circleBounce = circleBounce;
9067
8329
  exports.circleBounceDataFromParticle = circleBounceDataFromParticle;
9068
8330
  exports.clamp = clamp;
9069
- exports.clear = clear;
9070
8331
  exports.cloneStyle = cloneStyle;
9071
8332
  exports.collisionVelocity = collisionVelocity;
9072
8333
  exports.colorMix = colorMix;
9073
- exports.colorToHsl = colorToHsl;
9074
8334
  exports.colorToRgb = colorToRgb;
9075
8335
  exports.countOffset = countOffset;
9076
8336
  exports.decayOffset = decayOffset;
@@ -9097,16 +8357,8 @@
9097
8357
  exports.deleteCount = deleteCount;
9098
8358
  exports.double = double;
9099
8359
  exports.doublePI = doublePI;
9100
- exports.drawAfterEffect = drawAfterEffect;
9101
- exports.drawBeforeEffect = drawBeforeEffect;
9102
- exports.drawParticle = drawParticle;
9103
- exports.drawParticlePlugin = drawParticlePlugin;
9104
- exports.drawShape = drawShape;
9105
- exports.drawShapeAfterDraw = drawShapeAfterDraw;
9106
- exports.drawShapeBeforeDraw = drawShapeBeforeDraw;
9107
8360
  exports.empty = empty;
9108
8361
  exports.executeOnSingleOrMultiple = executeOnSingleOrMultiple;
9109
- exports.findItemFromSingleOrMultiple = findItemFromSingleOrMultiple;
9110
8362
  exports.fireworks = fireworks;
9111
8363
  exports.generatedAttribute = generatedAttribute;
9112
8364
  exports.generatedFalse = generatedFalse;
@@ -9126,23 +8378,21 @@
9126
8378
  exports.getParticleDirectionAngle = getParticleDirectionAngle;
9127
8379
  exports.getPosition = getPosition;
9128
8380
  exports.getRandom = getRandom;
8381
+ exports.getRandomFn = getRandomFn;
9129
8382
  exports.getRandomInRange = getRandomInRange;
9130
8383
  exports.getRandomRgbColor = getRandomRgbColor;
9131
8384
  exports.getRangeMax = getRangeMax;
9132
8385
  exports.getRangeMin = getRangeMin;
9133
8386
  exports.getRangeValue = getRangeValue;
9134
- exports.getSize = getSize;
9135
8387
  exports.getStyleFromHsl = getStyleFromHsl;
9136
8388
  exports.getStyleFromRgb = getStyleFromRgb;
9137
8389
  exports.hMax = hMax;
9138
8390
  exports.hMin = hMin;
9139
8391
  exports.hPhase = hPhase;
9140
8392
  exports.half = half;
9141
- exports.hasMatchMedia = hasMatchMedia;
9142
8393
  exports.hslToRgb = hslToRgb;
9143
8394
  exports.hslaToRgba = hslaToRgba;
9144
- exports.identity = identity$2;
9145
- exports.initParticleNumericAnimationValue = initParticleNumericAnimationValue;
8395
+ exports.identity = identity$1;
9146
8396
  exports.inverseFactorNumerator = inverseFactorNumerator;
9147
8397
  exports.isArray = isArray;
9148
8398
  exports.isBoolean = isBoolean;
@@ -9159,28 +8409,34 @@
9159
8409
  exports.lMax = lMax;
9160
8410
  exports.lMin = lMin;
9161
8411
  exports.lengthOffset = lengthOffset;
8412
+ exports.loadExtendProperty = loadExtendProperty;
8413
+ exports.loadLazyProperty = loadLazyProperty;
9162
8414
  exports.loadMinIndex = loadMinIndex;
8415
+ exports.loadNestedProperty = loadNestedProperty;
8416
+ exports.loadOptionProperty = loadOptionProperty;
9163
8417
  exports.loadOptions = loadOptions;
9164
8418
  exports.loadParticlesOptions = loadParticlesOptions;
8419
+ exports.loadProperty = loadProperty;
9165
8420
  exports.loadRandomFactor = loadRandomFactor;
8421
+ exports.loadRangeProperty = loadRangeProperty;
9166
8422
  exports.manageListener = manageListener;
9167
- exports.memoize = memoize;
8423
+ exports.maxNits = maxNits;
9168
8424
  exports.midColorValue = midColorValue;
9169
8425
  exports.millisecondsToSeconds = millisecondsToSeconds;
9170
8426
  exports.minCount = minCount;
8427
+ exports.minDistance = minDistance;
9171
8428
  exports.minFpsLimit = minFpsLimit;
9172
8429
  exports.minIndex = minIndex;
9173
8430
  exports.minLimit = minLimit;
8431
+ exports.minRadius = minRadius$1;
9174
8432
  exports.minStrokeWidth = minStrokeWidth;
9175
- exports.minVelocity = minVelocity$5;
8433
+ exports.minVelocity = minVelocity;
9176
8434
  exports.minZ = minZ;
9177
8435
  exports.minimumSize = minimumSize;
9178
8436
  exports.mix = mix;
9179
8437
  exports.none = none;
9180
8438
  exports.one = one;
9181
8439
  exports.originPoint = originPoint;
9182
- exports.paintBase = paintBase;
9183
- exports.paintImage = paintImage;
9184
8440
  exports.parseAlpha = parseAlpha;
9185
8441
  exports.percentDenominator = percentDenominator;
9186
8442
  exports.phaseNumerator = phaseNumerator;
@@ -9198,7 +8454,6 @@
9198
8454
  exports.sMin = sMin;
9199
8455
  exports.sNormalizedOffset = sNormalizedOffset;
9200
8456
  exports.safeDocument = safeDocument;
9201
- exports.safeIntersectionObserver = safeIntersectionObserver;
9202
8457
  exports.safeMatchMedia = safeMatchMedia;
9203
8458
  exports.safeMutationObserver = safeMutationObserver;
9204
8459
  exports.setAnimationFunctions = setAnimationFunctions;
@@ -9214,7 +8469,6 @@
9214
8469
  exports.triple = triple;
9215
8470
  exports.tryCountIncrement = tryCountIncrement;
9216
8471
  exports.tsParticles = tsParticles;
9217
- exports.updateAnimation = updateAnimation;
9218
8472
  exports.updateColor = updateColor;
9219
8473
  exports.updateColorValue = updateColorValue;
9220
8474
  exports.visibilityChangeEvent = visibilityChangeEvent;