@tsparticles/preset-fireworks 4.1.3 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
- /* Preset v4.1.3 */
2
+ /* Preset v4.2.1 */
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", 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, 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, 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", 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, 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, 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
  var MoveDirection;
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
  }
@@ -298,27 +293,6 @@
298
293
  return input.endsWith("%") ? parseFloat(input) / percentDenominator : parseFloat(input);
299
294
  }
300
295
 
301
- var AnimationMode;
302
- (function (AnimationMode) {
303
- AnimationMode["auto"] = "auto";
304
- AnimationMode["increase"] = "increase";
305
- AnimationMode["decrease"] = "decrease";
306
- AnimationMode["random"] = "random";
307
- })(AnimationMode || (AnimationMode = {}));
308
-
309
- var AnimationStatus;
310
- (function (AnimationStatus) {
311
- AnimationStatus["increasing"] = "increasing";
312
- AnimationStatus["decreasing"] = "decreasing";
313
- })(AnimationStatus || (AnimationStatus = {}));
314
-
315
- var DestroyType;
316
- (function (DestroyType) {
317
- DestroyType["none"] = "none";
318
- DestroyType["max"] = "max";
319
- DestroyType["min"] = "min";
320
- })(DestroyType || (DestroyType = {}));
321
-
322
296
  var OutModeDirection;
323
297
  (function (OutModeDirection) {
324
298
  OutModeDirection["bottom"] = "bottom";
@@ -333,67 +307,7 @@
333
307
  PixelMode["percent"] = "percent";
334
308
  })(PixelMode || (PixelMode = {}));
335
309
 
336
- var StartValueType;
337
- (function (StartValueType) {
338
- StartValueType["max"] = "max";
339
- StartValueType["min"] = "min";
340
- StartValueType["random"] = "random";
341
- })(StartValueType || (StartValueType = {}));
342
-
343
310
  const minRadius = 0;
344
- function memoize(fn, options) {
345
- const cache = new Map(), stableStringify = (obj, seen = new WeakSet()) => {
346
- if (obj === null) {
347
- return "null";
348
- }
349
- const t = typeof obj;
350
- if (t === "undefined") {
351
- return "undefined";
352
- }
353
- if (t === "number" || t === "boolean" || t === "string") {
354
- return JSON.stringify(obj);
355
- }
356
- if (t === "function") {
357
- try {
358
- const fn = obj;
359
- return fn.toString();
360
- }
361
- catch {
362
- return '"[Function]"';
363
- }
364
- }
365
- if (t === "symbol") {
366
- try {
367
- return obj.toString();
368
- }
369
- catch {
370
- return '"[Symbol]"';
371
- }
372
- }
373
- if (Array.isArray(obj)) {
374
- return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
375
- }
376
- if (seen.has(obj)) {
377
- return '"[Circular]"';
378
- }
379
- seen.add(obj);
380
- const keys = Object.keys(obj).sort();
381
- return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
382
- }, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (defaultKeyer(args));
383
- return (...args) => {
384
- const key = makeKey(args), now = Date.now(), entry = cache.get(key);
385
- if (entry !== undefined) {
386
- {
387
- cache.delete(key);
388
- cache.set(key, { value: entry.value, ts: entry.ts });
389
- return entry.value;
390
- }
391
- }
392
- const result = fn(...args);
393
- cache.set(key, { value: result, ts: now });
394
- return result;
395
- };
396
- }
397
311
  function hasMatchMedia() {
398
312
  return typeof matchMedia !== "undefined";
399
313
  }
@@ -415,11 +329,8 @@
415
329
  function isInArray(value, array) {
416
330
  return value === array || (isArray(array) && array.includes(value));
417
331
  }
418
- function arrayRandomIndex(array) {
419
- return Math.floor(getRandom() * array.length);
420
- }
421
332
  function itemFromArray(array, index, useIndex = true) {
422
- return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
333
+ return array[index !== undefined && useIndex ? index % array.length : Math.floor(getRandom() * array.length)];
423
334
  }
424
335
  function isPointInside(point, size, offset, radius, direction) {
425
336
  return areBoundsInside(calculateBounds(point, radius ?? minRadius), size, offset, direction);
@@ -503,56 +414,6 @@
503
414
  function itemFromSingleOrMultiple(obj, index, useIndex) {
504
415
  return isArray(obj) ? itemFromArray(obj, index, useIndex) : obj;
505
416
  }
506
- function initParticleNumericAnimationValue(options, pxRatio) {
507
- const valueRange = options.value, animationOptions = options.animation, res = {
508
- delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
509
- enable: animationOptions.enable,
510
- value: getRangeValue(options.value) * pxRatio,
511
- max: getRangeMax(valueRange) * pxRatio,
512
- min: getRangeMin(valueRange) * pxRatio,
513
- loops: 0,
514
- maxLoops: getRangeValue(animationOptions.count),
515
- time: 0,
516
- }, decayOffset = 1;
517
- if (animationOptions.enable) {
518
- res.decay = decayOffset - getRangeValue(animationOptions.decay);
519
- switch (animationOptions.mode) {
520
- case AnimationMode.increase:
521
- res.status = AnimationStatus.increasing;
522
- break;
523
- case AnimationMode.decrease:
524
- res.status = AnimationStatus.decreasing;
525
- break;
526
- case AnimationMode.random:
527
- res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
528
- break;
529
- }
530
- const autoStatus = animationOptions.mode === AnimationMode.auto;
531
- switch (animationOptions.startValue) {
532
- case StartValueType.min:
533
- res.value = res.min;
534
- if (autoStatus) {
535
- res.status = AnimationStatus.increasing;
536
- }
537
- break;
538
- case StartValueType.max:
539
- res.value = res.max;
540
- if (autoStatus) {
541
- res.status = AnimationStatus.decreasing;
542
- }
543
- break;
544
- case StartValueType.random:
545
- default:
546
- res.value = randomInRangeValue(res);
547
- if (autoStatus) {
548
- res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
549
- }
550
- break;
551
- }
552
- }
553
- res.initialValue = res.value;
554
- return res;
555
- }
556
417
  function getPositionOrSize(positionOrSize, canvasSize) {
557
418
  const isPercent = positionOrSize.mode === PixelMode.percent;
558
419
  if (!isPercent) {
@@ -576,80 +437,6 @@
576
437
  function getPosition(position, canvasSize) {
577
438
  return getPositionOrSize(position, canvasSize);
578
439
  }
579
- function getSize(size, canvasSize) {
580
- return getPositionOrSize(size, canvasSize);
581
- }
582
- function checkDestroy(particle, destroyType, value, minValue, maxValue) {
583
- switch (destroyType) {
584
- case DestroyType.max:
585
- if (value >= maxValue) {
586
- particle.destroy();
587
- }
588
- break;
589
- case DestroyType.min:
590
- if (value <= minValue) {
591
- particle.destroy();
592
- }
593
- break;
594
- }
595
- }
596
- function updateAnimation(particle, data, changeDirection, destroyType, delta) {
597
- const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
598
- if (particle.destroyed ||
599
- !data.enable ||
600
- ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
601
- return;
602
- }
603
- const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
604
- data.time ??= 0;
605
- if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
606
- data.time += delta.value;
607
- }
608
- if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
609
- return;
610
- }
611
- switch (data.status) {
612
- case AnimationStatus.increasing:
613
- data.value += velocity;
614
- break;
615
- case AnimationStatus.decreasing:
616
- data.value -= velocity;
617
- break;
618
- }
619
- if (data.velocity && decay !== identity) {
620
- data.velocity *= decay;
621
- }
622
- switch (data.status) {
623
- case AnimationStatus.increasing:
624
- if (data.value >= maxValue) {
625
- if (changeDirection) {
626
- data.status = AnimationStatus.decreasing;
627
- }
628
- else {
629
- data.value -= maxValue;
630
- }
631
- data.loops ??= minLoops;
632
- data.loops++;
633
- }
634
- break;
635
- case AnimationStatus.decreasing:
636
- if (data.value <= minValue) {
637
- if (changeDirection) {
638
- data.status = AnimationStatus.increasing;
639
- }
640
- else {
641
- data.value += maxValue;
642
- }
643
- data.loops ??= minLoops;
644
- data.loops++;
645
- }
646
- break;
647
- }
648
- checkDestroy(particle, destroyType, data.value, minValue, maxValue);
649
- if (!particle.destroyed) {
650
- data.value = clamp(data.value, minValue, maxValue);
651
- }
652
- }
653
440
  function cloneStyle(style) {
654
441
  const clonedStyle = safeDocument().createElement("div").style;
655
442
  for (const key in style) {
@@ -671,30 +458,34 @@
671
458
  }
672
459
  return clonedStyle;
673
460
  }
674
- function computeFullScreenStyle(zIndex) {
675
- const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
676
- width: "100%",
677
- height: "100%",
678
- margin: "0",
679
- padding: "0",
680
- borderWidth: "0",
681
- position: "fixed",
682
- zIndex: zIndex.toString(radix),
683
- "z-index": zIndex.toString(radix),
684
- top: "0",
685
- left: "0",
686
- "pointer-events": "none",
687
- };
688
- for (const key in style) {
689
- const value = style[key];
690
- if (value === undefined) {
691
- continue;
461
+ let _cachedZIndex, _cachedStyle;
462
+ function getFullScreenStyle(zIndex) {
463
+ if (_cachedZIndex !== zIndex || !_cachedStyle) {
464
+ _cachedZIndex = zIndex;
465
+ const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
466
+ width: "100%",
467
+ height: "100%",
468
+ margin: "0",
469
+ padding: "0",
470
+ borderWidth: "0",
471
+ position: "fixed",
472
+ zIndex: zIndex.toString(radix),
473
+ "z-index": zIndex.toString(radix),
474
+ top: "0",
475
+ left: "0",
476
+ "pointer-events": "none",
477
+ };
478
+ for (const key in style) {
479
+ const value = style[key];
480
+ if (value === undefined) {
481
+ continue;
482
+ }
483
+ fullScreenStyle.setProperty(key, value);
692
484
  }
693
- fullScreenStyle.setProperty(key, value);
485
+ _cachedStyle = fullScreenStyle;
694
486
  }
695
- return fullScreenStyle;
487
+ return _cachedStyle;
696
488
  }
697
- const getFullScreenStyle = memoize(computeFullScreenStyle);
698
489
  function manageListener(element, event, handler, add, options) {
699
490
  if (add) {
700
491
  let addOptions = { passive: true };
@@ -1021,7 +812,7 @@
1021
812
  return this.#domArray;
1022
813
  }
1023
814
  get version() {
1024
- return "4.1.3";
815
+ return "4.2.1";
1025
816
  }
1026
817
  addEventListener(type, listener) {
1027
818
  this.#eventDispatcher.addEventListener(type, listener);
@@ -1191,6 +982,14 @@
1191
982
  RotateDirection["random"] = "random";
1192
983
  })(RotateDirection || (RotateDirection = {}));
1193
984
 
985
+ var AnimationMode;
986
+ (function (AnimationMode) {
987
+ AnimationMode["auto"] = "auto";
988
+ AnimationMode["increase"] = "increase";
989
+ AnimationMode["decrease"] = "decrease";
990
+ AnimationMode["random"] = "random";
991
+ })(AnimationMode || (AnimationMode = {}));
992
+
1194
993
  var LimitMode;
1195
994
  (function (LimitMode) {
1196
995
  LimitMode["delete"] = "delete";
@@ -1212,6 +1011,13 @@
1212
1011
  AlterType["enlighten"] = "enlighten";
1213
1012
  })(AlterType || (AlterType = {}));
1214
1013
 
1014
+ var DestroyType;
1015
+ (function (DestroyType) {
1016
+ DestroyType["none"] = "none";
1017
+ DestroyType["max"] = "max";
1018
+ DestroyType["min"] = "min";
1019
+ })(DestroyType || (DestroyType = {}));
1020
+
1215
1021
  var GradientType;
1216
1022
  (function (GradientType) {
1217
1023
  GradientType["linear"] = "linear";
@@ -1226,160 +1032,121 @@
1226
1032
  ParticleOutType["outside"] = "outside";
1227
1033
  })(ParticleOutType || (ParticleOutType = {}));
1228
1034
 
1229
- var EasingType;
1230
- (function (EasingType) {
1231
- EasingType["easeInBack"] = "ease-in-back";
1232
- EasingType["easeInBounce"] = "ease-in-bounce";
1233
- EasingType["easeInCirc"] = "ease-in-circ";
1234
- EasingType["easeInCubic"] = "ease-in-cubic";
1235
- EasingType["easeInElastic"] = "ease-in-elastic";
1236
- EasingType["easeInExpo"] = "ease-in-expo";
1237
- EasingType["easeInGaussian"] = "ease-in-gaussian";
1238
- EasingType["easeInLinear"] = "ease-in-linear";
1239
- EasingType["easeInQuad"] = "ease-in-quad";
1240
- EasingType["easeInQuart"] = "ease-in-quart";
1241
- EasingType["easeInQuint"] = "ease-in-quint";
1242
- EasingType["easeInSigmoid"] = "ease-in-sigmoid";
1243
- EasingType["easeInSine"] = "ease-in-sine";
1244
- EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
1245
- EasingType["easeOutBack"] = "ease-out-back";
1246
- EasingType["easeOutBounce"] = "ease-out-bounce";
1247
- EasingType["easeOutCirc"] = "ease-out-circ";
1248
- EasingType["easeOutCubic"] = "ease-out-cubic";
1249
- EasingType["easeOutElastic"] = "ease-out-elastic";
1250
- EasingType["easeOutExpo"] = "ease-out-expo";
1251
- EasingType["easeOutGaussian"] = "ease-out-gaussian";
1252
- EasingType["easeOutLinear"] = "ease-out-linear";
1253
- EasingType["easeOutQuad"] = "ease-out-quad";
1254
- EasingType["easeOutQuart"] = "ease-out-quart";
1255
- EasingType["easeOutQuint"] = "ease-out-quint";
1256
- EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
1257
- EasingType["easeOutSine"] = "ease-out-sine";
1258
- EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
1259
- EasingType["easeInOutBack"] = "ease-in-out-back";
1260
- EasingType["easeInOutBounce"] = "ease-in-out-bounce";
1261
- EasingType["easeInOutCirc"] = "ease-in-out-circ";
1262
- EasingType["easeInOutCubic"] = "ease-in-out-cubic";
1263
- EasingType["easeInOutElastic"] = "ease-in-out-elastic";
1264
- EasingType["easeInOutExpo"] = "ease-in-out-expo";
1265
- EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
1266
- EasingType["easeInOutLinear"] = "ease-in-out-linear";
1267
- EasingType["easeInOutQuad"] = "ease-in-out-quad";
1268
- EasingType["easeInOutQuart"] = "ease-in-out-quart";
1269
- EasingType["easeInOutQuint"] = "ease-in-out-quint";
1270
- EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
1271
- EasingType["easeInOutSine"] = "ease-in-out-sine";
1272
- EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
1273
- })(EasingType || (EasingType = {}));
1274
-
1275
- class AnimationOptions {
1276
- count;
1277
- decay;
1278
- delay;
1279
- enable;
1280
- speed;
1281
- sync;
1282
- constructor() {
1283
- this.count = 0;
1284
- this.enable = false;
1285
- this.speed = 1;
1286
- this.decay = 0;
1287
- this.delay = 0;
1288
- this.sync = false;
1289
- }
1035
+ var StartValueType;
1036
+ (function (StartValueType) {
1037
+ StartValueType["max"] = "max";
1038
+ StartValueType["min"] = "min";
1039
+ StartValueType["random"] = "random";
1040
+ })(StartValueType || (StartValueType = {}));
1041
+
1042
+ var AnimationStatus;
1043
+ (function (AnimationStatus) {
1044
+ AnimationStatus["increasing"] = "increasing";
1045
+ AnimationStatus["decreasing"] = "decreasing";
1046
+ })(AnimationStatus || (AnimationStatus = {}));
1047
+
1048
+ class OptionLoader {
1290
1049
  load(data) {
1291
1050
  if (isNull(data)) {
1292
1051
  return;
1293
1052
  }
1294
- if (data.count !== undefined) {
1295
- this.count = setRangeValue(data.count);
1296
- }
1297
- if (data.enable !== undefined) {
1298
- this.enable = data.enable;
1299
- }
1300
- if (data.speed !== undefined) {
1301
- this.speed = setRangeValue(data.speed);
1302
- }
1303
- if (data.decay !== undefined) {
1304
- this.decay = setRangeValue(data.decay);
1305
- }
1306
- if (data.delay !== undefined) {
1307
- this.delay = setRangeValue(data.delay);
1308
- }
1309
- if (data.sync !== undefined) {
1310
- this.sync = data.sync;
1311
- }
1053
+ this.doLoad(data);
1312
1054
  }
1313
1055
  }
1314
- class RangedAnimationOptions extends AnimationOptions {
1315
- mode;
1316
- startValue;
1317
- constructor() {
1318
- super();
1319
- this.mode = AnimationMode.auto;
1320
- this.startValue = StartValueType.random;
1056
+ function loadOptions(options, ...sourceOptionsArr) {
1057
+ for (const sourceOptions of sourceOptionsArr) {
1058
+ options.load(sourceOptions);
1321
1059
  }
1322
- load(data) {
1323
- super.load(data);
1324
- if (isNull(data)) {
1325
- return;
1326
- }
1327
- if (data.mode !== undefined) {
1328
- this.mode = data.mode;
1329
- }
1330
- if (data.startValue !== undefined) {
1331
- this.startValue = data.startValue;
1332
- }
1060
+ }
1061
+
1062
+ function loadProperty(obj, key, value) {
1063
+ if (value !== undefined) {
1064
+ obj[key] = value;
1065
+ }
1066
+ }
1067
+ function loadRangeProperty(obj, key, value) {
1068
+ if (value !== undefined) {
1069
+ obj[key] = setRangeValue(value);
1070
+ }
1071
+ }
1072
+ function loadNestedProperty(obj, key, value) {
1073
+ if (value !== undefined) {
1074
+ obj[key].load(value);
1075
+ }
1076
+ }
1077
+ function loadLazyProperty(obj, key, value, factory) {
1078
+ if (value !== undefined) {
1079
+ const objRecord = obj;
1080
+ objRecord[key] ??= factory();
1081
+ objRecord[key].load(value);
1082
+ }
1083
+ }
1084
+ function loadOptionProperty(obj, key, optionClass, ...sources) {
1085
+ const objRecord = obj;
1086
+ objRecord[key] ??= new optionClass();
1087
+ const target = objRecord[key];
1088
+ for (const source of sources) {
1089
+ target.load(source?.[key]);
1090
+ }
1091
+ }
1092
+
1093
+ class AnimationOptions extends OptionLoader {
1094
+ count = 0;
1095
+ decay = 0;
1096
+ delay = 0;
1097
+ enable = false;
1098
+ speed = 1;
1099
+ sync = false;
1100
+ doLoad(data) {
1101
+ loadRangeProperty(this, "count", data.count);
1102
+ loadProperty(this, "enable", data.enable);
1103
+ loadRangeProperty(this, "speed", data.speed);
1104
+ loadRangeProperty(this, "decay", data.decay);
1105
+ loadRangeProperty(this, "delay", data.delay);
1106
+ loadProperty(this, "sync", data.sync);
1107
+ }
1108
+ }
1109
+ class RangedAnimationOptions extends AnimationOptions {
1110
+ mode = AnimationMode.auto;
1111
+ startValue = StartValueType.random;
1112
+ doLoad(data) {
1113
+ super.doLoad(data);
1114
+ loadProperty(this, "mode", data.mode);
1115
+ loadProperty(this, "startValue", data.startValue);
1333
1116
  }
1334
1117
  }
1335
1118
 
1336
1119
  class ColorAnimation extends AnimationOptions {
1337
1120
  max;
1338
1121
  min;
1339
- offset;
1122
+ offset = 0;
1123
+ sync = true;
1340
1124
  constructor(min, max) {
1341
1125
  super();
1342
1126
  this.min = min;
1343
1127
  this.max = max;
1344
- this.offset = 0;
1345
- this.sync = true;
1346
1128
  }
1347
- load(data) {
1348
- super.load(data);
1349
- if (isNull(data)) {
1350
- return;
1351
- }
1352
- if (data.max !== undefined) {
1353
- this.max = data.max;
1354
- }
1355
- if (data.min !== undefined) {
1356
- this.min = data.min;
1357
- }
1358
- if (data.offset !== undefined) {
1359
- this.offset = setRangeValue(data.offset);
1360
- }
1129
+ doLoad(data) {
1130
+ super.doLoad(data);
1131
+ loadProperty(this, "max", data.max);
1132
+ loadProperty(this, "min", data.min);
1133
+ loadRangeProperty(this, "offset", data.offset);
1361
1134
  }
1362
1135
  }
1363
1136
 
1364
- class HslAnimation {
1137
+ class HslAnimation extends OptionLoader {
1365
1138
  h = new ColorAnimation(hMin, hMax);
1366
1139
  l = new ColorAnimation(lMin, lMax);
1367
1140
  s = new ColorAnimation(sMin, sMax);
1368
- load(data) {
1369
- if (isNull(data)) {
1370
- return;
1371
- }
1141
+ doLoad(data) {
1372
1142
  this.h.load(data.h);
1373
1143
  this.s.load(data.s);
1374
1144
  this.l.load(data.l);
1375
1145
  }
1376
1146
  }
1377
1147
 
1378
- class OptionsColor {
1379
- value;
1380
- constructor() {
1381
- this.value = "";
1382
- }
1148
+ class OptionsColor extends OptionLoader {
1149
+ value = "";
1383
1150
  static create(source, data) {
1384
1151
  const color = new OptionsColor();
1385
1152
  color.load(source);
@@ -1393,10 +1160,7 @@
1393
1160
  }
1394
1161
  return color;
1395
1162
  }
1396
- load(data) {
1397
- if (isNull(data)) {
1398
- return;
1399
- }
1163
+ doLoad(data) {
1400
1164
  if (!isNull(data.value)) {
1401
1165
  this.value = data.value;
1402
1166
  }
@@ -1404,11 +1168,7 @@
1404
1168
  }
1405
1169
 
1406
1170
  class AnimatableColor extends OptionsColor {
1407
- animation;
1408
- constructor() {
1409
- super();
1410
- this.animation = new HslAnimation();
1411
- }
1171
+ animation = new HslAnimation();
1412
1172
  static create(source, data) {
1413
1173
  const color = new AnimatableColor();
1414
1174
  color.load(source);
@@ -1422,11 +1182,8 @@
1422
1182
  }
1423
1183
  return color;
1424
1184
  }
1425
- load(data) {
1426
- super.load(data);
1427
- if (isNull(data)) {
1428
- return;
1429
- }
1185
+ doLoad(data) {
1186
+ super.doLoad(data);
1430
1187
  const colorAnimation = data.animation;
1431
1188
  if (colorAnimation !== undefined) {
1432
1189
  if (colorAnimation.enable === undefined) {
@@ -1439,100 +1196,53 @@
1439
1196
  }
1440
1197
  }
1441
1198
 
1442
- class Background {
1199
+ class Background extends OptionLoader {
1443
1200
  color;
1444
- image;
1445
- opacity;
1446
- position;
1447
- repeat;
1448
- size;
1201
+ image = "";
1202
+ opacity = 1;
1203
+ position = "";
1204
+ repeat = "";
1205
+ size = "";
1449
1206
  constructor() {
1207
+ super();
1450
1208
  this.color = new OptionsColor();
1451
1209
  this.color.value = "";
1452
- this.image = "";
1453
- this.position = "";
1454
- this.repeat = "";
1455
- this.size = "";
1456
- this.opacity = 1;
1457
1210
  }
1458
- load(data) {
1459
- if (isNull(data)) {
1460
- return;
1461
- }
1211
+ doLoad(data) {
1462
1212
  if (data.color !== undefined) {
1463
1213
  this.color = OptionsColor.create(this.color, data.color);
1464
1214
  }
1465
- if (data.image !== undefined) {
1466
- this.image = data.image;
1467
- }
1468
- if (data.position !== undefined) {
1469
- this.position = data.position;
1470
- }
1471
- if (data.repeat !== undefined) {
1472
- this.repeat = data.repeat;
1473
- }
1474
- if (data.size !== undefined) {
1475
- this.size = data.size;
1476
- }
1477
- if (data.opacity !== undefined) {
1478
- this.opacity = data.opacity;
1479
- }
1215
+ loadProperty(this, "image", data.image);
1216
+ loadProperty(this, "position", data.position);
1217
+ loadProperty(this, "repeat", data.repeat);
1218
+ loadProperty(this, "size", data.size);
1219
+ loadProperty(this, "opacity", data.opacity);
1480
1220
  }
1481
1221
  }
1482
1222
 
1483
- class FullScreen {
1484
- enable;
1485
- zIndex;
1486
- constructor() {
1487
- this.enable = true;
1488
- this.zIndex = 0;
1489
- }
1490
- load(data) {
1491
- if (isNull(data)) {
1492
- return;
1493
- }
1494
- if (data.enable !== undefined) {
1495
- this.enable = data.enable;
1496
- }
1497
- if (data.zIndex !== undefined) {
1498
- this.zIndex = data.zIndex;
1499
- }
1223
+ class FullScreen extends OptionLoader {
1224
+ enable = true;
1225
+ zIndex = 0;
1226
+ doLoad(data) {
1227
+ loadProperty(this, "enable", data.enable);
1228
+ loadProperty(this, "zIndex", data.zIndex);
1500
1229
  }
1501
1230
  }
1502
1231
 
1503
- class ResizeEvent {
1504
- delay;
1505
- enable;
1506
- constructor() {
1507
- this.delay = 0.5;
1508
- this.enable = true;
1509
- }
1510
- load(data) {
1511
- if (isNull(data)) {
1512
- return;
1513
- }
1514
- if (data.delay !== undefined) {
1515
- this.delay = data.delay;
1516
- }
1517
- if (data.enable !== undefined) {
1518
- this.enable = data.enable;
1519
- }
1232
+ class ResizeEvent extends OptionLoader {
1233
+ delay = 0.5;
1234
+ enable = true;
1235
+ doLoad(data) {
1236
+ loadProperty(this, "delay", data.delay);
1237
+ loadProperty(this, "enable", data.enable);
1520
1238
  }
1521
1239
  }
1522
1240
 
1523
- class Effect {
1524
- close;
1525
- options;
1526
- type;
1527
- constructor() {
1528
- this.close = true;
1529
- this.options = {};
1530
- this.type = [];
1531
- }
1532
- load(data) {
1533
- if (isNull(data)) {
1534
- return;
1535
- }
1241
+ class Effect extends OptionLoader {
1242
+ close = true;
1243
+ options = {};
1244
+ type = [];
1245
+ doLoad(data) {
1536
1246
  const options = data.options;
1537
1247
  if (options !== undefined) {
1538
1248
  for (const effect in options) {
@@ -1542,128 +1252,62 @@
1542
1252
  }
1543
1253
  }
1544
1254
  }
1545
- if (data.close !== undefined) {
1546
- this.close = data.close;
1547
- }
1548
- if (data.type !== undefined) {
1549
- this.type = data.type;
1550
- }
1255
+ loadProperty(this, "close", data.close);
1256
+ loadProperty(this, "type", data.type);
1551
1257
  }
1552
1258
  }
1553
1259
 
1554
- class Fill {
1260
+ class Fill extends OptionLoader {
1555
1261
  color;
1556
- enable;
1557
- opacity;
1558
- constructor() {
1559
- this.enable = true;
1560
- this.opacity = 1;
1561
- }
1562
- load(data) {
1563
- if (isNull(data)) {
1564
- return;
1565
- }
1262
+ enable = true;
1263
+ opacity = 1;
1264
+ doLoad(data) {
1566
1265
  if (data.color !== undefined) {
1567
1266
  this.color = AnimatableColor.create(this.color, data.color);
1568
1267
  }
1569
- if (data.enable !== undefined) {
1570
- this.enable = data.enable;
1571
- }
1572
- if (data.opacity !== undefined) {
1573
- this.opacity = setRangeValue(data.opacity);
1574
- }
1268
+ loadProperty(this, "enable", data.enable);
1269
+ loadRangeProperty(this, "opacity", data.opacity);
1575
1270
  }
1576
1271
  }
1577
1272
 
1578
- class MoveAngle {
1579
- offset;
1580
- value;
1581
- constructor() {
1582
- this.offset = 0;
1583
- this.value = 90;
1584
- }
1585
- load(data) {
1586
- if (isNull(data)) {
1587
- return;
1588
- }
1589
- if (data.offset !== undefined) {
1590
- this.offset = setRangeValue(data.offset);
1591
- }
1592
- if (data.value !== undefined) {
1593
- this.value = setRangeValue(data.value);
1594
- }
1273
+ class MoveAngle extends OptionLoader {
1274
+ offset = 0;
1275
+ value = 90;
1276
+ doLoad(data) {
1277
+ loadRangeProperty(this, "offset", data.offset);
1278
+ loadRangeProperty(this, "value", data.value);
1595
1279
  }
1596
1280
  }
1597
1281
 
1598
- class MoveCenter {
1599
- mode;
1600
- radius;
1601
- x;
1602
- y;
1603
- constructor() {
1604
- this.x = 50;
1605
- this.y = 50;
1606
- this.mode = PixelMode.percent;
1607
- this.radius = 0;
1608
- }
1609
- load(data) {
1610
- if (isNull(data)) {
1611
- return;
1612
- }
1613
- if (data.x !== undefined) {
1614
- this.x = data.x;
1615
- }
1616
- if (data.y !== undefined) {
1617
- this.y = data.y;
1618
- }
1619
- if (data.mode !== undefined) {
1620
- this.mode = data.mode;
1621
- }
1622
- if (data.radius !== undefined) {
1623
- this.radius = data.radius;
1624
- }
1282
+ class MoveCenter extends OptionLoader {
1283
+ mode = PixelMode.percent;
1284
+ radius = 0;
1285
+ x = 50;
1286
+ y = 50;
1287
+ doLoad(data) {
1288
+ loadProperty(this, "x", data.x);
1289
+ loadProperty(this, "y", data.y);
1290
+ loadProperty(this, "mode", data.mode);
1291
+ loadProperty(this, "radius", data.radius);
1625
1292
  }
1626
1293
  }
1627
1294
 
1628
- class MoveGravity {
1629
- acceleration;
1630
- enable;
1631
- inverse;
1632
- maxSpeed;
1633
- constructor() {
1634
- this.acceleration = 9.81;
1635
- this.enable = false;
1636
- this.inverse = false;
1637
- this.maxSpeed = 50;
1638
- }
1639
- load(data) {
1640
- if (isNull(data)) {
1641
- return;
1642
- }
1643
- if (data.acceleration !== undefined) {
1644
- this.acceleration = setRangeValue(data.acceleration);
1645
- }
1646
- if (data.enable !== undefined) {
1647
- this.enable = data.enable;
1648
- }
1649
- if (data.inverse !== undefined) {
1650
- this.inverse = data.inverse;
1651
- }
1652
- if (data.maxSpeed !== undefined) {
1653
- this.maxSpeed = setRangeValue(data.maxSpeed);
1654
- }
1295
+ class MoveGravity extends OptionLoader {
1296
+ acceleration = 9.81;
1297
+ enable = false;
1298
+ inverse = false;
1299
+ maxSpeed = 50;
1300
+ doLoad(data) {
1301
+ loadRangeProperty(this, "acceleration", data.acceleration);
1302
+ loadProperty(this, "enable", data.enable);
1303
+ loadProperty(this, "inverse", data.inverse);
1304
+ loadRangeProperty(this, "maxSpeed", data.maxSpeed);
1655
1305
  }
1656
1306
  }
1657
1307
 
1658
- class ValueWithRandom {
1659
- value;
1660
- constructor() {
1661
- this.value = 0;
1662
- }
1663
- load(data) {
1664
- if (isNull(data)) {
1665
- return;
1666
- }
1308
+ class ValueWithRandom extends OptionLoader {
1309
+ value = 0;
1310
+ doLoad(data) {
1667
1311
  if (!isNull(data.value)) {
1668
1312
  this.value = setRangeValue(data.value);
1669
1313
  }
@@ -1671,51 +1315,25 @@
1671
1315
  }
1672
1316
  class AnimationValueWithRandom extends ValueWithRandom {
1673
1317
  animation = new AnimationOptions();
1674
- load(data) {
1675
- super.load(data);
1676
- if (isNull(data)) {
1677
- return;
1678
- }
1679
- const animation = data.animation;
1680
- if (animation !== undefined) {
1681
- this.animation.load(animation);
1682
- }
1318
+ doLoad(data) {
1319
+ super.doLoad(data);
1320
+ loadNestedProperty(this, "animation", data.animation);
1683
1321
  }
1684
1322
  }
1685
1323
  class RangedAnimationValueWithRandom extends AnimationValueWithRandom {
1686
- animation;
1687
- constructor() {
1688
- super();
1689
- this.animation = new RangedAnimationOptions();
1690
- }
1691
- load(data) {
1692
- super.load(data);
1693
- }
1324
+ animation = new RangedAnimationOptions();
1694
1325
  }
1695
1326
 
1696
- class MovePath {
1697
- clamp;
1698
- delay;
1699
- enable;
1327
+ class MovePath extends OptionLoader {
1328
+ clamp = true;
1329
+ delay = new ValueWithRandom();
1330
+ enable = false;
1700
1331
  generator;
1701
- options;
1702
- constructor() {
1703
- this.clamp = true;
1704
- this.delay = new ValueWithRandom();
1705
- this.enable = false;
1706
- this.options = {};
1707
- }
1708
- load(data) {
1709
- if (isNull(data)) {
1710
- return;
1711
- }
1712
- if (data.clamp !== undefined) {
1713
- this.clamp = data.clamp;
1714
- }
1332
+ options = {};
1333
+ doLoad(data) {
1334
+ loadProperty(this, "clamp", data.clamp);
1715
1335
  this.delay.load(data.delay);
1716
- if (data.enable !== undefined) {
1717
- this.enable = data.enable;
1718
- }
1336
+ loadProperty(this, "enable", data.enable);
1719
1337
  this.generator = data.generator;
1720
1338
  if (data.options) {
1721
1339
  this.options = deepExtend(this.options, data.options);
@@ -1723,19 +1341,13 @@
1723
1341
  }
1724
1342
  }
1725
1343
 
1726
- class OutModes {
1344
+ class OutModes extends OptionLoader {
1727
1345
  bottom;
1728
- default;
1346
+ default = OutMode.out;
1729
1347
  left;
1730
1348
  right;
1731
1349
  top;
1732
- constructor() {
1733
- this.default = OutMode.out;
1734
- }
1735
- load(data) {
1736
- if (isNull(data)) {
1737
- return;
1738
- }
1350
+ doLoad(data) {
1739
1351
  if (data.default !== undefined) {
1740
1352
  this.default = data.default;
1741
1353
  }
@@ -1746,79 +1358,42 @@
1746
1358
  }
1747
1359
  }
1748
1360
 
1749
- class Spin {
1750
- acceleration;
1751
- enable;
1361
+ class Spin extends OptionLoader {
1362
+ acceleration = 0;
1363
+ enable = false;
1752
1364
  position;
1753
- constructor() {
1754
- this.acceleration = 0;
1755
- this.enable = false;
1756
- }
1757
- load(data) {
1758
- if (isNull(data)) {
1759
- return;
1760
- }
1761
- if (data.acceleration !== undefined) {
1762
- this.acceleration = setRangeValue(data.acceleration);
1763
- }
1764
- if (data.enable !== undefined) {
1765
- this.enable = data.enable;
1766
- }
1365
+ doLoad(data) {
1366
+ loadRangeProperty(this, "acceleration", data.acceleration);
1367
+ loadProperty(this, "enable", data.enable);
1767
1368
  if (data.position) {
1768
1369
  this.position = deepExtend({}, data.position);
1769
1370
  }
1770
1371
  }
1771
1372
  }
1772
1373
 
1773
- class Move {
1774
- angle;
1775
- center;
1776
- decay;
1777
- direction;
1778
- distance;
1779
- drift;
1780
- enable;
1781
- gravity;
1782
- outModes;
1783
- path;
1784
- random;
1785
- size;
1786
- speed;
1787
- spin;
1788
- straight;
1789
- vibrate;
1790
- warp;
1791
- constructor() {
1792
- this.angle = new MoveAngle();
1793
- this.center = new MoveCenter();
1794
- this.decay = 0;
1795
- this.distance = {};
1796
- this.direction = MoveDirection.none;
1797
- this.drift = 0;
1798
- this.enable = false;
1799
- this.gravity = new MoveGravity();
1800
- this.path = new MovePath();
1801
- this.outModes = new OutModes();
1802
- this.random = false;
1803
- this.size = false;
1804
- this.speed = 2;
1805
- this.spin = new Spin();
1806
- this.straight = false;
1807
- this.vibrate = false;
1808
- this.warp = false;
1809
- }
1810
- load(data) {
1811
- if (isNull(data)) {
1812
- return;
1813
- }
1374
+ class Move extends OptionLoader {
1375
+ angle = new MoveAngle();
1376
+ center = new MoveCenter();
1377
+ decay = 0;
1378
+ direction = MoveDirection.none;
1379
+ distance = {};
1380
+ drift = 0;
1381
+ enable = false;
1382
+ gravity = new MoveGravity();
1383
+ outModes = new OutModes();
1384
+ path = new MovePath();
1385
+ random = false;
1386
+ size = false;
1387
+ speed = 2;
1388
+ spin = new Spin();
1389
+ straight = false;
1390
+ vibrate = false;
1391
+ warp = false;
1392
+ doLoad(data) {
1814
1393
  this.angle.load(isNumber(data.angle) ? { value: data.angle } : data.angle);
1815
1394
  this.center.load(data.center);
1816
- if (data.decay !== undefined) {
1817
- this.decay = setRangeValue(data.decay);
1818
- }
1819
- if (data.direction !== undefined) {
1820
- this.direction = data.direction;
1821
- }
1395
+ loadRangeProperty(this, "decay", data.decay);
1396
+ loadProperty(this, "direction", data.direction);
1822
1397
  if (data.distance !== undefined) {
1823
1398
  this.distance = isNumber(data.distance)
1824
1399
  ? {
@@ -1827,12 +1402,8 @@
1827
1402
  }
1828
1403
  : { ...data.distance };
1829
1404
  }
1830
- if (data.drift !== undefined) {
1831
- this.drift = setRangeValue(data.drift);
1832
- }
1833
- if (data.enable !== undefined) {
1834
- this.enable = data.enable;
1835
- }
1405
+ loadRangeProperty(this, "drift", data.drift);
1406
+ loadProperty(this, "enable", data.enable);
1836
1407
  this.gravity.load(data.gravity);
1837
1408
  const outModes = data.outModes;
1838
1409
  if (outModes !== undefined) {
@@ -1846,177 +1417,91 @@
1846
1417
  }
1847
1418
  }
1848
1419
  this.path.load(data.path);
1849
- if (data.random !== undefined) {
1850
- this.random = data.random;
1851
- }
1852
- if (data.size !== undefined) {
1853
- this.size = data.size;
1854
- }
1855
- if (data.speed !== undefined) {
1856
- this.speed = setRangeValue(data.speed);
1857
- }
1420
+ loadProperty(this, "random", data.random);
1421
+ loadProperty(this, "size", data.size);
1422
+ loadRangeProperty(this, "speed", data.speed);
1858
1423
  this.spin.load(data.spin);
1859
- if (data.straight !== undefined) {
1860
- this.straight = data.straight;
1861
- }
1862
- if (data.vibrate !== undefined) {
1863
- this.vibrate = data.vibrate;
1864
- }
1865
- if (data.warp !== undefined) {
1866
- this.warp = data.warp;
1867
- }
1424
+ loadProperty(this, "straight", data.straight);
1425
+ loadProperty(this, "vibrate", data.vibrate);
1426
+ loadProperty(this, "warp", data.warp);
1868
1427
  }
1869
1428
  }
1870
1429
 
1871
- class Stroke {
1430
+ class Stroke extends OptionLoader {
1872
1431
  color;
1873
1432
  opacity;
1874
- width;
1875
- constructor() {
1876
- this.width = 0;
1877
- }
1878
- load(data) {
1879
- if (isNull(data)) {
1880
- return;
1881
- }
1433
+ width = 0;
1434
+ doLoad(data) {
1882
1435
  if (data.color !== undefined) {
1883
1436
  this.color = AnimatableColor.create(this.color, data.color);
1884
1437
  }
1885
- if (data.width !== undefined) {
1886
- this.width = setRangeValue(data.width);
1887
- }
1888
- if (data.opacity !== undefined) {
1889
- this.opacity = setRangeValue(data.opacity);
1890
- }
1438
+ loadRangeProperty(this, "width", data.width);
1439
+ loadRangeProperty(this, "opacity", data.opacity);
1891
1440
  }
1892
1441
  }
1893
1442
 
1894
- class Paint {
1443
+ class Paint extends OptionLoader {
1895
1444
  color;
1896
1445
  fill;
1897
1446
  stroke;
1898
- load(data) {
1899
- if (isNull(data)) {
1900
- return;
1901
- }
1447
+ doLoad(data) {
1902
1448
  if (data.color !== undefined) {
1903
1449
  this.color = AnimatableColor.create(this.color, data.color);
1904
1450
  }
1905
- if (data.fill !== undefined) {
1906
- this.fill ??= new Fill();
1907
- this.fill.load(data.fill);
1908
- }
1909
- if (data.stroke !== undefined) {
1910
- this.stroke ??= new Stroke();
1911
- this.stroke.load(data.stroke);
1912
- }
1451
+ loadLazyProperty(this, "fill", data.fill, () => new Fill());
1452
+ loadLazyProperty(this, "stroke", data.stroke, () => new Stroke());
1913
1453
  }
1914
1454
  }
1915
1455
 
1916
1456
  class ParticlesBounceFactor extends ValueWithRandom {
1917
- constructor() {
1918
- super();
1919
- this.value = 1;
1920
- }
1457
+ value = 1;
1921
1458
  }
1922
1459
 
1923
- class ParticlesBounce {
1924
- horizontal;
1925
- vertical;
1926
- constructor() {
1927
- this.horizontal = new ParticlesBounceFactor();
1928
- this.vertical = new ParticlesBounceFactor();
1929
- }
1930
- load(data) {
1931
- if (isNull(data)) {
1932
- return;
1933
- }
1460
+ class ParticlesBounce extends OptionLoader {
1461
+ horizontal = new ParticlesBounceFactor();
1462
+ vertical = new ParticlesBounceFactor();
1463
+ doLoad(data) {
1934
1464
  this.horizontal.load(data.horizontal);
1935
1465
  this.vertical.load(data.vertical);
1936
1466
  }
1937
1467
  }
1938
1468
 
1939
- class ParticlesDensity {
1940
- enable;
1941
- height;
1942
- width;
1943
- constructor() {
1944
- this.enable = false;
1945
- this.width = 1920;
1946
- this.height = 1080;
1947
- }
1948
- load(data) {
1949
- if (isNull(data)) {
1950
- return;
1951
- }
1952
- if (data.enable !== undefined) {
1953
- this.enable = data.enable;
1954
- }
1955
- const width = data.width;
1956
- if (width !== undefined) {
1957
- this.width = width;
1958
- }
1959
- const height = data.height;
1960
- if (height !== undefined) {
1961
- this.height = height;
1962
- }
1469
+ class ParticlesDensity extends OptionLoader {
1470
+ enable = false;
1471
+ height = 1080;
1472
+ width = 1920;
1473
+ doLoad(data) {
1474
+ loadProperty(this, "enable", data.enable);
1475
+ loadProperty(this, "width", data.width);
1476
+ loadProperty(this, "height", data.height);
1963
1477
  }
1964
1478
  }
1965
1479
 
1966
- class ParticlesNumberLimit {
1967
- mode;
1968
- value;
1969
- constructor() {
1970
- this.mode = LimitMode.delete;
1971
- this.value = 0;
1972
- }
1973
- load(data) {
1974
- if (isNull(data)) {
1975
- return;
1976
- }
1977
- if (data.mode !== undefined) {
1978
- this.mode = data.mode;
1979
- }
1980
- if (data.value !== undefined) {
1981
- this.value = data.value;
1982
- }
1480
+ class ParticlesNumberLimit extends OptionLoader {
1481
+ mode = LimitMode.delete;
1482
+ value = 0;
1483
+ doLoad(data) {
1484
+ loadProperty(this, "mode", data.mode);
1485
+ loadProperty(this, "value", data.value);
1983
1486
  }
1984
1487
  }
1985
1488
 
1986
- class ParticlesNumber {
1987
- density;
1988
- limit;
1989
- value;
1990
- constructor() {
1991
- this.density = new ParticlesDensity();
1992
- this.limit = new ParticlesNumberLimit();
1993
- this.value = 0;
1994
- }
1995
- load(data) {
1996
- if (isNull(data)) {
1997
- return;
1998
- }
1489
+ class ParticlesNumber extends OptionLoader {
1490
+ density = new ParticlesDensity();
1491
+ limit = new ParticlesNumberLimit();
1492
+ value = 0;
1493
+ doLoad(data) {
1999
1494
  this.density.load(data.density);
2000
1495
  this.limit.load(data.limit);
2001
- if (data.value !== undefined) {
2002
- this.value = data.value;
2003
- }
1496
+ loadProperty(this, "value", data.value);
2004
1497
  }
2005
1498
  }
2006
1499
 
2007
- class Shape {
2008
- close;
2009
- options;
2010
- type;
2011
- constructor() {
2012
- this.close = true;
2013
- this.options = {};
2014
- this.type = "circle";
2015
- }
2016
- load(data) {
2017
- if (isNull(data)) {
2018
- return;
2019
- }
1500
+ class Shape extends OptionLoader {
1501
+ close = true;
1502
+ options = {};
1503
+ type = "circle";
1504
+ doLoad(data) {
2020
1505
  const options = data.options;
2021
1506
  if (options !== undefined) {
2022
1507
  for (const shape in options) {
@@ -2026,76 +1511,47 @@
2026
1511
  }
2027
1512
  }
2028
1513
  }
2029
- if (data.close !== undefined) {
2030
- this.close = data.close;
2031
- }
2032
- if (data.type !== undefined) {
2033
- this.type = data.type;
2034
- }
1514
+ loadProperty(this, "close", data.close);
1515
+ loadProperty(this, "type", data.type);
2035
1516
  }
2036
1517
  }
2037
1518
 
2038
1519
  class ZIndex extends ValueWithRandom {
2039
- opacityRate;
2040
- sizeRate;
2041
- velocityRate;
2042
- constructor() {
2043
- super();
2044
- this.opacityRate = 1;
2045
- this.sizeRate = 1;
2046
- this.velocityRate = 1;
2047
- }
2048
- load(data) {
2049
- super.load(data);
2050
- if (isNull(data)) {
2051
- return;
2052
- }
2053
- if (data.opacityRate !== undefined) {
2054
- this.opacityRate = data.opacityRate;
2055
- }
2056
- if (data.sizeRate !== undefined) {
2057
- this.sizeRate = data.sizeRate;
2058
- }
2059
- if (data.velocityRate !== undefined) {
2060
- this.velocityRate = data.velocityRate;
2061
- }
2062
- }
2063
- }
2064
-
2065
- class ParticlesOptions {
2066
- bounce;
2067
- effect;
2068
- groups;
2069
- move;
2070
- number;
1520
+ opacityRate = 1;
1521
+ sizeRate = 1;
1522
+ velocityRate = 1;
1523
+ doLoad(data) {
1524
+ super.doLoad(data);
1525
+ loadProperty(this, "opacityRate", data.opacityRate);
1526
+ loadProperty(this, "sizeRate", data.sizeRate);
1527
+ loadProperty(this, "velocityRate", data.velocityRate);
1528
+ }
1529
+ }
1530
+
1531
+ class ParticlesOptions extends OptionLoader {
1532
+ bounce = new ParticlesBounce();
1533
+ effect = new Effect();
1534
+ groups = {};
1535
+ move = new Move();
1536
+ number = new ParticlesNumber();
2071
1537
  paint;
2072
1538
  palette;
2073
- reduceDuplicates;
2074
- shape;
2075
- zIndex;
1539
+ reduceDuplicates = false;
1540
+ shape = new Shape();
1541
+ zIndex = new ZIndex();
2076
1542
  #container;
2077
1543
  #pluginManager;
2078
1544
  constructor(pluginManager, container) {
1545
+ super();
2079
1546
  this.#pluginManager = pluginManager;
2080
1547
  this.#container = container;
2081
- this.bounce = new ParticlesBounce();
2082
- this.effect = new Effect();
2083
- this.groups = {};
2084
- this.move = new Move();
2085
- this.number = new ParticlesNumber();
2086
1548
  this.paint = new Paint();
2087
1549
  this.paint.color = new AnimatableColor();
2088
1550
  this.paint.color.value = "#fff";
2089
1551
  this.paint.fill = new Fill();
2090
1552
  this.paint.fill.enable = true;
2091
- this.reduceDuplicates = false;
2092
- this.shape = new Shape();
2093
- this.zIndex = new ZIndex();
2094
1553
  }
2095
- load(data) {
2096
- if (isNull(data)) {
2097
- return;
2098
- }
1554
+ doLoad(data) {
2099
1555
  if (data.palette) {
2100
1556
  this.palette = data.palette;
2101
1557
  this.#importPalette(this.palette);
@@ -2153,7 +1609,7 @@
2153
1609
  }
2154
1610
  }
2155
1611
  }
2156
- #importPalette = (palette) => {
1612
+ #importPalette(palette) {
2157
1613
  const paletteData = this.#pluginManager.getPalette(palette);
2158
1614
  if (!paletteData) {
2159
1615
  return;
@@ -2197,69 +1653,49 @@
2197
1653
  mode: paletteData.blendMode,
2198
1654
  },
2199
1655
  });
2200
- };
2201
- }
2202
-
2203
- function loadOptions(options, ...sourceOptionsArr) {
2204
- for (const sourceOptions of sourceOptionsArr) {
2205
- options.load(sourceOptions);
2206
1656
  }
2207
1657
  }
1658
+
2208
1659
  function loadParticlesOptions(pluginManager, container, ...sourceOptionsArr) {
2209
1660
  const options = new ParticlesOptions(pluginManager, container);
2210
1661
  loadOptions(options, ...sourceOptionsArr);
2211
1662
  return options;
2212
1663
  }
2213
1664
 
2214
- class Options {
2215
- autoPlay;
1665
+ class Options extends OptionLoader {
1666
+ autoPlay = true;
2216
1667
  background;
2217
- clear;
2218
- defaultThemes;
2219
- delay;
2220
- detectRetina;
2221
- duration;
2222
- fpsLimit;
1668
+ clear = true;
1669
+ defaultThemes = {};
1670
+ delay = 0;
1671
+ detectRetina = true;
1672
+ duration = 0;
1673
+ fpsLimit = 120;
2223
1674
  fullScreen;
2224
- hdr;
1675
+ hdr = true;
2225
1676
  key;
2226
1677
  name;
2227
1678
  palette;
2228
1679
  particles;
2229
- pauseOnBlur;
2230
- pauseOnOutsideViewport;
1680
+ pauseOnBlur = true;
1681
+ pauseOnOutsideViewport = true;
2231
1682
  preset;
2232
1683
  resize;
2233
- smooth;
2234
- style;
2235
- zLayers;
1684
+ smooth = false;
1685
+ style = {};
1686
+ zLayers = 100;
2236
1687
  #container;
2237
1688
  #pluginManager;
2238
1689
  constructor(pluginManager, container) {
1690
+ super();
2239
1691
  this.#pluginManager = pluginManager;
2240
1692
  this.#container = container;
2241
- this.autoPlay = true;
2242
1693
  this.background = new Background();
2243
- this.clear = true;
2244
- this.defaultThemes = {};
2245
- this.delay = 0;
2246
1694
  this.fullScreen = new FullScreen();
2247
- this.detectRetina = true;
2248
- this.duration = 0;
2249
- this.fpsLimit = 120;
2250
- this.hdr = true;
2251
1695
  this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2252
- this.pauseOnBlur = true;
2253
- this.pauseOnOutsideViewport = true;
2254
1696
  this.resize = new ResizeEvent();
2255
- this.smooth = false;
2256
- this.style = {};
2257
- this.zLayers = 100;
2258
1697
  }
2259
- load(data) {
2260
- if (isNull(data)) {
2261
- return;
2262
- }
1698
+ doLoad(data) {
2263
1699
  if (data.preset !== undefined) {
2264
1700
  this.preset = data.preset;
2265
1701
  executeOnSingleOrMultiple(this.preset, preset => {
@@ -2270,44 +1706,18 @@
2270
1706
  this.palette = data.palette;
2271
1707
  this.#importPalette(this.palette);
2272
1708
  }
2273
- if (data.autoPlay !== undefined) {
2274
- this.autoPlay = data.autoPlay;
2275
- }
2276
- if (data.clear !== undefined) {
2277
- this.clear = data.clear;
2278
- }
2279
- if (data.key !== undefined) {
2280
- this.key = data.key;
2281
- }
2282
- if (data.name !== undefined) {
2283
- this.name = data.name;
2284
- }
2285
- if (data.delay !== undefined) {
2286
- this.delay = setRangeValue(data.delay);
2287
- }
2288
- const detectRetina = data.detectRetina;
2289
- if (detectRetina !== undefined) {
2290
- this.detectRetina = detectRetina;
2291
- }
2292
- if (data.duration !== undefined) {
2293
- this.duration = setRangeValue(data.duration);
2294
- }
2295
- const fpsLimit = data.fpsLimit;
2296
- if (fpsLimit !== undefined) {
2297
- this.fpsLimit = fpsLimit;
2298
- }
2299
- if (data.hdr !== undefined) {
2300
- this.hdr = data.hdr;
2301
- }
2302
- if (data.pauseOnBlur !== undefined) {
2303
- this.pauseOnBlur = data.pauseOnBlur;
2304
- }
2305
- if (data.pauseOnOutsideViewport !== undefined) {
2306
- this.pauseOnOutsideViewport = data.pauseOnOutsideViewport;
2307
- }
2308
- if (data.zLayers !== undefined) {
2309
- this.zLayers = data.zLayers;
2310
- }
1709
+ loadProperty(this, "autoPlay", data.autoPlay);
1710
+ loadProperty(this, "clear", data.clear);
1711
+ loadProperty(this, "key", data.key);
1712
+ loadProperty(this, "name", data.name);
1713
+ loadRangeProperty(this, "delay", data.delay);
1714
+ loadProperty(this, "detectRetina", data.detectRetina);
1715
+ loadRangeProperty(this, "duration", data.duration);
1716
+ loadProperty(this, "fpsLimit", data.fpsLimit);
1717
+ loadProperty(this, "hdr", data.hdr);
1718
+ loadProperty(this, "pauseOnBlur", data.pauseOnBlur);
1719
+ loadProperty(this, "pauseOnOutsideViewport", data.pauseOnOutsideViewport);
1720
+ loadProperty(this, "zLayers", data.zLayers);
2311
1721
  this.background.load(data.background);
2312
1722
  const fullScreen = data.fullScreen;
2313
1723
  if (isBoolean(fullScreen)) {
@@ -2319,14 +1729,12 @@
2319
1729
  this.particles.load(data.particles);
2320
1730
  this.resize.load(data.resize);
2321
1731
  this.style = deepExtend(this.style, data.style);
2322
- if (data.smooth !== undefined) {
2323
- this.smooth = data.smooth;
2324
- }
1732
+ loadProperty(this, "smooth", data.smooth);
2325
1733
  this.#pluginManager.plugins.forEach(plugin => {
2326
1734
  plugin.loadOptions(this.#container, this, data);
2327
1735
  });
2328
1736
  }
2329
- #importPalette = palette => {
1737
+ #importPalette(palette) {
2330
1738
  const paletteData = this.#pluginManager.getPalette(palette);
2331
1739
  if (!paletteData) {
2332
1740
  return;
@@ -2343,143 +1751,19 @@
2343
1751
  palette,
2344
1752
  },
2345
1753
  });
2346
- };
2347
- #importPreset = preset => {
2348
- this.load(this.#pluginManager.getPreset(preset));
2349
- };
2350
- }
2351
-
2352
- function paintBase(context, dimension, baseColor) {
2353
- context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
2354
- context.fillRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
2355
- }
2356
- function paintImage(context, dimension, image, opacity) {
2357
- if (!image) {
2358
- return;
2359
- }
2360
- const prevAlpha = context.globalAlpha;
2361
- context.globalAlpha = opacity;
2362
- context.drawImage(image, originPoint.x, originPoint.y, dimension.width, dimension.height);
2363
- context.globalAlpha = prevAlpha;
2364
- }
2365
- function clear(context, dimension) {
2366
- context.clearRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
2367
- }
2368
- function drawParticle(data) {
2369
- const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
2370
- x: pos.x,
2371
- y: pos.y,
2372
- };
2373
- context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
2374
- if (colorStyles.fill) {
2375
- context.fillStyle = colorStyles.fill;
2376
- }
2377
- const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
2378
- context.lineWidth = strokeWidth;
2379
- if (colorStyles.stroke) {
2380
- context.strokeStyle = colorStyles.stroke;
2381
- }
2382
- const drawData = {
2383
- context,
2384
- particle,
2385
- radius,
2386
- drawRadius: radius * drawScale,
2387
- opacity,
2388
- delta,
2389
- pixelRatio: container.retina.pixelRatio,
2390
- fill: fillEnabled,
2391
- stroke: strokeWidth > minStrokeWidth,
2392
- transformData,
2393
- position: { ...pos },
2394
- drawPosition,
2395
- drawScale,
2396
- };
2397
- for (const plugin of container.plugins) {
2398
- plugin.drawParticleTransform?.(drawData);
2399
- }
2400
- const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
2401
- drawBeforeEffect(effect, drawData);
2402
- drawShapeBeforeDraw(shape, drawData);
2403
- drawShape(shape, drawData);
2404
- drawShapeAfterDraw(shape, drawData);
2405
- drawAfterEffect(effect, drawData);
2406
- context.resetTransform();
2407
- }
2408
- function drawAfterEffect(drawer, data) {
2409
- if (!drawer?.drawAfter) {
2410
- return;
2411
- }
2412
- const { particle } = data;
2413
- if (!particle.effect) {
2414
- return;
2415
- }
2416
- drawer.drawAfter(data);
2417
- }
2418
- function drawBeforeEffect(drawer, data) {
2419
- if (!drawer?.drawBefore) {
2420
- return;
2421
- }
2422
- const { particle } = data;
2423
- if (!particle.effect) {
2424
- return;
2425
- }
2426
- drawer.drawBefore(data);
2427
- }
2428
- function drawShape(drawer, data) {
2429
- if (!drawer) {
2430
- return;
2431
- }
2432
- const { context, fill, particle, stroke } = data;
2433
- if (!particle.shape) {
2434
- return;
2435
- }
2436
- context.beginPath();
2437
- drawer.draw(data);
2438
- if (particle.shapeClose) {
2439
- context.closePath();
2440
- }
2441
- if (fill) {
2442
- context.fill();
2443
- }
2444
- if (stroke) {
2445
- context.stroke();
2446
- }
2447
- }
2448
- function drawShapeAfterDraw(drawer, data) {
2449
- if (!drawer?.afterDraw) {
2450
- return;
2451
- }
2452
- const { particle } = data;
2453
- if (!particle.shape) {
2454
- return;
2455
- }
2456
- drawer.afterDraw(data);
2457
- }
2458
- function drawShapeBeforeDraw(drawer, data) {
2459
- if (!drawer?.beforeDraw) {
2460
- return;
2461
1754
  }
2462
- const { particle } = data;
2463
- if (!particle.shape) {
2464
- return;
2465
- }
2466
- drawer.beforeDraw(data);
2467
- }
2468
- function drawParticlePlugin(context, plugin, particle, delta) {
2469
- if (!plugin.drawParticle) {
2470
- return;
1755
+ #importPreset(preset) {
1756
+ this.load(this.#pluginManager.getPreset(preset));
2471
1757
  }
2472
- plugin.drawParticle(context, particle, delta);
2473
1758
  }
2474
1759
 
2475
- const styleCache = new Map(), maxCacheSize = 1000, firstIndex$1 = 0, rgbFixedPrecision = 2, hslFixedPrecision = 2;
1760
+ const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, sdrReferenceWhiteNits = 203;
2476
1761
  function getCachedStyle(key, generator) {
2477
1762
  let cached = styleCache.get(key);
2478
1763
  if (!cached) {
2479
1764
  cached = generator();
2480
- if (styleCache.size >= maxCacheSize) {
2481
- const keysToDelete = [...styleCache.keys()].slice(firstIndex$1, maxCacheSize * half);
2482
- keysToDelete.forEach(k => styleCache.delete(k));
1765
+ if (styleCache.size > maxStyleCacheSize) {
1766
+ styleCache.clear();
2483
1767
  }
2484
1768
  styleCache.set(key, cached);
2485
1769
  }
@@ -2582,34 +1866,35 @@
2582
1866
  function stringToRgb(pluginManager, input) {
2583
1867
  return stringToRgba(pluginManager, input);
2584
1868
  }
1869
+ function hslChannel(temp1, temp2, temp3) {
1870
+ const temp3Min = 0, temp3Max = 1;
1871
+ if (temp3 < temp3Min) {
1872
+ temp3++;
1873
+ }
1874
+ if (temp3 > temp3Max) {
1875
+ temp3--;
1876
+ }
1877
+ if (temp3 * sextuple < temp3Max) {
1878
+ return temp1 + (temp2 - temp1) * sextuple * temp3;
1879
+ }
1880
+ if (temp3 * double < temp3Max) {
1881
+ return temp2;
1882
+ }
1883
+ if (temp3 * triple < temp3Max * double) {
1884
+ const temp3Offset = double / triple;
1885
+ return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
1886
+ }
1887
+ return temp1;
1888
+ }
2585
1889
  function hslToRgb(hsl) {
2586
1890
  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;
2587
1891
  if (s === sMin) {
2588
1892
  const grayscaleValue = Math.round(lNormalized * rgbMax);
2589
1893
  return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
2590
1894
  }
2591
- const channel = (temp1, temp2, temp3) => {
2592
- const temp3Min = 0, temp3Max = 1;
2593
- if (temp3 < temp3Min) {
2594
- temp3++;
2595
- }
2596
- if (temp3 > temp3Max) {
2597
- temp3--;
2598
- }
2599
- if (temp3 * sextuple < temp3Max) {
2600
- return temp1 + (temp2 - temp1) * sextuple * temp3;
2601
- }
2602
- if (temp3 * double < temp3Max) {
2603
- return temp2;
2604
- }
2605
- if (temp3 * triple < temp3Max * double) {
2606
- const temp3Offset = double / triple;
2607
- return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
2608
- }
2609
- return temp1;
2610
- }, temp1 = lNormalized < half
1895
+ const temp1 = lNormalized < half
2611
1896
  ? lNormalized * (sNormalizedOffset + sNormalized)
2612
- : 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));
1897
+ : 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));
2613
1898
  return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
2614
1899
  }
2615
1900
  function hslaToRgba(hsla) {
@@ -2622,7 +1907,7 @@
2622
1907
  };
2623
1908
  }
2624
1909
  function getRandomRgbColor(min) {
2625
- const fixedMin = defaultRgbMin, fixedMax = rgbMax + identity$2, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
1910
+ const fixedMin = defaultRgbMin, fixedMax = rgbMax + identity$1, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
2626
1911
  return {
2627
1912
  b: getRgbInRangeValue(),
2628
1913
  g: getRgbInRangeValue(),
@@ -2633,21 +1918,18 @@
2633
1918
  const op = opacity ?? defaultOpacity$1, key = `rgb-${color.r.toFixed(rgbFixedPrecision)}-${color.g.toFixed(rgbFixedPrecision)}-${color.b.toFixed(rgbFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
2634
1919
  return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
2635
1920
  }
2636
- function getHdrStyleFromRgb(color, opacity) {
2637
- return `color(display-p3 ${(color.r / rgbMax).toString()} ${(color.g / rgbMax).toString()} ${(color.b / rgbMax).toString()} / ${(opacity ?? defaultOpacity$1).toString()})`;
1921
+ function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
1922
+ const headroom = peakNits / sdrReferenceWhiteNits;
1923
+ return `color(display-p3 ${((color.r / rgbMax) * headroom).toString()} ${((color.g / rgbMax) * headroom).toString()} ${((color.b / rgbMax) * headroom).toString()} / ${(opacity ?? defaultOpacity$1).toString()})`;
2638
1924
  }
2639
1925
  function getSdrStyleFromRgb(color, opacity) {
2640
1926
  return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$1).toString()})`;
2641
1927
  }
2642
1928
  function getStyleFromHsl(color, hdr, opacity) {
2643
1929
  const op = opacity ?? defaultOpacity$1, key = `hsl-${color.h.toFixed(hslFixedPrecision)}-${color.s.toFixed(hslFixedPrecision)}-${color.l.toFixed(hslFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
2644
- return getCachedStyle(key, () => (hdr ? getHdrStyleFromHsl(color, opacity) : getSdrStyleFromHsl(color, opacity)));
2645
- }
2646
- function getHdrStyleFromHsl(color, opacity) {
2647
- return getHdrStyleFromRgb(hslToRgb(color), opacity);
2648
- }
2649
- function getSdrStyleFromHsl(color, opacity) {
2650
- return `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${(opacity ?? defaultOpacity$1).toString()})`;
1930
+ return getCachedStyle(key, () => hdr
1931
+ ? getStyleFromRgb(hslToRgb(color), true, opacity)
1932
+ : `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
2651
1933
  }
2652
1934
  function getHslFromAnimation(animation) {
2653
1935
  return animation === undefined
@@ -3025,22 +2307,14 @@
3025
2307
  }
3026
2308
 
3027
2309
  class Blend {
3028
- enable;
3029
- mode;
3030
- constructor() {
3031
- this.mode = "destination-out";
3032
- this.enable = false;
3033
- }
2310
+ enable = false;
2311
+ mode = "destination-out";
3034
2312
  load(data) {
3035
2313
  if (isNull(data)) {
3036
2314
  return;
3037
2315
  }
3038
- if (data.mode !== undefined) {
3039
- this.mode = data.mode;
3040
- }
3041
- if (data.enable !== undefined) {
3042
- this.enable = data.enable;
3043
- }
2316
+ loadProperty(this, "mode", data.mode);
2317
+ loadProperty(this, "enable", data.enable);
3044
2318
  }
3045
2319
  }
3046
2320
 
@@ -3070,7 +2344,7 @@
3070
2344
  }
3071
2345
 
3072
2346
  async function loadBlendPlugin(engine) {
3073
- engine.checkVersion("4.1.3");
2347
+ engine.checkVersion("4.2.1");
3074
2348
  await engine.pluginManager.register(e => {
3075
2349
  e.pluginManager.addPlugin(new BlendPlugin());
3076
2350
  });
@@ -3107,7 +2381,7 @@
3107
2381
  }
3108
2382
 
3109
2383
  async function loadCircleShape(engine) {
3110
- engine.checkVersion("4.1.3");
2384
+ engine.checkVersion("4.2.1");
3111
2385
  await engine.pluginManager.register(e => {
3112
2386
  e.pluginManager.addShape(["circle"], () => {
3113
2387
  return Promise.resolve(new CircleDrawer());
@@ -3155,7 +2429,7 @@
3155
2429
  }
3156
2430
 
3157
2431
  async function loadHexColorPlugin(engine) {
3158
- engine.checkVersion("4.1.3");
2432
+ engine.checkVersion("4.2.1");
3159
2433
  await engine.pluginManager.register(e => {
3160
2434
  e.pluginManager.addColorManager("hex", new HexColorManager());
3161
2435
  });
@@ -3178,103 +2452,215 @@
3178
2452
  if (!("h" in hslColor) || !("s" in hslColor) || !("l" in hslColor)) {
3179
2453
  return;
3180
2454
  }
3181
- return hslToRgb(hslColor);
2455
+ return hslToRgb(hslColor);
2456
+ }
2457
+ handleRangeColor(color) {
2458
+ const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
2459
+ if (!("h" in hslColor) || !("s" in hslColor) || !("l" in hslColor)) {
2460
+ return;
2461
+ }
2462
+ return hslToRgb({
2463
+ h: getRangeValue(hslColor.h),
2464
+ l: getRangeValue(hslColor.l),
2465
+ s: getRangeValue(hslColor.s),
2466
+ });
2467
+ }
2468
+ parseString(input) {
2469
+ if (!this.accepts(input)) {
2470
+ return;
2471
+ }
2472
+ const result = hslRegex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
2473
+ return result
2474
+ ? hslaToRgba({
2475
+ a: result.length > minLength ? parseAlpha(result[HslIndexes.a]) : defaultAlpha,
2476
+ h: Number.parseInt(result[HslIndexes.h] ?? "0", radix),
2477
+ l: Number.parseInt(result[HslIndexes.l] ?? "0", radix),
2478
+ s: Number.parseInt(result[HslIndexes.s] ?? "0", radix),
2479
+ })
2480
+ : undefined;
2481
+ }
2482
+ }
2483
+
2484
+ async function loadHslColorPlugin(engine) {
2485
+ engine.checkVersion("4.2.1");
2486
+ await engine.pluginManager.register(e => {
2487
+ e.pluginManager.addColorManager("hsl", new HslColorManager());
2488
+ });
2489
+ }
2490
+
2491
+ class MovePlugin {
2492
+ id = "move";
2493
+ #pluginManager;
2494
+ constructor(pluginManager) {
2495
+ this.#pluginManager = pluginManager;
2496
+ }
2497
+ async getPlugin(container) {
2498
+ const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
2499
+ return new MovePluginInstance(this.#pluginManager, container);
2500
+ }
2501
+ loadOptions() {
2502
+ }
2503
+ needsPlugin() {
2504
+ return true;
2505
+ }
2506
+ }
2507
+
2508
+ async function loadMovePlugin(engine) {
2509
+ engine.checkVersion("4.2.1");
2510
+ await engine.pluginManager.register(e => {
2511
+ const moveEngine = e, movePluginManager = moveEngine.pluginManager;
2512
+ movePluginManager.initializers.pathGenerators ??= new Map();
2513
+ movePluginManager.pathGenerators ??= new Map();
2514
+ movePluginManager.addPathGenerator = (name, generator) => {
2515
+ movePluginManager.initializers.pathGenerators ??= new Map();
2516
+ movePluginManager.initializers.pathGenerators.set(name, generator);
2517
+ };
2518
+ movePluginManager.getPathGenerators = async (container, force = false) => {
2519
+ movePluginManager.initializers.pathGenerators ??= new Map();
2520
+ movePluginManager.pathGenerators ??= new Map();
2521
+ return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
2522
+ };
2523
+ e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
2524
+ });
2525
+ }
2526
+
2527
+ function checkDestroy(particle, destroyType, value, minValue, maxValue) {
2528
+ switch (destroyType) {
2529
+ case DestroyType.max:
2530
+ if (value >= maxValue) {
2531
+ particle.destroy();
2532
+ }
2533
+ break;
2534
+ case DestroyType.min:
2535
+ if (value <= minValue) {
2536
+ particle.destroy();
2537
+ }
2538
+ break;
2539
+ }
2540
+ }
2541
+ function initParticleNumericAnimationValue(options, pxRatio) {
2542
+ const valueRange = options.value, animationOptions = options.animation, res = {
2543
+ delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
2544
+ enable: animationOptions.enable,
2545
+ value: getRangeValue(options.value) * pxRatio,
2546
+ max: getRangeMax(valueRange) * pxRatio,
2547
+ min: getRangeMin(valueRange) * pxRatio,
2548
+ loops: 0,
2549
+ maxLoops: getRangeValue(animationOptions.count),
2550
+ time: 0,
2551
+ }, decayOffset = 1;
2552
+ if (animationOptions.enable) {
2553
+ res.decay = decayOffset - getRangeValue(animationOptions.decay);
2554
+ switch (animationOptions.mode) {
2555
+ case AnimationMode.increase:
2556
+ res.status = AnimationStatus.increasing;
2557
+ break;
2558
+ case AnimationMode.decrease:
2559
+ res.status = AnimationStatus.decreasing;
2560
+ break;
2561
+ case AnimationMode.random:
2562
+ res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
2563
+ break;
2564
+ }
2565
+ const autoStatus = animationOptions.mode === AnimationMode.auto;
2566
+ switch (animationOptions.startValue) {
2567
+ case StartValueType.min:
2568
+ res.value = res.min;
2569
+ if (autoStatus) {
2570
+ res.status = AnimationStatus.increasing;
2571
+ }
2572
+ break;
2573
+ case StartValueType.max:
2574
+ res.value = res.max;
2575
+ if (autoStatus) {
2576
+ res.status = AnimationStatus.decreasing;
2577
+ }
2578
+ break;
2579
+ case StartValueType.random:
2580
+ default:
2581
+ res.value = randomInRangeValue(res);
2582
+ if (autoStatus) {
2583
+ res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
2584
+ }
2585
+ break;
2586
+ }
3182
2587
  }
3183
- handleRangeColor(color) {
3184
- const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
3185
- if (!("h" in hslColor) || !("s" in hslColor) || !("l" in hslColor)) {
3186
- return;
3187
- }
3188
- return hslToRgb({
3189
- h: getRangeValue(hslColor.h),
3190
- l: getRangeValue(hslColor.l),
3191
- s: getRangeValue(hslColor.s),
3192
- });
2588
+ res.initialValue = res.value;
2589
+ return res;
2590
+ }
2591
+ function updateAnimation(particle, data, changeDirection, destroyType, delta) {
2592
+ const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
2593
+ if (particle.destroyed ||
2594
+ !data.enable ||
2595
+ ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
2596
+ return;
3193
2597
  }
3194
- parseString(input) {
3195
- if (!this.accepts(input)) {
2598
+ const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
2599
+ data.time ??= 0;
2600
+ const delayTime = data.delayTime ?? minDelay;
2601
+ if (delayTime > minDelay && data.time < delayTime) {
2602
+ data.time += delta.value;
2603
+ if (data.time < delayTime) {
3196
2604
  return;
3197
2605
  }
3198
- const result = hslRegex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
3199
- return result
3200
- ? hslaToRgba({
3201
- a: result.length > minLength ? parseAlpha(result[HslIndexes.a]) : defaultAlpha,
3202
- h: Number.parseInt(result[HslIndexes.h] ?? "0", radix),
3203
- l: Number.parseInt(result[HslIndexes.l] ?? "0", radix),
3204
- s: Number.parseInt(result[HslIndexes.s] ?? "0", radix),
3205
- })
3206
- : undefined;
3207
2606
  }
3208
- }
3209
-
3210
- async function loadHslColorPlugin(engine) {
3211
- engine.checkVersion("4.1.3");
3212
- await engine.pluginManager.register(e => {
3213
- e.pluginManager.addColorManager("hsl", new HslColorManager());
3214
- });
3215
- }
3216
-
3217
- class MovePlugin {
3218
- id = "move";
3219
- #pluginManager;
3220
- constructor(pluginManager) {
3221
- this.#pluginManager = pluginManager;
2607
+ switch (data.status) {
2608
+ case AnimationStatus.increasing:
2609
+ data.value += velocity;
2610
+ break;
2611
+ case AnimationStatus.decreasing:
2612
+ data.value -= velocity;
2613
+ break;
3222
2614
  }
3223
- async getPlugin(container) {
3224
- const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
3225
- return new MovePluginInstance(this.#pluginManager, container);
2615
+ if (data.velocity && decay !== identity) {
2616
+ data.velocity *= decay;
3226
2617
  }
3227
- loadOptions() {
2618
+ switch (data.status) {
2619
+ case AnimationStatus.increasing:
2620
+ if (data.value >= maxValue) {
2621
+ if (changeDirection) {
2622
+ data.status = AnimationStatus.decreasing;
2623
+ }
2624
+ else {
2625
+ data.value -= maxValue;
2626
+ }
2627
+ data.loops ??= minLoops;
2628
+ data.loops++;
2629
+ }
2630
+ break;
2631
+ case AnimationStatus.decreasing:
2632
+ if (data.value <= minValue) {
2633
+ if (changeDirection) {
2634
+ data.status = AnimationStatus.increasing;
2635
+ }
2636
+ else {
2637
+ data.value += maxValue;
2638
+ }
2639
+ data.loops ??= minLoops;
2640
+ data.loops++;
2641
+ }
2642
+ break;
3228
2643
  }
3229
- needsPlugin() {
3230
- return true;
2644
+ checkDestroy(particle, destroyType, data.value, minValue, maxValue);
2645
+ if (!particle.destroyed) {
2646
+ data.value = clamp(data.value, minValue, maxValue);
3231
2647
  }
3232
2648
  }
3233
2649
 
3234
- async function loadMovePlugin(engine) {
3235
- engine.checkVersion("4.1.3");
3236
- await engine.pluginManager.register(e => {
3237
- const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3238
- movePluginManager.initializers.pathGenerators ??= new Map();
3239
- movePluginManager.pathGenerators ??= new Map();
3240
- movePluginManager.addPathGenerator = (name, generator) => {
3241
- movePluginManager.initializers.pathGenerators ??= new Map();
3242
- movePluginManager.initializers.pathGenerators.set(name, generator);
3243
- };
3244
- movePluginManager.getPathGenerators = async (container, force = false) => {
3245
- movePluginManager.initializers.pathGenerators ??= new Map();
3246
- movePluginManager.pathGenerators ??= new Map();
3247
- return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
3248
- };
3249
- e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
3250
- });
3251
- }
3252
-
3253
2650
  class OpacityAnimation extends RangedAnimationOptions {
3254
- destroy;
3255
- constructor() {
3256
- super();
3257
- this.destroy = DestroyType.none;
3258
- this.speed = 2;
3259
- }
2651
+ destroy = DestroyType.none;
3260
2652
  load(data) {
3261
2653
  super.load(data);
3262
2654
  if (isNull(data)) {
3263
2655
  return;
3264
2656
  }
3265
- if (data.destroy !== undefined) {
3266
- this.destroy = data.destroy;
3267
- }
2657
+ loadProperty(this, "destroy", data.destroy);
3268
2658
  }
3269
2659
  }
3270
2660
 
3271
2661
  class Opacity extends RangedAnimationValueWithRandom {
3272
- animation;
3273
- constructor() {
3274
- super();
3275
- this.animation = new OpacityAnimation();
3276
- this.value = 1;
3277
- }
2662
+ animation = new OpacityAnimation();
2663
+ value = 1;
3278
2664
  load(data) {
3279
2665
  if (isNull(data)) {
3280
2666
  return;
@@ -3318,10 +2704,7 @@
3318
2704
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3319
2705
  }
3320
2706
  loadOptions(options, ...sources) {
3321
- options.opacity ??= new Opacity();
3322
- for (const source of sources) {
3323
- options.opacity.load(source?.opacity);
3324
- }
2707
+ loadOptionProperty(options, "opacity", Opacity, ...sources);
3325
2708
  }
3326
2709
  reset(particle) {
3327
2710
  if (!particle.opacity) {
@@ -3339,7 +2722,7 @@
3339
2722
  }
3340
2723
 
3341
2724
  async function loadOpacityUpdater(engine) {
3342
- engine.checkVersion("4.1.3");
2725
+ engine.checkVersion("4.2.1");
3343
2726
  await engine.pluginManager.register(e => {
3344
2727
  e.pluginManager.addParticleUpdater("opacity", container => {
3345
2728
  return Promise.resolve(new OpacityUpdater(container));
@@ -3347,7 +2730,7 @@
3347
2730
  });
3348
2731
  }
3349
2732
 
3350
- const minVelocity$4 = 0, boundsMin = 0;
2733
+ const boundsMin = 0;
3351
2734
  function bounceHorizontal(data) {
3352
2735
  if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) ||
3353
2736
  (data.direction !== OutModeDirection.left && data.direction !== OutModeDirection.right)) {
@@ -3362,8 +2745,8 @@
3362
2745
  const velocity = data.particle.velocity.x;
3363
2746
  let bounced = false;
3364
2747
  if (data.outOfCanvas &&
3365
- ((data.direction === OutModeDirection.right && velocity > minVelocity$4) ||
3366
- (data.direction === OutModeDirection.left && velocity < minVelocity$4))) {
2748
+ ((data.direction === OutModeDirection.right && velocity > minVelocity) ||
2749
+ (data.direction === OutModeDirection.left && velocity < minVelocity))) {
3367
2750
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3368
2751
  data.particle.velocity.x *= -newVelocity;
3369
2752
  bounced = true;
@@ -3396,8 +2779,8 @@
3396
2779
  const velocity = data.particle.velocity.y;
3397
2780
  let bounced = false;
3398
2781
  if (data.outOfCanvas &&
3399
- ((data.direction === OutModeDirection.bottom && velocity > minVelocity$4) ||
3400
- (data.direction === OutModeDirection.top && velocity < minVelocity$4))) {
2782
+ ((data.direction === OutModeDirection.bottom && velocity > minVelocity) ||
2783
+ (data.direction === OutModeDirection.top && velocity < minVelocity))) {
3401
2784
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3402
2785
  data.particle.velocity.y *= -newVelocity;
3403
2786
  bounced = true;
@@ -3450,7 +2833,6 @@
3450
2833
  }
3451
2834
  }
3452
2835
 
3453
- const minVelocity$3 = 0;
3454
2836
  class DestroyOutMode {
3455
2837
  modes;
3456
2838
  constructor(_container) {
@@ -3469,10 +2851,10 @@
3469
2851
  break;
3470
2852
  case ParticleOutType.inside: {
3471
2853
  const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
3472
- if ((vx < minVelocity$3 && dx > particle.moveCenter.radius) ||
3473
- (vy < minVelocity$3 && dy > particle.moveCenter.radius) ||
3474
- (vx >= minVelocity$3 && dx < -particle.moveCenter.radius) ||
3475
- (vy >= minVelocity$3 && dy < -particle.moveCenter.radius)) {
2854
+ if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
2855
+ (vy < minVelocity && dy > particle.moveCenter.radius) ||
2856
+ (vx >= minVelocity && dx < -particle.moveCenter.radius) ||
2857
+ (vy >= minVelocity && dy < -particle.moveCenter.radius)) {
3476
2858
  return;
3477
2859
  }
3478
2860
  break;
@@ -3482,7 +2864,6 @@
3482
2864
  }
3483
2865
  }
3484
2866
 
3485
- const minVelocity$2 = 0;
3486
2867
  class NoneOutMode {
3487
2868
  modes;
3488
2869
  #container;
@@ -3502,10 +2883,10 @@
3502
2883
  }
3503
2884
  const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3504
2885
  if (!gravityOptions.enable) {
3505
- if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3506
- (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
3507
- (particle.velocity.x > minVelocity$2 && particle.position.x <= canvasSize.width + pRadius) ||
3508
- (particle.velocity.x < minVelocity$2 && particle.position.x >= -pRadius)) {
2886
+ if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
2887
+ (particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
2888
+ (particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
2889
+ (particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
3509
2890
  return;
3510
2891
  }
3511
2892
  if (!isPointInside(particle.position, container.canvas.size, originPoint, pRadius, direction)) {
@@ -3524,7 +2905,7 @@
3524
2905
  }
3525
2906
  }
3526
2907
 
3527
- const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
2908
+ const updateVector = Vector.origin;
3528
2909
  class OutOutMode {
3529
2910
  modes;
3530
2911
  #container;
@@ -3545,10 +2926,10 @@
3545
2926
  updateVector.angle = particle.velocity.angle + Math.PI;
3546
2927
  updateVector.addTo(particle.moveCenter);
3547
2928
  const { dx, dy } = getDistances(particle.position, updateVector);
3548
- if ((vx <= minVelocity$1 && dx >= minDistance) ||
3549
- (vy <= minVelocity$1 && dy >= minDistance) ||
3550
- (vx >= minVelocity$1 && dx <= minDistance) ||
3551
- (vy >= minVelocity$1 && dy <= minDistance)) {
2929
+ if ((vx <= minVelocity && dx >= minDistance) ||
2930
+ (vy <= minVelocity && dy >= minDistance) ||
2931
+ (vx >= minVelocity && dx <= minDistance) ||
2932
+ (vy >= minVelocity && dy <= minDistance)) {
3552
2933
  return;
3553
2934
  }
3554
2935
  particle.position.x = Math.floor(randomInRangeValue({
@@ -3672,21 +3053,21 @@
3672
3053
  this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3673
3054
  this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3674
3055
  }
3675
- #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3056
+ #addUpdaterIfMissing(particle, outMode, getUpdater) {
3676
3057
  const outModes = particle.options.move.outModes;
3677
3058
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3678
3059
  this.updaters.set(outMode, getUpdater(this.#container));
3679
3060
  }
3680
- };
3681
- #updateOutMode = (particle, delta, outMode, direction) => {
3061
+ }
3062
+ #updateOutMode(particle, delta, outMode, direction) {
3682
3063
  for (const updater of this.updaters.values()) {
3683
3064
  updater.update(particle, direction, delta, outMode);
3684
3065
  }
3685
- };
3066
+ }
3686
3067
  }
3687
3068
 
3688
3069
  async function loadOutModesUpdater(engine) {
3689
- engine.checkVersion("4.1.3");
3070
+ engine.checkVersion("4.2.1");
3690
3071
  await engine.pluginManager.register(e => {
3691
3072
  e.pluginManager.addParticleUpdater("outModes", container => {
3692
3073
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3757,7 +3138,7 @@
3757
3138
  }
3758
3139
 
3759
3140
  async function loadPaintUpdater(engine) {
3760
- engine.checkVersion("4.1.3");
3141
+ engine.checkVersion("4.2.1");
3761
3142
  await engine.pluginManager.register(e => {
3762
3143
  e.pluginManager.addParticleUpdater("paint", container => {
3763
3144
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3812,37 +3193,26 @@
3812
3193
  }
3813
3194
 
3814
3195
  async function loadRgbColorPlugin(engine) {
3815
- engine.checkVersion("4.1.3");
3196
+ engine.checkVersion("4.2.1");
3816
3197
  await engine.pluginManager.register(e => {
3817
3198
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3818
3199
  });
3819
3200
  }
3820
3201
 
3821
3202
  class SizeAnimation extends RangedAnimationOptions {
3822
- destroy;
3823
- constructor() {
3824
- super();
3825
- this.destroy = DestroyType.none;
3826
- this.speed = 5;
3827
- }
3203
+ destroy = DestroyType.none;
3828
3204
  load(data) {
3829
3205
  super.load(data);
3830
3206
  if (isNull(data)) {
3831
3207
  return;
3832
3208
  }
3833
- if (data.destroy !== undefined) {
3834
- this.destroy = data.destroy;
3835
- }
3209
+ loadProperty(this, "destroy", data.destroy);
3836
3210
  }
3837
3211
  }
3838
3212
 
3839
3213
  class Size extends RangedAnimationValueWithRandom {
3840
- animation;
3841
- constructor() {
3842
- super();
3843
- this.animation = new SizeAnimation();
3844
- this.value = 3;
3845
- }
3214
+ animation = new SizeAnimation();
3215
+ value = 3;
3846
3216
  load(data) {
3847
3217
  super.load(data);
3848
3218
  if (isNull(data)) {
@@ -3885,10 +3255,7 @@
3885
3255
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3886
3256
  }
3887
3257
  loadOptions(options, ...sources) {
3888
- options.size ??= new Size();
3889
- for (const source of sources) {
3890
- options.size.load(source?.size);
3891
- }
3258
+ loadOptionProperty(options, "size", Size, ...sources);
3892
3259
  }
3893
3260
  preInit(particle) {
3894
3261
  const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
@@ -3911,7 +3278,7 @@
3911
3278
  }
3912
3279
 
3913
3280
  async function loadSizeUpdater(engine) {
3914
- engine.checkVersion("4.1.3");
3281
+ engine.checkVersion("4.2.1");
3915
3282
  await engine.pluginManager.register(e => {
3916
3283
  e.pluginManager.addParticleUpdater("size", container => {
3917
3284
  return Promise.resolve(new SizeUpdater(container));
@@ -3920,7 +3287,7 @@
3920
3287
  }
3921
3288
 
3922
3289
  async function loadBasic(engine) {
3923
- engine.checkVersion("4.1.3");
3290
+ engine.checkVersion("4.2.1");
3924
3291
  await engine.pluginManager.register(async (e) => {
3925
3292
  await Promise.all([
3926
3293
  loadBlendPlugin(e),
@@ -3946,18 +3313,10 @@
3946
3313
  if (isNull(data)) {
3947
3314
  return;
3948
3315
  }
3949
- if (data.bottom !== undefined) {
3950
- this.bottom = setRangeValue(data.bottom);
3951
- }
3952
- if (data.left !== undefined) {
3953
- this.left = setRangeValue(data.left);
3954
- }
3955
- if (data.right !== undefined) {
3956
- this.right = setRangeValue(data.right);
3957
- }
3958
- if (data.top !== undefined) {
3959
- this.top = setRangeValue(data.top);
3960
- }
3316
+ loadRangeProperty(this, "bottom", data.bottom);
3317
+ loadRangeProperty(this, "left", data.left);
3318
+ loadRangeProperty(this, "right", data.right);
3319
+ loadRangeProperty(this, "top", data.top);
3961
3320
  }
3962
3321
  }
3963
3322
 
@@ -3969,55 +3328,35 @@
3969
3328
  })(DestroyMode || (DestroyMode = {}));
3970
3329
 
3971
3330
  class Explode {
3972
- maxSizeFactor;
3973
- speed;
3974
- constructor() {
3975
- this.maxSizeFactor = 3;
3976
- this.speed = 2;
3977
- }
3331
+ maxSizeFactor = 3;
3332
+ speed = 2;
3978
3333
  load(data) {
3979
3334
  if (isNull(data)) {
3980
3335
  return;
3981
3336
  }
3982
- if (data.maxSizeFactor !== undefined) {
3983
- this.maxSizeFactor = data.maxSizeFactor;
3984
- }
3985
- if (data.speed !== undefined) {
3986
- this.speed = data.speed;
3987
- }
3337
+ loadProperty(this, "maxSizeFactor", data.maxSizeFactor);
3338
+ loadProperty(this, "speed", data.speed);
3988
3339
  }
3989
3340
  }
3990
3341
 
3991
3342
  class SplitFactor extends ValueWithRandom {
3992
- constructor() {
3993
- super();
3994
- this.value = 3;
3995
- }
3343
+ value = 3;
3996
3344
  }
3997
3345
 
3998
3346
  class SplitRate extends ValueWithRandom {
3999
- constructor() {
4000
- super();
4001
- this.value = { min: 4, max: 9 };
4002
- }
3347
+ value = { min: 4, max: 9 };
4003
3348
  }
4004
3349
 
4005
3350
  class Split {
4006
- count;
4007
- factor;
3351
+ count = 1;
3352
+ factor = new SplitFactor();
4008
3353
  fillColor;
4009
3354
  fillColorOffset;
4010
3355
  particles;
4011
- rate;
4012
- sizeOffset;
3356
+ rate = new SplitRate();
3357
+ sizeOffset = true;
4013
3358
  strokeColor;
4014
3359
  strokeColorOffset;
4015
- constructor() {
4016
- this.count = 1;
4017
- this.factor = new SplitFactor();
4018
- this.rate = new SplitRate();
4019
- this.sizeOffset = true;
4020
- }
4021
3360
  load(data) {
4022
3361
  if (isNull(data)) {
4023
3362
  return;
@@ -4028,17 +3367,13 @@
4028
3367
  if (data.strokeColor !== undefined) {
4029
3368
  this.strokeColor = OptionsColor.create(this.strokeColor, data.strokeColor);
4030
3369
  }
4031
- if (data.count !== undefined) {
4032
- this.count = data.count;
4033
- }
3370
+ loadProperty(this, "count", data.count);
4034
3371
  this.factor.load(data.factor);
4035
3372
  this.rate.load(data.rate);
4036
3373
  this.particles = executeOnSingleOrMultiple(data.particles, particles => {
4037
3374
  return deepExtend({}, particles);
4038
3375
  });
4039
- if (data.sizeOffset !== undefined) {
4040
- this.sizeOffset = data.sizeOffset;
4041
- }
3376
+ loadProperty(this, "sizeOffset", data.sizeOffset);
4042
3377
  if (data.fillColorOffset) {
4043
3378
  this.fillColorOffset = this.fillColorOffset ?? {};
4044
3379
  if (data.fillColorOffset.h !== undefined) {
@@ -4067,16 +3402,10 @@
4067
3402
  }
4068
3403
 
4069
3404
  class Destroy {
4070
- bounds;
4071
- explode;
4072
- mode;
4073
- split;
4074
- constructor() {
4075
- this.bounds = new DestroyBounds();
4076
- this.explode = new Explode();
4077
- this.mode = DestroyMode.none;
4078
- this.split = new Split();
4079
- }
3405
+ bounds = new DestroyBounds();
3406
+ explode = new Explode();
3407
+ mode = DestroyMode.none;
3408
+ split = new Split();
4080
3409
  load(data) {
4081
3410
  if (isNull(data)) {
4082
3411
  return;
@@ -4137,7 +3466,7 @@
4137
3466
  mode: PixelMode.precise,
4138
3467
  },
4139
3468
  });
4140
- const factor = identity$2 / getRangeValue(splitOptions.factor.value), sizeOptions = splitParticleOptions["size"];
3469
+ const factor = identity$1 / getRangeValue(splitOptions.factor.value), sizeOptions = splitParticleOptions["size"];
4141
3470
  if (sizeOptions) {
4142
3471
  if (isNumber(sizeOptions.value)) {
4143
3472
  sizeOptions.value *= factor;
@@ -4224,10 +3553,7 @@
4224
3553
  return !destroyParticle.destroyed || !!destroyParticle.exploding;
4225
3554
  }
4226
3555
  loadOptions(options, ...sources) {
4227
- options.destroy ??= new Destroy();
4228
- for (const source of sources) {
4229
- options.destroy.load(source?.destroy);
4230
- }
3556
+ loadOptionProperty(options, "destroy", Destroy, ...sources);
4231
3557
  }
4232
3558
  particleDestroyed(particle, override) {
4233
3559
  if (override) {
@@ -4292,7 +3618,7 @@
4292
3618
  }
4293
3619
 
4294
3620
  async function loadDestroyUpdater(engine) {
4295
- engine.checkVersion("4.1.3");
3621
+ engine.checkVersion("4.2.1");
4296
3622
  await engine.pluginManager.register(e => {
4297
3623
  e.pluginManager.addParticleUpdater("destroy", container => {
4298
3624
  return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
@@ -4304,78 +3630,46 @@
4304
3630
  count;
4305
3631
  delay;
4306
3632
  duration;
4307
- wait;
4308
- constructor() {
4309
- this.wait = false;
4310
- }
3633
+ wait = false;
4311
3634
  load(data) {
4312
3635
  if (isNull(data)) {
4313
3636
  return;
4314
3637
  }
4315
- if (data.count !== undefined) {
4316
- this.count = data.count;
4317
- }
4318
- if (data.delay !== undefined) {
4319
- this.delay = setRangeValue(data.delay);
4320
- }
4321
- if (data.duration !== undefined) {
4322
- this.duration = setRangeValue(data.duration);
4323
- }
4324
- if (data.wait !== undefined) {
4325
- this.wait = data.wait;
4326
- }
3638
+ loadProperty(this, "count", data.count);
3639
+ loadRangeProperty(this, "delay", data.delay);
3640
+ loadRangeProperty(this, "duration", data.duration);
3641
+ loadProperty(this, "wait", data.wait);
4327
3642
  }
4328
3643
  }
4329
3644
 
4330
3645
  class EmitterRate {
4331
- delay;
4332
- quantity;
4333
- constructor() {
4334
- this.quantity = 1;
4335
- this.delay = 0.1;
4336
- }
3646
+ delay = 0.1;
3647
+ quantity = 1;
4337
3648
  load(data) {
4338
3649
  if (isNull(data)) {
4339
3650
  return;
4340
3651
  }
4341
- if (data.quantity !== undefined) {
4342
- this.quantity = setRangeValue(data.quantity);
4343
- }
4344
- if (data.delay !== undefined) {
4345
- this.delay = setRangeValue(data.delay);
4346
- }
3652
+ loadRangeProperty(this, "quantity", data.quantity);
3653
+ loadRangeProperty(this, "delay", data.delay);
4347
3654
  }
4348
3655
  }
4349
3656
 
4350
3657
  class EmitterShapeReplace {
4351
- color;
4352
- opacity;
4353
- constructor() {
4354
- this.color = false;
4355
- this.opacity = false;
4356
- }
3658
+ color = false;
3659
+ opacity = false;
4357
3660
  load(data) {
4358
3661
  if (isNull(data)) {
4359
3662
  return;
4360
3663
  }
4361
- if (data.color !== undefined) {
4362
- this.color = data.color;
4363
- }
4364
- if (data.opacity !== undefined) {
4365
- this.opacity = data.opacity;
4366
- }
3664
+ loadProperty(this, "color", data.color);
3665
+ loadProperty(this, "opacity", data.opacity);
4367
3666
  }
4368
3667
  }
4369
3668
 
4370
3669
  class EmitterShape {
4371
- options;
4372
- replace;
4373
- type;
4374
- constructor() {
4375
- this.options = {};
4376
- this.replace = new EmitterShapeReplace();
4377
- this.type = "square";
4378
- }
3670
+ options = {};
3671
+ replace = new EmitterShapeReplace();
3672
+ type = "square";
4379
3673
  load(data) {
4380
3674
  if (isNull(data)) {
4381
3675
  return;
@@ -4384,34 +3678,21 @@
4384
3678
  this.options = deepExtend({}, data.options ?? {});
4385
3679
  }
4386
3680
  this.replace.load(data.replace);
4387
- if (data.type !== undefined) {
4388
- this.type = data.type;
4389
- }
3681
+ loadProperty(this, "type", data.type);
4390
3682
  }
4391
3683
  }
4392
3684
 
4393
3685
  class EmitterSize {
4394
- height;
4395
- mode;
4396
- width;
4397
- constructor() {
4398
- this.mode = PixelMode.percent;
4399
- this.height = 0;
4400
- this.width = 0;
4401
- }
3686
+ height = 0;
3687
+ mode = PixelMode.percent;
3688
+ width = 0;
4402
3689
  load(data) {
4403
3690
  if (isNull(data)) {
4404
3691
  return;
4405
3692
  }
4406
- if (data.mode !== undefined) {
4407
- this.mode = data.mode;
4408
- }
4409
- if (data.height !== undefined) {
4410
- this.height = data.height;
4411
- }
4412
- if (data.width !== undefined) {
4413
- this.width = data.width;
4414
- }
3693
+ loadProperty(this, "mode", data.mode);
3694
+ loadProperty(this, "height", data.height);
3695
+ loadProperty(this, "width", data.width);
4415
3696
  }
4416
3697
  }
4417
3698
 
@@ -4434,50 +3715,35 @@
4434
3715
  }
4435
3716
 
4436
3717
  class Emitter {
4437
- autoPlay;
3718
+ autoPlay = true;
4438
3719
  direction;
4439
3720
  domId;
4440
- fill;
4441
- life;
3721
+ fill = true;
3722
+ life = new EmitterLife();
4442
3723
  name;
4443
3724
  particles;
4444
3725
  position;
4445
- rate;
4446
- shape;
3726
+ rate = new EmitterRate();
3727
+ shape = new EmitterShape();
4447
3728
  size;
4448
- spawn;
3729
+ spawn = new EmitterSpawn();
4449
3730
  spawnFillColor;
4450
3731
  spawnStrokeColor;
4451
- startCount;
4452
- constructor() {
4453
- this.autoPlay = true;
4454
- this.fill = true;
4455
- this.life = new EmitterLife();
4456
- this.rate = new EmitterRate();
4457
- this.shape = new EmitterShape();
4458
- this.spawn = new EmitterSpawn();
4459
- this.startCount = 0;
4460
- }
3732
+ startCount = 0;
4461
3733
  load(data) {
4462
3734
  if (isNull(data)) {
4463
3735
  return;
4464
3736
  }
4465
- if (data.autoPlay !== undefined) {
4466
- this.autoPlay = data.autoPlay;
4467
- }
3737
+ loadProperty(this, "autoPlay", data.autoPlay);
4468
3738
  if (data.size !== undefined) {
4469
3739
  this.size ??= new EmitterSize();
4470
3740
  this.size.load(data.size);
4471
3741
  }
4472
- if (data.direction !== undefined) {
4473
- this.direction = data.direction;
4474
- }
4475
- this.domId = data.domId;
4476
- if (data.fill !== undefined) {
4477
- this.fill = data.fill;
4478
- }
3742
+ loadProperty(this, "direction", data.direction);
3743
+ loadProperty(this, "domId", data.domId);
3744
+ loadProperty(this, "fill", data.fill);
4479
3745
  this.life.load(data.life);
4480
- this.name = data.name;
3746
+ loadProperty(this, "name", data.name);
4481
3747
  this.particles = executeOnSingleOrMultiple(data.particles, particles => {
4482
3748
  return deepExtend({}, particles);
4483
3749
  });
@@ -4501,9 +3767,7 @@
4501
3767
  this.spawnStrokeColor ??= new AnimatableColor();
4502
3768
  this.spawnStrokeColor.load(data.spawnStrokeColor);
4503
3769
  }
4504
- if (data.startCount !== undefined) {
4505
- this.startCount = data.startCount;
4506
- }
3770
+ loadProperty(this, "startCount", data.startCount);
4507
3771
  }
4508
3772
  }
4509
3773
 
@@ -4585,7 +3849,7 @@
4585
3849
  })(EmitterClickMode || (EmitterClickMode = {}));
4586
3850
 
4587
3851
  async function loadEmittersPluginSimple(engine) {
4588
- engine.checkVersion("4.1.3");
3852
+ engine.checkVersion("4.2.1");
4589
3853
  await engine.pluginManager.register(async (e) => {
4590
3854
  const instancesManager = await getEmittersInstancesManager(e);
4591
3855
  await addEmittersShapesManager(e);
@@ -4673,7 +3937,7 @@
4673
3937
  }
4674
3938
 
4675
3939
  async function loadEmittersShapeSquare(engine) {
4676
- engine.checkVersion("4.1.3");
3940
+ engine.checkVersion("4.2.1");
4677
3941
  await engine.pluginManager.register((e) => {
4678
3942
  ensureEmittersPluginLoaded(e);
4679
3943
  e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
@@ -4681,55 +3945,36 @@
4681
3945
  }
4682
3946
 
4683
3947
  class LifeDelay extends ValueWithRandom {
4684
- sync;
4685
- constructor() {
4686
- super();
4687
- this.sync = false;
4688
- }
3948
+ sync = false;
4689
3949
  load(data) {
4690
3950
  if (isNull(data)) {
4691
3951
  return;
4692
3952
  }
4693
3953
  super.load(data);
4694
- if (data.sync !== undefined) {
4695
- this.sync = data.sync;
4696
- }
3954
+ loadProperty(this, "sync", data.sync);
4697
3955
  }
4698
3956
  }
4699
3957
 
4700
3958
  class LifeDuration extends ValueWithRandom {
4701
- sync;
4702
- constructor() {
4703
- super();
4704
- this.sync = false;
4705
- }
3959
+ sync = false;
4706
3960
  load(data) {
4707
3961
  if (isNull(data)) {
4708
3962
  return;
4709
3963
  }
4710
3964
  super.load(data);
4711
- if (data.sync !== undefined) {
4712
- this.sync = data.sync;
4713
- }
3965
+ loadProperty(this, "sync", data.sync);
4714
3966
  }
4715
3967
  }
4716
3968
 
4717
3969
  class Life {
4718
- count;
4719
- delay;
4720
- duration;
4721
- constructor() {
4722
- this.count = 0;
4723
- this.delay = new LifeDelay();
4724
- this.duration = new LifeDuration();
4725
- }
3970
+ count = 0;
3971
+ delay = new LifeDelay();
3972
+ duration = new LifeDuration();
4726
3973
  load(data) {
4727
3974
  if (isNull(data)) {
4728
3975
  return;
4729
3976
  }
4730
- if (data.count !== undefined) {
4731
- this.count = data.count;
4732
- }
3977
+ loadProperty(this, "count", data.count);
4733
3978
  this.delay.load(data.delay);
4734
3979
  this.duration.load(data.duration);
4735
3980
  }
@@ -4788,7 +4033,7 @@
4788
4033
  }
4789
4034
  }
4790
4035
 
4791
- const noTime = 0, identity$1 = 1, infiniteValue = -1;
4036
+ const noTime = 0, identity = 1, infiniteValue = -1;
4792
4037
  class LifeUpdater {
4793
4038
  #container;
4794
4039
  constructor(container) {
@@ -4799,7 +4044,7 @@
4799
4044
  if (!lifeOptions) {
4800
4045
  return;
4801
4046
  }
4802
- const delayFactor = lifeOptions.delay.sync ? identity$1 : getRandom(), durationFactor = lifeOptions.duration.sync ? identity$1 : getRandom();
4047
+ const delayFactor = lifeOptions.delay.sync ? identity : getRandom(), durationFactor = lifeOptions.duration.sync ? identity : getRandom();
4803
4048
  particle.life = {
4804
4049
  delay: container.retina.reduceFactor
4805
4050
  ? ((getRangeValue(lifeOptions.delay.value) * delayFactor) / container.retina.reduceFactor) *
@@ -4825,10 +4070,7 @@
4825
4070
  return !particle.destroyed;
4826
4071
  }
4827
4072
  loadOptions(options, ...sources) {
4828
- options.life ??= new Life();
4829
- for (const source of sources) {
4830
- options.life.load(source?.life);
4831
- }
4073
+ loadOptionProperty(options, "life", Life, ...sources);
4832
4074
  }
4833
4075
  update(particle, delta) {
4834
4076
  if (!this.isEnabled(particle) || !particle.life) {
@@ -4839,7 +4081,7 @@
4839
4081
  }
4840
4082
 
4841
4083
  async function loadLifeUpdater(engine) {
4842
- engine.checkVersion("4.1.3");
4084
+ engine.checkVersion("4.2.1");
4843
4085
  await engine.pluginManager.register(e => {
4844
4086
  e.pluginManager.addParticleUpdater("life", container => {
4845
4087
  return Promise.resolve(new LifeUpdater(container));
@@ -4865,65 +4107,40 @@
4865
4107
  }
4866
4108
 
4867
4109
  async function loadLineShape(engine) {
4868
- engine.checkVersion("4.1.3");
4110
+ engine.checkVersion("4.2.1");
4869
4111
  await engine.pluginManager.register(e => {
4870
4112
  e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
4871
4113
  });
4872
4114
  }
4873
4115
 
4874
4116
  class RotateAnimation {
4875
- decay;
4876
- enable;
4877
- speed;
4878
- sync;
4879
- constructor() {
4880
- this.enable = false;
4881
- this.speed = 0;
4882
- this.decay = 0;
4883
- this.sync = false;
4884
- }
4117
+ decay = 0;
4118
+ enable = false;
4119
+ speed = 0;
4120
+ sync = false;
4885
4121
  load(data) {
4886
4122
  if (isNull(data)) {
4887
4123
  return;
4888
4124
  }
4889
- if (data.enable !== undefined) {
4890
- this.enable = data.enable;
4891
- }
4892
- if (data.speed !== undefined) {
4893
- this.speed = setRangeValue(data.speed);
4894
- }
4895
- if (data.decay !== undefined) {
4896
- this.decay = setRangeValue(data.decay);
4897
- }
4898
- if (data.sync !== undefined) {
4899
- this.sync = data.sync;
4900
- }
4125
+ loadProperty(this, "enable", data.enable);
4126
+ loadRangeProperty(this, "speed", data.speed);
4127
+ loadRangeProperty(this, "decay", data.decay);
4128
+ loadProperty(this, "sync", data.sync);
4901
4129
  }
4902
4130
  }
4903
4131
 
4904
4132
  class Rotate extends ValueWithRandom {
4905
- animation;
4906
- direction;
4907
- path;
4908
- constructor() {
4909
- super();
4910
- this.animation = new RotateAnimation();
4911
- this.direction = RotateDirection.clockwise;
4912
- this.path = false;
4913
- this.value = 0;
4914
- }
4133
+ animation = new RotateAnimation();
4134
+ direction = RotateDirection.clockwise;
4135
+ path = false;
4915
4136
  load(data) {
4916
4137
  if (isNull(data)) {
4917
4138
  return;
4918
4139
  }
4919
4140
  super.load(data);
4920
- if (data.direction !== undefined) {
4921
- this.direction = data.direction;
4922
- }
4141
+ loadProperty(this, "direction", data.direction);
4923
4142
  this.animation.load(data.animation);
4924
- if (data.path !== undefined) {
4925
- this.path = data.path;
4926
- }
4143
+ loadProperty(this, "path", data.path);
4927
4144
  }
4928
4145
  }
4929
4146
 
@@ -4961,7 +4178,7 @@
4961
4178
  }
4962
4179
  const rotateAnimation = rotateOptions.animation;
4963
4180
  if (rotateAnimation.enable) {
4964
- particle.rotate.decay = identity$2 - getRangeValue(rotateAnimation.decay);
4181
+ particle.rotate.decay = identity$1 - getRangeValue(rotateAnimation.decay);
4965
4182
  particle.rotate.velocity =
4966
4183
  (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.#container.retina.reduceFactor;
4967
4184
  if (!rotateAnimation.sync) {
@@ -4978,10 +4195,7 @@
4978
4195
  return !particle.destroyed && !particle.spawning && (!!rotate.value || rotate.animation.enable || rotate.path);
4979
4196
  }
4980
4197
  loadOptions(options, ...sources) {
4981
- options.rotate ??= new Rotate();
4982
- for (const source of sources) {
4983
- options.rotate.load(source?.rotate);
4984
- }
4198
+ loadOptionProperty(options, "rotate", Rotate, ...sources);
4985
4199
  }
4986
4200
  update(particle, delta) {
4987
4201
  if (!this.isEnabled(particle)) {
@@ -4997,7 +4211,7 @@
4997
4211
  }
4998
4212
 
4999
4213
  async function loadRotateUpdater(engine) {
5000
- engine.checkVersion("4.1.3");
4214
+ engine.checkVersion("4.2.1");
5001
4215
  await engine.pluginManager.register(e => {
5002
4216
  e.pluginManager.addParticleUpdater("rotate", container => {
5003
4217
  return Promise.resolve(new RotateUpdater(container));
@@ -5008,20 +4222,14 @@
5008
4222
  const mouseDownEvent = "pointerdown", touchStartEvent = "touchstart";
5009
4223
 
5010
4224
  class SoundsAudio {
5011
- loop;
5012
- source;
5013
- constructor() {
5014
- this.loop = false;
5015
- this.source = "";
5016
- }
4225
+ loop = false;
4226
+ source = "";
5017
4227
  load(data) {
5018
4228
  if (isNull(data)) {
5019
4229
  return;
5020
4230
  }
5021
4231
  if (isObject(data)) {
5022
- if (data.loop !== undefined) {
5023
- this.loop = data.loop;
5024
- }
4232
+ loadProperty(this, "loop", data.loop);
5025
4233
  if (data.source !== undefined) {
5026
4234
  this.source = data.source;
5027
4235
  }
@@ -5033,41 +4241,26 @@
5033
4241
  }
5034
4242
 
5035
4243
  class SoundsNote {
5036
- duration;
5037
- value;
5038
- constructor() {
5039
- this.duration = 500;
5040
- this.value = [];
5041
- }
4244
+ duration = 500;
4245
+ value = [];
5042
4246
  load(data) {
5043
4247
  if (isNull(data)) {
5044
4248
  return;
5045
4249
  }
5046
- if (data.duration !== undefined) {
5047
- this.duration = data.duration;
5048
- }
5049
- if (data.value !== undefined) {
5050
- this.value = data.value;
5051
- }
4250
+ loadProperty(this, "duration", data.duration);
4251
+ loadProperty(this, "value", data.value);
5052
4252
  }
5053
4253
  }
5054
4254
 
5055
4255
  class SoundsMelody {
5056
- loop;
5057
- melodies;
5058
- notes;
5059
- constructor() {
5060
- this.loop = false;
5061
- this.melodies = [];
5062
- this.notes = [];
5063
- }
4256
+ loop = false;
4257
+ melodies = [];
4258
+ notes = [];
5064
4259
  load(data) {
5065
4260
  if (isNull(data)) {
5066
4261
  return;
5067
4262
  }
5068
- if (data.loop !== undefined) {
5069
- this.loop = data.loop;
5070
- }
4263
+ loadProperty(this, "loop", data.loop);
5071
4264
  if (data.melodies !== undefined) {
5072
4265
  this.melodies = data.melodies.map(s => {
5073
4266
  const tmp = new SoundsMelody();
@@ -5087,21 +4280,15 @@
5087
4280
 
5088
4281
  class SoundsEvent {
5089
4282
  audio;
5090
- event;
4283
+ event = [];
5091
4284
  filter;
5092
4285
  melodies;
5093
- notes;
5094
- constructor() {
5095
- this.event = [];
5096
- this.notes = [];
5097
- }
4286
+ notes = [];
5098
4287
  load(data) {
5099
4288
  if (isNull(data)) {
5100
4289
  return;
5101
4290
  }
5102
- if (data.event !== undefined) {
5103
- this.event = data.event;
5104
- }
4291
+ loadProperty(this, "event", data.event);
5105
4292
  if (data.audio !== undefined) {
5106
4293
  if (isArray(data.audio)) {
5107
4294
  this.audio = data.audio.map(s => {
@@ -5144,32 +4331,19 @@
5144
4331
  }
5145
4332
 
5146
4333
  class SoundsIcon {
5147
- height;
4334
+ height = 24;
5148
4335
  path;
5149
- style;
4336
+ style = "";
5150
4337
  svg;
5151
- width;
5152
- constructor() {
5153
- this.width = 24;
5154
- this.height = 24;
5155
- this.style = "";
5156
- }
4338
+ width = 24;
5157
4339
  load(data) {
5158
4340
  if (isNull(data)) {
5159
4341
  return;
5160
4342
  }
5161
- if (data.path !== undefined) {
5162
- this.path = data.path;
5163
- }
5164
- if (data.svg !== undefined) {
5165
- this.svg = data.svg;
5166
- }
5167
- if (data.width !== undefined) {
5168
- this.width = data.width;
5169
- }
5170
- if (data.height !== undefined) {
5171
- this.height = data.height;
5172
- }
4343
+ loadProperty(this, "path", data.path);
4344
+ loadProperty(this, "svg", data.svg);
4345
+ loadProperty(this, "width", data.width);
4346
+ loadProperty(this, "height", data.height);
5173
4347
  }
5174
4348
  }
5175
4349
 
@@ -5226,41 +4400,27 @@
5226
4400
  if (isNull(data)) {
5227
4401
  return;
5228
4402
  }
5229
- if (data.enable !== undefined) {
5230
- this.enable = data.enable;
5231
- }
4403
+ loadProperty(this, "enable", data.enable);
5232
4404
  this.mute.load(data.mute);
5233
4405
  this.unmute.load(data.unmute);
5234
4406
  this.volumeDown.load(data.volumeDown);
5235
4407
  this.volumeUp.load(data.volumeUp);
5236
4408
  }
5237
4409
  }
5238
-
5239
- class SoundsVolume {
5240
- max;
5241
- min;
5242
- step;
5243
- value;
5244
- constructor() {
5245
- this.value = 100;
5246
- this.max = 100;
5247
- this.min = 0;
5248
- this.step = 10;
5249
- }
4410
+
4411
+ class SoundsVolume {
4412
+ max = 100;
4413
+ min = 0;
4414
+ step = 10;
4415
+ value = 100;
5250
4416
  load(data) {
5251
4417
  if (isNull(data)) {
5252
4418
  return;
5253
4419
  }
5254
4420
  if (isObject(data)) {
5255
- if (data.max !== undefined) {
5256
- this.max = data.max;
5257
- }
5258
- if (data.min !== undefined) {
5259
- this.min = data.min;
5260
- }
5261
- if (data.step !== undefined) {
5262
- this.step = data.step;
5263
- }
4421
+ loadProperty(this, "max", data.max);
4422
+ loadProperty(this, "min", data.min);
4423
+ loadProperty(this, "step", data.step);
5264
4424
  if (data.value !== undefined) {
5265
4425
  this.value = data.value;
5266
4426
  }
@@ -5272,28 +4432,17 @@
5272
4432
  }
5273
4433
 
5274
4434
  class Sounds {
5275
- autoPlay;
5276
- enable;
5277
- events;
5278
- icons;
5279
- volume;
5280
- constructor() {
5281
- this.autoPlay = true;
5282
- this.enable = false;
5283
- this.events = [];
5284
- this.icons = new SoundsIcons();
5285
- this.volume = new SoundsVolume();
5286
- }
4435
+ autoPlay = true;
4436
+ enable = false;
4437
+ events = [];
4438
+ icons = new SoundsIcons();
4439
+ volume = new SoundsVolume();
5287
4440
  load(data) {
5288
4441
  if (isNull(data)) {
5289
4442
  return;
5290
4443
  }
5291
- if (data.autoPlay !== undefined) {
5292
- this.autoPlay = data.autoPlay;
5293
- }
5294
- if (data.enable !== undefined) {
5295
- this.enable = data.enable;
5296
- }
4444
+ loadProperty(this, "autoPlay", data.autoPlay);
4445
+ loadProperty(this, "enable", data.enable);
5297
4446
  if (data.events !== undefined) {
5298
4447
  this.events = data.events.map(t => {
5299
4448
  const event = new SoundsEvent();
@@ -5378,7 +4527,7 @@
5378
4527
  }
5379
4528
 
5380
4529
  async function loadSoundsPlugin(engine) {
5381
- engine.checkVersion("4.1.3");
4530
+ engine.checkVersion("4.2.1");
5382
4531
  await engine.pluginManager.register(e => {
5383
4532
  e.pluginManager.addPlugin(new SoundsPlugin(e));
5384
4533
  });
@@ -5494,7 +4643,7 @@
5494
4643
  }
5495
4644
 
5496
4645
  async function loadTrailEffect(engine) {
5497
- engine.checkVersion("4.1.3");
4646
+ engine.checkVersion("4.2.1");
5498
4647
  await engine.pluginManager.register(e => {
5499
4648
  e.pluginManager.addEffect("trail", container => {
5500
4649
  return Promise.resolve(new TrailDrawer(container));
@@ -5581,7 +4730,7 @@
5581
4730
  return;
5582
4731
  }
5583
4732
  this.draw(ctx => {
5584
- clear(ctx, this.#canvasManager.size);
4733
+ ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
5585
4734
  });
5586
4735
  }
5587
4736
  clear() {
@@ -5643,7 +4792,7 @@
5643
4792
  plugin.drawParticleSetup?.(context, particle, delta);
5644
4793
  }
5645
4794
  this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
5646
- drawParticle({
4795
+ this.#drawParticle({
5647
4796
  container,
5648
4797
  context,
5649
4798
  particle,
@@ -5662,7 +4811,7 @@
5662
4811
  drawParticlePlugins(particle, delta) {
5663
4812
  this.draw(ctx => {
5664
4813
  for (const plugin of this.#drawParticlePlugins) {
5665
- drawParticlePlugin(ctx, plugin, particle, delta);
4814
+ this.#drawParticlePlugin(ctx, plugin, particle, delta);
5666
4815
  }
5667
4816
  });
5668
4817
  }
@@ -5762,12 +4911,19 @@
5762
4911
  }
5763
4912
  paintBase(baseColor) {
5764
4913
  this.draw(ctx => {
5765
- paintBase(ctx, this.#canvasManager.size, baseColor);
4914
+ ctx.fillStyle = baseColor ?? "rgba(0,0,0,0)";
4915
+ ctx.fillRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
5766
4916
  });
5767
4917
  }
5768
4918
  paintImage(image, opacity) {
5769
4919
  this.draw(ctx => {
5770
- paintImage(ctx, this.#canvasManager.size, image, opacity);
4920
+ if (!image) {
4921
+ return;
4922
+ }
4923
+ const prevAlpha = ctx.globalAlpha;
4924
+ ctx.globalAlpha = opacity;
4925
+ ctx.drawImage(image, originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
4926
+ ctx.globalAlpha = prevAlpha;
5771
4927
  });
5772
4928
  }
5773
4929
  setContext(context) {
@@ -5781,15 +4937,15 @@
5781
4937
  }
5782
4938
  stop() {
5783
4939
  this.draw(ctx => {
5784
- clear(ctx, this.#canvasManager.size);
4940
+ ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
5785
4941
  });
5786
4942
  }
5787
- #applyPostDrawUpdaters = particle => {
4943
+ #applyPostDrawUpdaters(particle) {
5788
4944
  for (const updater of this.#postDrawUpdaters) {
5789
4945
  updater.afterDraw?.(particle);
5790
4946
  }
5791
- };
5792
- #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4947
+ }
4948
+ #applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
5793
4949
  for (const updater of this.#preDrawUpdaters) {
5794
4950
  if (updater.getColorStyles) {
5795
4951
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
@@ -5808,8 +4964,114 @@
5808
4964
  }
5809
4965
  updater.beforeDraw?.(particle);
5810
4966
  }
5811
- };
5812
- #getPluginParticleColors = particle => {
4967
+ }
4968
+ #drawAfterEffect(drawer, data) {
4969
+ if (!drawer?.drawAfter) {
4970
+ return;
4971
+ }
4972
+ const { particle } = data;
4973
+ if (!particle.effect) {
4974
+ return;
4975
+ }
4976
+ drawer.drawAfter(data);
4977
+ }
4978
+ #drawBeforeEffect(drawer, data) {
4979
+ if (!drawer?.drawBefore) {
4980
+ return;
4981
+ }
4982
+ const { particle } = data;
4983
+ if (!particle.effect) {
4984
+ return;
4985
+ }
4986
+ drawer.drawBefore(data);
4987
+ }
4988
+ #drawParticle(data) {
4989
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
4990
+ x: pos.x,
4991
+ y: pos.y,
4992
+ };
4993
+ context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
4994
+ if (colorStyles.fill) {
4995
+ context.fillStyle = colorStyles.fill;
4996
+ }
4997
+ const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
4998
+ context.lineWidth = strokeWidth;
4999
+ if (colorStyles.stroke) {
5000
+ context.strokeStyle = colorStyles.stroke;
5001
+ }
5002
+ const drawData = {
5003
+ context,
5004
+ particle,
5005
+ radius,
5006
+ drawRadius: radius * drawScale,
5007
+ opacity,
5008
+ delta,
5009
+ pixelRatio: container.retina.pixelRatio,
5010
+ fill: fillEnabled,
5011
+ stroke: strokeWidth > minStrokeWidth,
5012
+ transformData,
5013
+ position: { ...pos },
5014
+ drawPosition,
5015
+ drawScale,
5016
+ };
5017
+ for (const plugin of container.plugins) {
5018
+ plugin.drawParticleTransform?.(drawData);
5019
+ }
5020
+ const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
5021
+ this.#drawBeforeEffect(effect, drawData);
5022
+ this.#drawShapeBeforeDraw(shape, drawData);
5023
+ this.#drawShape(shape, drawData);
5024
+ this.#drawShapeAfterDraw(shape, drawData);
5025
+ this.#drawAfterEffect(effect, drawData);
5026
+ context.resetTransform();
5027
+ }
5028
+ #drawParticlePlugin(context, plugin, particle, delta) {
5029
+ if (!plugin.drawParticle) {
5030
+ return;
5031
+ }
5032
+ plugin.drawParticle(context, particle, delta);
5033
+ }
5034
+ #drawShape(drawer, data) {
5035
+ if (!drawer) {
5036
+ return;
5037
+ }
5038
+ const { context, fill, particle, stroke } = data;
5039
+ if (!particle.shape) {
5040
+ return;
5041
+ }
5042
+ context.beginPath();
5043
+ drawer.draw(data);
5044
+ if (particle.shapeClose) {
5045
+ context.closePath();
5046
+ }
5047
+ if (fill) {
5048
+ context.fill();
5049
+ }
5050
+ if (stroke) {
5051
+ context.stroke();
5052
+ }
5053
+ }
5054
+ #drawShapeAfterDraw(drawer, data) {
5055
+ if (!drawer?.afterDraw) {
5056
+ return;
5057
+ }
5058
+ const { particle } = data;
5059
+ if (!particle.shape) {
5060
+ return;
5061
+ }
5062
+ drawer.afterDraw(data);
5063
+ }
5064
+ #drawShapeBeforeDraw(drawer, data) {
5065
+ if (!drawer?.beforeDraw) {
5066
+ return;
5067
+ }
5068
+ const { particle } = data;
5069
+ if (!particle.shape) {
5070
+ return;
5071
+ }
5072
+ drawer.beforeDraw(data);
5073
+ }
5074
+ #getPluginParticleColors(particle) {
5813
5075
  let fColor, sColor;
5814
5076
  for (const plugin of this.#colorPlugins) {
5815
5077
  if (!fColor && plugin.particleFillColor) {
@@ -5825,7 +5087,7 @@
5825
5087
  this.#reusablePluginColors[fColorIndex] = fColor;
5826
5088
  this.#reusablePluginColors[sColorIndex] = sColor;
5827
5089
  return this.#reusablePluginColors;
5828
- };
5090
+ }
5829
5091
  }
5830
5092
 
5831
5093
  const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
@@ -5957,6 +5219,7 @@
5957
5219
  obs.observe(element, { attributes: true });
5958
5220
  });
5959
5221
  this.initPlugins();
5222
+ this.#initContext();
5960
5223
  this.render.init();
5961
5224
  }
5962
5225
  initBackground() {
@@ -5966,7 +5229,7 @@
5966
5229
  }
5967
5230
  const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
5968
5231
  if (color) {
5969
- elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
5232
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
5970
5233
  }
5971
5234
  else {
5972
5235
  elementStyle.backgroundColor = "";
@@ -5988,7 +5251,7 @@
5988
5251
  if (this.#generated && this.domElement) {
5989
5252
  this.domElement.remove();
5990
5253
  }
5991
- const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
5254
+ const domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
5992
5255
  this.domElement = domCanvas;
5993
5256
  this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
5994
5257
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
@@ -6009,26 +5272,6 @@
6009
5272
  const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
6010
5273
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
6011
5274
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
6012
- const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
6013
- this.render.setContextSettings({
6014
- alpha: true,
6015
- colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
6016
- desynchronized: true,
6017
- willReadFrequently: false,
6018
- });
6019
- this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
6020
- this.#safeMutationObserver(obs => {
6021
- obs.disconnect();
6022
- });
6023
- container.retina.init();
6024
- this.initBackground();
6025
- this.#safeMutationObserver(obs => {
6026
- const element = this.domElement;
6027
- if (!element || !(element instanceof Node)) {
6028
- return;
6029
- }
6030
- obs.observe(element, { attributes: true });
6031
- });
6032
5275
  }
6033
5276
  resize() {
6034
5277
  const element = this.domElement;
@@ -6096,12 +5339,30 @@
6096
5339
  await container.refresh();
6097
5340
  }
6098
5341
  }
6099
- #applyResizePlugins = () => {
5342
+ #applyResizePlugins() {
6100
5343
  for (const plugin of this.#resizePlugins) {
6101
5344
  plugin.resize?.();
6102
5345
  }
6103
- };
6104
- #initStyle = () => {
5346
+ }
5347
+ #initContext() {
5348
+ const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
5349
+ safeMatchMedia("(color-gamut: p3)")?.matches &&
5350
+ safeMatchMedia("(dynamic-range: high)")?.matches;
5351
+ this.render.setContextSettings({
5352
+ alpha: true,
5353
+ desynchronized: true,
5354
+ willReadFrequently: false,
5355
+ ...(canSupportHdr
5356
+ ? { colorSpace: "display-p3", colorType: "float16" }
5357
+ : { colorSpace: "srgb" }),
5358
+ });
5359
+ const renderCanvas = this.renderCanvas;
5360
+ if (!renderCanvas) {
5361
+ return;
5362
+ }
5363
+ this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
5364
+ }
5365
+ #initStyle() {
6105
5366
  const element = this.domElement, options = this.#container.actualOptions;
6106
5367
  if (!element) {
6107
5368
  return;
@@ -6122,8 +5383,8 @@
6122
5383
  }
6123
5384
  element.style.setProperty(key, value, "important");
6124
5385
  }
6125
- };
6126
- #repairStyle = () => {
5386
+ }
5387
+ #repairStyle() {
6127
5388
  const element = this.domElement;
6128
5389
  if (!element) {
6129
5390
  return;
@@ -6142,27 +5403,27 @@
6142
5403
  }
6143
5404
  observer.observe(element, { attributes: true });
6144
5405
  });
6145
- };
6146
- #resetOriginalStyle = () => {
5406
+ }
5407
+ #resetOriginalStyle() {
6147
5408
  const element = this.domElement, originalStyle = this.#originalStyle;
6148
5409
  if (!element || !originalStyle) {
6149
5410
  return;
6150
5411
  }
6151
5412
  setStyle(element, originalStyle, true);
6152
- };
6153
- #safeMutationObserver = callback => {
5413
+ }
5414
+ #safeMutationObserver(callback) {
6154
5415
  if (!this.#mutationObserver) {
6155
5416
  return;
6156
5417
  }
6157
5418
  callback(this.#mutationObserver);
6158
- };
6159
- #setFullScreenStyle = () => {
5419
+ }
5420
+ #setFullScreenStyle() {
6160
5421
  const element = this.domElement;
6161
5422
  if (!element) {
6162
5423
  return;
6163
5424
  }
6164
5425
  setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
6165
- };
5426
+ }
6166
5427
  }
6167
5428
 
6168
5429
  class EventListeners {
@@ -6187,7 +5448,7 @@
6187
5448
  removeListeners() {
6188
5449
  this.#manageListeners(false);
6189
5450
  }
6190
- #handleVisibilityChange = () => {
5451
+ #handleVisibilityChange() {
6191
5452
  const container = this.#container, options = container.actualOptions;
6192
5453
  if (!options.pauseOnBlur) {
6193
5454
  return;
@@ -6205,8 +5466,8 @@
6205
5466
  container.draw(true);
6206
5467
  }
6207
5468
  }
6208
- };
6209
- #handleWindowResize = () => {
5469
+ }
5470
+ #handleWindowResize() {
6210
5471
  if (this.#resizeTimeout) {
6211
5472
  clearTimeout(this.#resizeTimeout);
6212
5473
  this.#resizeTimeout = undefined;
@@ -6216,13 +5477,13 @@
6216
5477
  await canvas.windowResize();
6217
5478
  };
6218
5479
  this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
6219
- };
6220
- #manageListeners = add => {
5480
+ }
5481
+ #manageListeners(add) {
6221
5482
  const handlers = this.#handlers;
6222
5483
  this.#manageResize(add);
6223
5484
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
6224
- };
6225
- #manageResize = add => {
5485
+ }
5486
+ #manageResize(add) {
6226
5487
  const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
6227
5488
  if (!options.resize.enable) {
6228
5489
  return;
@@ -6249,7 +5510,7 @@
6249
5510
  });
6250
5511
  this.#resizeObserver.observe(canvasEl);
6251
5512
  }
6252
- };
5513
+ }
6253
5514
  }
6254
5515
 
6255
5516
  function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
@@ -6276,6 +5537,131 @@
6276
5537
  data.setCb(data.radius);
6277
5538
  }
6278
5539
  }
5540
+ function normalizeAngle(angle, modulus) {
5541
+ const normalized = angle % modulus;
5542
+ return normalized < defaultAngle ? normalized + modulus : normalized;
5543
+ }
5544
+ function initParticleState(particle, id, group) {
5545
+ particle.id = id;
5546
+ particle.group = group;
5547
+ particle.justWarped = false;
5548
+ particle.effectClose = true;
5549
+ particle.shapeClose = true;
5550
+ particle.pathRotation = false;
5551
+ particle.lastPathTime = 0;
5552
+ particle.destroyed = false;
5553
+ particle.unbreakable = false;
5554
+ particle.isRotating = false;
5555
+ particle.rotation = 0;
5556
+ particle.misplaced = false;
5557
+ particle.retina = {
5558
+ maxDistance: {},
5559
+ maxSpeed: 0,
5560
+ moveDrift: 0,
5561
+ moveSpeed: 0,
5562
+ sizeAnimationSpeed: 0,
5563
+ };
5564
+ particle.size = {
5565
+ value: 1,
5566
+ max: 1,
5567
+ min: 1,
5568
+ enable: false,
5569
+ };
5570
+ particle.outType = ParticleOutType.normal;
5571
+ particle.ignoresResizeRatio = true;
5572
+ }
5573
+ function resolveParticleOptions(particle, container, pluginManager, overrideOptions) {
5574
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates;
5575
+ particle.effect = itemFromSingleOrMultiple(particlesOptions.effect.type, particle.id, reduceDuplicates);
5576
+ particle.shape = itemFromSingleOrMultiple(particlesOptions.shape.type, particle.id, reduceDuplicates);
5577
+ const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
5578
+ if (overrideOptions) {
5579
+ if (overrideOptions.effect) {
5580
+ const overrideEffectType = overrideOptions.effect.type;
5581
+ if (overrideEffectType && overrideEffectType !== particle.effect) {
5582
+ const effect = itemFromSingleOrMultiple(overrideEffectType, particle.id, reduceDuplicates);
5583
+ if (effect) {
5584
+ particle.effect = effect;
5585
+ }
5586
+ }
5587
+ effectOptions.load(overrideOptions.effect);
5588
+ }
5589
+ if (overrideOptions.shape) {
5590
+ const overrideShapeType = overrideOptions.shape.type;
5591
+ if (overrideShapeType && overrideShapeType !== particle.shape) {
5592
+ const shape = itemFromSingleOrMultiple(overrideShapeType, particle.id, reduceDuplicates);
5593
+ if (shape) {
5594
+ particle.shape = shape;
5595
+ }
5596
+ }
5597
+ shapeOptions.load(overrideOptions.shape);
5598
+ }
5599
+ }
5600
+ if (particle.effect === randomColorValue) {
5601
+ const availableEffects = [...container.effectDrawers.keys()];
5602
+ particle.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
5603
+ }
5604
+ if (particle.shape === randomColorValue) {
5605
+ const availableShapes = [...container.shapeDrawers.keys()];
5606
+ particle.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
5607
+ }
5608
+ particle.effectData = particle.effect
5609
+ ? loadEffectData(particle.effect, effectOptions, particle.id, reduceDuplicates)
5610
+ : undefined;
5611
+ particle.shapeData = particle.shape
5612
+ ? loadShapeData(particle.shape, shapeOptions, particle.id, reduceDuplicates)
5613
+ : undefined;
5614
+ particlesOptions.load(overrideOptions);
5615
+ const effectData = particle.effectData, shapeData = particle.shapeData;
5616
+ if (effectData) {
5617
+ particlesOptions.load(effectData.particles);
5618
+ }
5619
+ if (shapeData) {
5620
+ particlesOptions.load(shapeData.particles);
5621
+ }
5622
+ particle.effectClose = effectData?.close ?? particlesOptions.effect.close;
5623
+ particle.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
5624
+ return particlesOptions;
5625
+ }
5626
+ function initParticleDrawers(particle, container) {
5627
+ let effectDrawer, shapeDrawer;
5628
+ if (particle.effect) {
5629
+ effectDrawer = container.effectDrawers.get(particle.effect);
5630
+ }
5631
+ if (effectDrawer?.loadEffect) {
5632
+ effectDrawer.loadEffect(particle);
5633
+ }
5634
+ if (particle.shape) {
5635
+ shapeDrawer = container.shapeDrawers.get(particle.shape);
5636
+ }
5637
+ if (shapeDrawer?.loadShape) {
5638
+ shapeDrawer.loadShape(particle);
5639
+ }
5640
+ const sideCountFunc = shapeDrawer?.getSidesCount;
5641
+ if (sideCountFunc) {
5642
+ particle.sides = sideCountFunc(particle);
5643
+ }
5644
+ }
5645
+ function runUpdaterPreInit(updaters, particle) {
5646
+ for (const updater of updaters) {
5647
+ updater.preInit?.(particle);
5648
+ }
5649
+ }
5650
+ function runUpdaterInit(updaters, particle) {
5651
+ for (const updater of updaters) {
5652
+ updater.init(particle);
5653
+ }
5654
+ }
5655
+ function runDrawerInit(container, particle) {
5656
+ const shapeDrawer = particle.shape ? container.shapeDrawers.get(particle.shape) : undefined, effectDrawer = particle.effect ? container.effectDrawers.get(particle.effect) : undefined;
5657
+ effectDrawer?.particleInit?.(container, particle);
5658
+ shapeDrawer?.particleInit?.(container, particle);
5659
+ }
5660
+ function runParticleCreatedPlugins(container, particle) {
5661
+ for (const plugin of container.particleCreatedPlugins) {
5662
+ plugin.particleCreated?.(particle);
5663
+ }
5664
+ }
6279
5665
  class Particle {
6280
5666
  backColor;
6281
5667
  bubble;
@@ -6401,94 +5787,20 @@
6401
5787
  const rotateData = this.getRotateData(), rotating = this.isRotating;
6402
5788
  this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform$1.a);
6403
5789
  this.#cachedTransform.b = rotating
6404
- ? rotateData.sin * (externalTransform.b ?? identity$2)
5790
+ ? rotateData.sin * (externalTransform.b ?? identity$1)
6405
5791
  : (externalTransform.b ?? defaultTransform$1.b);
6406
5792
  this.#cachedTransform.c = rotating
6407
- ? -rotateData.sin * (externalTransform.c ?? identity$2)
5793
+ ? -rotateData.sin * (externalTransform.c ?? identity$1)
6408
5794
  : (externalTransform.c ?? defaultTransform$1.c);
6409
5795
  this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform$1.d);
6410
5796
  return this.#cachedTransform;
6411
5797
  }
6412
5798
  init(id, position, overrideOptions, group) {
6413
5799
  const container = this.#container;
6414
- this.id = id;
6415
- this.group = group;
6416
- this.justWarped = false;
6417
- this.effectClose = true;
6418
- this.shapeClose = true;
6419
- this.pathRotation = false;
6420
- this.lastPathTime = 0;
6421
- this.destroyed = false;
6422
- this.unbreakable = false;
6423
- this.isRotating = false;
6424
- this.rotation = 0;
6425
- this.misplaced = false;
6426
- this.retina = {
6427
- maxDistance: {},
6428
- maxSpeed: 0,
6429
- moveDrift: 0,
6430
- moveSpeed: 0,
6431
- sizeAnimationSpeed: 0,
6432
- };
6433
- this.size = {
6434
- value: 1,
6435
- max: 1,
6436
- min: 1,
6437
- enable: false,
6438
- };
6439
- this.outType = ParticleOutType.normal;
6440
- this.ignoresResizeRatio = true;
6441
- const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
6442
- this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
6443
- this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
6444
- const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
6445
- if (overrideOptions) {
6446
- if (overrideOptions.effect) {
6447
- const overrideEffectType = overrideOptions.effect.type;
6448
- if (overrideEffectType && overrideEffectType !== this.effect) {
6449
- const effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
6450
- if (effect) {
6451
- this.effect = effect;
6452
- }
6453
- }
6454
- effectOptions.load(overrideOptions.effect);
6455
- }
6456
- if (overrideOptions.shape) {
6457
- const overrideShapeType = overrideOptions.shape.type;
6458
- if (overrideShapeType && overrideShapeType !== this.shape) {
6459
- const shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
6460
- if (shape) {
6461
- this.shape = shape;
6462
- }
6463
- }
6464
- shapeOptions.load(overrideOptions.shape);
6465
- }
6466
- }
6467
- if (this.effect === randomColorValue) {
6468
- const availableEffects = [...this.#container.effectDrawers.keys()];
6469
- this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
6470
- }
6471
- if (this.shape === randomColorValue) {
6472
- const availableShapes = [...this.#container.shapeDrawers.keys()];
6473
- this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
6474
- }
6475
- this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
6476
- this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
6477
- particlesOptions.load(overrideOptions);
6478
- const effectData = this.effectData, shapeData = this.shapeData;
6479
- if (effectData) {
6480
- particlesOptions.load(effectData.particles);
6481
- }
6482
- if (shapeData) {
6483
- particlesOptions.load(shapeData.particles);
6484
- }
6485
- this.effectClose = effectData?.close ?? particlesOptions.effect.close;
6486
- this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
6487
- this.options = particlesOptions;
5800
+ initParticleState(this, id, group);
5801
+ this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
6488
5802
  container.retina.initParticle(this);
6489
- for (const updater of container.particleUpdaters) {
6490
- updater.preInit?.(this);
6491
- }
5803
+ runUpdaterPreInit(container.particleUpdaters, this);
6492
5804
  this.bubble = {
6493
5805
  inRange: false,
6494
5806
  };
@@ -6501,32 +5813,11 @@
6501
5813
  this.velocity = this.initialVelocity.copy();
6502
5814
  this.zIndexFactor = this.position.z / container.zLayers;
6503
5815
  this.sides = 24;
6504
- let effectDrawer, shapeDrawer;
6505
- if (this.effect) {
6506
- effectDrawer = container.effectDrawers.get(this.effect);
6507
- }
6508
- if (effectDrawer?.loadEffect) {
6509
- effectDrawer.loadEffect(this);
6510
- }
6511
- if (this.shape) {
6512
- shapeDrawer = container.shapeDrawers.get(this.shape);
6513
- }
6514
- if (shapeDrawer?.loadShape) {
6515
- shapeDrawer.loadShape(this);
6516
- }
6517
- const sideCountFunc = shapeDrawer?.getSidesCount;
6518
- if (sideCountFunc) {
6519
- this.sides = sideCountFunc(this);
6520
- }
5816
+ initParticleDrawers(this, container);
6521
5817
  this.spawning = false;
6522
- for (const updater of container.particleUpdaters) {
6523
- updater.init(this);
6524
- }
6525
- effectDrawer?.particleInit?.(container, this);
6526
- shapeDrawer?.particleInit?.(container, this);
6527
- for (const plugin of container.particleCreatedPlugins) {
6528
- plugin.particleCreated?.(this);
6529
- }
5818
+ runUpdaterInit(container.particleUpdaters, this);
5819
+ runDrawerInit(container, this);
5820
+ runParticleCreatedPlugins(container, this);
6530
5821
  }
6531
5822
  isInsideCanvas(direction) {
6532
5823
  return this.#getInsideCanvasResult({ direction }).inside;
@@ -6540,15 +5831,15 @@
6540
5831
  }
6541
5832
  const angle = this.roll.angle;
6542
5833
  if (this.roll.horizontal && this.roll.vertical) {
6543
- const normalizedAngle = angle % doublePI, adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + doublePI : normalizedAngle;
5834
+ const adjustedAngle = normalizeAngle(angle, doublePI);
6544
5835
  return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
6545
5836
  }
6546
5837
  if (this.roll.horizontal) {
6547
- const normalizedAngle = (angle + Math.PI * half) % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
5838
+ const adjustedAngle = normalizeAngle(angle + Math.PI * half, doublePI);
6548
5839
  return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
6549
5840
  }
6550
5841
  if (this.roll.vertical) {
6551
- const normalizedAngle = angle % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
5842
+ const adjustedAngle = normalizeAngle(angle, doublePI);
6552
5843
  return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
6553
5844
  }
6554
5845
  return false;
@@ -6561,10 +5852,10 @@
6561
5852
  updater.reset?.(this);
6562
5853
  }
6563
5854
  }
6564
- #calcPosition = (position, zIndex) => {
5855
+ #calcPosition(position, zIndex) {
6565
5856
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
6566
- const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
6567
- while (!signal.aborted) {
5857
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
5858
+ for (;;) {
6568
5859
  for (const plugin of plugins) {
6569
5860
  const pluginPos = plugin.particlePosition?.(posVec, this);
6570
5861
  if (pluginPos) {
@@ -6592,9 +5883,8 @@
6592
5883
  tryCount += tryCountIncrement;
6593
5884
  posVec = undefined;
6594
5885
  }
6595
- return posVec;
6596
- };
6597
- #calculateVelocity = () => {
5886
+ }
5887
+ #calculateVelocity() {
6598
5888
  const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
6599
5889
  if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
6600
5890
  return res;
@@ -6610,8 +5900,8 @@
6610
5900
  res.length *= getRandom();
6611
5901
  }
6612
5902
  return res;
6613
- };
6614
- #fixHorizontal = (pos, radius, outMode) => {
5903
+ }
5904
+ #fixHorizontal(pos, radius, outMode) {
6615
5905
  fixOutMode({
6616
5906
  outMode,
6617
5907
  checkModes: [OutMode.bounce],
@@ -6620,8 +5910,8 @@
6620
5910
  setCb: (value) => (pos.x += value),
6621
5911
  radius,
6622
5912
  });
6623
- };
6624
- #fixVertical = (pos, radius, outMode) => {
5913
+ }
5914
+ #fixVertical(pos, radius, outMode) {
6625
5915
  fixOutMode({
6626
5916
  outMode,
6627
5917
  checkModes: [OutMode.bounce],
@@ -6630,8 +5920,8 @@
6630
5920
  setCb: (value) => (pos.y += value),
6631
5921
  radius,
6632
5922
  });
6633
- };
6634
- #getDefaultInsideCanvasResult = (direction, outMode) => {
5923
+ }
5924
+ #getDefaultInsideCanvasResult(direction, outMode) {
6635
5925
  const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
6636
5926
  if (direction === OutModeDirection.bottom) {
6637
5927
  return {
@@ -6664,8 +5954,8 @@
6664
5954
  position.x <= canvasSize.width + radius,
6665
5955
  reason: "default",
6666
5956
  };
6667
- };
6668
- #getInsideCanvasCallbackData = (direction, outMode) => {
5957
+ }
5958
+ #getInsideCanvasCallbackData(direction, outMode) {
6669
5959
  return {
6670
5960
  canvasSize: this.#container.canvas.size,
6671
5961
  direction,
@@ -6673,8 +5963,8 @@
6673
5963
  particle: this,
6674
5964
  radius: this.getRadius(),
6675
5965
  };
6676
- };
6677
- #getInsideCanvasResult = (data) => {
5966
+ }
5967
+ #getInsideCanvasResult(data) {
6678
5968
  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;
6679
5969
  if (!shapeCheck && !effectCheck) {
6680
5970
  return defaultResult;
@@ -6689,8 +5979,8 @@
6689
5979
  };
6690
5980
  }
6691
5981
  return shapeResult ?? effectResult ?? defaultResult;
6692
- };
6693
- #getRollColor = color => {
5982
+ }
5983
+ #getRollColor(color) {
6694
5984
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
6695
5985
  return color;
6696
5986
  }
@@ -6704,8 +5994,8 @@
6704
5994
  return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
6705
5995
  }
6706
5996
  return color;
6707
- };
6708
- #initPosition = position => {
5997
+ }
5998
+ #initPosition(position) {
6709
5999
  const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
6710
6000
  if (!initialPosition) {
6711
6001
  throw new Error("a valid position cannot be found for particle");
@@ -6728,8 +6018,8 @@
6728
6018
  break;
6729
6019
  }
6730
6020
  this.offset = Vector.origin;
6731
- };
6732
- #normalizeInsideCanvasResult = (result, reason) => {
6021
+ }
6022
+ #normalizeInsideCanvasResult(result, reason) {
6733
6023
  if (typeof result === "boolean") {
6734
6024
  return {
6735
6025
  inside: result,
@@ -6741,7 +6031,7 @@
6741
6031
  margin: result.margin,
6742
6032
  reason: result.reason ?? reason,
6743
6033
  };
6744
- };
6034
+ }
6745
6035
  }
6746
6036
 
6747
6037
  class SpatialHashGrid {
@@ -7094,10 +6384,10 @@
7094
6384
  }
7095
6385
  this.#resizeFactor = undefined;
7096
6386
  }
7097
- #addToPool = (...particles) => {
6387
+ #addToPool(...particles) {
7098
6388
  this.#pool.push(...particles);
7099
- };
7100
- #applyDensity = (options, pluginsCount, group, groupOptions) => {
6389
+ }
6390
+ #applyDensity(options, pluginsCount, group, groupOptions) {
7101
6391
  const numberOptions = options.number;
7102
6392
  if (!numberOptions.density.enable) {
7103
6393
  if (group === undefined) {
@@ -7121,36 +6411,19 @@
7121
6411
  else if (particlesCount > particlesNumber) {
7122
6412
  this.removeQuantity(particlesCount - particlesNumber, group);
7123
6413
  }
7124
- };
7125
- #createBuckets = (zLayers) => {
6414
+ }
6415
+ #createBuckets(zLayers) {
7126
6416
  const bucketCount = Math.max(Math.floor(zLayers), one);
7127
6417
  return Array.from({ length: bucketCount }, () => []);
7128
- };
7129
- #getBucketIndex = (zIndex) => {
6418
+ }
6419
+ #getBucketIndex(zIndex) {
7130
6420
  const maxBucketIndex = this.#zBuckets.length - one;
7131
6421
  if (maxBucketIndex <= minIndex) {
7132
6422
  return minIndex;
7133
6423
  }
7134
6424
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
7135
- };
7136
- #getParticleInsertIndex = (bucket, particleId) => {
7137
- let start = minIndex, end = bucket.length;
7138
- while (start < end) {
7139
- const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
7140
- if (!middleParticle) {
7141
- end = middle;
7142
- continue;
7143
- }
7144
- if (middleParticle.id < particleId) {
7145
- start = middle + one;
7146
- }
7147
- else {
7148
- end = middle;
7149
- }
7150
- }
7151
- return start;
7152
- };
7153
- #initDensityFactor = densityOptions => {
6425
+ }
6426
+ #initDensityFactor(densityOptions) {
7154
6427
  const container = this.#container;
7155
6428
  if (!densityOptions.enable) {
7156
6429
  return defaultDensityFactor;
@@ -7160,16 +6433,16 @@
7160
6433
  return defaultDensityFactor;
7161
6434
  }
7162
6435
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
7163
- };
7164
- #insertParticleIntoBucket = (particle) => {
6436
+ }
6437
+ #insertParticleIntoBucket(particle) {
7165
6438
  const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
7166
6439
  if (!bucket) {
7167
6440
  return;
7168
6441
  }
7169
- bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
6442
+ bucket.push(particle);
7170
6443
  this.#particleBuckets.set(particle.id, bucketIndex);
7171
- };
7172
- #removeParticle = (index, group, override) => {
6444
+ }
6445
+ #removeParticle(index, group, override) {
7173
6446
  const particle = this.#array[index];
7174
6447
  if (!particle) {
7175
6448
  return false;
@@ -7185,22 +6458,20 @@
7185
6458
  });
7186
6459
  this.#addToPool(particle);
7187
6460
  return true;
7188
- };
7189
- #removeParticleFromBucket = (particle) => {
6461
+ }
6462
+ #removeParticleFromBucket(particle) {
7190
6463
  const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
7191
6464
  if (!bucket) {
7192
6465
  this.#particleBuckets.delete(particle.id);
7193
6466
  return;
7194
6467
  }
7195
- const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
7196
- if (bucket[particleIndex]?.id !== particle.id) {
7197
- this.#particleBuckets.delete(particle.id);
7198
- return;
6468
+ const idx = bucket.findIndex(p => p.id === particle.id);
6469
+ if (idx >= minIndex) {
6470
+ bucket.splice(idx, deleteCount);
7199
6471
  }
7200
- bucket.splice(particleIndex, deleteCount);
7201
6472
  this.#particleBuckets.delete(particle.id);
7202
- };
7203
- #resetBuckets = (zLayers) => {
6473
+ }
6474
+ #resetBuckets(zLayers) {
7204
6475
  const bucketCount = Math.max(Math.floor(zLayers), one);
7205
6476
  if (this.#zBuckets.length !== bucketCount) {
7206
6477
  this.#zBuckets = this.#createBuckets(bucketCount);
@@ -7209,8 +6480,8 @@
7209
6480
  for (const bucket of this.#zBuckets) {
7210
6481
  bucket.length = minIndex;
7211
6482
  }
7212
- };
7213
- #updateParticleBucket = (particle) => {
6483
+ }
6484
+ #updateParticleBucket(particle) {
7214
6485
  const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
7215
6486
  if (currentBucketIndex === undefined) {
7216
6487
  this.#insertParticleIntoBucket(particle);
@@ -7221,9 +6492,9 @@
7221
6492
  }
7222
6493
  const currentBucket = this.#zBuckets[currentBucketIndex];
7223
6494
  if (currentBucket) {
7224
- const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
7225
- if (currentBucket[particleIndex]?.id === particle.id) {
7226
- currentBucket.splice(particleIndex, deleteCount);
6495
+ const idx = currentBucket.findIndex(p => p.id === particle.id);
6496
+ if (idx >= minIndex) {
6497
+ currentBucket.splice(idx, deleteCount);
7227
6498
  }
7228
6499
  }
7229
6500
  const newBucket = this.#zBuckets[newBucketIndex];
@@ -7231,10 +6502,16 @@
7231
6502
  this.#particleBuckets.set(particle.id, newBucketIndex);
7232
6503
  return;
7233
6504
  }
7234
- newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
6505
+ newBucket.push(particle);
6506
+ if (newBucket.length >= double) {
6507
+ const prev = newBucket[newBucket.length - double];
6508
+ if (prev && particle.id < prev.id) {
6509
+ newBucket.sort((a, b) => a.id - b.id);
6510
+ }
6511
+ }
7235
6512
  this.#particleBuckets.set(particle.id, newBucketIndex);
7236
- };
7237
- #updateParticlesPhase1 = (delta) => {
6513
+ }
6514
+ #updateParticlesPhase1(delta) {
7238
6515
  const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
7239
6516
  for (const particle of this.#array) {
7240
6517
  if (resizeFactor && !particle.ignoresResizeRatio) {
@@ -7260,8 +6537,8 @@
7260
6537
  this.grid.insert(particle);
7261
6538
  }
7262
6539
  return particlesToDelete;
7263
- };
7264
- #updateParticlesPhase2 = (delta, particlesToDelete) => {
6540
+ }
6541
+ #updateParticlesPhase2(delta, particlesToDelete) {
7265
6542
  for (const particle of this.#array) {
7266
6543
  if (particle.destroyed) {
7267
6544
  particlesToDelete.add(particle);
@@ -7277,7 +6554,7 @@
7277
6554
  }
7278
6555
  this.#updateParticleBucket(particle);
7279
6556
  }
7280
- };
6557
+ }
7281
6558
  }
7282
6559
 
7283
6560
  class Retina {
@@ -7639,7 +6916,7 @@
7639
6916
  }
7640
6917
  return refresh;
7641
6918
  }
7642
- #nextFrame = (timestamp) => {
6919
+ #nextFrame(timestamp) {
7643
6920
  try {
7644
6921
  if (!this.#smooth &&
7645
6922
  this.#lastFrameTime !== undefined &&
@@ -7667,7 +6944,7 @@
7667
6944
  catch (e) {
7668
6945
  getLogger().error("error in animation loop", e);
7669
6946
  }
7670
- };
6947
+ }
7671
6948
  }
7672
6949
 
7673
6950
  var Container$1 = /*#__PURE__*/Object.freeze({
@@ -7713,7 +6990,7 @@
7713
6990
  BlendPluginInstance: BlendPluginInstance
7714
6991
  });
7715
6992
 
7716
- const minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
6993
+ const moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
7717
6994
  function applyDistance(particle) {
7718
6995
  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;
7719
6996
  if (!hDistance && !vDistance) {
@@ -7746,7 +7023,7 @@
7746
7023
  }
7747
7024
  function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {
7748
7025
  applyPath(particle, delta);
7749
- const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;
7026
+ const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity$1 : identity$1;
7750
7027
  if (moveDrift && moveSpeed) {
7751
7028
  particle.velocity.x += (moveDrift * delta.factor) / (moveSpeedFactor * moveSpeed);
7752
7029
  }
@@ -7766,7 +7043,7 @@
7766
7043
  particle.velocity.y = velocity.y / moveSpeed;
7767
7044
  }
7768
7045
  }
7769
- const zIndexOptions = particle.options.zIndex, zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;
7046
+ const zIndexOptions = particle.options.zIndex, zVelocityFactor = (identity$1 - particle.zIndexFactor) ** zIndexOptions.velocityRate;
7770
7047
  velocity.multTo(zVelocityFactor);
7771
7048
  velocity.multTo(reduceFactor);
7772
7049
  const { position } = particle;
@@ -7792,13 +7069,13 @@
7792
7069
  const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height), halfMaxSize = maxCanvasSize * half;
7793
7070
  if (particle.spin.radius > halfMaxSize) {
7794
7071
  particle.spin.radius = halfMaxSize;
7795
- particle.spin.acceleration *= -identity;
7072
+ particle.spin.acceleration *= -identity$1;
7796
7073
  }
7797
7074
  else if (particle.spin.radius < minSpinRadius) {
7798
7075
  particle.spin.radius = minSpinRadius;
7799
- particle.spin.acceleration *= -identity;
7076
+ particle.spin.acceleration *= -identity$1;
7800
7077
  }
7801
- particle.spin.angle += moveSpeed * spinFactor * (identity - particle.spin.radius / maxCanvasSize);
7078
+ particle.spin.angle += moveSpeed * spinFactor * (identity$1 - particle.spin.radius / maxCanvasSize);
7802
7079
  }
7803
7080
  function applyPath(particle, delta) {
7804
7081
  const particlesOptions = particle.options, pathOptions = particlesOptions.move.path, pathEnabled = pathOptions.enable;
@@ -7815,13 +7092,13 @@
7815
7092
  particle.velocity.addTo(path);
7816
7093
  }
7817
7094
  if (pathOptions.clamp) {
7818
- particle.velocity.x = clamp(particle.velocity.x, -identity, identity);
7819
- particle.velocity.y = clamp(particle.velocity.y, -identity, identity);
7095
+ particle.velocity.x = clamp(particle.velocity.x, -identity$1, identity$1);
7096
+ particle.velocity.y = clamp(particle.velocity.y, -identity$1, identity$1);
7820
7097
  }
7821
7098
  particle.lastPathTime -= pathDelay;
7822
7099
  }
7823
7100
  function getProximitySpeedFactor(particle) {
7824
- return particle.slow.inRange ? particle.slow.factor : identity;
7101
+ return particle.slow.inRange ? particle.slow.factor : identity$1;
7825
7102
  }
7826
7103
  function initSpin(container, particle) {
7827
7104
  const options = particle.options, spinOptions = options.move.spin;
@@ -8277,22 +7554,22 @@
8277
7554
  this.#volume += soundsOptions.volume.step;
8278
7555
  await this.#updateVolume();
8279
7556
  }
8280
- #addBuffer = audioCtx => {
7557
+ #addBuffer(audioCtx) {
8281
7558
  const buffer = audioCtx.createBufferSource();
8282
7559
  this.#audioSources.push(buffer);
8283
7560
  return buffer;
8284
- };
8285
- #addOscillator = audioCtx => {
7561
+ }
7562
+ #addOscillator(audioCtx) {
8286
7563
  const oscillator = audioCtx.createOscillator();
8287
7564
  this.#audioSources.push(oscillator);
8288
7565
  return oscillator;
8289
- };
7566
+ }
8290
7567
  #getAudioContext() {
8291
7568
  const container = this.#container;
8292
7569
  container.audioContext ??= new AudioContext();
8293
7570
  return container.audioContext;
8294
7571
  }
8295
- #initEvents = () => {
7572
+ #initEvents() {
8296
7573
  const container = this.#container, soundsOptions = container.actualOptions.sounds;
8297
7574
  if (!soundsOptions?.enable || !container.canvas.domElement) {
8298
7575
  return;
@@ -8349,8 +7626,8 @@
8349
7626
  this.#engine.addEventListener(item, cb);
8350
7627
  });
8351
7628
  }
8352
- };
8353
- #mute = async () => {
7629
+ }
7630
+ async #mute() {
8354
7631
  const container = this.#container, audioContext = this.#getAudioContext();
8355
7632
  for (const source of this.#audioSources) {
8356
7633
  this.#removeAudioSource(source);
@@ -8361,8 +7638,8 @@
8361
7638
  await audioContext.close();
8362
7639
  container.audioContext = undefined;
8363
7640
  this.#container.dispatchEvent(SoundsEventType.mute);
8364
- };
8365
- #playBuffer = audio => {
7641
+ }
7642
+ #playBuffer(audio) {
8366
7643
  const audioBuffer = this.#audioMap.get(audio.source);
8367
7644
  if (!audioBuffer) {
8368
7645
  return;
@@ -8376,8 +7653,8 @@
8376
7653
  source.buffer = audioBuffer;
8377
7654
  source.connect(this.#gain ?? audioCtx.destination);
8378
7655
  source.start();
8379
- };
8380
- #playFrequency = async (frequency, duration) => {
7656
+ }
7657
+ async #playFrequency(frequency, duration) {
8381
7658
  if (!this.#gain || this.#container.muted) {
8382
7659
  return;
8383
7660
  }
@@ -8392,8 +7669,8 @@
8392
7669
  resolve();
8393
7670
  }, duration);
8394
7671
  });
8395
- };
8396
- #playMuteSound = () => {
7672
+ }
7673
+ #playMuteSound() {
8397
7674
  if (this.#container.muted) {
8398
7675
  return;
8399
7676
  }
@@ -8410,8 +7687,8 @@
8410
7687
  oscillator.disconnect();
8411
7688
  gain.disconnect();
8412
7689
  });
8413
- };
8414
- #playNote = async (notes, noteIdx, loop) => {
7690
+ }
7691
+ async #playNote(notes, noteIdx, loop) {
8415
7692
  if (this.#container.muted) {
8416
7693
  return;
8417
7694
  }
@@ -8429,8 +7706,8 @@
8429
7706
  nextNoteIdx = nextNoteIdx % notes.length;
8430
7707
  }
8431
7708
  await this.#playNote(notes, nextNoteIdx, loop);
8432
- };
8433
- #playNoteValue = async (notes, noteIdx, valueIdx) => {
7709
+ }
7710
+ async #playNoteValue(notes, noteIdx, valueIdx) {
8434
7711
  const note = notes[noteIdx];
8435
7712
  if (!note) {
8436
7713
  return;
@@ -8449,14 +7726,14 @@
8449
7726
  catch (e) {
8450
7727
  getLogger().error(e);
8451
7728
  }
8452
- };
8453
- #removeAudioSource = source => {
7729
+ }
7730
+ #removeAudioSource(source) {
8454
7731
  source.stop();
8455
7732
  source.disconnect();
8456
7733
  const deleteCount = 1;
8457
7734
  this.#audioSources.splice(this.#audioSources.indexOf(source), deleteCount);
8458
- };
8459
- #unmute = () => {
7735
+ }
7736
+ #unmute() {
8460
7737
  const container = this.#container, options = container.actualOptions, soundsOptions = options.sounds;
8461
7738
  if (!soundsOptions) {
8462
7739
  return;
@@ -8467,8 +7744,8 @@
8467
7744
  this.#gain = gain;
8468
7745
  this.#initEvents();
8469
7746
  this.#container.dispatchEvent(SoundsEventType.unmute);
8470
- };
8471
- #updateMuteIcons = () => {
7747
+ }
7748
+ #updateMuteIcons() {
8472
7749
  const container = this.#container, soundsOptions = container.actualOptions.sounds;
8473
7750
  if (!soundsOptions?.enable || !soundsOptions.icons.enable) {
8474
7751
  return;
@@ -8480,8 +7757,8 @@
8480
7757
  if (unmuteImg) {
8481
7758
  unmuteImg.style.display = container.muted ? "none" : "block";
8482
7759
  }
8483
- };
8484
- #updateMuteStatus = async () => {
7760
+ }
7761
+ async #updateMuteStatus() {
8485
7762
  const container = this.#container, audioContext = this.#getAudioContext();
8486
7763
  if (container.muted) {
8487
7764
  await audioContext.suspend();
@@ -8492,8 +7769,8 @@
8492
7769
  this.#unmute();
8493
7770
  this.#playMuteSound();
8494
7771
  }
8495
- };
8496
- #updateVolume = async () => {
7772
+ }
7773
+ async #updateVolume() {
8497
7774
  const container = this.#container, soundsOptions = container.actualOptions.sounds;
8498
7775
  if (!soundsOptions?.enable) {
8499
7776
  return;
@@ -8516,7 +7793,7 @@
8516
7793
  if (this.#gain?.gain) {
8517
7794
  this.#gain.gain.value = this.#volume / percentDenominator;
8518
7795
  }
8519
- };
7796
+ }
8520
7797
  }
8521
7798
 
8522
7799
  var SoundsPluginInstance$1 = /*#__PURE__*/Object.freeze({
@@ -8609,7 +7886,13 @@
8609
7886
  this.#paused = !this.options.autoPlay;
8610
7887
  this.#particlesOptions = particlesOptions;
8611
7888
  this.#size = this.#calcSize();
8612
- this.size = getSize(this.#size, this.#container.canvas.size);
7889
+ this.size =
7890
+ this.#size.mode === PixelMode.percent
7891
+ ? {
7892
+ width: (this.#size.width / percentDenominator) * this.#container.canvas.size.width,
7893
+ height: (this.#size.height / percentDenominator) * this.#container.canvas.size.height,
7894
+ }
7895
+ : { width: this.#size.width, height: this.#size.height };
8613
7896
  this.#lifeCount = this.options.life.count ?? defaultLifeCount;
8614
7897
  this.#immortal = this.#lifeCount <= minLifeCount;
8615
7898
  if (this.options.domId) {
@@ -8680,7 +7963,13 @@
8680
7963
  ? initialPosition
8681
7964
  : this.#calcPosition();
8682
7965
  this.#size = this.#calcSize();
8683
- this.size = getSize(this.#size, container.canvas.size);
7966
+ this.size =
7967
+ this.#size.mode === PixelMode.percent
7968
+ ? {
7969
+ width: (this.#size.width / percentDenominator) * container.canvas.size.width,
7970
+ height: (this.#size.height / percentDenominator) * container.canvas.size.height,
7971
+ }
7972
+ : { width: this.#size.width, height: this.#size.height };
8684
7973
  this.#shape?.resize(this.position, this.size);
8685
7974
  }
8686
7975
  update(delta) {
@@ -8780,7 +8069,7 @@
8780
8069
  return size;
8781
8070
  })());
8782
8071
  }
8783
- #destroy = () => {
8072
+ #destroy() {
8784
8073
  this.#mutationObserver?.disconnect();
8785
8074
  this.#mutationObserver = undefined;
8786
8075
  this.#resizeObserver?.disconnect();
@@ -8789,7 +8078,7 @@
8789
8078
  this.#container.dispatchEvent("emitterDestroyed", {
8790
8079
  emitter: this,
8791
8080
  });
8792
- };
8081
+ }
8793
8082
  #emit() {
8794
8083
  if (this.#paused) {
8795
8084
  return;
@@ -8849,7 +8138,7 @@
8849
8138
  }
8850
8139
  }
8851
8140
  }
8852
- #prepareToDie = () => {
8141
+ #prepareToDie() {
8853
8142
  if (this.#paused) {
8854
8143
  return;
8855
8144
  }
@@ -8857,8 +8146,8 @@
8857
8146
  if ((this.#lifeCount > minLifeCount || this.#immortal) && duration !== undefined && duration > minDuration) {
8858
8147
  this.#duration = duration * millisecondsToSeconds;
8859
8148
  }
8860
- };
8861
- #setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
8149
+ }
8150
+ #setColorAnimation(animation, initValue, maxValue, factor = defaultColorAnimationFactor) {
8862
8151
  const container = this.#container;
8863
8152
  if (!animation.enable) {
8864
8153
  return initValue;
@@ -8867,7 +8156,7 @@
8867
8156
  ? (delay * millisecondsToSeconds) / container.retina.reduceFactor
8868
8157
  : Infinity, colorSpeed = getRangeValue(animation.speed);
8869
8158
  return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * factor) % maxValue;
8870
- };
8159
+ }
8871
8160
  }
8872
8161
 
8873
8162
  var EmitterInstance$1 = /*#__PURE__*/Object.freeze({