@tsparticles/preset-big-circles 4.0.5 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* Preset v4.0.5 */
2
+ /* Preset v4.1.1 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5
5
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -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
  }
@@ -705,38 +705,38 @@
705
705
  }
706
706
 
707
707
  class EventDispatcher {
708
- _listeners;
708
+ #listeners;
709
709
  constructor() {
710
- this._listeners = new Map();
710
+ this.#listeners = new Map();
711
711
  }
712
712
  addEventListener(type, listener) {
713
713
  this.removeEventListener(type, listener);
714
- let arr = this._listeners.get(type);
714
+ let arr = this.#listeners.get(type);
715
715
  if (!arr) {
716
716
  arr = [];
717
- this._listeners.set(type, arr);
717
+ this.#listeners.set(type, arr);
718
718
  }
719
719
  arr.push(listener);
720
720
  }
721
721
  dispatchEvent(type, args) {
722
- const listeners = this._listeners.get(type);
722
+ const listeners = this.#listeners.get(type);
723
723
  listeners?.forEach(handler => {
724
724
  handler(args);
725
725
  });
726
726
  }
727
727
  hasEventListener(type) {
728
- return !!this._listeners.get(type);
728
+ return !!this.#listeners.get(type);
729
729
  }
730
730
  removeAllEventListeners(type) {
731
731
  if (!type) {
732
- this._listeners = new Map();
732
+ this.#listeners = new Map();
733
733
  }
734
734
  else {
735
- this._listeners.delete(type);
735
+ this.#listeners.delete(type);
736
736
  }
737
737
  }
738
738
  removeEventListener(type, listener) {
739
- const arr = this._listeners.get(type);
739
+ const arr = this.#listeners.get(type);
740
740
  if (!arr) {
741
741
  return;
742
742
  }
@@ -745,7 +745,7 @@
745
745
  return;
746
746
  }
747
747
  if (length === deleteCount) {
748
- this._listeners.delete(type);
748
+ this.#listeners.delete(type);
749
749
  }
750
750
  else {
751
751
  arr.splice(idx, deleteCount);
@@ -783,19 +783,19 @@
783
783
  presets = new Map();
784
784
  shapeDrawers = new Map();
785
785
  updaters = new Map();
786
- _allLoadersSet = new Set();
787
- _configs = new Map();
788
- _engine;
789
- _executedSet = new Set();
790
- _initialized = false;
791
- _isRunningLoaders = false;
792
- _loadPromises = new Set();
786
+ #allLoadersSet = new Set();
787
+ #configs = new Map();
788
+ #engine;
789
+ #executedSet = new Set();
790
+ #initialized = false;
791
+ #isRunningLoaders = false;
792
+ #loadPromises = new Set();
793
793
  constructor(engine) {
794
- this._engine = engine;
794
+ this.#engine = engine;
795
795
  }
796
796
  get configs() {
797
797
  const res = {};
798
- for (const [name, config] of this._configs) {
798
+ for (const [name, config] of this.#configs) {
799
799
  res[name] = config;
800
800
  }
801
801
  return res;
@@ -805,8 +805,8 @@
805
805
  }
806
806
  addConfig(config) {
807
807
  const key = config.key ?? config.name ?? "default";
808
- this._configs.set(key, config);
809
- this._engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
808
+ this.#configs.set(key, config);
809
+ this.#engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
810
810
  }
811
811
  addEasing(name, easing) {
812
812
  if (this.easingFunctions.get(name)) {
@@ -867,21 +867,21 @@
867
867
  return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
868
868
  }
869
869
  async init() {
870
- if (this._initialized || this._isRunningLoaders) {
870
+ if (this.#initialized || this.#isRunningLoaders) {
871
871
  return;
872
872
  }
873
- this._isRunningLoaders = true;
874
- this._executedSet = new Set();
875
- this._allLoadersSet = new Set(this._loadPromises);
873
+ this.#isRunningLoaders = true;
874
+ this.#executedSet = new Set();
875
+ this.#allLoadersSet = new Set(this.#loadPromises);
876
876
  try {
877
- for (const loader of this._allLoadersSet) {
878
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
877
+ for (const loader of this.#allLoadersSet) {
878
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
879
879
  }
880
880
  }
881
881
  finally {
882
- this._loadPromises.clear();
883
- this._isRunningLoaders = false;
884
- this._initialized = true;
882
+ this.#loadPromises.clear();
883
+ this.#isRunningLoaders = false;
884
+ this.#initialized = true;
885
885
  }
886
886
  }
887
887
  loadParticlesOptions(container, options, ...sourceOptions) {
@@ -892,24 +892,24 @@
892
892
  updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
893
893
  }
894
894
  async register(...loaders) {
895
- if (this._initialized) {
895
+ if (this.#initialized) {
896
896
  throw new Error("Register plugins can only be done before calling tsParticles.load()");
897
897
  }
898
898
  for (const loader of loaders) {
899
- if (this._isRunningLoaders) {
900
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
899
+ if (this.#isRunningLoaders) {
900
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
901
901
  }
902
902
  else {
903
- this._loadPromises.add(loader);
903
+ this.#loadPromises.add(loader);
904
904
  }
905
905
  }
906
906
  }
907
- async _runLoader(loader, executed, allLoaders) {
907
+ async #runLoader(loader, executed, allLoaders) {
908
908
  if (executed.has(loader))
909
909
  return;
910
910
  executed.add(loader);
911
911
  allLoaders.add(loader);
912
- await loader(this._engine);
912
+ await loader(this.#engine);
913
913
  }
914
914
  }
915
915
 
@@ -989,17 +989,17 @@
989
989
  };
990
990
  class Engine {
991
991
  pluginManager = new PluginManager(this);
992
- _domArray = [];
993
- _eventDispatcher = new EventDispatcher();
994
- _initialized = false;
992
+ #domArray = [];
993
+ #eventDispatcher = new EventDispatcher();
994
+ #initialized = false;
995
995
  get items() {
996
- return this._domArray;
996
+ return this.#domArray;
997
997
  }
998
998
  get version() {
999
- return "4.0.5";
999
+ return "4.1.1";
1000
1000
  }
1001
1001
  addEventListener(type, listener) {
1002
- this._eventDispatcher.addEventListener(type, listener);
1002
+ this.#eventDispatcher.addEventListener(type, listener);
1003
1003
  }
1004
1004
  checkVersion(pluginVersion) {
1005
1005
  if (this.version === pluginVersion) {
@@ -1008,17 +1008,17 @@
1008
1008
  throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
1009
1009
  }
1010
1010
  dispatchEvent(type, args) {
1011
- this._eventDispatcher.dispatchEvent(type, args);
1011
+ this.#eventDispatcher.dispatchEvent(type, args);
1012
1012
  }
1013
1013
  async init() {
1014
- if (this._initialized) {
1014
+ if (this.#initialized) {
1015
1015
  return;
1016
1016
  }
1017
1017
  await this.pluginManager.init();
1018
- this._initialized = true;
1018
+ this.#initialized = true;
1019
1019
  }
1020
1020
  item(index) {
1021
- const { items } = this, item = items[index];
1021
+ const items = this.items, item = items[index];
1022
1022
  if (item?.destroyed) {
1023
1023
  items.splice(index, removeDeleteCount);
1024
1024
  return;
@@ -1072,7 +1072,7 @@
1072
1072
  await Promise.all(this.items.map(t => t.refresh()));
1073
1073
  }
1074
1074
  removeEventListener(type, listener) {
1075
- this._eventDispatcher.removeEventListener(type, listener);
1075
+ this.#eventDispatcher.removeEventListener(type, listener);
1076
1076
  }
1077
1077
  }
1078
1078
 
@@ -1843,43 +1843,6 @@
1843
1843
  }
1844
1844
  }
1845
1845
 
1846
- class OpacityAnimation extends RangedAnimationOptions {
1847
- destroy;
1848
- constructor() {
1849
- super();
1850
- this.destroy = DestroyType.none;
1851
- this.speed = 2;
1852
- }
1853
- load(data) {
1854
- super.load(data);
1855
- if (isNull(data)) {
1856
- return;
1857
- }
1858
- if (data.destroy !== undefined) {
1859
- this.destroy = data.destroy;
1860
- }
1861
- }
1862
- }
1863
-
1864
- class Opacity extends RangedAnimationValueWithRandom {
1865
- animation;
1866
- constructor() {
1867
- super();
1868
- this.animation = new OpacityAnimation();
1869
- this.value = 1;
1870
- }
1871
- load(data) {
1872
- if (isNull(data)) {
1873
- return;
1874
- }
1875
- super.load(data);
1876
- const animation = data.animation;
1877
- if (animation !== undefined) {
1878
- this.animation.load(animation);
1879
- }
1880
- }
1881
- }
1882
-
1883
1846
  class Stroke {
1884
1847
  color;
1885
1848
  opacity;
@@ -2047,43 +2010,6 @@
2047
2010
  }
2048
2011
  }
2049
2012
 
2050
- class SizeAnimation extends RangedAnimationOptions {
2051
- destroy;
2052
- constructor() {
2053
- super();
2054
- this.destroy = DestroyType.none;
2055
- this.speed = 5;
2056
- }
2057
- load(data) {
2058
- super.load(data);
2059
- if (isNull(data)) {
2060
- return;
2061
- }
2062
- if (data.destroy !== undefined) {
2063
- this.destroy = data.destroy;
2064
- }
2065
- }
2066
- }
2067
-
2068
- class Size extends RangedAnimationValueWithRandom {
2069
- animation;
2070
- constructor() {
2071
- super();
2072
- this.animation = new SizeAnimation();
2073
- this.value = 3;
2074
- }
2075
- load(data) {
2076
- super.load(data);
2077
- if (isNull(data)) {
2078
- return;
2079
- }
2080
- const animation = data.animation;
2081
- if (animation !== undefined) {
2082
- this.animation.load(animation);
2083
- }
2084
- }
2085
- }
2086
-
2087
2013
  class ZIndex extends ValueWithRandom {
2088
2014
  opacityRate;
2089
2015
  sizeRate;
@@ -2117,24 +2043,21 @@
2117
2043
  groups;
2118
2044
  move;
2119
2045
  number;
2120
- opacity;
2121
2046
  paint;
2122
2047
  palette;
2123
2048
  reduceDuplicates;
2124
2049
  shape;
2125
- size;
2126
2050
  zIndex;
2127
- _container;
2128
- _pluginManager;
2051
+ #container;
2052
+ #pluginManager;
2129
2053
  constructor(pluginManager, container) {
2130
- this._pluginManager = pluginManager;
2131
- this._container = container;
2054
+ this.#pluginManager = pluginManager;
2055
+ this.#container = container;
2132
2056
  this.bounce = new ParticlesBounce();
2133
2057
  this.effect = new Effect();
2134
2058
  this.groups = {};
2135
2059
  this.move = new Move();
2136
2060
  this.number = new ParticlesNumber();
2137
- this.opacity = new Opacity();
2138
2061
  this.paint = new Paint();
2139
2062
  this.paint.color = new AnimatableColor();
2140
2063
  this.paint.color.value = "#fff";
@@ -2142,7 +2065,6 @@
2142
2065
  this.paint.fill.enable = true;
2143
2066
  this.reduceDuplicates = false;
2144
2067
  this.shape = new Shape();
2145
- this.size = new Size();
2146
2068
  this.zIndex = new ZIndex();
2147
2069
  }
2148
2070
  load(data) {
@@ -2151,7 +2073,7 @@
2151
2073
  }
2152
2074
  if (data.palette) {
2153
2075
  this.palette = data.palette;
2154
- this._importPalette(this.palette);
2076
+ this.#importPalette(this.palette);
2155
2077
  }
2156
2078
  if (data.groups !== undefined) {
2157
2079
  for (const group of Object.keys(data.groups)) {
@@ -2171,7 +2093,6 @@
2171
2093
  this.effect.load(data.effect);
2172
2094
  this.move.load(data.move);
2173
2095
  this.number.load(data.number);
2174
- this.opacity.load(data.opacity);
2175
2096
  const paintToLoad = data.paint;
2176
2097
  if (paintToLoad) {
2177
2098
  if (isArray(paintToLoad)) {
@@ -2190,15 +2111,14 @@
2190
2111
  }
2191
2112
  }
2192
2113
  this.shape.load(data.shape);
2193
- this.size.load(data.size);
2194
2114
  this.zIndex.load(data.zIndex);
2195
- if (this._container) {
2196
- for (const plugin of this._pluginManager.plugins) {
2115
+ if (this.#container) {
2116
+ for (const plugin of this.#pluginManager.plugins) {
2197
2117
  if (plugin.loadParticlesOptions) {
2198
- plugin.loadParticlesOptions(this._container, this, data);
2118
+ plugin.loadParticlesOptions(this.#container, this, data);
2199
2119
  }
2200
2120
  }
2201
- const updaters = this._pluginManager.updaters.get(this._container);
2121
+ const updaters = this.#pluginManager.updaters.get(this.#container);
2202
2122
  if (updaters) {
2203
2123
  for (const updater of updaters) {
2204
2124
  if (updater.loadOptions) {
@@ -2208,8 +2128,8 @@
2208
2128
  }
2209
2129
  }
2210
2130
  }
2211
- _importPalette = (palette) => {
2212
- const paletteData = this._pluginManager.getPalette(palette);
2131
+ #importPalette = (palette) => {
2132
+ const paletteData = this.#pluginManager.getPalette(palette);
2213
2133
  if (!paletteData) {
2214
2134
  return;
2215
2135
  }
@@ -2288,11 +2208,11 @@
2288
2208
  smooth;
2289
2209
  style;
2290
2210
  zLayers;
2291
- _container;
2292
- _pluginManager;
2211
+ #container;
2212
+ #pluginManager;
2293
2213
  constructor(pluginManager, container) {
2294
- this._pluginManager = pluginManager;
2295
- this._container = container;
2214
+ this.#pluginManager = pluginManager;
2215
+ this.#container = container;
2296
2216
  this.autoPlay = true;
2297
2217
  this.background = new Background();
2298
2218
  this.clear = true;
@@ -2303,7 +2223,7 @@
2303
2223
  this.duration = 0;
2304
2224
  this.fpsLimit = 120;
2305
2225
  this.hdr = true;
2306
- this.particles = loadParticlesOptions(this._pluginManager, this._container);
2226
+ this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2307
2227
  this.pauseOnBlur = true;
2308
2228
  this.pauseOnOutsideViewport = true;
2309
2229
  this.resize = new ResizeEvent();
@@ -2318,12 +2238,12 @@
2318
2238
  if (data.preset !== undefined) {
2319
2239
  this.preset = data.preset;
2320
2240
  executeOnSingleOrMultiple(this.preset, preset => {
2321
- this._importPreset(preset);
2241
+ this.#importPreset(preset);
2322
2242
  });
2323
2243
  }
2324
2244
  if (data.palette !== undefined) {
2325
2245
  this.palette = data.palette;
2326
- this._importPalette(this.palette);
2246
+ this.#importPalette(this.palette);
2327
2247
  }
2328
2248
  if (data.autoPlay !== undefined) {
2329
2249
  this.autoPlay = data.autoPlay;
@@ -2377,12 +2297,12 @@
2377
2297
  if (data.smooth !== undefined) {
2378
2298
  this.smooth = data.smooth;
2379
2299
  }
2380
- this._pluginManager.plugins.forEach(plugin => {
2381
- plugin.loadOptions(this._container, this, data);
2300
+ this.#pluginManager.plugins.forEach(plugin => {
2301
+ plugin.loadOptions(this.#container, this, data);
2382
2302
  });
2383
2303
  }
2384
- _importPalette = palette => {
2385
- const paletteData = this._pluginManager.getPalette(palette);
2304
+ #importPalette = palette => {
2305
+ const paletteData = this.#pluginManager.getPalette(palette);
2386
2306
  if (!paletteData) {
2387
2307
  return;
2388
2308
  }
@@ -2399,8 +2319,8 @@
2399
2319
  },
2400
2320
  });
2401
2321
  };
2402
- _importPreset = preset => {
2403
- this.load(this._pluginManager.getPreset(preset));
2322
+ #importPreset = preset => {
2323
+ this.load(this.#pluginManager.getPreset(preset));
2404
2324
  };
2405
2325
  }
2406
2326
 
@@ -2869,7 +2789,7 @@
2869
2789
  }
2870
2790
 
2871
2791
  async function loadBlendPlugin(engine) {
2872
- engine.checkVersion("4.0.5");
2792
+ engine.checkVersion("4.1.1");
2873
2793
  await engine.pluginManager.register(e => {
2874
2794
  e.pluginManager.addPlugin(new BlendPlugin());
2875
2795
  });
@@ -2906,7 +2826,7 @@
2906
2826
  }
2907
2827
 
2908
2828
  async function loadCircleShape(engine) {
2909
- engine.checkVersion("4.0.5");
2829
+ engine.checkVersion("4.1.1");
2910
2830
  await engine.pluginManager.register(e => {
2911
2831
  e.pluginManager.addShape(["circle"], () => {
2912
2832
  return Promise.resolve(new CircleDrawer());
@@ -2927,15 +2847,15 @@
2927
2847
  return input.startsWith("#");
2928
2848
  }
2929
2849
  handleColor(color) {
2930
- return this._parseString(color.value);
2850
+ return this.#parseString(color.value);
2931
2851
  }
2932
2852
  handleRangeColor(color) {
2933
- return this._parseString(color.value);
2853
+ return this.#parseString(color.value);
2934
2854
  }
2935
2855
  parseString(input) {
2936
- return this._parseString(input);
2856
+ return this.#parseString(input);
2937
2857
  }
2938
- _parseString(hexColor) {
2858
+ #parseString(hexColor) {
2939
2859
  if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
2940
2860
  return;
2941
2861
  }
@@ -2954,7 +2874,7 @@
2954
2874
  }
2955
2875
 
2956
2876
  async function loadHexColorPlugin(engine) {
2957
- engine.checkVersion("4.0.5");
2877
+ engine.checkVersion("4.1.1");
2958
2878
  await engine.pluginManager.register(e => {
2959
2879
  e.pluginManager.addColorManager("hex", new HexColorManager());
2960
2880
  });
@@ -3007,7 +2927,7 @@
3007
2927
  }
3008
2928
 
3009
2929
  async function loadHslColorPlugin(engine) {
3010
- engine.checkVersion("4.0.5");
2930
+ engine.checkVersion("4.1.1");
3011
2931
  await engine.pluginManager.register(e => {
3012
2932
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3013
2933
  });
@@ -3015,13 +2935,13 @@
3015
2935
 
3016
2936
  class MovePlugin {
3017
2937
  id = "move";
3018
- _pluginManager;
2938
+ #pluginManager;
3019
2939
  constructor(pluginManager) {
3020
- this._pluginManager = pluginManager;
2940
+ this.#pluginManager = pluginManager;
3021
2941
  }
3022
2942
  async getPlugin(container) {
3023
2943
  const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
3024
- return new MovePluginInstance(this._pluginManager, container);
2944
+ return new MovePluginInstance(this.#pluginManager, container);
3025
2945
  }
3026
2946
  loadOptions() {
3027
2947
  }
@@ -3031,7 +2951,7 @@
3031
2951
  }
3032
2952
 
3033
2953
  async function loadMovePlugin(engine) {
3034
- engine.checkVersion("4.0.5");
2954
+ engine.checkVersion("4.1.1");
3035
2955
  await engine.pluginManager.register(e => {
3036
2956
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3037
2957
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3049,18 +2969,58 @@
3049
2969
  });
3050
2970
  }
3051
2971
 
2972
+ class OpacityAnimation extends RangedAnimationOptions {
2973
+ destroy;
2974
+ constructor() {
2975
+ super();
2976
+ this.destroy = DestroyType.none;
2977
+ this.speed = 2;
2978
+ }
2979
+ load(data) {
2980
+ super.load(data);
2981
+ if (isNull(data)) {
2982
+ return;
2983
+ }
2984
+ if (data.destroy !== undefined) {
2985
+ this.destroy = data.destroy;
2986
+ }
2987
+ }
2988
+ }
2989
+
2990
+ class Opacity extends RangedAnimationValueWithRandom {
2991
+ animation;
2992
+ constructor() {
2993
+ super();
2994
+ this.animation = new OpacityAnimation();
2995
+ this.value = 1;
2996
+ }
2997
+ load(data) {
2998
+ if (isNull(data)) {
2999
+ return;
3000
+ }
3001
+ super.load(data);
3002
+ const animation = data.animation;
3003
+ if (animation !== undefined) {
3004
+ this.animation.load(animation);
3005
+ }
3006
+ }
3007
+ }
3008
+
3052
3009
  class OpacityUpdater {
3053
- container;
3010
+ #container;
3054
3011
  constructor(container) {
3055
- this.container = container;
3012
+ this.#container = container;
3056
3013
  }
3057
3014
  init(particle) {
3058
3015
  const opacityOptions = particle.options.opacity, pxRatio = 1;
3016
+ if (!opacityOptions) {
3017
+ return;
3018
+ }
3059
3019
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
3060
3020
  const opacityAnimation = opacityOptions.animation;
3061
3021
  if (opacityAnimation.enable) {
3062
3022
  particle.opacity.velocity =
3063
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
3023
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
3064
3024
  if (!opacityAnimation.sync) {
3065
3025
  particle.opacity.velocity *= getRandom();
3066
3026
  }
@@ -3076,6 +3036,12 @@
3076
3036
  ((particle.opacity.maxLoops ?? none) > none &&
3077
3037
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3078
3038
  }
3039
+ loadOptions(options, ...sources) {
3040
+ options.opacity ??= new Opacity();
3041
+ for (const source of sources) {
3042
+ options.opacity.load(source?.opacity);
3043
+ }
3044
+ }
3079
3045
  reset(particle) {
3080
3046
  if (!particle.opacity) {
3081
3047
  return;
@@ -3084,7 +3050,7 @@
3084
3050
  particle.opacity.loops = 0;
3085
3051
  }
3086
3052
  update(particle, delta) {
3087
- if (!this.isEnabled(particle) || !particle.opacity) {
3053
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
3088
3054
  return;
3089
3055
  }
3090
3056
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -3092,7 +3058,7 @@
3092
3058
  }
3093
3059
 
3094
3060
  async function loadOpacityUpdater(engine) {
3095
- engine.checkVersion("4.0.5");
3061
+ engine.checkVersion("4.1.1");
3096
3062
  await engine.pluginManager.register(e => {
3097
3063
  e.pluginManager.addParticleUpdater("opacity", container => {
3098
3064
  return Promise.resolve(new OpacityUpdater(container));
@@ -3114,10 +3080,9 @@
3114
3080
  }
3115
3081
  const velocity = data.particle.velocity.x;
3116
3082
  let bounced = false;
3117
- if ((data.direction === OutModeDirection.right &&
3118
- data.bounds.right >= data.canvasSize.width &&
3119
- velocity > minVelocity$4) ||
3120
- (data.direction === OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity$4)) {
3083
+ if (data.outOfCanvas &&
3084
+ ((data.direction === OutModeDirection.right && velocity > minVelocity$4) ||
3085
+ (data.direction === OutModeDirection.left && velocity < minVelocity$4))) {
3121
3086
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3122
3087
  data.particle.velocity.x *= -newVelocity;
3123
3088
  bounced = true;
@@ -3126,10 +3091,10 @@
3126
3091
  return;
3127
3092
  }
3128
3093
  const minPos = data.offset.x + data.size;
3129
- if (data.bounds.right >= data.canvasSize.width && data.direction === OutModeDirection.right) {
3094
+ if (data.outOfCanvas && data.direction === OutModeDirection.right) {
3130
3095
  data.particle.position.x = data.canvasSize.width - minPos;
3131
3096
  }
3132
- else if (data.bounds.left <= boundsMin && data.direction === OutModeDirection.left) {
3097
+ else if (data.outOfCanvas && data.direction === OutModeDirection.left) {
3133
3098
  data.particle.position.x = minPos;
3134
3099
  }
3135
3100
  if (data.outMode === OutMode.split) {
@@ -3149,10 +3114,9 @@
3149
3114
  }
3150
3115
  const velocity = data.particle.velocity.y;
3151
3116
  let bounced = false;
3152
- if ((data.direction === OutModeDirection.bottom &&
3153
- data.bounds.bottom >= data.canvasSize.height &&
3154
- velocity > minVelocity$4) ||
3155
- (data.direction === OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity$4)) {
3117
+ if (data.outOfCanvas &&
3118
+ ((data.direction === OutModeDirection.bottom && velocity > minVelocity$4) ||
3119
+ (data.direction === OutModeDirection.top && velocity < minVelocity$4))) {
3156
3120
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3157
3121
  data.particle.velocity.y *= -newVelocity;
3158
3122
  bounced = true;
@@ -3161,10 +3125,10 @@
3161
3125
  return;
3162
3126
  }
3163
3127
  const minPos = data.offset.y + data.size;
3164
- if (data.bounds.bottom >= data.canvasSize.height && data.direction === OutModeDirection.bottom) {
3128
+ if (data.outOfCanvas && data.direction === OutModeDirection.bottom) {
3165
3129
  data.particle.position.y = data.canvasSize.height - minPos;
3166
3130
  }
3167
- else if (data.bounds.top <= boundsMin && data.direction === OutModeDirection.top) {
3131
+ else if (data.outOfCanvas && data.direction === OutModeDirection.top) {
3168
3132
  data.particle.position.y = minPos;
3169
3133
  }
3170
3134
  if (data.outMode === OutMode.split) {
@@ -3173,24 +3137,24 @@
3173
3137
  }
3174
3138
 
3175
3139
  class BounceOutMode {
3176
- container;
3177
3140
  modes;
3178
- _particleBouncePlugins;
3141
+ #container;
3142
+ #particleBouncePlugins;
3179
3143
  constructor(container) {
3180
- this.container = container;
3144
+ this.#container = container;
3181
3145
  this.modes = [
3182
3146
  OutMode.bounce,
3183
3147
  OutMode.split,
3184
3148
  ];
3185
- this._particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3149
+ this.#particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3186
3150
  }
3187
3151
  update(particle, direction, delta, outMode) {
3188
3152
  if (!this.modes.includes(outMode)) {
3189
3153
  return;
3190
3154
  }
3191
- const container = this.container;
3155
+ const container = this.#container;
3192
3156
  let handled = false;
3193
- for (const plugin of this._particleBouncePlugins) {
3157
+ for (const plugin of this.#particleBouncePlugins) {
3194
3158
  handled = plugin.particleBounce?.(particle, delta, direction) ?? false;
3195
3159
  if (handled) {
3196
3160
  break;
@@ -3199,29 +3163,26 @@
3199
3163
  if (handled) {
3200
3164
  return;
3201
3165
  }
3202
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size;
3203
- bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
3204
- bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
3166
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, outOfCanvas = !particle.isInsideCanvasForOutMode(outMode, direction);
3167
+ bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3168
+ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3205
3169
  }
3206
3170
  }
3207
3171
 
3208
3172
  const minVelocity$3 = 0;
3209
3173
  class DestroyOutMode {
3210
- container;
3211
3174
  modes;
3212
- constructor(container) {
3213
- this.container = container;
3175
+ constructor(_container) {
3214
3176
  this.modes = [OutMode.destroy];
3215
3177
  }
3216
3178
  update(particle, direction, _delta, outMode) {
3217
3179
  if (!this.modes.includes(outMode)) {
3218
3180
  return;
3219
3181
  }
3220
- const container = this.container;
3221
3182
  switch (particle.outType) {
3222
3183
  case ParticleOutType.normal:
3223
3184
  case ParticleOutType.outside:
3224
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3185
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3225
3186
  return;
3226
3187
  }
3227
3188
  break;
@@ -3242,10 +3203,10 @@
3242
3203
 
3243
3204
  const minVelocity$2 = 0;
3244
3205
  class NoneOutMode {
3245
- container;
3246
3206
  modes;
3207
+ #container;
3247
3208
  constructor(container) {
3248
- this.container = container;
3209
+ this.#container = container;
3249
3210
  this.modes = [OutMode.none];
3250
3211
  }
3251
3212
  update(particle, direction, _delta, outMode) {
@@ -3258,7 +3219,7 @@
3258
3219
  (direction === OutModeDirection.top || direction === OutModeDirection.bottom))) {
3259
3220
  return;
3260
3221
  }
3261
- const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3222
+ const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3262
3223
  if (!gravityOptions.enable) {
3263
3224
  if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3264
3225
  (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
@@ -3284,17 +3245,17 @@
3284
3245
 
3285
3246
  const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
3286
3247
  class OutOutMode {
3287
- container;
3288
3248
  modes;
3249
+ #container;
3289
3250
  constructor(container) {
3290
- this.container = container;
3251
+ this.#container = container;
3291
3252
  this.modes = [OutMode.out];
3292
3253
  }
3293
3254
  update(particle, direction, _delta, outMode) {
3294
3255
  if (!this.modes.includes(outMode)) {
3295
3256
  return;
3296
3257
  }
3297
- const container = this.container;
3258
+ const container = this.#container;
3298
3259
  switch (particle.outType) {
3299
3260
  case ParticleOutType.inside: {
3300
3261
  const { x: vx, y: vy } = particle.velocity;
@@ -3324,7 +3285,7 @@
3324
3285
  break;
3325
3286
  }
3326
3287
  default: {
3327
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3288
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3328
3289
  return;
3329
3290
  }
3330
3291
  switch (particle.outType) {
@@ -3408,16 +3369,16 @@
3408
3369
  };
3409
3370
  class OutOfCanvasUpdater {
3410
3371
  updaters;
3411
- container;
3372
+ #container;
3412
3373
  constructor(container) {
3413
- this.container = container;
3374
+ this.#container = container;
3414
3375
  this.updaters = new Map();
3415
3376
  }
3416
3377
  init(particle) {
3417
- this._addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3418
- this._addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3419
- this._addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3420
- this._addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3378
+ this.#addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3379
+ this.#addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3380
+ this.#addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3381
+ this.#addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3421
3382
  }
3422
3383
  isEnabled(particle) {
3423
3384
  return !particle.destroyed && !particle.spawning;
@@ -3425,18 +3386,18 @@
3425
3386
  update(particle, delta) {
3426
3387
  const outModes = particle.options.move.outModes;
3427
3388
  particle.justWarped = false;
3428
- this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3429
- this._updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3430
- this._updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3431
- this._updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3389
+ this.#updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3390
+ this.#updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3391
+ this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3392
+ this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3432
3393
  }
3433
- _addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3394
+ #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3434
3395
  const outModes = particle.options.move.outModes;
3435
3396
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3436
- this.updaters.set(outMode, getUpdater(this.container));
3397
+ this.updaters.set(outMode, getUpdater(this.#container));
3437
3398
  }
3438
3399
  };
3439
- _updateOutMode = (particle, delta, outMode, direction) => {
3400
+ #updateOutMode = (particle, delta, outMode, direction) => {
3440
3401
  for (const updater of this.updaters.values()) {
3441
3402
  updater.update(particle, direction, delta, outMode);
3442
3403
  }
@@ -3444,7 +3405,7 @@
3444
3405
  }
3445
3406
 
3446
3407
  async function loadOutModesUpdater(engine) {
3447
- engine.checkVersion("4.0.5");
3408
+ engine.checkVersion("4.1.1");
3448
3409
  await engine.pluginManager.register(e => {
3449
3410
  e.pluginManager.addParticleUpdater("outModes", container => {
3450
3411
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3454,20 +3415,20 @@
3454
3415
 
3455
3416
  const defaultOpacity = 1;
3456
3417
  class PaintUpdater {
3457
- _container;
3458
- _pluginManager;
3418
+ #container;
3419
+ #pluginManager;
3459
3420
  constructor(pluginManager, container) {
3460
- this._container = container;
3461
- this._pluginManager = pluginManager;
3421
+ this.#container = container;
3422
+ this.#pluginManager = pluginManager;
3462
3423
  }
3463
3424
  init(particle) {
3464
- 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;
3425
+ 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;
3465
3426
  if (fill) {
3466
3427
  const fillColor = AnimatableColor.create(paintColor === undefined ? undefined : AnimatableColor.create(undefined, paintColor), fill.color);
3467
3428
  particle.fillEnabled = fill.enable;
3468
3429
  particle.fillOpacity = getRangeValue(fill.opacity);
3469
3430
  particle.fillAnimation = fillColor.animation;
3470
- const fillHslColor = rangeColorToHsl(this._pluginManager, fillColor);
3431
+ const fillHslColor = rangeColorToHsl(this.#pluginManager, fillColor);
3471
3432
  if (fillHslColor) {
3472
3433
  particle.fillColor = getHslAnimationFromHsl(fillHslColor, particle.fillAnimation, container.retina.reduceFactor);
3473
3434
  }
@@ -3483,7 +3444,7 @@
3483
3444
  particle.strokeWidth = getRangeValue(stroke.width) * container.retina.pixelRatio;
3484
3445
  particle.strokeOpacity = getRangeValue(stroke.opacity ?? defaultOpacity);
3485
3446
  particle.strokeAnimation = strokeColor.animation;
3486
- const strokeHslColor = rangeColorToHsl(this._pluginManager, strokeColor) ?? particle.getFillColor();
3447
+ const strokeHslColor = rangeColorToHsl(this.#pluginManager, strokeColor) ?? particle.getFillColor();
3487
3448
  if (strokeHslColor) {
3488
3449
  particle.strokeColor = getHslAnimationFromHsl(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
3489
3450
  }
@@ -3515,7 +3476,7 @@
3515
3476
  }
3516
3477
 
3517
3478
  async function loadPaintUpdater(engine) {
3518
- engine.checkVersion("4.0.5");
3479
+ engine.checkVersion("4.1.1");
3519
3480
  await engine.pluginManager.register(e => {
3520
3481
  e.pluginManager.addParticleUpdater("paint", container => {
3521
3482
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3570,27 +3531,69 @@
3570
3531
  }
3571
3532
 
3572
3533
  async function loadRgbColorPlugin(engine) {
3573
- engine.checkVersion("4.0.5");
3534
+ engine.checkVersion("4.1.1");
3574
3535
  await engine.pluginManager.register(e => {
3575
3536
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3576
3537
  });
3577
3538
  }
3578
3539
 
3540
+ class SizeAnimation extends RangedAnimationOptions {
3541
+ destroy;
3542
+ constructor() {
3543
+ super();
3544
+ this.destroy = DestroyType.none;
3545
+ this.speed = 5;
3546
+ }
3547
+ load(data) {
3548
+ super.load(data);
3549
+ if (isNull(data)) {
3550
+ return;
3551
+ }
3552
+ if (data.destroy !== undefined) {
3553
+ this.destroy = data.destroy;
3554
+ }
3555
+ }
3556
+ }
3557
+
3558
+ class Size extends RangedAnimationValueWithRandom {
3559
+ animation;
3560
+ constructor() {
3561
+ super();
3562
+ this.animation = new SizeAnimation();
3563
+ this.value = 3;
3564
+ }
3565
+ load(data) {
3566
+ super.load(data);
3567
+ if (isNull(data)) {
3568
+ return;
3569
+ }
3570
+ const animation = data.animation;
3571
+ if (animation !== undefined) {
3572
+ this.animation.load(animation);
3573
+ }
3574
+ }
3575
+ }
3576
+
3579
3577
  const minLoops = 0;
3580
3578
  class SizeUpdater {
3581
- _container;
3579
+ #container;
3582
3580
  constructor(container) {
3583
- this._container = container;
3581
+ this.#container = container;
3584
3582
  }
3585
3583
  init(particle) {
3586
- const container = this._container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
3587
- if (sizeAnimation.enable) {
3588
- particle.size.velocity =
3589
- (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3590
- if (!sizeAnimation.sync) {
3591
- particle.size.velocity *= getRandom();
3592
- }
3584
+ const container = this.#container, sizeOptions = particle.options.size;
3585
+ if (!sizeOptions) {
3586
+ return;
3593
3587
  }
3588
+ const sizeAnimation = sizeOptions.animation;
3589
+ if (!sizeAnimation.enable) {
3590
+ return;
3591
+ }
3592
+ particle.size.velocity = (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3593
+ if (sizeAnimation.sync) {
3594
+ return;
3595
+ }
3596
+ particle.size.velocity *= getRandom();
3594
3597
  }
3595
3598
  isEnabled(particle) {
3596
3599
  return (!particle.destroyed &&
@@ -3600,12 +3603,26 @@
3600
3603
  ((particle.size.maxLoops ?? minLoops) > minLoops &&
3601
3604
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3602
3605
  }
3606
+ loadOptions(options, ...sources) {
3607
+ options.size ??= new Size();
3608
+ for (const source of sources) {
3609
+ options.size.load(source?.size);
3610
+ }
3611
+ }
3612
+ preInit(particle) {
3613
+ const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
3614
+ if (!sizeOptions) {
3615
+ return;
3616
+ }
3617
+ particle.size = initParticleNumericAnimationValue(sizeOptions, pxRatio);
3618
+ particle.retina.sizeAnimationSpeed = getRangeValue(sizeOptions.animation.speed) * pxRatio;
3619
+ }
3603
3620
  reset(particle) {
3604
3621
  particle.size.time = 0;
3605
3622
  particle.size.loops = 0;
3606
3623
  }
3607
3624
  update(particle, delta) {
3608
- if (!this.isEnabled(particle)) {
3625
+ if (!this.isEnabled(particle) || !particle.options.size) {
3609
3626
  return;
3610
3627
  }
3611
3628
  updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
@@ -3613,7 +3630,7 @@
3613
3630
  }
3614
3631
 
3615
3632
  async function loadSizeUpdater(engine) {
3616
- engine.checkVersion("4.0.5");
3633
+ engine.checkVersion("4.1.1");
3617
3634
  await engine.pluginManager.register(e => {
3618
3635
  e.pluginManager.addParticleUpdater("size", container => {
3619
3636
  return Promise.resolve(new SizeUpdater(container));
@@ -3622,7 +3639,7 @@
3622
3639
  }
3623
3640
 
3624
3641
  async function loadBasic(engine) {
3625
- engine.checkVersion("4.0.5");
3642
+ engine.checkVersion("4.1.1");
3626
3643
  await engine.pluginManager.register(async (e) => {
3627
3644
  await Promise.all([
3628
3645
  loadBlendPlugin(e),
@@ -3744,58 +3761,58 @@
3744
3761
  }
3745
3762
  }
3746
3763
  class RenderManager {
3747
- _canvasClearPlugins;
3748
- _canvasManager;
3749
- _canvasPaintPlugins;
3750
- _clearDrawPlugins;
3751
- _colorPlugins;
3752
- _container;
3753
- _context;
3754
- _contextSettings;
3755
- _drawParticlePlugins;
3756
- _drawParticlesCleanupPlugins;
3757
- _drawParticlesSetupPlugins;
3758
- _drawPlugins;
3759
- _drawSettingsCleanupPlugins;
3760
- _drawSettingsSetupPlugins;
3761
- _pluginManager;
3762
- _postDrawUpdaters;
3763
- _preDrawUpdaters;
3764
- _reusableColorStyles = {};
3765
- _reusablePluginColors = [undefined, undefined];
3766
- _reusableTransform = {};
3764
+ #canvasClearPlugins;
3765
+ #canvasManager;
3766
+ #canvasPaintPlugins;
3767
+ #clearDrawPlugins;
3768
+ #colorPlugins;
3769
+ #container;
3770
+ #context;
3771
+ #contextSettings;
3772
+ #drawParticlePlugins;
3773
+ #drawParticlesCleanupPlugins;
3774
+ #drawParticlesSetupPlugins;
3775
+ #drawPlugins;
3776
+ #drawSettingsCleanupPlugins;
3777
+ #drawSettingsSetupPlugins;
3778
+ #pluginManager;
3779
+ #postDrawUpdaters;
3780
+ #preDrawUpdaters;
3781
+ #reusableColorStyles = {};
3782
+ #reusablePluginColors = [undefined, undefined];
3783
+ #reusableTransform = {};
3767
3784
  constructor(pluginManager, container, canvasManager) {
3768
- this._pluginManager = pluginManager;
3769
- this._container = container;
3770
- this._canvasManager = canvasManager;
3771
- this._context = null;
3772
- this._preDrawUpdaters = [];
3773
- this._postDrawUpdaters = [];
3774
- this._colorPlugins = [];
3775
- this._canvasClearPlugins = [];
3776
- this._canvasPaintPlugins = [];
3777
- this._clearDrawPlugins = [];
3778
- this._drawParticlePlugins = [];
3779
- this._drawParticlesCleanupPlugins = [];
3780
- this._drawParticlesSetupPlugins = [];
3781
- this._drawPlugins = [];
3782
- this._drawSettingsSetupPlugins = [];
3783
- this._drawSettingsCleanupPlugins = [];
3785
+ this.#pluginManager = pluginManager;
3786
+ this.#container = container;
3787
+ this.#canvasManager = canvasManager;
3788
+ this.#context = null;
3789
+ this.#preDrawUpdaters = [];
3790
+ this.#postDrawUpdaters = [];
3791
+ this.#colorPlugins = [];
3792
+ this.#canvasClearPlugins = [];
3793
+ this.#canvasPaintPlugins = [];
3794
+ this.#clearDrawPlugins = [];
3795
+ this.#drawParticlePlugins = [];
3796
+ this.#drawParticlesCleanupPlugins = [];
3797
+ this.#drawParticlesSetupPlugins = [];
3798
+ this.#drawPlugins = [];
3799
+ this.#drawSettingsSetupPlugins = [];
3800
+ this.#drawSettingsCleanupPlugins = [];
3784
3801
  }
3785
3802
  get settings() {
3786
- return this._contextSettings;
3803
+ return this.#contextSettings;
3787
3804
  }
3788
3805
  canvasClear() {
3789
- if (!this._container.actualOptions.clear) {
3806
+ if (!this.#container.actualOptions.clear) {
3790
3807
  return;
3791
3808
  }
3792
3809
  this.draw(ctx => {
3793
- clear(ctx, this._canvasManager.size);
3810
+ clear(ctx, this.#canvasManager.size);
3794
3811
  });
3795
3812
  }
3796
3813
  clear() {
3797
3814
  let pluginHandled = false;
3798
- for (const plugin of this._canvasClearPlugins) {
3815
+ for (const plugin of this.#canvasClearPlugins) {
3799
3816
  pluginHandled = plugin.canvasClear?.() ?? false;
3800
3817
  if (pluginHandled) {
3801
3818
  break;
@@ -3808,21 +3825,21 @@
3808
3825
  }
3809
3826
  destroy() {
3810
3827
  this.stop();
3811
- this._preDrawUpdaters = [];
3812
- this._postDrawUpdaters = [];
3813
- this._colorPlugins = [];
3814
- this._canvasClearPlugins = [];
3815
- this._canvasPaintPlugins = [];
3816
- this._clearDrawPlugins = [];
3817
- this._drawParticlePlugins = [];
3818
- this._drawParticlesCleanupPlugins = [];
3819
- this._drawParticlesSetupPlugins = [];
3820
- this._drawPlugins = [];
3821
- this._drawSettingsSetupPlugins = [];
3822
- this._drawSettingsCleanupPlugins = [];
3828
+ this.#preDrawUpdaters = [];
3829
+ this.#postDrawUpdaters = [];
3830
+ this.#colorPlugins = [];
3831
+ this.#canvasClearPlugins = [];
3832
+ this.#canvasPaintPlugins = [];
3833
+ this.#clearDrawPlugins = [];
3834
+ this.#drawParticlePlugins = [];
3835
+ this.#drawParticlesCleanupPlugins = [];
3836
+ this.#drawParticlesSetupPlugins = [];
3837
+ this.#drawPlugins = [];
3838
+ this.#drawSettingsSetupPlugins = [];
3839
+ this.#drawSettingsCleanupPlugins = [];
3823
3840
  }
3824
3841
  draw(cb) {
3825
- const ctx = this._context;
3842
+ const ctx = this.#context;
3826
3843
  if (!ctx) {
3827
3844
  return;
3828
3845
  }
@@ -3837,21 +3854,21 @@
3837
3854
  return;
3838
3855
  }
3839
3856
  const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
3840
- let [fColor, sColor] = this._getPluginParticleColors(particle);
3857
+ let [fColor, sColor] = this.#getPluginParticleColors(particle);
3841
3858
  fColor ??= pfColor;
3842
3859
  sColor ??= psColor;
3843
3860
  if (!fColor && !sColor) {
3844
3861
  return;
3845
3862
  }
3846
- 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;
3863
+ 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;
3847
3864
  transform.a = transform.b = transform.c = transform.d = undefined;
3848
3865
  colorStyles.fill = fill;
3849
3866
  colorStyles.stroke = stroke;
3850
3867
  this.draw((context) => {
3851
- for (const plugin of this._drawParticlesSetupPlugins) {
3868
+ for (const plugin of this.#drawParticlesSetupPlugins) {
3852
3869
  plugin.drawParticleSetup?.(context, particle, delta);
3853
3870
  }
3854
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
3871
+ this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
3855
3872
  drawParticle({
3856
3873
  container,
3857
3874
  context,
@@ -3862,35 +3879,35 @@
3862
3879
  opacity: opacity,
3863
3880
  transform,
3864
3881
  });
3865
- this._applyPostDrawUpdaters(particle);
3866
- for (const plugin of this._drawParticlesCleanupPlugins) {
3882
+ this.#applyPostDrawUpdaters(particle);
3883
+ for (const plugin of this.#drawParticlesCleanupPlugins) {
3867
3884
  plugin.drawParticleCleanup?.(context, particle, delta);
3868
3885
  }
3869
3886
  });
3870
3887
  }
3871
3888
  drawParticlePlugins(particle, delta) {
3872
3889
  this.draw(ctx => {
3873
- for (const plugin of this._drawParticlePlugins) {
3890
+ for (const plugin of this.#drawParticlePlugins) {
3874
3891
  drawParticlePlugin(ctx, plugin, particle, delta);
3875
3892
  }
3876
3893
  });
3877
3894
  }
3878
3895
  drawParticles(delta) {
3879
- const { particles } = this._container;
3896
+ const { particles } = this.#container;
3880
3897
  this.clear();
3881
3898
  particles.update(delta);
3882
3899
  this.draw(ctx => {
3883
- for (const plugin of this._drawSettingsSetupPlugins) {
3900
+ for (const plugin of this.#drawSettingsSetupPlugins) {
3884
3901
  plugin.drawSettingsSetup?.(ctx, delta);
3885
3902
  }
3886
- for (const plugin of this._drawPlugins) {
3903
+ for (const plugin of this.#drawPlugins) {
3887
3904
  plugin.draw?.(ctx, delta);
3888
3905
  }
3889
3906
  particles.drawParticles(delta);
3890
- for (const plugin of this._clearDrawPlugins) {
3907
+ for (const plugin of this.#clearDrawPlugins) {
3891
3908
  plugin.clearDraw?.(ctx, delta);
3892
3909
  }
3893
- for (const plugin of this._drawSettingsCleanupPlugins) {
3910
+ for (const plugin of this.#drawSettingsCleanupPlugins) {
3894
3911
  plugin.drawSettingsCleanup?.(ctx, delta);
3895
3912
  }
3896
3913
  });
@@ -3901,64 +3918,64 @@
3901
3918
  this.paint();
3902
3919
  }
3903
3920
  initPlugins() {
3904
- this._colorPlugins = [];
3905
- this._canvasClearPlugins = [];
3906
- this._canvasPaintPlugins = [];
3907
- this._clearDrawPlugins = [];
3908
- this._drawParticlePlugins = [];
3909
- this._drawParticlesSetupPlugins = [];
3910
- this._drawParticlesCleanupPlugins = [];
3911
- this._drawPlugins = [];
3912
- this._drawSettingsSetupPlugins = [];
3913
- this._drawSettingsCleanupPlugins = [];
3914
- for (const plugin of this._container.plugins) {
3921
+ this.#colorPlugins = [];
3922
+ this.#canvasClearPlugins = [];
3923
+ this.#canvasPaintPlugins = [];
3924
+ this.#clearDrawPlugins = [];
3925
+ this.#drawParticlePlugins = [];
3926
+ this.#drawParticlesSetupPlugins = [];
3927
+ this.#drawParticlesCleanupPlugins = [];
3928
+ this.#drawPlugins = [];
3929
+ this.#drawSettingsSetupPlugins = [];
3930
+ this.#drawSettingsCleanupPlugins = [];
3931
+ for (const plugin of this.#container.plugins) {
3915
3932
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
3916
- this._colorPlugins.push(plugin);
3933
+ this.#colorPlugins.push(plugin);
3917
3934
  }
3918
3935
  if (plugin.canvasClear) {
3919
- this._canvasClearPlugins.push(plugin);
3936
+ this.#canvasClearPlugins.push(plugin);
3920
3937
  }
3921
3938
  if (plugin.canvasPaint) {
3922
- this._canvasPaintPlugins.push(plugin);
3939
+ this.#canvasPaintPlugins.push(plugin);
3923
3940
  }
3924
3941
  if (plugin.drawParticle) {
3925
- this._drawParticlePlugins.push(plugin);
3942
+ this.#drawParticlePlugins.push(plugin);
3926
3943
  }
3927
3944
  if (plugin.drawParticleSetup) {
3928
- this._drawParticlesSetupPlugins.push(plugin);
3945
+ this.#drawParticlesSetupPlugins.push(plugin);
3929
3946
  }
3930
3947
  if (plugin.drawParticleCleanup) {
3931
- this._drawParticlesCleanupPlugins.push(plugin);
3948
+ this.#drawParticlesCleanupPlugins.push(plugin);
3932
3949
  }
3933
3950
  if (plugin.draw) {
3934
- this._drawPlugins.push(plugin);
3951
+ this.#drawPlugins.push(plugin);
3935
3952
  }
3936
3953
  if (plugin.drawSettingsSetup) {
3937
- this._drawSettingsSetupPlugins.push(plugin);
3954
+ this.#drawSettingsSetupPlugins.push(plugin);
3938
3955
  }
3939
3956
  if (plugin.drawSettingsCleanup) {
3940
- this._drawSettingsCleanupPlugins.push(plugin);
3957
+ this.#drawSettingsCleanupPlugins.push(plugin);
3941
3958
  }
3942
3959
  if (plugin.clearDraw) {
3943
- this._clearDrawPlugins.push(plugin);
3960
+ this.#clearDrawPlugins.push(plugin);
3944
3961
  }
3945
3962
  }
3946
3963
  }
3947
3964
  initUpdaters() {
3948
- this._preDrawUpdaters = [];
3949
- this._postDrawUpdaters = [];
3950
- for (const updater of this._container.particleUpdaters) {
3965
+ this.#preDrawUpdaters = [];
3966
+ this.#postDrawUpdaters = [];
3967
+ for (const updater of this.#container.particleUpdaters) {
3951
3968
  if (updater.afterDraw) {
3952
- this._postDrawUpdaters.push(updater);
3969
+ this.#postDrawUpdaters.push(updater);
3953
3970
  }
3954
3971
  if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
3955
- this._preDrawUpdaters.push(updater);
3972
+ this.#preDrawUpdaters.push(updater);
3956
3973
  }
3957
3974
  }
3958
3975
  }
3959
3976
  paint() {
3960
3977
  let handled = false;
3961
- for (const plugin of this._canvasPaintPlugins) {
3978
+ for (const plugin of this.#canvasPaintPlugins) {
3962
3979
  handled = plugin.canvasPaint?.() ?? false;
3963
3980
  if (handled) {
3964
3981
  break;
@@ -3971,35 +3988,35 @@
3971
3988
  }
3972
3989
  paintBase(baseColor) {
3973
3990
  this.draw(ctx => {
3974
- paintBase(ctx, this._canvasManager.size, baseColor);
3991
+ paintBase(ctx, this.#canvasManager.size, baseColor);
3975
3992
  });
3976
3993
  }
3977
3994
  paintImage(image, opacity) {
3978
3995
  this.draw(ctx => {
3979
- paintImage(ctx, this._canvasManager.size, image, opacity);
3996
+ paintImage(ctx, this.#canvasManager.size, image, opacity);
3980
3997
  });
3981
3998
  }
3982
3999
  setContext(context) {
3983
- this._context = context;
3984
- if (this._context) {
3985
- this._context.globalCompositeOperation = defaultCompositeValue;
4000
+ this.#context = context;
4001
+ if (this.#context) {
4002
+ this.#context.globalCompositeOperation = defaultCompositeValue;
3986
4003
  }
3987
4004
  }
3988
4005
  setContextSettings(settings) {
3989
- this._contextSettings = settings;
4006
+ this.#contextSettings = settings;
3990
4007
  }
3991
4008
  stop() {
3992
4009
  this.draw(ctx => {
3993
- clear(ctx, this._canvasManager.size);
4010
+ clear(ctx, this.#canvasManager.size);
3994
4011
  });
3995
4012
  }
3996
- _applyPostDrawUpdaters = particle => {
3997
- for (const updater of this._postDrawUpdaters) {
4013
+ #applyPostDrawUpdaters = particle => {
4014
+ for (const updater of this.#postDrawUpdaters) {
3998
4015
  updater.afterDraw?.(particle);
3999
4016
  }
4000
4017
  };
4001
- _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4002
- for (const updater of this._preDrawUpdaters) {
4018
+ #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4019
+ for (const updater of this.#preDrawUpdaters) {
4003
4020
  if (updater.getColorStyles) {
4004
4021
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
4005
4022
  if (fill) {
@@ -4018,22 +4035,22 @@
4018
4035
  updater.beforeDraw?.(particle);
4019
4036
  }
4020
4037
  };
4021
- _getPluginParticleColors = particle => {
4038
+ #getPluginParticleColors = particle => {
4022
4039
  let fColor, sColor;
4023
- for (const plugin of this._colorPlugins) {
4040
+ for (const plugin of this.#colorPlugins) {
4024
4041
  if (!fColor && plugin.particleFillColor) {
4025
- fColor = rangeColorToHsl(this._pluginManager, plugin.particleFillColor(particle));
4042
+ fColor = rangeColorToHsl(this.#pluginManager, plugin.particleFillColor(particle));
4026
4043
  }
4027
4044
  if (!sColor && plugin.particleStrokeColor) {
4028
- sColor = rangeColorToHsl(this._pluginManager, plugin.particleStrokeColor(particle));
4045
+ sColor = rangeColorToHsl(this.#pluginManager, plugin.particleStrokeColor(particle));
4029
4046
  }
4030
4047
  if (fColor && sColor) {
4031
4048
  break;
4032
4049
  }
4033
4050
  }
4034
- this._reusablePluginColors[fColorIndex] = fColor;
4035
- this._reusablePluginColors[sColorIndex] = sColor;
4036
- return this._reusablePluginColors;
4051
+ this.#reusablePluginColors[fColorIndex] = fColor;
4052
+ this.#reusablePluginColors[sColorIndex] = sColor;
4053
+ return this.#reusablePluginColors;
4037
4054
  };
4038
4055
  }
4039
4056
 
@@ -4091,53 +4108,53 @@
4091
4108
  renderCanvas;
4092
4109
  size;
4093
4110
  zoom = defaultZoom;
4094
- _container;
4095
- _generated;
4096
- _mutationObserver;
4097
- _originalStyle;
4098
- _pluginManager;
4099
- _pointerEvents;
4100
- _resizePlugins;
4101
- _standardSize;
4102
- _zoomCenter;
4111
+ #container;
4112
+ #generated;
4113
+ #mutationObserver;
4114
+ #originalStyle;
4115
+ #pluginManager;
4116
+ #pointerEvents;
4117
+ #resizePlugins;
4118
+ #standardSize;
4119
+ #zoomCenter;
4103
4120
  constructor(pluginManager, container) {
4104
- this._pluginManager = pluginManager;
4105
- this._container = container;
4121
+ this.#pluginManager = pluginManager;
4122
+ this.#container = container;
4106
4123
  this.render = new RenderManager(pluginManager, container, this);
4107
- this._standardSize = {
4124
+ this.#standardSize = {
4108
4125
  height: 0,
4109
4126
  width: 0,
4110
4127
  };
4111
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
4128
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
4112
4129
  this.size = {
4113
4130
  height: stdSize.height * pxRatio,
4114
4131
  width: stdSize.width * pxRatio,
4115
4132
  };
4116
- this._generated = false;
4117
- this._resizePlugins = [];
4118
- this._pointerEvents = "none";
4133
+ this.#generated = false;
4134
+ this.#resizePlugins = [];
4135
+ this.#pointerEvents = "none";
4119
4136
  }
4120
- get _fullScreen() {
4121
- return this._container.actualOptions.fullScreen.enable;
4137
+ get #fullScreen() {
4138
+ return this.#container.actualOptions.fullScreen.enable;
4122
4139
  }
4123
4140
  destroy() {
4124
4141
  this.stop();
4125
- if (this._generated) {
4142
+ if (this.#generated) {
4126
4143
  const element = this.domElement;
4127
4144
  element?.remove();
4128
4145
  this.domElement = undefined;
4129
4146
  this.renderCanvas = undefined;
4130
4147
  }
4131
4148
  else {
4132
- this._resetOriginalStyle();
4149
+ this.#resetOriginalStyle();
4133
4150
  }
4134
4151
  this.render.destroy();
4135
- this._resizePlugins = [];
4152
+ this.#resizePlugins = [];
4136
4153
  }
4137
4154
  getZoomCenter() {
4138
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
4139
- if (this._zoomCenter) {
4140
- return this._zoomCenter;
4155
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
4156
+ if (this.#zoomCenter) {
4157
+ return this.#zoomCenter;
4141
4158
  }
4142
4159
  return {
4143
4160
  x: (width * half) / pxRatio,
@@ -4145,20 +4162,20 @@
4145
4162
  };
4146
4163
  }
4147
4164
  init() {
4148
- this._safeMutationObserver(obs => {
4165
+ this.#safeMutationObserver(obs => {
4149
4166
  obs.disconnect();
4150
4167
  });
4151
- this._mutationObserver = safeMutationObserver(records => {
4168
+ this.#mutationObserver = safeMutationObserver(records => {
4152
4169
  for (const record of records) {
4153
4170
  if (record.type === "attributes" && record.attributeName === "style") {
4154
- this._repairStyle();
4171
+ this.#repairStyle();
4155
4172
  }
4156
4173
  }
4157
4174
  });
4158
4175
  this.resize();
4159
- this._initStyle();
4176
+ this.#initStyle();
4160
4177
  this.initBackground();
4161
- this._safeMutationObserver(obs => {
4178
+ this.#safeMutationObserver(obs => {
4162
4179
  const element = this.domElement;
4163
4180
  if (!element || !(element instanceof Node)) {
4164
4181
  return;
@@ -4169,13 +4186,13 @@
4169
4186
  this.render.init();
4170
4187
  }
4171
4188
  initBackground() {
4172
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
4189
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
4173
4190
  if (!element) {
4174
4191
  return;
4175
4192
  }
4176
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
4193
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
4177
4194
  if (color) {
4178
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
4195
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
4179
4196
  }
4180
4197
  else {
4181
4198
  elementStyle.backgroundColor = "";
@@ -4186,27 +4203,27 @@
4186
4203
  elementStyle.backgroundSize = background.size || "";
4187
4204
  }
4188
4205
  initPlugins() {
4189
- this._resizePlugins = [];
4190
- for (const plugin of this._container.plugins) {
4206
+ this.#resizePlugins = [];
4207
+ for (const plugin of this.#container.plugins) {
4191
4208
  if (plugin.resize) {
4192
- this._resizePlugins.push(plugin);
4209
+ this.#resizePlugins.push(plugin);
4193
4210
  }
4194
4211
  }
4195
4212
  }
4196
4213
  loadCanvas(canvas) {
4197
- if (this._generated && this.domElement) {
4214
+ if (this.#generated && this.domElement) {
4198
4215
  this.domElement.remove();
4199
4216
  }
4200
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4217
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4201
4218
  this.domElement = domCanvas;
4202
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4219
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4203
4220
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
4204
4221
  const domElement = this.domElement;
4205
4222
  if (domElement) {
4206
4223
  domElement.ariaHidden = "true";
4207
- this._originalStyle = cloneStyle(domElement.style);
4224
+ this.#originalStyle = cloneStyle(domElement.style);
4208
4225
  }
4209
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
4226
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
4210
4227
  if (domElement) {
4211
4228
  standardSize.height = domElement.offsetHeight;
4212
4229
  standardSize.width = domElement.offsetWidth;
@@ -4215,7 +4232,7 @@
4215
4232
  standardSize.height = renderCanvas.height;
4216
4233
  standardSize.width = renderCanvas.width;
4217
4234
  }
4218
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
4235
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
4219
4236
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
4220
4237
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
4221
4238
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -4226,12 +4243,12 @@
4226
4243
  willReadFrequently: false,
4227
4244
  });
4228
4245
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
4229
- this._safeMutationObserver(obs => {
4246
+ this.#safeMutationObserver(obs => {
4230
4247
  obs.disconnect();
4231
4248
  });
4232
4249
  container.retina.init();
4233
4250
  this.initBackground();
4234
- this._safeMutationObserver(obs => {
4251
+ this.#safeMutationObserver(obs => {
4235
4252
  const element = this.domElement;
4236
4253
  if (!element || !(element instanceof Node)) {
4237
4254
  return;
@@ -4244,11 +4261,11 @@
4244
4261
  if (!element) {
4245
4262
  return false;
4246
4263
  }
4247
- const container = this._container, renderCanvas = this.renderCanvas;
4264
+ const container = this.#container, renderCanvas = this.renderCanvas;
4248
4265
  if (renderCanvas === undefined) {
4249
4266
  return false;
4250
4267
  }
4251
- const currentSize = container.canvas._standardSize, newSize = {
4268
+ const currentSize = container.canvas.#standardSize, newSize = {
4252
4269
  width: element.offsetWidth,
4253
4270
  height: element.offsetHeight,
4254
4271
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -4267,7 +4284,7 @@
4267
4284
  const canvasSize = this.size;
4268
4285
  renderCanvas.width = canvasSize.width = retinaSize.width;
4269
4286
  renderCanvas.height = canvasSize.height = retinaSize.height;
4270
- if (this._container.started) {
4287
+ if (this.#container.started) {
4271
4288
  container.particles.setResizeFactor({
4272
4289
  width: currentSize.width / oldSize.width,
4273
4290
  height: currentSize.height / oldSize.height,
@@ -4280,46 +4297,46 @@
4280
4297
  if (!element) {
4281
4298
  return;
4282
4299
  }
4283
- this._pointerEvents = type;
4284
- this._repairStyle();
4300
+ this.#pointerEvents = type;
4301
+ this.#repairStyle();
4285
4302
  }
4286
4303
  setZoom(zoomLevel, center) {
4287
4304
  this.zoom = zoomLevel;
4288
- this._zoomCenter = center;
4305
+ this.#zoomCenter = center;
4289
4306
  }
4290
4307
  stop() {
4291
- this._safeMutationObserver(obs => {
4308
+ this.#safeMutationObserver(obs => {
4292
4309
  obs.disconnect();
4293
4310
  });
4294
- this._mutationObserver = undefined;
4311
+ this.#mutationObserver = undefined;
4295
4312
  this.render.stop();
4296
4313
  }
4297
4314
  async windowResize() {
4298
4315
  if (!this.domElement || !this.resize()) {
4299
4316
  return;
4300
4317
  }
4301
- const container = this._container, needsRefresh = container.updateActualOptions();
4318
+ const container = this.#container, needsRefresh = container.updateActualOptions();
4302
4319
  container.particles.setDensity();
4303
- this._applyResizePlugins();
4320
+ this.#applyResizePlugins();
4304
4321
  if (needsRefresh) {
4305
4322
  await container.refresh();
4306
4323
  }
4307
4324
  }
4308
- _applyResizePlugins = () => {
4309
- for (const plugin of this._resizePlugins) {
4325
+ #applyResizePlugins = () => {
4326
+ for (const plugin of this.#resizePlugins) {
4310
4327
  plugin.resize?.();
4311
4328
  }
4312
4329
  };
4313
- _initStyle = () => {
4314
- const element = this.domElement, options = this._container.actualOptions;
4330
+ #initStyle = () => {
4331
+ const element = this.domElement, options = this.#container.actualOptions;
4315
4332
  if (!element) {
4316
4333
  return;
4317
4334
  }
4318
- if (this._fullScreen) {
4319
- this._setFullScreenStyle();
4335
+ if (this.#fullScreen) {
4336
+ this.#setFullScreenStyle();
4320
4337
  }
4321
4338
  else {
4322
- this._resetOriginalStyle();
4339
+ this.#resetOriginalStyle();
4323
4340
  }
4324
4341
  for (const key in options.style) {
4325
4342
  if (!key || !(key in options.style)) {
@@ -4332,72 +4349,72 @@
4332
4349
  element.style.setProperty(key, value, "important");
4333
4350
  }
4334
4351
  };
4335
- _repairStyle = () => {
4352
+ #repairStyle = () => {
4336
4353
  const element = this.domElement;
4337
4354
  if (!element) {
4338
4355
  return;
4339
4356
  }
4340
- this._safeMutationObserver(observer => {
4357
+ this.#safeMutationObserver(observer => {
4341
4358
  observer.disconnect();
4342
4359
  });
4343
- this._initStyle();
4360
+ this.#initStyle();
4344
4361
  this.initBackground();
4345
- const pointerEvents = this._pointerEvents;
4362
+ const pointerEvents = this.#pointerEvents;
4346
4363
  element.style.pointerEvents = pointerEvents;
4347
4364
  element.style.setProperty("pointer-events", pointerEvents);
4348
- this._safeMutationObserver(observer => {
4365
+ this.#safeMutationObserver(observer => {
4349
4366
  if (!(element instanceof Node)) {
4350
4367
  return;
4351
4368
  }
4352
4369
  observer.observe(element, { attributes: true });
4353
4370
  });
4354
4371
  };
4355
- _resetOriginalStyle = () => {
4356
- const element = this.domElement, originalStyle = this._originalStyle;
4372
+ #resetOriginalStyle = () => {
4373
+ const element = this.domElement, originalStyle = this.#originalStyle;
4357
4374
  if (!element || !originalStyle) {
4358
4375
  return;
4359
4376
  }
4360
4377
  setStyle(element, originalStyle, true);
4361
4378
  };
4362
- _safeMutationObserver = callback => {
4363
- if (!this._mutationObserver) {
4379
+ #safeMutationObserver = callback => {
4380
+ if (!this.#mutationObserver) {
4364
4381
  return;
4365
4382
  }
4366
- callback(this._mutationObserver);
4383
+ callback(this.#mutationObserver);
4367
4384
  };
4368
- _setFullScreenStyle = () => {
4385
+ #setFullScreenStyle = () => {
4369
4386
  const element = this.domElement;
4370
4387
  if (!element) {
4371
4388
  return;
4372
4389
  }
4373
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
4390
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
4374
4391
  };
4375
4392
  }
4376
4393
 
4377
4394
  class EventListeners {
4378
- container;
4379
- _handlers;
4380
- _resizeObserver;
4381
- _resizeTimeout;
4395
+ #container;
4396
+ #handlers;
4397
+ #resizeObserver;
4398
+ #resizeTimeout;
4382
4399
  constructor(container) {
4383
- this.container = container;
4384
- this._handlers = {
4400
+ this.#container = container;
4401
+ this.#handlers = {
4385
4402
  visibilityChange: () => {
4386
- this._handleVisibilityChange();
4403
+ this.#handleVisibilityChange();
4387
4404
  },
4388
4405
  resize: () => {
4389
- this._handleWindowResize();
4406
+ this.#handleWindowResize();
4390
4407
  },
4391
4408
  };
4392
4409
  }
4393
4410
  addListeners() {
4394
- this._manageListeners(true);
4411
+ this.#manageListeners(true);
4395
4412
  }
4396
4413
  removeListeners() {
4397
- this._manageListeners(false);
4414
+ this.#manageListeners(false);
4398
4415
  }
4399
- _handleVisibilityChange = () => {
4400
- const container = this.container, options = container.actualOptions;
4416
+ #handleVisibilityChange = () => {
4417
+ const container = this.#container, options = container.actualOptions;
4401
4418
  if (!options.pauseOnBlur) {
4402
4419
  return;
4403
4420
  }
@@ -4415,24 +4432,24 @@
4415
4432
  }
4416
4433
  }
4417
4434
  };
4418
- _handleWindowResize = () => {
4419
- if (this._resizeTimeout) {
4420
- clearTimeout(this._resizeTimeout);
4421
- delete this._resizeTimeout;
4435
+ #handleWindowResize = () => {
4436
+ if (this.#resizeTimeout) {
4437
+ clearTimeout(this.#resizeTimeout);
4438
+ this.#resizeTimeout = undefined;
4422
4439
  }
4423
4440
  const handleResize = async () => {
4424
- const canvas = this.container.canvas;
4441
+ const canvas = this.#container.canvas;
4425
4442
  await canvas.windowResize();
4426
4443
  };
4427
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
4444
+ this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
4428
4445
  };
4429
- _manageListeners = add => {
4430
- const handlers = this._handlers;
4431
- this._manageResize(add);
4446
+ #manageListeners = add => {
4447
+ const handlers = this.#handlers;
4448
+ this.#manageResize(add);
4432
4449
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
4433
4450
  };
4434
- _manageResize = add => {
4435
- const handlers = this._handlers, container = this.container, options = container.actualOptions;
4451
+ #manageResize = add => {
4452
+ const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
4436
4453
  if (!options.resize.enable) {
4437
4454
  return;
4438
4455
  }
@@ -4441,22 +4458,22 @@
4441
4458
  return;
4442
4459
  }
4443
4460
  const canvasEl = container.canvas.domElement;
4444
- if (this._resizeObserver && !add) {
4461
+ if (this.#resizeObserver && !add) {
4445
4462
  if (canvasEl) {
4446
- this._resizeObserver.unobserve(canvasEl);
4463
+ this.#resizeObserver.unobserve(canvasEl);
4447
4464
  }
4448
- this._resizeObserver.disconnect();
4449
- delete this._resizeObserver;
4465
+ this.#resizeObserver.disconnect();
4466
+ this.#resizeObserver = undefined;
4450
4467
  }
4451
- else if (!this._resizeObserver && add && canvasEl) {
4452
- this._resizeObserver = new ResizeObserver((entries) => {
4468
+ else if (!this.#resizeObserver && add && canvasEl) {
4469
+ this.#resizeObserver = new ResizeObserver((entries) => {
4453
4470
  const entry = entries.find(e => e.target === canvasEl);
4454
4471
  if (!entry) {
4455
4472
  return;
4456
4473
  }
4457
- this._handleWindowResize();
4474
+ this.#handleWindowResize();
4458
4475
  });
4459
- this._resizeObserver.observe(canvasEl);
4476
+ this.#resizeObserver.observe(canvasEl);
4460
4477
  }
4461
4478
  };
4462
4479
  }
@@ -4529,24 +4546,24 @@
4529
4546
  unbreakable;
4530
4547
  velocity;
4531
4548
  zIndexFactor;
4532
- _cachedOpacityData = {
4549
+ #cachedOpacityData = {
4533
4550
  fillOpacity: defaultOpacity$1,
4534
4551
  opacity: defaultOpacity$1,
4535
4552
  strokeOpacity: defaultOpacity$1,
4536
4553
  };
4537
- _cachedPosition = Vector3d.origin;
4538
- _cachedRotateData = { sin: 0, cos: 0 };
4539
- _cachedTransform = {
4554
+ #cachedPosition = Vector3d.origin;
4555
+ #cachedRotateData = { sin: 0, cos: 0 };
4556
+ #cachedTransform = {
4540
4557
  a: 1,
4541
4558
  b: 0,
4542
4559
  c: 0,
4543
4560
  d: 1,
4544
4561
  };
4545
- _container;
4546
- _pluginManager;
4562
+ #container;
4563
+ #pluginManager;
4547
4564
  constructor(pluginManager, container) {
4548
- this._pluginManager = pluginManager;
4549
- this._container = container;
4565
+ this.#pluginManager = pluginManager;
4566
+ this.#container = container;
4550
4567
  }
4551
4568
  destroy(override) {
4552
4569
  if (this.unbreakable || this.destroyed) {
@@ -4555,7 +4572,7 @@
4555
4572
  this.destroyed = true;
4556
4573
  this.bubble.inRange = false;
4557
4574
  this.slow.inRange = false;
4558
- const container = this._container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4575
+ const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4559
4576
  shapeDrawer?.particleDestroy?.(this);
4560
4577
  for (const plugin of container.particleDestroyedPlugins) {
4561
4578
  plugin.particleDestroyed?.(this, override);
@@ -4563,12 +4580,12 @@
4563
4580
  for (const updater of container.particleUpdaters) {
4564
4581
  updater.particleDestroyed?.(this, override);
4565
4582
  }
4566
- this._container.dispatchEvent(EventType.particleDestroyed, {
4583
+ this.#container.dispatchEvent(EventType.particleDestroyed, {
4567
4584
  particle: this,
4568
4585
  });
4569
4586
  }
4570
4587
  draw(delta) {
4571
- const container = this._container, render = container.canvas.render;
4588
+ const container = this.#container, render = container.canvas.render;
4572
4589
  render.drawParticlePlugins(this, delta);
4573
4590
  render.drawParticle(this, delta);
4574
4591
  }
@@ -4576,50 +4593,50 @@
4576
4593
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
4577
4594
  }
4578
4595
  getFillColor() {
4579
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4596
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4580
4597
  }
4581
4598
  getMass() {
4582
4599
  return this.getRadius() ** squareExp * Math.PI * half;
4583
4600
  }
4584
4601
  getOpacity() {
4585
4602
  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;
4586
- this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4587
- this._cachedOpacityData.opacity = opacity * zOpacityFactor;
4588
- this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4589
- return this._cachedOpacityData;
4603
+ this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4604
+ this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
4605
+ this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4606
+ return this.#cachedOpacityData;
4590
4607
  }
4591
4608
  getPosition() {
4592
- this._cachedPosition.x = this.position.x + this.offset.x;
4593
- this._cachedPosition.y = this.position.y + this.offset.y;
4594
- this._cachedPosition.z = this.position.z;
4595
- return this._cachedPosition;
4609
+ this.#cachedPosition.x = this.position.x + this.offset.x;
4610
+ this.#cachedPosition.y = this.position.y + this.offset.y;
4611
+ this.#cachedPosition.z = this.position.z;
4612
+ return this.#cachedPosition;
4596
4613
  }
4597
4614
  getRadius() {
4598
4615
  return this.bubble.radius ?? this.size.value;
4599
4616
  }
4600
4617
  getRotateData() {
4601
4618
  const angle = this.getAngle();
4602
- this._cachedRotateData.sin = Math.sin(angle);
4603
- this._cachedRotateData.cos = Math.cos(angle);
4604
- return this._cachedRotateData;
4619
+ this.#cachedRotateData.sin = Math.sin(angle);
4620
+ this.#cachedRotateData.cos = Math.cos(angle);
4621
+ return this.#cachedRotateData;
4605
4622
  }
4606
4623
  getStrokeColor() {
4607
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4624
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4608
4625
  }
4609
4626
  getTransformData(externalTransform) {
4610
4627
  const rotateData = this.getRotateData(), rotating = this.isRotating;
4611
- this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4612
- this._cachedTransform.b = rotating
4628
+ this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4629
+ this.#cachedTransform.b = rotating
4613
4630
  ? rotateData.sin * (externalTransform.b ?? identity$1)
4614
4631
  : (externalTransform.b ?? defaultTransform.b);
4615
- this._cachedTransform.c = rotating
4632
+ this.#cachedTransform.c = rotating
4616
4633
  ? -rotateData.sin * (externalTransform.c ?? identity$1)
4617
4634
  : (externalTransform.c ?? defaultTransform.c);
4618
- this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4619
- return this._cachedTransform;
4635
+ this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4636
+ return this.#cachedTransform;
4620
4637
  }
4621
4638
  init(id, position, overrideOptions, group) {
4622
- const container = this._container;
4639
+ const container = this.#container;
4623
4640
  this.id = id;
4624
4641
  this.group = group;
4625
4642
  this.justWarped = false;
@@ -4639,21 +4656,27 @@
4639
4656
  moveSpeed: 0,
4640
4657
  sizeAnimationSpeed: 0,
4641
4658
  };
4659
+ this.size = {
4660
+ value: 1,
4661
+ max: 1,
4662
+ min: 1,
4663
+ enable: false,
4664
+ };
4642
4665
  this.outType = ParticleOutType.normal;
4643
4666
  this.ignoresResizeRatio = true;
4644
- 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;
4667
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
4645
4668
  this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
4646
4669
  this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
4647
4670
  const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
4648
4671
  if (overrideOptions) {
4649
- if (overrideOptions.effect?.type) {
4672
+ if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
4650
4673
  const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
4651
4674
  if (effect) {
4652
4675
  this.effect = effect;
4653
4676
  effectOptions.load(overrideOptions.effect);
4654
4677
  }
4655
4678
  }
4656
- if (overrideOptions.shape?.type) {
4679
+ if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
4657
4680
  const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
4658
4681
  if (shape) {
4659
4682
  this.shape = shape;
@@ -4662,21 +4685,20 @@
4662
4685
  }
4663
4686
  }
4664
4687
  if (this.effect === randomColorValue) {
4665
- const availableEffects = [...this._container.effectDrawers.keys()];
4688
+ const availableEffects = [...this.#container.effectDrawers.keys()];
4666
4689
  this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
4667
4690
  }
4668
4691
  if (this.shape === randomColorValue) {
4669
- const availableShapes = [...this._container.shapeDrawers.keys()];
4692
+ const availableShapes = [...this.#container.shapeDrawers.keys()];
4670
4693
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
4671
4694
  }
4672
4695
  this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
4673
4696
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
4674
4697
  particlesOptions.load(overrideOptions);
4675
- const effectData = this.effectData;
4698
+ const effectData = this.effectData, shapeData = this.shapeData;
4676
4699
  if (effectData) {
4677
4700
  particlesOptions.load(effectData.particles);
4678
4701
  }
4679
- const shapeData = this.shapeData;
4680
4702
  if (shapeData) {
4681
4703
  particlesOptions.load(shapeData.particles);
4682
4704
  }
@@ -4684,7 +4706,9 @@
4684
4706
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
4685
4707
  this.options = particlesOptions;
4686
4708
  container.retina.initParticle(this);
4687
- this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
4709
+ for (const updater of container.particleUpdaters) {
4710
+ updater.preInit?.(this);
4711
+ }
4688
4712
  this.bubble = {
4689
4713
  inRange: false,
4690
4714
  };
@@ -4692,8 +4716,8 @@
4692
4716
  inRange: false,
4693
4717
  factor: 1,
4694
4718
  };
4695
- this._initPosition(position);
4696
- this.initialVelocity = this._calculateVelocity();
4719
+ this.#initPosition(position);
4720
+ this.initialVelocity = this.#calculateVelocity();
4697
4721
  this.velocity = this.initialVelocity.copy();
4698
4722
  this.zIndexFactor = this.position.z / container.zLayers;
4699
4723
  this.sides = 24;
@@ -4724,12 +4748,11 @@
4724
4748
  plugin.particleCreated?.(this);
4725
4749
  }
4726
4750
  }
4727
- isInsideCanvas() {
4728
- const radius = this.getRadius(), canvasSize = this._container.canvas.size, position = this.position;
4729
- return (position.x >= -radius &&
4730
- position.y >= -radius &&
4731
- position.y <= canvasSize.height + radius &&
4732
- position.x <= canvasSize.width + radius);
4751
+ isInsideCanvas(direction) {
4752
+ return this.#getInsideCanvasResult({ direction }).inside;
4753
+ }
4754
+ isInsideCanvasForOutMode(outMode, direction) {
4755
+ return this.#getInsideCanvasResult({ direction, outMode }).inside;
4733
4756
  }
4734
4757
  isShowingBack() {
4735
4758
  if (!this.roll) {
@@ -4754,13 +4777,13 @@
4754
4777
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
4755
4778
  }
4756
4779
  reset() {
4757
- for (const updater of this._container.particleUpdaters) {
4780
+ for (const updater of this.#container.particleUpdaters) {
4758
4781
  updater.reset?.(this);
4759
4782
  }
4760
4783
  }
4761
- _calcPosition = (position, zIndex) => {
4784
+ #calcPosition = (position, zIndex) => {
4762
4785
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
4763
- const container = this._container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
4786
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
4764
4787
  while (!signal.aborted) {
4765
4788
  for (const plugin of plugins) {
4766
4789
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -4772,10 +4795,10 @@
4772
4795
  size: canvasSize,
4773
4796
  position: posVec,
4774
4797
  }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
4775
- this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
4776
- this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
4777
- this._fixVertical(pos, radius, outModes.top ?? outModes.default);
4778
- this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
4798
+ this.#fixHorizontal(pos, radius, outModes.left ?? outModes.default);
4799
+ this.#fixHorizontal(pos, radius, outModes.right ?? outModes.default);
4800
+ this.#fixVertical(pos, radius, outModes.top ?? outModes.default);
4801
+ this.#fixVertical(pos, radius, outModes.bottom ?? outModes.default);
4779
4802
  let isValidPosition = true;
4780
4803
  for (const plugin of container.particles.checkParticlePositionPlugins) {
4781
4804
  isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
@@ -4791,8 +4814,8 @@
4791
4814
  }
4792
4815
  return posVec;
4793
4816
  };
4794
- _calculateVelocity = () => {
4795
- const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
4817
+ #calculateVelocity = () => {
4818
+ const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
4796
4819
  if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
4797
4820
  return res;
4798
4821
  }
@@ -4808,27 +4831,86 @@
4808
4831
  }
4809
4832
  return res;
4810
4833
  };
4811
- _fixHorizontal = (pos, radius, outMode) => {
4834
+ #fixHorizontal = (pos, radius, outMode) => {
4812
4835
  fixOutMode({
4813
4836
  outMode,
4814
4837
  checkModes: [OutMode.bounce],
4815
4838
  coord: pos.x,
4816
- maxCoord: this._container.canvas.size.width,
4839
+ maxCoord: this.#container.canvas.size.width,
4817
4840
  setCb: (value) => (pos.x += value),
4818
4841
  radius,
4819
4842
  });
4820
4843
  };
4821
- _fixVertical = (pos, radius, outMode) => {
4844
+ #fixVertical = (pos, radius, outMode) => {
4822
4845
  fixOutMode({
4823
4846
  outMode,
4824
4847
  checkModes: [OutMode.bounce],
4825
4848
  coord: pos.y,
4826
- maxCoord: this._container.canvas.size.height,
4849
+ maxCoord: this.#container.canvas.size.height,
4827
4850
  setCb: (value) => (pos.y += value),
4828
4851
  radius,
4829
4852
  });
4830
4853
  };
4831
- _getRollColor = color => {
4854
+ #getDefaultInsideCanvasResult = (direction, outMode) => {
4855
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
4856
+ if (direction === OutModeDirection.bottom) {
4857
+ return {
4858
+ inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
4859
+ reason: "default",
4860
+ };
4861
+ }
4862
+ if (direction === OutModeDirection.left) {
4863
+ return {
4864
+ inside: isBounce ? position.x - radius > defaultAngle : position.x + radius > defaultAngle,
4865
+ reason: "default",
4866
+ };
4867
+ }
4868
+ if (direction === OutModeDirection.right) {
4869
+ return {
4870
+ inside: isBounce ? position.x + radius < canvasSize.width : position.x - radius < canvasSize.width,
4871
+ reason: "default",
4872
+ };
4873
+ }
4874
+ if (direction === OutModeDirection.top) {
4875
+ return {
4876
+ inside: isBounce ? position.y - radius > defaultAngle : position.y + radius > defaultAngle,
4877
+ reason: "default",
4878
+ };
4879
+ }
4880
+ return {
4881
+ inside: position.x >= -radius &&
4882
+ position.y >= -radius &&
4883
+ position.y <= canvasSize.height + radius &&
4884
+ position.x <= canvasSize.width + radius,
4885
+ reason: "default",
4886
+ };
4887
+ };
4888
+ #getInsideCanvasCallbackData = (direction, outMode) => {
4889
+ return {
4890
+ canvasSize: this.#container.canvas.size,
4891
+ direction,
4892
+ outMode,
4893
+ particle: this,
4894
+ radius: this.getRadius(),
4895
+ };
4896
+ };
4897
+ #getInsideCanvasResult = (data) => {
4898
+ 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;
4899
+ if (!shapeCheck && !effectCheck) {
4900
+ return defaultResult;
4901
+ }
4902
+ const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
4903
+ if (shapeResult && effectResult) {
4904
+ const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
4905
+ return {
4906
+ inside: shapeResult.inside && effectResult.inside,
4907
+ margin: margin > defaultAngle ? margin : undefined,
4908
+ reason: "combined",
4909
+ };
4910
+ }
4911
+ return shapeResult ?? effectResult ?? defaultResult;
4912
+ };
4913
+ #getRollColor = color => {
4832
4914
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
4833
4915
  return color;
4834
4916
  }
@@ -4843,8 +4925,8 @@
4843
4925
  }
4844
4926
  return color;
4845
4927
  };
4846
- _initPosition = position => {
4847
- const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
4928
+ #initPosition = position => {
4929
+ const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
4848
4930
  if (!initialPosition) {
4849
4931
  throw new Error("a valid position cannot be found for particle");
4850
4932
  }
@@ -4867,45 +4949,58 @@
4867
4949
  }
4868
4950
  this.offset = Vector.origin;
4869
4951
  };
4952
+ #normalizeInsideCanvasResult = (result, reason) => {
4953
+ if (typeof result === "boolean") {
4954
+ return {
4955
+ inside: result,
4956
+ reason,
4957
+ };
4958
+ }
4959
+ return {
4960
+ inside: result.inside,
4961
+ margin: result.margin,
4962
+ reason: result.reason ?? reason,
4963
+ };
4964
+ };
4870
4965
  }
4871
4966
 
4872
4967
  class SpatialHashGrid {
4873
- _cellSize;
4874
- _cells = new Map();
4875
- _circlePool = [];
4876
- _circlePoolIdx;
4877
- _pendingCellSize;
4878
- _rectanglePool = [];
4879
- _rectanglePoolIdx;
4968
+ #cellSize;
4969
+ #cells = new Map();
4970
+ #circlePool = [];
4971
+ #circlePoolIdx;
4972
+ #pendingCellSize;
4973
+ #rectanglePool = [];
4974
+ #rectanglePoolIdx;
4880
4975
  constructor(cellSize) {
4881
- this._cellSize = cellSize;
4882
- this._circlePoolIdx = 0;
4883
- this._rectanglePoolIdx = 0;
4976
+ this.#cellSize = cellSize;
4977
+ this.#circlePoolIdx = 0;
4978
+ this.#rectanglePoolIdx = 0;
4884
4979
  }
4885
4980
  clear() {
4886
- this._cells.clear();
4887
- const pendingCellSize = this._pendingCellSize;
4981
+ this.#cells.clear();
4982
+ const pendingCellSize = this.#pendingCellSize;
4888
4983
  if (pendingCellSize) {
4889
- this._cellSize = pendingCellSize;
4984
+ this.#cellSize = pendingCellSize;
4890
4985
  }
4891
- this._pendingCellSize = undefined;
4986
+ this.#pendingCellSize = undefined;
4892
4987
  }
4893
4988
  insert(particle) {
4894
- const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
4895
- if (!this._cells.has(key)) {
4896
- this._cells.set(key, []);
4989
+ const { x, y } = particle.getPosition(), key = this.#cellKeyFromCoords(x, y);
4990
+ if (!this.#cells.has(key)) {
4991
+ this.#cells.set(key, []);
4897
4992
  }
4898
- this._cells.get(key)?.push(particle);
4993
+ this.#cells.get(key)?.push(particle);
4899
4994
  }
4900
4995
  query(range, check, out = []) {
4901
- const bounds = this._getRangeBounds(range);
4996
+ const bounds = this.#getRangeBounds(range);
4902
4997
  if (!bounds) {
4903
4998
  return out;
4904
4999
  }
4905
- 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);
5000
+ 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);
4906
5001
  for (let cx = minCellX; cx <= maxCellX; cx++) {
4907
5002
  for (let cy = minCellY; cy <= maxCellY; cy++) {
4908
- const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
5003
+ const key = `${cx}_${cy}`, cellParticles = this.#cells.get(key);
4909
5004
  if (!cellParticles) {
4910
5005
  continue;
4911
5006
  }
@@ -4922,29 +5017,29 @@
4922
5017
  return out;
4923
5018
  }
4924
5019
  queryCircle(position, radius, check, out = []) {
4925
- const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
4926
- this._releaseShapes();
5020
+ const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5021
+ this.#releaseShapes();
4927
5022
  return result;
4928
5023
  }
4929
5024
  queryRectangle(position, size, check, out = []) {
4930
- const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
4931
- this._releaseShapes();
5025
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5026
+ this.#releaseShapes();
4932
5027
  return result;
4933
5028
  }
4934
5029
  setCellSize(cellSize) {
4935
- this._pendingCellSize = cellSize;
5030
+ this.#pendingCellSize = cellSize;
4936
5031
  }
4937
- _acquireCircle(x, y, r) {
4938
- return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5032
+ #acquireCircle(x, y, r) {
5033
+ return (this.#circlePool[this.#circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
4939
5034
  }
4940
- _acquireRectangle(x, y, w, h) {
4941
- return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5035
+ #acquireRectangle(x, y, w, h) {
5036
+ return (this.#rectanglePool[this.#rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
4942
5037
  }
4943
- _cellKeyFromCoords(x, y) {
4944
- const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
5038
+ #cellKeyFromCoords(x, y) {
5039
+ const cellX = Math.floor(x / this.#cellSize), cellY = Math.floor(y / this.#cellSize);
4945
5040
  return `${cellX}_${cellY}`;
4946
5041
  }
4947
- _getRangeBounds(range) {
5042
+ #getRangeBounds(range) {
4948
5043
  if (range instanceof Circle) {
4949
5044
  const r = range.radius, { x, y } = range.position;
4950
5045
  return {
@@ -4965,53 +5060,53 @@
4965
5060
  }
4966
5061
  return null;
4967
5062
  }
4968
- _releaseShapes() {
4969
- this._circlePoolIdx = 0;
4970
- this._rectanglePoolIdx = 0;
5063
+ #releaseShapes() {
5064
+ this.#circlePoolIdx = 0;
5065
+ this.#rectanglePoolIdx = 0;
4971
5066
  }
4972
5067
  }
4973
5068
 
4974
5069
  class ParticlesManager {
4975
5070
  checkParticlePositionPlugins;
4976
5071
  grid;
4977
- _array;
4978
- _container;
4979
- _groupLimits;
4980
- _limit;
4981
- _nextId;
4982
- _particleBuckets;
4983
- _particleResetPlugins;
4984
- _particleUpdatePlugins;
4985
- _pluginManager;
4986
- _pool;
4987
- _postParticleUpdatePlugins;
4988
- _postUpdatePlugins;
4989
- _resizeFactor;
4990
- _updatePlugins;
4991
- _zBuckets;
5072
+ #array;
5073
+ #container;
5074
+ #groupLimits;
5075
+ #limit;
5076
+ #nextId;
5077
+ #particleBuckets;
5078
+ #particleResetPlugins;
5079
+ #particleUpdatePlugins;
5080
+ #pluginManager;
5081
+ #pool;
5082
+ #postParticleUpdatePlugins;
5083
+ #postUpdatePlugins;
5084
+ #resizeFactor;
5085
+ #updatePlugins;
5086
+ #zBuckets;
4992
5087
  constructor(pluginManager, container) {
4993
- this._pluginManager = pluginManager;
4994
- this._container = container;
4995
- this._nextId = 0;
4996
- this._array = [];
4997
- this._pool = [];
4998
- this._limit = 0;
4999
- this._groupLimits = new Map();
5000
- this._particleBuckets = new Map();
5001
- this._zBuckets = this._createBuckets(this._container.zLayers);
5088
+ this.#pluginManager = pluginManager;
5089
+ this.#container = container;
5090
+ this.#nextId = 0;
5091
+ this.#array = [];
5092
+ this.#pool = [];
5093
+ this.#limit = 0;
5094
+ this.#groupLimits = new Map();
5095
+ this.#particleBuckets = new Map();
5096
+ this.#zBuckets = this.#createBuckets(this.#container.zLayers);
5002
5097
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
5003
5098
  this.checkParticlePositionPlugins = [];
5004
- this._particleResetPlugins = [];
5005
- this._particleUpdatePlugins = [];
5006
- this._postUpdatePlugins = [];
5007
- this._postParticleUpdatePlugins = [];
5008
- this._updatePlugins = [];
5099
+ this.#particleResetPlugins = [];
5100
+ this.#particleUpdatePlugins = [];
5101
+ this.#postUpdatePlugins = [];
5102
+ this.#postParticleUpdatePlugins = [];
5103
+ this.#updatePlugins = [];
5009
5104
  }
5010
5105
  get count() {
5011
- return this._array.length;
5106
+ return this.#array.length;
5012
5107
  }
5013
5108
  addParticle(position, overrideOptions, group, initializer) {
5014
- const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
5109
+ const limitMode = this.#container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this.#limit : (this.#groupLimits.get(group) ?? this.#limit), currentCount = this.count;
5015
5110
  if (limit > minLimit) {
5016
5111
  switch (limitMode) {
5017
5112
  case LimitMode.delete: {
@@ -5029,20 +5124,20 @@
5029
5124
  }
5030
5125
  }
5031
5126
  try {
5032
- const particle = this._pool.pop() ?? new Particle(this._pluginManager, this._container);
5033
- particle.init(this._nextId, position, overrideOptions, group);
5127
+ const particle = this.#pool.pop() ?? new Particle(this.#pluginManager, this.#container);
5128
+ particle.init(this.#nextId, position, overrideOptions, group);
5034
5129
  let canAdd = true;
5035
5130
  if (initializer) {
5036
5131
  canAdd = initializer(particle);
5037
5132
  }
5038
5133
  if (!canAdd) {
5039
- this._pool.push(particle);
5134
+ this.#pool.push(particle);
5040
5135
  return;
5041
5136
  }
5042
- this._array.push(particle);
5043
- this._insertParticleIntoBucket(particle);
5044
- this._nextId++;
5045
- this._container.dispatchEvent(EventType.particleAdded, {
5137
+ this.#array.push(particle);
5138
+ this.#insertParticleIntoBucket(particle);
5139
+ this.#nextId++;
5140
+ this.#container.dispatchEvent(EventType.particleAdded, {
5046
5141
  particle,
5047
5142
  });
5048
5143
  return particle;
@@ -5053,25 +5148,25 @@
5053
5148
  return undefined;
5054
5149
  }
5055
5150
  clear() {
5056
- this._array = [];
5057
- this._particleBuckets.clear();
5058
- this._resetBuckets(this._container.zLayers);
5151
+ this.#array = [];
5152
+ this.#particleBuckets.clear();
5153
+ this.#resetBuckets(this.#container.zLayers);
5059
5154
  }
5060
5155
  destroy() {
5061
- this._array = [];
5062
- this._pool.length = 0;
5063
- this._particleBuckets.clear();
5064
- this._zBuckets = [];
5156
+ this.#array = [];
5157
+ this.#pool.length = 0;
5158
+ this.#particleBuckets.clear();
5159
+ this.#zBuckets = [];
5065
5160
  this.checkParticlePositionPlugins = [];
5066
- this._particleResetPlugins = [];
5067
- this._particleUpdatePlugins = [];
5068
- this._postUpdatePlugins = [];
5069
- this._postParticleUpdatePlugins = [];
5070
- this._updatePlugins = [];
5161
+ this.#particleResetPlugins = [];
5162
+ this.#particleUpdatePlugins = [];
5163
+ this.#postUpdatePlugins = [];
5164
+ this.#postParticleUpdatePlugins = [];
5165
+ this.#updatePlugins = [];
5071
5166
  }
5072
5167
  drawParticles(delta) {
5073
- for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
5074
- const bucket = this._zBuckets[i];
5168
+ for (let i = this.#zBuckets.length - one; i >= minIndex; i--) {
5169
+ const bucket = this.#zBuckets[i];
5075
5170
  if (!bucket) {
5076
5171
  continue;
5077
5172
  }
@@ -5081,24 +5176,24 @@
5081
5176
  }
5082
5177
  }
5083
5178
  filter(condition) {
5084
- return this._array.filter(condition);
5179
+ return this.#array.filter(condition);
5085
5180
  }
5086
5181
  find(condition) {
5087
- return this._array.find(condition);
5182
+ return this.#array.find(condition);
5088
5183
  }
5089
5184
  get(index) {
5090
- return this._array[index];
5185
+ return this.#array[index];
5091
5186
  }
5092
5187
  async init() {
5093
- const container = this._container, options = container.actualOptions;
5188
+ const container = this.#container, options = container.actualOptions;
5094
5189
  this.checkParticlePositionPlugins = [];
5095
- this._updatePlugins = [];
5096
- this._particleUpdatePlugins = [];
5097
- this._postUpdatePlugins = [];
5098
- this._particleResetPlugins = [];
5099
- this._postParticleUpdatePlugins = [];
5100
- this._particleBuckets.clear();
5101
- this._resetBuckets(container.zLayers);
5190
+ this.#updatePlugins = [];
5191
+ this.#particleUpdatePlugins = [];
5192
+ this.#postUpdatePlugins = [];
5193
+ this.#particleResetPlugins = [];
5194
+ this.#postParticleUpdatePlugins = [];
5195
+ this.#particleBuckets.clear();
5196
+ this.#resetBuckets(container.zLayers);
5102
5197
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
5103
5198
  for (const plugin of container.plugins) {
5104
5199
  if (plugin.redrawInit) {
@@ -5108,26 +5203,26 @@
5108
5203
  this.checkParticlePositionPlugins.push(plugin);
5109
5204
  }
5110
5205
  if (plugin.update) {
5111
- this._updatePlugins.push(plugin);
5206
+ this.#updatePlugins.push(plugin);
5112
5207
  }
5113
5208
  if (plugin.particleUpdate) {
5114
- this._particleUpdatePlugins.push(plugin);
5209
+ this.#particleUpdatePlugins.push(plugin);
5115
5210
  }
5116
5211
  if (plugin.postUpdate) {
5117
- this._postUpdatePlugins.push(plugin);
5212
+ this.#postUpdatePlugins.push(plugin);
5118
5213
  }
5119
5214
  if (plugin.particleReset) {
5120
- this._particleResetPlugins.push(plugin);
5215
+ this.#particleResetPlugins.push(plugin);
5121
5216
  }
5122
5217
  if (plugin.postParticleUpdate) {
5123
- this._postParticleUpdatePlugins.push(plugin);
5218
+ this.#postParticleUpdatePlugins.push(plugin);
5124
5219
  }
5125
5220
  }
5126
- await this._container.initDrawersAndUpdaters();
5127
- for (const drawer of this._container.effectDrawers.values()) {
5221
+ await this.#container.initDrawersAndUpdaters();
5222
+ for (const drawer of this.#container.effectDrawers.values()) {
5128
5223
  await drawer.init?.(container);
5129
5224
  }
5130
- for (const drawer of this._container.shapeDrawers.values()) {
5225
+ for (const drawer of this.#container.shapeDrawers.values()) {
5131
5226
  await drawer.init?.(container);
5132
5227
  }
5133
5228
  let handled = false;
@@ -5161,10 +5256,10 @@
5161
5256
  async redraw() {
5162
5257
  this.clear();
5163
5258
  await this.init();
5164
- this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
5259
+ this.#container.canvas.render.drawParticles({ value: 0, factor: 0 });
5165
5260
  }
5166
5261
  remove(particle, group, override) {
5167
- this.removeAt(this._array.indexOf(particle), undefined, group, override);
5262
+ this.removeAt(this.#array.indexOf(particle), undefined, group, override);
5168
5263
  }
5169
5264
  removeAt(index, quantity = defaultRemoveQuantity, group, override) {
5170
5265
  if (index < minIndex || index > this.count) {
@@ -5172,7 +5267,7 @@
5172
5267
  }
5173
5268
  let deleted = 0;
5174
5269
  for (let i = index; deleted < quantity && i < this.count; i++) {
5175
- if (this._removeParticle(i, group, override)) {
5270
+ if (this.#removeParticle(i, group, override)) {
5176
5271
  i--;
5177
5272
  deleted++;
5178
5273
  }
@@ -5182,9 +5277,9 @@
5182
5277
  this.removeAt(minIndex, quantity, group);
5183
5278
  }
5184
5279
  setDensity() {
5185
- const options = this._container.actualOptions, groups = options.particles.groups;
5280
+ const options = this.#container.actualOptions, groups = options.particles.groups;
5186
5281
  let pluginsCount = 0;
5187
- for (const plugin of this._container.plugins) {
5282
+ for (const plugin of this.#container.plugins) {
5188
5283
  if (plugin.particlesDensityCount) {
5189
5284
  pluginsCount += plugin.particlesDensityCount();
5190
5285
  }
@@ -5194,51 +5289,51 @@
5194
5289
  if (!groupData) {
5195
5290
  continue;
5196
5291
  }
5197
- const groupDataOptions = loadParticlesOptions(this._pluginManager, this._container, groupData);
5198
- this._applyDensity(groupDataOptions, pluginsCount, group);
5292
+ const groupDataOptions = loadParticlesOptions(this.#pluginManager, this.#container, groupData);
5293
+ this.#applyDensity(groupDataOptions, pluginsCount, group);
5199
5294
  }
5200
- this._applyDensity(options.particles, pluginsCount);
5295
+ this.#applyDensity(options.particles, pluginsCount);
5201
5296
  }
5202
5297
  setResizeFactor(factor) {
5203
- this._resizeFactor = factor;
5298
+ this.#resizeFactor = factor;
5204
5299
  }
5205
5300
  update(delta) {
5206
5301
  this.grid.clear();
5207
- for (const plugin of this._updatePlugins) {
5302
+ for (const plugin of this.#updatePlugins) {
5208
5303
  plugin.update?.(delta);
5209
5304
  }
5210
- const particlesToDelete = this._updateParticlesPhase1(delta);
5211
- for (const plugin of this._postUpdatePlugins) {
5305
+ const particlesToDelete = this.#updateParticlesPhase1(delta);
5306
+ for (const plugin of this.#postUpdatePlugins) {
5212
5307
  plugin.postUpdate?.(delta);
5213
5308
  }
5214
- this._updateParticlesPhase2(delta, particlesToDelete);
5309
+ this.#updateParticlesPhase2(delta, particlesToDelete);
5215
5310
  if (particlesToDelete.size) {
5216
5311
  for (const particle of particlesToDelete) {
5217
5312
  this.remove(particle);
5218
5313
  }
5219
5314
  }
5220
- delete this._resizeFactor;
5315
+ this.#resizeFactor = undefined;
5221
5316
  }
5222
- _addToPool = (...particles) => {
5223
- this._pool.push(...particles);
5317
+ #addToPool = (...particles) => {
5318
+ this.#pool.push(...particles);
5224
5319
  };
5225
- _applyDensity = (options, pluginsCount, group, groupOptions) => {
5320
+ #applyDensity = (options, pluginsCount, group, groupOptions) => {
5226
5321
  const numberOptions = options.number;
5227
5322
  if (!numberOptions.density.enable) {
5228
5323
  if (group === undefined) {
5229
- this._limit = numberOptions.limit.value;
5324
+ this.#limit = numberOptions.limit.value;
5230
5325
  }
5231
5326
  else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
5232
- this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5327
+ this.#groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5233
5328
  }
5234
5329
  return;
5235
5330
  }
5236
- 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);
5331
+ 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);
5237
5332
  if (group === undefined) {
5238
- this._limit = numberOptions.limit.value * densityFactor;
5333
+ this.#limit = numberOptions.limit.value * densityFactor;
5239
5334
  }
5240
5335
  else {
5241
- this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
5336
+ this.#groupLimits.set(group, numberOptions.limit.value * densityFactor);
5242
5337
  }
5243
5338
  if (particlesCount < particlesNumber) {
5244
5339
  this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
@@ -5247,18 +5342,18 @@
5247
5342
  this.removeQuantity(particlesCount - particlesNumber, group);
5248
5343
  }
5249
5344
  };
5250
- _createBuckets = (zLayers) => {
5345
+ #createBuckets = (zLayers) => {
5251
5346
  const bucketCount = Math.max(Math.floor(zLayers), one);
5252
5347
  return Array.from({ length: bucketCount }, () => []);
5253
5348
  };
5254
- _getBucketIndex = (zIndex) => {
5255
- const maxBucketIndex = this._zBuckets.length - one;
5349
+ #getBucketIndex = (zIndex) => {
5350
+ const maxBucketIndex = this.#zBuckets.length - one;
5256
5351
  if (maxBucketIndex <= minIndex) {
5257
5352
  return minIndex;
5258
5353
  }
5259
5354
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
5260
5355
  };
5261
- _getParticleInsertIndex = (bucket, particleId) => {
5356
+ #getParticleInsertIndex = (bucket, particleId) => {
5262
5357
  let start = minIndex, end = bucket.length;
5263
5358
  while (start < end) {
5264
5359
  const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
@@ -5275,8 +5370,8 @@
5275
5370
  }
5276
5371
  return start;
5277
5372
  };
5278
- _initDensityFactor = densityOptions => {
5279
- const container = this._container;
5373
+ #initDensityFactor = densityOptions => {
5374
+ const container = this.#container;
5280
5375
  if (!densityOptions.enable) {
5281
5376
  return defaultDensityFactor;
5282
5377
  }
@@ -5286,82 +5381,82 @@
5286
5381
  }
5287
5382
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
5288
5383
  };
5289
- _insertParticleIntoBucket = (particle) => {
5290
- const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5384
+ #insertParticleIntoBucket = (particle) => {
5385
+ const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5291
5386
  if (!bucket) {
5292
5387
  return;
5293
5388
  }
5294
- bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
5295
- this._particleBuckets.set(particle.id, bucketIndex);
5389
+ bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
5390
+ this.#particleBuckets.set(particle.id, bucketIndex);
5296
5391
  };
5297
- _removeParticle = (index, group, override) => {
5298
- const particle = this._array[index];
5392
+ #removeParticle = (index, group, override) => {
5393
+ const particle = this.#array[index];
5299
5394
  if (!particle) {
5300
5395
  return false;
5301
5396
  }
5302
5397
  if (particle.group !== group) {
5303
5398
  return false;
5304
5399
  }
5305
- this._array.splice(index, deleteCount);
5306
- this._removeParticleFromBucket(particle);
5400
+ this.#array.splice(index, deleteCount);
5401
+ this.#removeParticleFromBucket(particle);
5307
5402
  particle.destroy(override);
5308
- this._container.dispatchEvent(EventType.particleRemoved, {
5403
+ this.#container.dispatchEvent(EventType.particleRemoved, {
5309
5404
  particle,
5310
5405
  });
5311
- this._addToPool(particle);
5406
+ this.#addToPool(particle);
5312
5407
  return true;
5313
5408
  };
5314
- _removeParticleFromBucket = (particle) => {
5315
- const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5409
+ #removeParticleFromBucket = (particle) => {
5410
+ const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5316
5411
  if (!bucket) {
5317
- this._particleBuckets.delete(particle.id);
5412
+ this.#particleBuckets.delete(particle.id);
5318
5413
  return;
5319
5414
  }
5320
- const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
5415
+ const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
5321
5416
  if (bucket[particleIndex]?.id !== particle.id) {
5322
- this._particleBuckets.delete(particle.id);
5417
+ this.#particleBuckets.delete(particle.id);
5323
5418
  return;
5324
5419
  }
5325
5420
  bucket.splice(particleIndex, deleteCount);
5326
- this._particleBuckets.delete(particle.id);
5421
+ this.#particleBuckets.delete(particle.id);
5327
5422
  };
5328
- _resetBuckets = (zLayers) => {
5423
+ #resetBuckets = (zLayers) => {
5329
5424
  const bucketCount = Math.max(Math.floor(zLayers), one);
5330
- if (this._zBuckets.length !== bucketCount) {
5331
- this._zBuckets = this._createBuckets(bucketCount);
5425
+ if (this.#zBuckets.length !== bucketCount) {
5426
+ this.#zBuckets = this.#createBuckets(bucketCount);
5332
5427
  return;
5333
5428
  }
5334
- for (const bucket of this._zBuckets) {
5429
+ for (const bucket of this.#zBuckets) {
5335
5430
  bucket.length = minIndex;
5336
5431
  }
5337
5432
  };
5338
- _updateParticleBucket = (particle) => {
5339
- const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
5433
+ #updateParticleBucket = (particle) => {
5434
+ const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
5340
5435
  if (currentBucketIndex === undefined) {
5341
- this._insertParticleIntoBucket(particle);
5436
+ this.#insertParticleIntoBucket(particle);
5342
5437
  return;
5343
5438
  }
5344
5439
  if (currentBucketIndex === newBucketIndex) {
5345
5440
  return;
5346
5441
  }
5347
- const currentBucket = this._zBuckets[currentBucketIndex];
5442
+ const currentBucket = this.#zBuckets[currentBucketIndex];
5348
5443
  if (currentBucket) {
5349
- const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
5444
+ const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
5350
5445
  if (currentBucket[particleIndex]?.id === particle.id) {
5351
5446
  currentBucket.splice(particleIndex, deleteCount);
5352
5447
  }
5353
5448
  }
5354
- const newBucket = this._zBuckets[newBucketIndex];
5449
+ const newBucket = this.#zBuckets[newBucketIndex];
5355
5450
  if (!newBucket) {
5356
- this._particleBuckets.set(particle.id, newBucketIndex);
5451
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5357
5452
  return;
5358
5453
  }
5359
- newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
5360
- this._particleBuckets.set(particle.id, newBucketIndex);
5454
+ newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
5455
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5361
5456
  };
5362
- _updateParticlesPhase1 = (delta) => {
5363
- const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
5364
- for (const particle of this._array) {
5457
+ #updateParticlesPhase1 = (delta) => {
5458
+ const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
5459
+ for (const particle of this.#array) {
5365
5460
  if (resizeFactor && !particle.ignoresResizeRatio) {
5366
5461
  particle.position.x *= resizeFactor.width;
5367
5462
  particle.position.y *= resizeFactor.height;
@@ -5369,10 +5464,10 @@
5369
5464
  particle.initialPosition.y *= resizeFactor.height;
5370
5465
  }
5371
5466
  particle.ignoresResizeRatio = false;
5372
- for (const plugin of this._particleResetPlugins) {
5467
+ for (const plugin of this.#particleResetPlugins) {
5373
5468
  plugin.particleReset?.(particle);
5374
5469
  }
5375
- for (const plugin of this._particleUpdatePlugins) {
5470
+ for (const plugin of this.#particleUpdatePlugins) {
5376
5471
  if (particle.destroyed) {
5377
5472
  break;
5378
5473
  }
@@ -5386,36 +5481,36 @@
5386
5481
  }
5387
5482
  return particlesToDelete;
5388
5483
  };
5389
- _updateParticlesPhase2 = (delta, particlesToDelete) => {
5390
- for (const particle of this._array) {
5484
+ #updateParticlesPhase2 = (delta, particlesToDelete) => {
5485
+ for (const particle of this.#array) {
5391
5486
  if (particle.destroyed) {
5392
5487
  particlesToDelete.add(particle);
5393
5488
  continue;
5394
5489
  }
5395
- for (const updater of this._container.particleUpdaters) {
5490
+ for (const updater of this.#container.particleUpdaters) {
5396
5491
  updater.update(particle, delta);
5397
5492
  }
5398
5493
  if (!particle.spawning) {
5399
- for (const plugin of this._postParticleUpdatePlugins) {
5494
+ for (const plugin of this.#postParticleUpdatePlugins) {
5400
5495
  plugin.postParticleUpdate?.(particle, delta);
5401
5496
  }
5402
5497
  }
5403
- this._updateParticleBucket(particle);
5498
+ this.#updateParticleBucket(particle);
5404
5499
  }
5405
5500
  };
5406
5501
  }
5407
5502
 
5408
5503
  class Retina {
5409
- container;
5410
5504
  pixelRatio;
5411
5505
  reduceFactor;
5506
+ #container;
5412
5507
  constructor(container) {
5413
- this.container = container;
5508
+ this.#container = container;
5414
5509
  this.pixelRatio = defaultRatio;
5415
5510
  this.reduceFactor = defaultReduceFactor;
5416
5511
  }
5417
5512
  init() {
5418
- const container = this.container, options = container.actualOptions;
5513
+ const container = this.#container, options = container.actualOptions;
5419
5514
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
5420
5515
  this.reduceFactor = defaultReduceFactor;
5421
5516
  const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
@@ -5429,7 +5524,6 @@
5429
5524
  props.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
5430
5525
  props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
5431
5526
  props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
5432
- props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
5433
5527
  const maxDistance = props.maxDistance;
5434
5528
  maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
5435
5529
  maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
@@ -5467,73 +5561,73 @@
5467
5561
  shapeDrawers;
5468
5562
  started;
5469
5563
  zLayers;
5470
- _delay;
5471
- _delayTimeout;
5472
- _delta = { value: 0, factor: 0 };
5473
- _dispatchCallback;
5474
- _drawAnimationFrame;
5475
- _duration;
5476
- _eventListeners;
5477
- _firstStart;
5478
- _initialSourceOptions;
5479
- _lastFrameTime;
5480
- _lifeTime;
5481
- _onDestroy;
5482
- _options;
5483
- _paused;
5484
- _pluginManager;
5485
- _smooth;
5486
- _sourceOptions;
5564
+ #delay;
5565
+ #delayTimeout;
5566
+ #delta = { value: 0, factor: 0 };
5567
+ #dispatchCallback;
5568
+ #drawAnimationFrame;
5569
+ #duration;
5570
+ #eventListeners;
5571
+ #firstStart;
5572
+ #initialSourceOptions;
5573
+ #lastFrameTime;
5574
+ #lifeTime;
5575
+ #onDestroy;
5576
+ #options;
5577
+ #paused;
5578
+ #pluginManager;
5579
+ #smooth;
5580
+ #sourceOptions;
5487
5581
  constructor(params) {
5488
5582
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
5489
- this._pluginManager = pluginManager;
5490
- this._dispatchCallback = dispatchCallback;
5491
- this._onDestroy = onDestroy;
5583
+ this.#pluginManager = pluginManager;
5584
+ this.#dispatchCallback = dispatchCallback;
5585
+ this.#onDestroy = onDestroy;
5492
5586
  this.id = Symbol(id);
5493
5587
  this.fpsLimit = 120;
5494
5588
  this.hdr = false;
5495
- this._smooth = false;
5496
- this._delay = 0;
5497
- this._duration = 0;
5498
- this._lifeTime = 0;
5499
- this._firstStart = true;
5589
+ this.#smooth = false;
5590
+ this.#delay = 0;
5591
+ this.#duration = 0;
5592
+ this.#lifeTime = 0;
5593
+ this.#firstStart = true;
5500
5594
  this.started = false;
5501
5595
  this.destroyed = false;
5502
- this._paused = true;
5503
- this._lastFrameTime = 0;
5596
+ this.#paused = true;
5597
+ this.#lastFrameTime = 0;
5504
5598
  this.zLayers = 100;
5505
5599
  this.pageHidden = false;
5506
- this._sourceOptions = sourceOptions;
5507
- this._initialSourceOptions = sourceOptions;
5600
+ this.#sourceOptions = sourceOptions;
5601
+ this.#initialSourceOptions = sourceOptions;
5508
5602
  this.effectDrawers = new Map();
5509
5603
  this.shapeDrawers = new Map();
5510
5604
  this.particleUpdaters = [];
5511
5605
  this.retina = new Retina(this);
5512
- this.canvas = new CanvasManager(this._pluginManager, this);
5513
- this.particles = new ParticlesManager(this._pluginManager, this);
5606
+ this.canvas = new CanvasManager(this.#pluginManager, this);
5607
+ this.particles = new ParticlesManager(this.#pluginManager, this);
5514
5608
  this.plugins = [];
5515
5609
  this.particleDestroyedPlugins = [];
5516
5610
  this.particleCreatedPlugins = [];
5517
5611
  this.particlePositionPlugins = [];
5518
- this._options = loadContainerOptions(this._pluginManager, this);
5519
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
5520
- this._eventListeners = new EventListeners(this);
5612
+ this.#options = loadContainerOptions(this.#pluginManager, this);
5613
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
5614
+ this.#eventListeners = new EventListeners(this);
5521
5615
  this.dispatchEvent(EventType.containerBuilt);
5522
5616
  }
5523
5617
  get animationStatus() {
5524
- return !this._paused && !this.pageHidden && guardCheck(this);
5618
+ return !this.#paused && !this.pageHidden && guardCheck(this);
5525
5619
  }
5526
5620
  get options() {
5527
- return this._options;
5621
+ return this.#options;
5528
5622
  }
5529
5623
  get sourceOptions() {
5530
- return this._sourceOptions;
5624
+ return this.#sourceOptions;
5531
5625
  }
5532
5626
  addLifeTime(value) {
5533
- this._lifeTime += value;
5627
+ this.#lifeTime += value;
5534
5628
  }
5535
5629
  alive() {
5536
- return !this._duration || this._lifeTime <= this._duration;
5630
+ return !this.#duration || this.#lifeTime <= this.#duration;
5537
5631
  }
5538
5632
  destroy(remove = true) {
5539
5633
  if (!guardCheck(this)) {
@@ -5555,13 +5649,13 @@
5555
5649
  this.shapeDrawers = new Map();
5556
5650
  this.particleUpdaters = [];
5557
5651
  this.plugins.length = 0;
5558
- this._pluginManager.clearPlugins(this);
5652
+ this.#pluginManager.clearPlugins(this);
5559
5653
  this.destroyed = true;
5560
- this._onDestroy(remove);
5654
+ this.#onDestroy(remove);
5561
5655
  this.dispatchEvent(EventType.containerDestroyed);
5562
5656
  }
5563
5657
  dispatchEvent(type, data) {
5564
- this._dispatchCallback(type, {
5658
+ this.#dispatchCallback(type, {
5565
5659
  container: this,
5566
5660
  data,
5567
5661
  });
@@ -5571,12 +5665,12 @@
5571
5665
  return;
5572
5666
  }
5573
5667
  let refreshTime = force;
5574
- this._drawAnimationFrame = animate((timestamp) => {
5668
+ this.#drawAnimationFrame = animate((timestamp) => {
5575
5669
  if (refreshTime) {
5576
- this._lastFrameTime = undefined;
5670
+ this.#lastFrameTime = undefined;
5577
5671
  refreshTime = false;
5578
5672
  }
5579
- this._nextFrame(timestamp);
5673
+ this.#nextFrame(timestamp);
5580
5674
  });
5581
5675
  }
5582
5676
  async export(type, options = {}) {
@@ -5598,7 +5692,7 @@
5598
5692
  return;
5599
5693
  }
5600
5694
  const allContainerPlugins = new Map();
5601
- for (const plugin of this._pluginManager.plugins) {
5695
+ for (const plugin of this.#pluginManager.plugins) {
5602
5696
  const containerPlugin = await plugin.getPlugin(this);
5603
5697
  if (containerPlugin.preInit) {
5604
5698
  await containerPlugin.preInit();
@@ -5606,8 +5700,8 @@
5606
5700
  allContainerPlugins.set(plugin, containerPlugin);
5607
5701
  }
5608
5702
  await this.initDrawersAndUpdaters();
5609
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
5610
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
5703
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
5704
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
5611
5705
  this.plugins.length = 0;
5612
5706
  this.particleDestroyedPlugins.length = 0;
5613
5707
  this.particleCreatedPlugins.length = 0;
@@ -5634,11 +5728,11 @@
5634
5728
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
5635
5729
  this.hdr = hdr;
5636
5730
  this.zLayers = zLayers;
5637
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
5638
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
5639
- this._lifeTime = 0;
5731
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
5732
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
5733
+ this.#lifeTime = 0;
5640
5734
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
5641
- this._smooth = smooth;
5735
+ this.#smooth = smooth;
5642
5736
  for (const plugin of this.plugins) {
5643
5737
  await plugin.init?.();
5644
5738
  }
@@ -5651,7 +5745,7 @@
5651
5745
  this.dispatchEvent(EventType.particlesSetup);
5652
5746
  }
5653
5747
  async initDrawersAndUpdaters() {
5654
- const pluginManager = this._pluginManager;
5748
+ const pluginManager = this.#pluginManager;
5655
5749
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
5656
5750
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
5657
5751
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -5660,18 +5754,18 @@
5660
5754
  if (!guardCheck(this)) {
5661
5755
  return;
5662
5756
  }
5663
- if (this._drawAnimationFrame !== undefined) {
5664
- cancelAnimation(this._drawAnimationFrame);
5665
- delete this._drawAnimationFrame;
5757
+ if (this.#drawAnimationFrame !== undefined) {
5758
+ cancelAnimation(this.#drawAnimationFrame);
5759
+ this.#drawAnimationFrame = undefined;
5666
5760
  }
5667
- if (this._paused) {
5761
+ if (this.#paused) {
5668
5762
  return;
5669
5763
  }
5670
5764
  for (const plugin of this.plugins) {
5671
5765
  plugin.pause?.();
5672
5766
  }
5673
5767
  if (!this.pageHidden) {
5674
- this._paused = true;
5768
+ this.#paused = true;
5675
5769
  }
5676
5770
  this.dispatchEvent(EventType.containerPaused);
5677
5771
  }
@@ -5679,13 +5773,13 @@
5679
5773
  if (!guardCheck(this)) {
5680
5774
  return;
5681
5775
  }
5682
- const needsUpdate = this._paused || force;
5683
- if (this._firstStart && !this.actualOptions.autoPlay) {
5684
- this._firstStart = false;
5776
+ const needsUpdate = this.#paused || force;
5777
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
5778
+ this.#firstStart = false;
5685
5779
  return;
5686
5780
  }
5687
- if (this._paused) {
5688
- this._paused = false;
5781
+ if (this.#paused) {
5782
+ this.#paused = false;
5689
5783
  }
5690
5784
  if (needsUpdate) {
5691
5785
  for (const plugin of this.plugins) {
@@ -5708,10 +5802,10 @@
5708
5802
  if (!guardCheck(this)) {
5709
5803
  return;
5710
5804
  }
5711
- this._initialSourceOptions = sourceOptions;
5712
- this._sourceOptions = sourceOptions;
5713
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
5714
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
5805
+ this.#initialSourceOptions = sourceOptions;
5806
+ this.#sourceOptions = sourceOptions;
5807
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
5808
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
5715
5809
  return this.refresh();
5716
5810
  }
5717
5811
  async start() {
@@ -5722,7 +5816,7 @@
5722
5816
  this.started = true;
5723
5817
  await new Promise(resolve => {
5724
5818
  const start = async () => {
5725
- this._eventListeners.addListeners();
5819
+ this.#eventListeners.addListeners();
5726
5820
  for (const plugin of this.plugins) {
5727
5821
  await plugin.start?.();
5728
5822
  }
@@ -5730,20 +5824,20 @@
5730
5824
  this.play();
5731
5825
  resolve();
5732
5826
  };
5733
- this._delayTimeout = setTimeout(() => void start(), this._delay);
5827
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
5734
5828
  });
5735
5829
  }
5736
5830
  stop() {
5737
5831
  if (!guardCheck(this) || !this.started) {
5738
5832
  return;
5739
5833
  }
5740
- if (this._delayTimeout) {
5741
- clearTimeout(this._delayTimeout);
5742
- delete this._delayTimeout;
5834
+ if (this.#delayTimeout) {
5835
+ clearTimeout(this.#delayTimeout);
5836
+ this.#delayTimeout = undefined;
5743
5837
  }
5744
- this._firstStart = true;
5838
+ this.#firstStart = true;
5745
5839
  this.started = false;
5746
- this._eventListeners.removeListeners();
5840
+ this.#eventListeners.removeListeners();
5747
5841
  this.pause();
5748
5842
  this.particles.clear();
5749
5843
  this.canvas.stop();
@@ -5753,7 +5847,7 @@
5753
5847
  this.particleCreatedPlugins.length = 0;
5754
5848
  this.particleDestroyedPlugins.length = 0;
5755
5849
  this.particlePositionPlugins.length = 0;
5756
- this._sourceOptions = this._options;
5850
+ this.#sourceOptions = this.#options;
5757
5851
  this.dispatchEvent(EventType.containerStopped);
5758
5852
  }
5759
5853
  updateActualOptions() {
@@ -5765,23 +5859,23 @@
5765
5859
  }
5766
5860
  return refresh;
5767
5861
  }
5768
- _nextFrame = (timestamp) => {
5862
+ #nextFrame = (timestamp) => {
5769
5863
  try {
5770
- if (!this._smooth &&
5771
- this._lastFrameTime !== undefined &&
5772
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
5864
+ if (!this.#smooth &&
5865
+ this.#lastFrameTime !== undefined &&
5866
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
5773
5867
  this.draw(false);
5774
5868
  return;
5775
5869
  }
5776
- this._lastFrameTime ??= timestamp;
5777
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
5778
- this.addLifeTime(this._delta.value);
5779
- this._lastFrameTime = timestamp;
5780
- if (this._delta.value > millisecondsToSeconds) {
5870
+ this.#lastFrameTime ??= timestamp;
5871
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
5872
+ this.addLifeTime(this.#delta.value);
5873
+ this.#lastFrameTime = timestamp;
5874
+ if (this.#delta.value > millisecondsToSeconds) {
5781
5875
  this.draw(false);
5782
5876
  return;
5783
5877
  }
5784
- this.canvas.render.drawParticles(this._delta);
5878
+ this.canvas.render.drawParticles(this.#delta);
5785
5879
  if (!this.alive()) {
5786
5880
  this.destroy();
5787
5881
  return;
@@ -5802,10 +5896,10 @@
5802
5896
  });
5803
5897
 
5804
5898
  class BlendPluginInstance {
5805
- _container;
5806
- _defaultCompositeValue;
5899
+ #container;
5900
+ #defaultCompositeValue;
5807
5901
  constructor(container) {
5808
- this._container = container;
5902
+ this.#container = container;
5809
5903
  }
5810
5904
  drawParticleCleanup(context, particle) {
5811
5905
  if (!particle.options.blend?.enable) {
@@ -5822,14 +5916,14 @@
5822
5916
  context.globalCompositeOperation = particle.options.blend.mode;
5823
5917
  }
5824
5918
  drawSettingsCleanup(context) {
5825
- if (!this._defaultCompositeValue) {
5919
+ if (!this.#defaultCompositeValue) {
5826
5920
  return;
5827
5921
  }
5828
- context.globalCompositeOperation = this._defaultCompositeValue;
5922
+ context.globalCompositeOperation = this.#defaultCompositeValue;
5829
5923
  }
5830
5924
  drawSettingsSetup(context) {
5831
- const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
5832
- this._defaultCompositeValue = previousComposite;
5925
+ const previousComposite = context.globalCompositeOperation, blend = this.#container.actualOptions.blend;
5926
+ this.#defaultCompositeValue = previousComposite;
5833
5927
  context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
5834
5928
  }
5835
5929
  }
@@ -5972,11 +6066,11 @@
5972
6066
  class MovePluginInstance {
5973
6067
  availablePathGenerators;
5974
6068
  pathGenerators;
5975
- _container;
5976
- _pluginManager;
6069
+ #container;
6070
+ #pluginManager;
5977
6071
  constructor(pluginManager, container) {
5978
- this._pluginManager = pluginManager;
5979
- this._container = container;
6072
+ this.#pluginManager = pluginManager;
6073
+ this.#container = container;
5980
6074
  this.availablePathGenerators = new Map();
5981
6075
  this.pathGenerators = new Map();
5982
6076
  }
@@ -6007,7 +6101,7 @@
6007
6101
  acceleration: getRangeValue(gravityOptions.acceleration),
6008
6102
  inverse: gravityOptions.inverse,
6009
6103
  };
6010
- initSpin(this._container, particle);
6104
+ initSpin(this.#container, particle);
6011
6105
  }
6012
6106
  particleDestroyed(particle) {
6013
6107
  const pathGenerator = particle.pathGenerator;
@@ -6018,7 +6112,7 @@
6018
6112
  if (!moveOptions.enable) {
6019
6113
  return;
6020
6114
  }
6021
- 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;
6115
+ 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;
6022
6116
  if (moveOptions.spin.enable) {
6023
6117
  spin(container, particle, moveSpeed, reduceFactor);
6024
6118
  }
@@ -6028,18 +6122,18 @@
6028
6122
  applyDistance(particle);
6029
6123
  }
6030
6124
  preInit() {
6031
- return this._init();
6125
+ return this.#init();
6032
6126
  }
6033
6127
  redrawInit() {
6034
- return this._init();
6128
+ return this.#init();
6035
6129
  }
6036
6130
  update() {
6037
6131
  for (const pathGenerator of this.pathGenerators.values()) {
6038
6132
  pathGenerator.update();
6039
6133
  }
6040
6134
  }
6041
- async _init() {
6042
- const availablePathGenerators = await this._pluginManager.getPathGenerators?.(this._container, true);
6135
+ async #init() {
6136
+ const availablePathGenerators = await this.#pluginManager.getPathGenerators?.(this.#container, true);
6043
6137
  if (!availablePathGenerators) {
6044
6138
  return;
6045
6139
  }