@tsparticles/fireworks 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
- /* tsParticles v4.2.1 */
2
+ /* tsParticles 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) :
@@ -398,29 +398,27 @@
398
398
  }
399
399
  }
400
400
  else if (!isObject(destination) || Array.isArray(destination)) {
401
- destination = {};
401
+ destination = Object.create(null);
402
402
  }
403
- const sourceKeys = Object.keys(source), dangerousKeys = new Set(["__proto__", "constructor", "prototype"]), hasNested = sourceKeys.some(k => {
403
+ const sourceKeys = Object.keys(source), hasNested = sourceKeys.some(k => {
404
404
  const v = source[k];
405
405
  return isObject(v) || Array.isArray(v);
406
406
  });
407
407
  if (!hasNested) {
408
408
  const sourceDict = source, destDict = destination;
409
409
  for (const key of sourceKeys) {
410
- if (dangerousKeys.has(key)) {
410
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
411
411
  continue;
412
412
  }
413
- if (key in sourceDict) {
414
- const v = sourceDict[key];
415
- if (v !== undefined) {
416
- destDict[key] = v;
417
- }
413
+ const v = sourceDict[key];
414
+ if (v !== undefined) {
415
+ destDict[key] = v;
418
416
  }
419
417
  }
420
418
  continue;
421
419
  }
422
420
  for (const key of sourceKeys) {
423
- if (dangerousKeys.has(key)) {
421
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
424
422
  continue;
425
423
  }
426
424
  const sourceDict = source, destDict = destination, value = sourceDict[key];
@@ -879,7 +877,7 @@
879
877
  return this.#domArray;
880
878
  }
881
879
  get version() {
882
- return "4.2.1";
880
+ return "4.3.1";
883
881
  }
884
882
  addEventListener(type, listener) {
885
883
  this.#eventDispatcher.addEventListener(type, listener);
@@ -1112,6 +1110,18 @@
1112
1110
  AnimationStatus["decreasing"] = "decreasing";
1113
1111
  })(exports.AnimationStatus || (exports.AnimationStatus = {}));
1114
1112
 
1113
+ exports.DrawLayer = void 0;
1114
+ (function (DrawLayer) {
1115
+ DrawLayer[DrawLayer["BackgroundElement"] = 0] = "BackgroundElement";
1116
+ DrawLayer[DrawLayer["BackgroundDraw"] = 1] = "BackgroundDraw";
1117
+ DrawLayer[DrawLayer["BackgroundMask"] = 2] = "BackgroundMask";
1118
+ DrawLayer[DrawLayer["CanvasSetup"] = 3] = "CanvasSetup";
1119
+ DrawLayer[DrawLayer["PluginContent"] = 4] = "PluginContent";
1120
+ DrawLayer[DrawLayer["Particles"] = 5] = "Particles";
1121
+ DrawLayer[DrawLayer["CanvasCleanup"] = 6] = "CanvasCleanup";
1122
+ DrawLayer[DrawLayer["Foreground"] = 7] = "Foreground";
1123
+ })(exports.DrawLayer || (exports.DrawLayer = {}));
1124
+
1115
1125
  class OptionLoader {
1116
1126
  load(data) {
1117
1127
  if (isNull(data)) {
@@ -1270,6 +1280,8 @@
1270
1280
 
1271
1281
  class Background extends OptionLoader {
1272
1282
  color;
1283
+ draw;
1284
+ element;
1273
1285
  image = "";
1274
1286
  opacity = 1;
1275
1287
  position = "";
@@ -1284,6 +1296,8 @@
1284
1296
  if (data.color !== undefined) {
1285
1297
  this.color = OptionsColor.create(this.color, data.color);
1286
1298
  }
1299
+ loadProperty(this, "element", data.element);
1300
+ loadProperty(this, "draw", data.draw);
1287
1301
  loadProperty(this, "image", data.image);
1288
1302
  loadProperty(this, "position", data.position);
1289
1303
  loadProperty(this, "repeat", data.repeat);
@@ -1829,7 +1843,7 @@
1829
1843
  }
1830
1844
  }
1831
1845
 
1832
- const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, sdrReferenceWhiteNits = 203;
1846
+ const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, hdrRgbFixedPrecision = 4, hdrHslFixedPrecision = 4, sdrReferenceWhiteNits = 203, hdrAnimationScale = sdrReferenceWhiteNits / maxNits;
1833
1847
  function getCachedStyle(key, generator) {
1834
1848
  let cached = styleCache.get(key);
1835
1849
  if (!cached) {
@@ -1972,6 +1986,17 @@
1972
1986
  : 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));
1973
1987
  return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
1974
1988
  }
1989
+ function hslToRgbFloat(hsl) {
1990
+ 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;
1991
+ if (s === sMin) {
1992
+ const grayscaleValue = lNormalized * rgbMax;
1993
+ return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
1994
+ }
1995
+ const temp1 = lNormalized < half
1996
+ ? lNormalized * (sNormalizedOffset + sNormalized)
1997
+ : 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));
1998
+ return { r: red, g: green, b: blue };
1999
+ }
1975
2000
  function hslaToRgba(hsla) {
1976
2001
  const rgbResult = hslToRgb(hsla);
1977
2002
  return {
@@ -1981,8 +2006,16 @@
1981
2006
  r: rgbResult.r,
1982
2007
  };
1983
2008
  }
1984
- function getRandomRgbColor(min) {
1985
- const fixedMin = min ?? defaultRgbMin, fixedMax = rgbMax + identity$1, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
2009
+ function getRandomRgbColor(min, hdr) {
2010
+ const fixedMin = min ?? defaultRgbMin;
2011
+ if (hdr) {
2012
+ return {
2013
+ r: getRandomInRange(fixedMin, rgbMax),
2014
+ g: getRandomInRange(fixedMin, rgbMax),
2015
+ b: getRandomInRange(fixedMin, rgbMax),
2016
+ };
2017
+ }
2018
+ const fixedMax = rgbMax + identity$1, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
1986
2019
  return {
1987
2020
  b: getRgbInRangeValue(),
1988
2021
  g: getRgbInRangeValue(),
@@ -1990,7 +2023,7 @@
1990
2023
  };
1991
2024
  }
1992
2025
  function getStyleFromRgb(color, hdr, opacity) {
1993
- const op = opacity ?? defaultOpacity$1, key = `rgb-${color.r.toFixed(rgbFixedPrecision)}-${color.g.toFixed(rgbFixedPrecision)}-${color.b.toFixed(rgbFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
2026
+ 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()}`;
1994
2027
  return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
1995
2028
  }
1996
2029
  function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
@@ -2001,9 +2034,9 @@
2001
2034
  return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$1).toString()})`;
2002
2035
  }
2003
2036
  function getStyleFromHsl(color, hdr, opacity) {
2004
- const op = opacity ?? defaultOpacity$1, key = `hsl-${color.h.toFixed(hslFixedPrecision)}-${color.s.toFixed(hslFixedPrecision)}-${color.l.toFixed(hslFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
2037
+ 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()}`;
2005
2038
  return getCachedStyle(key, () => hdr
2006
- ? getStyleFromRgb(hslToRgb(color), true, opacity)
2039
+ ? getStyleFromRgb(hslToRgbFloat(color), true, opacity)
2007
2040
  : `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
2008
2041
  }
2009
2042
  function colorMix(color1, color2, size1, size2) {
@@ -2123,7 +2156,7 @@
2123
2156
  colorValue.velocity = defaultVelocity;
2124
2157
  }
2125
2158
  }
2126
- function updateColorValue(data, decrease, delta) {
2159
+ function updateColorValue(data, decrease, delta, hdr) {
2127
2160
  const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minOffset = 0, velocityFactor = 3.6;
2128
2161
  if (!data.enable ||
2129
2162
  ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
@@ -2136,7 +2169,7 @@
2136
2169
  if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
2137
2170
  return;
2138
2171
  }
2139
- 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;
2172
+ 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;
2140
2173
  if (!decrease || data.status === exports.AnimationStatus.increasing) {
2141
2174
  data.value += velocity;
2142
2175
  if (data.value > max) {
@@ -2163,14 +2196,14 @@
2163
2196
  }
2164
2197
  data.value = clamp(data.value, min, max);
2165
2198
  }
2166
- function updateColor(color, delta) {
2199
+ function updateColor(color, delta, hdr) {
2167
2200
  if (!color) {
2168
2201
  return;
2169
2202
  }
2170
2203
  const { h, s, l } = color;
2171
- updateColorValue(h, false, delta);
2172
- updateColorValue(s, true, delta);
2173
- updateColorValue(l, true, delta);
2204
+ updateColorValue(h, false, delta, hdr);
2205
+ updateColorValue(s, true, delta, hdr);
2206
+ updateColorValue(l, true, delta, hdr);
2174
2207
  }
2175
2208
  function alterHsl(color, type, value) {
2176
2209
  return {
@@ -2513,7 +2546,7 @@
2513
2546
  }
2514
2547
 
2515
2548
  async function loadBlendPlugin(engine) {
2516
- engine.checkVersion("4.2.1");
2549
+ engine.checkVersion("4.3.1");
2517
2550
  await engine.pluginManager.register(e => {
2518
2551
  e.pluginManager.addPlugin(new BlendPlugin());
2519
2552
  });
@@ -2550,7 +2583,7 @@
2550
2583
  }
2551
2584
 
2552
2585
  async function loadCircleShape(engine) {
2553
- engine.checkVersion("4.2.1");
2586
+ engine.checkVersion("4.3.1");
2554
2587
  await engine.pluginManager.register(e => {
2555
2588
  e.pluginManager.addShape(["circle"], () => {
2556
2589
  return Promise.resolve(new CircleDrawer());
@@ -2598,7 +2631,7 @@
2598
2631
  }
2599
2632
 
2600
2633
  async function loadHexColorPlugin(engine) {
2601
- engine.checkVersion("4.2.1");
2634
+ engine.checkVersion("4.3.1");
2602
2635
  await engine.pluginManager.register(e => {
2603
2636
  e.pluginManager.addColorManager("hex", new HexColorManager());
2604
2637
  });
@@ -2651,7 +2684,7 @@
2651
2684
  }
2652
2685
 
2653
2686
  async function loadHslColorPlugin(engine) {
2654
- engine.checkVersion("4.2.1");
2687
+ engine.checkVersion("4.3.1");
2655
2688
  await engine.pluginManager.register(e => {
2656
2689
  e.pluginManager.addColorManager("hsl", new HslColorManager());
2657
2690
  });
@@ -2675,7 +2708,7 @@
2675
2708
  }
2676
2709
 
2677
2710
  async function loadMovePlugin(engine) {
2678
- engine.checkVersion("4.2.1");
2711
+ engine.checkVersion("4.3.1");
2679
2712
  await engine.pluginManager.register(e => {
2680
2713
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
2681
2714
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -2891,7 +2924,7 @@
2891
2924
  }
2892
2925
 
2893
2926
  async function loadOpacityUpdater(engine) {
2894
- engine.checkVersion("4.2.1");
2927
+ engine.checkVersion("4.3.1");
2895
2928
  await engine.pluginManager.register(e => {
2896
2929
  e.pluginManager.addParticleUpdater("opacity", container => {
2897
2930
  return Promise.resolve(new OpacityUpdater(container));
@@ -3236,7 +3269,7 @@
3236
3269
  }
3237
3270
 
3238
3271
  async function loadOutModesUpdater(engine) {
3239
- engine.checkVersion("4.2.1");
3272
+ engine.checkVersion("4.3.1");
3240
3273
  await engine.pluginManager.register(e => {
3241
3274
  e.pluginManager.addParticleUpdater("outModes", container => {
3242
3275
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3301,13 +3334,13 @@
3301
3334
  if (!this.isEnabled(particle)) {
3302
3335
  return;
3303
3336
  }
3304
- updateColor(particle.fillColor, delta);
3305
- updateColor(particle.strokeColor, delta);
3337
+ updateColor(particle.fillColor, delta, this.#container.hdr);
3338
+ updateColor(particle.strokeColor, delta, this.#container.hdr);
3306
3339
  }
3307
3340
  }
3308
3341
 
3309
3342
  async function loadPaintUpdater(engine) {
3310
- engine.checkVersion("4.2.1");
3343
+ engine.checkVersion("4.3.1");
3311
3344
  await engine.pluginManager.register(e => {
3312
3345
  e.pluginManager.addParticleUpdater("paint", container => {
3313
3346
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3362,7 +3395,7 @@
3362
3395
  }
3363
3396
 
3364
3397
  async function loadRgbColorPlugin(engine) {
3365
- engine.checkVersion("4.2.1");
3398
+ engine.checkVersion("4.3.1");
3366
3399
  await engine.pluginManager.register(e => {
3367
3400
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3368
3401
  });
@@ -3447,7 +3480,7 @@
3447
3480
  }
3448
3481
 
3449
3482
  async function loadSizeUpdater(engine) {
3450
- engine.checkVersion("4.2.1");
3483
+ engine.checkVersion("4.3.1");
3451
3484
  await engine.pluginManager.register(e => {
3452
3485
  e.pluginManager.addParticleUpdater("size", container => {
3453
3486
  return Promise.resolve(new SizeUpdater(container));
@@ -3456,7 +3489,7 @@
3456
3489
  }
3457
3490
 
3458
3491
  async function loadBasic(engine) {
3459
- engine.checkVersion("4.2.1");
3492
+ engine.checkVersion("4.3.1");
3460
3493
  await engine.pluginManager.register(async (e) => {
3461
3494
  await Promise.all([
3462
3495
  loadBlendPlugin(e),
@@ -3787,7 +3820,7 @@
3787
3820
  }
3788
3821
 
3789
3822
  async function loadDestroyUpdater(engine) {
3790
- engine.checkVersion("4.2.1");
3823
+ engine.checkVersion("4.3.1");
3791
3824
  await engine.pluginManager.register(e => {
3792
3825
  e.pluginManager.addParticleUpdater("destroy", container => {
3793
3826
  return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
@@ -4018,7 +4051,7 @@
4018
4051
  })(EmitterClickMode || (EmitterClickMode = {}));
4019
4052
 
4020
4053
  async function loadEmittersPluginSimple(engine) {
4021
- engine.checkVersion("4.2.1");
4054
+ engine.checkVersion("4.3.1");
4022
4055
  await engine.pluginManager.register(async (e) => {
4023
4056
  const instancesManager = await getEmittersInstancesManager(e);
4024
4057
  await addEmittersShapesManager(e);
@@ -4106,7 +4139,7 @@
4106
4139
  }
4107
4140
 
4108
4141
  async function loadEmittersShapeSquare(engine) {
4109
- engine.checkVersion("4.2.1");
4142
+ engine.checkVersion("4.3.1");
4110
4143
  await engine.pluginManager.register((e) => {
4111
4144
  ensureEmittersPluginLoaded(e);
4112
4145
  e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
@@ -4250,7 +4283,7 @@
4250
4283
  }
4251
4284
 
4252
4285
  async function loadLifeUpdater(engine) {
4253
- engine.checkVersion("4.2.1");
4286
+ engine.checkVersion("4.3.1");
4254
4287
  await engine.pluginManager.register(e => {
4255
4288
  e.pluginManager.addParticleUpdater("life", container => {
4256
4289
  return Promise.resolve(new LifeUpdater(container));
@@ -4276,7 +4309,7 @@
4276
4309
  }
4277
4310
 
4278
4311
  async function loadLineShape(engine) {
4279
- engine.checkVersion("4.2.1");
4312
+ engine.checkVersion("4.3.1");
4280
4313
  await engine.pluginManager.register(e => {
4281
4314
  e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
4282
4315
  });
@@ -4380,7 +4413,7 @@
4380
4413
  }
4381
4414
 
4382
4415
  async function loadRotateUpdater(engine) {
4383
- engine.checkVersion("4.2.1");
4416
+ engine.checkVersion("4.3.1");
4384
4417
  await engine.pluginManager.register(e => {
4385
4418
  e.pluginManager.addParticleUpdater("rotate", container => {
4386
4419
  return Promise.resolve(new RotateUpdater(container));
@@ -4696,7 +4729,7 @@
4696
4729
  }
4697
4730
 
4698
4731
  async function loadSoundsPlugin(engine) {
4699
- engine.checkVersion("4.2.1");
4732
+ engine.checkVersion("4.3.1");
4700
4733
  await engine.pluginManager.register(e => {
4701
4734
  e.pluginManager.addPlugin(new SoundsPlugin(e));
4702
4735
  });
@@ -4704,7 +4737,7 @@
4704
4737
 
4705
4738
  let initPromise = null;
4706
4739
  async function doInitPlugins(engine) {
4707
- engine.checkVersion("4.2.1");
4740
+ engine.checkVersion("4.3.1");
4708
4741
  await engine.pluginManager.register(async (e) => {
4709
4742
  const loadEmittersForFireworks = async (e) => {
4710
4743
  await loadEmittersPluginSimple(e);
@@ -4751,7 +4784,7 @@
4751
4784
  fireworks.init = async () => {
4752
4785
  await initPlugins(tsParticles);
4753
4786
  };
4754
- fireworks.version = "4.2.1";
4787
+ fireworks.version = "4.3.1";
4755
4788
  globalThis.fireworks = fireworks;
4756
4789
 
4757
4790
  const globalObject = globalThis;
@@ -4766,10 +4799,10 @@
4766
4799
  }
4767
4800
  }
4768
4801
  class RenderManager {
4802
+ #backgroundElement;
4803
+ #backgroundWarnings;
4769
4804
  #canvasClearPlugins;
4770
4805
  #canvasManager;
4771
- #canvasPaintPlugins;
4772
- #clearDrawPlugins;
4773
4806
  #colorPlugins;
4774
4807
  #container;
4775
4808
  #context;
@@ -4777,9 +4810,7 @@
4777
4810
  #drawParticlePlugins;
4778
4811
  #drawParticlesCleanupPlugins;
4779
4812
  #drawParticlesSetupPlugins;
4780
- #drawPlugins;
4781
- #drawSettingsCleanupPlugins;
4782
- #drawSettingsSetupPlugins;
4813
+ #layers;
4783
4814
  #pluginManager;
4784
4815
  #postDrawUpdaters;
4785
4816
  #preDrawUpdaters;
@@ -4791,18 +4822,25 @@
4791
4822
  this.#container = container;
4792
4823
  this.#canvasManager = canvasManager;
4793
4824
  this.#context = null;
4825
+ this.#backgroundElement = null;
4826
+ this.#backgroundWarnings = new Set();
4794
4827
  this.#preDrawUpdaters = [];
4795
4828
  this.#postDrawUpdaters = [];
4796
- this.#colorPlugins = [];
4797
4829
  this.#canvasClearPlugins = [];
4798
- this.#canvasPaintPlugins = [];
4799
- this.#clearDrawPlugins = [];
4830
+ this.#colorPlugins = [];
4800
4831
  this.#drawParticlePlugins = [];
4801
4832
  this.#drawParticlesCleanupPlugins = [];
4802
4833
  this.#drawParticlesSetupPlugins = [];
4803
- this.#drawPlugins = [];
4804
- this.#drawSettingsSetupPlugins = [];
4805
- this.#drawSettingsCleanupPlugins = [];
4834
+ this.#layers = {
4835
+ 0: [],
4836
+ 1: [],
4837
+ 2: [],
4838
+ 3: [],
4839
+ 4: [],
4840
+ 5: [],
4841
+ 6: [],
4842
+ 7: [],
4843
+ };
4806
4844
  }
4807
4845
  get settings() {
4808
4846
  return this.#contextSettings;
@@ -4816,32 +4854,38 @@
4816
4854
  });
4817
4855
  }
4818
4856
  clear() {
4819
- let pluginHandled = false;
4820
4857
  for (const plugin of this.#canvasClearPlugins) {
4821
- pluginHandled = plugin.canvasClear?.() ?? false;
4822
- if (pluginHandled) {
4823
- break;
4858
+ if (plugin.canvasClear?.() ?? false) {
4859
+ return;
4824
4860
  }
4825
4861
  }
4826
- if (pluginHandled) {
4827
- return;
4862
+ for (const layer of Object.values(exports.DrawLayer)) {
4863
+ if (typeof layer === "number") {
4864
+ for (const plugin of this.#getLayerPlugins(layer)) {
4865
+ if (plugin.canvasClear?.() ?? false) {
4866
+ return;
4867
+ }
4868
+ }
4869
+ }
4828
4870
  }
4829
4871
  this.canvasClear();
4830
4872
  }
4831
4873
  destroy() {
4832
4874
  this.stop();
4875
+ this.#backgroundElement = null;
4876
+ this.#backgroundWarnings.clear();
4833
4877
  this.#preDrawUpdaters = [];
4834
4878
  this.#postDrawUpdaters = [];
4835
- this.#colorPlugins = [];
4836
4879
  this.#canvasClearPlugins = [];
4837
- this.#canvasPaintPlugins = [];
4838
- this.#clearDrawPlugins = [];
4880
+ this.#colorPlugins = [];
4839
4881
  this.#drawParticlePlugins = [];
4840
4882
  this.#drawParticlesCleanupPlugins = [];
4841
4883
  this.#drawParticlesSetupPlugins = [];
4842
- this.#drawPlugins = [];
4843
- this.#drawSettingsSetupPlugins = [];
4844
- this.#drawSettingsCleanupPlugins = [];
4884
+ for (const layer of Object.values(exports.DrawLayer)) {
4885
+ if (typeof layer === "number") {
4886
+ this.#layers[layer] = [];
4887
+ }
4888
+ }
4845
4889
  }
4846
4890
  draw(cb) {
4847
4891
  const ctx = this.#context;
@@ -4898,21 +4942,40 @@
4898
4942
  });
4899
4943
  }
4900
4944
  drawParticles(delta) {
4901
- const { particles } = this.#container;
4945
+ const { particles, actualOptions } = this.#container;
4902
4946
  this.clear();
4903
4947
  particles.update(delta);
4904
4948
  this.draw(ctx => {
4905
- for (const plugin of this.#drawSettingsSetupPlugins) {
4949
+ const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
4950
+ if (this.#backgroundElement) {
4951
+ try {
4952
+ ctx.drawImage(this.#backgroundElement, originPoint.x, originPoint.y, width, height);
4953
+ }
4954
+ catch {
4955
+ this.#warnOnce("background-element-draw-error", "Error drawing background element onto canvas");
4956
+ }
4957
+ }
4958
+ const background = actualOptions.background;
4959
+ if (background.draw) {
4960
+ try {
4961
+ background.draw(ctx, delta);
4962
+ }
4963
+ catch {
4964
+ this.#warnOnce("background-draw-error", "Error in background.draw callback");
4965
+ }
4966
+ }
4967
+ for (const plugin of this.#getLayerPlugins(exports.DrawLayer.BackgroundMask)) {
4968
+ plugin.canvasPaint?.();
4969
+ }
4970
+ for (const plugin of this.#getLayerPlugins(exports.DrawLayer.CanvasSetup)) {
4906
4971
  plugin.drawSettingsSetup?.(ctx, delta);
4907
4972
  }
4908
- for (const plugin of this.#drawPlugins) {
4973
+ for (const plugin of this.#getLayerPlugins(exports.DrawLayer.PluginContent)) {
4909
4974
  plugin.draw?.(ctx, delta);
4910
4975
  }
4911
4976
  particles.drawParticles(delta);
4912
- for (const plugin of this.#clearDrawPlugins) {
4977
+ for (const plugin of this.#getLayerPlugins(exports.DrawLayer.CanvasCleanup)) {
4913
4978
  plugin.clearDraw?.(ctx, delta);
4914
- }
4915
- for (const plugin of this.#drawSettingsCleanupPlugins) {
4916
4979
  plugin.drawSettingsCleanup?.(ctx, delta);
4917
4980
  }
4918
4981
  });
@@ -4920,29 +4983,24 @@
4920
4983
  init() {
4921
4984
  this.initUpdaters();
4922
4985
  this.initPlugins();
4986
+ this.#resolveBackgroundElement();
4923
4987
  this.paint();
4924
4988
  }
4925
4989
  initPlugins() {
4926
- this.#colorPlugins = [];
4927
4990
  this.#canvasClearPlugins = [];
4928
- this.#canvasPaintPlugins = [];
4929
- this.#clearDrawPlugins = [];
4991
+ this.#colorPlugins = [];
4930
4992
  this.#drawParticlePlugins = [];
4931
4993
  this.#drawParticlesSetupPlugins = [];
4932
4994
  this.#drawParticlesCleanupPlugins = [];
4933
- this.#drawPlugins = [];
4934
- this.#drawSettingsSetupPlugins = [];
4935
- this.#drawSettingsCleanupPlugins = [];
4995
+ for (const layer of Object.values(exports.DrawLayer)) {
4996
+ if (typeof layer === "number") {
4997
+ this.#layers[layer] = [];
4998
+ }
4999
+ }
4936
5000
  for (const plugin of this.#container.plugins) {
4937
5001
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
4938
5002
  this.#colorPlugins.push(plugin);
4939
5003
  }
4940
- if (plugin.canvasClear) {
4941
- this.#canvasClearPlugins.push(plugin);
4942
- }
4943
- if (plugin.canvasPaint) {
4944
- this.#canvasPaintPlugins.push(plugin);
4945
- }
4946
5004
  if (plugin.drawParticle) {
4947
5005
  this.#drawParticlePlugins.push(plugin);
4948
5006
  }
@@ -4952,17 +5010,20 @@
4952
5010
  if (plugin.drawParticleCleanup) {
4953
5011
  this.#drawParticlesCleanupPlugins.push(plugin);
4954
5012
  }
4955
- if (plugin.draw) {
4956
- this.#drawPlugins.push(plugin);
5013
+ if (plugin.canvasClear) {
5014
+ this.#canvasClearPlugins.push(plugin);
5015
+ }
5016
+ if (plugin.canvasPaint) {
5017
+ this.#getLayerPlugins(exports.DrawLayer.BackgroundMask).push(plugin);
4957
5018
  }
4958
5019
  if (plugin.drawSettingsSetup) {
4959
- this.#drawSettingsSetupPlugins.push(plugin);
5020
+ this.#getLayerPlugins(exports.DrawLayer.CanvasSetup).push(plugin);
4960
5021
  }
4961
- if (plugin.drawSettingsCleanup) {
4962
- this.#drawSettingsCleanupPlugins.push(plugin);
5022
+ if (plugin.draw) {
5023
+ this.#getLayerPlugins(exports.DrawLayer.PluginContent).push(plugin);
4963
5024
  }
4964
- if (plugin.clearDraw) {
4965
- this.#clearDrawPlugins.push(plugin);
5025
+ if (plugin.clearDraw ?? plugin.drawSettingsCleanup) {
5026
+ this.#getLayerPlugins(exports.DrawLayer.CanvasCleanup).push(plugin);
4966
5027
  }
4967
5028
  }
4968
5029
  }
@@ -4980,7 +5041,7 @@
4980
5041
  }
4981
5042
  paint() {
4982
5043
  let handled = false;
4983
- for (const plugin of this.#canvasPaintPlugins) {
5044
+ for (const plugin of this.#getLayerPlugins(exports.DrawLayer.BackgroundMask)) {
4984
5045
  handled = plugin.canvasPaint?.() ?? false;
4985
5046
  if (handled) {
4986
5047
  break;
@@ -5153,6 +5214,9 @@
5153
5214
  }
5154
5215
  drawer.beforeDraw(data);
5155
5216
  }
5217
+ #getLayerPlugins(layer) {
5218
+ return this.#layers[layer];
5219
+ }
5156
5220
  #getPluginParticleColors(particle) {
5157
5221
  let fColor, sColor;
5158
5222
  for (const plugin of this.#colorPlugins) {
@@ -5170,6 +5234,39 @@
5170
5234
  this.#reusablePluginColors[sColorIndex] = sColor;
5171
5235
  return this.#reusablePluginColors;
5172
5236
  }
5237
+ #resolveBackgroundElement() {
5238
+ const background = this.#container.actualOptions.background;
5239
+ this.#backgroundElement = null;
5240
+ if (!background.element) {
5241
+ return;
5242
+ }
5243
+ if (typeof background.element === "string") {
5244
+ if (typeof document !== "undefined") {
5245
+ const node = document.querySelector(background.element);
5246
+ if (node instanceof HTMLCanvasElement || node instanceof HTMLVideoElement || node instanceof HTMLImageElement) {
5247
+ this.#backgroundElement = node;
5248
+ }
5249
+ else if (node) {
5250
+ this.#warnOnce("background-element-not-supported", `Background element "${background.element}" is not a supported drawable element (canvas, video, or img)`);
5251
+ }
5252
+ else {
5253
+ this.#warnOnce("background-element-not-found", `Background element selector "${background.element}" not found`);
5254
+ }
5255
+ }
5256
+ }
5257
+ else if (background.element instanceof HTMLCanvasElement ||
5258
+ background.element instanceof OffscreenCanvas ||
5259
+ background.element instanceof HTMLVideoElement ||
5260
+ background.element instanceof HTMLImageElement) {
5261
+ this.#backgroundElement = background.element;
5262
+ }
5263
+ }
5264
+ #warnOnce(key, message) {
5265
+ if (!this.#backgroundWarnings.has(key)) {
5266
+ this.#backgroundWarnings.add(key);
5267
+ getLogger().warning(message);
5268
+ }
5269
+ }
5173
5270
  }
5174
5271
 
5175
5272
  const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
@@ -5746,7 +5843,6 @@
5746
5843
  }
5747
5844
  class Particle {
5748
5845
  backColor;
5749
- bubble;
5750
5846
  destroyed;
5751
5847
  direction;
5752
5848
  effect;
@@ -5780,7 +5876,6 @@
5780
5876
  shapeData;
5781
5877
  sides;
5782
5878
  size;
5783
- slow;
5784
5879
  spawning;
5785
5880
  strokeColor;
5786
5881
  strokeOpacity;
@@ -5802,18 +5897,25 @@
5802
5897
  d: 1,
5803
5898
  };
5804
5899
  #container;
5900
+ #modifiers = [];
5805
5901
  #pluginManager;
5806
5902
  constructor(pluginManager, container) {
5807
5903
  this.#pluginManager = pluginManager;
5808
5904
  this.#container = container;
5809
5905
  }
5906
+ addModifier(modifier) {
5907
+ this.#modifiers.push(modifier);
5908
+ this.#modifiers.sort((a, b) => a.priority - b.priority);
5909
+ }
5910
+ clearModifiers() {
5911
+ this.#modifiers.length = 0;
5912
+ }
5810
5913
  destroy(override) {
5811
5914
  if (this.unbreakable || this.destroyed) {
5812
5915
  return;
5813
5916
  }
5814
5917
  this.destroyed = true;
5815
- this.bubble.inRange = false;
5816
- this.slow.inRange = false;
5918
+ this.clearModifiers();
5817
5919
  const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
5818
5920
  shapeDrawer?.particleDestroy?.(this);
5819
5921
  for (const plugin of container.particleDestroyedPlugins) {
@@ -5835,13 +5937,16 @@
5835
5937
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
5836
5938
  }
5837
5939
  getFillColor() {
5838
- return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
5940
+ return this.#getRollColor(this.#applyModifiers(getHslFromAnimation(this.fillColor), m => m.fillColor));
5839
5941
  }
5840
5942
  getMass() {
5841
5943
  return this.getRadius() ** squareExp * Math.PI * half;
5842
5944
  }
5945
+ getModifier(id) {
5946
+ return this.#modifiers.find(m => m.id === id);
5947
+ }
5843
5948
  getOpacity() {
5844
- 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;
5949
+ 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;
5845
5950
  this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
5846
5951
  this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
5847
5952
  this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
@@ -5854,7 +5959,7 @@
5854
5959
  return this.#cachedPosition;
5855
5960
  }
5856
5961
  getRadius() {
5857
- return this.bubble.radius ?? this.size.value;
5962
+ return this.#applyModifiers(this.size.value, m => m.radius);
5858
5963
  }
5859
5964
  getRotateData() {
5860
5965
  const angle = this.getAngle();
@@ -5863,7 +5968,7 @@
5863
5968
  return this.#cachedRotateData;
5864
5969
  }
5865
5970
  getStrokeColor() {
5866
- return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
5971
+ return this.#getRollColor(this.#applyModifiers(getHslFromAnimation(this.strokeColor), m => m.strokeColor));
5867
5972
  }
5868
5973
  getTransformData(externalTransform) {
5869
5974
  const rotateData = this.getRotateData(), rotating = this.isRotating;
@@ -5883,13 +5988,6 @@
5883
5988
  this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
5884
5989
  container.retina.initParticle(this);
5885
5990
  runUpdaterPreInit(container.particleUpdaters, this);
5886
- this.bubble = {
5887
- inRange: false,
5888
- };
5889
- this.slow = {
5890
- inRange: false,
5891
- factor: 1,
5892
- };
5893
5991
  this.#initPosition(position);
5894
5992
  this.initialVelocity = this.#calculateVelocity();
5895
5993
  this.velocity = this.initialVelocity.copy();
@@ -5929,11 +6027,29 @@
5929
6027
  isVisible() {
5930
6028
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
5931
6029
  }
6030
+ removeModifier(id) {
6031
+ const idx = this.#modifiers.findIndex(m => m.id === id);
6032
+ if (idx >= defaultAngle) {
6033
+ this.#modifiers.splice(idx, identity$1);
6034
+ }
6035
+ }
5932
6036
  reset() {
5933
6037
  for (const updater of this.#container.particleUpdaters) {
5934
6038
  updater.reset?.(this);
5935
6039
  }
5936
6040
  }
6041
+ #applyModifiers(base, getter) {
6042
+ let value = base;
6043
+ for (const mod of this.#modifiers) {
6044
+ if (mod.enabled) {
6045
+ const override = getter(mod);
6046
+ if (override !== undefined) {
6047
+ value = override;
6048
+ }
6049
+ }
6050
+ }
6051
+ return value;
6052
+ }
5937
6053
  #calcPosition(position, zIndex) {
5938
6054
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
5939
6055
  const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
@@ -7065,6 +7181,7 @@
7065
7181
  });
7066
7182
 
7067
7183
  class BlendPluginInstance {
7184
+ layer = exports.DrawLayer.CanvasSetup;
7068
7185
  #container;
7069
7186
  #defaultCompositeValue;
7070
7187
  constructor(container) {
@@ -7210,7 +7327,8 @@
7210
7327
  particle.lastPathTime -= pathDelay;
7211
7328
  }
7212
7329
  function getProximitySpeedFactor(particle) {
7213
- return particle.slow.inRange ? particle.slow.factor : identity$1;
7330
+ const mod = particle.getModifier("slow");
7331
+ return mod?.enabled ? (mod.speedFactor ?? identity$1) : identity$1;
7214
7332
  }
7215
7333
  function initSpin(container, particle) {
7216
7334
  const options = particle.options, spinOptions = options.move.spin;
@@ -8391,6 +8509,7 @@
8391
8509
  exports.hPhase = hPhase;
8392
8510
  exports.half = half;
8393
8511
  exports.hslToRgb = hslToRgb;
8512
+ exports.hslToRgbFloat = hslToRgbFloat;
8394
8513
  exports.hslaToRgba = hslaToRgba;
8395
8514
  exports.identity = identity$1;
8396
8515
  exports.inverseFactorNumerator = inverseFactorNumerator;