@tsparticles/preset-fire 4.0.4 → 4.1.0

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.0.4 */
2
+ /* Preset v4.1.0 */
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) :
@@ -51,13 +51,13 @@
51
51
  return Math.atan2(this.y, this.x);
52
52
  }
53
53
  set angle(angle) {
54
- this._updateFromAngle(angle, this.length);
54
+ this.#updateFromAngle(angle, this.length);
55
55
  }
56
56
  get length() {
57
57
  return Math.sqrt(this.getLengthSq());
58
58
  }
59
59
  set length(length) {
60
- this._updateFromAngle(this.angle, length);
60
+ this.#updateFromAngle(this.angle, length);
61
61
  }
62
62
  static clone(source) {
63
63
  return Vector3d.create(source.x, source.y, getZ(source));
@@ -120,7 +120,7 @@
120
120
  this.y -= v.y;
121
121
  this.z -= getZ(v);
122
122
  }
123
- _updateFromAngle(angle, length) {
123
+ #updateFromAngle(angle, length) {
124
124
  this.x = Math.cos(angle) * length;
125
125
  this.y = Math.sin(angle) * length;
126
126
  }
@@ -711,38 +711,38 @@
711
711
  }
712
712
 
713
713
  class EventDispatcher {
714
- _listeners;
714
+ #listeners;
715
715
  constructor() {
716
- this._listeners = new Map();
716
+ this.#listeners = new Map();
717
717
  }
718
718
  addEventListener(type, listener) {
719
719
  this.removeEventListener(type, listener);
720
- let arr = this._listeners.get(type);
720
+ let arr = this.#listeners.get(type);
721
721
  if (!arr) {
722
722
  arr = [];
723
- this._listeners.set(type, arr);
723
+ this.#listeners.set(type, arr);
724
724
  }
725
725
  arr.push(listener);
726
726
  }
727
727
  dispatchEvent(type, args) {
728
- const listeners = this._listeners.get(type);
728
+ const listeners = this.#listeners.get(type);
729
729
  listeners?.forEach(handler => {
730
730
  handler(args);
731
731
  });
732
732
  }
733
733
  hasEventListener(type) {
734
- return !!this._listeners.get(type);
734
+ return !!this.#listeners.get(type);
735
735
  }
736
736
  removeAllEventListeners(type) {
737
737
  if (!type) {
738
- this._listeners = new Map();
738
+ this.#listeners = new Map();
739
739
  }
740
740
  else {
741
- this._listeners.delete(type);
741
+ this.#listeners.delete(type);
742
742
  }
743
743
  }
744
744
  removeEventListener(type, listener) {
745
- const arr = this._listeners.get(type);
745
+ const arr = this.#listeners.get(type);
746
746
  if (!arr) {
747
747
  return;
748
748
  }
@@ -751,7 +751,7 @@
751
751
  return;
752
752
  }
753
753
  if (length === deleteCount) {
754
- this._listeners.delete(type);
754
+ this.#listeners.delete(type);
755
755
  }
756
756
  else {
757
757
  arr.splice(idx, deleteCount);
@@ -789,19 +789,19 @@
789
789
  presets = new Map();
790
790
  shapeDrawers = new Map();
791
791
  updaters = new Map();
792
- _allLoadersSet = new Set();
793
- _configs = new Map();
794
- _engine;
795
- _executedSet = new Set();
796
- _initialized = false;
797
- _isRunningLoaders = false;
798
- _loadPromises = new Set();
792
+ #allLoadersSet = new Set();
793
+ #configs = new Map();
794
+ #engine;
795
+ #executedSet = new Set();
796
+ #initialized = false;
797
+ #isRunningLoaders = false;
798
+ #loadPromises = new Set();
799
799
  constructor(engine) {
800
- this._engine = engine;
800
+ this.#engine = engine;
801
801
  }
802
802
  get configs() {
803
803
  const res = {};
804
- for (const [name, config] of this._configs) {
804
+ for (const [name, config] of this.#configs) {
805
805
  res[name] = config;
806
806
  }
807
807
  return res;
@@ -811,8 +811,8 @@
811
811
  }
812
812
  addConfig(config) {
813
813
  const key = config.key ?? config.name ?? "default";
814
- this._configs.set(key, config);
815
- this._engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
814
+ this.#configs.set(key, config);
815
+ this.#engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
816
816
  }
817
817
  addEasing(name, easing) {
818
818
  if (this.easingFunctions.get(name)) {
@@ -873,21 +873,21 @@
873
873
  return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
874
874
  }
875
875
  async init() {
876
- if (this._initialized || this._isRunningLoaders) {
876
+ if (this.#initialized || this.#isRunningLoaders) {
877
877
  return;
878
878
  }
879
- this._isRunningLoaders = true;
880
- this._executedSet = new Set();
881
- this._allLoadersSet = new Set(this._loadPromises);
879
+ this.#isRunningLoaders = true;
880
+ this.#executedSet = new Set();
881
+ this.#allLoadersSet = new Set(this.#loadPromises);
882
882
  try {
883
- for (const loader of this._allLoadersSet) {
884
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
883
+ for (const loader of this.#allLoadersSet) {
884
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
885
885
  }
886
886
  }
887
887
  finally {
888
- this._loadPromises.clear();
889
- this._isRunningLoaders = false;
890
- this._initialized = true;
888
+ this.#loadPromises.clear();
889
+ this.#isRunningLoaders = false;
890
+ this.#initialized = true;
891
891
  }
892
892
  }
893
893
  loadParticlesOptions(container, options, ...sourceOptions) {
@@ -898,24 +898,24 @@
898
898
  updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
899
899
  }
900
900
  async register(...loaders) {
901
- if (this._initialized) {
901
+ if (this.#initialized) {
902
902
  throw new Error("Register plugins can only be done before calling tsParticles.load()");
903
903
  }
904
904
  for (const loader of loaders) {
905
- if (this._isRunningLoaders) {
906
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
905
+ if (this.#isRunningLoaders) {
906
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
907
907
  }
908
908
  else {
909
- this._loadPromises.add(loader);
909
+ this.#loadPromises.add(loader);
910
910
  }
911
911
  }
912
912
  }
913
- async _runLoader(loader, executed, allLoaders) {
913
+ async #runLoader(loader, executed, allLoaders) {
914
914
  if (executed.has(loader))
915
915
  return;
916
916
  executed.add(loader);
917
917
  allLoaders.add(loader);
918
- await loader(this._engine);
918
+ await loader(this.#engine);
919
919
  }
920
920
  }
921
921
 
@@ -995,17 +995,17 @@
995
995
  };
996
996
  class Engine {
997
997
  pluginManager = new PluginManager(this);
998
- _domArray = [];
999
- _eventDispatcher = new EventDispatcher();
1000
- _initialized = false;
998
+ #domArray = [];
999
+ #eventDispatcher = new EventDispatcher();
1000
+ #initialized = false;
1001
1001
  get items() {
1002
- return this._domArray;
1002
+ return this.#domArray;
1003
1003
  }
1004
1004
  get version() {
1005
- return "4.0.4";
1005
+ return "4.1.0";
1006
1006
  }
1007
1007
  addEventListener(type, listener) {
1008
- this._eventDispatcher.addEventListener(type, listener);
1008
+ this.#eventDispatcher.addEventListener(type, listener);
1009
1009
  }
1010
1010
  checkVersion(pluginVersion) {
1011
1011
  if (this.version === pluginVersion) {
@@ -1014,17 +1014,17 @@
1014
1014
  throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
1015
1015
  }
1016
1016
  dispatchEvent(type, args) {
1017
- this._eventDispatcher.dispatchEvent(type, args);
1017
+ this.#eventDispatcher.dispatchEvent(type, args);
1018
1018
  }
1019
1019
  async init() {
1020
- if (this._initialized) {
1020
+ if (this.#initialized) {
1021
1021
  return;
1022
1022
  }
1023
1023
  await this.pluginManager.init();
1024
- this._initialized = true;
1024
+ this.#initialized = true;
1025
1025
  }
1026
1026
  item(index) {
1027
- const { items } = this, item = items[index];
1027
+ const items = this.items, item = items[index];
1028
1028
  if (item?.destroyed) {
1029
1029
  items.splice(index, removeDeleteCount);
1030
1030
  return;
@@ -1078,7 +1078,7 @@
1078
1078
  await Promise.all(this.items.map(t => t.refresh()));
1079
1079
  }
1080
1080
  removeEventListener(type, listener) {
1081
- this._eventDispatcher.removeEventListener(type, listener);
1081
+ this.#eventDispatcher.removeEventListener(type, listener);
1082
1082
  }
1083
1083
  }
1084
1084
 
@@ -1849,43 +1849,6 @@
1849
1849
  }
1850
1850
  }
1851
1851
 
1852
- class OpacityAnimation extends RangedAnimationOptions {
1853
- destroy;
1854
- constructor() {
1855
- super();
1856
- this.destroy = DestroyType.none;
1857
- this.speed = 2;
1858
- }
1859
- load(data) {
1860
- super.load(data);
1861
- if (isNull(data)) {
1862
- return;
1863
- }
1864
- if (data.destroy !== undefined) {
1865
- this.destroy = data.destroy;
1866
- }
1867
- }
1868
- }
1869
-
1870
- class Opacity extends RangedAnimationValueWithRandom {
1871
- animation;
1872
- constructor() {
1873
- super();
1874
- this.animation = new OpacityAnimation();
1875
- this.value = 1;
1876
- }
1877
- load(data) {
1878
- if (isNull(data)) {
1879
- return;
1880
- }
1881
- super.load(data);
1882
- const animation = data.animation;
1883
- if (animation !== undefined) {
1884
- this.animation.load(animation);
1885
- }
1886
- }
1887
- }
1888
-
1889
1852
  class Stroke {
1890
1853
  color;
1891
1854
  opacity;
@@ -2053,43 +2016,6 @@
2053
2016
  }
2054
2017
  }
2055
2018
 
2056
- class SizeAnimation extends RangedAnimationOptions {
2057
- destroy;
2058
- constructor() {
2059
- super();
2060
- this.destroy = DestroyType.none;
2061
- this.speed = 5;
2062
- }
2063
- load(data) {
2064
- super.load(data);
2065
- if (isNull(data)) {
2066
- return;
2067
- }
2068
- if (data.destroy !== undefined) {
2069
- this.destroy = data.destroy;
2070
- }
2071
- }
2072
- }
2073
-
2074
- class Size extends RangedAnimationValueWithRandom {
2075
- animation;
2076
- constructor() {
2077
- super();
2078
- this.animation = new SizeAnimation();
2079
- this.value = 3;
2080
- }
2081
- load(data) {
2082
- super.load(data);
2083
- if (isNull(data)) {
2084
- return;
2085
- }
2086
- const animation = data.animation;
2087
- if (animation !== undefined) {
2088
- this.animation.load(animation);
2089
- }
2090
- }
2091
- }
2092
-
2093
2019
  class ZIndex extends ValueWithRandom {
2094
2020
  opacityRate;
2095
2021
  sizeRate;
@@ -2123,24 +2049,21 @@
2123
2049
  groups;
2124
2050
  move;
2125
2051
  number;
2126
- opacity;
2127
2052
  paint;
2128
2053
  palette;
2129
2054
  reduceDuplicates;
2130
2055
  shape;
2131
- size;
2132
2056
  zIndex;
2133
- _container;
2134
- _pluginManager;
2057
+ #container;
2058
+ #pluginManager;
2135
2059
  constructor(pluginManager, container) {
2136
- this._pluginManager = pluginManager;
2137
- this._container = container;
2060
+ this.#pluginManager = pluginManager;
2061
+ this.#container = container;
2138
2062
  this.bounce = new ParticlesBounce();
2139
2063
  this.effect = new Effect();
2140
2064
  this.groups = {};
2141
2065
  this.move = new Move();
2142
2066
  this.number = new ParticlesNumber();
2143
- this.opacity = new Opacity();
2144
2067
  this.paint = new Paint();
2145
2068
  this.paint.color = new AnimatableColor();
2146
2069
  this.paint.color.value = "#fff";
@@ -2148,7 +2071,6 @@
2148
2071
  this.paint.fill.enable = true;
2149
2072
  this.reduceDuplicates = false;
2150
2073
  this.shape = new Shape();
2151
- this.size = new Size();
2152
2074
  this.zIndex = new ZIndex();
2153
2075
  }
2154
2076
  load(data) {
@@ -2157,7 +2079,7 @@
2157
2079
  }
2158
2080
  if (data.palette) {
2159
2081
  this.palette = data.palette;
2160
- this._importPalette(this.palette);
2082
+ this.#importPalette(this.palette);
2161
2083
  }
2162
2084
  if (data.groups !== undefined) {
2163
2085
  for (const group of Object.keys(data.groups)) {
@@ -2177,7 +2099,6 @@
2177
2099
  this.effect.load(data.effect);
2178
2100
  this.move.load(data.move);
2179
2101
  this.number.load(data.number);
2180
- this.opacity.load(data.opacity);
2181
2102
  const paintToLoad = data.paint;
2182
2103
  if (paintToLoad) {
2183
2104
  if (isArray(paintToLoad)) {
@@ -2196,15 +2117,14 @@
2196
2117
  }
2197
2118
  }
2198
2119
  this.shape.load(data.shape);
2199
- this.size.load(data.size);
2200
2120
  this.zIndex.load(data.zIndex);
2201
- if (this._container) {
2202
- for (const plugin of this._pluginManager.plugins) {
2121
+ if (this.#container) {
2122
+ for (const plugin of this.#pluginManager.plugins) {
2203
2123
  if (plugin.loadParticlesOptions) {
2204
- plugin.loadParticlesOptions(this._container, this, data);
2124
+ plugin.loadParticlesOptions(this.#container, this, data);
2205
2125
  }
2206
2126
  }
2207
- const updaters = this._pluginManager.updaters.get(this._container);
2127
+ const updaters = this.#pluginManager.updaters.get(this.#container);
2208
2128
  if (updaters) {
2209
2129
  for (const updater of updaters) {
2210
2130
  if (updater.loadOptions) {
@@ -2214,8 +2134,8 @@
2214
2134
  }
2215
2135
  }
2216
2136
  }
2217
- _importPalette = (palette) => {
2218
- const paletteData = this._pluginManager.getPalette(palette);
2137
+ #importPalette = (palette) => {
2138
+ const paletteData = this.#pluginManager.getPalette(palette);
2219
2139
  if (!paletteData) {
2220
2140
  return;
2221
2141
  }
@@ -2294,11 +2214,11 @@
2294
2214
  smooth;
2295
2215
  style;
2296
2216
  zLayers;
2297
- _container;
2298
- _pluginManager;
2217
+ #container;
2218
+ #pluginManager;
2299
2219
  constructor(pluginManager, container) {
2300
- this._pluginManager = pluginManager;
2301
- this._container = container;
2220
+ this.#pluginManager = pluginManager;
2221
+ this.#container = container;
2302
2222
  this.autoPlay = true;
2303
2223
  this.background = new Background();
2304
2224
  this.clear = true;
@@ -2309,7 +2229,7 @@
2309
2229
  this.duration = 0;
2310
2230
  this.fpsLimit = 120;
2311
2231
  this.hdr = true;
2312
- this.particles = loadParticlesOptions(this._pluginManager, this._container);
2232
+ this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2313
2233
  this.pauseOnBlur = true;
2314
2234
  this.pauseOnOutsideViewport = true;
2315
2235
  this.resize = new ResizeEvent();
@@ -2324,12 +2244,12 @@
2324
2244
  if (data.preset !== undefined) {
2325
2245
  this.preset = data.preset;
2326
2246
  executeOnSingleOrMultiple(this.preset, preset => {
2327
- this._importPreset(preset);
2247
+ this.#importPreset(preset);
2328
2248
  });
2329
2249
  }
2330
2250
  if (data.palette !== undefined) {
2331
2251
  this.palette = data.palette;
2332
- this._importPalette(this.palette);
2252
+ this.#importPalette(this.palette);
2333
2253
  }
2334
2254
  if (data.autoPlay !== undefined) {
2335
2255
  this.autoPlay = data.autoPlay;
@@ -2383,12 +2303,12 @@
2383
2303
  if (data.smooth !== undefined) {
2384
2304
  this.smooth = data.smooth;
2385
2305
  }
2386
- this._pluginManager.plugins.forEach(plugin => {
2387
- plugin.loadOptions(this._container, this, data);
2306
+ this.#pluginManager.plugins.forEach(plugin => {
2307
+ plugin.loadOptions(this.#container, this, data);
2388
2308
  });
2389
2309
  }
2390
- _importPalette = palette => {
2391
- const paletteData = this._pluginManager.getPalette(palette);
2310
+ #importPalette = palette => {
2311
+ const paletteData = this.#pluginManager.getPalette(palette);
2392
2312
  if (!paletteData) {
2393
2313
  return;
2394
2314
  }
@@ -2405,8 +2325,8 @@
2405
2325
  },
2406
2326
  });
2407
2327
  };
2408
- _importPreset = preset => {
2409
- this.load(this._pluginManager.getPreset(preset));
2328
+ #importPreset = preset => {
2329
+ this.load(this.#pluginManager.getPreset(preset));
2410
2330
  };
2411
2331
  }
2412
2332
 
@@ -2875,7 +2795,7 @@
2875
2795
  }
2876
2796
 
2877
2797
  async function loadBlendPlugin(engine) {
2878
- engine.checkVersion("4.0.4");
2798
+ engine.checkVersion("4.1.0");
2879
2799
  await engine.pluginManager.register(e => {
2880
2800
  e.pluginManager.addPlugin(new BlendPlugin());
2881
2801
  });
@@ -2912,7 +2832,7 @@
2912
2832
  }
2913
2833
 
2914
2834
  async function loadCircleShape(engine) {
2915
- engine.checkVersion("4.0.4");
2835
+ engine.checkVersion("4.1.0");
2916
2836
  await engine.pluginManager.register(e => {
2917
2837
  e.pluginManager.addShape(["circle"], () => {
2918
2838
  return Promise.resolve(new CircleDrawer());
@@ -2933,15 +2853,15 @@
2933
2853
  return input.startsWith("#");
2934
2854
  }
2935
2855
  handleColor(color) {
2936
- return this._parseString(color.value);
2856
+ return this.#parseString(color.value);
2937
2857
  }
2938
2858
  handleRangeColor(color) {
2939
- return this._parseString(color.value);
2859
+ return this.#parseString(color.value);
2940
2860
  }
2941
2861
  parseString(input) {
2942
- return this._parseString(input);
2862
+ return this.#parseString(input);
2943
2863
  }
2944
- _parseString(hexColor) {
2864
+ #parseString(hexColor) {
2945
2865
  if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
2946
2866
  return;
2947
2867
  }
@@ -2960,7 +2880,7 @@
2960
2880
  }
2961
2881
 
2962
2882
  async function loadHexColorPlugin(engine) {
2963
- engine.checkVersion("4.0.4");
2883
+ engine.checkVersion("4.1.0");
2964
2884
  await engine.pluginManager.register(e => {
2965
2885
  e.pluginManager.addColorManager("hex", new HexColorManager());
2966
2886
  });
@@ -3013,7 +2933,7 @@
3013
2933
  }
3014
2934
 
3015
2935
  async function loadHslColorPlugin(engine) {
3016
- engine.checkVersion("4.0.4");
2936
+ engine.checkVersion("4.1.0");
3017
2937
  await engine.pluginManager.register(e => {
3018
2938
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3019
2939
  });
@@ -3021,13 +2941,13 @@
3021
2941
 
3022
2942
  class MovePlugin {
3023
2943
  id = "move";
3024
- _pluginManager;
2944
+ #pluginManager;
3025
2945
  constructor(pluginManager) {
3026
- this._pluginManager = pluginManager;
2946
+ this.#pluginManager = pluginManager;
3027
2947
  }
3028
2948
  async getPlugin(container) {
3029
2949
  const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
3030
- return new MovePluginInstance(this._pluginManager, container);
2950
+ return new MovePluginInstance(this.#pluginManager, container);
3031
2951
  }
3032
2952
  loadOptions() {
3033
2953
  }
@@ -3037,7 +2957,7 @@
3037
2957
  }
3038
2958
 
3039
2959
  async function loadMovePlugin(engine) {
3040
- engine.checkVersion("4.0.4");
2960
+ engine.checkVersion("4.1.0");
3041
2961
  await engine.pluginManager.register(e => {
3042
2962
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3043
2963
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3055,18 +2975,58 @@
3055
2975
  });
3056
2976
  }
3057
2977
 
2978
+ class OpacityAnimation extends RangedAnimationOptions {
2979
+ destroy;
2980
+ constructor() {
2981
+ super();
2982
+ this.destroy = DestroyType.none;
2983
+ this.speed = 2;
2984
+ }
2985
+ load(data) {
2986
+ super.load(data);
2987
+ if (isNull(data)) {
2988
+ return;
2989
+ }
2990
+ if (data.destroy !== undefined) {
2991
+ this.destroy = data.destroy;
2992
+ }
2993
+ }
2994
+ }
2995
+
2996
+ class Opacity extends RangedAnimationValueWithRandom {
2997
+ animation;
2998
+ constructor() {
2999
+ super();
3000
+ this.animation = new OpacityAnimation();
3001
+ this.value = 1;
3002
+ }
3003
+ load(data) {
3004
+ if (isNull(data)) {
3005
+ return;
3006
+ }
3007
+ super.load(data);
3008
+ const animation = data.animation;
3009
+ if (animation !== undefined) {
3010
+ this.animation.load(animation);
3011
+ }
3012
+ }
3013
+ }
3014
+
3058
3015
  class OpacityUpdater {
3059
- container;
3016
+ #container;
3060
3017
  constructor(container) {
3061
- this.container = container;
3018
+ this.#container = container;
3062
3019
  }
3063
3020
  init(particle) {
3064
3021
  const opacityOptions = particle.options.opacity, pxRatio = 1;
3022
+ if (!opacityOptions) {
3023
+ return;
3024
+ }
3065
3025
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
3066
3026
  const opacityAnimation = opacityOptions.animation;
3067
3027
  if (opacityAnimation.enable) {
3068
3028
  particle.opacity.velocity =
3069
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
3029
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
3070
3030
  if (!opacityAnimation.sync) {
3071
3031
  particle.opacity.velocity *= getRandom();
3072
3032
  }
@@ -3082,6 +3042,12 @@
3082
3042
  ((particle.opacity.maxLoops ?? none) > none &&
3083
3043
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3084
3044
  }
3045
+ loadOptions(options, ...sources) {
3046
+ options.opacity ??= new Opacity();
3047
+ for (const source of sources) {
3048
+ options.opacity.load(source?.opacity);
3049
+ }
3050
+ }
3085
3051
  reset(particle) {
3086
3052
  if (!particle.opacity) {
3087
3053
  return;
@@ -3090,7 +3056,7 @@
3090
3056
  particle.opacity.loops = 0;
3091
3057
  }
3092
3058
  update(particle, delta) {
3093
- if (!this.isEnabled(particle) || !particle.opacity) {
3059
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
3094
3060
  return;
3095
3061
  }
3096
3062
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -3098,7 +3064,7 @@
3098
3064
  }
3099
3065
 
3100
3066
  async function loadOpacityUpdater(engine) {
3101
- engine.checkVersion("4.0.4");
3067
+ engine.checkVersion("4.1.0");
3102
3068
  await engine.pluginManager.register(e => {
3103
3069
  e.pluginManager.addParticleUpdater("opacity", container => {
3104
3070
  return Promise.resolve(new OpacityUpdater(container));
@@ -3120,10 +3086,9 @@
3120
3086
  }
3121
3087
  const velocity = data.particle.velocity.x;
3122
3088
  let bounced = false;
3123
- if ((data.direction === OutModeDirection.right &&
3124
- data.bounds.right >= data.canvasSize.width &&
3125
- velocity > minVelocity$4) ||
3126
- (data.direction === OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity$4)) {
3089
+ if (data.outOfCanvas &&
3090
+ ((data.direction === OutModeDirection.right && velocity > minVelocity$4) ||
3091
+ (data.direction === OutModeDirection.left && velocity < minVelocity$4))) {
3127
3092
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3128
3093
  data.particle.velocity.x *= -newVelocity;
3129
3094
  bounced = true;
@@ -3132,10 +3097,10 @@
3132
3097
  return;
3133
3098
  }
3134
3099
  const minPos = data.offset.x + data.size;
3135
- if (data.bounds.right >= data.canvasSize.width && data.direction === OutModeDirection.right) {
3100
+ if (data.outOfCanvas && data.direction === OutModeDirection.right) {
3136
3101
  data.particle.position.x = data.canvasSize.width - minPos;
3137
3102
  }
3138
- else if (data.bounds.left <= boundsMin && data.direction === OutModeDirection.left) {
3103
+ else if (data.outOfCanvas && data.direction === OutModeDirection.left) {
3139
3104
  data.particle.position.x = minPos;
3140
3105
  }
3141
3106
  if (data.outMode === OutMode.split) {
@@ -3155,10 +3120,9 @@
3155
3120
  }
3156
3121
  const velocity = data.particle.velocity.y;
3157
3122
  let bounced = false;
3158
- if ((data.direction === OutModeDirection.bottom &&
3159
- data.bounds.bottom >= data.canvasSize.height &&
3160
- velocity > minVelocity$4) ||
3161
- (data.direction === OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity$4)) {
3123
+ if (data.outOfCanvas &&
3124
+ ((data.direction === OutModeDirection.bottom && velocity > minVelocity$4) ||
3125
+ (data.direction === OutModeDirection.top && velocity < minVelocity$4))) {
3162
3126
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3163
3127
  data.particle.velocity.y *= -newVelocity;
3164
3128
  bounced = true;
@@ -3167,10 +3131,10 @@
3167
3131
  return;
3168
3132
  }
3169
3133
  const minPos = data.offset.y + data.size;
3170
- if (data.bounds.bottom >= data.canvasSize.height && data.direction === OutModeDirection.bottom) {
3134
+ if (data.outOfCanvas && data.direction === OutModeDirection.bottom) {
3171
3135
  data.particle.position.y = data.canvasSize.height - minPos;
3172
3136
  }
3173
- else if (data.bounds.top <= boundsMin && data.direction === OutModeDirection.top) {
3137
+ else if (data.outOfCanvas && data.direction === OutModeDirection.top) {
3174
3138
  data.particle.position.y = minPos;
3175
3139
  }
3176
3140
  if (data.outMode === OutMode.split) {
@@ -3179,24 +3143,24 @@
3179
3143
  }
3180
3144
 
3181
3145
  class BounceOutMode {
3182
- container;
3183
3146
  modes;
3184
- _particleBouncePlugins;
3147
+ #container;
3148
+ #particleBouncePlugins;
3185
3149
  constructor(container) {
3186
- this.container = container;
3150
+ this.#container = container;
3187
3151
  this.modes = [
3188
3152
  OutMode.bounce,
3189
3153
  OutMode.split,
3190
3154
  ];
3191
- this._particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3155
+ this.#particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3192
3156
  }
3193
3157
  update(particle, direction, delta, outMode) {
3194
3158
  if (!this.modes.includes(outMode)) {
3195
3159
  return;
3196
3160
  }
3197
- const container = this.container;
3161
+ const container = this.#container;
3198
3162
  let handled = false;
3199
- for (const plugin of this._particleBouncePlugins) {
3163
+ for (const plugin of this.#particleBouncePlugins) {
3200
3164
  handled = plugin.particleBounce?.(particle, delta, direction) ?? false;
3201
3165
  if (handled) {
3202
3166
  break;
@@ -3205,29 +3169,26 @@
3205
3169
  if (handled) {
3206
3170
  return;
3207
3171
  }
3208
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size;
3209
- bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
3210
- bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
3172
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, outOfCanvas = !particle.isInsideCanvasForOutMode(outMode, direction);
3173
+ bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3174
+ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3211
3175
  }
3212
3176
  }
3213
3177
 
3214
3178
  const minVelocity$3 = 0;
3215
3179
  class DestroyOutMode {
3216
- container;
3217
3180
  modes;
3218
- constructor(container) {
3219
- this.container = container;
3181
+ constructor(_container) {
3220
3182
  this.modes = [OutMode.destroy];
3221
3183
  }
3222
3184
  update(particle, direction, _delta, outMode) {
3223
3185
  if (!this.modes.includes(outMode)) {
3224
3186
  return;
3225
3187
  }
3226
- const container = this.container;
3227
3188
  switch (particle.outType) {
3228
3189
  case ParticleOutType.normal:
3229
3190
  case ParticleOutType.outside:
3230
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3191
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3231
3192
  return;
3232
3193
  }
3233
3194
  break;
@@ -3248,10 +3209,10 @@
3248
3209
 
3249
3210
  const minVelocity$2 = 0;
3250
3211
  class NoneOutMode {
3251
- container;
3252
3212
  modes;
3213
+ #container;
3253
3214
  constructor(container) {
3254
- this.container = container;
3215
+ this.#container = container;
3255
3216
  this.modes = [OutMode.none];
3256
3217
  }
3257
3218
  update(particle, direction, _delta, outMode) {
@@ -3264,7 +3225,7 @@
3264
3225
  (direction === OutModeDirection.top || direction === OutModeDirection.bottom))) {
3265
3226
  return;
3266
3227
  }
3267
- const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3228
+ const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3268
3229
  if (!gravityOptions.enable) {
3269
3230
  if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3270
3231
  (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
@@ -3290,17 +3251,17 @@
3290
3251
 
3291
3252
  const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
3292
3253
  class OutOutMode {
3293
- container;
3294
3254
  modes;
3255
+ #container;
3295
3256
  constructor(container) {
3296
- this.container = container;
3257
+ this.#container = container;
3297
3258
  this.modes = [OutMode.out];
3298
3259
  }
3299
3260
  update(particle, direction, _delta, outMode) {
3300
3261
  if (!this.modes.includes(outMode)) {
3301
3262
  return;
3302
3263
  }
3303
- const container = this.container;
3264
+ const container = this.#container;
3304
3265
  switch (particle.outType) {
3305
3266
  case ParticleOutType.inside: {
3306
3267
  const { x: vx, y: vy } = particle.velocity;
@@ -3330,7 +3291,7 @@
3330
3291
  break;
3331
3292
  }
3332
3293
  default: {
3333
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3294
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3334
3295
  return;
3335
3296
  }
3336
3297
  switch (particle.outType) {
@@ -3414,16 +3375,16 @@
3414
3375
  };
3415
3376
  class OutOfCanvasUpdater {
3416
3377
  updaters;
3417
- container;
3378
+ #container;
3418
3379
  constructor(container) {
3419
- this.container = container;
3380
+ this.#container = container;
3420
3381
  this.updaters = new Map();
3421
3382
  }
3422
3383
  init(particle) {
3423
- this._addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3424
- this._addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3425
- this._addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3426
- this._addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3384
+ this.#addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3385
+ this.#addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3386
+ this.#addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3387
+ this.#addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3427
3388
  }
3428
3389
  isEnabled(particle) {
3429
3390
  return !particle.destroyed && !particle.spawning;
@@ -3431,18 +3392,18 @@
3431
3392
  update(particle, delta) {
3432
3393
  const outModes = particle.options.move.outModes;
3433
3394
  particle.justWarped = false;
3434
- this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3435
- this._updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3436
- this._updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3437
- this._updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3395
+ this.#updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3396
+ this.#updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3397
+ this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3398
+ this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3438
3399
  }
3439
- _addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3400
+ #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3440
3401
  const outModes = particle.options.move.outModes;
3441
3402
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3442
- this.updaters.set(outMode, getUpdater(this.container));
3403
+ this.updaters.set(outMode, getUpdater(this.#container));
3443
3404
  }
3444
3405
  };
3445
- _updateOutMode = (particle, delta, outMode, direction) => {
3406
+ #updateOutMode = (particle, delta, outMode, direction) => {
3446
3407
  for (const updater of this.updaters.values()) {
3447
3408
  updater.update(particle, direction, delta, outMode);
3448
3409
  }
@@ -3450,7 +3411,7 @@
3450
3411
  }
3451
3412
 
3452
3413
  async function loadOutModesUpdater(engine) {
3453
- engine.checkVersion("4.0.4");
3414
+ engine.checkVersion("4.1.0");
3454
3415
  await engine.pluginManager.register(e => {
3455
3416
  e.pluginManager.addParticleUpdater("outModes", container => {
3456
3417
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3460,20 +3421,20 @@
3460
3421
 
3461
3422
  const defaultOpacity = 1;
3462
3423
  class PaintUpdater {
3463
- _container;
3464
- _pluginManager;
3424
+ #container;
3425
+ #pluginManager;
3465
3426
  constructor(pluginManager, container) {
3466
- this._container = container;
3467
- this._pluginManager = pluginManager;
3427
+ this.#container = container;
3428
+ this.#pluginManager = pluginManager;
3468
3429
  }
3469
3430
  init(particle) {
3470
- const container = this._container, options = particle.options, paint = itemFromSingleOrMultiple(options.paint, particle.id, options.reduceDuplicates), color = paint?.color, paintColor = color ?? undefined, fill = paint?.fill, stroke = paint?.stroke;
3431
+ const container = this.#container, options = particle.options, paint = itemFromSingleOrMultiple(options.paint, particle.id, options.reduceDuplicates), color = paint?.color, paintColor = color ?? undefined, fill = paint?.fill, stroke = paint?.stroke;
3471
3432
  if (fill) {
3472
3433
  const fillColor = AnimatableColor.create(paintColor === undefined ? undefined : AnimatableColor.create(undefined, paintColor), fill.color);
3473
3434
  particle.fillEnabled = fill.enable;
3474
3435
  particle.fillOpacity = getRangeValue(fill.opacity);
3475
3436
  particle.fillAnimation = fillColor.animation;
3476
- const fillHslColor = rangeColorToHsl(this._pluginManager, fillColor);
3437
+ const fillHslColor = rangeColorToHsl(this.#pluginManager, fillColor);
3477
3438
  if (fillHslColor) {
3478
3439
  particle.fillColor = getHslAnimationFromHsl(fillHslColor, particle.fillAnimation, container.retina.reduceFactor);
3479
3440
  }
@@ -3489,7 +3450,7 @@
3489
3450
  particle.strokeWidth = getRangeValue(stroke.width) * container.retina.pixelRatio;
3490
3451
  particle.strokeOpacity = getRangeValue(stroke.opacity ?? defaultOpacity);
3491
3452
  particle.strokeAnimation = strokeColor.animation;
3492
- const strokeHslColor = rangeColorToHsl(this._pluginManager, strokeColor) ?? particle.getFillColor();
3453
+ const strokeHslColor = rangeColorToHsl(this.#pluginManager, strokeColor) ?? particle.getFillColor();
3493
3454
  if (strokeHslColor) {
3494
3455
  particle.strokeColor = getHslAnimationFromHsl(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
3495
3456
  }
@@ -3521,7 +3482,7 @@
3521
3482
  }
3522
3483
 
3523
3484
  async function loadPaintUpdater(engine) {
3524
- engine.checkVersion("4.0.4");
3485
+ engine.checkVersion("4.1.0");
3525
3486
  await engine.pluginManager.register(e => {
3526
3487
  e.pluginManager.addParticleUpdater("paint", container => {
3527
3488
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3576,27 +3537,69 @@
3576
3537
  }
3577
3538
 
3578
3539
  async function loadRgbColorPlugin(engine) {
3579
- engine.checkVersion("4.0.4");
3540
+ engine.checkVersion("4.1.0");
3580
3541
  await engine.pluginManager.register(e => {
3581
3542
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3582
3543
  });
3583
3544
  }
3584
3545
 
3546
+ class SizeAnimation extends RangedAnimationOptions {
3547
+ destroy;
3548
+ constructor() {
3549
+ super();
3550
+ this.destroy = DestroyType.none;
3551
+ this.speed = 5;
3552
+ }
3553
+ load(data) {
3554
+ super.load(data);
3555
+ if (isNull(data)) {
3556
+ return;
3557
+ }
3558
+ if (data.destroy !== undefined) {
3559
+ this.destroy = data.destroy;
3560
+ }
3561
+ }
3562
+ }
3563
+
3564
+ class Size extends RangedAnimationValueWithRandom {
3565
+ animation;
3566
+ constructor() {
3567
+ super();
3568
+ this.animation = new SizeAnimation();
3569
+ this.value = 3;
3570
+ }
3571
+ load(data) {
3572
+ super.load(data);
3573
+ if (isNull(data)) {
3574
+ return;
3575
+ }
3576
+ const animation = data.animation;
3577
+ if (animation !== undefined) {
3578
+ this.animation.load(animation);
3579
+ }
3580
+ }
3581
+ }
3582
+
3585
3583
  const minLoops = 0;
3586
3584
  class SizeUpdater {
3587
- _container;
3585
+ #container;
3588
3586
  constructor(container) {
3589
- this._container = container;
3587
+ this.#container = container;
3590
3588
  }
3591
3589
  init(particle) {
3592
- const container = this._container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
3593
- if (sizeAnimation.enable) {
3594
- particle.size.velocity =
3595
- (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3596
- if (!sizeAnimation.sync) {
3597
- particle.size.velocity *= getRandom();
3598
- }
3590
+ const container = this.#container, sizeOptions = particle.options.size;
3591
+ if (!sizeOptions) {
3592
+ return;
3593
+ }
3594
+ const sizeAnimation = sizeOptions.animation;
3595
+ if (!sizeAnimation.enable) {
3596
+ return;
3599
3597
  }
3598
+ particle.size.velocity = (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3599
+ if (sizeAnimation.sync) {
3600
+ return;
3601
+ }
3602
+ particle.size.velocity *= getRandom();
3600
3603
  }
3601
3604
  isEnabled(particle) {
3602
3605
  return (!particle.destroyed &&
@@ -3606,12 +3609,26 @@
3606
3609
  ((particle.size.maxLoops ?? minLoops) > minLoops &&
3607
3610
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3608
3611
  }
3612
+ loadOptions(options, ...sources) {
3613
+ options.size ??= new Size();
3614
+ for (const source of sources) {
3615
+ options.size.load(source?.size);
3616
+ }
3617
+ }
3618
+ preInit(particle) {
3619
+ const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
3620
+ if (!sizeOptions) {
3621
+ return;
3622
+ }
3623
+ particle.size = initParticleNumericAnimationValue(sizeOptions, pxRatio);
3624
+ particle.retina.sizeAnimationSpeed = getRangeValue(sizeOptions.animation.speed) * pxRatio;
3625
+ }
3609
3626
  reset(particle) {
3610
3627
  particle.size.time = 0;
3611
3628
  particle.size.loops = 0;
3612
3629
  }
3613
3630
  update(particle, delta) {
3614
- if (!this.isEnabled(particle)) {
3631
+ if (!this.isEnabled(particle) || !particle.options.size) {
3615
3632
  return;
3616
3633
  }
3617
3634
  updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
@@ -3619,7 +3636,7 @@
3619
3636
  }
3620
3637
 
3621
3638
  async function loadSizeUpdater(engine) {
3622
- engine.checkVersion("4.0.4");
3639
+ engine.checkVersion("4.1.0");
3623
3640
  await engine.pluginManager.register(e => {
3624
3641
  e.pluginManager.addParticleUpdater("size", container => {
3625
3642
  return Promise.resolve(new SizeUpdater(container));
@@ -3628,7 +3645,7 @@
3628
3645
  }
3629
3646
 
3630
3647
  async function loadBasic(engine) {
3631
- engine.checkVersion("4.0.4");
3648
+ engine.checkVersion("4.1.0");
3632
3649
  await engine.pluginManager.register(async (e) => {
3633
3650
  await Promise.all([
3634
3651
  loadBlendPlugin(e),
@@ -3755,20 +3772,20 @@
3755
3772
  })(InteractivityDetect || (InteractivityDetect = {}));
3756
3773
 
3757
3774
  class Modes {
3758
- _container;
3759
- _pluginManager;
3775
+ #container;
3776
+ #pluginManager;
3760
3777
  constructor(pluginManager, container) {
3761
- this._pluginManager = pluginManager;
3762
- this._container = container;
3778
+ this.#pluginManager = pluginManager;
3779
+ this.#container = container;
3763
3780
  }
3764
3781
  load(data) {
3765
3782
  if (isNull(data)) {
3766
3783
  return;
3767
3784
  }
3768
- if (!this._container) {
3785
+ if (!this.#container) {
3769
3786
  return;
3770
3787
  }
3771
- const interactors = this._pluginManager.interactors?.get(this._container);
3788
+ const interactors = this.#pluginManager.interactors?.get(this.#container);
3772
3789
  if (!interactors) {
3773
3790
  return;
3774
3791
  }
@@ -3805,13 +3822,13 @@
3805
3822
 
3806
3823
  class InteractivityPlugin {
3807
3824
  id = "interactivity";
3808
- _pluginManager;
3825
+ #pluginManager;
3809
3826
  constructor(pluginManager) {
3810
- this._pluginManager = pluginManager;
3827
+ this.#pluginManager = pluginManager;
3811
3828
  }
3812
3829
  async getPlugin(container) {
3813
3830
  const { InteractivityPluginInstance } = await Promise.resolve().then(function () { return InteractivityPluginInstance$1; });
3814
- return new InteractivityPluginInstance(this._pluginManager, container);
3831
+ return new InteractivityPluginInstance(this.#pluginManager, container);
3815
3832
  }
3816
3833
  loadOptions(container, options, source) {
3817
3834
  if (!this.needsPlugin()) {
@@ -3819,10 +3836,10 @@
3819
3836
  }
3820
3837
  let interactivityOptions = options.interactivity;
3821
3838
  if (!interactivityOptions?.load) {
3822
- options.interactivity = interactivityOptions = new Interactivity(this._pluginManager, container);
3839
+ options.interactivity = interactivityOptions = new Interactivity(this.#pluginManager, container);
3823
3840
  }
3824
3841
  interactivityOptions.load(source?.interactivity);
3825
- const interactors = this._pluginManager.interactors?.get(container);
3842
+ const interactors = this.#pluginManager.interactors?.get(container);
3826
3843
  if (!interactors) {
3827
3844
  return;
3828
3845
  }
@@ -3836,7 +3853,7 @@
3836
3853
  if (source?.interactivity) {
3837
3854
  options.interactivity = deepExtend({}, source.interactivity);
3838
3855
  }
3839
- const interactors = this._pluginManager.interactors?.get(container);
3856
+ const interactors = this.#pluginManager.interactors?.get(container);
3840
3857
  if (!interactors) {
3841
3858
  return;
3842
3859
  }
@@ -3866,7 +3883,7 @@
3866
3883
  const clickEvent = "click", mouseDownEvent = "pointerdown", mouseUpEvent = "pointerup", mouseLeaveEvent = "pointerleave", mouseMoveEvent = "pointermove", touchStartEvent = "touchstart", touchEndEvent = "touchend", touchMoveEvent = "touchmove", touchCancelEvent = "touchcancel";
3867
3884
 
3868
3885
  async function loadInteractivityPlugin(engine) {
3869
- engine.checkVersion("4.0.4");
3886
+ engine.checkVersion("4.1.0");
3870
3887
  await engine.pluginManager.register(e => {
3871
3888
  const interactivityEngine = e, interactivityPluginManager = interactivityEngine.pluginManager;
3872
3889
  interactivityPluginManager.addPlugin(new InteractivityPlugin(interactivityPluginManager));
@@ -3975,7 +3992,7 @@
3975
3992
  }
3976
3993
 
3977
3994
  async function loadExternalPushInteraction(engine) {
3978
- engine.checkVersion("4.0.4");
3995
+ engine.checkVersion("4.1.0");
3979
3996
  await engine.pluginManager.register((e) => {
3980
3997
  ensureInteractivityPluginLoaded(e);
3981
3998
  e.pluginManager.addInteractor?.("externalPush", container => {
@@ -4053,58 +4070,58 @@
4053
4070
  }
4054
4071
  }
4055
4072
  class RenderManager {
4056
- _canvasClearPlugins;
4057
- _canvasManager;
4058
- _canvasPaintPlugins;
4059
- _clearDrawPlugins;
4060
- _colorPlugins;
4061
- _container;
4062
- _context;
4063
- _contextSettings;
4064
- _drawParticlePlugins;
4065
- _drawParticlesCleanupPlugins;
4066
- _drawParticlesSetupPlugins;
4067
- _drawPlugins;
4068
- _drawSettingsCleanupPlugins;
4069
- _drawSettingsSetupPlugins;
4070
- _pluginManager;
4071
- _postDrawUpdaters;
4072
- _preDrawUpdaters;
4073
- _reusableColorStyles = {};
4074
- _reusablePluginColors = [undefined, undefined];
4075
- _reusableTransform = {};
4073
+ #canvasClearPlugins;
4074
+ #canvasManager;
4075
+ #canvasPaintPlugins;
4076
+ #clearDrawPlugins;
4077
+ #colorPlugins;
4078
+ #container;
4079
+ #context;
4080
+ #contextSettings;
4081
+ #drawParticlePlugins;
4082
+ #drawParticlesCleanupPlugins;
4083
+ #drawParticlesSetupPlugins;
4084
+ #drawPlugins;
4085
+ #drawSettingsCleanupPlugins;
4086
+ #drawSettingsSetupPlugins;
4087
+ #pluginManager;
4088
+ #postDrawUpdaters;
4089
+ #preDrawUpdaters;
4090
+ #reusableColorStyles = {};
4091
+ #reusablePluginColors = [undefined, undefined];
4092
+ #reusableTransform = {};
4076
4093
  constructor(pluginManager, container, canvasManager) {
4077
- this._pluginManager = pluginManager;
4078
- this._container = container;
4079
- this._canvasManager = canvasManager;
4080
- this._context = null;
4081
- this._preDrawUpdaters = [];
4082
- this._postDrawUpdaters = [];
4083
- this._colorPlugins = [];
4084
- this._canvasClearPlugins = [];
4085
- this._canvasPaintPlugins = [];
4086
- this._clearDrawPlugins = [];
4087
- this._drawParticlePlugins = [];
4088
- this._drawParticlesCleanupPlugins = [];
4089
- this._drawParticlesSetupPlugins = [];
4090
- this._drawPlugins = [];
4091
- this._drawSettingsSetupPlugins = [];
4092
- this._drawSettingsCleanupPlugins = [];
4094
+ this.#pluginManager = pluginManager;
4095
+ this.#container = container;
4096
+ this.#canvasManager = canvasManager;
4097
+ this.#context = null;
4098
+ this.#preDrawUpdaters = [];
4099
+ this.#postDrawUpdaters = [];
4100
+ this.#colorPlugins = [];
4101
+ this.#canvasClearPlugins = [];
4102
+ this.#canvasPaintPlugins = [];
4103
+ this.#clearDrawPlugins = [];
4104
+ this.#drawParticlePlugins = [];
4105
+ this.#drawParticlesCleanupPlugins = [];
4106
+ this.#drawParticlesSetupPlugins = [];
4107
+ this.#drawPlugins = [];
4108
+ this.#drawSettingsSetupPlugins = [];
4109
+ this.#drawSettingsCleanupPlugins = [];
4093
4110
  }
4094
4111
  get settings() {
4095
- return this._contextSettings;
4112
+ return this.#contextSettings;
4096
4113
  }
4097
4114
  canvasClear() {
4098
- if (!this._container.actualOptions.clear) {
4115
+ if (!this.#container.actualOptions.clear) {
4099
4116
  return;
4100
4117
  }
4101
4118
  this.draw(ctx => {
4102
- clear(ctx, this._canvasManager.size);
4119
+ clear(ctx, this.#canvasManager.size);
4103
4120
  });
4104
4121
  }
4105
4122
  clear() {
4106
4123
  let pluginHandled = false;
4107
- for (const plugin of this._canvasClearPlugins) {
4124
+ for (const plugin of this.#canvasClearPlugins) {
4108
4125
  pluginHandled = plugin.canvasClear?.() ?? false;
4109
4126
  if (pluginHandled) {
4110
4127
  break;
@@ -4117,21 +4134,21 @@
4117
4134
  }
4118
4135
  destroy() {
4119
4136
  this.stop();
4120
- this._preDrawUpdaters = [];
4121
- this._postDrawUpdaters = [];
4122
- this._colorPlugins = [];
4123
- this._canvasClearPlugins = [];
4124
- this._canvasPaintPlugins = [];
4125
- this._clearDrawPlugins = [];
4126
- this._drawParticlePlugins = [];
4127
- this._drawParticlesCleanupPlugins = [];
4128
- this._drawParticlesSetupPlugins = [];
4129
- this._drawPlugins = [];
4130
- this._drawSettingsSetupPlugins = [];
4131
- this._drawSettingsCleanupPlugins = [];
4137
+ this.#preDrawUpdaters = [];
4138
+ this.#postDrawUpdaters = [];
4139
+ this.#colorPlugins = [];
4140
+ this.#canvasClearPlugins = [];
4141
+ this.#canvasPaintPlugins = [];
4142
+ this.#clearDrawPlugins = [];
4143
+ this.#drawParticlePlugins = [];
4144
+ this.#drawParticlesCleanupPlugins = [];
4145
+ this.#drawParticlesSetupPlugins = [];
4146
+ this.#drawPlugins = [];
4147
+ this.#drawSettingsSetupPlugins = [];
4148
+ this.#drawSettingsCleanupPlugins = [];
4132
4149
  }
4133
4150
  draw(cb) {
4134
- const ctx = this._context;
4151
+ const ctx = this.#context;
4135
4152
  if (!ctx) {
4136
4153
  return;
4137
4154
  }
@@ -4146,21 +4163,21 @@
4146
4163
  return;
4147
4164
  }
4148
4165
  const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
4149
- let [fColor, sColor] = this._getPluginParticleColors(particle);
4166
+ let [fColor, sColor] = this.#getPluginParticleColors(particle);
4150
4167
  fColor ??= pfColor;
4151
4168
  sColor ??= psColor;
4152
4169
  if (!fColor && !sColor) {
4153
4170
  return;
4154
4171
  }
4155
- const container = this._container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity) : undefined, stroke = sColor ? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity) : fill;
4172
+ const container = this.#container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this.#reusableTransform, colorStyles = this.#reusableColorStyles, fill = fColor ? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity) : undefined, stroke = sColor ? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity) : fill;
4156
4173
  transform.a = transform.b = transform.c = transform.d = undefined;
4157
4174
  colorStyles.fill = fill;
4158
4175
  colorStyles.stroke = stroke;
4159
4176
  this.draw((context) => {
4160
- for (const plugin of this._drawParticlesSetupPlugins) {
4177
+ for (const plugin of this.#drawParticlesSetupPlugins) {
4161
4178
  plugin.drawParticleSetup?.(context, particle, delta);
4162
4179
  }
4163
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4180
+ this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4164
4181
  drawParticle({
4165
4182
  container,
4166
4183
  context,
@@ -4171,35 +4188,35 @@
4171
4188
  opacity: opacity,
4172
4189
  transform,
4173
4190
  });
4174
- this._applyPostDrawUpdaters(particle);
4175
- for (const plugin of this._drawParticlesCleanupPlugins) {
4191
+ this.#applyPostDrawUpdaters(particle);
4192
+ for (const plugin of this.#drawParticlesCleanupPlugins) {
4176
4193
  plugin.drawParticleCleanup?.(context, particle, delta);
4177
4194
  }
4178
4195
  });
4179
4196
  }
4180
4197
  drawParticlePlugins(particle, delta) {
4181
4198
  this.draw(ctx => {
4182
- for (const plugin of this._drawParticlePlugins) {
4199
+ for (const plugin of this.#drawParticlePlugins) {
4183
4200
  drawParticlePlugin(ctx, plugin, particle, delta);
4184
4201
  }
4185
4202
  });
4186
4203
  }
4187
4204
  drawParticles(delta) {
4188
- const { particles } = this._container;
4205
+ const { particles } = this.#container;
4189
4206
  this.clear();
4190
4207
  particles.update(delta);
4191
4208
  this.draw(ctx => {
4192
- for (const plugin of this._drawSettingsSetupPlugins) {
4209
+ for (const plugin of this.#drawSettingsSetupPlugins) {
4193
4210
  plugin.drawSettingsSetup?.(ctx, delta);
4194
4211
  }
4195
- for (const plugin of this._drawPlugins) {
4212
+ for (const plugin of this.#drawPlugins) {
4196
4213
  plugin.draw?.(ctx, delta);
4197
4214
  }
4198
4215
  particles.drawParticles(delta);
4199
- for (const plugin of this._clearDrawPlugins) {
4216
+ for (const plugin of this.#clearDrawPlugins) {
4200
4217
  plugin.clearDraw?.(ctx, delta);
4201
4218
  }
4202
- for (const plugin of this._drawSettingsCleanupPlugins) {
4219
+ for (const plugin of this.#drawSettingsCleanupPlugins) {
4203
4220
  plugin.drawSettingsCleanup?.(ctx, delta);
4204
4221
  }
4205
4222
  });
@@ -4210,64 +4227,64 @@
4210
4227
  this.paint();
4211
4228
  }
4212
4229
  initPlugins() {
4213
- this._colorPlugins = [];
4214
- this._canvasClearPlugins = [];
4215
- this._canvasPaintPlugins = [];
4216
- this._clearDrawPlugins = [];
4217
- this._drawParticlePlugins = [];
4218
- this._drawParticlesSetupPlugins = [];
4219
- this._drawParticlesCleanupPlugins = [];
4220
- this._drawPlugins = [];
4221
- this._drawSettingsSetupPlugins = [];
4222
- this._drawSettingsCleanupPlugins = [];
4223
- for (const plugin of this._container.plugins) {
4230
+ this.#colorPlugins = [];
4231
+ this.#canvasClearPlugins = [];
4232
+ this.#canvasPaintPlugins = [];
4233
+ this.#clearDrawPlugins = [];
4234
+ this.#drawParticlePlugins = [];
4235
+ this.#drawParticlesSetupPlugins = [];
4236
+ this.#drawParticlesCleanupPlugins = [];
4237
+ this.#drawPlugins = [];
4238
+ this.#drawSettingsSetupPlugins = [];
4239
+ this.#drawSettingsCleanupPlugins = [];
4240
+ for (const plugin of this.#container.plugins) {
4224
4241
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
4225
- this._colorPlugins.push(plugin);
4242
+ this.#colorPlugins.push(plugin);
4226
4243
  }
4227
4244
  if (plugin.canvasClear) {
4228
- this._canvasClearPlugins.push(plugin);
4245
+ this.#canvasClearPlugins.push(plugin);
4229
4246
  }
4230
4247
  if (plugin.canvasPaint) {
4231
- this._canvasPaintPlugins.push(plugin);
4248
+ this.#canvasPaintPlugins.push(plugin);
4232
4249
  }
4233
4250
  if (plugin.drawParticle) {
4234
- this._drawParticlePlugins.push(plugin);
4251
+ this.#drawParticlePlugins.push(plugin);
4235
4252
  }
4236
4253
  if (plugin.drawParticleSetup) {
4237
- this._drawParticlesSetupPlugins.push(plugin);
4254
+ this.#drawParticlesSetupPlugins.push(plugin);
4238
4255
  }
4239
4256
  if (plugin.drawParticleCleanup) {
4240
- this._drawParticlesCleanupPlugins.push(plugin);
4257
+ this.#drawParticlesCleanupPlugins.push(plugin);
4241
4258
  }
4242
4259
  if (plugin.draw) {
4243
- this._drawPlugins.push(plugin);
4260
+ this.#drawPlugins.push(plugin);
4244
4261
  }
4245
4262
  if (plugin.drawSettingsSetup) {
4246
- this._drawSettingsSetupPlugins.push(plugin);
4263
+ this.#drawSettingsSetupPlugins.push(plugin);
4247
4264
  }
4248
4265
  if (plugin.drawSettingsCleanup) {
4249
- this._drawSettingsCleanupPlugins.push(plugin);
4266
+ this.#drawSettingsCleanupPlugins.push(plugin);
4250
4267
  }
4251
4268
  if (plugin.clearDraw) {
4252
- this._clearDrawPlugins.push(plugin);
4269
+ this.#clearDrawPlugins.push(plugin);
4253
4270
  }
4254
4271
  }
4255
4272
  }
4256
4273
  initUpdaters() {
4257
- this._preDrawUpdaters = [];
4258
- this._postDrawUpdaters = [];
4259
- for (const updater of this._container.particleUpdaters) {
4274
+ this.#preDrawUpdaters = [];
4275
+ this.#postDrawUpdaters = [];
4276
+ for (const updater of this.#container.particleUpdaters) {
4260
4277
  if (updater.afterDraw) {
4261
- this._postDrawUpdaters.push(updater);
4278
+ this.#postDrawUpdaters.push(updater);
4262
4279
  }
4263
4280
  if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
4264
- this._preDrawUpdaters.push(updater);
4281
+ this.#preDrawUpdaters.push(updater);
4265
4282
  }
4266
4283
  }
4267
4284
  }
4268
4285
  paint() {
4269
4286
  let handled = false;
4270
- for (const plugin of this._canvasPaintPlugins) {
4287
+ for (const plugin of this.#canvasPaintPlugins) {
4271
4288
  handled = plugin.canvasPaint?.() ?? false;
4272
4289
  if (handled) {
4273
4290
  break;
@@ -4280,35 +4297,35 @@
4280
4297
  }
4281
4298
  paintBase(baseColor) {
4282
4299
  this.draw(ctx => {
4283
- paintBase(ctx, this._canvasManager.size, baseColor);
4300
+ paintBase(ctx, this.#canvasManager.size, baseColor);
4284
4301
  });
4285
4302
  }
4286
4303
  paintImage(image, opacity) {
4287
4304
  this.draw(ctx => {
4288
- paintImage(ctx, this._canvasManager.size, image, opacity);
4305
+ paintImage(ctx, this.#canvasManager.size, image, opacity);
4289
4306
  });
4290
4307
  }
4291
4308
  setContext(context) {
4292
- this._context = context;
4293
- if (this._context) {
4294
- this._context.globalCompositeOperation = defaultCompositeValue;
4309
+ this.#context = context;
4310
+ if (this.#context) {
4311
+ this.#context.globalCompositeOperation = defaultCompositeValue;
4295
4312
  }
4296
4313
  }
4297
4314
  setContextSettings(settings) {
4298
- this._contextSettings = settings;
4315
+ this.#contextSettings = settings;
4299
4316
  }
4300
4317
  stop() {
4301
4318
  this.draw(ctx => {
4302
- clear(ctx, this._canvasManager.size);
4319
+ clear(ctx, this.#canvasManager.size);
4303
4320
  });
4304
4321
  }
4305
- _applyPostDrawUpdaters = particle => {
4306
- for (const updater of this._postDrawUpdaters) {
4322
+ #applyPostDrawUpdaters = particle => {
4323
+ for (const updater of this.#postDrawUpdaters) {
4307
4324
  updater.afterDraw?.(particle);
4308
4325
  }
4309
4326
  };
4310
- _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4311
- for (const updater of this._preDrawUpdaters) {
4327
+ #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4328
+ for (const updater of this.#preDrawUpdaters) {
4312
4329
  if (updater.getColorStyles) {
4313
4330
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
4314
4331
  if (fill) {
@@ -4327,22 +4344,22 @@
4327
4344
  updater.beforeDraw?.(particle);
4328
4345
  }
4329
4346
  };
4330
- _getPluginParticleColors = particle => {
4347
+ #getPluginParticleColors = particle => {
4331
4348
  let fColor, sColor;
4332
- for (const plugin of this._colorPlugins) {
4349
+ for (const plugin of this.#colorPlugins) {
4333
4350
  if (!fColor && plugin.particleFillColor) {
4334
- fColor = rangeColorToHsl(this._pluginManager, plugin.particleFillColor(particle));
4351
+ fColor = rangeColorToHsl(this.#pluginManager, plugin.particleFillColor(particle));
4335
4352
  }
4336
4353
  if (!sColor && plugin.particleStrokeColor) {
4337
- sColor = rangeColorToHsl(this._pluginManager, plugin.particleStrokeColor(particle));
4354
+ sColor = rangeColorToHsl(this.#pluginManager, plugin.particleStrokeColor(particle));
4338
4355
  }
4339
4356
  if (fColor && sColor) {
4340
4357
  break;
4341
4358
  }
4342
4359
  }
4343
- this._reusablePluginColors[fColorIndex] = fColor;
4344
- this._reusablePluginColors[sColorIndex] = sColor;
4345
- return this._reusablePluginColors;
4360
+ this.#reusablePluginColors[fColorIndex] = fColor;
4361
+ this.#reusablePluginColors[sColorIndex] = sColor;
4362
+ return this.#reusablePluginColors;
4346
4363
  };
4347
4364
  }
4348
4365
 
@@ -4400,53 +4417,53 @@
4400
4417
  renderCanvas;
4401
4418
  size;
4402
4419
  zoom = defaultZoom;
4403
- _container;
4404
- _generated;
4405
- _mutationObserver;
4406
- _originalStyle;
4407
- _pluginManager;
4408
- _pointerEvents;
4409
- _resizePlugins;
4410
- _standardSize;
4411
- _zoomCenter;
4420
+ #container;
4421
+ #generated;
4422
+ #mutationObserver;
4423
+ #originalStyle;
4424
+ #pluginManager;
4425
+ #pointerEvents;
4426
+ #resizePlugins;
4427
+ #standardSize;
4428
+ #zoomCenter;
4412
4429
  constructor(pluginManager, container) {
4413
- this._pluginManager = pluginManager;
4414
- this._container = container;
4430
+ this.#pluginManager = pluginManager;
4431
+ this.#container = container;
4415
4432
  this.render = new RenderManager(pluginManager, container, this);
4416
- this._standardSize = {
4433
+ this.#standardSize = {
4417
4434
  height: 0,
4418
4435
  width: 0,
4419
4436
  };
4420
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
4437
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
4421
4438
  this.size = {
4422
4439
  height: stdSize.height * pxRatio,
4423
4440
  width: stdSize.width * pxRatio,
4424
4441
  };
4425
- this._generated = false;
4426
- this._resizePlugins = [];
4427
- this._pointerEvents = "none";
4442
+ this.#generated = false;
4443
+ this.#resizePlugins = [];
4444
+ this.#pointerEvents = "none";
4428
4445
  }
4429
- get _fullScreen() {
4430
- return this._container.actualOptions.fullScreen.enable;
4446
+ get #fullScreen() {
4447
+ return this.#container.actualOptions.fullScreen.enable;
4431
4448
  }
4432
4449
  destroy() {
4433
4450
  this.stop();
4434
- if (this._generated) {
4451
+ if (this.#generated) {
4435
4452
  const element = this.domElement;
4436
4453
  element?.remove();
4437
4454
  this.domElement = undefined;
4438
4455
  this.renderCanvas = undefined;
4439
4456
  }
4440
4457
  else {
4441
- this._resetOriginalStyle();
4458
+ this.#resetOriginalStyle();
4442
4459
  }
4443
4460
  this.render.destroy();
4444
- this._resizePlugins = [];
4461
+ this.#resizePlugins = [];
4445
4462
  }
4446
4463
  getZoomCenter() {
4447
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
4448
- if (this._zoomCenter) {
4449
- return this._zoomCenter;
4464
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
4465
+ if (this.#zoomCenter) {
4466
+ return this.#zoomCenter;
4450
4467
  }
4451
4468
  return {
4452
4469
  x: (width * half) / pxRatio,
@@ -4454,20 +4471,20 @@
4454
4471
  };
4455
4472
  }
4456
4473
  init() {
4457
- this._safeMutationObserver(obs => {
4474
+ this.#safeMutationObserver(obs => {
4458
4475
  obs.disconnect();
4459
4476
  });
4460
- this._mutationObserver = safeMutationObserver(records => {
4477
+ this.#mutationObserver = safeMutationObserver(records => {
4461
4478
  for (const record of records) {
4462
4479
  if (record.type === "attributes" && record.attributeName === "style") {
4463
- this._repairStyle();
4480
+ this.#repairStyle();
4464
4481
  }
4465
4482
  }
4466
4483
  });
4467
4484
  this.resize();
4468
- this._initStyle();
4485
+ this.#initStyle();
4469
4486
  this.initBackground();
4470
- this._safeMutationObserver(obs => {
4487
+ this.#safeMutationObserver(obs => {
4471
4488
  const element = this.domElement;
4472
4489
  if (!element || !(element instanceof Node)) {
4473
4490
  return;
@@ -4478,13 +4495,13 @@
4478
4495
  this.render.init();
4479
4496
  }
4480
4497
  initBackground() {
4481
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
4498
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
4482
4499
  if (!element) {
4483
4500
  return;
4484
4501
  }
4485
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
4502
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
4486
4503
  if (color) {
4487
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
4504
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
4488
4505
  }
4489
4506
  else {
4490
4507
  elementStyle.backgroundColor = "";
@@ -4495,27 +4512,27 @@
4495
4512
  elementStyle.backgroundSize = background.size || "";
4496
4513
  }
4497
4514
  initPlugins() {
4498
- this._resizePlugins = [];
4499
- for (const plugin of this._container.plugins) {
4515
+ this.#resizePlugins = [];
4516
+ for (const plugin of this.#container.plugins) {
4500
4517
  if (plugin.resize) {
4501
- this._resizePlugins.push(plugin);
4518
+ this.#resizePlugins.push(plugin);
4502
4519
  }
4503
4520
  }
4504
4521
  }
4505
4522
  loadCanvas(canvas) {
4506
- if (this._generated && this.domElement) {
4523
+ if (this.#generated && this.domElement) {
4507
4524
  this.domElement.remove();
4508
4525
  }
4509
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4526
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4510
4527
  this.domElement = domCanvas;
4511
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4528
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4512
4529
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
4513
4530
  const domElement = this.domElement;
4514
4531
  if (domElement) {
4515
4532
  domElement.ariaHidden = "true";
4516
- this._originalStyle = cloneStyle(domElement.style);
4533
+ this.#originalStyle = cloneStyle(domElement.style);
4517
4534
  }
4518
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
4535
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
4519
4536
  if (domElement) {
4520
4537
  standardSize.height = domElement.offsetHeight;
4521
4538
  standardSize.width = domElement.offsetWidth;
@@ -4524,7 +4541,7 @@
4524
4541
  standardSize.height = renderCanvas.height;
4525
4542
  standardSize.width = renderCanvas.width;
4526
4543
  }
4527
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
4544
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
4528
4545
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
4529
4546
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
4530
4547
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -4535,12 +4552,12 @@
4535
4552
  willReadFrequently: false,
4536
4553
  });
4537
4554
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
4538
- this._safeMutationObserver(obs => {
4555
+ this.#safeMutationObserver(obs => {
4539
4556
  obs.disconnect();
4540
4557
  });
4541
4558
  container.retina.init();
4542
4559
  this.initBackground();
4543
- this._safeMutationObserver(obs => {
4560
+ this.#safeMutationObserver(obs => {
4544
4561
  const element = this.domElement;
4545
4562
  if (!element || !(element instanceof Node)) {
4546
4563
  return;
@@ -4553,11 +4570,11 @@
4553
4570
  if (!element) {
4554
4571
  return false;
4555
4572
  }
4556
- const container = this._container, renderCanvas = this.renderCanvas;
4573
+ const container = this.#container, renderCanvas = this.renderCanvas;
4557
4574
  if (renderCanvas === undefined) {
4558
4575
  return false;
4559
4576
  }
4560
- const currentSize = container.canvas._standardSize, newSize = {
4577
+ const currentSize = container.canvas.#standardSize, newSize = {
4561
4578
  width: element.offsetWidth,
4562
4579
  height: element.offsetHeight,
4563
4580
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -4576,7 +4593,7 @@
4576
4593
  const canvasSize = this.size;
4577
4594
  renderCanvas.width = canvasSize.width = retinaSize.width;
4578
4595
  renderCanvas.height = canvasSize.height = retinaSize.height;
4579
- if (this._container.started) {
4596
+ if (this.#container.started) {
4580
4597
  container.particles.setResizeFactor({
4581
4598
  width: currentSize.width / oldSize.width,
4582
4599
  height: currentSize.height / oldSize.height,
@@ -4589,46 +4606,46 @@
4589
4606
  if (!element) {
4590
4607
  return;
4591
4608
  }
4592
- this._pointerEvents = type;
4593
- this._repairStyle();
4609
+ this.#pointerEvents = type;
4610
+ this.#repairStyle();
4594
4611
  }
4595
4612
  setZoom(zoomLevel, center) {
4596
4613
  this.zoom = zoomLevel;
4597
- this._zoomCenter = center;
4614
+ this.#zoomCenter = center;
4598
4615
  }
4599
4616
  stop() {
4600
- this._safeMutationObserver(obs => {
4617
+ this.#safeMutationObserver(obs => {
4601
4618
  obs.disconnect();
4602
4619
  });
4603
- this._mutationObserver = undefined;
4620
+ this.#mutationObserver = undefined;
4604
4621
  this.render.stop();
4605
4622
  }
4606
4623
  async windowResize() {
4607
4624
  if (!this.domElement || !this.resize()) {
4608
4625
  return;
4609
4626
  }
4610
- const container = this._container, needsRefresh = container.updateActualOptions();
4627
+ const container = this.#container, needsRefresh = container.updateActualOptions();
4611
4628
  container.particles.setDensity();
4612
- this._applyResizePlugins();
4629
+ this.#applyResizePlugins();
4613
4630
  if (needsRefresh) {
4614
4631
  await container.refresh();
4615
4632
  }
4616
4633
  }
4617
- _applyResizePlugins = () => {
4618
- for (const plugin of this._resizePlugins) {
4634
+ #applyResizePlugins = () => {
4635
+ for (const plugin of this.#resizePlugins) {
4619
4636
  plugin.resize?.();
4620
4637
  }
4621
4638
  };
4622
- _initStyle = () => {
4623
- const element = this.domElement, options = this._container.actualOptions;
4639
+ #initStyle = () => {
4640
+ const element = this.domElement, options = this.#container.actualOptions;
4624
4641
  if (!element) {
4625
4642
  return;
4626
4643
  }
4627
- if (this._fullScreen) {
4628
- this._setFullScreenStyle();
4644
+ if (this.#fullScreen) {
4645
+ this.#setFullScreenStyle();
4629
4646
  }
4630
4647
  else {
4631
- this._resetOriginalStyle();
4648
+ this.#resetOriginalStyle();
4632
4649
  }
4633
4650
  for (const key in options.style) {
4634
4651
  if (!key || !(key in options.style)) {
@@ -4641,72 +4658,72 @@
4641
4658
  element.style.setProperty(key, value, "important");
4642
4659
  }
4643
4660
  };
4644
- _repairStyle = () => {
4661
+ #repairStyle = () => {
4645
4662
  const element = this.domElement;
4646
4663
  if (!element) {
4647
4664
  return;
4648
4665
  }
4649
- this._safeMutationObserver(observer => {
4666
+ this.#safeMutationObserver(observer => {
4650
4667
  observer.disconnect();
4651
4668
  });
4652
- this._initStyle();
4669
+ this.#initStyle();
4653
4670
  this.initBackground();
4654
- const pointerEvents = this._pointerEvents;
4671
+ const pointerEvents = this.#pointerEvents;
4655
4672
  element.style.pointerEvents = pointerEvents;
4656
4673
  element.style.setProperty("pointer-events", pointerEvents);
4657
- this._safeMutationObserver(observer => {
4674
+ this.#safeMutationObserver(observer => {
4658
4675
  if (!(element instanceof Node)) {
4659
4676
  return;
4660
4677
  }
4661
4678
  observer.observe(element, { attributes: true });
4662
4679
  });
4663
4680
  };
4664
- _resetOriginalStyle = () => {
4665
- const element = this.domElement, originalStyle = this._originalStyle;
4681
+ #resetOriginalStyle = () => {
4682
+ const element = this.domElement, originalStyle = this.#originalStyle;
4666
4683
  if (!element || !originalStyle) {
4667
4684
  return;
4668
4685
  }
4669
4686
  setStyle(element, originalStyle, true);
4670
4687
  };
4671
- _safeMutationObserver = callback => {
4672
- if (!this._mutationObserver) {
4688
+ #safeMutationObserver = callback => {
4689
+ if (!this.#mutationObserver) {
4673
4690
  return;
4674
4691
  }
4675
- callback(this._mutationObserver);
4692
+ callback(this.#mutationObserver);
4676
4693
  };
4677
- _setFullScreenStyle = () => {
4694
+ #setFullScreenStyle = () => {
4678
4695
  const element = this.domElement;
4679
4696
  if (!element) {
4680
4697
  return;
4681
4698
  }
4682
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
4699
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
4683
4700
  };
4684
4701
  }
4685
4702
 
4686
4703
  class EventListeners {
4687
- container;
4688
- _handlers;
4689
- _resizeObserver;
4690
- _resizeTimeout;
4704
+ #container;
4705
+ #handlers;
4706
+ #resizeObserver;
4707
+ #resizeTimeout;
4691
4708
  constructor(container) {
4692
- this.container = container;
4693
- this._handlers = {
4709
+ this.#container = container;
4710
+ this.#handlers = {
4694
4711
  visibilityChange: () => {
4695
- this._handleVisibilityChange();
4712
+ this.#handleVisibilityChange();
4696
4713
  },
4697
4714
  resize: () => {
4698
- this._handleWindowResize();
4715
+ this.#handleWindowResize();
4699
4716
  },
4700
4717
  };
4701
4718
  }
4702
4719
  addListeners() {
4703
- this._manageListeners(true);
4720
+ this.#manageListeners(true);
4704
4721
  }
4705
4722
  removeListeners() {
4706
- this._manageListeners(false);
4723
+ this.#manageListeners(false);
4707
4724
  }
4708
- _handleVisibilityChange = () => {
4709
- const container = this.container, options = container.actualOptions;
4725
+ #handleVisibilityChange = () => {
4726
+ const container = this.#container, options = container.actualOptions;
4710
4727
  if (!options.pauseOnBlur) {
4711
4728
  return;
4712
4729
  }
@@ -4724,24 +4741,24 @@
4724
4741
  }
4725
4742
  }
4726
4743
  };
4727
- _handleWindowResize = () => {
4728
- if (this._resizeTimeout) {
4729
- clearTimeout(this._resizeTimeout);
4730
- delete this._resizeTimeout;
4744
+ #handleWindowResize = () => {
4745
+ if (this.#resizeTimeout) {
4746
+ clearTimeout(this.#resizeTimeout);
4747
+ this.#resizeTimeout = undefined;
4731
4748
  }
4732
4749
  const handleResize = async () => {
4733
- const canvas = this.container.canvas;
4750
+ const canvas = this.#container.canvas;
4734
4751
  await canvas.windowResize();
4735
4752
  };
4736
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
4753
+ this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
4737
4754
  };
4738
- _manageListeners = add => {
4739
- const handlers = this._handlers;
4740
- this._manageResize(add);
4755
+ #manageListeners = add => {
4756
+ const handlers = this.#handlers;
4757
+ this.#manageResize(add);
4741
4758
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
4742
4759
  };
4743
- _manageResize = add => {
4744
- const handlers = this._handlers, container = this.container, options = container.actualOptions;
4760
+ #manageResize = add => {
4761
+ const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
4745
4762
  if (!options.resize.enable) {
4746
4763
  return;
4747
4764
  }
@@ -4750,22 +4767,22 @@
4750
4767
  return;
4751
4768
  }
4752
4769
  const canvasEl = container.canvas.domElement;
4753
- if (this._resizeObserver && !add) {
4770
+ if (this.#resizeObserver && !add) {
4754
4771
  if (canvasEl) {
4755
- this._resizeObserver.unobserve(canvasEl);
4772
+ this.#resizeObserver.unobserve(canvasEl);
4756
4773
  }
4757
- this._resizeObserver.disconnect();
4758
- delete this._resizeObserver;
4774
+ this.#resizeObserver.disconnect();
4775
+ this.#resizeObserver = undefined;
4759
4776
  }
4760
- else if (!this._resizeObserver && add && canvasEl) {
4761
- this._resizeObserver = new ResizeObserver((entries) => {
4777
+ else if (!this.#resizeObserver && add && canvasEl) {
4778
+ this.#resizeObserver = new ResizeObserver((entries) => {
4762
4779
  const entry = entries.find(e => e.target === canvasEl);
4763
4780
  if (!entry) {
4764
4781
  return;
4765
4782
  }
4766
- this._handleWindowResize();
4783
+ this.#handleWindowResize();
4767
4784
  });
4768
- this._resizeObserver.observe(canvasEl);
4785
+ this.#resizeObserver.observe(canvasEl);
4769
4786
  }
4770
4787
  };
4771
4788
  }
@@ -4838,24 +4855,24 @@
4838
4855
  unbreakable;
4839
4856
  velocity;
4840
4857
  zIndexFactor;
4841
- _cachedOpacityData = {
4858
+ #cachedOpacityData = {
4842
4859
  fillOpacity: defaultOpacity$1,
4843
4860
  opacity: defaultOpacity$1,
4844
4861
  strokeOpacity: defaultOpacity$1,
4845
4862
  };
4846
- _cachedPosition = Vector3d.origin;
4847
- _cachedRotateData = { sin: 0, cos: 0 };
4848
- _cachedTransform = {
4863
+ #cachedPosition = Vector3d.origin;
4864
+ #cachedRotateData = { sin: 0, cos: 0 };
4865
+ #cachedTransform = {
4849
4866
  a: 1,
4850
4867
  b: 0,
4851
4868
  c: 0,
4852
4869
  d: 1,
4853
4870
  };
4854
- _container;
4855
- _pluginManager;
4871
+ #container;
4872
+ #pluginManager;
4856
4873
  constructor(pluginManager, container) {
4857
- this._pluginManager = pluginManager;
4858
- this._container = container;
4874
+ this.#pluginManager = pluginManager;
4875
+ this.#container = container;
4859
4876
  }
4860
4877
  destroy(override) {
4861
4878
  if (this.unbreakable || this.destroyed) {
@@ -4864,7 +4881,7 @@
4864
4881
  this.destroyed = true;
4865
4882
  this.bubble.inRange = false;
4866
4883
  this.slow.inRange = false;
4867
- const container = this._container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4884
+ const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4868
4885
  shapeDrawer?.particleDestroy?.(this);
4869
4886
  for (const plugin of container.particleDestroyedPlugins) {
4870
4887
  plugin.particleDestroyed?.(this, override);
@@ -4872,12 +4889,12 @@
4872
4889
  for (const updater of container.particleUpdaters) {
4873
4890
  updater.particleDestroyed?.(this, override);
4874
4891
  }
4875
- this._container.dispatchEvent(EventType.particleDestroyed, {
4892
+ this.#container.dispatchEvent(EventType.particleDestroyed, {
4876
4893
  particle: this,
4877
4894
  });
4878
4895
  }
4879
4896
  draw(delta) {
4880
- const container = this._container, render = container.canvas.render;
4897
+ const container = this.#container, render = container.canvas.render;
4881
4898
  render.drawParticlePlugins(this, delta);
4882
4899
  render.drawParticle(this, delta);
4883
4900
  }
@@ -4885,50 +4902,50 @@
4885
4902
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
4886
4903
  }
4887
4904
  getFillColor() {
4888
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4905
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4889
4906
  }
4890
4907
  getMass() {
4891
4908
  return this.getRadius() ** squareExp * Math.PI * half;
4892
4909
  }
4893
4910
  getOpacity() {
4894
4911
  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;
4895
- this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4896
- this._cachedOpacityData.opacity = opacity * zOpacityFactor;
4897
- this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4898
- return this._cachedOpacityData;
4912
+ this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4913
+ this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
4914
+ this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4915
+ return this.#cachedOpacityData;
4899
4916
  }
4900
4917
  getPosition() {
4901
- this._cachedPosition.x = this.position.x + this.offset.x;
4902
- this._cachedPosition.y = this.position.y + this.offset.y;
4903
- this._cachedPosition.z = this.position.z;
4904
- return this._cachedPosition;
4918
+ this.#cachedPosition.x = this.position.x + this.offset.x;
4919
+ this.#cachedPosition.y = this.position.y + this.offset.y;
4920
+ this.#cachedPosition.z = this.position.z;
4921
+ return this.#cachedPosition;
4905
4922
  }
4906
4923
  getRadius() {
4907
4924
  return this.bubble.radius ?? this.size.value;
4908
4925
  }
4909
4926
  getRotateData() {
4910
4927
  const angle = this.getAngle();
4911
- this._cachedRotateData.sin = Math.sin(angle);
4912
- this._cachedRotateData.cos = Math.cos(angle);
4913
- return this._cachedRotateData;
4928
+ this.#cachedRotateData.sin = Math.sin(angle);
4929
+ this.#cachedRotateData.cos = Math.cos(angle);
4930
+ return this.#cachedRotateData;
4914
4931
  }
4915
4932
  getStrokeColor() {
4916
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4933
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4917
4934
  }
4918
4935
  getTransformData(externalTransform) {
4919
4936
  const rotateData = this.getRotateData(), rotating = this.isRotating;
4920
- this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4921
- this._cachedTransform.b = rotating
4937
+ this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4938
+ this.#cachedTransform.b = rotating
4922
4939
  ? rotateData.sin * (externalTransform.b ?? identity$1)
4923
4940
  : (externalTransform.b ?? defaultTransform.b);
4924
- this._cachedTransform.c = rotating
4941
+ this.#cachedTransform.c = rotating
4925
4942
  ? -rotateData.sin * (externalTransform.c ?? identity$1)
4926
4943
  : (externalTransform.c ?? defaultTransform.c);
4927
- this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4928
- return this._cachedTransform;
4944
+ this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4945
+ return this.#cachedTransform;
4929
4946
  }
4930
4947
  init(id, position, overrideOptions, group) {
4931
- const container = this._container;
4948
+ const container = this.#container;
4932
4949
  this.id = id;
4933
4950
  this.group = group;
4934
4951
  this.justWarped = false;
@@ -4948,21 +4965,27 @@
4948
4965
  moveSpeed: 0,
4949
4966
  sizeAnimationSpeed: 0,
4950
4967
  };
4968
+ this.size = {
4969
+ value: 1,
4970
+ max: 1,
4971
+ min: 1,
4972
+ enable: false,
4973
+ };
4951
4974
  this.outType = ParticleOutType.normal;
4952
4975
  this.ignoresResizeRatio = true;
4953
- const pxRatio = container.retina.pixelRatio, mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this._pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
4976
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
4954
4977
  this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
4955
4978
  this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
4956
4979
  const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
4957
4980
  if (overrideOptions) {
4958
- if (overrideOptions.effect?.type) {
4981
+ if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
4959
4982
  const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
4960
4983
  if (effect) {
4961
4984
  this.effect = effect;
4962
4985
  effectOptions.load(overrideOptions.effect);
4963
4986
  }
4964
4987
  }
4965
- if (overrideOptions.shape?.type) {
4988
+ if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
4966
4989
  const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
4967
4990
  if (shape) {
4968
4991
  this.shape = shape;
@@ -4971,21 +4994,20 @@
4971
4994
  }
4972
4995
  }
4973
4996
  if (this.effect === randomColorValue) {
4974
- const availableEffects = [...this._container.effectDrawers.keys()];
4997
+ const availableEffects = [...this.#container.effectDrawers.keys()];
4975
4998
  this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
4976
4999
  }
4977
5000
  if (this.shape === randomColorValue) {
4978
- const availableShapes = [...this._container.shapeDrawers.keys()];
5001
+ const availableShapes = [...this.#container.shapeDrawers.keys()];
4979
5002
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
4980
5003
  }
4981
5004
  this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
4982
5005
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
4983
5006
  particlesOptions.load(overrideOptions);
4984
- const effectData = this.effectData;
5007
+ const effectData = this.effectData, shapeData = this.shapeData;
4985
5008
  if (effectData) {
4986
5009
  particlesOptions.load(effectData.particles);
4987
5010
  }
4988
- const shapeData = this.shapeData;
4989
5011
  if (shapeData) {
4990
5012
  particlesOptions.load(shapeData.particles);
4991
5013
  }
@@ -4993,7 +5015,9 @@
4993
5015
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
4994
5016
  this.options = particlesOptions;
4995
5017
  container.retina.initParticle(this);
4996
- this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
5018
+ for (const updater of container.particleUpdaters) {
5019
+ updater.preInit?.(this);
5020
+ }
4997
5021
  this.bubble = {
4998
5022
  inRange: false,
4999
5023
  };
@@ -5001,8 +5025,8 @@
5001
5025
  inRange: false,
5002
5026
  factor: 1,
5003
5027
  };
5004
- this._initPosition(position);
5005
- this.initialVelocity = this._calculateVelocity();
5028
+ this.#initPosition(position);
5029
+ this.initialVelocity = this.#calculateVelocity();
5006
5030
  this.velocity = this.initialVelocity.copy();
5007
5031
  this.zIndexFactor = this.position.z / container.zLayers;
5008
5032
  this.sides = 24;
@@ -5033,12 +5057,11 @@
5033
5057
  plugin.particleCreated?.(this);
5034
5058
  }
5035
5059
  }
5036
- isInsideCanvas() {
5037
- const radius = this.getRadius(), canvasSize = this._container.canvas.size, position = this.position;
5038
- return (position.x >= -radius &&
5039
- position.y >= -radius &&
5040
- position.y <= canvasSize.height + radius &&
5041
- position.x <= canvasSize.width + radius);
5060
+ isInsideCanvas(direction) {
5061
+ return this.#getInsideCanvasResult({ direction }).inside;
5062
+ }
5063
+ isInsideCanvasForOutMode(outMode, direction) {
5064
+ return this.#getInsideCanvasResult({ direction, outMode }).inside;
5042
5065
  }
5043
5066
  isShowingBack() {
5044
5067
  if (!this.roll) {
@@ -5063,13 +5086,13 @@
5063
5086
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
5064
5087
  }
5065
5088
  reset() {
5066
- for (const updater of this._container.particleUpdaters) {
5089
+ for (const updater of this.#container.particleUpdaters) {
5067
5090
  updater.reset?.(this);
5068
5091
  }
5069
5092
  }
5070
- _calcPosition = (position, zIndex) => {
5093
+ #calcPosition = (position, zIndex) => {
5071
5094
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
5072
- const container = this._container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5095
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5073
5096
  while (!signal.aborted) {
5074
5097
  for (const plugin of plugins) {
5075
5098
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -5081,10 +5104,10 @@
5081
5104
  size: canvasSize,
5082
5105
  position: posVec,
5083
5106
  }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
5084
- this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
5085
- this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
5086
- this._fixVertical(pos, radius, outModes.top ?? outModes.default);
5087
- this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
5107
+ this.#fixHorizontal(pos, radius, outModes.left ?? outModes.default);
5108
+ this.#fixHorizontal(pos, radius, outModes.right ?? outModes.default);
5109
+ this.#fixVertical(pos, radius, outModes.top ?? outModes.default);
5110
+ this.#fixVertical(pos, radius, outModes.bottom ?? outModes.default);
5088
5111
  let isValidPosition = true;
5089
5112
  for (const plugin of container.particles.checkParticlePositionPlugins) {
5090
5113
  isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
@@ -5100,8 +5123,8 @@
5100
5123
  }
5101
5124
  return posVec;
5102
5125
  };
5103
- _calculateVelocity = () => {
5104
- const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
5126
+ #calculateVelocity = () => {
5127
+ const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
5105
5128
  if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
5106
5129
  return res;
5107
5130
  }
@@ -5117,27 +5140,86 @@
5117
5140
  }
5118
5141
  return res;
5119
5142
  };
5120
- _fixHorizontal = (pos, radius, outMode) => {
5143
+ #fixHorizontal = (pos, radius, outMode) => {
5121
5144
  fixOutMode({
5122
5145
  outMode,
5123
5146
  checkModes: [OutMode.bounce],
5124
5147
  coord: pos.x,
5125
- maxCoord: this._container.canvas.size.width,
5148
+ maxCoord: this.#container.canvas.size.width,
5126
5149
  setCb: (value) => (pos.x += value),
5127
5150
  radius,
5128
5151
  });
5129
5152
  };
5130
- _fixVertical = (pos, radius, outMode) => {
5153
+ #fixVertical = (pos, radius, outMode) => {
5131
5154
  fixOutMode({
5132
5155
  outMode,
5133
5156
  checkModes: [OutMode.bounce],
5134
5157
  coord: pos.y,
5135
- maxCoord: this._container.canvas.size.height,
5158
+ maxCoord: this.#container.canvas.size.height,
5136
5159
  setCb: (value) => (pos.y += value),
5137
5160
  radius,
5138
5161
  });
5139
5162
  };
5140
- _getRollColor = color => {
5163
+ #getDefaultInsideCanvasResult = (direction, outMode) => {
5164
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
5165
+ if (direction === OutModeDirection.bottom) {
5166
+ return {
5167
+ inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
5168
+ reason: "default",
5169
+ };
5170
+ }
5171
+ if (direction === OutModeDirection.left) {
5172
+ return {
5173
+ inside: isBounce ? position.x - radius > defaultAngle : position.x + radius > defaultAngle,
5174
+ reason: "default",
5175
+ };
5176
+ }
5177
+ if (direction === OutModeDirection.right) {
5178
+ return {
5179
+ inside: isBounce ? position.x + radius < canvasSize.width : position.x - radius < canvasSize.width,
5180
+ reason: "default",
5181
+ };
5182
+ }
5183
+ if (direction === OutModeDirection.top) {
5184
+ return {
5185
+ inside: isBounce ? position.y - radius > defaultAngle : position.y + radius > defaultAngle,
5186
+ reason: "default",
5187
+ };
5188
+ }
5189
+ return {
5190
+ inside: position.x >= -radius &&
5191
+ position.y >= -radius &&
5192
+ position.y <= canvasSize.height + radius &&
5193
+ position.x <= canvasSize.width + radius,
5194
+ reason: "default",
5195
+ };
5196
+ };
5197
+ #getInsideCanvasCallbackData = (direction, outMode) => {
5198
+ return {
5199
+ canvasSize: this.#container.canvas.size,
5200
+ direction,
5201
+ outMode,
5202
+ particle: this,
5203
+ radius: this.getRadius(),
5204
+ };
5205
+ };
5206
+ #getInsideCanvasResult = (data) => {
5207
+ 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;
5208
+ if (!shapeCheck && !effectCheck) {
5209
+ return defaultResult;
5210
+ }
5211
+ const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
5212
+ if (shapeResult && effectResult) {
5213
+ const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
5214
+ return {
5215
+ inside: shapeResult.inside && effectResult.inside,
5216
+ margin: margin > defaultAngle ? margin : undefined,
5217
+ reason: "combined",
5218
+ };
5219
+ }
5220
+ return shapeResult ?? effectResult ?? defaultResult;
5221
+ };
5222
+ #getRollColor = color => {
5141
5223
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
5142
5224
  return color;
5143
5225
  }
@@ -5152,8 +5234,8 @@
5152
5234
  }
5153
5235
  return color;
5154
5236
  };
5155
- _initPosition = position => {
5156
- const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5237
+ #initPosition = position => {
5238
+ const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5157
5239
  if (!initialPosition) {
5158
5240
  throw new Error("a valid position cannot be found for particle");
5159
5241
  }
@@ -5176,45 +5258,58 @@
5176
5258
  }
5177
5259
  this.offset = Vector.origin;
5178
5260
  };
5261
+ #normalizeInsideCanvasResult = (result, reason) => {
5262
+ if (typeof result === "boolean") {
5263
+ return {
5264
+ inside: result,
5265
+ reason,
5266
+ };
5267
+ }
5268
+ return {
5269
+ inside: result.inside,
5270
+ margin: result.margin,
5271
+ reason: result.reason ?? reason,
5272
+ };
5273
+ };
5179
5274
  }
5180
5275
 
5181
5276
  class SpatialHashGrid {
5182
- _cellSize;
5183
- _cells = new Map();
5184
- _circlePool = [];
5185
- _circlePoolIdx;
5186
- _pendingCellSize;
5187
- _rectanglePool = [];
5188
- _rectanglePoolIdx;
5277
+ #cellSize;
5278
+ #cells = new Map();
5279
+ #circlePool = [];
5280
+ #circlePoolIdx;
5281
+ #pendingCellSize;
5282
+ #rectanglePool = [];
5283
+ #rectanglePoolIdx;
5189
5284
  constructor(cellSize) {
5190
- this._cellSize = cellSize;
5191
- this._circlePoolIdx = 0;
5192
- this._rectanglePoolIdx = 0;
5285
+ this.#cellSize = cellSize;
5286
+ this.#circlePoolIdx = 0;
5287
+ this.#rectanglePoolIdx = 0;
5193
5288
  }
5194
5289
  clear() {
5195
- this._cells.clear();
5196
- const pendingCellSize = this._pendingCellSize;
5290
+ this.#cells.clear();
5291
+ const pendingCellSize = this.#pendingCellSize;
5197
5292
  if (pendingCellSize) {
5198
- this._cellSize = pendingCellSize;
5293
+ this.#cellSize = pendingCellSize;
5199
5294
  }
5200
- this._pendingCellSize = undefined;
5295
+ this.#pendingCellSize = undefined;
5201
5296
  }
5202
5297
  insert(particle) {
5203
- const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
5204
- if (!this._cells.has(key)) {
5205
- this._cells.set(key, []);
5298
+ const { x, y } = particle.getPosition(), key = this.#cellKeyFromCoords(x, y);
5299
+ if (!this.#cells.has(key)) {
5300
+ this.#cells.set(key, []);
5206
5301
  }
5207
- this._cells.get(key)?.push(particle);
5302
+ this.#cells.get(key)?.push(particle);
5208
5303
  }
5209
5304
  query(range, check, out = []) {
5210
- const bounds = this._getRangeBounds(range);
5305
+ const bounds = this.#getRangeBounds(range);
5211
5306
  if (!bounds) {
5212
5307
  return out;
5213
5308
  }
5214
- const minCellX = Math.floor(bounds.minX / this._cellSize), maxCellX = Math.floor(bounds.maxX / this._cellSize), minCellY = Math.floor(bounds.minY / this._cellSize), maxCellY = Math.floor(bounds.maxY / this._cellSize);
5309
+ const minCellX = Math.floor(bounds.minX / this.#cellSize), maxCellX = Math.floor(bounds.maxX / this.#cellSize), minCellY = Math.floor(bounds.minY / this.#cellSize), maxCellY = Math.floor(bounds.maxY / this.#cellSize);
5215
5310
  for (let cx = minCellX; cx <= maxCellX; cx++) {
5216
5311
  for (let cy = minCellY; cy <= maxCellY; cy++) {
5217
- const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
5312
+ const key = `${cx}_${cy}`, cellParticles = this.#cells.get(key);
5218
5313
  if (!cellParticles) {
5219
5314
  continue;
5220
5315
  }
@@ -5231,29 +5326,29 @@
5231
5326
  return out;
5232
5327
  }
5233
5328
  queryCircle(position, radius, check, out = []) {
5234
- const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5235
- this._releaseShapes();
5329
+ const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5330
+ this.#releaseShapes();
5236
5331
  return result;
5237
5332
  }
5238
5333
  queryRectangle(position, size, check, out = []) {
5239
- const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5240
- this._releaseShapes();
5334
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5335
+ this.#releaseShapes();
5241
5336
  return result;
5242
5337
  }
5243
5338
  setCellSize(cellSize) {
5244
- this._pendingCellSize = cellSize;
5339
+ this.#pendingCellSize = cellSize;
5245
5340
  }
5246
- _acquireCircle(x, y, r) {
5247
- return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5341
+ #acquireCircle(x, y, r) {
5342
+ return (this.#circlePool[this.#circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5248
5343
  }
5249
- _acquireRectangle(x, y, w, h) {
5250
- return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5344
+ #acquireRectangle(x, y, w, h) {
5345
+ return (this.#rectanglePool[this.#rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5251
5346
  }
5252
- _cellKeyFromCoords(x, y) {
5253
- const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
5347
+ #cellKeyFromCoords(x, y) {
5348
+ const cellX = Math.floor(x / this.#cellSize), cellY = Math.floor(y / this.#cellSize);
5254
5349
  return `${cellX}_${cellY}`;
5255
5350
  }
5256
- _getRangeBounds(range) {
5351
+ #getRangeBounds(range) {
5257
5352
  if (range instanceof Circle) {
5258
5353
  const r = range.radius, { x, y } = range.position;
5259
5354
  return {
@@ -5274,53 +5369,53 @@
5274
5369
  }
5275
5370
  return null;
5276
5371
  }
5277
- _releaseShapes() {
5278
- this._circlePoolIdx = 0;
5279
- this._rectanglePoolIdx = 0;
5372
+ #releaseShapes() {
5373
+ this.#circlePoolIdx = 0;
5374
+ this.#rectanglePoolIdx = 0;
5280
5375
  }
5281
5376
  }
5282
5377
 
5283
5378
  class ParticlesManager {
5284
5379
  checkParticlePositionPlugins;
5285
5380
  grid;
5286
- _array;
5287
- _container;
5288
- _groupLimits;
5289
- _limit;
5290
- _nextId;
5291
- _particleBuckets;
5292
- _particleResetPlugins;
5293
- _particleUpdatePlugins;
5294
- _pluginManager;
5295
- _pool;
5296
- _postParticleUpdatePlugins;
5297
- _postUpdatePlugins;
5298
- _resizeFactor;
5299
- _updatePlugins;
5300
- _zBuckets;
5381
+ #array;
5382
+ #container;
5383
+ #groupLimits;
5384
+ #limit;
5385
+ #nextId;
5386
+ #particleBuckets;
5387
+ #particleResetPlugins;
5388
+ #particleUpdatePlugins;
5389
+ #pluginManager;
5390
+ #pool;
5391
+ #postParticleUpdatePlugins;
5392
+ #postUpdatePlugins;
5393
+ #resizeFactor;
5394
+ #updatePlugins;
5395
+ #zBuckets;
5301
5396
  constructor(pluginManager, container) {
5302
- this._pluginManager = pluginManager;
5303
- this._container = container;
5304
- this._nextId = 0;
5305
- this._array = [];
5306
- this._pool = [];
5307
- this._limit = 0;
5308
- this._groupLimits = new Map();
5309
- this._particleBuckets = new Map();
5310
- this._zBuckets = this._createBuckets(this._container.zLayers);
5397
+ this.#pluginManager = pluginManager;
5398
+ this.#container = container;
5399
+ this.#nextId = 0;
5400
+ this.#array = [];
5401
+ this.#pool = [];
5402
+ this.#limit = 0;
5403
+ this.#groupLimits = new Map();
5404
+ this.#particleBuckets = new Map();
5405
+ this.#zBuckets = this.#createBuckets(this.#container.zLayers);
5311
5406
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
5312
5407
  this.checkParticlePositionPlugins = [];
5313
- this._particleResetPlugins = [];
5314
- this._particleUpdatePlugins = [];
5315
- this._postUpdatePlugins = [];
5316
- this._postParticleUpdatePlugins = [];
5317
- this._updatePlugins = [];
5408
+ this.#particleResetPlugins = [];
5409
+ this.#particleUpdatePlugins = [];
5410
+ this.#postUpdatePlugins = [];
5411
+ this.#postParticleUpdatePlugins = [];
5412
+ this.#updatePlugins = [];
5318
5413
  }
5319
5414
  get count() {
5320
- return this._array.length;
5415
+ return this.#array.length;
5321
5416
  }
5322
5417
  addParticle(position, overrideOptions, group, initializer) {
5323
- const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
5418
+ const limitMode = this.#container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this.#limit : (this.#groupLimits.get(group) ?? this.#limit), currentCount = this.count;
5324
5419
  if (limit > minLimit) {
5325
5420
  switch (limitMode) {
5326
5421
  case LimitMode.delete: {
@@ -5338,20 +5433,20 @@
5338
5433
  }
5339
5434
  }
5340
5435
  try {
5341
- const particle = this._pool.pop() ?? new Particle(this._pluginManager, this._container);
5342
- particle.init(this._nextId, position, overrideOptions, group);
5436
+ const particle = this.#pool.pop() ?? new Particle(this.#pluginManager, this.#container);
5437
+ particle.init(this.#nextId, position, overrideOptions, group);
5343
5438
  let canAdd = true;
5344
5439
  if (initializer) {
5345
5440
  canAdd = initializer(particle);
5346
5441
  }
5347
5442
  if (!canAdd) {
5348
- this._pool.push(particle);
5443
+ this.#pool.push(particle);
5349
5444
  return;
5350
5445
  }
5351
- this._array.push(particle);
5352
- this._insertParticleIntoBucket(particle);
5353
- this._nextId++;
5354
- this._container.dispatchEvent(EventType.particleAdded, {
5446
+ this.#array.push(particle);
5447
+ this.#insertParticleIntoBucket(particle);
5448
+ this.#nextId++;
5449
+ this.#container.dispatchEvent(EventType.particleAdded, {
5355
5450
  particle,
5356
5451
  });
5357
5452
  return particle;
@@ -5362,25 +5457,25 @@
5362
5457
  return undefined;
5363
5458
  }
5364
5459
  clear() {
5365
- this._array = [];
5366
- this._particleBuckets.clear();
5367
- this._resetBuckets(this._container.zLayers);
5460
+ this.#array = [];
5461
+ this.#particleBuckets.clear();
5462
+ this.#resetBuckets(this.#container.zLayers);
5368
5463
  }
5369
5464
  destroy() {
5370
- this._array = [];
5371
- this._pool.length = 0;
5372
- this._particleBuckets.clear();
5373
- this._zBuckets = [];
5465
+ this.#array = [];
5466
+ this.#pool.length = 0;
5467
+ this.#particleBuckets.clear();
5468
+ this.#zBuckets = [];
5374
5469
  this.checkParticlePositionPlugins = [];
5375
- this._particleResetPlugins = [];
5376
- this._particleUpdatePlugins = [];
5377
- this._postUpdatePlugins = [];
5378
- this._postParticleUpdatePlugins = [];
5379
- this._updatePlugins = [];
5470
+ this.#particleResetPlugins = [];
5471
+ this.#particleUpdatePlugins = [];
5472
+ this.#postUpdatePlugins = [];
5473
+ this.#postParticleUpdatePlugins = [];
5474
+ this.#updatePlugins = [];
5380
5475
  }
5381
5476
  drawParticles(delta) {
5382
- for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
5383
- const bucket = this._zBuckets[i];
5477
+ for (let i = this.#zBuckets.length - one; i >= minIndex; i--) {
5478
+ const bucket = this.#zBuckets[i];
5384
5479
  if (!bucket) {
5385
5480
  continue;
5386
5481
  }
@@ -5390,24 +5485,24 @@
5390
5485
  }
5391
5486
  }
5392
5487
  filter(condition) {
5393
- return this._array.filter(condition);
5488
+ return this.#array.filter(condition);
5394
5489
  }
5395
5490
  find(condition) {
5396
- return this._array.find(condition);
5491
+ return this.#array.find(condition);
5397
5492
  }
5398
5493
  get(index) {
5399
- return this._array[index];
5494
+ return this.#array[index];
5400
5495
  }
5401
5496
  async init() {
5402
- const container = this._container, options = container.actualOptions;
5497
+ const container = this.#container, options = container.actualOptions;
5403
5498
  this.checkParticlePositionPlugins = [];
5404
- this._updatePlugins = [];
5405
- this._particleUpdatePlugins = [];
5406
- this._postUpdatePlugins = [];
5407
- this._particleResetPlugins = [];
5408
- this._postParticleUpdatePlugins = [];
5409
- this._particleBuckets.clear();
5410
- this._resetBuckets(container.zLayers);
5499
+ this.#updatePlugins = [];
5500
+ this.#particleUpdatePlugins = [];
5501
+ this.#postUpdatePlugins = [];
5502
+ this.#particleResetPlugins = [];
5503
+ this.#postParticleUpdatePlugins = [];
5504
+ this.#particleBuckets.clear();
5505
+ this.#resetBuckets(container.zLayers);
5411
5506
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
5412
5507
  for (const plugin of container.plugins) {
5413
5508
  if (plugin.redrawInit) {
@@ -5417,26 +5512,26 @@
5417
5512
  this.checkParticlePositionPlugins.push(plugin);
5418
5513
  }
5419
5514
  if (plugin.update) {
5420
- this._updatePlugins.push(plugin);
5515
+ this.#updatePlugins.push(plugin);
5421
5516
  }
5422
5517
  if (plugin.particleUpdate) {
5423
- this._particleUpdatePlugins.push(plugin);
5518
+ this.#particleUpdatePlugins.push(plugin);
5424
5519
  }
5425
5520
  if (plugin.postUpdate) {
5426
- this._postUpdatePlugins.push(plugin);
5521
+ this.#postUpdatePlugins.push(plugin);
5427
5522
  }
5428
5523
  if (plugin.particleReset) {
5429
- this._particleResetPlugins.push(plugin);
5524
+ this.#particleResetPlugins.push(plugin);
5430
5525
  }
5431
5526
  if (plugin.postParticleUpdate) {
5432
- this._postParticleUpdatePlugins.push(plugin);
5527
+ this.#postParticleUpdatePlugins.push(plugin);
5433
5528
  }
5434
5529
  }
5435
- await this._container.initDrawersAndUpdaters();
5436
- for (const drawer of this._container.effectDrawers.values()) {
5530
+ await this.#container.initDrawersAndUpdaters();
5531
+ for (const drawer of this.#container.effectDrawers.values()) {
5437
5532
  await drawer.init?.(container);
5438
5533
  }
5439
- for (const drawer of this._container.shapeDrawers.values()) {
5534
+ for (const drawer of this.#container.shapeDrawers.values()) {
5440
5535
  await drawer.init?.(container);
5441
5536
  }
5442
5537
  let handled = false;
@@ -5470,10 +5565,10 @@
5470
5565
  async redraw() {
5471
5566
  this.clear();
5472
5567
  await this.init();
5473
- this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
5568
+ this.#container.canvas.render.drawParticles({ value: 0, factor: 0 });
5474
5569
  }
5475
5570
  remove(particle, group, override) {
5476
- this.removeAt(this._array.indexOf(particle), undefined, group, override);
5571
+ this.removeAt(this.#array.indexOf(particle), undefined, group, override);
5477
5572
  }
5478
5573
  removeAt(index, quantity = defaultRemoveQuantity, group, override) {
5479
5574
  if (index < minIndex || index > this.count) {
@@ -5481,7 +5576,7 @@
5481
5576
  }
5482
5577
  let deleted = 0;
5483
5578
  for (let i = index; deleted < quantity && i < this.count; i++) {
5484
- if (this._removeParticle(i, group, override)) {
5579
+ if (this.#removeParticle(i, group, override)) {
5485
5580
  i--;
5486
5581
  deleted++;
5487
5582
  }
@@ -5491,9 +5586,9 @@
5491
5586
  this.removeAt(minIndex, quantity, group);
5492
5587
  }
5493
5588
  setDensity() {
5494
- const options = this._container.actualOptions, groups = options.particles.groups;
5589
+ const options = this.#container.actualOptions, groups = options.particles.groups;
5495
5590
  let pluginsCount = 0;
5496
- for (const plugin of this._container.plugins) {
5591
+ for (const plugin of this.#container.plugins) {
5497
5592
  if (plugin.particlesDensityCount) {
5498
5593
  pluginsCount += plugin.particlesDensityCount();
5499
5594
  }
@@ -5503,51 +5598,51 @@
5503
5598
  if (!groupData) {
5504
5599
  continue;
5505
5600
  }
5506
- const groupDataOptions = loadParticlesOptions(this._pluginManager, this._container, groupData);
5507
- this._applyDensity(groupDataOptions, pluginsCount, group);
5601
+ const groupDataOptions = loadParticlesOptions(this.#pluginManager, this.#container, groupData);
5602
+ this.#applyDensity(groupDataOptions, pluginsCount, group);
5508
5603
  }
5509
- this._applyDensity(options.particles, pluginsCount);
5604
+ this.#applyDensity(options.particles, pluginsCount);
5510
5605
  }
5511
5606
  setResizeFactor(factor) {
5512
- this._resizeFactor = factor;
5607
+ this.#resizeFactor = factor;
5513
5608
  }
5514
5609
  update(delta) {
5515
5610
  this.grid.clear();
5516
- for (const plugin of this._updatePlugins) {
5611
+ for (const plugin of this.#updatePlugins) {
5517
5612
  plugin.update?.(delta);
5518
5613
  }
5519
- const particlesToDelete = this._updateParticlesPhase1(delta);
5520
- for (const plugin of this._postUpdatePlugins) {
5614
+ const particlesToDelete = this.#updateParticlesPhase1(delta);
5615
+ for (const plugin of this.#postUpdatePlugins) {
5521
5616
  plugin.postUpdate?.(delta);
5522
5617
  }
5523
- this._updateParticlesPhase2(delta, particlesToDelete);
5618
+ this.#updateParticlesPhase2(delta, particlesToDelete);
5524
5619
  if (particlesToDelete.size) {
5525
5620
  for (const particle of particlesToDelete) {
5526
5621
  this.remove(particle);
5527
5622
  }
5528
5623
  }
5529
- delete this._resizeFactor;
5624
+ this.#resizeFactor = undefined;
5530
5625
  }
5531
- _addToPool = (...particles) => {
5532
- this._pool.push(...particles);
5626
+ #addToPool = (...particles) => {
5627
+ this.#pool.push(...particles);
5533
5628
  };
5534
- _applyDensity = (options, pluginsCount, group, groupOptions) => {
5629
+ #applyDensity = (options, pluginsCount, group, groupOptions) => {
5535
5630
  const numberOptions = options.number;
5536
5631
  if (!numberOptions.density.enable) {
5537
5632
  if (group === undefined) {
5538
- this._limit = numberOptions.limit.value;
5633
+ this.#limit = numberOptions.limit.value;
5539
5634
  }
5540
5635
  else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
5541
- this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5636
+ this.#groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5542
5637
  }
5543
5638
  return;
5544
5639
  }
5545
- const densityFactor = this._initDensityFactor(numberOptions.density), optParticlesNumber = numberOptions.value, optParticlesLimit = numberOptions.limit.value > minLimit ? numberOptions.limit.value : optParticlesNumber, particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + pluginsCount, particlesCount = Math.min(this.count, this.filter(t => t.group === group).length);
5640
+ const densityFactor = this.#initDensityFactor(numberOptions.density), optParticlesNumber = numberOptions.value, optParticlesLimit = numberOptions.limit.value > minLimit ? numberOptions.limit.value : optParticlesNumber, particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + pluginsCount, particlesCount = Math.min(this.count, this.filter(t => t.group === group).length);
5546
5641
  if (group === undefined) {
5547
- this._limit = numberOptions.limit.value * densityFactor;
5642
+ this.#limit = numberOptions.limit.value * densityFactor;
5548
5643
  }
5549
5644
  else {
5550
- this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
5645
+ this.#groupLimits.set(group, numberOptions.limit.value * densityFactor);
5551
5646
  }
5552
5647
  if (particlesCount < particlesNumber) {
5553
5648
  this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
@@ -5556,18 +5651,18 @@
5556
5651
  this.removeQuantity(particlesCount - particlesNumber, group);
5557
5652
  }
5558
5653
  };
5559
- _createBuckets = (zLayers) => {
5654
+ #createBuckets = (zLayers) => {
5560
5655
  const bucketCount = Math.max(Math.floor(zLayers), one);
5561
5656
  return Array.from({ length: bucketCount }, () => []);
5562
5657
  };
5563
- _getBucketIndex = (zIndex) => {
5564
- const maxBucketIndex = this._zBuckets.length - one;
5658
+ #getBucketIndex = (zIndex) => {
5659
+ const maxBucketIndex = this.#zBuckets.length - one;
5565
5660
  if (maxBucketIndex <= minIndex) {
5566
5661
  return minIndex;
5567
5662
  }
5568
5663
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
5569
5664
  };
5570
- _getParticleInsertIndex = (bucket, particleId) => {
5665
+ #getParticleInsertIndex = (bucket, particleId) => {
5571
5666
  let start = minIndex, end = bucket.length;
5572
5667
  while (start < end) {
5573
5668
  const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
@@ -5584,8 +5679,8 @@
5584
5679
  }
5585
5680
  return start;
5586
5681
  };
5587
- _initDensityFactor = densityOptions => {
5588
- const container = this._container;
5682
+ #initDensityFactor = densityOptions => {
5683
+ const container = this.#container;
5589
5684
  if (!densityOptions.enable) {
5590
5685
  return defaultDensityFactor;
5591
5686
  }
@@ -5595,82 +5690,82 @@
5595
5690
  }
5596
5691
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
5597
5692
  };
5598
- _insertParticleIntoBucket = (particle) => {
5599
- const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5693
+ #insertParticleIntoBucket = (particle) => {
5694
+ const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5600
5695
  if (!bucket) {
5601
5696
  return;
5602
5697
  }
5603
- bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
5604
- this._particleBuckets.set(particle.id, bucketIndex);
5698
+ bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
5699
+ this.#particleBuckets.set(particle.id, bucketIndex);
5605
5700
  };
5606
- _removeParticle = (index, group, override) => {
5607
- const particle = this._array[index];
5701
+ #removeParticle = (index, group, override) => {
5702
+ const particle = this.#array[index];
5608
5703
  if (!particle) {
5609
5704
  return false;
5610
5705
  }
5611
5706
  if (particle.group !== group) {
5612
5707
  return false;
5613
5708
  }
5614
- this._array.splice(index, deleteCount);
5615
- this._removeParticleFromBucket(particle);
5709
+ this.#array.splice(index, deleteCount);
5710
+ this.#removeParticleFromBucket(particle);
5616
5711
  particle.destroy(override);
5617
- this._container.dispatchEvent(EventType.particleRemoved, {
5712
+ this.#container.dispatchEvent(EventType.particleRemoved, {
5618
5713
  particle,
5619
5714
  });
5620
- this._addToPool(particle);
5715
+ this.#addToPool(particle);
5621
5716
  return true;
5622
5717
  };
5623
- _removeParticleFromBucket = (particle) => {
5624
- const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5718
+ #removeParticleFromBucket = (particle) => {
5719
+ const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5625
5720
  if (!bucket) {
5626
- this._particleBuckets.delete(particle.id);
5721
+ this.#particleBuckets.delete(particle.id);
5627
5722
  return;
5628
5723
  }
5629
- const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
5724
+ const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
5630
5725
  if (bucket[particleIndex]?.id !== particle.id) {
5631
- this._particleBuckets.delete(particle.id);
5726
+ this.#particleBuckets.delete(particle.id);
5632
5727
  return;
5633
5728
  }
5634
5729
  bucket.splice(particleIndex, deleteCount);
5635
- this._particleBuckets.delete(particle.id);
5730
+ this.#particleBuckets.delete(particle.id);
5636
5731
  };
5637
- _resetBuckets = (zLayers) => {
5732
+ #resetBuckets = (zLayers) => {
5638
5733
  const bucketCount = Math.max(Math.floor(zLayers), one);
5639
- if (this._zBuckets.length !== bucketCount) {
5640
- this._zBuckets = this._createBuckets(bucketCount);
5734
+ if (this.#zBuckets.length !== bucketCount) {
5735
+ this.#zBuckets = this.#createBuckets(bucketCount);
5641
5736
  return;
5642
5737
  }
5643
- for (const bucket of this._zBuckets) {
5738
+ for (const bucket of this.#zBuckets) {
5644
5739
  bucket.length = minIndex;
5645
5740
  }
5646
5741
  };
5647
- _updateParticleBucket = (particle) => {
5648
- const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
5742
+ #updateParticleBucket = (particle) => {
5743
+ const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
5649
5744
  if (currentBucketIndex === undefined) {
5650
- this._insertParticleIntoBucket(particle);
5745
+ this.#insertParticleIntoBucket(particle);
5651
5746
  return;
5652
5747
  }
5653
5748
  if (currentBucketIndex === newBucketIndex) {
5654
5749
  return;
5655
5750
  }
5656
- const currentBucket = this._zBuckets[currentBucketIndex];
5751
+ const currentBucket = this.#zBuckets[currentBucketIndex];
5657
5752
  if (currentBucket) {
5658
- const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
5753
+ const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
5659
5754
  if (currentBucket[particleIndex]?.id === particle.id) {
5660
5755
  currentBucket.splice(particleIndex, deleteCount);
5661
5756
  }
5662
5757
  }
5663
- const newBucket = this._zBuckets[newBucketIndex];
5758
+ const newBucket = this.#zBuckets[newBucketIndex];
5664
5759
  if (!newBucket) {
5665
- this._particleBuckets.set(particle.id, newBucketIndex);
5760
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5666
5761
  return;
5667
5762
  }
5668
- newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
5669
- this._particleBuckets.set(particle.id, newBucketIndex);
5763
+ newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
5764
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5670
5765
  };
5671
- _updateParticlesPhase1 = (delta) => {
5672
- const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
5673
- for (const particle of this._array) {
5766
+ #updateParticlesPhase1 = (delta) => {
5767
+ const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
5768
+ for (const particle of this.#array) {
5674
5769
  if (resizeFactor && !particle.ignoresResizeRatio) {
5675
5770
  particle.position.x *= resizeFactor.width;
5676
5771
  particle.position.y *= resizeFactor.height;
@@ -5678,10 +5773,10 @@
5678
5773
  particle.initialPosition.y *= resizeFactor.height;
5679
5774
  }
5680
5775
  particle.ignoresResizeRatio = false;
5681
- for (const plugin of this._particleResetPlugins) {
5776
+ for (const plugin of this.#particleResetPlugins) {
5682
5777
  plugin.particleReset?.(particle);
5683
5778
  }
5684
- for (const plugin of this._particleUpdatePlugins) {
5779
+ for (const plugin of this.#particleUpdatePlugins) {
5685
5780
  if (particle.destroyed) {
5686
5781
  break;
5687
5782
  }
@@ -5695,36 +5790,36 @@
5695
5790
  }
5696
5791
  return particlesToDelete;
5697
5792
  };
5698
- _updateParticlesPhase2 = (delta, particlesToDelete) => {
5699
- for (const particle of this._array) {
5793
+ #updateParticlesPhase2 = (delta, particlesToDelete) => {
5794
+ for (const particle of this.#array) {
5700
5795
  if (particle.destroyed) {
5701
5796
  particlesToDelete.add(particle);
5702
5797
  continue;
5703
5798
  }
5704
- for (const updater of this._container.particleUpdaters) {
5799
+ for (const updater of this.#container.particleUpdaters) {
5705
5800
  updater.update(particle, delta);
5706
5801
  }
5707
5802
  if (!particle.spawning) {
5708
- for (const plugin of this._postParticleUpdatePlugins) {
5803
+ for (const plugin of this.#postParticleUpdatePlugins) {
5709
5804
  plugin.postParticleUpdate?.(particle, delta);
5710
5805
  }
5711
5806
  }
5712
- this._updateParticleBucket(particle);
5807
+ this.#updateParticleBucket(particle);
5713
5808
  }
5714
5809
  };
5715
5810
  }
5716
5811
 
5717
5812
  class Retina {
5718
- container;
5719
5813
  pixelRatio;
5720
5814
  reduceFactor;
5815
+ #container;
5721
5816
  constructor(container) {
5722
- this.container = container;
5817
+ this.#container = container;
5723
5818
  this.pixelRatio = defaultRatio;
5724
5819
  this.reduceFactor = defaultReduceFactor;
5725
5820
  }
5726
5821
  init() {
5727
- const container = this.container, options = container.actualOptions;
5822
+ const container = this.#container, options = container.actualOptions;
5728
5823
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
5729
5824
  this.reduceFactor = defaultReduceFactor;
5730
5825
  const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
@@ -5738,7 +5833,6 @@
5738
5833
  props.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
5739
5834
  props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
5740
5835
  props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
5741
- props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
5742
5836
  const maxDistance = props.maxDistance;
5743
5837
  maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
5744
5838
  maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
@@ -5776,73 +5870,73 @@
5776
5870
  shapeDrawers;
5777
5871
  started;
5778
5872
  zLayers;
5779
- _delay;
5780
- _delayTimeout;
5781
- _delta = { value: 0, factor: 0 };
5782
- _dispatchCallback;
5783
- _drawAnimationFrame;
5784
- _duration;
5785
- _eventListeners;
5786
- _firstStart;
5787
- _initialSourceOptions;
5788
- _lastFrameTime;
5789
- _lifeTime;
5790
- _onDestroy;
5791
- _options;
5792
- _paused;
5793
- _pluginManager;
5794
- _smooth;
5795
- _sourceOptions;
5873
+ #delay;
5874
+ #delayTimeout;
5875
+ #delta = { value: 0, factor: 0 };
5876
+ #dispatchCallback;
5877
+ #drawAnimationFrame;
5878
+ #duration;
5879
+ #eventListeners;
5880
+ #firstStart;
5881
+ #initialSourceOptions;
5882
+ #lastFrameTime;
5883
+ #lifeTime;
5884
+ #onDestroy;
5885
+ #options;
5886
+ #paused;
5887
+ #pluginManager;
5888
+ #smooth;
5889
+ #sourceOptions;
5796
5890
  constructor(params) {
5797
5891
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
5798
- this._pluginManager = pluginManager;
5799
- this._dispatchCallback = dispatchCallback;
5800
- this._onDestroy = onDestroy;
5892
+ this.#pluginManager = pluginManager;
5893
+ this.#dispatchCallback = dispatchCallback;
5894
+ this.#onDestroy = onDestroy;
5801
5895
  this.id = Symbol(id);
5802
5896
  this.fpsLimit = 120;
5803
5897
  this.hdr = false;
5804
- this._smooth = false;
5805
- this._delay = 0;
5806
- this._duration = 0;
5807
- this._lifeTime = 0;
5808
- this._firstStart = true;
5898
+ this.#smooth = false;
5899
+ this.#delay = 0;
5900
+ this.#duration = 0;
5901
+ this.#lifeTime = 0;
5902
+ this.#firstStart = true;
5809
5903
  this.started = false;
5810
5904
  this.destroyed = false;
5811
- this._paused = true;
5812
- this._lastFrameTime = 0;
5905
+ this.#paused = true;
5906
+ this.#lastFrameTime = 0;
5813
5907
  this.zLayers = 100;
5814
5908
  this.pageHidden = false;
5815
- this._sourceOptions = sourceOptions;
5816
- this._initialSourceOptions = sourceOptions;
5909
+ this.#sourceOptions = sourceOptions;
5910
+ this.#initialSourceOptions = sourceOptions;
5817
5911
  this.effectDrawers = new Map();
5818
5912
  this.shapeDrawers = new Map();
5819
5913
  this.particleUpdaters = [];
5820
5914
  this.retina = new Retina(this);
5821
- this.canvas = new CanvasManager(this._pluginManager, this);
5822
- this.particles = new ParticlesManager(this._pluginManager, this);
5915
+ this.canvas = new CanvasManager(this.#pluginManager, this);
5916
+ this.particles = new ParticlesManager(this.#pluginManager, this);
5823
5917
  this.plugins = [];
5824
5918
  this.particleDestroyedPlugins = [];
5825
5919
  this.particleCreatedPlugins = [];
5826
5920
  this.particlePositionPlugins = [];
5827
- this._options = loadContainerOptions(this._pluginManager, this);
5828
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
5829
- this._eventListeners = new EventListeners(this);
5921
+ this.#options = loadContainerOptions(this.#pluginManager, this);
5922
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
5923
+ this.#eventListeners = new EventListeners(this);
5830
5924
  this.dispatchEvent(EventType.containerBuilt);
5831
5925
  }
5832
5926
  get animationStatus() {
5833
- return !this._paused && !this.pageHidden && guardCheck(this);
5927
+ return !this.#paused && !this.pageHidden && guardCheck(this);
5834
5928
  }
5835
5929
  get options() {
5836
- return this._options;
5930
+ return this.#options;
5837
5931
  }
5838
5932
  get sourceOptions() {
5839
- return this._sourceOptions;
5933
+ return this.#sourceOptions;
5840
5934
  }
5841
5935
  addLifeTime(value) {
5842
- this._lifeTime += value;
5936
+ this.#lifeTime += value;
5843
5937
  }
5844
5938
  alive() {
5845
- return !this._duration || this._lifeTime <= this._duration;
5939
+ return !this.#duration || this.#lifeTime <= this.#duration;
5846
5940
  }
5847
5941
  destroy(remove = true) {
5848
5942
  if (!guardCheck(this)) {
@@ -5864,13 +5958,13 @@
5864
5958
  this.shapeDrawers = new Map();
5865
5959
  this.particleUpdaters = [];
5866
5960
  this.plugins.length = 0;
5867
- this._pluginManager.clearPlugins(this);
5961
+ this.#pluginManager.clearPlugins(this);
5868
5962
  this.destroyed = true;
5869
- this._onDestroy(remove);
5963
+ this.#onDestroy(remove);
5870
5964
  this.dispatchEvent(EventType.containerDestroyed);
5871
5965
  }
5872
5966
  dispatchEvent(type, data) {
5873
- this._dispatchCallback(type, {
5967
+ this.#dispatchCallback(type, {
5874
5968
  container: this,
5875
5969
  data,
5876
5970
  });
@@ -5880,12 +5974,12 @@
5880
5974
  return;
5881
5975
  }
5882
5976
  let refreshTime = force;
5883
- this._drawAnimationFrame = animate((timestamp) => {
5977
+ this.#drawAnimationFrame = animate((timestamp) => {
5884
5978
  if (refreshTime) {
5885
- this._lastFrameTime = undefined;
5979
+ this.#lastFrameTime = undefined;
5886
5980
  refreshTime = false;
5887
5981
  }
5888
- this._nextFrame(timestamp);
5982
+ this.#nextFrame(timestamp);
5889
5983
  });
5890
5984
  }
5891
5985
  async export(type, options = {}) {
@@ -5907,7 +6001,7 @@
5907
6001
  return;
5908
6002
  }
5909
6003
  const allContainerPlugins = new Map();
5910
- for (const plugin of this._pluginManager.plugins) {
6004
+ for (const plugin of this.#pluginManager.plugins) {
5911
6005
  const containerPlugin = await plugin.getPlugin(this);
5912
6006
  if (containerPlugin.preInit) {
5913
6007
  await containerPlugin.preInit();
@@ -5915,8 +6009,8 @@
5915
6009
  allContainerPlugins.set(plugin, containerPlugin);
5916
6010
  }
5917
6011
  await this.initDrawersAndUpdaters();
5918
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
5919
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
6012
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
6013
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
5920
6014
  this.plugins.length = 0;
5921
6015
  this.particleDestroyedPlugins.length = 0;
5922
6016
  this.particleCreatedPlugins.length = 0;
@@ -5943,11 +6037,11 @@
5943
6037
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
5944
6038
  this.hdr = hdr;
5945
6039
  this.zLayers = zLayers;
5946
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
5947
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
5948
- this._lifeTime = 0;
6040
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
6041
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
6042
+ this.#lifeTime = 0;
5949
6043
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
5950
- this._smooth = smooth;
6044
+ this.#smooth = smooth;
5951
6045
  for (const plugin of this.plugins) {
5952
6046
  await plugin.init?.();
5953
6047
  }
@@ -5960,7 +6054,7 @@
5960
6054
  this.dispatchEvent(EventType.particlesSetup);
5961
6055
  }
5962
6056
  async initDrawersAndUpdaters() {
5963
- const pluginManager = this._pluginManager;
6057
+ const pluginManager = this.#pluginManager;
5964
6058
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
5965
6059
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
5966
6060
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -5969,18 +6063,18 @@
5969
6063
  if (!guardCheck(this)) {
5970
6064
  return;
5971
6065
  }
5972
- if (this._drawAnimationFrame !== undefined) {
5973
- cancelAnimation(this._drawAnimationFrame);
5974
- delete this._drawAnimationFrame;
6066
+ if (this.#drawAnimationFrame !== undefined) {
6067
+ cancelAnimation(this.#drawAnimationFrame);
6068
+ this.#drawAnimationFrame = undefined;
5975
6069
  }
5976
- if (this._paused) {
6070
+ if (this.#paused) {
5977
6071
  return;
5978
6072
  }
5979
6073
  for (const plugin of this.plugins) {
5980
6074
  plugin.pause?.();
5981
6075
  }
5982
6076
  if (!this.pageHidden) {
5983
- this._paused = true;
6077
+ this.#paused = true;
5984
6078
  }
5985
6079
  this.dispatchEvent(EventType.containerPaused);
5986
6080
  }
@@ -5988,13 +6082,13 @@
5988
6082
  if (!guardCheck(this)) {
5989
6083
  return;
5990
6084
  }
5991
- const needsUpdate = this._paused || force;
5992
- if (this._firstStart && !this.actualOptions.autoPlay) {
5993
- this._firstStart = false;
6085
+ const needsUpdate = this.#paused || force;
6086
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
6087
+ this.#firstStart = false;
5994
6088
  return;
5995
6089
  }
5996
- if (this._paused) {
5997
- this._paused = false;
6090
+ if (this.#paused) {
6091
+ this.#paused = false;
5998
6092
  }
5999
6093
  if (needsUpdate) {
6000
6094
  for (const plugin of this.plugins) {
@@ -6017,10 +6111,10 @@
6017
6111
  if (!guardCheck(this)) {
6018
6112
  return;
6019
6113
  }
6020
- this._initialSourceOptions = sourceOptions;
6021
- this._sourceOptions = sourceOptions;
6022
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
6023
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
6114
+ this.#initialSourceOptions = sourceOptions;
6115
+ this.#sourceOptions = sourceOptions;
6116
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
6117
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
6024
6118
  return this.refresh();
6025
6119
  }
6026
6120
  async start() {
@@ -6031,7 +6125,7 @@
6031
6125
  this.started = true;
6032
6126
  await new Promise(resolve => {
6033
6127
  const start = async () => {
6034
- this._eventListeners.addListeners();
6128
+ this.#eventListeners.addListeners();
6035
6129
  for (const plugin of this.plugins) {
6036
6130
  await plugin.start?.();
6037
6131
  }
@@ -6039,20 +6133,20 @@
6039
6133
  this.play();
6040
6134
  resolve();
6041
6135
  };
6042
- this._delayTimeout = setTimeout(() => void start(), this._delay);
6136
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
6043
6137
  });
6044
6138
  }
6045
6139
  stop() {
6046
6140
  if (!guardCheck(this) || !this.started) {
6047
6141
  return;
6048
6142
  }
6049
- if (this._delayTimeout) {
6050
- clearTimeout(this._delayTimeout);
6051
- delete this._delayTimeout;
6143
+ if (this.#delayTimeout) {
6144
+ clearTimeout(this.#delayTimeout);
6145
+ this.#delayTimeout = undefined;
6052
6146
  }
6053
- this._firstStart = true;
6147
+ this.#firstStart = true;
6054
6148
  this.started = false;
6055
- this._eventListeners.removeListeners();
6149
+ this.#eventListeners.removeListeners();
6056
6150
  this.pause();
6057
6151
  this.particles.clear();
6058
6152
  this.canvas.stop();
@@ -6062,7 +6156,7 @@
6062
6156
  this.particleCreatedPlugins.length = 0;
6063
6157
  this.particleDestroyedPlugins.length = 0;
6064
6158
  this.particlePositionPlugins.length = 0;
6065
- this._sourceOptions = this._options;
6159
+ this.#sourceOptions = this.#options;
6066
6160
  this.dispatchEvent(EventType.containerStopped);
6067
6161
  }
6068
6162
  updateActualOptions() {
@@ -6074,23 +6168,23 @@
6074
6168
  }
6075
6169
  return refresh;
6076
6170
  }
6077
- _nextFrame = (timestamp) => {
6171
+ #nextFrame = (timestamp) => {
6078
6172
  try {
6079
- if (!this._smooth &&
6080
- this._lastFrameTime !== undefined &&
6081
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
6173
+ if (!this.#smooth &&
6174
+ this.#lastFrameTime !== undefined &&
6175
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
6082
6176
  this.draw(false);
6083
6177
  return;
6084
6178
  }
6085
- this._lastFrameTime ??= timestamp;
6086
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
6087
- this.addLifeTime(this._delta.value);
6088
- this._lastFrameTime = timestamp;
6089
- if (this._delta.value > millisecondsToSeconds) {
6179
+ this.#lastFrameTime ??= timestamp;
6180
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
6181
+ this.addLifeTime(this.#delta.value);
6182
+ this.#lastFrameTime = timestamp;
6183
+ if (this.#delta.value > millisecondsToSeconds) {
6090
6184
  this.draw(false);
6091
6185
  return;
6092
6186
  }
6093
- this.canvas.render.drawParticles(this._delta);
6187
+ this.canvas.render.drawParticles(this.#delta);
6094
6188
  if (!this.alive()) {
6095
6189
  this.destroy();
6096
6190
  return;
@@ -6111,10 +6205,10 @@
6111
6205
  });
6112
6206
 
6113
6207
  class BlendPluginInstance {
6114
- _container;
6115
- _defaultCompositeValue;
6208
+ #container;
6209
+ #defaultCompositeValue;
6116
6210
  constructor(container) {
6117
- this._container = container;
6211
+ this.#container = container;
6118
6212
  }
6119
6213
  drawParticleCleanup(context, particle) {
6120
6214
  if (!particle.options.blend?.enable) {
@@ -6131,14 +6225,14 @@
6131
6225
  context.globalCompositeOperation = particle.options.blend.mode;
6132
6226
  }
6133
6227
  drawSettingsCleanup(context) {
6134
- if (!this._defaultCompositeValue) {
6228
+ if (!this.#defaultCompositeValue) {
6135
6229
  return;
6136
6230
  }
6137
- context.globalCompositeOperation = this._defaultCompositeValue;
6231
+ context.globalCompositeOperation = this.#defaultCompositeValue;
6138
6232
  }
6139
6233
  drawSettingsSetup(context) {
6140
- const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
6141
- this._defaultCompositeValue = previousComposite;
6234
+ const previousComposite = context.globalCompositeOperation, blend = this.#container.actualOptions.blend;
6235
+ this.#defaultCompositeValue = previousComposite;
6142
6236
  context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
6143
6237
  }
6144
6238
  }
@@ -6281,11 +6375,11 @@
6281
6375
  class MovePluginInstance {
6282
6376
  availablePathGenerators;
6283
6377
  pathGenerators;
6284
- _container;
6285
- _pluginManager;
6378
+ #container;
6379
+ #pluginManager;
6286
6380
  constructor(pluginManager, container) {
6287
- this._pluginManager = pluginManager;
6288
- this._container = container;
6381
+ this.#pluginManager = pluginManager;
6382
+ this.#container = container;
6289
6383
  this.availablePathGenerators = new Map();
6290
6384
  this.pathGenerators = new Map();
6291
6385
  }
@@ -6316,7 +6410,7 @@
6316
6410
  acceleration: getRangeValue(gravityOptions.acceleration),
6317
6411
  inverse: gravityOptions.inverse,
6318
6412
  };
6319
- initSpin(this._container, particle);
6413
+ initSpin(this.#container, particle);
6320
6414
  }
6321
6415
  particleDestroyed(particle) {
6322
6416
  const pathGenerator = particle.pathGenerator;
@@ -6327,7 +6421,7 @@
6327
6421
  if (!moveOptions.enable) {
6328
6422
  return;
6329
6423
  }
6330
- const container = this._container, pxRatio = container.retina.pixelRatio, slowFactor = getProximitySpeedFactor(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = getRangeMax(particleOptions.size.value) * pxRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = baseSpeed * sizeFactor * slowFactor * deltaFactor * half, maxSpeed = particle.retina.maxSpeed;
6424
+ const container = this.#container, slowFactor = getProximitySpeedFactor(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = particle.size.max, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = baseSpeed * sizeFactor * slowFactor * deltaFactor * half, maxSpeed = particle.retina.maxSpeed;
6331
6425
  if (moveOptions.spin.enable) {
6332
6426
  spin(container, particle, moveSpeed, reduceFactor);
6333
6427
  }
@@ -6337,18 +6431,18 @@
6337
6431
  applyDistance(particle);
6338
6432
  }
6339
6433
  preInit() {
6340
- return this._init();
6434
+ return this.#init();
6341
6435
  }
6342
6436
  redrawInit() {
6343
- return this._init();
6437
+ return this.#init();
6344
6438
  }
6345
6439
  update() {
6346
6440
  for (const pathGenerator of this.pathGenerators.values()) {
6347
6441
  pathGenerator.update();
6348
6442
  }
6349
6443
  }
6350
- async _init() {
6351
- const availablePathGenerators = await this._pluginManager.getPathGenerators?.(this._container, true);
6444
+ async #init() {
6445
+ const availablePathGenerators = await this.#pluginManager.getPathGenerators?.(this.#container, true);
6352
6446
  if (!availablePathGenerators) {
6353
6447
  return;
6354
6448
  }
@@ -6367,65 +6461,65 @@
6367
6461
 
6368
6462
  const touchDelay = 500;
6369
6463
  class InteractivityEventListeners {
6370
- _canPush = true;
6371
- _clickPositionPlugins;
6372
- _container;
6373
- _handlers;
6374
- _interactionManager;
6375
- _touches;
6464
+ #canPush = true;
6465
+ #clickPositionPlugins;
6466
+ #container;
6467
+ #handlers;
6468
+ #interactionManager;
6469
+ #touches;
6376
6470
  constructor(container, interactionManager) {
6377
- this._container = container;
6378
- this._clickPositionPlugins = [];
6379
- this._interactionManager = interactionManager;
6380
- this._touches = new Map();
6381
- this._handlers = {
6471
+ this.#container = container;
6472
+ this.#clickPositionPlugins = [];
6473
+ this.#interactionManager = interactionManager;
6474
+ this.#touches = new Map();
6475
+ this.#handlers = {
6382
6476
  mouseDown: () => {
6383
- this._mouseDown();
6477
+ this.#mouseDown();
6384
6478
  },
6385
6479
  mouseLeave: () => {
6386
- this._mouseTouchFinish();
6480
+ this.#mouseTouchFinish();
6387
6481
  },
6388
6482
  mouseMove: (e) => {
6389
- this._mouseTouchMove(e);
6483
+ this.#mouseTouchMove(e);
6390
6484
  },
6391
6485
  mouseUp: (e) => {
6392
- this._mouseTouchClick(e);
6486
+ this.#mouseTouchClick(e);
6393
6487
  },
6394
6488
  touchStart: (e) => {
6395
- this._touchStart(e);
6489
+ this.#touchStart(e);
6396
6490
  },
6397
6491
  touchMove: (e) => {
6398
- this._mouseTouchMove(e);
6492
+ this.#mouseTouchMove(e);
6399
6493
  },
6400
6494
  touchEnd: (e) => {
6401
- this._touchEnd(e);
6495
+ this.#touchEnd(e);
6402
6496
  },
6403
6497
  touchCancel: (e) => {
6404
- this._touchEnd(e);
6498
+ this.#touchEnd(e);
6405
6499
  },
6406
6500
  touchEndClick: (e) => {
6407
- this._touchEndClick(e);
6501
+ this.#touchEndClick(e);
6408
6502
  },
6409
6503
  visibilityChange: () => {
6410
- this._handleVisibilityChange();
6504
+ this.#handleVisibilityChange();
6411
6505
  },
6412
6506
  };
6413
6507
  }
6414
6508
  addListeners() {
6415
- this._manageListeners(true);
6509
+ this.#manageListeners(true);
6416
6510
  }
6417
6511
  init() {
6418
- this._clickPositionPlugins.length = 0;
6419
- for (const plugin of this._container.plugins.filter(p => !!p.clickPositionValid)) {
6420
- this._clickPositionPlugins.push(plugin);
6512
+ this.#clickPositionPlugins.length = 0;
6513
+ for (const plugin of this.#container.plugins.filter(p => !!p.clickPositionValid)) {
6514
+ this.#clickPositionPlugins.push(plugin);
6421
6515
  }
6422
6516
  }
6423
6517
  removeListeners() {
6424
- this._manageListeners(false);
6518
+ this.#manageListeners(false);
6425
6519
  }
6426
- _doMouseTouchClick = e => {
6427
- const container = this._container, interactionManager = this._interactionManager, options = container.actualOptions;
6428
- if (this._canPush) {
6520
+ #doMouseTouchClick = e => {
6521
+ const container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions;
6522
+ if (this.#canPush) {
6429
6523
  const mouseInteractivity = interactionManager.interactivityData.mouse, mousePos = mouseInteractivity.position;
6430
6524
  if (!mousePos) {
6431
6525
  return;
@@ -6442,15 +6536,15 @@
6442
6536
  }
6443
6537
  if (e.type === "touchend") {
6444
6538
  setTimeout(() => {
6445
- this._mouseTouchFinish();
6539
+ this.#mouseTouchFinish();
6446
6540
  }, touchDelay);
6447
6541
  }
6448
6542
  };
6449
- _handleVisibilityChange = () => {
6450
- this._mouseTouchFinish();
6543
+ #handleVisibilityChange = () => {
6544
+ this.#mouseTouchFinish();
6451
6545
  };
6452
- _manageInteractivityListeners = add => {
6453
- const handlers = this._handlers, container = this._container, interactionManager = this._interactionManager, options = container.actualOptions, interactivityEl = interactionManager.interactivityData.element;
6546
+ #manageInteractivityListeners = add => {
6547
+ const handlers = this.#handlers, container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions, interactivityEl = interactionManager.interactivityData.element;
6454
6548
  if (!interactivityEl) {
6455
6549
  return;
6456
6550
  }
@@ -6481,8 +6575,8 @@
6481
6575
  manageListener(interactivityEl, mouseLeaveEvent, handlers.mouseLeave, add);
6482
6576
  manageListener(interactivityEl, touchCancelEvent, handlers.touchCancel, add);
6483
6577
  };
6484
- _manageListeners = add => {
6485
- const handlers = this._handlers, container = this._container, interactionManager = this._interactionManager, options = container.actualOptions, detectType = options.interactivity?.detectsOn, canvasEl = container.canvas.domElement;
6578
+ #manageListeners = add => {
6579
+ const handlers = this.#handlers, container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions, detectType = options.interactivity?.detectsOn, canvasEl = container.canvas.domElement;
6486
6580
  if (detectType === InteractivityDetect.window) {
6487
6581
  interactionManager.interactivityData.element = safeDocument();
6488
6582
  }
@@ -6492,35 +6586,35 @@
6492
6586
  else {
6493
6587
  interactionManager.interactivityData.element = canvasEl;
6494
6588
  }
6495
- this._manageInteractivityListeners(add);
6589
+ this.#manageInteractivityListeners(add);
6496
6590
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
6497
6591
  };
6498
- _mouseDown = () => {
6499
- const { interactivityData } = this._interactionManager, { mouse } = interactivityData;
6592
+ #mouseDown = () => {
6593
+ const { interactivityData } = this.#interactionManager, { mouse } = interactivityData;
6500
6594
  mouse.clicking = true;
6501
6595
  mouse.downPosition = mouse.position;
6502
6596
  };
6503
- _mouseTouchClick = e => {
6504
- const container = this._container, interactionManager = this._interactionManager, options = container.actualOptions, { mouse } = interactionManager.interactivityData;
6597
+ #mouseTouchClick = e => {
6598
+ const container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions, { mouse } = interactionManager.interactivityData;
6505
6599
  mouse.inside = true;
6506
6600
  let handled = false;
6507
6601
  const mousePosition = mouse.position;
6508
6602
  if (!mousePosition || !options.interactivity?.events.onClick.enable) {
6509
6603
  return;
6510
6604
  }
6511
- for (const plugin of this._clickPositionPlugins) {
6605
+ for (const plugin of this.#clickPositionPlugins) {
6512
6606
  handled = plugin.clickPositionValid?.(mousePosition) ?? false;
6513
6607
  if (handled) {
6514
6608
  break;
6515
6609
  }
6516
6610
  }
6517
6611
  if (!handled) {
6518
- this._doMouseTouchClick(e);
6612
+ this.#doMouseTouchClick(e);
6519
6613
  }
6520
6614
  mouse.clicking = false;
6521
6615
  };
6522
- _mouseTouchFinish = () => {
6523
- const { interactivityData } = this._interactionManager, { mouse } = interactivityData;
6616
+ #mouseTouchFinish = () => {
6617
+ const { interactivityData } = this.#interactionManager, { mouse } = interactivityData;
6524
6618
  delete mouse.position;
6525
6619
  delete mouse.clickPosition;
6526
6620
  delete mouse.downPosition;
@@ -6528,15 +6622,15 @@
6528
6622
  mouse.inside = false;
6529
6623
  mouse.clicking = false;
6530
6624
  };
6531
- _mouseTouchMove = e => {
6532
- const container = this._container, interactionManager = this._interactionManager, options = container.actualOptions, interactivity = interactionManager.interactivityData, canvasEl = container.canvas.domElement;
6625
+ #mouseTouchMove = e => {
6626
+ const container = this.#container, interactionManager = this.#interactionManager, options = container.actualOptions, interactivity = interactionManager.interactivityData, canvasEl = container.canvas.domElement;
6533
6627
  if (!interactivity.element) {
6534
6628
  return;
6535
6629
  }
6536
6630
  interactivity.mouse.inside = true;
6537
6631
  let pos;
6538
6632
  if (e.type.startsWith("pointer")) {
6539
- this._canPush = true;
6633
+ this.#canPush = true;
6540
6634
  const mouseEvent = e;
6541
6635
  if (interactivity.element === safeDocument()) {
6542
6636
  if (canvasEl) {
@@ -6571,7 +6665,7 @@
6571
6665
  }
6572
6666
  }
6573
6667
  else {
6574
- this._canPush = e.type !== "touchmove";
6668
+ this.#canPush = e.type !== "touchmove";
6575
6669
  if (canvasEl) {
6576
6670
  const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - lengthOffset], canvasRect = canvasEl.getBoundingClientRect();
6577
6671
  if (!lastTouch) {
@@ -6591,60 +6685,60 @@
6591
6685
  interactivity.mouse.position = pos;
6592
6686
  interactivity.status = mouseMoveEvent;
6593
6687
  };
6594
- _touchEnd = e => {
6688
+ #touchEnd = e => {
6595
6689
  const evt = e, touches = Array.from(evt.changedTouches);
6596
6690
  for (const touch of touches) {
6597
- this._touches.delete(touch.identifier);
6691
+ this.#touches.delete(touch.identifier);
6598
6692
  }
6599
- this._mouseTouchFinish();
6693
+ this.#mouseTouchFinish();
6600
6694
  };
6601
- _touchEndClick = e => {
6695
+ #touchEndClick = e => {
6602
6696
  const evt = e, touches = Array.from(evt.changedTouches);
6603
6697
  for (const touch of touches) {
6604
- this._touches.delete(touch.identifier);
6698
+ this.#touches.delete(touch.identifier);
6605
6699
  }
6606
- this._mouseTouchClick(e);
6700
+ this.#mouseTouchClick(e);
6607
6701
  };
6608
- _touchStart = e => {
6702
+ #touchStart = e => {
6609
6703
  const evt = e, touches = Array.from(evt.changedTouches);
6610
6704
  for (const touch of touches) {
6611
- this._touches.set(touch.identifier, performance.now());
6705
+ this.#touches.set(touch.identifier, performance.now());
6612
6706
  }
6613
- this._mouseTouchMove(e);
6707
+ this.#mouseTouchMove(e);
6614
6708
  };
6615
6709
  }
6616
6710
 
6617
6711
  const clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0;
6618
6712
  class InteractionManager {
6619
- container;
6620
6713
  interactivityData;
6621
- _clickHandlers;
6622
- _eventListeners;
6623
- _externalInteractors;
6624
- _interactors;
6625
- _intersectionObserver;
6626
- _particleInteractors;
6627
- _pluginManager;
6714
+ #clickHandlers;
6715
+ #container;
6716
+ #eventListeners;
6717
+ #externalInteractors;
6718
+ #interactors;
6719
+ #intersectionObserver;
6720
+ #particleInteractors;
6721
+ #pluginManager;
6628
6722
  constructor(pluginManager, container) {
6629
- this.container = container;
6630
- this._pluginManager = pluginManager;
6631
- this._interactors = [];
6632
- this._externalInteractors = [];
6633
- this._particleInteractors = [];
6634
- this._clickHandlers = new Map();
6635
- this._eventListeners = new InteractivityEventListeners(container, this);
6723
+ this.#container = container;
6724
+ this.#pluginManager = pluginManager;
6725
+ this.#interactors = [];
6726
+ this.#externalInteractors = [];
6727
+ this.#particleInteractors = [];
6728
+ this.#clickHandlers = new Map();
6729
+ this.#eventListeners = new InteractivityEventListeners(container, this);
6636
6730
  this.interactivityData = {
6637
6731
  mouse: {
6638
6732
  clicking: false,
6639
6733
  inside: false,
6640
6734
  },
6641
6735
  };
6642
- this._intersectionObserver = safeIntersectionObserver(entries => {
6643
- this._intersectionManager(entries);
6736
+ this.#intersectionObserver = safeIntersectionObserver(entries => {
6737
+ this.#intersectionManager(entries);
6644
6738
  });
6645
6739
  }
6646
6740
  addClickHandler(callback) {
6647
- const { container, interactivityData } = this;
6741
+ const container = this.#container, interactivityData = this.interactivityData;
6648
6742
  if (container.destroyed) {
6649
6743
  return;
6650
6744
  }
@@ -6706,119 +6800,119 @@
6706
6800
  touchMoved = false;
6707
6801
  };
6708
6802
  let touched = false, touchMoved = false;
6709
- this._clickHandlers.set(clickEvent, clickHandler);
6710
- this._clickHandlers.set(touchStartEvent, touchStartHandler);
6711
- this._clickHandlers.set(touchMoveEvent, touchMoveHandler);
6712
- this._clickHandlers.set(touchEndEvent, touchEndHandler);
6713
- this._clickHandlers.set(touchCancelEvent, touchCancelHandler);
6714
- for (const [key, handler] of this._clickHandlers) {
6803
+ this.#clickHandlers.set(clickEvent, clickHandler);
6804
+ this.#clickHandlers.set(touchStartEvent, touchStartHandler);
6805
+ this.#clickHandlers.set(touchMoveEvent, touchMoveHandler);
6806
+ this.#clickHandlers.set(touchEndEvent, touchEndHandler);
6807
+ this.#clickHandlers.set(touchCancelEvent, touchCancelHandler);
6808
+ for (const [key, handler] of this.#clickHandlers) {
6715
6809
  el.addEventListener(key, handler);
6716
6810
  }
6717
6811
  }
6718
6812
  addListeners() {
6719
- this._eventListeners.addListeners();
6813
+ this.#eventListeners.addListeners();
6720
6814
  }
6721
6815
  clearClickHandlers() {
6722
- const { container, interactivityData } = this;
6816
+ const container = this.#container, interactivityData = this.interactivityData;
6723
6817
  if (container.destroyed) {
6724
6818
  return;
6725
6819
  }
6726
- for (const [key, handler] of this._clickHandlers) {
6820
+ for (const [key, handler] of this.#clickHandlers) {
6727
6821
  interactivityData.element?.removeEventListener(key, handler);
6728
6822
  }
6729
- this._clickHandlers.clear();
6823
+ this.#clickHandlers.clear();
6730
6824
  }
6731
6825
  externalInteract(delta) {
6732
- for (const interactor of this._externalInteractors) {
6733
- const { interactivityData } = this;
6826
+ for (const interactor of this.#externalInteractors) {
6827
+ const interactivityData = this.interactivityData;
6734
6828
  if (interactor.isEnabled(interactivityData)) {
6735
6829
  interactor.interact(interactivityData, delta);
6736
6830
  }
6737
6831
  }
6738
6832
  }
6739
6833
  handleClickMode(mode) {
6740
- if (this.container.destroyed) {
6834
+ if (this.#container.destroyed) {
6741
6835
  return;
6742
6836
  }
6743
- const { interactivityData } = this;
6744
- for (const interactor of this._externalInteractors) {
6837
+ const interactivityData = this.interactivityData;
6838
+ for (const interactor of this.#externalInteractors) {
6745
6839
  interactor.handleClickMode?.(mode, interactivityData);
6746
6840
  }
6747
6841
  }
6748
6842
  init() {
6749
- this._eventListeners.init();
6750
- for (const interactor of this._interactors) {
6843
+ this.#eventListeners.init();
6844
+ for (const interactor of this.#interactors) {
6751
6845
  switch (interactor.type) {
6752
6846
  case InteractorType.external:
6753
- this._externalInteractors.push(interactor);
6847
+ this.#externalInteractors.push(interactor);
6754
6848
  break;
6755
6849
  case InteractorType.particles:
6756
- this._particleInteractors.push(interactor);
6850
+ this.#particleInteractors.push(interactor);
6757
6851
  break;
6758
6852
  }
6759
6853
  interactor.init();
6760
6854
  }
6761
6855
  }
6762
6856
  async initInteractors() {
6763
- const interactors = await this._pluginManager.getInteractors?.(this.container, true);
6857
+ const interactors = await this.#pluginManager.getInteractors?.(this.#container, true);
6764
6858
  if (!interactors) {
6765
6859
  return;
6766
6860
  }
6767
- this._interactors = interactors;
6768
- this._externalInteractors = [];
6769
- this._particleInteractors = [];
6861
+ this.#interactors = interactors;
6862
+ this.#externalInteractors = [];
6863
+ this.#particleInteractors = [];
6770
6864
  }
6771
6865
  particlesInteract(particle, delta) {
6772
- const { interactivityData } = this;
6773
- for (const interactor of this._externalInteractors) {
6866
+ const interactivityData = this.interactivityData;
6867
+ for (const interactor of this.#externalInteractors) {
6774
6868
  interactor.clear(particle, delta);
6775
6869
  }
6776
- for (const interactor of this._particleInteractors) {
6870
+ for (const interactor of this.#particleInteractors) {
6777
6871
  if (interactor.isEnabled(particle, interactivityData)) {
6778
6872
  interactor.interact(particle, interactivityData, delta);
6779
6873
  }
6780
6874
  }
6781
6875
  }
6782
6876
  removeListeners() {
6783
- this._eventListeners.removeListeners();
6877
+ this.#eventListeners.removeListeners();
6784
6878
  }
6785
6879
  reset(particle) {
6786
- const { interactivityData } = this;
6787
- for (const interactor of this._externalInteractors) {
6880
+ const interactivityData = this.interactivityData;
6881
+ for (const interactor of this.#externalInteractors) {
6788
6882
  if (interactor.isEnabled(interactivityData)) {
6789
6883
  interactor.reset(interactivityData, particle);
6790
6884
  }
6791
6885
  }
6792
- for (const interactor of this._particleInteractors) {
6886
+ for (const interactor of this.#particleInteractors) {
6793
6887
  if (interactor.isEnabled(particle, interactivityData)) {
6794
6888
  interactor.reset(interactivityData, particle);
6795
6889
  }
6796
6890
  }
6797
6891
  }
6798
6892
  startObserving() {
6799
- const { interactivityData } = this;
6800
- if (interactivityData.element instanceof HTMLElement && this._intersectionObserver) {
6801
- this._intersectionObserver.observe(interactivityData.element);
6893
+ const interactivityData = this.interactivityData;
6894
+ if (interactivityData.element instanceof HTMLElement && this.#intersectionObserver) {
6895
+ this.#intersectionObserver.observe(interactivityData.element);
6802
6896
  }
6803
6897
  }
6804
6898
  stopObserving() {
6805
- const { interactivityData } = this;
6806
- if (interactivityData.element instanceof HTMLElement && this._intersectionObserver) {
6807
- this._intersectionObserver.unobserve(interactivityData.element);
6899
+ const interactivityData = this.interactivityData;
6900
+ if (interactivityData.element instanceof HTMLElement && this.#intersectionObserver) {
6901
+ this.#intersectionObserver.unobserve(interactivityData.element);
6808
6902
  }
6809
6903
  }
6810
6904
  updateMaxDistance() {
6811
6905
  let maxTotalDistance = 0;
6812
- for (const interactor of this._interactors) {
6906
+ for (const interactor of this.#interactors) {
6813
6907
  if (interactor.maxDistance > maxTotalDistance) {
6814
6908
  maxTotalDistance = interactor.maxDistance;
6815
6909
  }
6816
6910
  }
6817
- const container = this.container;
6911
+ const container = this.#container;
6818
6912
  container.particles.grid.setCellSize(maxTotalDistance * container.retina.pixelRatio);
6819
6913
  }
6820
- _intersectionManager = entries => {
6821
- const { container } = this;
6914
+ #intersectionManager = entries => {
6915
+ const container = this.#container;
6822
6916
  if (container.destroyed || !container.actualOptions.pauseOnOutsideViewport) {
6823
6917
  return;
6824
6918
  }
@@ -6838,13 +6932,13 @@
6838
6932
 
6839
6933
  class InteractivityPluginInstance {
6840
6934
  interactionManager;
6841
- _container;
6842
- _pluginManager;
6935
+ #container;
6936
+ #pluginManager;
6843
6937
  constructor(pluginManager, container) {
6844
- this._container = container;
6845
- this._pluginManager = pluginManager;
6938
+ this.#container = container;
6939
+ this.#pluginManager = pluginManager;
6846
6940
  this.interactionManager = new InteractionManager(pluginManager, container);
6847
- this._container.addClickHandler = (callback) => {
6941
+ this.#container.addClickHandler = (callback) => {
6848
6942
  this.interactionManager.addClickHandler(callback);
6849
6943
  };
6850
6944
  }
@@ -6856,11 +6950,11 @@
6856
6950
  }
6857
6951
  destroy() {
6858
6952
  this.clearClickHandlers();
6859
- this._pluginManager.interactors?.delete(this._container);
6953
+ this.#pluginManager.interactors?.delete(this.#container);
6860
6954
  }
6861
6955
  particleCreated(particle) {
6862
- const interactivityParticle = particle, interactivity = new Interactivity(this._pluginManager, this._container);
6863
- interactivity.load(this._container.actualOptions.interactivity);
6956
+ const interactivityParticle = particle, interactivity = new Interactivity(this.#pluginManager, this.#container);
6957
+ interactivity.load(this.#container.actualOptions.interactivity);
6864
6958
  interactivity.load(interactivityParticle.options.interactivity);
6865
6959
  interactivityParticle.interactivity = interactivity;
6866
6960
  }