@tsparticles/preset-matrix 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),
@@ -3854,7 +3871,7 @@
3854
3871
  }
3855
3872
 
3856
3873
  async function loadMatrixShape(engine) {
3857
- engine.checkVersion("4.0.5");
3874
+ engine.checkVersion("4.1.1");
3858
3875
  await engine.pluginManager.register(e => {
3859
3876
  e.pluginManager.addShape(["matrix"], () => Promise.resolve(new MatrixDrawer()));
3860
3877
  });
@@ -3914,7 +3931,7 @@
3914
3931
  }
3915
3932
 
3916
3933
  async function loadPoissonDiscPlugin(engine) {
3917
- engine.checkVersion("4.0.5");
3934
+ engine.checkVersion("4.1.1");
3918
3935
  await engine.pluginManager.register(e => {
3919
3936
  e.pluginManager.addPlugin(new PoissonDiscPlugin());
3920
3937
  });
@@ -3922,18 +3939,18 @@
3922
3939
 
3923
3940
  const defaultShadowBlur = 0, defaultShadowOffsetValue = 0;
3924
3941
  class ShadowDrawer {
3925
- _container;
3926
- _pluginManager;
3942
+ #container;
3943
+ #pluginManager;
3927
3944
  constructor(pluginManager, container) {
3928
- this._pluginManager = pluginManager;
3929
- this._container = container;
3945
+ this.#pluginManager = pluginManager;
3946
+ this.#container = container;
3930
3947
  }
3931
3948
  drawAfter(data) {
3932
3949
  const { context } = data;
3933
3950
  context.restore();
3934
3951
  }
3935
3952
  drawBefore(data) {
3936
- const { particle, context } = data, { _container: container } = this, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;
3953
+ const { particle, context } = data, container = this.#container, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;
3937
3954
  if (!shadowColor) {
3938
3955
  return;
3939
3956
  }
@@ -3945,14 +3962,14 @@
3945
3962
  }
3946
3963
  particleInit(_container, particle) {
3947
3964
  const effectData = particle.effectData, shadowColor = OptionsColor.create(new OptionsColor(), effectData?.color);
3948
- particle.shadowColor = rangeColorToRgb(this._pluginManager, shadowColor);
3965
+ particle.shadowColor = rangeColorToRgb(this.#pluginManager, shadowColor);
3949
3966
  particle.shadowBlur = effectData?.blur ?? defaultShadowBlur;
3950
3967
  particle.shadowOffset = effectData?.offset ?? originPoint;
3951
3968
  }
3952
3969
  }
3953
3970
 
3954
3971
  async function loadShadowEffect(engine) {
3955
- engine.checkVersion("4.0.5");
3972
+ engine.checkVersion("4.1.1");
3956
3973
  await engine.pluginManager.register(e => {
3957
3974
  e.pluginManager.addEffect("shadow", container => {
3958
3975
  return Promise.resolve(new ShadowDrawer(e.pluginManager, container));
@@ -4003,13 +4020,13 @@
4003
4020
 
4004
4021
  class TrailPlugin {
4005
4022
  id = "trail";
4006
- _pluginManager;
4023
+ #pluginManager;
4007
4024
  constructor(pluginManager) {
4008
- this._pluginManager = pluginManager;
4025
+ this.#pluginManager = pluginManager;
4009
4026
  }
4010
4027
  async getPlugin(container) {
4011
4028
  const { TrailPluginInstance } = await Promise.resolve().then(function () { return TrailPluginInstance$1; });
4012
- return new TrailPluginInstance(this._pluginManager, container);
4029
+ return new TrailPluginInstance(this.#pluginManager, container);
4013
4030
  }
4014
4031
  loadOptions(_container, options, source) {
4015
4032
  if (!this.needsPlugin()) {
@@ -4027,7 +4044,7 @@
4027
4044
  }
4028
4045
 
4029
4046
  async function loadTrailPlugin(engine) {
4030
- engine.checkVersion("4.0.5");
4047
+ engine.checkVersion("4.1.1");
4031
4048
  await engine.pluginManager.register(e => {
4032
4049
  e.pluginManager.addPlugin(new TrailPlugin(e.pluginManager));
4033
4050
  });
@@ -4137,58 +4154,58 @@
4137
4154
  }
4138
4155
  }
4139
4156
  class RenderManager {
4140
- _canvasClearPlugins;
4141
- _canvasManager;
4142
- _canvasPaintPlugins;
4143
- _clearDrawPlugins;
4144
- _colorPlugins;
4145
- _container;
4146
- _context;
4147
- _contextSettings;
4148
- _drawParticlePlugins;
4149
- _drawParticlesCleanupPlugins;
4150
- _drawParticlesSetupPlugins;
4151
- _drawPlugins;
4152
- _drawSettingsCleanupPlugins;
4153
- _drawSettingsSetupPlugins;
4154
- _pluginManager;
4155
- _postDrawUpdaters;
4156
- _preDrawUpdaters;
4157
- _reusableColorStyles = {};
4158
- _reusablePluginColors = [undefined, undefined];
4159
- _reusableTransform = {};
4157
+ #canvasClearPlugins;
4158
+ #canvasManager;
4159
+ #canvasPaintPlugins;
4160
+ #clearDrawPlugins;
4161
+ #colorPlugins;
4162
+ #container;
4163
+ #context;
4164
+ #contextSettings;
4165
+ #drawParticlePlugins;
4166
+ #drawParticlesCleanupPlugins;
4167
+ #drawParticlesSetupPlugins;
4168
+ #drawPlugins;
4169
+ #drawSettingsCleanupPlugins;
4170
+ #drawSettingsSetupPlugins;
4171
+ #pluginManager;
4172
+ #postDrawUpdaters;
4173
+ #preDrawUpdaters;
4174
+ #reusableColorStyles = {};
4175
+ #reusablePluginColors = [undefined, undefined];
4176
+ #reusableTransform = {};
4160
4177
  constructor(pluginManager, container, canvasManager) {
4161
- this._pluginManager = pluginManager;
4162
- this._container = container;
4163
- this._canvasManager = canvasManager;
4164
- this._context = null;
4165
- this._preDrawUpdaters = [];
4166
- this._postDrawUpdaters = [];
4167
- this._colorPlugins = [];
4168
- this._canvasClearPlugins = [];
4169
- this._canvasPaintPlugins = [];
4170
- this._clearDrawPlugins = [];
4171
- this._drawParticlePlugins = [];
4172
- this._drawParticlesCleanupPlugins = [];
4173
- this._drawParticlesSetupPlugins = [];
4174
- this._drawPlugins = [];
4175
- this._drawSettingsSetupPlugins = [];
4176
- this._drawSettingsCleanupPlugins = [];
4178
+ this.#pluginManager = pluginManager;
4179
+ this.#container = container;
4180
+ this.#canvasManager = canvasManager;
4181
+ this.#context = null;
4182
+ this.#preDrawUpdaters = [];
4183
+ this.#postDrawUpdaters = [];
4184
+ this.#colorPlugins = [];
4185
+ this.#canvasClearPlugins = [];
4186
+ this.#canvasPaintPlugins = [];
4187
+ this.#clearDrawPlugins = [];
4188
+ this.#drawParticlePlugins = [];
4189
+ this.#drawParticlesCleanupPlugins = [];
4190
+ this.#drawParticlesSetupPlugins = [];
4191
+ this.#drawPlugins = [];
4192
+ this.#drawSettingsSetupPlugins = [];
4193
+ this.#drawSettingsCleanupPlugins = [];
4177
4194
  }
4178
4195
  get settings() {
4179
- return this._contextSettings;
4196
+ return this.#contextSettings;
4180
4197
  }
4181
4198
  canvasClear() {
4182
- if (!this._container.actualOptions.clear) {
4199
+ if (!this.#container.actualOptions.clear) {
4183
4200
  return;
4184
4201
  }
4185
4202
  this.draw(ctx => {
4186
- clear(ctx, this._canvasManager.size);
4203
+ clear(ctx, this.#canvasManager.size);
4187
4204
  });
4188
4205
  }
4189
4206
  clear() {
4190
4207
  let pluginHandled = false;
4191
- for (const plugin of this._canvasClearPlugins) {
4208
+ for (const plugin of this.#canvasClearPlugins) {
4192
4209
  pluginHandled = plugin.canvasClear?.() ?? false;
4193
4210
  if (pluginHandled) {
4194
4211
  break;
@@ -4201,21 +4218,21 @@
4201
4218
  }
4202
4219
  destroy() {
4203
4220
  this.stop();
4204
- this._preDrawUpdaters = [];
4205
- this._postDrawUpdaters = [];
4206
- this._colorPlugins = [];
4207
- this._canvasClearPlugins = [];
4208
- this._canvasPaintPlugins = [];
4209
- this._clearDrawPlugins = [];
4210
- this._drawParticlePlugins = [];
4211
- this._drawParticlesCleanupPlugins = [];
4212
- this._drawParticlesSetupPlugins = [];
4213
- this._drawPlugins = [];
4214
- this._drawSettingsSetupPlugins = [];
4215
- this._drawSettingsCleanupPlugins = [];
4221
+ this.#preDrawUpdaters = [];
4222
+ this.#postDrawUpdaters = [];
4223
+ this.#colorPlugins = [];
4224
+ this.#canvasClearPlugins = [];
4225
+ this.#canvasPaintPlugins = [];
4226
+ this.#clearDrawPlugins = [];
4227
+ this.#drawParticlePlugins = [];
4228
+ this.#drawParticlesCleanupPlugins = [];
4229
+ this.#drawParticlesSetupPlugins = [];
4230
+ this.#drawPlugins = [];
4231
+ this.#drawSettingsSetupPlugins = [];
4232
+ this.#drawSettingsCleanupPlugins = [];
4216
4233
  }
4217
4234
  draw(cb) {
4218
- const ctx = this._context;
4235
+ const ctx = this.#context;
4219
4236
  if (!ctx) {
4220
4237
  return;
4221
4238
  }
@@ -4230,21 +4247,21 @@
4230
4247
  return;
4231
4248
  }
4232
4249
  const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
4233
- let [fColor, sColor] = this._getPluginParticleColors(particle);
4250
+ let [fColor, sColor] = this.#getPluginParticleColors(particle);
4234
4251
  fColor ??= pfColor;
4235
4252
  sColor ??= psColor;
4236
4253
  if (!fColor && !sColor) {
4237
4254
  return;
4238
4255
  }
4239
- 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;
4256
+ 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;
4240
4257
  transform.a = transform.b = transform.c = transform.d = undefined;
4241
4258
  colorStyles.fill = fill;
4242
4259
  colorStyles.stroke = stroke;
4243
4260
  this.draw((context) => {
4244
- for (const plugin of this._drawParticlesSetupPlugins) {
4261
+ for (const plugin of this.#drawParticlesSetupPlugins) {
4245
4262
  plugin.drawParticleSetup?.(context, particle, delta);
4246
4263
  }
4247
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4264
+ this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4248
4265
  drawParticle({
4249
4266
  container,
4250
4267
  context,
@@ -4255,35 +4272,35 @@
4255
4272
  opacity: opacity,
4256
4273
  transform,
4257
4274
  });
4258
- this._applyPostDrawUpdaters(particle);
4259
- for (const plugin of this._drawParticlesCleanupPlugins) {
4275
+ this.#applyPostDrawUpdaters(particle);
4276
+ for (const plugin of this.#drawParticlesCleanupPlugins) {
4260
4277
  plugin.drawParticleCleanup?.(context, particle, delta);
4261
4278
  }
4262
4279
  });
4263
4280
  }
4264
4281
  drawParticlePlugins(particle, delta) {
4265
4282
  this.draw(ctx => {
4266
- for (const plugin of this._drawParticlePlugins) {
4283
+ for (const plugin of this.#drawParticlePlugins) {
4267
4284
  drawParticlePlugin(ctx, plugin, particle, delta);
4268
4285
  }
4269
4286
  });
4270
4287
  }
4271
4288
  drawParticles(delta) {
4272
- const { particles } = this._container;
4289
+ const { particles } = this.#container;
4273
4290
  this.clear();
4274
4291
  particles.update(delta);
4275
4292
  this.draw(ctx => {
4276
- for (const plugin of this._drawSettingsSetupPlugins) {
4293
+ for (const plugin of this.#drawSettingsSetupPlugins) {
4277
4294
  plugin.drawSettingsSetup?.(ctx, delta);
4278
4295
  }
4279
- for (const plugin of this._drawPlugins) {
4296
+ for (const plugin of this.#drawPlugins) {
4280
4297
  plugin.draw?.(ctx, delta);
4281
4298
  }
4282
4299
  particles.drawParticles(delta);
4283
- for (const plugin of this._clearDrawPlugins) {
4300
+ for (const plugin of this.#clearDrawPlugins) {
4284
4301
  plugin.clearDraw?.(ctx, delta);
4285
4302
  }
4286
- for (const plugin of this._drawSettingsCleanupPlugins) {
4303
+ for (const plugin of this.#drawSettingsCleanupPlugins) {
4287
4304
  plugin.drawSettingsCleanup?.(ctx, delta);
4288
4305
  }
4289
4306
  });
@@ -4294,64 +4311,64 @@
4294
4311
  this.paint();
4295
4312
  }
4296
4313
  initPlugins() {
4297
- this._colorPlugins = [];
4298
- this._canvasClearPlugins = [];
4299
- this._canvasPaintPlugins = [];
4300
- this._clearDrawPlugins = [];
4301
- this._drawParticlePlugins = [];
4302
- this._drawParticlesSetupPlugins = [];
4303
- this._drawParticlesCleanupPlugins = [];
4304
- this._drawPlugins = [];
4305
- this._drawSettingsSetupPlugins = [];
4306
- this._drawSettingsCleanupPlugins = [];
4307
- for (const plugin of this._container.plugins) {
4314
+ this.#colorPlugins = [];
4315
+ this.#canvasClearPlugins = [];
4316
+ this.#canvasPaintPlugins = [];
4317
+ this.#clearDrawPlugins = [];
4318
+ this.#drawParticlePlugins = [];
4319
+ this.#drawParticlesSetupPlugins = [];
4320
+ this.#drawParticlesCleanupPlugins = [];
4321
+ this.#drawPlugins = [];
4322
+ this.#drawSettingsSetupPlugins = [];
4323
+ this.#drawSettingsCleanupPlugins = [];
4324
+ for (const plugin of this.#container.plugins) {
4308
4325
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
4309
- this._colorPlugins.push(plugin);
4326
+ this.#colorPlugins.push(plugin);
4310
4327
  }
4311
4328
  if (plugin.canvasClear) {
4312
- this._canvasClearPlugins.push(plugin);
4329
+ this.#canvasClearPlugins.push(plugin);
4313
4330
  }
4314
4331
  if (plugin.canvasPaint) {
4315
- this._canvasPaintPlugins.push(plugin);
4332
+ this.#canvasPaintPlugins.push(plugin);
4316
4333
  }
4317
4334
  if (plugin.drawParticle) {
4318
- this._drawParticlePlugins.push(plugin);
4335
+ this.#drawParticlePlugins.push(plugin);
4319
4336
  }
4320
4337
  if (plugin.drawParticleSetup) {
4321
- this._drawParticlesSetupPlugins.push(plugin);
4338
+ this.#drawParticlesSetupPlugins.push(plugin);
4322
4339
  }
4323
4340
  if (plugin.drawParticleCleanup) {
4324
- this._drawParticlesCleanupPlugins.push(plugin);
4341
+ this.#drawParticlesCleanupPlugins.push(plugin);
4325
4342
  }
4326
4343
  if (plugin.draw) {
4327
- this._drawPlugins.push(plugin);
4344
+ this.#drawPlugins.push(plugin);
4328
4345
  }
4329
4346
  if (plugin.drawSettingsSetup) {
4330
- this._drawSettingsSetupPlugins.push(plugin);
4347
+ this.#drawSettingsSetupPlugins.push(plugin);
4331
4348
  }
4332
4349
  if (plugin.drawSettingsCleanup) {
4333
- this._drawSettingsCleanupPlugins.push(plugin);
4350
+ this.#drawSettingsCleanupPlugins.push(plugin);
4334
4351
  }
4335
4352
  if (plugin.clearDraw) {
4336
- this._clearDrawPlugins.push(plugin);
4353
+ this.#clearDrawPlugins.push(plugin);
4337
4354
  }
4338
4355
  }
4339
4356
  }
4340
4357
  initUpdaters() {
4341
- this._preDrawUpdaters = [];
4342
- this._postDrawUpdaters = [];
4343
- for (const updater of this._container.particleUpdaters) {
4358
+ this.#preDrawUpdaters = [];
4359
+ this.#postDrawUpdaters = [];
4360
+ for (const updater of this.#container.particleUpdaters) {
4344
4361
  if (updater.afterDraw) {
4345
- this._postDrawUpdaters.push(updater);
4362
+ this.#postDrawUpdaters.push(updater);
4346
4363
  }
4347
4364
  if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
4348
- this._preDrawUpdaters.push(updater);
4365
+ this.#preDrawUpdaters.push(updater);
4349
4366
  }
4350
4367
  }
4351
4368
  }
4352
4369
  paint() {
4353
4370
  let handled = false;
4354
- for (const plugin of this._canvasPaintPlugins) {
4371
+ for (const plugin of this.#canvasPaintPlugins) {
4355
4372
  handled = plugin.canvasPaint?.() ?? false;
4356
4373
  if (handled) {
4357
4374
  break;
@@ -4364,35 +4381,35 @@
4364
4381
  }
4365
4382
  paintBase(baseColor) {
4366
4383
  this.draw(ctx => {
4367
- paintBase(ctx, this._canvasManager.size, baseColor);
4384
+ paintBase(ctx, this.#canvasManager.size, baseColor);
4368
4385
  });
4369
4386
  }
4370
4387
  paintImage(image, opacity) {
4371
4388
  this.draw(ctx => {
4372
- paintImage(ctx, this._canvasManager.size, image, opacity);
4389
+ paintImage(ctx, this.#canvasManager.size, image, opacity);
4373
4390
  });
4374
4391
  }
4375
4392
  setContext(context) {
4376
- this._context = context;
4377
- if (this._context) {
4378
- this._context.globalCompositeOperation = defaultCompositeValue;
4393
+ this.#context = context;
4394
+ if (this.#context) {
4395
+ this.#context.globalCompositeOperation = defaultCompositeValue;
4379
4396
  }
4380
4397
  }
4381
4398
  setContextSettings(settings) {
4382
- this._contextSettings = settings;
4399
+ this.#contextSettings = settings;
4383
4400
  }
4384
4401
  stop() {
4385
4402
  this.draw(ctx => {
4386
- clear(ctx, this._canvasManager.size);
4403
+ clear(ctx, this.#canvasManager.size);
4387
4404
  });
4388
4405
  }
4389
- _applyPostDrawUpdaters = particle => {
4390
- for (const updater of this._postDrawUpdaters) {
4406
+ #applyPostDrawUpdaters = particle => {
4407
+ for (const updater of this.#postDrawUpdaters) {
4391
4408
  updater.afterDraw?.(particle);
4392
4409
  }
4393
4410
  };
4394
- _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4395
- for (const updater of this._preDrawUpdaters) {
4411
+ #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4412
+ for (const updater of this.#preDrawUpdaters) {
4396
4413
  if (updater.getColorStyles) {
4397
4414
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
4398
4415
  if (fill) {
@@ -4411,22 +4428,22 @@
4411
4428
  updater.beforeDraw?.(particle);
4412
4429
  }
4413
4430
  };
4414
- _getPluginParticleColors = particle => {
4431
+ #getPluginParticleColors = particle => {
4415
4432
  let fColor, sColor;
4416
- for (const plugin of this._colorPlugins) {
4433
+ for (const plugin of this.#colorPlugins) {
4417
4434
  if (!fColor && plugin.particleFillColor) {
4418
- fColor = rangeColorToHsl(this._pluginManager, plugin.particleFillColor(particle));
4435
+ fColor = rangeColorToHsl(this.#pluginManager, plugin.particleFillColor(particle));
4419
4436
  }
4420
4437
  if (!sColor && plugin.particleStrokeColor) {
4421
- sColor = rangeColorToHsl(this._pluginManager, plugin.particleStrokeColor(particle));
4438
+ sColor = rangeColorToHsl(this.#pluginManager, plugin.particleStrokeColor(particle));
4422
4439
  }
4423
4440
  if (fColor && sColor) {
4424
4441
  break;
4425
4442
  }
4426
4443
  }
4427
- this._reusablePluginColors[fColorIndex] = fColor;
4428
- this._reusablePluginColors[sColorIndex] = sColor;
4429
- return this._reusablePluginColors;
4444
+ this.#reusablePluginColors[fColorIndex] = fColor;
4445
+ this.#reusablePluginColors[sColorIndex] = sColor;
4446
+ return this.#reusablePluginColors;
4430
4447
  };
4431
4448
  }
4432
4449
 
@@ -4484,53 +4501,53 @@
4484
4501
  renderCanvas;
4485
4502
  size;
4486
4503
  zoom = defaultZoom;
4487
- _container;
4488
- _generated;
4489
- _mutationObserver;
4490
- _originalStyle;
4491
- _pluginManager;
4492
- _pointerEvents;
4493
- _resizePlugins;
4494
- _standardSize;
4495
- _zoomCenter;
4504
+ #container;
4505
+ #generated;
4506
+ #mutationObserver;
4507
+ #originalStyle;
4508
+ #pluginManager;
4509
+ #pointerEvents;
4510
+ #resizePlugins;
4511
+ #standardSize;
4512
+ #zoomCenter;
4496
4513
  constructor(pluginManager, container) {
4497
- this._pluginManager = pluginManager;
4498
- this._container = container;
4514
+ this.#pluginManager = pluginManager;
4515
+ this.#container = container;
4499
4516
  this.render = new RenderManager(pluginManager, container, this);
4500
- this._standardSize = {
4517
+ this.#standardSize = {
4501
4518
  height: 0,
4502
4519
  width: 0,
4503
4520
  };
4504
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
4521
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
4505
4522
  this.size = {
4506
4523
  height: stdSize.height * pxRatio,
4507
4524
  width: stdSize.width * pxRatio,
4508
4525
  };
4509
- this._generated = false;
4510
- this._resizePlugins = [];
4511
- this._pointerEvents = "none";
4526
+ this.#generated = false;
4527
+ this.#resizePlugins = [];
4528
+ this.#pointerEvents = "none";
4512
4529
  }
4513
- get _fullScreen() {
4514
- return this._container.actualOptions.fullScreen.enable;
4530
+ get #fullScreen() {
4531
+ return this.#container.actualOptions.fullScreen.enable;
4515
4532
  }
4516
4533
  destroy() {
4517
4534
  this.stop();
4518
- if (this._generated) {
4535
+ if (this.#generated) {
4519
4536
  const element = this.domElement;
4520
4537
  element?.remove();
4521
4538
  this.domElement = undefined;
4522
4539
  this.renderCanvas = undefined;
4523
4540
  }
4524
4541
  else {
4525
- this._resetOriginalStyle();
4542
+ this.#resetOriginalStyle();
4526
4543
  }
4527
4544
  this.render.destroy();
4528
- this._resizePlugins = [];
4545
+ this.#resizePlugins = [];
4529
4546
  }
4530
4547
  getZoomCenter() {
4531
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
4532
- if (this._zoomCenter) {
4533
- return this._zoomCenter;
4548
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
4549
+ if (this.#zoomCenter) {
4550
+ return this.#zoomCenter;
4534
4551
  }
4535
4552
  return {
4536
4553
  x: (width * half) / pxRatio,
@@ -4538,20 +4555,20 @@
4538
4555
  };
4539
4556
  }
4540
4557
  init() {
4541
- this._safeMutationObserver(obs => {
4558
+ this.#safeMutationObserver(obs => {
4542
4559
  obs.disconnect();
4543
4560
  });
4544
- this._mutationObserver = safeMutationObserver(records => {
4561
+ this.#mutationObserver = safeMutationObserver(records => {
4545
4562
  for (const record of records) {
4546
4563
  if (record.type === "attributes" && record.attributeName === "style") {
4547
- this._repairStyle();
4564
+ this.#repairStyle();
4548
4565
  }
4549
4566
  }
4550
4567
  });
4551
4568
  this.resize();
4552
- this._initStyle();
4569
+ this.#initStyle();
4553
4570
  this.initBackground();
4554
- this._safeMutationObserver(obs => {
4571
+ this.#safeMutationObserver(obs => {
4555
4572
  const element = this.domElement;
4556
4573
  if (!element || !(element instanceof Node)) {
4557
4574
  return;
@@ -4562,13 +4579,13 @@
4562
4579
  this.render.init();
4563
4580
  }
4564
4581
  initBackground() {
4565
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
4582
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
4566
4583
  if (!element) {
4567
4584
  return;
4568
4585
  }
4569
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
4586
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
4570
4587
  if (color) {
4571
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
4588
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
4572
4589
  }
4573
4590
  else {
4574
4591
  elementStyle.backgroundColor = "";
@@ -4579,27 +4596,27 @@
4579
4596
  elementStyle.backgroundSize = background.size || "";
4580
4597
  }
4581
4598
  initPlugins() {
4582
- this._resizePlugins = [];
4583
- for (const plugin of this._container.plugins) {
4599
+ this.#resizePlugins = [];
4600
+ for (const plugin of this.#container.plugins) {
4584
4601
  if (plugin.resize) {
4585
- this._resizePlugins.push(plugin);
4602
+ this.#resizePlugins.push(plugin);
4586
4603
  }
4587
4604
  }
4588
4605
  }
4589
4606
  loadCanvas(canvas) {
4590
- if (this._generated && this.domElement) {
4607
+ if (this.#generated && this.domElement) {
4591
4608
  this.domElement.remove();
4592
4609
  }
4593
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4610
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4594
4611
  this.domElement = domCanvas;
4595
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4612
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4596
4613
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
4597
4614
  const domElement = this.domElement;
4598
4615
  if (domElement) {
4599
4616
  domElement.ariaHidden = "true";
4600
- this._originalStyle = cloneStyle(domElement.style);
4617
+ this.#originalStyle = cloneStyle(domElement.style);
4601
4618
  }
4602
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
4619
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
4603
4620
  if (domElement) {
4604
4621
  standardSize.height = domElement.offsetHeight;
4605
4622
  standardSize.width = domElement.offsetWidth;
@@ -4608,7 +4625,7 @@
4608
4625
  standardSize.height = renderCanvas.height;
4609
4626
  standardSize.width = renderCanvas.width;
4610
4627
  }
4611
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
4628
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
4612
4629
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
4613
4630
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
4614
4631
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -4619,12 +4636,12 @@
4619
4636
  willReadFrequently: false,
4620
4637
  });
4621
4638
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
4622
- this._safeMutationObserver(obs => {
4639
+ this.#safeMutationObserver(obs => {
4623
4640
  obs.disconnect();
4624
4641
  });
4625
4642
  container.retina.init();
4626
4643
  this.initBackground();
4627
- this._safeMutationObserver(obs => {
4644
+ this.#safeMutationObserver(obs => {
4628
4645
  const element = this.domElement;
4629
4646
  if (!element || !(element instanceof Node)) {
4630
4647
  return;
@@ -4637,11 +4654,11 @@
4637
4654
  if (!element) {
4638
4655
  return false;
4639
4656
  }
4640
- const container = this._container, renderCanvas = this.renderCanvas;
4657
+ const container = this.#container, renderCanvas = this.renderCanvas;
4641
4658
  if (renderCanvas === undefined) {
4642
4659
  return false;
4643
4660
  }
4644
- const currentSize = container.canvas._standardSize, newSize = {
4661
+ const currentSize = container.canvas.#standardSize, newSize = {
4645
4662
  width: element.offsetWidth,
4646
4663
  height: element.offsetHeight,
4647
4664
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -4660,7 +4677,7 @@
4660
4677
  const canvasSize = this.size;
4661
4678
  renderCanvas.width = canvasSize.width = retinaSize.width;
4662
4679
  renderCanvas.height = canvasSize.height = retinaSize.height;
4663
- if (this._container.started) {
4680
+ if (this.#container.started) {
4664
4681
  container.particles.setResizeFactor({
4665
4682
  width: currentSize.width / oldSize.width,
4666
4683
  height: currentSize.height / oldSize.height,
@@ -4673,46 +4690,46 @@
4673
4690
  if (!element) {
4674
4691
  return;
4675
4692
  }
4676
- this._pointerEvents = type;
4677
- this._repairStyle();
4693
+ this.#pointerEvents = type;
4694
+ this.#repairStyle();
4678
4695
  }
4679
4696
  setZoom(zoomLevel, center) {
4680
4697
  this.zoom = zoomLevel;
4681
- this._zoomCenter = center;
4698
+ this.#zoomCenter = center;
4682
4699
  }
4683
4700
  stop() {
4684
- this._safeMutationObserver(obs => {
4701
+ this.#safeMutationObserver(obs => {
4685
4702
  obs.disconnect();
4686
4703
  });
4687
- this._mutationObserver = undefined;
4704
+ this.#mutationObserver = undefined;
4688
4705
  this.render.stop();
4689
4706
  }
4690
4707
  async windowResize() {
4691
4708
  if (!this.domElement || !this.resize()) {
4692
4709
  return;
4693
4710
  }
4694
- const container = this._container, needsRefresh = container.updateActualOptions();
4711
+ const container = this.#container, needsRefresh = container.updateActualOptions();
4695
4712
  container.particles.setDensity();
4696
- this._applyResizePlugins();
4713
+ this.#applyResizePlugins();
4697
4714
  if (needsRefresh) {
4698
4715
  await container.refresh();
4699
4716
  }
4700
4717
  }
4701
- _applyResizePlugins = () => {
4702
- for (const plugin of this._resizePlugins) {
4718
+ #applyResizePlugins = () => {
4719
+ for (const plugin of this.#resizePlugins) {
4703
4720
  plugin.resize?.();
4704
4721
  }
4705
4722
  };
4706
- _initStyle = () => {
4707
- const element = this.domElement, options = this._container.actualOptions;
4723
+ #initStyle = () => {
4724
+ const element = this.domElement, options = this.#container.actualOptions;
4708
4725
  if (!element) {
4709
4726
  return;
4710
4727
  }
4711
- if (this._fullScreen) {
4712
- this._setFullScreenStyle();
4728
+ if (this.#fullScreen) {
4729
+ this.#setFullScreenStyle();
4713
4730
  }
4714
4731
  else {
4715
- this._resetOriginalStyle();
4732
+ this.#resetOriginalStyle();
4716
4733
  }
4717
4734
  for (const key in options.style) {
4718
4735
  if (!key || !(key in options.style)) {
@@ -4725,72 +4742,72 @@
4725
4742
  element.style.setProperty(key, value, "important");
4726
4743
  }
4727
4744
  };
4728
- _repairStyle = () => {
4745
+ #repairStyle = () => {
4729
4746
  const element = this.domElement;
4730
4747
  if (!element) {
4731
4748
  return;
4732
4749
  }
4733
- this._safeMutationObserver(observer => {
4750
+ this.#safeMutationObserver(observer => {
4734
4751
  observer.disconnect();
4735
4752
  });
4736
- this._initStyle();
4753
+ this.#initStyle();
4737
4754
  this.initBackground();
4738
- const pointerEvents = this._pointerEvents;
4755
+ const pointerEvents = this.#pointerEvents;
4739
4756
  element.style.pointerEvents = pointerEvents;
4740
4757
  element.style.setProperty("pointer-events", pointerEvents);
4741
- this._safeMutationObserver(observer => {
4758
+ this.#safeMutationObserver(observer => {
4742
4759
  if (!(element instanceof Node)) {
4743
4760
  return;
4744
4761
  }
4745
4762
  observer.observe(element, { attributes: true });
4746
4763
  });
4747
4764
  };
4748
- _resetOriginalStyle = () => {
4749
- const element = this.domElement, originalStyle = this._originalStyle;
4765
+ #resetOriginalStyle = () => {
4766
+ const element = this.domElement, originalStyle = this.#originalStyle;
4750
4767
  if (!element || !originalStyle) {
4751
4768
  return;
4752
4769
  }
4753
4770
  setStyle(element, originalStyle, true);
4754
4771
  };
4755
- _safeMutationObserver = callback => {
4756
- if (!this._mutationObserver) {
4772
+ #safeMutationObserver = callback => {
4773
+ if (!this.#mutationObserver) {
4757
4774
  return;
4758
4775
  }
4759
- callback(this._mutationObserver);
4776
+ callback(this.#mutationObserver);
4760
4777
  };
4761
- _setFullScreenStyle = () => {
4778
+ #setFullScreenStyle = () => {
4762
4779
  const element = this.domElement;
4763
4780
  if (!element) {
4764
4781
  return;
4765
4782
  }
4766
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
4783
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
4767
4784
  };
4768
4785
  }
4769
4786
 
4770
4787
  class EventListeners {
4771
- container;
4772
- _handlers;
4773
- _resizeObserver;
4774
- _resizeTimeout;
4788
+ #container;
4789
+ #handlers;
4790
+ #resizeObserver;
4791
+ #resizeTimeout;
4775
4792
  constructor(container) {
4776
- this.container = container;
4777
- this._handlers = {
4793
+ this.#container = container;
4794
+ this.#handlers = {
4778
4795
  visibilityChange: () => {
4779
- this._handleVisibilityChange();
4796
+ this.#handleVisibilityChange();
4780
4797
  },
4781
4798
  resize: () => {
4782
- this._handleWindowResize();
4799
+ this.#handleWindowResize();
4783
4800
  },
4784
4801
  };
4785
4802
  }
4786
4803
  addListeners() {
4787
- this._manageListeners(true);
4804
+ this.#manageListeners(true);
4788
4805
  }
4789
4806
  removeListeners() {
4790
- this._manageListeners(false);
4807
+ this.#manageListeners(false);
4791
4808
  }
4792
- _handleVisibilityChange = () => {
4793
- const container = this.container, options = container.actualOptions;
4809
+ #handleVisibilityChange = () => {
4810
+ const container = this.#container, options = container.actualOptions;
4794
4811
  if (!options.pauseOnBlur) {
4795
4812
  return;
4796
4813
  }
@@ -4808,24 +4825,24 @@
4808
4825
  }
4809
4826
  }
4810
4827
  };
4811
- _handleWindowResize = () => {
4812
- if (this._resizeTimeout) {
4813
- clearTimeout(this._resizeTimeout);
4814
- delete this._resizeTimeout;
4828
+ #handleWindowResize = () => {
4829
+ if (this.#resizeTimeout) {
4830
+ clearTimeout(this.#resizeTimeout);
4831
+ this.#resizeTimeout = undefined;
4815
4832
  }
4816
4833
  const handleResize = async () => {
4817
- const canvas = this.container.canvas;
4834
+ const canvas = this.#container.canvas;
4818
4835
  await canvas.windowResize();
4819
4836
  };
4820
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
4837
+ this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
4821
4838
  };
4822
- _manageListeners = add => {
4823
- const handlers = this._handlers;
4824
- this._manageResize(add);
4839
+ #manageListeners = add => {
4840
+ const handlers = this.#handlers;
4841
+ this.#manageResize(add);
4825
4842
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
4826
4843
  };
4827
- _manageResize = add => {
4828
- const handlers = this._handlers, container = this.container, options = container.actualOptions;
4844
+ #manageResize = add => {
4845
+ const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
4829
4846
  if (!options.resize.enable) {
4830
4847
  return;
4831
4848
  }
@@ -4834,22 +4851,22 @@
4834
4851
  return;
4835
4852
  }
4836
4853
  const canvasEl = container.canvas.domElement;
4837
- if (this._resizeObserver && !add) {
4854
+ if (this.#resizeObserver && !add) {
4838
4855
  if (canvasEl) {
4839
- this._resizeObserver.unobserve(canvasEl);
4856
+ this.#resizeObserver.unobserve(canvasEl);
4840
4857
  }
4841
- this._resizeObserver.disconnect();
4842
- delete this._resizeObserver;
4858
+ this.#resizeObserver.disconnect();
4859
+ this.#resizeObserver = undefined;
4843
4860
  }
4844
- else if (!this._resizeObserver && add && canvasEl) {
4845
- this._resizeObserver = new ResizeObserver((entries) => {
4861
+ else if (!this.#resizeObserver && add && canvasEl) {
4862
+ this.#resizeObserver = new ResizeObserver((entries) => {
4846
4863
  const entry = entries.find(e => e.target === canvasEl);
4847
4864
  if (!entry) {
4848
4865
  return;
4849
4866
  }
4850
- this._handleWindowResize();
4867
+ this.#handleWindowResize();
4851
4868
  });
4852
- this._resizeObserver.observe(canvasEl);
4869
+ this.#resizeObserver.observe(canvasEl);
4853
4870
  }
4854
4871
  };
4855
4872
  }
@@ -4922,24 +4939,24 @@
4922
4939
  unbreakable;
4923
4940
  velocity;
4924
4941
  zIndexFactor;
4925
- _cachedOpacityData = {
4942
+ #cachedOpacityData = {
4926
4943
  fillOpacity: defaultOpacity$1,
4927
4944
  opacity: defaultOpacity$1,
4928
4945
  strokeOpacity: defaultOpacity$1,
4929
4946
  };
4930
- _cachedPosition = Vector3d.origin;
4931
- _cachedRotateData = { sin: 0, cos: 0 };
4932
- _cachedTransform = {
4947
+ #cachedPosition = Vector3d.origin;
4948
+ #cachedRotateData = { sin: 0, cos: 0 };
4949
+ #cachedTransform = {
4933
4950
  a: 1,
4934
4951
  b: 0,
4935
4952
  c: 0,
4936
4953
  d: 1,
4937
4954
  };
4938
- _container;
4939
- _pluginManager;
4955
+ #container;
4956
+ #pluginManager;
4940
4957
  constructor(pluginManager, container) {
4941
- this._pluginManager = pluginManager;
4942
- this._container = container;
4958
+ this.#pluginManager = pluginManager;
4959
+ this.#container = container;
4943
4960
  }
4944
4961
  destroy(override) {
4945
4962
  if (this.unbreakable || this.destroyed) {
@@ -4948,7 +4965,7 @@
4948
4965
  this.destroyed = true;
4949
4966
  this.bubble.inRange = false;
4950
4967
  this.slow.inRange = false;
4951
- const container = this._container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4968
+ const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4952
4969
  shapeDrawer?.particleDestroy?.(this);
4953
4970
  for (const plugin of container.particleDestroyedPlugins) {
4954
4971
  plugin.particleDestroyed?.(this, override);
@@ -4956,12 +4973,12 @@
4956
4973
  for (const updater of container.particleUpdaters) {
4957
4974
  updater.particleDestroyed?.(this, override);
4958
4975
  }
4959
- this._container.dispatchEvent(EventType.particleDestroyed, {
4976
+ this.#container.dispatchEvent(EventType.particleDestroyed, {
4960
4977
  particle: this,
4961
4978
  });
4962
4979
  }
4963
4980
  draw(delta) {
4964
- const container = this._container, render = container.canvas.render;
4981
+ const container = this.#container, render = container.canvas.render;
4965
4982
  render.drawParticlePlugins(this, delta);
4966
4983
  render.drawParticle(this, delta);
4967
4984
  }
@@ -4969,50 +4986,50 @@
4969
4986
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
4970
4987
  }
4971
4988
  getFillColor() {
4972
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4989
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4973
4990
  }
4974
4991
  getMass() {
4975
4992
  return this.getRadius() ** squareExp * Math.PI * half;
4976
4993
  }
4977
4994
  getOpacity() {
4978
4995
  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;
4979
- this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4980
- this._cachedOpacityData.opacity = opacity * zOpacityFactor;
4981
- this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4982
- return this._cachedOpacityData;
4996
+ this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4997
+ this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
4998
+ this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4999
+ return this.#cachedOpacityData;
4983
5000
  }
4984
5001
  getPosition() {
4985
- this._cachedPosition.x = this.position.x + this.offset.x;
4986
- this._cachedPosition.y = this.position.y + this.offset.y;
4987
- this._cachedPosition.z = this.position.z;
4988
- return this._cachedPosition;
5002
+ this.#cachedPosition.x = this.position.x + this.offset.x;
5003
+ this.#cachedPosition.y = this.position.y + this.offset.y;
5004
+ this.#cachedPosition.z = this.position.z;
5005
+ return this.#cachedPosition;
4989
5006
  }
4990
5007
  getRadius() {
4991
5008
  return this.bubble.radius ?? this.size.value;
4992
5009
  }
4993
5010
  getRotateData() {
4994
5011
  const angle = this.getAngle();
4995
- this._cachedRotateData.sin = Math.sin(angle);
4996
- this._cachedRotateData.cos = Math.cos(angle);
4997
- return this._cachedRotateData;
5012
+ this.#cachedRotateData.sin = Math.sin(angle);
5013
+ this.#cachedRotateData.cos = Math.cos(angle);
5014
+ return this.#cachedRotateData;
4998
5015
  }
4999
5016
  getStrokeColor() {
5000
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
5017
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
5001
5018
  }
5002
5019
  getTransformData(externalTransform) {
5003
5020
  const rotateData = this.getRotateData(), rotating = this.isRotating;
5004
- this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
5005
- this._cachedTransform.b = rotating
5021
+ this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
5022
+ this.#cachedTransform.b = rotating
5006
5023
  ? rotateData.sin * (externalTransform.b ?? identity$1)
5007
5024
  : (externalTransform.b ?? defaultTransform.b);
5008
- this._cachedTransform.c = rotating
5025
+ this.#cachedTransform.c = rotating
5009
5026
  ? -rotateData.sin * (externalTransform.c ?? identity$1)
5010
5027
  : (externalTransform.c ?? defaultTransform.c);
5011
- this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
5012
- return this._cachedTransform;
5028
+ this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
5029
+ return this.#cachedTransform;
5013
5030
  }
5014
5031
  init(id, position, overrideOptions, group) {
5015
- const container = this._container;
5032
+ const container = this.#container;
5016
5033
  this.id = id;
5017
5034
  this.group = group;
5018
5035
  this.justWarped = false;
@@ -5032,21 +5049,27 @@
5032
5049
  moveSpeed: 0,
5033
5050
  sizeAnimationSpeed: 0,
5034
5051
  };
5052
+ this.size = {
5053
+ value: 1,
5054
+ max: 1,
5055
+ min: 1,
5056
+ enable: false,
5057
+ };
5035
5058
  this.outType = ParticleOutType.normal;
5036
5059
  this.ignoresResizeRatio = true;
5037
- 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;
5060
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
5038
5061
  this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
5039
5062
  this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
5040
5063
  const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
5041
5064
  if (overrideOptions) {
5042
- if (overrideOptions.effect?.type) {
5065
+ if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
5043
5066
  const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
5044
5067
  if (effect) {
5045
5068
  this.effect = effect;
5046
5069
  effectOptions.load(overrideOptions.effect);
5047
5070
  }
5048
5071
  }
5049
- if (overrideOptions.shape?.type) {
5072
+ if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
5050
5073
  const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
5051
5074
  if (shape) {
5052
5075
  this.shape = shape;
@@ -5055,21 +5078,20 @@
5055
5078
  }
5056
5079
  }
5057
5080
  if (this.effect === randomColorValue) {
5058
- const availableEffects = [...this._container.effectDrawers.keys()];
5081
+ const availableEffects = [...this.#container.effectDrawers.keys()];
5059
5082
  this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
5060
5083
  }
5061
5084
  if (this.shape === randomColorValue) {
5062
- const availableShapes = [...this._container.shapeDrawers.keys()];
5085
+ const availableShapes = [...this.#container.shapeDrawers.keys()];
5063
5086
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
5064
5087
  }
5065
5088
  this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
5066
5089
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
5067
5090
  particlesOptions.load(overrideOptions);
5068
- const effectData = this.effectData;
5091
+ const effectData = this.effectData, shapeData = this.shapeData;
5069
5092
  if (effectData) {
5070
5093
  particlesOptions.load(effectData.particles);
5071
5094
  }
5072
- const shapeData = this.shapeData;
5073
5095
  if (shapeData) {
5074
5096
  particlesOptions.load(shapeData.particles);
5075
5097
  }
@@ -5077,7 +5099,9 @@
5077
5099
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
5078
5100
  this.options = particlesOptions;
5079
5101
  container.retina.initParticle(this);
5080
- this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
5102
+ for (const updater of container.particleUpdaters) {
5103
+ updater.preInit?.(this);
5104
+ }
5081
5105
  this.bubble = {
5082
5106
  inRange: false,
5083
5107
  };
@@ -5085,8 +5109,8 @@
5085
5109
  inRange: false,
5086
5110
  factor: 1,
5087
5111
  };
5088
- this._initPosition(position);
5089
- this.initialVelocity = this._calculateVelocity();
5112
+ this.#initPosition(position);
5113
+ this.initialVelocity = this.#calculateVelocity();
5090
5114
  this.velocity = this.initialVelocity.copy();
5091
5115
  this.zIndexFactor = this.position.z / container.zLayers;
5092
5116
  this.sides = 24;
@@ -5117,12 +5141,11 @@
5117
5141
  plugin.particleCreated?.(this);
5118
5142
  }
5119
5143
  }
5120
- isInsideCanvas() {
5121
- const radius = this.getRadius(), canvasSize = this._container.canvas.size, position = this.position;
5122
- return (position.x >= -radius &&
5123
- position.y >= -radius &&
5124
- position.y <= canvasSize.height + radius &&
5125
- position.x <= canvasSize.width + radius);
5144
+ isInsideCanvas(direction) {
5145
+ return this.#getInsideCanvasResult({ direction }).inside;
5146
+ }
5147
+ isInsideCanvasForOutMode(outMode, direction) {
5148
+ return this.#getInsideCanvasResult({ direction, outMode }).inside;
5126
5149
  }
5127
5150
  isShowingBack() {
5128
5151
  if (!this.roll) {
@@ -5147,13 +5170,13 @@
5147
5170
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
5148
5171
  }
5149
5172
  reset() {
5150
- for (const updater of this._container.particleUpdaters) {
5173
+ for (const updater of this.#container.particleUpdaters) {
5151
5174
  updater.reset?.(this);
5152
5175
  }
5153
5176
  }
5154
- _calcPosition = (position, zIndex) => {
5177
+ #calcPosition = (position, zIndex) => {
5155
5178
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
5156
- const container = this._container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5179
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5157
5180
  while (!signal.aborted) {
5158
5181
  for (const plugin of plugins) {
5159
5182
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -5165,10 +5188,10 @@
5165
5188
  size: canvasSize,
5166
5189
  position: posVec,
5167
5190
  }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
5168
- this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
5169
- this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
5170
- this._fixVertical(pos, radius, outModes.top ?? outModes.default);
5171
- this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
5191
+ this.#fixHorizontal(pos, radius, outModes.left ?? outModes.default);
5192
+ this.#fixHorizontal(pos, radius, outModes.right ?? outModes.default);
5193
+ this.#fixVertical(pos, radius, outModes.top ?? outModes.default);
5194
+ this.#fixVertical(pos, radius, outModes.bottom ?? outModes.default);
5172
5195
  let isValidPosition = true;
5173
5196
  for (const plugin of container.particles.checkParticlePositionPlugins) {
5174
5197
  isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
@@ -5184,8 +5207,8 @@
5184
5207
  }
5185
5208
  return posVec;
5186
5209
  };
5187
- _calculateVelocity = () => {
5188
- const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
5210
+ #calculateVelocity = () => {
5211
+ const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
5189
5212
  if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
5190
5213
  return res;
5191
5214
  }
@@ -5201,27 +5224,86 @@
5201
5224
  }
5202
5225
  return res;
5203
5226
  };
5204
- _fixHorizontal = (pos, radius, outMode) => {
5227
+ #fixHorizontal = (pos, radius, outMode) => {
5205
5228
  fixOutMode({
5206
5229
  outMode,
5207
5230
  checkModes: [OutMode.bounce],
5208
5231
  coord: pos.x,
5209
- maxCoord: this._container.canvas.size.width,
5232
+ maxCoord: this.#container.canvas.size.width,
5210
5233
  setCb: (value) => (pos.x += value),
5211
5234
  radius,
5212
5235
  });
5213
5236
  };
5214
- _fixVertical = (pos, radius, outMode) => {
5237
+ #fixVertical = (pos, radius, outMode) => {
5215
5238
  fixOutMode({
5216
5239
  outMode,
5217
5240
  checkModes: [OutMode.bounce],
5218
5241
  coord: pos.y,
5219
- maxCoord: this._container.canvas.size.height,
5242
+ maxCoord: this.#container.canvas.size.height,
5220
5243
  setCb: (value) => (pos.y += value),
5221
5244
  radius,
5222
5245
  });
5223
5246
  };
5224
- _getRollColor = color => {
5247
+ #getDefaultInsideCanvasResult = (direction, outMode) => {
5248
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
5249
+ if (direction === OutModeDirection.bottom) {
5250
+ return {
5251
+ inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
5252
+ reason: "default",
5253
+ };
5254
+ }
5255
+ if (direction === OutModeDirection.left) {
5256
+ return {
5257
+ inside: isBounce ? position.x - radius > defaultAngle : position.x + radius > defaultAngle,
5258
+ reason: "default",
5259
+ };
5260
+ }
5261
+ if (direction === OutModeDirection.right) {
5262
+ return {
5263
+ inside: isBounce ? position.x + radius < canvasSize.width : position.x - radius < canvasSize.width,
5264
+ reason: "default",
5265
+ };
5266
+ }
5267
+ if (direction === OutModeDirection.top) {
5268
+ return {
5269
+ inside: isBounce ? position.y - radius > defaultAngle : position.y + radius > defaultAngle,
5270
+ reason: "default",
5271
+ };
5272
+ }
5273
+ return {
5274
+ inside: position.x >= -radius &&
5275
+ position.y >= -radius &&
5276
+ position.y <= canvasSize.height + radius &&
5277
+ position.x <= canvasSize.width + radius,
5278
+ reason: "default",
5279
+ };
5280
+ };
5281
+ #getInsideCanvasCallbackData = (direction, outMode) => {
5282
+ return {
5283
+ canvasSize: this.#container.canvas.size,
5284
+ direction,
5285
+ outMode,
5286
+ particle: this,
5287
+ radius: this.getRadius(),
5288
+ };
5289
+ };
5290
+ #getInsideCanvasResult = (data) => {
5291
+ 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;
5292
+ if (!shapeCheck && !effectCheck) {
5293
+ return defaultResult;
5294
+ }
5295
+ const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
5296
+ if (shapeResult && effectResult) {
5297
+ const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
5298
+ return {
5299
+ inside: shapeResult.inside && effectResult.inside,
5300
+ margin: margin > defaultAngle ? margin : undefined,
5301
+ reason: "combined",
5302
+ };
5303
+ }
5304
+ return shapeResult ?? effectResult ?? defaultResult;
5305
+ };
5306
+ #getRollColor = color => {
5225
5307
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
5226
5308
  return color;
5227
5309
  }
@@ -5236,8 +5318,8 @@
5236
5318
  }
5237
5319
  return color;
5238
5320
  };
5239
- _initPosition = position => {
5240
- const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5321
+ #initPosition = position => {
5322
+ const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5241
5323
  if (!initialPosition) {
5242
5324
  throw new Error("a valid position cannot be found for particle");
5243
5325
  }
@@ -5260,45 +5342,58 @@
5260
5342
  }
5261
5343
  this.offset = Vector.origin;
5262
5344
  };
5345
+ #normalizeInsideCanvasResult = (result, reason) => {
5346
+ if (typeof result === "boolean") {
5347
+ return {
5348
+ inside: result,
5349
+ reason,
5350
+ };
5351
+ }
5352
+ return {
5353
+ inside: result.inside,
5354
+ margin: result.margin,
5355
+ reason: result.reason ?? reason,
5356
+ };
5357
+ };
5263
5358
  }
5264
5359
 
5265
5360
  class SpatialHashGrid {
5266
- _cellSize;
5267
- _cells = new Map();
5268
- _circlePool = [];
5269
- _circlePoolIdx;
5270
- _pendingCellSize;
5271
- _rectanglePool = [];
5272
- _rectanglePoolIdx;
5361
+ #cellSize;
5362
+ #cells = new Map();
5363
+ #circlePool = [];
5364
+ #circlePoolIdx;
5365
+ #pendingCellSize;
5366
+ #rectanglePool = [];
5367
+ #rectanglePoolIdx;
5273
5368
  constructor(cellSize) {
5274
- this._cellSize = cellSize;
5275
- this._circlePoolIdx = 0;
5276
- this._rectanglePoolIdx = 0;
5369
+ this.#cellSize = cellSize;
5370
+ this.#circlePoolIdx = 0;
5371
+ this.#rectanglePoolIdx = 0;
5277
5372
  }
5278
5373
  clear() {
5279
- this._cells.clear();
5280
- const pendingCellSize = this._pendingCellSize;
5374
+ this.#cells.clear();
5375
+ const pendingCellSize = this.#pendingCellSize;
5281
5376
  if (pendingCellSize) {
5282
- this._cellSize = pendingCellSize;
5377
+ this.#cellSize = pendingCellSize;
5283
5378
  }
5284
- this._pendingCellSize = undefined;
5379
+ this.#pendingCellSize = undefined;
5285
5380
  }
5286
5381
  insert(particle) {
5287
- const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
5288
- if (!this._cells.has(key)) {
5289
- this._cells.set(key, []);
5382
+ const { x, y } = particle.getPosition(), key = this.#cellKeyFromCoords(x, y);
5383
+ if (!this.#cells.has(key)) {
5384
+ this.#cells.set(key, []);
5290
5385
  }
5291
- this._cells.get(key)?.push(particle);
5386
+ this.#cells.get(key)?.push(particle);
5292
5387
  }
5293
5388
  query(range, check, out = []) {
5294
- const bounds = this._getRangeBounds(range);
5389
+ const bounds = this.#getRangeBounds(range);
5295
5390
  if (!bounds) {
5296
5391
  return out;
5297
5392
  }
5298
- 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);
5393
+ 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);
5299
5394
  for (let cx = minCellX; cx <= maxCellX; cx++) {
5300
5395
  for (let cy = minCellY; cy <= maxCellY; cy++) {
5301
- const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
5396
+ const key = `${cx}_${cy}`, cellParticles = this.#cells.get(key);
5302
5397
  if (!cellParticles) {
5303
5398
  continue;
5304
5399
  }
@@ -5315,29 +5410,29 @@
5315
5410
  return out;
5316
5411
  }
5317
5412
  queryCircle(position, radius, check, out = []) {
5318
- const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5319
- this._releaseShapes();
5413
+ const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5414
+ this.#releaseShapes();
5320
5415
  return result;
5321
5416
  }
5322
5417
  queryRectangle(position, size, check, out = []) {
5323
- const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5324
- this._releaseShapes();
5418
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5419
+ this.#releaseShapes();
5325
5420
  return result;
5326
5421
  }
5327
5422
  setCellSize(cellSize) {
5328
- this._pendingCellSize = cellSize;
5423
+ this.#pendingCellSize = cellSize;
5329
5424
  }
5330
- _acquireCircle(x, y, r) {
5331
- return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5425
+ #acquireCircle(x, y, r) {
5426
+ return (this.#circlePool[this.#circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5332
5427
  }
5333
- _acquireRectangle(x, y, w, h) {
5334
- return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5428
+ #acquireRectangle(x, y, w, h) {
5429
+ return (this.#rectanglePool[this.#rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5335
5430
  }
5336
- _cellKeyFromCoords(x, y) {
5337
- const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
5431
+ #cellKeyFromCoords(x, y) {
5432
+ const cellX = Math.floor(x / this.#cellSize), cellY = Math.floor(y / this.#cellSize);
5338
5433
  return `${cellX}_${cellY}`;
5339
5434
  }
5340
- _getRangeBounds(range) {
5435
+ #getRangeBounds(range) {
5341
5436
  if (range instanceof Circle) {
5342
5437
  const r = range.radius, { x, y } = range.position;
5343
5438
  return {
@@ -5358,53 +5453,53 @@
5358
5453
  }
5359
5454
  return null;
5360
5455
  }
5361
- _releaseShapes() {
5362
- this._circlePoolIdx = 0;
5363
- this._rectanglePoolIdx = 0;
5456
+ #releaseShapes() {
5457
+ this.#circlePoolIdx = 0;
5458
+ this.#rectanglePoolIdx = 0;
5364
5459
  }
5365
5460
  }
5366
5461
 
5367
5462
  class ParticlesManager {
5368
5463
  checkParticlePositionPlugins;
5369
5464
  grid;
5370
- _array;
5371
- _container;
5372
- _groupLimits;
5373
- _limit;
5374
- _nextId;
5375
- _particleBuckets;
5376
- _particleResetPlugins;
5377
- _particleUpdatePlugins;
5378
- _pluginManager;
5379
- _pool;
5380
- _postParticleUpdatePlugins;
5381
- _postUpdatePlugins;
5382
- _resizeFactor;
5383
- _updatePlugins;
5384
- _zBuckets;
5465
+ #array;
5466
+ #container;
5467
+ #groupLimits;
5468
+ #limit;
5469
+ #nextId;
5470
+ #particleBuckets;
5471
+ #particleResetPlugins;
5472
+ #particleUpdatePlugins;
5473
+ #pluginManager;
5474
+ #pool;
5475
+ #postParticleUpdatePlugins;
5476
+ #postUpdatePlugins;
5477
+ #resizeFactor;
5478
+ #updatePlugins;
5479
+ #zBuckets;
5385
5480
  constructor(pluginManager, container) {
5386
- this._pluginManager = pluginManager;
5387
- this._container = container;
5388
- this._nextId = 0;
5389
- this._array = [];
5390
- this._pool = [];
5391
- this._limit = 0;
5392
- this._groupLimits = new Map();
5393
- this._particleBuckets = new Map();
5394
- this._zBuckets = this._createBuckets(this._container.zLayers);
5481
+ this.#pluginManager = pluginManager;
5482
+ this.#container = container;
5483
+ this.#nextId = 0;
5484
+ this.#array = [];
5485
+ this.#pool = [];
5486
+ this.#limit = 0;
5487
+ this.#groupLimits = new Map();
5488
+ this.#particleBuckets = new Map();
5489
+ this.#zBuckets = this.#createBuckets(this.#container.zLayers);
5395
5490
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
5396
5491
  this.checkParticlePositionPlugins = [];
5397
- this._particleResetPlugins = [];
5398
- this._particleUpdatePlugins = [];
5399
- this._postUpdatePlugins = [];
5400
- this._postParticleUpdatePlugins = [];
5401
- this._updatePlugins = [];
5492
+ this.#particleResetPlugins = [];
5493
+ this.#particleUpdatePlugins = [];
5494
+ this.#postUpdatePlugins = [];
5495
+ this.#postParticleUpdatePlugins = [];
5496
+ this.#updatePlugins = [];
5402
5497
  }
5403
5498
  get count() {
5404
- return this._array.length;
5499
+ return this.#array.length;
5405
5500
  }
5406
5501
  addParticle(position, overrideOptions, group, initializer) {
5407
- const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
5502
+ const limitMode = this.#container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this.#limit : (this.#groupLimits.get(group) ?? this.#limit), currentCount = this.count;
5408
5503
  if (limit > minLimit) {
5409
5504
  switch (limitMode) {
5410
5505
  case LimitMode.delete: {
@@ -5422,20 +5517,20 @@
5422
5517
  }
5423
5518
  }
5424
5519
  try {
5425
- const particle = this._pool.pop() ?? new Particle(this._pluginManager, this._container);
5426
- particle.init(this._nextId, position, overrideOptions, group);
5520
+ const particle = this.#pool.pop() ?? new Particle(this.#pluginManager, this.#container);
5521
+ particle.init(this.#nextId, position, overrideOptions, group);
5427
5522
  let canAdd = true;
5428
5523
  if (initializer) {
5429
5524
  canAdd = initializer(particle);
5430
5525
  }
5431
5526
  if (!canAdd) {
5432
- this._pool.push(particle);
5527
+ this.#pool.push(particle);
5433
5528
  return;
5434
5529
  }
5435
- this._array.push(particle);
5436
- this._insertParticleIntoBucket(particle);
5437
- this._nextId++;
5438
- this._container.dispatchEvent(EventType.particleAdded, {
5530
+ this.#array.push(particle);
5531
+ this.#insertParticleIntoBucket(particle);
5532
+ this.#nextId++;
5533
+ this.#container.dispatchEvent(EventType.particleAdded, {
5439
5534
  particle,
5440
5535
  });
5441
5536
  return particle;
@@ -5446,25 +5541,25 @@
5446
5541
  return undefined;
5447
5542
  }
5448
5543
  clear() {
5449
- this._array = [];
5450
- this._particleBuckets.clear();
5451
- this._resetBuckets(this._container.zLayers);
5544
+ this.#array = [];
5545
+ this.#particleBuckets.clear();
5546
+ this.#resetBuckets(this.#container.zLayers);
5452
5547
  }
5453
5548
  destroy() {
5454
- this._array = [];
5455
- this._pool.length = 0;
5456
- this._particleBuckets.clear();
5457
- this._zBuckets = [];
5549
+ this.#array = [];
5550
+ this.#pool.length = 0;
5551
+ this.#particleBuckets.clear();
5552
+ this.#zBuckets = [];
5458
5553
  this.checkParticlePositionPlugins = [];
5459
- this._particleResetPlugins = [];
5460
- this._particleUpdatePlugins = [];
5461
- this._postUpdatePlugins = [];
5462
- this._postParticleUpdatePlugins = [];
5463
- this._updatePlugins = [];
5554
+ this.#particleResetPlugins = [];
5555
+ this.#particleUpdatePlugins = [];
5556
+ this.#postUpdatePlugins = [];
5557
+ this.#postParticleUpdatePlugins = [];
5558
+ this.#updatePlugins = [];
5464
5559
  }
5465
5560
  drawParticles(delta) {
5466
- for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
5467
- const bucket = this._zBuckets[i];
5561
+ for (let i = this.#zBuckets.length - one; i >= minIndex; i--) {
5562
+ const bucket = this.#zBuckets[i];
5468
5563
  if (!bucket) {
5469
5564
  continue;
5470
5565
  }
@@ -5474,24 +5569,24 @@
5474
5569
  }
5475
5570
  }
5476
5571
  filter(condition) {
5477
- return this._array.filter(condition);
5572
+ return this.#array.filter(condition);
5478
5573
  }
5479
5574
  find(condition) {
5480
- return this._array.find(condition);
5575
+ return this.#array.find(condition);
5481
5576
  }
5482
5577
  get(index) {
5483
- return this._array[index];
5578
+ return this.#array[index];
5484
5579
  }
5485
5580
  async init() {
5486
- const container = this._container, options = container.actualOptions;
5581
+ const container = this.#container, options = container.actualOptions;
5487
5582
  this.checkParticlePositionPlugins = [];
5488
- this._updatePlugins = [];
5489
- this._particleUpdatePlugins = [];
5490
- this._postUpdatePlugins = [];
5491
- this._particleResetPlugins = [];
5492
- this._postParticleUpdatePlugins = [];
5493
- this._particleBuckets.clear();
5494
- this._resetBuckets(container.zLayers);
5583
+ this.#updatePlugins = [];
5584
+ this.#particleUpdatePlugins = [];
5585
+ this.#postUpdatePlugins = [];
5586
+ this.#particleResetPlugins = [];
5587
+ this.#postParticleUpdatePlugins = [];
5588
+ this.#particleBuckets.clear();
5589
+ this.#resetBuckets(container.zLayers);
5495
5590
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
5496
5591
  for (const plugin of container.plugins) {
5497
5592
  if (plugin.redrawInit) {
@@ -5501,26 +5596,26 @@
5501
5596
  this.checkParticlePositionPlugins.push(plugin);
5502
5597
  }
5503
5598
  if (plugin.update) {
5504
- this._updatePlugins.push(plugin);
5599
+ this.#updatePlugins.push(plugin);
5505
5600
  }
5506
5601
  if (plugin.particleUpdate) {
5507
- this._particleUpdatePlugins.push(plugin);
5602
+ this.#particleUpdatePlugins.push(plugin);
5508
5603
  }
5509
5604
  if (plugin.postUpdate) {
5510
- this._postUpdatePlugins.push(plugin);
5605
+ this.#postUpdatePlugins.push(plugin);
5511
5606
  }
5512
5607
  if (plugin.particleReset) {
5513
- this._particleResetPlugins.push(plugin);
5608
+ this.#particleResetPlugins.push(plugin);
5514
5609
  }
5515
5610
  if (plugin.postParticleUpdate) {
5516
- this._postParticleUpdatePlugins.push(plugin);
5611
+ this.#postParticleUpdatePlugins.push(plugin);
5517
5612
  }
5518
5613
  }
5519
- await this._container.initDrawersAndUpdaters();
5520
- for (const drawer of this._container.effectDrawers.values()) {
5614
+ await this.#container.initDrawersAndUpdaters();
5615
+ for (const drawer of this.#container.effectDrawers.values()) {
5521
5616
  await drawer.init?.(container);
5522
5617
  }
5523
- for (const drawer of this._container.shapeDrawers.values()) {
5618
+ for (const drawer of this.#container.shapeDrawers.values()) {
5524
5619
  await drawer.init?.(container);
5525
5620
  }
5526
5621
  let handled = false;
@@ -5554,10 +5649,10 @@
5554
5649
  async redraw() {
5555
5650
  this.clear();
5556
5651
  await this.init();
5557
- this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
5652
+ this.#container.canvas.render.drawParticles({ value: 0, factor: 0 });
5558
5653
  }
5559
5654
  remove(particle, group, override) {
5560
- this.removeAt(this._array.indexOf(particle), undefined, group, override);
5655
+ this.removeAt(this.#array.indexOf(particle), undefined, group, override);
5561
5656
  }
5562
5657
  removeAt(index, quantity = defaultRemoveQuantity, group, override) {
5563
5658
  if (index < minIndex || index > this.count) {
@@ -5565,7 +5660,7 @@
5565
5660
  }
5566
5661
  let deleted = 0;
5567
5662
  for (let i = index; deleted < quantity && i < this.count; i++) {
5568
- if (this._removeParticle(i, group, override)) {
5663
+ if (this.#removeParticle(i, group, override)) {
5569
5664
  i--;
5570
5665
  deleted++;
5571
5666
  }
@@ -5575,9 +5670,9 @@
5575
5670
  this.removeAt(minIndex, quantity, group);
5576
5671
  }
5577
5672
  setDensity() {
5578
- const options = this._container.actualOptions, groups = options.particles.groups;
5673
+ const options = this.#container.actualOptions, groups = options.particles.groups;
5579
5674
  let pluginsCount = 0;
5580
- for (const plugin of this._container.plugins) {
5675
+ for (const plugin of this.#container.plugins) {
5581
5676
  if (plugin.particlesDensityCount) {
5582
5677
  pluginsCount += plugin.particlesDensityCount();
5583
5678
  }
@@ -5587,51 +5682,51 @@
5587
5682
  if (!groupData) {
5588
5683
  continue;
5589
5684
  }
5590
- const groupDataOptions = loadParticlesOptions(this._pluginManager, this._container, groupData);
5591
- this._applyDensity(groupDataOptions, pluginsCount, group);
5685
+ const groupDataOptions = loadParticlesOptions(this.#pluginManager, this.#container, groupData);
5686
+ this.#applyDensity(groupDataOptions, pluginsCount, group);
5592
5687
  }
5593
- this._applyDensity(options.particles, pluginsCount);
5688
+ this.#applyDensity(options.particles, pluginsCount);
5594
5689
  }
5595
5690
  setResizeFactor(factor) {
5596
- this._resizeFactor = factor;
5691
+ this.#resizeFactor = factor;
5597
5692
  }
5598
5693
  update(delta) {
5599
5694
  this.grid.clear();
5600
- for (const plugin of this._updatePlugins) {
5695
+ for (const plugin of this.#updatePlugins) {
5601
5696
  plugin.update?.(delta);
5602
5697
  }
5603
- const particlesToDelete = this._updateParticlesPhase1(delta);
5604
- for (const plugin of this._postUpdatePlugins) {
5698
+ const particlesToDelete = this.#updateParticlesPhase1(delta);
5699
+ for (const plugin of this.#postUpdatePlugins) {
5605
5700
  plugin.postUpdate?.(delta);
5606
5701
  }
5607
- this._updateParticlesPhase2(delta, particlesToDelete);
5702
+ this.#updateParticlesPhase2(delta, particlesToDelete);
5608
5703
  if (particlesToDelete.size) {
5609
5704
  for (const particle of particlesToDelete) {
5610
5705
  this.remove(particle);
5611
5706
  }
5612
5707
  }
5613
- delete this._resizeFactor;
5708
+ this.#resizeFactor = undefined;
5614
5709
  }
5615
- _addToPool = (...particles) => {
5616
- this._pool.push(...particles);
5710
+ #addToPool = (...particles) => {
5711
+ this.#pool.push(...particles);
5617
5712
  };
5618
- _applyDensity = (options, pluginsCount, group, groupOptions) => {
5713
+ #applyDensity = (options, pluginsCount, group, groupOptions) => {
5619
5714
  const numberOptions = options.number;
5620
5715
  if (!numberOptions.density.enable) {
5621
5716
  if (group === undefined) {
5622
- this._limit = numberOptions.limit.value;
5717
+ this.#limit = numberOptions.limit.value;
5623
5718
  }
5624
5719
  else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
5625
- this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5720
+ this.#groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5626
5721
  }
5627
5722
  return;
5628
5723
  }
5629
- 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);
5724
+ 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);
5630
5725
  if (group === undefined) {
5631
- this._limit = numberOptions.limit.value * densityFactor;
5726
+ this.#limit = numberOptions.limit.value * densityFactor;
5632
5727
  }
5633
5728
  else {
5634
- this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
5729
+ this.#groupLimits.set(group, numberOptions.limit.value * densityFactor);
5635
5730
  }
5636
5731
  if (particlesCount < particlesNumber) {
5637
5732
  this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
@@ -5640,18 +5735,18 @@
5640
5735
  this.removeQuantity(particlesCount - particlesNumber, group);
5641
5736
  }
5642
5737
  };
5643
- _createBuckets = (zLayers) => {
5738
+ #createBuckets = (zLayers) => {
5644
5739
  const bucketCount = Math.max(Math.floor(zLayers), one);
5645
5740
  return Array.from({ length: bucketCount }, () => []);
5646
5741
  };
5647
- _getBucketIndex = (zIndex) => {
5648
- const maxBucketIndex = this._zBuckets.length - one;
5742
+ #getBucketIndex = (zIndex) => {
5743
+ const maxBucketIndex = this.#zBuckets.length - one;
5649
5744
  if (maxBucketIndex <= minIndex) {
5650
5745
  return minIndex;
5651
5746
  }
5652
5747
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
5653
5748
  };
5654
- _getParticleInsertIndex = (bucket, particleId) => {
5749
+ #getParticleInsertIndex = (bucket, particleId) => {
5655
5750
  let start = minIndex, end = bucket.length;
5656
5751
  while (start < end) {
5657
5752
  const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
@@ -5668,8 +5763,8 @@
5668
5763
  }
5669
5764
  return start;
5670
5765
  };
5671
- _initDensityFactor = densityOptions => {
5672
- const container = this._container;
5766
+ #initDensityFactor = densityOptions => {
5767
+ const container = this.#container;
5673
5768
  if (!densityOptions.enable) {
5674
5769
  return defaultDensityFactor;
5675
5770
  }
@@ -5679,82 +5774,82 @@
5679
5774
  }
5680
5775
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
5681
5776
  };
5682
- _insertParticleIntoBucket = (particle) => {
5683
- const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5777
+ #insertParticleIntoBucket = (particle) => {
5778
+ const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5684
5779
  if (!bucket) {
5685
5780
  return;
5686
5781
  }
5687
- bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
5688
- this._particleBuckets.set(particle.id, bucketIndex);
5782
+ bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
5783
+ this.#particleBuckets.set(particle.id, bucketIndex);
5689
5784
  };
5690
- _removeParticle = (index, group, override) => {
5691
- const particle = this._array[index];
5785
+ #removeParticle = (index, group, override) => {
5786
+ const particle = this.#array[index];
5692
5787
  if (!particle) {
5693
5788
  return false;
5694
5789
  }
5695
5790
  if (particle.group !== group) {
5696
5791
  return false;
5697
5792
  }
5698
- this._array.splice(index, deleteCount);
5699
- this._removeParticleFromBucket(particle);
5793
+ this.#array.splice(index, deleteCount);
5794
+ this.#removeParticleFromBucket(particle);
5700
5795
  particle.destroy(override);
5701
- this._container.dispatchEvent(EventType.particleRemoved, {
5796
+ this.#container.dispatchEvent(EventType.particleRemoved, {
5702
5797
  particle,
5703
5798
  });
5704
- this._addToPool(particle);
5799
+ this.#addToPool(particle);
5705
5800
  return true;
5706
5801
  };
5707
- _removeParticleFromBucket = (particle) => {
5708
- const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5802
+ #removeParticleFromBucket = (particle) => {
5803
+ const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5709
5804
  if (!bucket) {
5710
- this._particleBuckets.delete(particle.id);
5805
+ this.#particleBuckets.delete(particle.id);
5711
5806
  return;
5712
5807
  }
5713
- const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
5808
+ const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
5714
5809
  if (bucket[particleIndex]?.id !== particle.id) {
5715
- this._particleBuckets.delete(particle.id);
5810
+ this.#particleBuckets.delete(particle.id);
5716
5811
  return;
5717
5812
  }
5718
5813
  bucket.splice(particleIndex, deleteCount);
5719
- this._particleBuckets.delete(particle.id);
5814
+ this.#particleBuckets.delete(particle.id);
5720
5815
  };
5721
- _resetBuckets = (zLayers) => {
5816
+ #resetBuckets = (zLayers) => {
5722
5817
  const bucketCount = Math.max(Math.floor(zLayers), one);
5723
- if (this._zBuckets.length !== bucketCount) {
5724
- this._zBuckets = this._createBuckets(bucketCount);
5818
+ if (this.#zBuckets.length !== bucketCount) {
5819
+ this.#zBuckets = this.#createBuckets(bucketCount);
5725
5820
  return;
5726
5821
  }
5727
- for (const bucket of this._zBuckets) {
5822
+ for (const bucket of this.#zBuckets) {
5728
5823
  bucket.length = minIndex;
5729
5824
  }
5730
5825
  };
5731
- _updateParticleBucket = (particle) => {
5732
- const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
5826
+ #updateParticleBucket = (particle) => {
5827
+ const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
5733
5828
  if (currentBucketIndex === undefined) {
5734
- this._insertParticleIntoBucket(particle);
5829
+ this.#insertParticleIntoBucket(particle);
5735
5830
  return;
5736
5831
  }
5737
5832
  if (currentBucketIndex === newBucketIndex) {
5738
5833
  return;
5739
5834
  }
5740
- const currentBucket = this._zBuckets[currentBucketIndex];
5835
+ const currentBucket = this.#zBuckets[currentBucketIndex];
5741
5836
  if (currentBucket) {
5742
- const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
5837
+ const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
5743
5838
  if (currentBucket[particleIndex]?.id === particle.id) {
5744
5839
  currentBucket.splice(particleIndex, deleteCount);
5745
5840
  }
5746
5841
  }
5747
- const newBucket = this._zBuckets[newBucketIndex];
5842
+ const newBucket = this.#zBuckets[newBucketIndex];
5748
5843
  if (!newBucket) {
5749
- this._particleBuckets.set(particle.id, newBucketIndex);
5844
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5750
5845
  return;
5751
5846
  }
5752
- newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
5753
- this._particleBuckets.set(particle.id, newBucketIndex);
5847
+ newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
5848
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5754
5849
  };
5755
- _updateParticlesPhase1 = (delta) => {
5756
- const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
5757
- for (const particle of this._array) {
5850
+ #updateParticlesPhase1 = (delta) => {
5851
+ const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
5852
+ for (const particle of this.#array) {
5758
5853
  if (resizeFactor && !particle.ignoresResizeRatio) {
5759
5854
  particle.position.x *= resizeFactor.width;
5760
5855
  particle.position.y *= resizeFactor.height;
@@ -5762,10 +5857,10 @@
5762
5857
  particle.initialPosition.y *= resizeFactor.height;
5763
5858
  }
5764
5859
  particle.ignoresResizeRatio = false;
5765
- for (const plugin of this._particleResetPlugins) {
5860
+ for (const plugin of this.#particleResetPlugins) {
5766
5861
  plugin.particleReset?.(particle);
5767
5862
  }
5768
- for (const plugin of this._particleUpdatePlugins) {
5863
+ for (const plugin of this.#particleUpdatePlugins) {
5769
5864
  if (particle.destroyed) {
5770
5865
  break;
5771
5866
  }
@@ -5779,36 +5874,36 @@
5779
5874
  }
5780
5875
  return particlesToDelete;
5781
5876
  };
5782
- _updateParticlesPhase2 = (delta, particlesToDelete) => {
5783
- for (const particle of this._array) {
5877
+ #updateParticlesPhase2 = (delta, particlesToDelete) => {
5878
+ for (const particle of this.#array) {
5784
5879
  if (particle.destroyed) {
5785
5880
  particlesToDelete.add(particle);
5786
5881
  continue;
5787
5882
  }
5788
- for (const updater of this._container.particleUpdaters) {
5883
+ for (const updater of this.#container.particleUpdaters) {
5789
5884
  updater.update(particle, delta);
5790
5885
  }
5791
5886
  if (!particle.spawning) {
5792
- for (const plugin of this._postParticleUpdatePlugins) {
5887
+ for (const plugin of this.#postParticleUpdatePlugins) {
5793
5888
  plugin.postParticleUpdate?.(particle, delta);
5794
5889
  }
5795
5890
  }
5796
- this._updateParticleBucket(particle);
5891
+ this.#updateParticleBucket(particle);
5797
5892
  }
5798
5893
  };
5799
5894
  }
5800
5895
 
5801
5896
  class Retina {
5802
- container;
5803
5897
  pixelRatio;
5804
5898
  reduceFactor;
5899
+ #container;
5805
5900
  constructor(container) {
5806
- this.container = container;
5901
+ this.#container = container;
5807
5902
  this.pixelRatio = defaultRatio;
5808
5903
  this.reduceFactor = defaultReduceFactor;
5809
5904
  }
5810
5905
  init() {
5811
- const container = this.container, options = container.actualOptions;
5906
+ const container = this.#container, options = container.actualOptions;
5812
5907
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
5813
5908
  this.reduceFactor = defaultReduceFactor;
5814
5909
  const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
@@ -5822,7 +5917,6 @@
5822
5917
  props.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
5823
5918
  props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
5824
5919
  props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
5825
- props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
5826
5920
  const maxDistance = props.maxDistance;
5827
5921
  maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
5828
5922
  maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
@@ -5860,73 +5954,73 @@
5860
5954
  shapeDrawers;
5861
5955
  started;
5862
5956
  zLayers;
5863
- _delay;
5864
- _delayTimeout;
5865
- _delta = { value: 0, factor: 0 };
5866
- _dispatchCallback;
5867
- _drawAnimationFrame;
5868
- _duration;
5869
- _eventListeners;
5870
- _firstStart;
5871
- _initialSourceOptions;
5872
- _lastFrameTime;
5873
- _lifeTime;
5874
- _onDestroy;
5875
- _options;
5876
- _paused;
5877
- _pluginManager;
5878
- _smooth;
5879
- _sourceOptions;
5957
+ #delay;
5958
+ #delayTimeout;
5959
+ #delta = { value: 0, factor: 0 };
5960
+ #dispatchCallback;
5961
+ #drawAnimationFrame;
5962
+ #duration;
5963
+ #eventListeners;
5964
+ #firstStart;
5965
+ #initialSourceOptions;
5966
+ #lastFrameTime;
5967
+ #lifeTime;
5968
+ #onDestroy;
5969
+ #options;
5970
+ #paused;
5971
+ #pluginManager;
5972
+ #smooth;
5973
+ #sourceOptions;
5880
5974
  constructor(params) {
5881
5975
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
5882
- this._pluginManager = pluginManager;
5883
- this._dispatchCallback = dispatchCallback;
5884
- this._onDestroy = onDestroy;
5976
+ this.#pluginManager = pluginManager;
5977
+ this.#dispatchCallback = dispatchCallback;
5978
+ this.#onDestroy = onDestroy;
5885
5979
  this.id = Symbol(id);
5886
5980
  this.fpsLimit = 120;
5887
5981
  this.hdr = false;
5888
- this._smooth = false;
5889
- this._delay = 0;
5890
- this._duration = 0;
5891
- this._lifeTime = 0;
5892
- this._firstStart = true;
5982
+ this.#smooth = false;
5983
+ this.#delay = 0;
5984
+ this.#duration = 0;
5985
+ this.#lifeTime = 0;
5986
+ this.#firstStart = true;
5893
5987
  this.started = false;
5894
5988
  this.destroyed = false;
5895
- this._paused = true;
5896
- this._lastFrameTime = 0;
5989
+ this.#paused = true;
5990
+ this.#lastFrameTime = 0;
5897
5991
  this.zLayers = 100;
5898
5992
  this.pageHidden = false;
5899
- this._sourceOptions = sourceOptions;
5900
- this._initialSourceOptions = sourceOptions;
5993
+ this.#sourceOptions = sourceOptions;
5994
+ this.#initialSourceOptions = sourceOptions;
5901
5995
  this.effectDrawers = new Map();
5902
5996
  this.shapeDrawers = new Map();
5903
5997
  this.particleUpdaters = [];
5904
5998
  this.retina = new Retina(this);
5905
- this.canvas = new CanvasManager(this._pluginManager, this);
5906
- this.particles = new ParticlesManager(this._pluginManager, this);
5999
+ this.canvas = new CanvasManager(this.#pluginManager, this);
6000
+ this.particles = new ParticlesManager(this.#pluginManager, this);
5907
6001
  this.plugins = [];
5908
6002
  this.particleDestroyedPlugins = [];
5909
6003
  this.particleCreatedPlugins = [];
5910
6004
  this.particlePositionPlugins = [];
5911
- this._options = loadContainerOptions(this._pluginManager, this);
5912
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
5913
- this._eventListeners = new EventListeners(this);
6005
+ this.#options = loadContainerOptions(this.#pluginManager, this);
6006
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
6007
+ this.#eventListeners = new EventListeners(this);
5914
6008
  this.dispatchEvent(EventType.containerBuilt);
5915
6009
  }
5916
6010
  get animationStatus() {
5917
- return !this._paused && !this.pageHidden && guardCheck(this);
6011
+ return !this.#paused && !this.pageHidden && guardCheck(this);
5918
6012
  }
5919
6013
  get options() {
5920
- return this._options;
6014
+ return this.#options;
5921
6015
  }
5922
6016
  get sourceOptions() {
5923
- return this._sourceOptions;
6017
+ return this.#sourceOptions;
5924
6018
  }
5925
6019
  addLifeTime(value) {
5926
- this._lifeTime += value;
6020
+ this.#lifeTime += value;
5927
6021
  }
5928
6022
  alive() {
5929
- return !this._duration || this._lifeTime <= this._duration;
6023
+ return !this.#duration || this.#lifeTime <= this.#duration;
5930
6024
  }
5931
6025
  destroy(remove = true) {
5932
6026
  if (!guardCheck(this)) {
@@ -5948,13 +6042,13 @@
5948
6042
  this.shapeDrawers = new Map();
5949
6043
  this.particleUpdaters = [];
5950
6044
  this.plugins.length = 0;
5951
- this._pluginManager.clearPlugins(this);
6045
+ this.#pluginManager.clearPlugins(this);
5952
6046
  this.destroyed = true;
5953
- this._onDestroy(remove);
6047
+ this.#onDestroy(remove);
5954
6048
  this.dispatchEvent(EventType.containerDestroyed);
5955
6049
  }
5956
6050
  dispatchEvent(type, data) {
5957
- this._dispatchCallback(type, {
6051
+ this.#dispatchCallback(type, {
5958
6052
  container: this,
5959
6053
  data,
5960
6054
  });
@@ -5964,12 +6058,12 @@
5964
6058
  return;
5965
6059
  }
5966
6060
  let refreshTime = force;
5967
- this._drawAnimationFrame = animate((timestamp) => {
6061
+ this.#drawAnimationFrame = animate((timestamp) => {
5968
6062
  if (refreshTime) {
5969
- this._lastFrameTime = undefined;
6063
+ this.#lastFrameTime = undefined;
5970
6064
  refreshTime = false;
5971
6065
  }
5972
- this._nextFrame(timestamp);
6066
+ this.#nextFrame(timestamp);
5973
6067
  });
5974
6068
  }
5975
6069
  async export(type, options = {}) {
@@ -5991,7 +6085,7 @@
5991
6085
  return;
5992
6086
  }
5993
6087
  const allContainerPlugins = new Map();
5994
- for (const plugin of this._pluginManager.plugins) {
6088
+ for (const plugin of this.#pluginManager.plugins) {
5995
6089
  const containerPlugin = await plugin.getPlugin(this);
5996
6090
  if (containerPlugin.preInit) {
5997
6091
  await containerPlugin.preInit();
@@ -5999,8 +6093,8 @@
5999
6093
  allContainerPlugins.set(plugin, containerPlugin);
6000
6094
  }
6001
6095
  await this.initDrawersAndUpdaters();
6002
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
6003
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
6096
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
6097
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
6004
6098
  this.plugins.length = 0;
6005
6099
  this.particleDestroyedPlugins.length = 0;
6006
6100
  this.particleCreatedPlugins.length = 0;
@@ -6027,11 +6121,11 @@
6027
6121
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
6028
6122
  this.hdr = hdr;
6029
6123
  this.zLayers = zLayers;
6030
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
6031
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
6032
- this._lifeTime = 0;
6124
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
6125
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
6126
+ this.#lifeTime = 0;
6033
6127
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
6034
- this._smooth = smooth;
6128
+ this.#smooth = smooth;
6035
6129
  for (const plugin of this.plugins) {
6036
6130
  await plugin.init?.();
6037
6131
  }
@@ -6044,7 +6138,7 @@
6044
6138
  this.dispatchEvent(EventType.particlesSetup);
6045
6139
  }
6046
6140
  async initDrawersAndUpdaters() {
6047
- const pluginManager = this._pluginManager;
6141
+ const pluginManager = this.#pluginManager;
6048
6142
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
6049
6143
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
6050
6144
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -6053,18 +6147,18 @@
6053
6147
  if (!guardCheck(this)) {
6054
6148
  return;
6055
6149
  }
6056
- if (this._drawAnimationFrame !== undefined) {
6057
- cancelAnimation(this._drawAnimationFrame);
6058
- delete this._drawAnimationFrame;
6150
+ if (this.#drawAnimationFrame !== undefined) {
6151
+ cancelAnimation(this.#drawAnimationFrame);
6152
+ this.#drawAnimationFrame = undefined;
6059
6153
  }
6060
- if (this._paused) {
6154
+ if (this.#paused) {
6061
6155
  return;
6062
6156
  }
6063
6157
  for (const plugin of this.plugins) {
6064
6158
  plugin.pause?.();
6065
6159
  }
6066
6160
  if (!this.pageHidden) {
6067
- this._paused = true;
6161
+ this.#paused = true;
6068
6162
  }
6069
6163
  this.dispatchEvent(EventType.containerPaused);
6070
6164
  }
@@ -6072,13 +6166,13 @@
6072
6166
  if (!guardCheck(this)) {
6073
6167
  return;
6074
6168
  }
6075
- const needsUpdate = this._paused || force;
6076
- if (this._firstStart && !this.actualOptions.autoPlay) {
6077
- this._firstStart = false;
6169
+ const needsUpdate = this.#paused || force;
6170
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
6171
+ this.#firstStart = false;
6078
6172
  return;
6079
6173
  }
6080
- if (this._paused) {
6081
- this._paused = false;
6174
+ if (this.#paused) {
6175
+ this.#paused = false;
6082
6176
  }
6083
6177
  if (needsUpdate) {
6084
6178
  for (const plugin of this.plugins) {
@@ -6101,10 +6195,10 @@
6101
6195
  if (!guardCheck(this)) {
6102
6196
  return;
6103
6197
  }
6104
- this._initialSourceOptions = sourceOptions;
6105
- this._sourceOptions = sourceOptions;
6106
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
6107
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
6198
+ this.#initialSourceOptions = sourceOptions;
6199
+ this.#sourceOptions = sourceOptions;
6200
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
6201
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
6108
6202
  return this.refresh();
6109
6203
  }
6110
6204
  async start() {
@@ -6115,7 +6209,7 @@
6115
6209
  this.started = true;
6116
6210
  await new Promise(resolve => {
6117
6211
  const start = async () => {
6118
- this._eventListeners.addListeners();
6212
+ this.#eventListeners.addListeners();
6119
6213
  for (const plugin of this.plugins) {
6120
6214
  await plugin.start?.();
6121
6215
  }
@@ -6123,20 +6217,20 @@
6123
6217
  this.play();
6124
6218
  resolve();
6125
6219
  };
6126
- this._delayTimeout = setTimeout(() => void start(), this._delay);
6220
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
6127
6221
  });
6128
6222
  }
6129
6223
  stop() {
6130
6224
  if (!guardCheck(this) || !this.started) {
6131
6225
  return;
6132
6226
  }
6133
- if (this._delayTimeout) {
6134
- clearTimeout(this._delayTimeout);
6135
- delete this._delayTimeout;
6227
+ if (this.#delayTimeout) {
6228
+ clearTimeout(this.#delayTimeout);
6229
+ this.#delayTimeout = undefined;
6136
6230
  }
6137
- this._firstStart = true;
6231
+ this.#firstStart = true;
6138
6232
  this.started = false;
6139
- this._eventListeners.removeListeners();
6233
+ this.#eventListeners.removeListeners();
6140
6234
  this.pause();
6141
6235
  this.particles.clear();
6142
6236
  this.canvas.stop();
@@ -6146,7 +6240,7 @@
6146
6240
  this.particleCreatedPlugins.length = 0;
6147
6241
  this.particleDestroyedPlugins.length = 0;
6148
6242
  this.particlePositionPlugins.length = 0;
6149
- this._sourceOptions = this._options;
6243
+ this.#sourceOptions = this.#options;
6150
6244
  this.dispatchEvent(EventType.containerStopped);
6151
6245
  }
6152
6246
  updateActualOptions() {
@@ -6158,23 +6252,23 @@
6158
6252
  }
6159
6253
  return refresh;
6160
6254
  }
6161
- _nextFrame = (timestamp) => {
6255
+ #nextFrame = (timestamp) => {
6162
6256
  try {
6163
- if (!this._smooth &&
6164
- this._lastFrameTime !== undefined &&
6165
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
6257
+ if (!this.#smooth &&
6258
+ this.#lastFrameTime !== undefined &&
6259
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
6166
6260
  this.draw(false);
6167
6261
  return;
6168
6262
  }
6169
- this._lastFrameTime ??= timestamp;
6170
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
6171
- this.addLifeTime(this._delta.value);
6172
- this._lastFrameTime = timestamp;
6173
- if (this._delta.value > millisecondsToSeconds) {
6263
+ this.#lastFrameTime ??= timestamp;
6264
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
6265
+ this.addLifeTime(this.#delta.value);
6266
+ this.#lastFrameTime = timestamp;
6267
+ if (this.#delta.value > millisecondsToSeconds) {
6174
6268
  this.draw(false);
6175
6269
  return;
6176
6270
  }
6177
- this.canvas.render.drawParticles(this._delta);
6271
+ this.canvas.render.drawParticles(this.#delta);
6178
6272
  if (!this.alive()) {
6179
6273
  this.destroy();
6180
6274
  return;
@@ -6195,10 +6289,10 @@
6195
6289
  });
6196
6290
 
6197
6291
  class BlendPluginInstance {
6198
- _container;
6199
- _defaultCompositeValue;
6292
+ #container;
6293
+ #defaultCompositeValue;
6200
6294
  constructor(container) {
6201
- this._container = container;
6295
+ this.#container = container;
6202
6296
  }
6203
6297
  drawParticleCleanup(context, particle) {
6204
6298
  if (!particle.options.blend?.enable) {
@@ -6215,14 +6309,14 @@
6215
6309
  context.globalCompositeOperation = particle.options.blend.mode;
6216
6310
  }
6217
6311
  drawSettingsCleanup(context) {
6218
- if (!this._defaultCompositeValue) {
6312
+ if (!this.#defaultCompositeValue) {
6219
6313
  return;
6220
6314
  }
6221
- context.globalCompositeOperation = this._defaultCompositeValue;
6315
+ context.globalCompositeOperation = this.#defaultCompositeValue;
6222
6316
  }
6223
6317
  drawSettingsSetup(context) {
6224
- const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
6225
- this._defaultCompositeValue = previousComposite;
6318
+ const previousComposite = context.globalCompositeOperation, blend = this.#container.actualOptions.blend;
6319
+ this.#defaultCompositeValue = previousComposite;
6226
6320
  context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
6227
6321
  }
6228
6322
  }
@@ -6365,11 +6459,11 @@
6365
6459
  class MovePluginInstance {
6366
6460
  availablePathGenerators;
6367
6461
  pathGenerators;
6368
- _container;
6369
- _pluginManager;
6462
+ #container;
6463
+ #pluginManager;
6370
6464
  constructor(pluginManager, container) {
6371
- this._pluginManager = pluginManager;
6372
- this._container = container;
6465
+ this.#pluginManager = pluginManager;
6466
+ this.#container = container;
6373
6467
  this.availablePathGenerators = new Map();
6374
6468
  this.pathGenerators = new Map();
6375
6469
  }
@@ -6400,7 +6494,7 @@
6400
6494
  acceleration: getRangeValue(gravityOptions.acceleration),
6401
6495
  inverse: gravityOptions.inverse,
6402
6496
  };
6403
- initSpin(this._container, particle);
6497
+ initSpin(this.#container, particle);
6404
6498
  }
6405
6499
  particleDestroyed(particle) {
6406
6500
  const pathGenerator = particle.pathGenerator;
@@ -6411,7 +6505,7 @@
6411
6505
  if (!moveOptions.enable) {
6412
6506
  return;
6413
6507
  }
6414
- 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;
6508
+ 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;
6415
6509
  if (moveOptions.spin.enable) {
6416
6510
  spin(container, particle, moveSpeed, reduceFactor);
6417
6511
  }
@@ -6421,18 +6515,18 @@
6421
6515
  applyDistance(particle);
6422
6516
  }
6423
6517
  preInit() {
6424
- return this._init();
6518
+ return this.#init();
6425
6519
  }
6426
6520
  redrawInit() {
6427
- return this._init();
6521
+ return this.#init();
6428
6522
  }
6429
6523
  update() {
6430
6524
  for (const pathGenerator of this.pathGenerators.values()) {
6431
6525
  pathGenerator.update();
6432
6526
  }
6433
6527
  }
6434
- async _init() {
6435
- const availablePathGenerators = await this._pluginManager.getPathGenerators?.(this._container, true);
6528
+ async #init() {
6529
+ const availablePathGenerators = await this.#pluginManager.getPathGenerators?.(this.#container, true);
6436
6530
  if (!availablePathGenerators) {
6437
6531
  return;
6438
6532
  }
@@ -6449,27 +6543,28 @@
6449
6543
  MovePluginInstance: MovePluginInstance
6450
6544
  });
6451
6545
 
6546
+ const defaultSize = 1;
6452
6547
  class PoissonDiscPluginInstance {
6453
6548
  poissonDisc;
6454
6549
  redrawTimeout;
6455
- _container;
6456
- _currentIndex;
6550
+ #container;
6551
+ #currentIndex;
6457
6552
  constructor(container) {
6458
- this._container = container;
6459
- this._currentIndex = 0;
6553
+ this.#container = container;
6554
+ this.#currentIndex = 0;
6460
6555
  }
6461
6556
  async init() {
6462
- await this._initData();
6557
+ await this.#initData();
6463
6558
  }
6464
6559
  particlePosition(position) {
6465
- const container = this._container, options = container.actualOptions.poisson;
6466
- if (!this.poissonDisc || !(options?.enable ?? false) || this._currentIndex >= this.poissonDisc.points.length) {
6560
+ const container = this.#container, options = container.actualOptions.poisson;
6561
+ if (!this.poissonDisc || !(options?.enable ?? false) || this.#currentIndex >= this.poissonDisc.points.length) {
6467
6562
  return;
6468
6563
  }
6469
- return position ?? this.poissonDisc.points[this._currentIndex++]?.position;
6564
+ return position ?? this.poissonDisc.points[this.#currentIndex++]?.position;
6470
6565
  }
6471
6566
  resize() {
6472
- const container = this._container, options = container.actualOptions.poisson;
6567
+ const container = this.#container, options = container.actualOptions.poisson;
6473
6568
  if (!(options?.enable ?? false)) {
6474
6569
  return;
6475
6570
  }
@@ -6479,10 +6574,10 @@
6479
6574
  const timeout = 250;
6480
6575
  this.redrawTimeout = setTimeout(() => {
6481
6576
  void (async () => {
6482
- if (this._container.destroyed) {
6577
+ if (this.#container.destroyed) {
6483
6578
  return;
6484
6579
  }
6485
- await this._initData();
6580
+ await this.#initData();
6486
6581
  await container.particles.redraw();
6487
6582
  })();
6488
6583
  }, timeout);
@@ -6490,16 +6585,16 @@
6490
6585
  stop() {
6491
6586
  delete this.poissonDisc;
6492
6587
  }
6493
- async _initData() {
6494
- const container = this._container, poissonOptions = container.actualOptions.poisson, particlesOptions = container.actualOptions.particles, canvasSize = container.canvas.size, pixelRatio = container.retina.pixelRatio;
6588
+ async #initData() {
6589
+ const container = this.#container, poissonOptions = container.actualOptions.poisson, particlesOptions = container.actualOptions.particles, canvasSize = container.canvas.size, pixelRatio = container.retina.pixelRatio;
6495
6590
  if (!poissonOptions?.enable) {
6496
6591
  return;
6497
6592
  }
6498
- this._currentIndex = 0;
6593
+ this.#currentIndex = 0;
6499
6594
  const { PoissonDisc } = await Promise.resolve().then(function () { return PoissonDisc$1; });
6500
6595
  this.poissonDisc = new PoissonDisc(canvasSize, poissonOptions.radius
6501
6596
  ? poissonOptions.radius * pixelRatio
6502
- : Math.max(getRangeMax(particlesOptions.size.value) * pixelRatio, Math.sqrt((canvasSize.width * canvasSize.height) / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);
6597
+ : Math.max(getRangeMax(particlesOptions["size.value"] ?? defaultSize) * pixelRatio, Math.sqrt((canvasSize.width * canvasSize.height) / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);
6503
6598
  const noSteps = 0;
6504
6599
  if (poissonOptions.steps > noSteps) {
6505
6600
  this.poissonDisc.steps(poissonOptions.steps);
@@ -6517,15 +6612,15 @@
6517
6612
 
6518
6613
  const minimumLength = 0;
6519
6614
  class TrailPluginInstance {
6520
- _container;
6521
- _pluginManager;
6522
- _trailFill;
6615
+ #container;
6616
+ #pluginManager;
6617
+ #trailFill;
6523
6618
  constructor(pluginManager, container) {
6524
- this._container = container;
6525
- this._pluginManager = pluginManager;
6619
+ this.#container = container;
6620
+ this.#pluginManager = pluginManager;
6526
6621
  }
6527
6622
  canvasClear() {
6528
- const container = this._container, trail = container.actualOptions.trail, trailFill = this._trailFill;
6623
+ const container = this.#container, trail = container.actualOptions.trail, trailFill = this.#trailFill;
6529
6624
  if (!trail?.enable || !trailFill || trail.length <= minimumLength) {
6530
6625
  return false;
6531
6626
  }
@@ -6543,24 +6638,24 @@
6543
6638
  }
6544
6639
  async init() {
6545
6640
  try {
6546
- await this._initTrail();
6641
+ await this.#initTrail();
6547
6642
  }
6548
6643
  catch (e) {
6549
6644
  getLogger().error(e);
6550
6645
  }
6551
6646
  }
6552
- _initTrail = async () => {
6553
- const options = this._container.actualOptions, trail = options.trail;
6647
+ #initTrail = async () => {
6648
+ const options = this.#container.actualOptions, trail = options.trail;
6554
6649
  if (!trail?.enable) {
6555
6650
  return;
6556
6651
  }
6557
6652
  const trailFill = trail.fill, opacity = inverseFactorNumerator / trail.length;
6558
6653
  if (trailFill.color) {
6559
- const fillColor = rangeColorToRgb(this._pluginManager, trailFill.color);
6654
+ const fillColor = rangeColorToRgb(this.#pluginManager, trailFill.color);
6560
6655
  if (!fillColor) {
6561
6656
  return;
6562
6657
  }
6563
- this._trailFill = {
6658
+ this.#trailFill = {
6564
6659
  color: {
6565
6660
  ...fillColor,
6566
6661
  },
@@ -6574,7 +6669,7 @@
6574
6669
  }
6575
6670
  const img = safeDocument().createElement("img");
6576
6671
  img.addEventListener("load", () => {
6577
- this._trailFill = {
6672
+ this.#trailFill = {
6578
6673
  image: img,
6579
6674
  opacity,
6580
6675
  };
@@ -6684,10 +6779,10 @@
6684
6779
  if (this.active.length <= minCount) {
6685
6780
  continue;
6686
6781
  }
6687
- this._step();
6782
+ this.#step();
6688
6783
  }
6689
6784
  }
6690
- _getNewPoint(currentPoint, tries) {
6785
+ #getNewPoint(currentPoint, tries) {
6691
6786
  const minCoordinate = 0, gridMinValue = 0, maxNeighbourIndex = 1, newAngle = tries * (doublePI / this.retries), newDist = this.getRandom(this.radius, this.radius * double), offset = {
6692
6787
  x: Math.cos(newAngle) * newDist,
6693
6788
  y: Math.sin(newAngle) * newDist,
@@ -6745,7 +6840,7 @@
6745
6840
  }
6746
6841
  return newPoint;
6747
6842
  }
6748
- _step() {
6843
+ #step() {
6749
6844
  const minCount = 0, randomActive = this.getRandom(minCount, this.active.length);
6750
6845
  let foundNewPoint = false;
6751
6846
  for (let tries = 0; tries < this.retries; tries++) {
@@ -6757,7 +6852,7 @@
6757
6852
  if (!point) {
6758
6853
  continue;
6759
6854
  }
6760
- const newPoint = this._getNewPoint(point, tries);
6855
+ const newPoint = this.#getNewPoint(point, tries);
6761
6856
  if (newPoint) {
6762
6857
  foundNewPoint = true;
6763
6858
  this.addPoint(newPoint);