@tsparticles/preset-big-circles 4.5.0 → 4.5.2

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,6 +1,6 @@
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);})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
2
  (function (g) {
3
- /* Preset v4.5.0 */
3
+ /* Preset v4.5.2 */
4
4
  g.__tsParticlesInternals = g.__tsParticlesInternals || {};
5
5
  g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6
6
  (function (exports) {
@@ -120,7 +120,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
120
120
  }
121
121
  normalize() {
122
122
  const length = this.length;
123
- if (length != none) {
123
+ if (length !== none) {
124
124
  this.multTo(inverseFactorNumerator / length);
125
125
  }
126
126
  }
@@ -654,12 +654,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
654
654
  }
655
655
  addEventListener(type, listener) {
656
656
  this.removeEventListener(type, listener);
657
- let arr = this.#listeners.get(type);
658
- if (!arr) {
659
- arr = [];
660
- this.#listeners.set(type, arr);
661
- }
662
- arr.push(listener);
657
+ const arr = this.#listeners.get(type);
658
+ this.#listeners.set(type, arr ? [...arr, listener] : [listener]);
663
659
  }
664
660
  dispatchEvent(type, args) {
665
661
  const listeners = this.#listeners.get(type);
@@ -691,7 +687,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
691
687
  this.#listeners.delete(type);
692
688
  }
693
689
  else {
694
- arr.splice(idx, deleteCount);
690
+ this.#listeners.set(type, [...arr.slice(minIndex, idx), ...arr.slice(idx + deleteCount)]);
695
691
  }
696
692
  }
697
693
  }
@@ -868,11 +864,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
868
864
  #domArray = [];
869
865
  #eventDispatcher = new EventDispatcher();
870
866
  #initialized = false;
867
+ #loadSequence = 0;
868
+ #loadSequences = new Map();
871
869
  get items() {
872
870
  return this.#domArray;
873
871
  }
874
872
  get version() {
875
- return "4.5.0";
873
+ return "4.5.2";
876
874
  }
877
875
  addEventListener(type, listener) {
878
876
  this.#eventDispatcher.addEventListener(type, listener);
@@ -902,44 +900,60 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
902
900
  return item;
903
901
  }
904
902
  async load(params) {
905
- await this.init();
906
903
  let domSourceElement;
907
904
  if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
908
905
  domSourceElement = params.element;
909
906
  }
910
- const { Container } = await Promise.resolve().then(function () { return Container$1; }), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
911
- dispatchCallback: (eventType, args) => {
912
- this.dispatchEvent(eventType, args);
913
- },
914
- id,
915
- onDestroy: (remove) => {
916
- if (!remove) {
917
- return;
918
- }
919
- const mainArr = this.items, idx = mainArr.indexOf(newItem);
920
- if (idx >= removeMinIndex) {
921
- mainArr.splice(idx, removeDeleteCount);
907
+ const id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, loadSequence = ++this.#loadSequence;
908
+ this.#loadSequences.set(id, loadSequence);
909
+ try {
910
+ await this.init();
911
+ const { Container } = await Promise.resolve().then(function () { return Container$1; }), { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options;
912
+ if (this.#loadSequences.get(id) !== loadSequence) {
913
+ return undefined;
914
+ }
915
+ const currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
916
+ dispatchCallback: (eventType, args) => {
917
+ this.dispatchEvent(eventType, args);
918
+ },
919
+ id,
920
+ onDestroy: (remove) => {
921
+ if (!remove) {
922
+ return;
923
+ }
924
+ const mainArr = this.items, idx = mainArr.indexOf(newItem);
925
+ if (idx >= removeMinIndex) {
926
+ mainArr.splice(idx, removeDeleteCount);
927
+ }
928
+ },
929
+ pluginManager: this.pluginManager,
930
+ sourceOptions: currentOptions,
931
+ });
932
+ if (oldIndex >= loadMinIndex) {
933
+ const old = this.item(oldIndex), deleteCount = old ? one : none;
934
+ if (old && !old.destroyed) {
935
+ old.destroy(false);
922
936
  }
923
- },
924
- pluginManager: this.pluginManager,
925
- sourceOptions: currentOptions,
926
- });
927
- if (oldIndex >= loadMinIndex) {
928
- const old = this.item(oldIndex), deleteCount = old ? one : none;
929
- if (old && !old.destroyed) {
930
- old.destroy(false);
937
+ items.splice(oldIndex, deleteCount, newItem);
931
938
  }
932
- items.splice(oldIndex, deleteCount, newItem);
939
+ else {
940
+ items.push(newItem);
941
+ }
942
+ const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
943
+ ? params.element
944
+ : getCanvasFromContainer(getDomContainer(id, domSourceElement));
945
+ newItem.canvas.loadCanvas(sourceCanvas);
946
+ await newItem.start();
947
+ if (newItem.destroyed) {
948
+ return undefined;
949
+ }
950
+ return newItem;
933
951
  }
934
- else {
935
- items.push(newItem);
952
+ finally {
953
+ if (this.#loadSequences.get(id) === loadSequence) {
954
+ this.#loadSequences.delete(id);
955
+ }
936
956
  }
937
- const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
938
- ? params.element
939
- : getCanvasFromContainer(getDomContainer(id, domSourceElement));
940
- newItem.canvas.loadCanvas(sourceCanvas);
941
- await newItem.start();
942
- return newItem;
943
957
  }
944
958
  async refresh(refresh = true) {
945
959
  if (!refresh) {
@@ -2247,6 +2261,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2247
2261
  }
2248
2262
  }
2249
2263
 
2264
+ function hasEnabledBlend(particleOptions) {
2265
+ if (!particleOptions || typeof particleOptions !== "object" || !("blend" in particleOptions)) {
2266
+ return false;
2267
+ }
2268
+ const blend = particleOptions.blend;
2269
+ return !!blend && typeof blend === "object" && "enable" in blend && !!blend.enable;
2270
+ }
2250
2271
  class BlendPlugin {
2251
2272
  id = "blend";
2252
2273
  async getPlugin(container) {
@@ -2268,12 +2289,31 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2268
2289
  options.blend.load(source?.blend);
2269
2290
  }
2270
2291
  needsPlugin(options) {
2271
- return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
2292
+ if (options?.blend?.enable ||
2293
+ options?.particles?.blend?.enable ||
2294
+ Object.values(options?.particles?.groups ?? {}).some(hasEnabledBlend)) {
2295
+ return true;
2296
+ }
2297
+ const emitters = options?.["emitters"];
2298
+ let emitterList = [];
2299
+ if (Array.isArray(emitters)) {
2300
+ emitterList = emitters;
2301
+ }
2302
+ else if (emitters) {
2303
+ emitterList = [emitters];
2304
+ }
2305
+ return emitterList.some(emitter => {
2306
+ if (!emitter || typeof emitter !== "object" || !("particles" in emitter)) {
2307
+ return false;
2308
+ }
2309
+ const particles = emitter.particles;
2310
+ return Array.isArray(particles) ? particles.some(hasEnabledBlend) : hasEnabledBlend(particles);
2311
+ });
2272
2312
  }
2273
2313
  }
2274
2314
 
2275
2315
  async function loadBlendPlugin(engine) {
2276
- engine.checkVersion("4.5.0");
2316
+ engine.checkVersion("4.5.2");
2277
2317
  await engine.pluginManager.register(e => {
2278
2318
  e.pluginManager.addPlugin(new BlendPlugin());
2279
2319
  });
@@ -2310,7 +2350,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2310
2350
  }
2311
2351
 
2312
2352
  async function loadCircleShape(engine) {
2313
- engine.checkVersion("4.5.0");
2353
+ engine.checkVersion("4.5.2");
2314
2354
  await engine.pluginManager.register(e => {
2315
2355
  e.pluginManager.addShape(["circle"], () => {
2316
2356
  return Promise.resolve(new CircleDrawer());
@@ -2358,7 +2398,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2358
2398
  }
2359
2399
 
2360
2400
  async function loadHexColorPlugin(engine) {
2361
- engine.checkVersion("4.5.0");
2401
+ engine.checkVersion("4.5.2");
2362
2402
  await engine.pluginManager.register(e => {
2363
2403
  e.pluginManager.addColorManager("hex", new HexColorManager());
2364
2404
  });
@@ -2411,7 +2451,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2411
2451
  }
2412
2452
 
2413
2453
  async function loadHslColorPlugin(engine) {
2414
- engine.checkVersion("4.5.0");
2454
+ engine.checkVersion("4.5.2");
2415
2455
  await engine.pluginManager.register(e => {
2416
2456
  e.pluginManager.addColorManager("hsl", new HslColorManager());
2417
2457
  });
@@ -2443,7 +2483,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2443
2483
  }
2444
2484
 
2445
2485
  async function loadMovePlugin(engine) {
2446
- engine.checkVersion("4.5.0");
2486
+ engine.checkVersion("4.5.2");
2447
2487
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
2448
2488
  addErrorMessages(ErrorMessages);
2449
2489
  }
@@ -2653,7 +2693,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2653
2693
  }
2654
2694
 
2655
2695
  async function loadOpacityUpdater(engine) {
2656
- engine.checkVersion("4.5.0");
2696
+ engine.checkVersion("4.5.2");
2657
2697
  await engine.pluginManager.register(e => {
2658
2698
  e.pluginManager.addParticleUpdater("opacity", container => {
2659
2699
  return Promise.resolve(new OpacityUpdater(container));
@@ -2982,7 +3022,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2982
3022
  }
2983
3023
 
2984
3024
  async function loadOutModesUpdater(engine) {
2985
- engine.checkVersion("4.5.0");
3025
+ engine.checkVersion("4.5.2");
2986
3026
  await engine.pluginManager.register(e => {
2987
3027
  e.pluginManager.addParticleUpdater("outModes", container => {
2988
3028
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3061,7 +3101,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3061
3101
  }
3062
3102
 
3063
3103
  async function loadPaintUpdater(engine) {
3064
- engine.checkVersion("4.5.0");
3104
+ engine.checkVersion("4.5.2");
3065
3105
  await engine.pluginManager.register(e => {
3066
3106
  e.pluginManager.addParticleUpdater("paint", container => {
3067
3107
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3116,7 +3156,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3116
3156
  }
3117
3157
 
3118
3158
  async function loadRgbColorPlugin(engine) {
3119
- engine.checkVersion("4.5.0");
3159
+ engine.checkVersion("4.5.2");
3120
3160
  await engine.pluginManager.register(e => {
3121
3161
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3122
3162
  });
@@ -3201,7 +3241,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3201
3241
  }
3202
3242
 
3203
3243
  async function loadSizeUpdater(engine) {
3204
- engine.checkVersion("4.5.0");
3244
+ engine.checkVersion("4.5.2");
3205
3245
  await engine.pluginManager.register(e => {
3206
3246
  e.pluginManager.addParticleUpdater("size", container => {
3207
3247
  return Promise.resolve(new SizeUpdater(container));
@@ -3210,7 +3250,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3210
3250
  }
3211
3251
 
3212
3252
  async function loadBasic(engine) {
3213
- engine.checkVersion("4.5.0");
3253
+ engine.checkVersion("4.5.2");
3214
3254
  await engine.pluginManager.register(async (e) => {
3215
3255
  await Promise.all([
3216
3256
  loadBlendPlugin(e),
@@ -3486,7 +3526,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3486
3526
  });
3487
3527
  }
3488
3528
  drawParticles(delta) {
3489
- const { particles, actualOptions } = this.#container, clearedPlugin = this.clear();
3529
+ const { particles, actualOptions } = this.#container;
3530
+ this.clear();
3490
3531
  particles.update(delta);
3491
3532
  this.draw(ctx => {
3492
3533
  const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
@@ -3508,9 +3549,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3508
3549
  }
3509
3550
  }
3510
3551
  for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
3511
- if (plugin !== clearedPlugin) {
3512
- plugin.canvasPaint?.();
3513
- }
3552
+ plugin.canvasPaint?.();
3514
3553
  }
3515
3554
  for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
3516
3555
  plugin.drawSettingsSetup?.(ctx, delta);
@@ -3600,6 +3639,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3600
3639
  ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
3601
3640
  });
3602
3641
  }
3642
+ updateBackgroundElement() {
3643
+ this.#resolveBackgroundElement();
3644
+ }
3603
3645
  #applyPostDrawUpdaters(particle) {
3604
3646
  for (const updater of this.#postDrawUpdaters) {
3605
3647
  updater.afterDraw?.(particle);
@@ -3798,7 +3840,14 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3798
3840
  }
3799
3841
  if (typeof background.element === "string") {
3800
3842
  if (typeof document !== "undefined") {
3801
- const node = document.querySelector(background.element);
3843
+ let node;
3844
+ try {
3845
+ node = document.querySelector(background.element);
3846
+ }
3847
+ catch {
3848
+ this.#warnOnce("background-element-invalid-selector", `Background element selector "${background.element}" is invalid`);
3849
+ return;
3850
+ }
3802
3851
  if (node && this.#isSupportedElement(node)) {
3803
3852
  this.#backgroundElement = node;
3804
3853
  }
@@ -4244,6 +4293,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4244
4293
  this.#manageListeners(true);
4245
4294
  }
4246
4295
  removeListeners() {
4296
+ if (this.#resizeTimeout !== undefined) {
4297
+ clearTimeout(this.#resizeTimeout);
4298
+ this.#resizeTimeout = undefined;
4299
+ }
4247
4300
  this.#manageListeners(false);
4248
4301
  }
4249
4302
  #handleVisibilityChange() {
@@ -4618,10 +4671,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4618
4671
  runParticleCreatedPlugins(container, this);
4619
4672
  }
4620
4673
  isInsideCanvas(direction) {
4621
- return this.#getInsideCanvasResult({ direction }).inside;
4674
+ return this.#getInsideCanvasResult(direction).inside;
4622
4675
  }
4623
4676
  isInsideCanvasForOutMode(outMode, direction) {
4624
- return this.#getInsideCanvasResult({ direction, outMode }).inside;
4677
+ return this.#getInsideCanvasResult(direction, outMode).inside;
4625
4678
  }
4626
4679
  isShowingBack() {
4627
4680
  if (!this.roll) {
@@ -4738,7 +4791,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4738
4791
  });
4739
4792
  }
4740
4793
  #getDefaultInsideCanvasResult(direction, outMode) {
4741
- const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
4794
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce || outMode === OutMode.split;
4742
4795
  if (direction === OutModeDirection.bottom) {
4743
4796
  return {
4744
4797
  inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
@@ -4780,12 +4833,16 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4780
4833
  radius: this.getRadius(),
4781
4834
  };
4782
4835
  }
4783
- #getInsideCanvasResult(data) {
4784
- 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;
4785
- if (!shapeCheck && !effectCheck) {
4836
+ #getInsideCanvasResult(direction, outMode) {
4837
+ const defaultResult = this.#getDefaultInsideCanvasResult(direction, outMode), container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined, effectDrawer = this.effect ? container.effectDrawers.get(this.effect) : undefined;
4838
+ if (!shapeDrawer?.isInsideCanvas && !effectDrawer?.isInsideCanvas) {
4786
4839
  return defaultResult;
4787
4840
  }
4788
- const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
4841
+ const callbackData = this.#getInsideCanvasCallbackData(direction, outMode), shapeResult = shapeDrawer?.isInsideCanvas
4842
+ ? this.#normalizeInsideCanvasResult(shapeDrawer.isInsideCanvas(callbackData), "shape")
4843
+ : undefined, effectResult = effectDrawer?.isInsideCanvas
4844
+ ? this.#normalizeInsideCanvasResult(effectDrawer.isInsideCanvas(callbackData), "effect")
4845
+ : undefined;
4789
4846
  if (shapeResult && effectResult) {
4790
4847
  const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
4791
4848
  return {
@@ -4851,8 +4908,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4851
4908
  }
4852
4909
 
4853
4910
  class SpatialHashGrid {
4854
- #cellSize;
4855
4911
  #cells = new Map();
4912
+ #cellSize;
4856
4913
  #circlePool = [];
4857
4914
  #circlePoolIdx;
4858
4915
  #pendingCellSize;
@@ -4898,14 +4955,22 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4898
4955
  return out;
4899
4956
  }
4900
4957
  queryCircle(position, radius, check, out = []) {
4901
- const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
4902
- this.#releaseShapes();
4903
- return result;
4958
+ const circle = this.#acquireCircle(position.x, position.y, radius);
4959
+ try {
4960
+ return this.query(circle, check, out);
4961
+ }
4962
+ finally {
4963
+ this.#circlePoolIdx--;
4964
+ }
4904
4965
  }
4905
4966
  queryRectangle(position, size, check, out = []) {
4906
- const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
4907
- this.#releaseShapes();
4908
- return result;
4967
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height);
4968
+ try {
4969
+ return this.query(rect, check, out);
4970
+ }
4971
+ finally {
4972
+ this.#rectanglePoolIdx--;
4973
+ }
4909
4974
  }
4910
4975
  #acquireCircle(x, y, r) {
4911
4976
  const idx = this.#circlePoolIdx++;
@@ -4964,10 +5029,6 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4964
5029
  }
4965
5030
  }
4966
5031
  }
4967
- #releaseShapes() {
4968
- this.#circlePoolIdx = 0;
4969
- this.#rectanglePoolIdx = 0;
4970
- }
4971
5032
  }
4972
5033
 
4973
5034
  class ParticlesManager {
@@ -5506,8 +5567,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5506
5567
  particleCreatedPlugins;
5507
5568
  particleDestroyedPlugins;
5508
5569
  particlePositionPlugins;
5509
- particleUpdaters;
5510
5570
  particles;
5571
+ particleUpdaters;
5511
5572
  peakNits;
5512
5573
  plugins;
5513
5574
  retina;
@@ -5515,6 +5576,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5515
5576
  started;
5516
5577
  zLayers;
5517
5578
  #delay;
5579
+ #delayResolve;
5518
5580
  #delayTimeout;
5519
5581
  #delta = { value: 0, factor: 0 };
5520
5582
  #dispatchCallback;
@@ -5753,7 +5815,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5753
5815
  await this.init();
5754
5816
  this.started = true;
5755
5817
  await new Promise(resolve => {
5818
+ this.#delayResolve = resolve;
5756
5819
  const start = async () => {
5820
+ this.#delayTimeout = undefined;
5821
+ this.#delayResolve = undefined;
5757
5822
  this.#eventListeners.addListeners();
5758
5823
  for (const plugin of this.plugins) {
5759
5824
  await plugin.start?.();
@@ -5769,9 +5834,11 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5769
5834
  if (!guardCheck(this) || !this.started) {
5770
5835
  return;
5771
5836
  }
5772
- if (this.#delayTimeout) {
5837
+ if (this.#delayTimeout !== undefined) {
5773
5838
  clearTimeout(this.#delayTimeout);
5774
5839
  this.#delayTimeout = undefined;
5840
+ this.#delayResolve?.();
5841
+ this.#delayResolve = undefined;
5775
5842
  }
5776
5843
  this.#firstStart = true;
5777
5844
  this.started = false;
@@ -5795,6 +5862,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5795
5862
  refresh = plugin.updateActualOptions() || refresh;
5796
5863
  }
5797
5864
  }
5865
+ this.canvas.render.updateBackgroundElement();
5798
5866
  return refresh;
5799
5867
  }
5800
5868
  #initPlugins(allContainerPlugins) {