@tsparticles/preset-confetti-falling 4.2.1 → 4.3.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.2.1 */
2
+ /* Preset v4.3.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) :
@@ -358,29 +358,27 @@
358
358
  }
359
359
  }
360
360
  else if (!isObject(destination) || Array.isArray(destination)) {
361
- destination = {};
361
+ destination = Object.create(null);
362
362
  }
363
- const sourceKeys = Object.keys(source), dangerousKeys = new Set(["__proto__", "constructor", "prototype"]), hasNested = sourceKeys.some(k => {
363
+ const sourceKeys = Object.keys(source), hasNested = sourceKeys.some(k => {
364
364
  const v = source[k];
365
365
  return isObject(v) || Array.isArray(v);
366
366
  });
367
367
  if (!hasNested) {
368
368
  const sourceDict = source, destDict = destination;
369
369
  for (const key of sourceKeys) {
370
- if (dangerousKeys.has(key)) {
370
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
371
371
  continue;
372
372
  }
373
- if (key in sourceDict) {
374
- const v = sourceDict[key];
375
- if (v !== undefined) {
376
- destDict[key] = v;
377
- }
373
+ const v = sourceDict[key];
374
+ if (v !== undefined) {
375
+ destDict[key] = v;
378
376
  }
379
377
  }
380
378
  continue;
381
379
  }
382
380
  for (const key of sourceKeys) {
383
- if (dangerousKeys.has(key)) {
381
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
384
382
  continue;
385
383
  }
386
384
  const sourceDict = source, destDict = destination, value = sourceDict[key];
@@ -796,7 +794,7 @@
796
794
  return this.#domArray;
797
795
  }
798
796
  get version() {
799
- return "4.2.1";
797
+ return "4.3.1";
800
798
  }
801
799
  addEventListener(type, listener) {
802
800
  this.#eventDispatcher.addEventListener(type, listener);
@@ -1029,6 +1027,18 @@
1029
1027
  AnimationStatus["decreasing"] = "decreasing";
1030
1028
  })(AnimationStatus || (AnimationStatus = {}));
1031
1029
 
1030
+ var DrawLayer;
1031
+ (function (DrawLayer) {
1032
+ DrawLayer[DrawLayer["BackgroundElement"] = 0] = "BackgroundElement";
1033
+ DrawLayer[DrawLayer["BackgroundDraw"] = 1] = "BackgroundDraw";
1034
+ DrawLayer[DrawLayer["BackgroundMask"] = 2] = "BackgroundMask";
1035
+ DrawLayer[DrawLayer["CanvasSetup"] = 3] = "CanvasSetup";
1036
+ DrawLayer[DrawLayer["PluginContent"] = 4] = "PluginContent";
1037
+ DrawLayer[DrawLayer["Particles"] = 5] = "Particles";
1038
+ DrawLayer[DrawLayer["CanvasCleanup"] = 6] = "CanvasCleanup";
1039
+ DrawLayer[DrawLayer["Foreground"] = 7] = "Foreground";
1040
+ })(DrawLayer || (DrawLayer = {}));
1041
+
1032
1042
  class OptionLoader {
1033
1043
  load(data) {
1034
1044
  if (isNull(data)) {
@@ -1182,6 +1192,8 @@
1182
1192
 
1183
1193
  class Background extends OptionLoader {
1184
1194
  color;
1195
+ draw;
1196
+ element;
1185
1197
  image = "";
1186
1198
  opacity = 1;
1187
1199
  position = "";
@@ -1196,6 +1208,8 @@
1196
1208
  if (data.color !== undefined) {
1197
1209
  this.color = OptionsColor.create(this.color, data.color);
1198
1210
  }
1211
+ loadProperty(this, "element", data.element);
1212
+ loadProperty(this, "draw", data.draw);
1199
1213
  loadProperty(this, "image", data.image);
1200
1214
  loadProperty(this, "position", data.position);
1201
1215
  loadProperty(this, "repeat", data.repeat);
@@ -1741,7 +1755,7 @@
1741
1755
  }
1742
1756
  }
1743
1757
 
1744
- const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, sdrReferenceWhiteNits = 203;
1758
+ const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, hdrRgbFixedPrecision = 4, hdrHslFixedPrecision = 4, sdrReferenceWhiteNits = 203, hdrAnimationScale = sdrReferenceWhiteNits / maxNits;
1745
1759
  function getCachedStyle(key, generator) {
1746
1760
  let cached = styleCache.get(key);
1747
1761
  if (!cached) {
@@ -1881,6 +1895,17 @@
1881
1895
  : 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));
1882
1896
  return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
1883
1897
  }
1898
+ function hslToRgbFloat(hsl) {
1899
+ 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;
1900
+ if (s === sMin) {
1901
+ const grayscaleValue = lNormalized * rgbMax;
1902
+ return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
1903
+ }
1904
+ const temp1 = lNormalized < half
1905
+ ? lNormalized * (sNormalizedOffset + sNormalized)
1906
+ : 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));
1907
+ return { r: red, g: green, b: blue };
1908
+ }
1884
1909
  function hslaToRgba(hsla) {
1885
1910
  const rgbResult = hslToRgb(hsla);
1886
1911
  return {
@@ -1890,8 +1915,9 @@
1890
1915
  r: rgbResult.r,
1891
1916
  };
1892
1917
  }
1893
- function getRandomRgbColor(min) {
1894
- const fixedMin = defaultRgbMin, fixedMax = rgbMax + identity$1, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
1918
+ function getRandomRgbColor(min, hdr) {
1919
+ const fixedMin = defaultRgbMin;
1920
+ const fixedMax = rgbMax + identity$1, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
1895
1921
  return {
1896
1922
  b: getRgbInRangeValue(),
1897
1923
  g: getRgbInRangeValue(),
@@ -1899,7 +1925,7 @@
1899
1925
  };
1900
1926
  }
1901
1927
  function getStyleFromRgb(color, hdr, opacity) {
1902
- const op = opacity ?? defaultOpacity$1, key = `rgb-${color.r.toFixed(rgbFixedPrecision)}-${color.g.toFixed(rgbFixedPrecision)}-${color.b.toFixed(rgbFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
1928
+ const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? defaultOpacity$1, key = `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
1903
1929
  return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
1904
1930
  }
1905
1931
  function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
@@ -1910,9 +1936,9 @@
1910
1936
  return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$1).toString()})`;
1911
1937
  }
1912
1938
  function getStyleFromHsl(color, hdr, opacity) {
1913
- const op = opacity ?? defaultOpacity$1, key = `hsl-${color.h.toFixed(hslFixedPrecision)}-${color.s.toFixed(hslFixedPrecision)}-${color.l.toFixed(hslFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
1939
+ const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? defaultOpacity$1, key = `hsl-${color.h.toFixed(hslPrecision)}-${color.s.toFixed(hslPrecision)}-${color.l.toFixed(hslPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
1914
1940
  return getCachedStyle(key, () => hdr
1915
- ? getStyleFromRgb(hslToRgb(color), true, opacity)
1941
+ ? getStyleFromRgb(hslToRgbFloat(color), true, opacity)
1916
1942
  : `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
1917
1943
  }
1918
1944
  function getHslFromAnimation(animation) {
@@ -1975,7 +2001,7 @@
1975
2001
  colorValue.velocity = defaultVelocity;
1976
2002
  }
1977
2003
  }
1978
- function updateColorValue(data, decrease, delta) {
2004
+ function updateColorValue(data, decrease, delta, hdr) {
1979
2005
  const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minOffset = 0, velocityFactor = 3.6;
1980
2006
  if (!data.enable ||
1981
2007
  ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
@@ -1988,7 +2014,7 @@
1988
2014
  if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
1989
2015
  return;
1990
2016
  }
1991
- const offset = data.offset ? randomInRangeValue(data.offset) : minOffset, velocity = (data.velocity ?? minVelocity) * delta.factor + offset * velocityFactor, decay = data.decay ?? identity, max = data.max, min = data.min;
2017
+ const offset = data.offset ? randomInRangeValue(data.offset) : minOffset, velocity = ((data.velocity ?? minVelocity) * delta.factor + offset * velocityFactor) * (hdr ? hdrAnimationScale : identity), decay = data.decay ?? identity, max = data.max, min = data.min;
1992
2018
  if (!decrease || data.status === AnimationStatus.increasing) {
1993
2019
  data.value += velocity;
1994
2020
  if (data.value > max) {
@@ -2015,14 +2041,14 @@
2015
2041
  }
2016
2042
  data.value = clamp(data.value, min, max);
2017
2043
  }
2018
- function updateColor(color, delta) {
2044
+ function updateColor(color, delta, hdr) {
2019
2045
  if (!color) {
2020
2046
  return;
2021
2047
  }
2022
2048
  const { h, s, l } = color;
2023
- updateColorValue(h, false, delta);
2024
- updateColorValue(s, true, delta);
2025
- updateColorValue(l, true, delta);
2049
+ updateColorValue(h, false, delta, hdr);
2050
+ updateColorValue(s, true, delta, hdr);
2051
+ updateColorValue(l, true, delta, hdr);
2026
2052
  }
2027
2053
  function alterHsl(color, type, value) {
2028
2054
  return {
@@ -2072,7 +2098,7 @@
2072
2098
  }
2073
2099
 
2074
2100
  async function loadBlendPlugin(engine) {
2075
- engine.checkVersion("4.2.1");
2101
+ engine.checkVersion("4.3.1");
2076
2102
  await engine.pluginManager.register(e => {
2077
2103
  e.pluginManager.addPlugin(new BlendPlugin());
2078
2104
  });
@@ -2109,7 +2135,7 @@
2109
2135
  }
2110
2136
 
2111
2137
  async function loadCircleShape(engine) {
2112
- engine.checkVersion("4.2.1");
2138
+ engine.checkVersion("4.3.1");
2113
2139
  await engine.pluginManager.register(e => {
2114
2140
  e.pluginManager.addShape(["circle"], () => {
2115
2141
  return Promise.resolve(new CircleDrawer());
@@ -2157,7 +2183,7 @@
2157
2183
  }
2158
2184
 
2159
2185
  async function loadHexColorPlugin(engine) {
2160
- engine.checkVersion("4.2.1");
2186
+ engine.checkVersion("4.3.1");
2161
2187
  await engine.pluginManager.register(e => {
2162
2188
  e.pluginManager.addColorManager("hex", new HexColorManager());
2163
2189
  });
@@ -2210,7 +2236,7 @@
2210
2236
  }
2211
2237
 
2212
2238
  async function loadHslColorPlugin(engine) {
2213
- engine.checkVersion("4.2.1");
2239
+ engine.checkVersion("4.3.1");
2214
2240
  await engine.pluginManager.register(e => {
2215
2241
  e.pluginManager.addColorManager("hsl", new HslColorManager());
2216
2242
  });
@@ -2234,7 +2260,7 @@
2234
2260
  }
2235
2261
 
2236
2262
  async function loadMovePlugin(engine) {
2237
- engine.checkVersion("4.2.1");
2263
+ engine.checkVersion("4.3.1");
2238
2264
  await engine.pluginManager.register(e => {
2239
2265
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
2240
2266
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -2450,7 +2476,7 @@
2450
2476
  }
2451
2477
 
2452
2478
  async function loadOpacityUpdater(engine) {
2453
- engine.checkVersion("4.2.1");
2479
+ engine.checkVersion("4.3.1");
2454
2480
  await engine.pluginManager.register(e => {
2455
2481
  e.pluginManager.addParticleUpdater("opacity", container => {
2456
2482
  return Promise.resolve(new OpacityUpdater(container));
@@ -2795,7 +2821,7 @@
2795
2821
  }
2796
2822
 
2797
2823
  async function loadOutModesUpdater(engine) {
2798
- engine.checkVersion("4.2.1");
2824
+ engine.checkVersion("4.3.1");
2799
2825
  await engine.pluginManager.register(e => {
2800
2826
  e.pluginManager.addParticleUpdater("outModes", container => {
2801
2827
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -2860,13 +2886,13 @@
2860
2886
  if (!this.isEnabled(particle)) {
2861
2887
  return;
2862
2888
  }
2863
- updateColor(particle.fillColor, delta);
2864
- updateColor(particle.strokeColor, delta);
2889
+ updateColor(particle.fillColor, delta, this.#container.hdr);
2890
+ updateColor(particle.strokeColor, delta, this.#container.hdr);
2865
2891
  }
2866
2892
  }
2867
2893
 
2868
2894
  async function loadPaintUpdater(engine) {
2869
- engine.checkVersion("4.2.1");
2895
+ engine.checkVersion("4.3.1");
2870
2896
  await engine.pluginManager.register(e => {
2871
2897
  e.pluginManager.addParticleUpdater("paint", container => {
2872
2898
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -2921,7 +2947,7 @@
2921
2947
  }
2922
2948
 
2923
2949
  async function loadRgbColorPlugin(engine) {
2924
- engine.checkVersion("4.2.1");
2950
+ engine.checkVersion("4.3.1");
2925
2951
  await engine.pluginManager.register(e => {
2926
2952
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
2927
2953
  });
@@ -3006,7 +3032,7 @@
3006
3032
  }
3007
3033
 
3008
3034
  async function loadSizeUpdater(engine) {
3009
- engine.checkVersion("4.2.1");
3035
+ engine.checkVersion("4.3.1");
3010
3036
  await engine.pluginManager.register(e => {
3011
3037
  e.pluginManager.addParticleUpdater("size", container => {
3012
3038
  return Promise.resolve(new SizeUpdater(container));
@@ -3015,7 +3041,7 @@
3015
3041
  }
3016
3042
 
3017
3043
  async function loadBasic(engine) {
3018
- engine.checkVersion("4.2.1");
3044
+ engine.checkVersion("4.3.1");
3019
3045
  await engine.pluginManager.register(async (e) => {
3020
3046
  await Promise.all([
3021
3047
  loadBlendPlugin(e),
@@ -3108,7 +3134,7 @@
3108
3134
  }
3109
3135
 
3110
3136
  async function loadMotionPlugin(engine) {
3111
- engine.checkVersion("4.2.1");
3137
+ engine.checkVersion("4.3.1");
3112
3138
  await engine.pluginManager.register(e => {
3113
3139
  e.pluginManager.addPlugin(new MotionPlugin());
3114
3140
  });
@@ -3241,7 +3267,7 @@
3241
3267
  }
3242
3268
 
3243
3269
  async function loadRollUpdater(engine) {
3244
- engine.checkVersion("4.2.1");
3270
+ engine.checkVersion("4.3.1");
3245
3271
  await engine.pluginManager.register(e => {
3246
3272
  e.pluginManager.addParticleUpdater("roll", () => {
3247
3273
  return Promise.resolve(new RollUpdater(e.pluginManager));
@@ -3347,7 +3373,7 @@
3347
3373
  }
3348
3374
 
3349
3375
  async function loadRotateUpdater(engine) {
3350
- engine.checkVersion("4.2.1");
3376
+ engine.checkVersion("4.3.1");
3351
3377
  await engine.pluginManager.register(e => {
3352
3378
  e.pluginManager.addParticleUpdater("rotate", container => {
3353
3379
  return Promise.resolve(new RotateUpdater(container));
@@ -3371,7 +3397,7 @@
3371
3397
  }
3372
3398
 
3373
3399
  async function loadSquareShape(engine) {
3374
- engine.checkVersion("4.2.1");
3400
+ engine.checkVersion("4.3.1");
3375
3401
  await engine.pluginManager.register(e => {
3376
3402
  e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
3377
3403
  });
@@ -3480,7 +3506,7 @@
3480
3506
  }
3481
3507
 
3482
3508
  async function loadTiltUpdater(engine) {
3483
- engine.checkVersion("4.2.1");
3509
+ engine.checkVersion("4.3.1");
3484
3510
  await engine.pluginManager.register(e => {
3485
3511
  e.pluginManager.addParticleUpdater("tilt", container => {
3486
3512
  return Promise.resolve(new TiltUpdater(container));
@@ -3582,7 +3608,7 @@
3582
3608
  }
3583
3609
 
3584
3610
  async function loadWobbleUpdater(engine) {
3585
- engine.checkVersion("4.2.1");
3611
+ engine.checkVersion("4.3.1");
3586
3612
  await engine.pluginManager.register(e => {
3587
3613
  e.pluginManager.addParticleUpdater("wobble", container => {
3588
3614
  return Promise.resolve(new WobbleUpdater(container));
@@ -3709,10 +3735,10 @@
3709
3735
  }
3710
3736
  }
3711
3737
  class RenderManager {
3738
+ #backgroundElement;
3739
+ #backgroundWarnings;
3712
3740
  #canvasClearPlugins;
3713
3741
  #canvasManager;
3714
- #canvasPaintPlugins;
3715
- #clearDrawPlugins;
3716
3742
  #colorPlugins;
3717
3743
  #container;
3718
3744
  #context;
@@ -3720,9 +3746,7 @@
3720
3746
  #drawParticlePlugins;
3721
3747
  #drawParticlesCleanupPlugins;
3722
3748
  #drawParticlesSetupPlugins;
3723
- #drawPlugins;
3724
- #drawSettingsCleanupPlugins;
3725
- #drawSettingsSetupPlugins;
3749
+ #layers;
3726
3750
  #pluginManager;
3727
3751
  #postDrawUpdaters;
3728
3752
  #preDrawUpdaters;
@@ -3734,18 +3758,25 @@
3734
3758
  this.#container = container;
3735
3759
  this.#canvasManager = canvasManager;
3736
3760
  this.#context = null;
3761
+ this.#backgroundElement = null;
3762
+ this.#backgroundWarnings = new Set();
3737
3763
  this.#preDrawUpdaters = [];
3738
3764
  this.#postDrawUpdaters = [];
3739
- this.#colorPlugins = [];
3740
3765
  this.#canvasClearPlugins = [];
3741
- this.#canvasPaintPlugins = [];
3742
- this.#clearDrawPlugins = [];
3766
+ this.#colorPlugins = [];
3743
3767
  this.#drawParticlePlugins = [];
3744
3768
  this.#drawParticlesCleanupPlugins = [];
3745
3769
  this.#drawParticlesSetupPlugins = [];
3746
- this.#drawPlugins = [];
3747
- this.#drawSettingsSetupPlugins = [];
3748
- this.#drawSettingsCleanupPlugins = [];
3770
+ this.#layers = {
3771
+ 0: [],
3772
+ 1: [],
3773
+ 2: [],
3774
+ 3: [],
3775
+ 4: [],
3776
+ 5: [],
3777
+ 6: [],
3778
+ 7: [],
3779
+ };
3749
3780
  }
3750
3781
  get settings() {
3751
3782
  return this.#contextSettings;
@@ -3759,32 +3790,38 @@
3759
3790
  });
3760
3791
  }
3761
3792
  clear() {
3762
- let pluginHandled = false;
3763
3793
  for (const plugin of this.#canvasClearPlugins) {
3764
- pluginHandled = plugin.canvasClear?.() ?? false;
3765
- if (pluginHandled) {
3766
- break;
3794
+ if (plugin.canvasClear?.() ?? false) {
3795
+ return;
3767
3796
  }
3768
3797
  }
3769
- if (pluginHandled) {
3770
- return;
3798
+ for (const layer of Object.values(DrawLayer)) {
3799
+ if (typeof layer === "number") {
3800
+ for (const plugin of this.#getLayerPlugins(layer)) {
3801
+ if (plugin.canvasClear?.() ?? false) {
3802
+ return;
3803
+ }
3804
+ }
3805
+ }
3771
3806
  }
3772
3807
  this.canvasClear();
3773
3808
  }
3774
3809
  destroy() {
3775
3810
  this.stop();
3811
+ this.#backgroundElement = null;
3812
+ this.#backgroundWarnings.clear();
3776
3813
  this.#preDrawUpdaters = [];
3777
3814
  this.#postDrawUpdaters = [];
3778
- this.#colorPlugins = [];
3779
3815
  this.#canvasClearPlugins = [];
3780
- this.#canvasPaintPlugins = [];
3781
- this.#clearDrawPlugins = [];
3816
+ this.#colorPlugins = [];
3782
3817
  this.#drawParticlePlugins = [];
3783
3818
  this.#drawParticlesCleanupPlugins = [];
3784
3819
  this.#drawParticlesSetupPlugins = [];
3785
- this.#drawPlugins = [];
3786
- this.#drawSettingsSetupPlugins = [];
3787
- this.#drawSettingsCleanupPlugins = [];
3820
+ for (const layer of Object.values(DrawLayer)) {
3821
+ if (typeof layer === "number") {
3822
+ this.#layers[layer] = [];
3823
+ }
3824
+ }
3788
3825
  }
3789
3826
  draw(cb) {
3790
3827
  const ctx = this.#context;
@@ -3841,21 +3878,40 @@
3841
3878
  });
3842
3879
  }
3843
3880
  drawParticles(delta) {
3844
- const { particles } = this.#container;
3881
+ const { particles, actualOptions } = this.#container;
3845
3882
  this.clear();
3846
3883
  particles.update(delta);
3847
3884
  this.draw(ctx => {
3848
- for (const plugin of this.#drawSettingsSetupPlugins) {
3885
+ const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
3886
+ if (this.#backgroundElement) {
3887
+ try {
3888
+ ctx.drawImage(this.#backgroundElement, originPoint.x, originPoint.y, width, height);
3889
+ }
3890
+ catch {
3891
+ this.#warnOnce("background-element-draw-error", "Error drawing background element onto canvas");
3892
+ }
3893
+ }
3894
+ const background = actualOptions.background;
3895
+ if (background.draw) {
3896
+ try {
3897
+ background.draw(ctx, delta);
3898
+ }
3899
+ catch {
3900
+ this.#warnOnce("background-draw-error", "Error in background.draw callback");
3901
+ }
3902
+ }
3903
+ for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
3904
+ plugin.canvasPaint?.();
3905
+ }
3906
+ for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
3849
3907
  plugin.drawSettingsSetup?.(ctx, delta);
3850
3908
  }
3851
- for (const plugin of this.#drawPlugins) {
3909
+ for (const plugin of this.#getLayerPlugins(DrawLayer.PluginContent)) {
3852
3910
  plugin.draw?.(ctx, delta);
3853
3911
  }
3854
3912
  particles.drawParticles(delta);
3855
- for (const plugin of this.#clearDrawPlugins) {
3913
+ for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasCleanup)) {
3856
3914
  plugin.clearDraw?.(ctx, delta);
3857
- }
3858
- for (const plugin of this.#drawSettingsCleanupPlugins) {
3859
3915
  plugin.drawSettingsCleanup?.(ctx, delta);
3860
3916
  }
3861
3917
  });
@@ -3863,29 +3919,24 @@
3863
3919
  init() {
3864
3920
  this.initUpdaters();
3865
3921
  this.initPlugins();
3922
+ this.#resolveBackgroundElement();
3866
3923
  this.paint();
3867
3924
  }
3868
3925
  initPlugins() {
3869
- this.#colorPlugins = [];
3870
3926
  this.#canvasClearPlugins = [];
3871
- this.#canvasPaintPlugins = [];
3872
- this.#clearDrawPlugins = [];
3927
+ this.#colorPlugins = [];
3873
3928
  this.#drawParticlePlugins = [];
3874
3929
  this.#drawParticlesSetupPlugins = [];
3875
3930
  this.#drawParticlesCleanupPlugins = [];
3876
- this.#drawPlugins = [];
3877
- this.#drawSettingsSetupPlugins = [];
3878
- this.#drawSettingsCleanupPlugins = [];
3931
+ for (const layer of Object.values(DrawLayer)) {
3932
+ if (typeof layer === "number") {
3933
+ this.#layers[layer] = [];
3934
+ }
3935
+ }
3879
3936
  for (const plugin of this.#container.plugins) {
3880
3937
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
3881
3938
  this.#colorPlugins.push(plugin);
3882
3939
  }
3883
- if (plugin.canvasClear) {
3884
- this.#canvasClearPlugins.push(plugin);
3885
- }
3886
- if (plugin.canvasPaint) {
3887
- this.#canvasPaintPlugins.push(plugin);
3888
- }
3889
3940
  if (plugin.drawParticle) {
3890
3941
  this.#drawParticlePlugins.push(plugin);
3891
3942
  }
@@ -3895,17 +3946,20 @@
3895
3946
  if (plugin.drawParticleCleanup) {
3896
3947
  this.#drawParticlesCleanupPlugins.push(plugin);
3897
3948
  }
3898
- if (plugin.draw) {
3899
- this.#drawPlugins.push(plugin);
3949
+ if (plugin.canvasClear) {
3950
+ this.#canvasClearPlugins.push(plugin);
3951
+ }
3952
+ if (plugin.canvasPaint) {
3953
+ this.#getLayerPlugins(DrawLayer.BackgroundMask).push(plugin);
3900
3954
  }
3901
3955
  if (plugin.drawSettingsSetup) {
3902
- this.#drawSettingsSetupPlugins.push(plugin);
3956
+ this.#getLayerPlugins(DrawLayer.CanvasSetup).push(plugin);
3903
3957
  }
3904
- if (plugin.drawSettingsCleanup) {
3905
- this.#drawSettingsCleanupPlugins.push(plugin);
3958
+ if (plugin.draw) {
3959
+ this.#getLayerPlugins(DrawLayer.PluginContent).push(plugin);
3906
3960
  }
3907
- if (plugin.clearDraw) {
3908
- this.#clearDrawPlugins.push(plugin);
3961
+ if (plugin.clearDraw ?? plugin.drawSettingsCleanup) {
3962
+ this.#getLayerPlugins(DrawLayer.CanvasCleanup).push(plugin);
3909
3963
  }
3910
3964
  }
3911
3965
  }
@@ -3923,7 +3977,7 @@
3923
3977
  }
3924
3978
  paint() {
3925
3979
  let handled = false;
3926
- for (const plugin of this.#canvasPaintPlugins) {
3980
+ for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
3927
3981
  handled = plugin.canvasPaint?.() ?? false;
3928
3982
  if (handled) {
3929
3983
  break;
@@ -4096,6 +4150,9 @@
4096
4150
  }
4097
4151
  drawer.beforeDraw(data);
4098
4152
  }
4153
+ #getLayerPlugins(layer) {
4154
+ return this.#layers[layer];
4155
+ }
4099
4156
  #getPluginParticleColors(particle) {
4100
4157
  let fColor, sColor;
4101
4158
  for (const plugin of this.#colorPlugins) {
@@ -4113,6 +4170,39 @@
4113
4170
  this.#reusablePluginColors[sColorIndex] = sColor;
4114
4171
  return this.#reusablePluginColors;
4115
4172
  }
4173
+ #resolveBackgroundElement() {
4174
+ const background = this.#container.actualOptions.background;
4175
+ this.#backgroundElement = null;
4176
+ if (!background.element) {
4177
+ return;
4178
+ }
4179
+ if (typeof background.element === "string") {
4180
+ if (typeof document !== "undefined") {
4181
+ const node = document.querySelector(background.element);
4182
+ if (node instanceof HTMLCanvasElement || node instanceof HTMLVideoElement || node instanceof HTMLImageElement) {
4183
+ this.#backgroundElement = node;
4184
+ }
4185
+ else if (node) {
4186
+ this.#warnOnce("background-element-not-supported", `Background element "${background.element}" is not a supported drawable element (canvas, video, or img)`);
4187
+ }
4188
+ else {
4189
+ this.#warnOnce("background-element-not-found", `Background element selector "${background.element}" not found`);
4190
+ }
4191
+ }
4192
+ }
4193
+ else if (background.element instanceof HTMLCanvasElement ||
4194
+ background.element instanceof OffscreenCanvas ||
4195
+ background.element instanceof HTMLVideoElement ||
4196
+ background.element instanceof HTMLImageElement) {
4197
+ this.#backgroundElement = background.element;
4198
+ }
4199
+ }
4200
+ #warnOnce(key, message) {
4201
+ if (!this.#backgroundWarnings.has(key)) {
4202
+ this.#backgroundWarnings.add(key);
4203
+ getLogger().warning(message);
4204
+ }
4205
+ }
4116
4206
  }
4117
4207
 
4118
4208
  const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
@@ -4689,7 +4779,6 @@
4689
4779
  }
4690
4780
  class Particle {
4691
4781
  backColor;
4692
- bubble;
4693
4782
  destroyed;
4694
4783
  direction;
4695
4784
  effect;
@@ -4723,7 +4812,6 @@
4723
4812
  shapeData;
4724
4813
  sides;
4725
4814
  size;
4726
- slow;
4727
4815
  spawning;
4728
4816
  strokeColor;
4729
4817
  strokeOpacity;
@@ -4745,18 +4833,25 @@
4745
4833
  d: 1,
4746
4834
  };
4747
4835
  #container;
4836
+ #modifiers = [];
4748
4837
  #pluginManager;
4749
4838
  constructor(pluginManager, container) {
4750
4839
  this.#pluginManager = pluginManager;
4751
4840
  this.#container = container;
4752
4841
  }
4842
+ addModifier(modifier) {
4843
+ this.#modifiers.push(modifier);
4844
+ this.#modifiers.sort((a, b) => a.priority - b.priority);
4845
+ }
4846
+ clearModifiers() {
4847
+ this.#modifiers.length = 0;
4848
+ }
4753
4849
  destroy(override) {
4754
4850
  if (this.unbreakable || this.destroyed) {
4755
4851
  return;
4756
4852
  }
4757
4853
  this.destroyed = true;
4758
- this.bubble.inRange = false;
4759
- this.slow.inRange = false;
4854
+ this.clearModifiers();
4760
4855
  const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4761
4856
  shapeDrawer?.particleDestroy?.(this);
4762
4857
  for (const plugin of container.particleDestroyedPlugins) {
@@ -4778,13 +4873,16 @@
4778
4873
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
4779
4874
  }
4780
4875
  getFillColor() {
4781
- return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4876
+ return this.#getRollColor(this.#applyModifiers(getHslFromAnimation(this.fillColor), m => m.fillColor));
4782
4877
  }
4783
4878
  getMass() {
4784
4879
  return this.getRadius() ** squareExp * Math.PI * half;
4785
4880
  }
4881
+ getModifier(id) {
4882
+ return this.#modifiers.find(m => m.id === id);
4883
+ }
4786
4884
  getOpacity() {
4787
- const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? getRangeValue(this.opacity?.value ?? defaultOpacity$1), fillOpacity = this.fillOpacity ?? defaultOpacity$1, strokeOpacity = this.strokeOpacity ?? defaultOpacity$1;
4885
+ const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, baseOpacity = getRangeValue(this.opacity?.value ?? defaultOpacity$1), modifierOpacity = this.#applyModifiers(undefined, m => m.opacity), opacity = modifierOpacity ?? baseOpacity, fillOpacity = this.fillOpacity ?? defaultOpacity$1, strokeOpacity = this.strokeOpacity ?? defaultOpacity$1;
4788
4886
  this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4789
4887
  this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
4790
4888
  this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
@@ -4797,7 +4895,7 @@
4797
4895
  return this.#cachedPosition;
4798
4896
  }
4799
4897
  getRadius() {
4800
- return this.bubble.radius ?? this.size.value;
4898
+ return this.#applyModifiers(this.size.value, m => m.radius);
4801
4899
  }
4802
4900
  getRotateData() {
4803
4901
  const angle = this.getAngle();
@@ -4806,7 +4904,7 @@
4806
4904
  return this.#cachedRotateData;
4807
4905
  }
4808
4906
  getStrokeColor() {
4809
- return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4907
+ return this.#getRollColor(this.#applyModifiers(getHslFromAnimation(this.strokeColor), m => m.strokeColor));
4810
4908
  }
4811
4909
  getTransformData(externalTransform) {
4812
4910
  const rotateData = this.getRotateData(), rotating = this.isRotating;
@@ -4826,13 +4924,6 @@
4826
4924
  this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
4827
4925
  container.retina.initParticle(this);
4828
4926
  runUpdaterPreInit(container.particleUpdaters, this);
4829
- this.bubble = {
4830
- inRange: false,
4831
- };
4832
- this.slow = {
4833
- inRange: false,
4834
- factor: 1,
4835
- };
4836
4927
  this.#initPosition(position);
4837
4928
  this.initialVelocity = this.#calculateVelocity();
4838
4929
  this.velocity = this.initialVelocity.copy();
@@ -4872,11 +4963,29 @@
4872
4963
  isVisible() {
4873
4964
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
4874
4965
  }
4966
+ removeModifier(id) {
4967
+ const idx = this.#modifiers.findIndex(m => m.id === id);
4968
+ if (idx >= defaultAngle) {
4969
+ this.#modifiers.splice(idx, identity$1);
4970
+ }
4971
+ }
4875
4972
  reset() {
4876
4973
  for (const updater of this.#container.particleUpdaters) {
4877
4974
  updater.reset?.(this);
4878
4975
  }
4879
4976
  }
4977
+ #applyModifiers(base, getter) {
4978
+ let value = base;
4979
+ for (const mod of this.#modifiers) {
4980
+ if (mod.enabled) {
4981
+ const override = getter(mod);
4982
+ if (override !== undefined) {
4983
+ value = override;
4984
+ }
4985
+ }
4986
+ }
4987
+ return value;
4988
+ }
4880
4989
  #calcPosition(position, zIndex) {
4881
4990
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
4882
4991
  const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
@@ -5978,6 +6087,7 @@
5978
6087
  });
5979
6088
 
5980
6089
  class BlendPluginInstance {
6090
+ layer = DrawLayer.CanvasSetup;
5981
6091
  #container;
5982
6092
  #defaultCompositeValue;
5983
6093
  constructor(container) {
@@ -6123,7 +6233,8 @@
6123
6233
  particle.lastPathTime -= pathDelay;
6124
6234
  }
6125
6235
  function getProximitySpeedFactor(particle) {
6126
- return particle.slow.inRange ? particle.slow.factor : identity$1;
6236
+ const mod = particle.getModifier("slow");
6237
+ return mod?.enabled ? (mod.speedFactor ?? identity$1) : identity$1;
6127
6238
  }
6128
6239
  function initSpin(container, particle) {
6129
6240
  const options = particle.options, spinOptions = options.move.spin;