@tsparticles/preset-bubbles 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
  }
@@ -667,12 +667,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
667
667
  }
668
668
  addEventListener(type, listener) {
669
669
  this.removeEventListener(type, listener);
670
- let arr = this.#listeners.get(type);
671
- if (!arr) {
672
- arr = [];
673
- this.#listeners.set(type, arr);
674
- }
675
- arr.push(listener);
670
+ const arr = this.#listeners.get(type);
671
+ this.#listeners.set(type, arr ? [...arr, listener] : [listener]);
676
672
  }
677
673
  dispatchEvent(type, args) {
678
674
  const listeners = this.#listeners.get(type);
@@ -704,7 +700,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
704
700
  this.#listeners.delete(type);
705
701
  }
706
702
  else {
707
- arr.splice(idx, deleteCount);
703
+ this.#listeners.set(type, [...arr.slice(minIndex, idx), ...arr.slice(idx + deleteCount)]);
708
704
  }
709
705
  }
710
706
  }
@@ -881,11 +877,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
881
877
  #domArray = [];
882
878
  #eventDispatcher = new EventDispatcher();
883
879
  #initialized = false;
880
+ #loadSequence = 0;
881
+ #loadSequences = new Map();
884
882
  get items() {
885
883
  return this.#domArray;
886
884
  }
887
885
  get version() {
888
- return "4.5.0";
886
+ return "4.5.2";
889
887
  }
890
888
  addEventListener(type, listener) {
891
889
  this.#eventDispatcher.addEventListener(type, listener);
@@ -915,44 +913,60 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
915
913
  return item;
916
914
  }
917
915
  async load(params) {
918
- await this.init();
919
916
  let domSourceElement;
920
917
  if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
921
918
  domSourceElement = params.element;
922
919
  }
923
- 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({
924
- dispatchCallback: (eventType, args) => {
925
- this.dispatchEvent(eventType, args);
926
- },
927
- id,
928
- onDestroy: (remove) => {
929
- if (!remove) {
930
- return;
931
- }
932
- const mainArr = this.items, idx = mainArr.indexOf(newItem);
933
- if (idx >= removeMinIndex) {
934
- mainArr.splice(idx, removeDeleteCount);
920
+ const id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, loadSequence = ++this.#loadSequence;
921
+ this.#loadSequences.set(id, loadSequence);
922
+ try {
923
+ await this.init();
924
+ const { Container } = await Promise.resolve().then(function () { return Container$1; }), { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options;
925
+ if (this.#loadSequences.get(id) !== loadSequence) {
926
+ return undefined;
927
+ }
928
+ const currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
929
+ dispatchCallback: (eventType, args) => {
930
+ this.dispatchEvent(eventType, args);
931
+ },
932
+ id,
933
+ onDestroy: (remove) => {
934
+ if (!remove) {
935
+ return;
936
+ }
937
+ const mainArr = this.items, idx = mainArr.indexOf(newItem);
938
+ if (idx >= removeMinIndex) {
939
+ mainArr.splice(idx, removeDeleteCount);
940
+ }
941
+ },
942
+ pluginManager: this.pluginManager,
943
+ sourceOptions: currentOptions,
944
+ });
945
+ if (oldIndex >= loadMinIndex) {
946
+ const old = this.item(oldIndex), deleteCount = old ? one : none;
947
+ if (old && !old.destroyed) {
948
+ old.destroy(false);
935
949
  }
936
- },
937
- pluginManager: this.pluginManager,
938
- sourceOptions: currentOptions,
939
- });
940
- if (oldIndex >= loadMinIndex) {
941
- const old = this.item(oldIndex), deleteCount = old ? one : none;
942
- if (old && !old.destroyed) {
943
- old.destroy(false);
950
+ items.splice(oldIndex, deleteCount, newItem);
944
951
  }
945
- items.splice(oldIndex, deleteCount, newItem);
952
+ else {
953
+ items.push(newItem);
954
+ }
955
+ const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
956
+ ? params.element
957
+ : getCanvasFromContainer(getDomContainer(id, domSourceElement));
958
+ newItem.canvas.loadCanvas(sourceCanvas);
959
+ await newItem.start();
960
+ if (newItem.destroyed) {
961
+ return undefined;
962
+ }
963
+ return newItem;
946
964
  }
947
- else {
948
- items.push(newItem);
965
+ finally {
966
+ if (this.#loadSequences.get(id) === loadSequence) {
967
+ this.#loadSequences.delete(id);
968
+ }
949
969
  }
950
- const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
951
- ? params.element
952
- : getCanvasFromContainer(getDomContainer(id, domSourceElement));
953
- newItem.canvas.loadCanvas(sourceCanvas);
954
- await newItem.start();
955
- return newItem;
956
970
  }
957
971
  async refresh(refresh = true) {
958
972
  if (!refresh) {
@@ -2260,6 +2274,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2260
2274
  }
2261
2275
  }
2262
2276
 
2277
+ function hasEnabledBlend(particleOptions) {
2278
+ if (!particleOptions || typeof particleOptions !== "object" || !("blend" in particleOptions)) {
2279
+ return false;
2280
+ }
2281
+ const blend = particleOptions.blend;
2282
+ return !!blend && typeof blend === "object" && "enable" in blend && !!blend.enable;
2283
+ }
2263
2284
  class BlendPlugin {
2264
2285
  id = "blend";
2265
2286
  async getPlugin(container) {
@@ -2281,12 +2302,31 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2281
2302
  options.blend.load(source?.blend);
2282
2303
  }
2283
2304
  needsPlugin(options) {
2284
- return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
2305
+ if (options?.blend?.enable ||
2306
+ options?.particles?.blend?.enable ||
2307
+ Object.values(options?.particles?.groups ?? {}).some(hasEnabledBlend)) {
2308
+ return true;
2309
+ }
2310
+ const emitters = options?.["emitters"];
2311
+ let emitterList = [];
2312
+ if (Array.isArray(emitters)) {
2313
+ emitterList = emitters;
2314
+ }
2315
+ else if (emitters) {
2316
+ emitterList = [emitters];
2317
+ }
2318
+ return emitterList.some(emitter => {
2319
+ if (!emitter || typeof emitter !== "object" || !("particles" in emitter)) {
2320
+ return false;
2321
+ }
2322
+ const particles = emitter.particles;
2323
+ return Array.isArray(particles) ? particles.some(hasEnabledBlend) : hasEnabledBlend(particles);
2324
+ });
2285
2325
  }
2286
2326
  }
2287
2327
 
2288
2328
  async function loadBlendPlugin(engine) {
2289
- engine.checkVersion("4.5.0");
2329
+ engine.checkVersion("4.5.2");
2290
2330
  await engine.pluginManager.register(e => {
2291
2331
  e.pluginManager.addPlugin(new BlendPlugin());
2292
2332
  });
@@ -2323,7 +2363,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2323
2363
  }
2324
2364
 
2325
2365
  async function loadCircleShape(engine) {
2326
- engine.checkVersion("4.5.0");
2366
+ engine.checkVersion("4.5.2");
2327
2367
  await engine.pluginManager.register(e => {
2328
2368
  e.pluginManager.addShape(["circle"], () => {
2329
2369
  return Promise.resolve(new CircleDrawer());
@@ -2371,7 +2411,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2371
2411
  }
2372
2412
 
2373
2413
  async function loadHexColorPlugin(engine) {
2374
- engine.checkVersion("4.5.0");
2414
+ engine.checkVersion("4.5.2");
2375
2415
  await engine.pluginManager.register(e => {
2376
2416
  e.pluginManager.addColorManager("hex", new HexColorManager());
2377
2417
  });
@@ -2424,7 +2464,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2424
2464
  }
2425
2465
 
2426
2466
  async function loadHslColorPlugin(engine) {
2427
- engine.checkVersion("4.5.0");
2467
+ engine.checkVersion("4.5.2");
2428
2468
  await engine.pluginManager.register(e => {
2429
2469
  e.pluginManager.addColorManager("hsl", new HslColorManager());
2430
2470
  });
@@ -2456,7 +2496,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2456
2496
  }
2457
2497
 
2458
2498
  async function loadMovePlugin(engine) {
2459
- engine.checkVersion("4.5.0");
2499
+ engine.checkVersion("4.5.2");
2460
2500
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
2461
2501
  addErrorMessages(ErrorMessages$1);
2462
2502
  }
@@ -2666,7 +2706,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2666
2706
  }
2667
2707
 
2668
2708
  async function loadOpacityUpdater(engine) {
2669
- engine.checkVersion("4.5.0");
2709
+ engine.checkVersion("4.5.2");
2670
2710
  await engine.pluginManager.register(e => {
2671
2711
  e.pluginManager.addParticleUpdater("opacity", container => {
2672
2712
  return Promise.resolve(new OpacityUpdater(container));
@@ -2995,7 +3035,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2995
3035
  }
2996
3036
 
2997
3037
  async function loadOutModesUpdater(engine) {
2998
- engine.checkVersion("4.5.0");
3038
+ engine.checkVersion("4.5.2");
2999
3039
  await engine.pluginManager.register(e => {
3000
3040
  e.pluginManager.addParticleUpdater("outModes", container => {
3001
3041
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3074,7 +3114,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3074
3114
  }
3075
3115
 
3076
3116
  async function loadPaintUpdater(engine) {
3077
- engine.checkVersion("4.5.0");
3117
+ engine.checkVersion("4.5.2");
3078
3118
  await engine.pluginManager.register(e => {
3079
3119
  e.pluginManager.addParticleUpdater("paint", container => {
3080
3120
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3129,7 +3169,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3129
3169
  }
3130
3170
 
3131
3171
  async function loadRgbColorPlugin(engine) {
3132
- engine.checkVersion("4.5.0");
3172
+ engine.checkVersion("4.5.2");
3133
3173
  await engine.pluginManager.register(e => {
3134
3174
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3135
3175
  });
@@ -3214,7 +3254,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3214
3254
  }
3215
3255
 
3216
3256
  async function loadSizeUpdater(engine) {
3217
- engine.checkVersion("4.5.0");
3257
+ engine.checkVersion("4.5.2");
3218
3258
  await engine.pluginManager.register(e => {
3219
3259
  e.pluginManager.addParticleUpdater("size", container => {
3220
3260
  return Promise.resolve(new SizeUpdater(container));
@@ -3223,7 +3263,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3223
3263
  }
3224
3264
 
3225
3265
  async function loadBasic(engine) {
3226
- engine.checkVersion("4.5.0");
3266
+ engine.checkVersion("4.5.2");
3227
3267
  await engine.pluginManager.register(async (e) => {
3228
3268
  await Promise.all([
3229
3269
  loadBlendPlugin(e),
@@ -3333,7 +3373,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3333
3373
  direction;
3334
3374
  domId;
3335
3375
  draggable = false;
3336
- draw = true;
3376
+ draw = false;
3337
3377
  fill = true;
3338
3378
  life = new EmitterLife();
3339
3379
  name;
@@ -3458,7 +3498,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3458
3498
  })(EmitterClickMode || (EmitterClickMode = {}));
3459
3499
 
3460
3500
  async function loadEmittersPluginSimple(engine) {
3461
- engine.checkVersion("4.5.0");
3501
+ engine.checkVersion("4.5.2");
3462
3502
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
3463
3503
  addErrorMessages(ErrorMessages);
3464
3504
  }
@@ -3700,7 +3740,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3700
3740
  });
3701
3741
  }
3702
3742
  drawParticles(delta) {
3703
- const { particles, actualOptions } = this.#container, clearedPlugin = this.clear();
3743
+ const { particles, actualOptions } = this.#container;
3744
+ this.clear();
3704
3745
  particles.update(delta);
3705
3746
  this.draw(ctx => {
3706
3747
  const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
@@ -3722,9 +3763,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3722
3763
  }
3723
3764
  }
3724
3765
  for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
3725
- if (plugin !== clearedPlugin) {
3726
- plugin.canvasPaint?.();
3727
- }
3766
+ plugin.canvasPaint?.();
3728
3767
  }
3729
3768
  for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
3730
3769
  plugin.drawSettingsSetup?.(ctx, delta);
@@ -3814,6 +3853,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3814
3853
  ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
3815
3854
  });
3816
3855
  }
3856
+ updateBackgroundElement() {
3857
+ this.#resolveBackgroundElement();
3858
+ }
3817
3859
  #applyPostDrawUpdaters(particle) {
3818
3860
  for (const updater of this.#postDrawUpdaters) {
3819
3861
  updater.afterDraw?.(particle);
@@ -4012,7 +4054,14 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4012
4054
  }
4013
4055
  if (typeof background.element === "string") {
4014
4056
  if (typeof document !== "undefined") {
4015
- const node = document.querySelector(background.element);
4057
+ let node;
4058
+ try {
4059
+ node = document.querySelector(background.element);
4060
+ }
4061
+ catch {
4062
+ this.#warnOnce("background-element-invalid-selector", `Background element selector "${background.element}" is invalid`);
4063
+ return;
4064
+ }
4016
4065
  if (node && this.#isSupportedElement(node)) {
4017
4066
  this.#backgroundElement = node;
4018
4067
  }
@@ -4458,6 +4507,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4458
4507
  this.#manageListeners(true);
4459
4508
  }
4460
4509
  removeListeners() {
4510
+ if (this.#resizeTimeout !== undefined) {
4511
+ clearTimeout(this.#resizeTimeout);
4512
+ this.#resizeTimeout = undefined;
4513
+ }
4461
4514
  this.#manageListeners(false);
4462
4515
  }
4463
4516
  #handleVisibilityChange() {
@@ -4832,10 +4885,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4832
4885
  runParticleCreatedPlugins(container, this);
4833
4886
  }
4834
4887
  isInsideCanvas(direction) {
4835
- return this.#getInsideCanvasResult({ direction }).inside;
4888
+ return this.#getInsideCanvasResult(direction).inside;
4836
4889
  }
4837
4890
  isInsideCanvasForOutMode(outMode, direction) {
4838
- return this.#getInsideCanvasResult({ direction, outMode }).inside;
4891
+ return this.#getInsideCanvasResult(direction, outMode).inside;
4839
4892
  }
4840
4893
  isShowingBack() {
4841
4894
  if (!this.roll) {
@@ -4952,7 +5005,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4952
5005
  });
4953
5006
  }
4954
5007
  #getDefaultInsideCanvasResult(direction, outMode) {
4955
- const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
5008
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce || outMode === OutMode.split;
4956
5009
  if (direction === OutModeDirection.bottom) {
4957
5010
  return {
4958
5011
  inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
@@ -4994,12 +5047,16 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4994
5047
  radius: this.getRadius(),
4995
5048
  };
4996
5049
  }
4997
- #getInsideCanvasResult(data) {
4998
- 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;
4999
- if (!shapeCheck && !effectCheck) {
5050
+ #getInsideCanvasResult(direction, outMode) {
5051
+ 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;
5052
+ if (!shapeDrawer?.isInsideCanvas && !effectDrawer?.isInsideCanvas) {
5000
5053
  return defaultResult;
5001
5054
  }
5002
- const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
5055
+ const callbackData = this.#getInsideCanvasCallbackData(direction, outMode), shapeResult = shapeDrawer?.isInsideCanvas
5056
+ ? this.#normalizeInsideCanvasResult(shapeDrawer.isInsideCanvas(callbackData), "shape")
5057
+ : undefined, effectResult = effectDrawer?.isInsideCanvas
5058
+ ? this.#normalizeInsideCanvasResult(effectDrawer.isInsideCanvas(callbackData), "effect")
5059
+ : undefined;
5003
5060
  if (shapeResult && effectResult) {
5004
5061
  const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
5005
5062
  return {
@@ -5065,8 +5122,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5065
5122
  }
5066
5123
 
5067
5124
  class SpatialHashGrid {
5068
- #cellSize;
5069
5125
  #cells = new Map();
5126
+ #cellSize;
5070
5127
  #circlePool = [];
5071
5128
  #circlePoolIdx;
5072
5129
  #pendingCellSize;
@@ -5112,14 +5169,22 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5112
5169
  return out;
5113
5170
  }
5114
5171
  queryCircle(position, radius, check, out = []) {
5115
- const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5116
- this.#releaseShapes();
5117
- return result;
5172
+ const circle = this.#acquireCircle(position.x, position.y, radius);
5173
+ try {
5174
+ return this.query(circle, check, out);
5175
+ }
5176
+ finally {
5177
+ this.#circlePoolIdx--;
5178
+ }
5118
5179
  }
5119
5180
  queryRectangle(position, size, check, out = []) {
5120
- const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5121
- this.#releaseShapes();
5122
- return result;
5181
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height);
5182
+ try {
5183
+ return this.query(rect, check, out);
5184
+ }
5185
+ finally {
5186
+ this.#rectanglePoolIdx--;
5187
+ }
5123
5188
  }
5124
5189
  #acquireCircle(x, y, r) {
5125
5190
  const idx = this.#circlePoolIdx++;
@@ -5178,10 +5243,6 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5178
5243
  }
5179
5244
  }
5180
5245
  }
5181
- #releaseShapes() {
5182
- this.#circlePoolIdx = 0;
5183
- this.#rectanglePoolIdx = 0;
5184
- }
5185
5246
  }
5186
5247
 
5187
5248
  class ParticlesManager {
@@ -5720,8 +5781,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5720
5781
  particleCreatedPlugins;
5721
5782
  particleDestroyedPlugins;
5722
5783
  particlePositionPlugins;
5723
- particleUpdaters;
5724
5784
  particles;
5785
+ particleUpdaters;
5725
5786
  peakNits;
5726
5787
  plugins;
5727
5788
  retina;
@@ -5729,6 +5790,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5729
5790
  started;
5730
5791
  zLayers;
5731
5792
  #delay;
5793
+ #delayResolve;
5732
5794
  #delayTimeout;
5733
5795
  #delta = { value: 0, factor: 0 };
5734
5796
  #dispatchCallback;
@@ -5967,7 +6029,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5967
6029
  await this.init();
5968
6030
  this.started = true;
5969
6031
  await new Promise(resolve => {
6032
+ this.#delayResolve = resolve;
5970
6033
  const start = async () => {
6034
+ this.#delayTimeout = undefined;
6035
+ this.#delayResolve = undefined;
5971
6036
  this.#eventListeners.addListeners();
5972
6037
  for (const plugin of this.plugins) {
5973
6038
  await plugin.start?.();
@@ -5983,9 +6048,11 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5983
6048
  if (!guardCheck(this) || !this.started) {
5984
6049
  return;
5985
6050
  }
5986
- if (this.#delayTimeout) {
6051
+ if (this.#delayTimeout !== undefined) {
5987
6052
  clearTimeout(this.#delayTimeout);
5988
6053
  this.#delayTimeout = undefined;
6054
+ this.#delayResolve?.();
6055
+ this.#delayResolve = undefined;
5989
6056
  }
5990
6057
  this.#firstStart = true;
5991
6058
  this.started = false;
@@ -6009,6 +6076,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6009
6076
  refresh = plugin.updateActualOptions() || refresh;
6010
6077
  }
6011
6078
  }
6079
+ this.canvas.render.updateBackgroundElement();
6012
6080
  return refresh;
6013
6081
  }
6014
6082
  #initPlugins(allContainerPlugins) {
@@ -6565,6 +6633,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6565
6633
  if (this.options.spawn.stroke?.color) {
6566
6634
  this.spawnStrokeColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.stroke.color);
6567
6635
  }
6636
+ const spawnFill = this.options.spawn.fill, spawnStroke = this.options.spawn.stroke;
6637
+ this.spawnFillOpacity = spawnFill?.opacity === undefined ? defaultOpacity$1 : getRangeValue(spawnFill.opacity);
6638
+ this.spawnStrokeOpacity = spawnStroke?.opacity === undefined ? defaultOpacity$1 : getRangeValue(spawnStroke.opacity);
6639
+ this.spawnStrokeWidth = spawnStroke?.width === undefined ? defaultStrokeWidth : getRangeValue(spawnStroke.width);
6568
6640
  this.#paused = !this.options.autoPlay;
6569
6641
  this.#particlesOptions = particlesOptions;
6570
6642
  this.#size = this.#calcSize();
@@ -6712,8 +6784,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6712
6784
  this.#lifeCount--;
6713
6785
  }
6714
6786
  if (this.#lifeCount > minLifeCount || this.#immortal) {
6715
- this.position = this.#calcPosition();
6716
- this.#shape?.resize(this.position, this.size);
6787
+ if (!this.#positionOverride) {
6788
+ this.position = this.#calcPosition();
6789
+ this.#shape?.resize(this.position, this.size);
6790
+ }
6717
6791
  this.#spawnDelay = container.retina.reduceFactor
6718
6792
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
6719
6793
  container.retina.reduceFactor