@tsparticles/preset-hyperspace 4.0.4 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* Preset v4.0.4 */
2
+ /* Preset v4.1.0 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5
5
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -51,13 +51,13 @@
51
51
  return Math.atan2(this.y, this.x);
52
52
  }
53
53
  set angle(angle) {
54
- this._updateFromAngle(angle, this.length);
54
+ this.#updateFromAngle(angle, this.length);
55
55
  }
56
56
  get length() {
57
57
  return Math.sqrt(this.getLengthSq());
58
58
  }
59
59
  set length(length) {
60
- this._updateFromAngle(this.angle, length);
60
+ this.#updateFromAngle(this.angle, length);
61
61
  }
62
62
  static clone(source) {
63
63
  return Vector3d.create(source.x, source.y, getZ(source));
@@ -120,7 +120,7 @@
120
120
  this.y -= v.y;
121
121
  this.z -= getZ(v);
122
122
  }
123
- _updateFromAngle(angle, length) {
123
+ #updateFromAngle(angle, length) {
124
124
  this.x = Math.cos(angle) * length;
125
125
  this.y = Math.sin(angle) * length;
126
126
  }
@@ -721,38 +721,38 @@
721
721
  }
722
722
 
723
723
  class EventDispatcher {
724
- _listeners;
724
+ #listeners;
725
725
  constructor() {
726
- this._listeners = new Map();
726
+ this.#listeners = new Map();
727
727
  }
728
728
  addEventListener(type, listener) {
729
729
  this.removeEventListener(type, listener);
730
- let arr = this._listeners.get(type);
730
+ let arr = this.#listeners.get(type);
731
731
  if (!arr) {
732
732
  arr = [];
733
- this._listeners.set(type, arr);
733
+ this.#listeners.set(type, arr);
734
734
  }
735
735
  arr.push(listener);
736
736
  }
737
737
  dispatchEvent(type, args) {
738
- const listeners = this._listeners.get(type);
738
+ const listeners = this.#listeners.get(type);
739
739
  listeners?.forEach(handler => {
740
740
  handler(args);
741
741
  });
742
742
  }
743
743
  hasEventListener(type) {
744
- return !!this._listeners.get(type);
744
+ return !!this.#listeners.get(type);
745
745
  }
746
746
  removeAllEventListeners(type) {
747
747
  if (!type) {
748
- this._listeners = new Map();
748
+ this.#listeners = new Map();
749
749
  }
750
750
  else {
751
- this._listeners.delete(type);
751
+ this.#listeners.delete(type);
752
752
  }
753
753
  }
754
754
  removeEventListener(type, listener) {
755
- const arr = this._listeners.get(type);
755
+ const arr = this.#listeners.get(type);
756
756
  if (!arr) {
757
757
  return;
758
758
  }
@@ -761,7 +761,7 @@
761
761
  return;
762
762
  }
763
763
  if (length === deleteCount) {
764
- this._listeners.delete(type);
764
+ this.#listeners.delete(type);
765
765
  }
766
766
  else {
767
767
  arr.splice(idx, deleteCount);
@@ -799,19 +799,19 @@
799
799
  presets = new Map();
800
800
  shapeDrawers = new Map();
801
801
  updaters = new Map();
802
- _allLoadersSet = new Set();
803
- _configs = new Map();
804
- _engine;
805
- _executedSet = new Set();
806
- _initialized = false;
807
- _isRunningLoaders = false;
808
- _loadPromises = new Set();
802
+ #allLoadersSet = new Set();
803
+ #configs = new Map();
804
+ #engine;
805
+ #executedSet = new Set();
806
+ #initialized = false;
807
+ #isRunningLoaders = false;
808
+ #loadPromises = new Set();
809
809
  constructor(engine) {
810
- this._engine = engine;
810
+ this.#engine = engine;
811
811
  }
812
812
  get configs() {
813
813
  const res = {};
814
- for (const [name, config] of this._configs) {
814
+ for (const [name, config] of this.#configs) {
815
815
  res[name] = config;
816
816
  }
817
817
  return res;
@@ -821,8 +821,8 @@
821
821
  }
822
822
  addConfig(config) {
823
823
  const key = config.key ?? config.name ?? "default";
824
- this._configs.set(key, config);
825
- this._engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
824
+ this.#configs.set(key, config);
825
+ this.#engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
826
826
  }
827
827
  addEasing(name, easing) {
828
828
  if (this.easingFunctions.get(name)) {
@@ -883,21 +883,21 @@
883
883
  return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
884
884
  }
885
885
  async init() {
886
- if (this._initialized || this._isRunningLoaders) {
886
+ if (this.#initialized || this.#isRunningLoaders) {
887
887
  return;
888
888
  }
889
- this._isRunningLoaders = true;
890
- this._executedSet = new Set();
891
- this._allLoadersSet = new Set(this._loadPromises);
889
+ this.#isRunningLoaders = true;
890
+ this.#executedSet = new Set();
891
+ this.#allLoadersSet = new Set(this.#loadPromises);
892
892
  try {
893
- for (const loader of this._allLoadersSet) {
894
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
893
+ for (const loader of this.#allLoadersSet) {
894
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
895
895
  }
896
896
  }
897
897
  finally {
898
- this._loadPromises.clear();
899
- this._isRunningLoaders = false;
900
- this._initialized = true;
898
+ this.#loadPromises.clear();
899
+ this.#isRunningLoaders = false;
900
+ this.#initialized = true;
901
901
  }
902
902
  }
903
903
  loadParticlesOptions(container, options, ...sourceOptions) {
@@ -908,24 +908,24 @@
908
908
  updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
909
909
  }
910
910
  async register(...loaders) {
911
- if (this._initialized) {
911
+ if (this.#initialized) {
912
912
  throw new Error("Register plugins can only be done before calling tsParticles.load()");
913
913
  }
914
914
  for (const loader of loaders) {
915
- if (this._isRunningLoaders) {
916
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
915
+ if (this.#isRunningLoaders) {
916
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
917
917
  }
918
918
  else {
919
- this._loadPromises.add(loader);
919
+ this.#loadPromises.add(loader);
920
920
  }
921
921
  }
922
922
  }
923
- async _runLoader(loader, executed, allLoaders) {
923
+ async #runLoader(loader, executed, allLoaders) {
924
924
  if (executed.has(loader))
925
925
  return;
926
926
  executed.add(loader);
927
927
  allLoaders.add(loader);
928
- await loader(this._engine);
928
+ await loader(this.#engine);
929
929
  }
930
930
  }
931
931
 
@@ -1005,17 +1005,17 @@
1005
1005
  };
1006
1006
  class Engine {
1007
1007
  pluginManager = new PluginManager(this);
1008
- _domArray = [];
1009
- _eventDispatcher = new EventDispatcher();
1010
- _initialized = false;
1008
+ #domArray = [];
1009
+ #eventDispatcher = new EventDispatcher();
1010
+ #initialized = false;
1011
1011
  get items() {
1012
- return this._domArray;
1012
+ return this.#domArray;
1013
1013
  }
1014
1014
  get version() {
1015
- return "4.0.4";
1015
+ return "4.1.0";
1016
1016
  }
1017
1017
  addEventListener(type, listener) {
1018
- this._eventDispatcher.addEventListener(type, listener);
1018
+ this.#eventDispatcher.addEventListener(type, listener);
1019
1019
  }
1020
1020
  checkVersion(pluginVersion) {
1021
1021
  if (this.version === pluginVersion) {
@@ -1024,17 +1024,17 @@
1024
1024
  throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
1025
1025
  }
1026
1026
  dispatchEvent(type, args) {
1027
- this._eventDispatcher.dispatchEvent(type, args);
1027
+ this.#eventDispatcher.dispatchEvent(type, args);
1028
1028
  }
1029
1029
  async init() {
1030
- if (this._initialized) {
1030
+ if (this.#initialized) {
1031
1031
  return;
1032
1032
  }
1033
1033
  await this.pluginManager.init();
1034
- this._initialized = true;
1034
+ this.#initialized = true;
1035
1035
  }
1036
1036
  item(index) {
1037
- const { items } = this, item = items[index];
1037
+ const items = this.items, item = items[index];
1038
1038
  if (item?.destroyed) {
1039
1039
  items.splice(index, removeDeleteCount);
1040
1040
  return;
@@ -1088,7 +1088,7 @@
1088
1088
  await Promise.all(this.items.map(t => t.refresh()));
1089
1089
  }
1090
1090
  removeEventListener(type, listener) {
1091
- this._eventDispatcher.removeEventListener(type, listener);
1091
+ this.#eventDispatcher.removeEventListener(type, listener);
1092
1092
  }
1093
1093
  }
1094
1094
 
@@ -1859,43 +1859,6 @@
1859
1859
  }
1860
1860
  }
1861
1861
 
1862
- class OpacityAnimation extends RangedAnimationOptions {
1863
- destroy;
1864
- constructor() {
1865
- super();
1866
- this.destroy = DestroyType.none;
1867
- this.speed = 2;
1868
- }
1869
- load(data) {
1870
- super.load(data);
1871
- if (isNull(data)) {
1872
- return;
1873
- }
1874
- if (data.destroy !== undefined) {
1875
- this.destroy = data.destroy;
1876
- }
1877
- }
1878
- }
1879
-
1880
- class Opacity extends RangedAnimationValueWithRandom {
1881
- animation;
1882
- constructor() {
1883
- super();
1884
- this.animation = new OpacityAnimation();
1885
- this.value = 1;
1886
- }
1887
- load(data) {
1888
- if (isNull(data)) {
1889
- return;
1890
- }
1891
- super.load(data);
1892
- const animation = data.animation;
1893
- if (animation !== undefined) {
1894
- this.animation.load(animation);
1895
- }
1896
- }
1897
- }
1898
-
1899
1862
  class Stroke {
1900
1863
  color;
1901
1864
  opacity;
@@ -2063,43 +2026,6 @@
2063
2026
  }
2064
2027
  }
2065
2028
 
2066
- class SizeAnimation extends RangedAnimationOptions {
2067
- destroy;
2068
- constructor() {
2069
- super();
2070
- this.destroy = DestroyType.none;
2071
- this.speed = 5;
2072
- }
2073
- load(data) {
2074
- super.load(data);
2075
- if (isNull(data)) {
2076
- return;
2077
- }
2078
- if (data.destroy !== undefined) {
2079
- this.destroy = data.destroy;
2080
- }
2081
- }
2082
- }
2083
-
2084
- class Size extends RangedAnimationValueWithRandom {
2085
- animation;
2086
- constructor() {
2087
- super();
2088
- this.animation = new SizeAnimation();
2089
- this.value = 3;
2090
- }
2091
- load(data) {
2092
- super.load(data);
2093
- if (isNull(data)) {
2094
- return;
2095
- }
2096
- const animation = data.animation;
2097
- if (animation !== undefined) {
2098
- this.animation.load(animation);
2099
- }
2100
- }
2101
- }
2102
-
2103
2029
  class ZIndex extends ValueWithRandom {
2104
2030
  opacityRate;
2105
2031
  sizeRate;
@@ -2133,24 +2059,21 @@
2133
2059
  groups;
2134
2060
  move;
2135
2061
  number;
2136
- opacity;
2137
2062
  paint;
2138
2063
  palette;
2139
2064
  reduceDuplicates;
2140
2065
  shape;
2141
- size;
2142
2066
  zIndex;
2143
- _container;
2144
- _pluginManager;
2067
+ #container;
2068
+ #pluginManager;
2145
2069
  constructor(pluginManager, container) {
2146
- this._pluginManager = pluginManager;
2147
- this._container = container;
2070
+ this.#pluginManager = pluginManager;
2071
+ this.#container = container;
2148
2072
  this.bounce = new ParticlesBounce();
2149
2073
  this.effect = new Effect();
2150
2074
  this.groups = {};
2151
2075
  this.move = new Move();
2152
2076
  this.number = new ParticlesNumber();
2153
- this.opacity = new Opacity();
2154
2077
  this.paint = new Paint();
2155
2078
  this.paint.color = new AnimatableColor();
2156
2079
  this.paint.color.value = "#fff";
@@ -2158,7 +2081,6 @@
2158
2081
  this.paint.fill.enable = true;
2159
2082
  this.reduceDuplicates = false;
2160
2083
  this.shape = new Shape();
2161
- this.size = new Size();
2162
2084
  this.zIndex = new ZIndex();
2163
2085
  }
2164
2086
  load(data) {
@@ -2167,7 +2089,7 @@
2167
2089
  }
2168
2090
  if (data.palette) {
2169
2091
  this.palette = data.palette;
2170
- this._importPalette(this.palette);
2092
+ this.#importPalette(this.palette);
2171
2093
  }
2172
2094
  if (data.groups !== undefined) {
2173
2095
  for (const group of Object.keys(data.groups)) {
@@ -2187,7 +2109,6 @@
2187
2109
  this.effect.load(data.effect);
2188
2110
  this.move.load(data.move);
2189
2111
  this.number.load(data.number);
2190
- this.opacity.load(data.opacity);
2191
2112
  const paintToLoad = data.paint;
2192
2113
  if (paintToLoad) {
2193
2114
  if (isArray(paintToLoad)) {
@@ -2206,15 +2127,14 @@
2206
2127
  }
2207
2128
  }
2208
2129
  this.shape.load(data.shape);
2209
- this.size.load(data.size);
2210
2130
  this.zIndex.load(data.zIndex);
2211
- if (this._container) {
2212
- for (const plugin of this._pluginManager.plugins) {
2131
+ if (this.#container) {
2132
+ for (const plugin of this.#pluginManager.plugins) {
2213
2133
  if (plugin.loadParticlesOptions) {
2214
- plugin.loadParticlesOptions(this._container, this, data);
2134
+ plugin.loadParticlesOptions(this.#container, this, data);
2215
2135
  }
2216
2136
  }
2217
- const updaters = this._pluginManager.updaters.get(this._container);
2137
+ const updaters = this.#pluginManager.updaters.get(this.#container);
2218
2138
  if (updaters) {
2219
2139
  for (const updater of updaters) {
2220
2140
  if (updater.loadOptions) {
@@ -2224,8 +2144,8 @@
2224
2144
  }
2225
2145
  }
2226
2146
  }
2227
- _importPalette = (palette) => {
2228
- const paletteData = this._pluginManager.getPalette(palette);
2147
+ #importPalette = (palette) => {
2148
+ const paletteData = this.#pluginManager.getPalette(palette);
2229
2149
  if (!paletteData) {
2230
2150
  return;
2231
2151
  }
@@ -2304,11 +2224,11 @@
2304
2224
  smooth;
2305
2225
  style;
2306
2226
  zLayers;
2307
- _container;
2308
- _pluginManager;
2227
+ #container;
2228
+ #pluginManager;
2309
2229
  constructor(pluginManager, container) {
2310
- this._pluginManager = pluginManager;
2311
- this._container = container;
2230
+ this.#pluginManager = pluginManager;
2231
+ this.#container = container;
2312
2232
  this.autoPlay = true;
2313
2233
  this.background = new Background();
2314
2234
  this.clear = true;
@@ -2319,7 +2239,7 @@
2319
2239
  this.duration = 0;
2320
2240
  this.fpsLimit = 120;
2321
2241
  this.hdr = true;
2322
- this.particles = loadParticlesOptions(this._pluginManager, this._container);
2242
+ this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2323
2243
  this.pauseOnBlur = true;
2324
2244
  this.pauseOnOutsideViewport = true;
2325
2245
  this.resize = new ResizeEvent();
@@ -2334,12 +2254,12 @@
2334
2254
  if (data.preset !== undefined) {
2335
2255
  this.preset = data.preset;
2336
2256
  executeOnSingleOrMultiple(this.preset, preset => {
2337
- this._importPreset(preset);
2257
+ this.#importPreset(preset);
2338
2258
  });
2339
2259
  }
2340
2260
  if (data.palette !== undefined) {
2341
2261
  this.palette = data.palette;
2342
- this._importPalette(this.palette);
2262
+ this.#importPalette(this.palette);
2343
2263
  }
2344
2264
  if (data.autoPlay !== undefined) {
2345
2265
  this.autoPlay = data.autoPlay;
@@ -2393,12 +2313,12 @@
2393
2313
  if (data.smooth !== undefined) {
2394
2314
  this.smooth = data.smooth;
2395
2315
  }
2396
- this._pluginManager.plugins.forEach(plugin => {
2397
- plugin.loadOptions(this._container, this, data);
2316
+ this.#pluginManager.plugins.forEach(plugin => {
2317
+ plugin.loadOptions(this.#container, this, data);
2398
2318
  });
2399
2319
  }
2400
- _importPalette = palette => {
2401
- const paletteData = this._pluginManager.getPalette(palette);
2320
+ #importPalette = palette => {
2321
+ const paletteData = this.#pluginManager.getPalette(palette);
2402
2322
  if (!paletteData) {
2403
2323
  return;
2404
2324
  }
@@ -2415,8 +2335,8 @@
2415
2335
  },
2416
2336
  });
2417
2337
  };
2418
- _importPreset = preset => {
2419
- this.load(this._pluginManager.getPreset(preset));
2338
+ #importPreset = preset => {
2339
+ this.load(this.#pluginManager.getPreset(preset));
2420
2340
  };
2421
2341
  }
2422
2342
 
@@ -2885,7 +2805,7 @@
2885
2805
  }
2886
2806
 
2887
2807
  async function loadBlendPlugin(engine) {
2888
- engine.checkVersion("4.0.4");
2808
+ engine.checkVersion("4.1.0");
2889
2809
  await engine.pluginManager.register(e => {
2890
2810
  e.pluginManager.addPlugin(new BlendPlugin());
2891
2811
  });
@@ -2922,7 +2842,7 @@
2922
2842
  }
2923
2843
 
2924
2844
  async function loadCircleShape(engine) {
2925
- engine.checkVersion("4.0.4");
2845
+ engine.checkVersion("4.1.0");
2926
2846
  await engine.pluginManager.register(e => {
2927
2847
  e.pluginManager.addShape(["circle"], () => {
2928
2848
  return Promise.resolve(new CircleDrawer());
@@ -2943,15 +2863,15 @@
2943
2863
  return input.startsWith("#");
2944
2864
  }
2945
2865
  handleColor(color) {
2946
- return this._parseString(color.value);
2866
+ return this.#parseString(color.value);
2947
2867
  }
2948
2868
  handleRangeColor(color) {
2949
- return this._parseString(color.value);
2869
+ return this.#parseString(color.value);
2950
2870
  }
2951
2871
  parseString(input) {
2952
- return this._parseString(input);
2872
+ return this.#parseString(input);
2953
2873
  }
2954
- _parseString(hexColor) {
2874
+ #parseString(hexColor) {
2955
2875
  if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
2956
2876
  return;
2957
2877
  }
@@ -2970,7 +2890,7 @@
2970
2890
  }
2971
2891
 
2972
2892
  async function loadHexColorPlugin(engine) {
2973
- engine.checkVersion("4.0.4");
2893
+ engine.checkVersion("4.1.0");
2974
2894
  await engine.pluginManager.register(e => {
2975
2895
  e.pluginManager.addColorManager("hex", new HexColorManager());
2976
2896
  });
@@ -3023,7 +2943,7 @@
3023
2943
  }
3024
2944
 
3025
2945
  async function loadHslColorPlugin(engine) {
3026
- engine.checkVersion("4.0.4");
2946
+ engine.checkVersion("4.1.0");
3027
2947
  await engine.pluginManager.register(e => {
3028
2948
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3029
2949
  });
@@ -3031,13 +2951,13 @@
3031
2951
 
3032
2952
  class MovePlugin {
3033
2953
  id = "move";
3034
- _pluginManager;
2954
+ #pluginManager;
3035
2955
  constructor(pluginManager) {
3036
- this._pluginManager = pluginManager;
2956
+ this.#pluginManager = pluginManager;
3037
2957
  }
3038
2958
  async getPlugin(container) {
3039
2959
  const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
3040
- return new MovePluginInstance(this._pluginManager, container);
2960
+ return new MovePluginInstance(this.#pluginManager, container);
3041
2961
  }
3042
2962
  loadOptions() {
3043
2963
  }
@@ -3047,7 +2967,7 @@
3047
2967
  }
3048
2968
 
3049
2969
  async function loadMovePlugin(engine) {
3050
- engine.checkVersion("4.0.4");
2970
+ engine.checkVersion("4.1.0");
3051
2971
  await engine.pluginManager.register(e => {
3052
2972
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3053
2973
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3065,18 +2985,58 @@
3065
2985
  });
3066
2986
  }
3067
2987
 
2988
+ class OpacityAnimation extends RangedAnimationOptions {
2989
+ destroy;
2990
+ constructor() {
2991
+ super();
2992
+ this.destroy = DestroyType.none;
2993
+ this.speed = 2;
2994
+ }
2995
+ load(data) {
2996
+ super.load(data);
2997
+ if (isNull(data)) {
2998
+ return;
2999
+ }
3000
+ if (data.destroy !== undefined) {
3001
+ this.destroy = data.destroy;
3002
+ }
3003
+ }
3004
+ }
3005
+
3006
+ class Opacity extends RangedAnimationValueWithRandom {
3007
+ animation;
3008
+ constructor() {
3009
+ super();
3010
+ this.animation = new OpacityAnimation();
3011
+ this.value = 1;
3012
+ }
3013
+ load(data) {
3014
+ if (isNull(data)) {
3015
+ return;
3016
+ }
3017
+ super.load(data);
3018
+ const animation = data.animation;
3019
+ if (animation !== undefined) {
3020
+ this.animation.load(animation);
3021
+ }
3022
+ }
3023
+ }
3024
+
3068
3025
  class OpacityUpdater {
3069
- container;
3026
+ #container;
3070
3027
  constructor(container) {
3071
- this.container = container;
3028
+ this.#container = container;
3072
3029
  }
3073
3030
  init(particle) {
3074
3031
  const opacityOptions = particle.options.opacity, pxRatio = 1;
3032
+ if (!opacityOptions) {
3033
+ return;
3034
+ }
3075
3035
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
3076
3036
  const opacityAnimation = opacityOptions.animation;
3077
3037
  if (opacityAnimation.enable) {
3078
3038
  particle.opacity.velocity =
3079
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
3039
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
3080
3040
  if (!opacityAnimation.sync) {
3081
3041
  particle.opacity.velocity *= getRandom();
3082
3042
  }
@@ -3092,6 +3052,12 @@
3092
3052
  ((particle.opacity.maxLoops ?? none) > none &&
3093
3053
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3094
3054
  }
3055
+ loadOptions(options, ...sources) {
3056
+ options.opacity ??= new Opacity();
3057
+ for (const source of sources) {
3058
+ options.opacity.load(source?.opacity);
3059
+ }
3060
+ }
3095
3061
  reset(particle) {
3096
3062
  if (!particle.opacity) {
3097
3063
  return;
@@ -3100,7 +3066,7 @@
3100
3066
  particle.opacity.loops = 0;
3101
3067
  }
3102
3068
  update(particle, delta) {
3103
- if (!this.isEnabled(particle) || !particle.opacity) {
3069
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
3104
3070
  return;
3105
3071
  }
3106
3072
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -3108,7 +3074,7 @@
3108
3074
  }
3109
3075
 
3110
3076
  async function loadOpacityUpdater(engine) {
3111
- engine.checkVersion("4.0.4");
3077
+ engine.checkVersion("4.1.0");
3112
3078
  await engine.pluginManager.register(e => {
3113
3079
  e.pluginManager.addParticleUpdater("opacity", container => {
3114
3080
  return Promise.resolve(new OpacityUpdater(container));
@@ -3130,10 +3096,9 @@
3130
3096
  }
3131
3097
  const velocity = data.particle.velocity.x;
3132
3098
  let bounced = false;
3133
- if ((data.direction === OutModeDirection.right &&
3134
- data.bounds.right >= data.canvasSize.width &&
3135
- velocity > minVelocity$4) ||
3136
- (data.direction === OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity$4)) {
3099
+ if (data.outOfCanvas &&
3100
+ ((data.direction === OutModeDirection.right && velocity > minVelocity$4) ||
3101
+ (data.direction === OutModeDirection.left && velocity < minVelocity$4))) {
3137
3102
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3138
3103
  data.particle.velocity.x *= -newVelocity;
3139
3104
  bounced = true;
@@ -3142,10 +3107,10 @@
3142
3107
  return;
3143
3108
  }
3144
3109
  const minPos = data.offset.x + data.size;
3145
- if (data.bounds.right >= data.canvasSize.width && data.direction === OutModeDirection.right) {
3110
+ if (data.outOfCanvas && data.direction === OutModeDirection.right) {
3146
3111
  data.particle.position.x = data.canvasSize.width - minPos;
3147
3112
  }
3148
- else if (data.bounds.left <= boundsMin && data.direction === OutModeDirection.left) {
3113
+ else if (data.outOfCanvas && data.direction === OutModeDirection.left) {
3149
3114
  data.particle.position.x = minPos;
3150
3115
  }
3151
3116
  if (data.outMode === OutMode.split) {
@@ -3165,10 +3130,9 @@
3165
3130
  }
3166
3131
  const velocity = data.particle.velocity.y;
3167
3132
  let bounced = false;
3168
- if ((data.direction === OutModeDirection.bottom &&
3169
- data.bounds.bottom >= data.canvasSize.height &&
3170
- velocity > minVelocity$4) ||
3171
- (data.direction === OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity$4)) {
3133
+ if (data.outOfCanvas &&
3134
+ ((data.direction === OutModeDirection.bottom && velocity > minVelocity$4) ||
3135
+ (data.direction === OutModeDirection.top && velocity < minVelocity$4))) {
3172
3136
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3173
3137
  data.particle.velocity.y *= -newVelocity;
3174
3138
  bounced = true;
@@ -3177,10 +3141,10 @@
3177
3141
  return;
3178
3142
  }
3179
3143
  const minPos = data.offset.y + data.size;
3180
- if (data.bounds.bottom >= data.canvasSize.height && data.direction === OutModeDirection.bottom) {
3144
+ if (data.outOfCanvas && data.direction === OutModeDirection.bottom) {
3181
3145
  data.particle.position.y = data.canvasSize.height - minPos;
3182
3146
  }
3183
- else if (data.bounds.top <= boundsMin && data.direction === OutModeDirection.top) {
3147
+ else if (data.outOfCanvas && data.direction === OutModeDirection.top) {
3184
3148
  data.particle.position.y = minPos;
3185
3149
  }
3186
3150
  if (data.outMode === OutMode.split) {
@@ -3189,24 +3153,24 @@
3189
3153
  }
3190
3154
 
3191
3155
  class BounceOutMode {
3192
- container;
3193
3156
  modes;
3194
- _particleBouncePlugins;
3157
+ #container;
3158
+ #particleBouncePlugins;
3195
3159
  constructor(container) {
3196
- this.container = container;
3160
+ this.#container = container;
3197
3161
  this.modes = [
3198
3162
  OutMode.bounce,
3199
3163
  OutMode.split,
3200
3164
  ];
3201
- this._particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3165
+ this.#particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3202
3166
  }
3203
3167
  update(particle, direction, delta, outMode) {
3204
3168
  if (!this.modes.includes(outMode)) {
3205
3169
  return;
3206
3170
  }
3207
- const container = this.container;
3171
+ const container = this.#container;
3208
3172
  let handled = false;
3209
- for (const plugin of this._particleBouncePlugins) {
3173
+ for (const plugin of this.#particleBouncePlugins) {
3210
3174
  handled = plugin.particleBounce?.(particle, delta, direction) ?? false;
3211
3175
  if (handled) {
3212
3176
  break;
@@ -3215,29 +3179,26 @@
3215
3179
  if (handled) {
3216
3180
  return;
3217
3181
  }
3218
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size;
3219
- bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
3220
- bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
3182
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, outOfCanvas = !particle.isInsideCanvasForOutMode(outMode, direction);
3183
+ bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3184
+ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3221
3185
  }
3222
3186
  }
3223
3187
 
3224
3188
  const minVelocity$3 = 0;
3225
3189
  class DestroyOutMode {
3226
- container;
3227
3190
  modes;
3228
- constructor(container) {
3229
- this.container = container;
3191
+ constructor(_container) {
3230
3192
  this.modes = [OutMode.destroy];
3231
3193
  }
3232
3194
  update(particle, direction, _delta, outMode) {
3233
3195
  if (!this.modes.includes(outMode)) {
3234
3196
  return;
3235
3197
  }
3236
- const container = this.container;
3237
3198
  switch (particle.outType) {
3238
3199
  case ParticleOutType.normal:
3239
3200
  case ParticleOutType.outside:
3240
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3201
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3241
3202
  return;
3242
3203
  }
3243
3204
  break;
@@ -3258,10 +3219,10 @@
3258
3219
 
3259
3220
  const minVelocity$2 = 0;
3260
3221
  class NoneOutMode {
3261
- container;
3262
3222
  modes;
3223
+ #container;
3263
3224
  constructor(container) {
3264
- this.container = container;
3225
+ this.#container = container;
3265
3226
  this.modes = [OutMode.none];
3266
3227
  }
3267
3228
  update(particle, direction, _delta, outMode) {
@@ -3274,7 +3235,7 @@
3274
3235
  (direction === OutModeDirection.top || direction === OutModeDirection.bottom))) {
3275
3236
  return;
3276
3237
  }
3277
- const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3238
+ const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3278
3239
  if (!gravityOptions.enable) {
3279
3240
  if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3280
3241
  (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
@@ -3300,17 +3261,17 @@
3300
3261
 
3301
3262
  const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
3302
3263
  class OutOutMode {
3303
- container;
3304
3264
  modes;
3265
+ #container;
3305
3266
  constructor(container) {
3306
- this.container = container;
3267
+ this.#container = container;
3307
3268
  this.modes = [OutMode.out];
3308
3269
  }
3309
3270
  update(particle, direction, _delta, outMode) {
3310
3271
  if (!this.modes.includes(outMode)) {
3311
3272
  return;
3312
3273
  }
3313
- const container = this.container;
3274
+ const container = this.#container;
3314
3275
  switch (particle.outType) {
3315
3276
  case ParticleOutType.inside: {
3316
3277
  const { x: vx, y: vy } = particle.velocity;
@@ -3340,7 +3301,7 @@
3340
3301
  break;
3341
3302
  }
3342
3303
  default: {
3343
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3304
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3344
3305
  return;
3345
3306
  }
3346
3307
  switch (particle.outType) {
@@ -3424,16 +3385,16 @@
3424
3385
  };
3425
3386
  class OutOfCanvasUpdater {
3426
3387
  updaters;
3427
- container;
3388
+ #container;
3428
3389
  constructor(container) {
3429
- this.container = container;
3390
+ this.#container = container;
3430
3391
  this.updaters = new Map();
3431
3392
  }
3432
3393
  init(particle) {
3433
- this._addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3434
- this._addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3435
- this._addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3436
- this._addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3394
+ this.#addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3395
+ this.#addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3396
+ this.#addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3397
+ this.#addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3437
3398
  }
3438
3399
  isEnabled(particle) {
3439
3400
  return !particle.destroyed && !particle.spawning;
@@ -3441,18 +3402,18 @@
3441
3402
  update(particle, delta) {
3442
3403
  const outModes = particle.options.move.outModes;
3443
3404
  particle.justWarped = false;
3444
- this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3445
- this._updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3446
- this._updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3447
- this._updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3405
+ this.#updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3406
+ this.#updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3407
+ this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3408
+ this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3448
3409
  }
3449
- _addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3410
+ #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3450
3411
  const outModes = particle.options.move.outModes;
3451
3412
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3452
- this.updaters.set(outMode, getUpdater(this.container));
3413
+ this.updaters.set(outMode, getUpdater(this.#container));
3453
3414
  }
3454
3415
  };
3455
- _updateOutMode = (particle, delta, outMode, direction) => {
3416
+ #updateOutMode = (particle, delta, outMode, direction) => {
3456
3417
  for (const updater of this.updaters.values()) {
3457
3418
  updater.update(particle, direction, delta, outMode);
3458
3419
  }
@@ -3460,7 +3421,7 @@
3460
3421
  }
3461
3422
 
3462
3423
  async function loadOutModesUpdater(engine) {
3463
- engine.checkVersion("4.0.4");
3424
+ engine.checkVersion("4.1.0");
3464
3425
  await engine.pluginManager.register(e => {
3465
3426
  e.pluginManager.addParticleUpdater("outModes", container => {
3466
3427
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3470,20 +3431,20 @@
3470
3431
 
3471
3432
  const defaultOpacity = 1;
3472
3433
  class PaintUpdater {
3473
- _container;
3474
- _pluginManager;
3434
+ #container;
3435
+ #pluginManager;
3475
3436
  constructor(pluginManager, container) {
3476
- this._container = container;
3477
- this._pluginManager = pluginManager;
3437
+ this.#container = container;
3438
+ this.#pluginManager = pluginManager;
3478
3439
  }
3479
3440
  init(particle) {
3480
- 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;
3441
+ 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;
3481
3442
  if (fill) {
3482
3443
  const fillColor = AnimatableColor.create(paintColor === undefined ? undefined : AnimatableColor.create(undefined, paintColor), fill.color);
3483
3444
  particle.fillEnabled = fill.enable;
3484
3445
  particle.fillOpacity = getRangeValue(fill.opacity);
3485
3446
  particle.fillAnimation = fillColor.animation;
3486
- const fillHslColor = rangeColorToHsl(this._pluginManager, fillColor);
3447
+ const fillHslColor = rangeColorToHsl(this.#pluginManager, fillColor);
3487
3448
  if (fillHslColor) {
3488
3449
  particle.fillColor = getHslAnimationFromHsl(fillHslColor, particle.fillAnimation, container.retina.reduceFactor);
3489
3450
  }
@@ -3499,7 +3460,7 @@
3499
3460
  particle.strokeWidth = getRangeValue(stroke.width) * container.retina.pixelRatio;
3500
3461
  particle.strokeOpacity = getRangeValue(stroke.opacity ?? defaultOpacity);
3501
3462
  particle.strokeAnimation = strokeColor.animation;
3502
- const strokeHslColor = rangeColorToHsl(this._pluginManager, strokeColor) ?? particle.getFillColor();
3463
+ const strokeHslColor = rangeColorToHsl(this.#pluginManager, strokeColor) ?? particle.getFillColor();
3503
3464
  if (strokeHslColor) {
3504
3465
  particle.strokeColor = getHslAnimationFromHsl(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
3505
3466
  }
@@ -3531,7 +3492,7 @@
3531
3492
  }
3532
3493
 
3533
3494
  async function loadPaintUpdater(engine) {
3534
- engine.checkVersion("4.0.4");
3495
+ engine.checkVersion("4.1.0");
3535
3496
  await engine.pluginManager.register(e => {
3536
3497
  e.pluginManager.addParticleUpdater("paint", container => {
3537
3498
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3586,27 +3547,69 @@
3586
3547
  }
3587
3548
 
3588
3549
  async function loadRgbColorPlugin(engine) {
3589
- engine.checkVersion("4.0.4");
3550
+ engine.checkVersion("4.1.0");
3590
3551
  await engine.pluginManager.register(e => {
3591
3552
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3592
3553
  });
3593
3554
  }
3594
3555
 
3556
+ class SizeAnimation extends RangedAnimationOptions {
3557
+ destroy;
3558
+ constructor() {
3559
+ super();
3560
+ this.destroy = DestroyType.none;
3561
+ this.speed = 5;
3562
+ }
3563
+ load(data) {
3564
+ super.load(data);
3565
+ if (isNull(data)) {
3566
+ return;
3567
+ }
3568
+ if (data.destroy !== undefined) {
3569
+ this.destroy = data.destroy;
3570
+ }
3571
+ }
3572
+ }
3573
+
3574
+ class Size extends RangedAnimationValueWithRandom {
3575
+ animation;
3576
+ constructor() {
3577
+ super();
3578
+ this.animation = new SizeAnimation();
3579
+ this.value = 3;
3580
+ }
3581
+ load(data) {
3582
+ super.load(data);
3583
+ if (isNull(data)) {
3584
+ return;
3585
+ }
3586
+ const animation = data.animation;
3587
+ if (animation !== undefined) {
3588
+ this.animation.load(animation);
3589
+ }
3590
+ }
3591
+ }
3592
+
3595
3593
  const minLoops = 0;
3596
3594
  class SizeUpdater {
3597
- _container;
3595
+ #container;
3598
3596
  constructor(container) {
3599
- this._container = container;
3597
+ this.#container = container;
3600
3598
  }
3601
3599
  init(particle) {
3602
- const container = this._container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
3603
- if (sizeAnimation.enable) {
3604
- particle.size.velocity =
3605
- (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3606
- if (!sizeAnimation.sync) {
3607
- particle.size.velocity *= getRandom();
3608
- }
3600
+ const container = this.#container, sizeOptions = particle.options.size;
3601
+ if (!sizeOptions) {
3602
+ return;
3603
+ }
3604
+ const sizeAnimation = sizeOptions.animation;
3605
+ if (!sizeAnimation.enable) {
3606
+ return;
3607
+ }
3608
+ particle.size.velocity = (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3609
+ if (sizeAnimation.sync) {
3610
+ return;
3609
3611
  }
3612
+ particle.size.velocity *= getRandom();
3610
3613
  }
3611
3614
  isEnabled(particle) {
3612
3615
  return (!particle.destroyed &&
@@ -3616,12 +3619,26 @@
3616
3619
  ((particle.size.maxLoops ?? minLoops) > minLoops &&
3617
3620
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3618
3621
  }
3622
+ loadOptions(options, ...sources) {
3623
+ options.size ??= new Size();
3624
+ for (const source of sources) {
3625
+ options.size.load(source?.size);
3626
+ }
3627
+ }
3628
+ preInit(particle) {
3629
+ const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
3630
+ if (!sizeOptions) {
3631
+ return;
3632
+ }
3633
+ particle.size = initParticleNumericAnimationValue(sizeOptions, pxRatio);
3634
+ particle.retina.sizeAnimationSpeed = getRangeValue(sizeOptions.animation.speed) * pxRatio;
3635
+ }
3619
3636
  reset(particle) {
3620
3637
  particle.size.time = 0;
3621
3638
  particle.size.loops = 0;
3622
3639
  }
3623
3640
  update(particle, delta) {
3624
- if (!this.isEnabled(particle)) {
3641
+ if (!this.isEnabled(particle) || !particle.options.size) {
3625
3642
  return;
3626
3643
  }
3627
3644
  updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
@@ -3629,7 +3646,7 @@
3629
3646
  }
3630
3647
 
3631
3648
  async function loadSizeUpdater(engine) {
3632
- engine.checkVersion("4.0.4");
3649
+ engine.checkVersion("4.1.0");
3633
3650
  await engine.pluginManager.register(e => {
3634
3651
  e.pluginManager.addParticleUpdater("size", container => {
3635
3652
  return Promise.resolve(new SizeUpdater(container));
@@ -3638,7 +3655,7 @@
3638
3655
  }
3639
3656
 
3640
3657
  async function loadBasic(engine) {
3641
- engine.checkVersion("4.0.4");
3658
+ engine.checkVersion("4.1.0");
3642
3659
  await engine.pluginManager.register(async (e) => {
3643
3660
  await Promise.all([
3644
3661
  loadBlendPlugin(e),
@@ -3864,13 +3881,13 @@
3864
3881
 
3865
3882
  class EmittersPlugin {
3866
3883
  id = "emitters";
3867
- _instancesManager;
3884
+ #instancesManager;
3868
3885
  constructor(instancesManager) {
3869
- this._instancesManager = instancesManager;
3886
+ this.#instancesManager = instancesManager;
3870
3887
  }
3871
3888
  async getPlugin(container) {
3872
3889
  const { EmittersPluginInstance } = await Promise.resolve().then(function () { return EmittersPluginInstance$1; });
3873
- return new EmittersPluginInstance(this._instancesManager, container);
3890
+ return new EmittersPluginInstance(this.#instancesManager, container);
3874
3891
  }
3875
3892
  loadOptions(_container, options, source) {
3876
3893
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
@@ -3940,7 +3957,7 @@
3940
3957
  })(EmitterClickMode || (EmitterClickMode = {}));
3941
3958
 
3942
3959
  async function loadEmittersPluginSimple(engine) {
3943
- engine.checkVersion("4.0.4");
3960
+ engine.checkVersion("4.1.0");
3944
3961
  await engine.pluginManager.register(async (e) => {
3945
3962
  const instancesManager = await getEmittersInstancesManager(e);
3946
3963
  await addEmittersShapesManager(e);
@@ -4028,7 +4045,7 @@
4028
4045
  }
4029
4046
 
4030
4047
  async function loadEmittersShapeSquare(engine) {
4031
- engine.checkVersion("4.0.4");
4048
+ engine.checkVersion("4.1.0");
4032
4049
  await engine.pluginManager.register((e) => {
4033
4050
  ensureEmittersPluginLoaded(e);
4034
4051
  e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
@@ -4145,12 +4162,12 @@
4145
4162
 
4146
4163
  const noTime = 0, identity$1 = 1, infiniteValue = -1;
4147
4164
  class LifeUpdater {
4148
- container;
4165
+ #container;
4149
4166
  constructor(container) {
4150
- this.container = container;
4167
+ this.#container = container;
4151
4168
  }
4152
4169
  init(particle) {
4153
- const container = this.container, particlesOptions = particle.options, lifeOptions = particlesOptions.life;
4170
+ const container = this.#container, particlesOptions = particle.options, lifeOptions = particlesOptions.life;
4154
4171
  if (!lifeOptions) {
4155
4172
  return;
4156
4173
  }
@@ -4189,12 +4206,12 @@
4189
4206
  if (!this.isEnabled(particle) || !particle.life) {
4190
4207
  return;
4191
4208
  }
4192
- updateLife(particle, delta, this.container.canvas.size);
4209
+ updateLife(particle, delta, this.#container.canvas.size);
4193
4210
  }
4194
4211
  }
4195
4212
 
4196
4213
  async function loadLifeUpdater(engine) {
4197
- engine.checkVersion("4.0.4");
4214
+ engine.checkVersion("4.1.0");
4198
4215
  await engine.pluginManager.register(e => {
4199
4216
  e.pluginManager.addParticleUpdater("life", container => {
4200
4217
  return Promise.resolve(new LifeUpdater(container));
@@ -4245,13 +4262,13 @@
4245
4262
 
4246
4263
  class TrailPlugin {
4247
4264
  id = "trail";
4248
- _pluginManager;
4265
+ #pluginManager;
4249
4266
  constructor(pluginManager) {
4250
- this._pluginManager = pluginManager;
4267
+ this.#pluginManager = pluginManager;
4251
4268
  }
4252
4269
  async getPlugin(container) {
4253
4270
  const { TrailPluginInstance } = await Promise.resolve().then(function () { return TrailPluginInstance$1; });
4254
- return new TrailPluginInstance(this._pluginManager, container);
4271
+ return new TrailPluginInstance(this.#pluginManager, container);
4255
4272
  }
4256
4273
  loadOptions(_container, options, source) {
4257
4274
  if (!this.needsPlugin()) {
@@ -4269,7 +4286,7 @@
4269
4286
  }
4270
4287
 
4271
4288
  async function loadTrailPlugin(engine) {
4272
- engine.checkVersion("4.0.4");
4289
+ engine.checkVersion("4.1.0");
4273
4290
  await engine.pluginManager.register(e => {
4274
4291
  e.pluginManager.addPlugin(new TrailPlugin(e.pluginManager));
4275
4292
  });
@@ -4366,58 +4383,58 @@
4366
4383
  }
4367
4384
  }
4368
4385
  class RenderManager {
4369
- _canvasClearPlugins;
4370
- _canvasManager;
4371
- _canvasPaintPlugins;
4372
- _clearDrawPlugins;
4373
- _colorPlugins;
4374
- _container;
4375
- _context;
4376
- _contextSettings;
4377
- _drawParticlePlugins;
4378
- _drawParticlesCleanupPlugins;
4379
- _drawParticlesSetupPlugins;
4380
- _drawPlugins;
4381
- _drawSettingsCleanupPlugins;
4382
- _drawSettingsSetupPlugins;
4383
- _pluginManager;
4384
- _postDrawUpdaters;
4385
- _preDrawUpdaters;
4386
- _reusableColorStyles = {};
4387
- _reusablePluginColors = [undefined, undefined];
4388
- _reusableTransform = {};
4386
+ #canvasClearPlugins;
4387
+ #canvasManager;
4388
+ #canvasPaintPlugins;
4389
+ #clearDrawPlugins;
4390
+ #colorPlugins;
4391
+ #container;
4392
+ #context;
4393
+ #contextSettings;
4394
+ #drawParticlePlugins;
4395
+ #drawParticlesCleanupPlugins;
4396
+ #drawParticlesSetupPlugins;
4397
+ #drawPlugins;
4398
+ #drawSettingsCleanupPlugins;
4399
+ #drawSettingsSetupPlugins;
4400
+ #pluginManager;
4401
+ #postDrawUpdaters;
4402
+ #preDrawUpdaters;
4403
+ #reusableColorStyles = {};
4404
+ #reusablePluginColors = [undefined, undefined];
4405
+ #reusableTransform = {};
4389
4406
  constructor(pluginManager, container, canvasManager) {
4390
- this._pluginManager = pluginManager;
4391
- this._container = container;
4392
- this._canvasManager = canvasManager;
4393
- this._context = null;
4394
- this._preDrawUpdaters = [];
4395
- this._postDrawUpdaters = [];
4396
- this._colorPlugins = [];
4397
- this._canvasClearPlugins = [];
4398
- this._canvasPaintPlugins = [];
4399
- this._clearDrawPlugins = [];
4400
- this._drawParticlePlugins = [];
4401
- this._drawParticlesCleanupPlugins = [];
4402
- this._drawParticlesSetupPlugins = [];
4403
- this._drawPlugins = [];
4404
- this._drawSettingsSetupPlugins = [];
4405
- this._drawSettingsCleanupPlugins = [];
4407
+ this.#pluginManager = pluginManager;
4408
+ this.#container = container;
4409
+ this.#canvasManager = canvasManager;
4410
+ this.#context = null;
4411
+ this.#preDrawUpdaters = [];
4412
+ this.#postDrawUpdaters = [];
4413
+ this.#colorPlugins = [];
4414
+ this.#canvasClearPlugins = [];
4415
+ this.#canvasPaintPlugins = [];
4416
+ this.#clearDrawPlugins = [];
4417
+ this.#drawParticlePlugins = [];
4418
+ this.#drawParticlesCleanupPlugins = [];
4419
+ this.#drawParticlesSetupPlugins = [];
4420
+ this.#drawPlugins = [];
4421
+ this.#drawSettingsSetupPlugins = [];
4422
+ this.#drawSettingsCleanupPlugins = [];
4406
4423
  }
4407
4424
  get settings() {
4408
- return this._contextSettings;
4425
+ return this.#contextSettings;
4409
4426
  }
4410
4427
  canvasClear() {
4411
- if (!this._container.actualOptions.clear) {
4428
+ if (!this.#container.actualOptions.clear) {
4412
4429
  return;
4413
4430
  }
4414
4431
  this.draw(ctx => {
4415
- clear(ctx, this._canvasManager.size);
4432
+ clear(ctx, this.#canvasManager.size);
4416
4433
  });
4417
4434
  }
4418
4435
  clear() {
4419
4436
  let pluginHandled = false;
4420
- for (const plugin of this._canvasClearPlugins) {
4437
+ for (const plugin of this.#canvasClearPlugins) {
4421
4438
  pluginHandled = plugin.canvasClear?.() ?? false;
4422
4439
  if (pluginHandled) {
4423
4440
  break;
@@ -4430,21 +4447,21 @@
4430
4447
  }
4431
4448
  destroy() {
4432
4449
  this.stop();
4433
- this._preDrawUpdaters = [];
4434
- this._postDrawUpdaters = [];
4435
- this._colorPlugins = [];
4436
- this._canvasClearPlugins = [];
4437
- this._canvasPaintPlugins = [];
4438
- this._clearDrawPlugins = [];
4439
- this._drawParticlePlugins = [];
4440
- this._drawParticlesCleanupPlugins = [];
4441
- this._drawParticlesSetupPlugins = [];
4442
- this._drawPlugins = [];
4443
- this._drawSettingsSetupPlugins = [];
4444
- this._drawSettingsCleanupPlugins = [];
4450
+ this.#preDrawUpdaters = [];
4451
+ this.#postDrawUpdaters = [];
4452
+ this.#colorPlugins = [];
4453
+ this.#canvasClearPlugins = [];
4454
+ this.#canvasPaintPlugins = [];
4455
+ this.#clearDrawPlugins = [];
4456
+ this.#drawParticlePlugins = [];
4457
+ this.#drawParticlesCleanupPlugins = [];
4458
+ this.#drawParticlesSetupPlugins = [];
4459
+ this.#drawPlugins = [];
4460
+ this.#drawSettingsSetupPlugins = [];
4461
+ this.#drawSettingsCleanupPlugins = [];
4445
4462
  }
4446
4463
  draw(cb) {
4447
- const ctx = this._context;
4464
+ const ctx = this.#context;
4448
4465
  if (!ctx) {
4449
4466
  return;
4450
4467
  }
@@ -4459,21 +4476,21 @@
4459
4476
  return;
4460
4477
  }
4461
4478
  const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
4462
- let [fColor, sColor] = this._getPluginParticleColors(particle);
4479
+ let [fColor, sColor] = this.#getPluginParticleColors(particle);
4463
4480
  fColor ??= pfColor;
4464
4481
  sColor ??= psColor;
4465
4482
  if (!fColor && !sColor) {
4466
4483
  return;
4467
4484
  }
4468
- 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;
4485
+ 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;
4469
4486
  transform.a = transform.b = transform.c = transform.d = undefined;
4470
4487
  colorStyles.fill = fill;
4471
4488
  colorStyles.stroke = stroke;
4472
4489
  this.draw((context) => {
4473
- for (const plugin of this._drawParticlesSetupPlugins) {
4490
+ for (const plugin of this.#drawParticlesSetupPlugins) {
4474
4491
  plugin.drawParticleSetup?.(context, particle, delta);
4475
4492
  }
4476
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4493
+ this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4477
4494
  drawParticle({
4478
4495
  container,
4479
4496
  context,
@@ -4484,35 +4501,35 @@
4484
4501
  opacity: opacity,
4485
4502
  transform,
4486
4503
  });
4487
- this._applyPostDrawUpdaters(particle);
4488
- for (const plugin of this._drawParticlesCleanupPlugins) {
4504
+ this.#applyPostDrawUpdaters(particle);
4505
+ for (const plugin of this.#drawParticlesCleanupPlugins) {
4489
4506
  plugin.drawParticleCleanup?.(context, particle, delta);
4490
4507
  }
4491
4508
  });
4492
4509
  }
4493
4510
  drawParticlePlugins(particle, delta) {
4494
4511
  this.draw(ctx => {
4495
- for (const plugin of this._drawParticlePlugins) {
4512
+ for (const plugin of this.#drawParticlePlugins) {
4496
4513
  drawParticlePlugin(ctx, plugin, particle, delta);
4497
4514
  }
4498
4515
  });
4499
4516
  }
4500
4517
  drawParticles(delta) {
4501
- const { particles } = this._container;
4518
+ const { particles } = this.#container;
4502
4519
  this.clear();
4503
4520
  particles.update(delta);
4504
4521
  this.draw(ctx => {
4505
- for (const plugin of this._drawSettingsSetupPlugins) {
4522
+ for (const plugin of this.#drawSettingsSetupPlugins) {
4506
4523
  plugin.drawSettingsSetup?.(ctx, delta);
4507
4524
  }
4508
- for (const plugin of this._drawPlugins) {
4525
+ for (const plugin of this.#drawPlugins) {
4509
4526
  plugin.draw?.(ctx, delta);
4510
4527
  }
4511
4528
  particles.drawParticles(delta);
4512
- for (const plugin of this._clearDrawPlugins) {
4529
+ for (const plugin of this.#clearDrawPlugins) {
4513
4530
  plugin.clearDraw?.(ctx, delta);
4514
4531
  }
4515
- for (const plugin of this._drawSettingsCleanupPlugins) {
4532
+ for (const plugin of this.#drawSettingsCleanupPlugins) {
4516
4533
  plugin.drawSettingsCleanup?.(ctx, delta);
4517
4534
  }
4518
4535
  });
@@ -4523,64 +4540,64 @@
4523
4540
  this.paint();
4524
4541
  }
4525
4542
  initPlugins() {
4526
- this._colorPlugins = [];
4527
- this._canvasClearPlugins = [];
4528
- this._canvasPaintPlugins = [];
4529
- this._clearDrawPlugins = [];
4530
- this._drawParticlePlugins = [];
4531
- this._drawParticlesSetupPlugins = [];
4532
- this._drawParticlesCleanupPlugins = [];
4533
- this._drawPlugins = [];
4534
- this._drawSettingsSetupPlugins = [];
4535
- this._drawSettingsCleanupPlugins = [];
4536
- for (const plugin of this._container.plugins) {
4543
+ this.#colorPlugins = [];
4544
+ this.#canvasClearPlugins = [];
4545
+ this.#canvasPaintPlugins = [];
4546
+ this.#clearDrawPlugins = [];
4547
+ this.#drawParticlePlugins = [];
4548
+ this.#drawParticlesSetupPlugins = [];
4549
+ this.#drawParticlesCleanupPlugins = [];
4550
+ this.#drawPlugins = [];
4551
+ this.#drawSettingsSetupPlugins = [];
4552
+ this.#drawSettingsCleanupPlugins = [];
4553
+ for (const plugin of this.#container.plugins) {
4537
4554
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
4538
- this._colorPlugins.push(plugin);
4555
+ this.#colorPlugins.push(plugin);
4539
4556
  }
4540
4557
  if (plugin.canvasClear) {
4541
- this._canvasClearPlugins.push(plugin);
4558
+ this.#canvasClearPlugins.push(plugin);
4542
4559
  }
4543
4560
  if (plugin.canvasPaint) {
4544
- this._canvasPaintPlugins.push(plugin);
4561
+ this.#canvasPaintPlugins.push(plugin);
4545
4562
  }
4546
4563
  if (plugin.drawParticle) {
4547
- this._drawParticlePlugins.push(plugin);
4564
+ this.#drawParticlePlugins.push(plugin);
4548
4565
  }
4549
4566
  if (plugin.drawParticleSetup) {
4550
- this._drawParticlesSetupPlugins.push(plugin);
4567
+ this.#drawParticlesSetupPlugins.push(plugin);
4551
4568
  }
4552
4569
  if (plugin.drawParticleCleanup) {
4553
- this._drawParticlesCleanupPlugins.push(plugin);
4570
+ this.#drawParticlesCleanupPlugins.push(plugin);
4554
4571
  }
4555
4572
  if (plugin.draw) {
4556
- this._drawPlugins.push(plugin);
4573
+ this.#drawPlugins.push(plugin);
4557
4574
  }
4558
4575
  if (plugin.drawSettingsSetup) {
4559
- this._drawSettingsSetupPlugins.push(plugin);
4576
+ this.#drawSettingsSetupPlugins.push(plugin);
4560
4577
  }
4561
4578
  if (plugin.drawSettingsCleanup) {
4562
- this._drawSettingsCleanupPlugins.push(plugin);
4579
+ this.#drawSettingsCleanupPlugins.push(plugin);
4563
4580
  }
4564
4581
  if (plugin.clearDraw) {
4565
- this._clearDrawPlugins.push(plugin);
4582
+ this.#clearDrawPlugins.push(plugin);
4566
4583
  }
4567
4584
  }
4568
4585
  }
4569
4586
  initUpdaters() {
4570
- this._preDrawUpdaters = [];
4571
- this._postDrawUpdaters = [];
4572
- for (const updater of this._container.particleUpdaters) {
4587
+ this.#preDrawUpdaters = [];
4588
+ this.#postDrawUpdaters = [];
4589
+ for (const updater of this.#container.particleUpdaters) {
4573
4590
  if (updater.afterDraw) {
4574
- this._postDrawUpdaters.push(updater);
4591
+ this.#postDrawUpdaters.push(updater);
4575
4592
  }
4576
4593
  if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
4577
- this._preDrawUpdaters.push(updater);
4594
+ this.#preDrawUpdaters.push(updater);
4578
4595
  }
4579
4596
  }
4580
4597
  }
4581
4598
  paint() {
4582
4599
  let handled = false;
4583
- for (const plugin of this._canvasPaintPlugins) {
4600
+ for (const plugin of this.#canvasPaintPlugins) {
4584
4601
  handled = plugin.canvasPaint?.() ?? false;
4585
4602
  if (handled) {
4586
4603
  break;
@@ -4593,35 +4610,35 @@
4593
4610
  }
4594
4611
  paintBase(baseColor) {
4595
4612
  this.draw(ctx => {
4596
- paintBase(ctx, this._canvasManager.size, baseColor);
4613
+ paintBase(ctx, this.#canvasManager.size, baseColor);
4597
4614
  });
4598
4615
  }
4599
4616
  paintImage(image, opacity) {
4600
4617
  this.draw(ctx => {
4601
- paintImage(ctx, this._canvasManager.size, image, opacity);
4618
+ paintImage(ctx, this.#canvasManager.size, image, opacity);
4602
4619
  });
4603
4620
  }
4604
4621
  setContext(context) {
4605
- this._context = context;
4606
- if (this._context) {
4607
- this._context.globalCompositeOperation = defaultCompositeValue;
4622
+ this.#context = context;
4623
+ if (this.#context) {
4624
+ this.#context.globalCompositeOperation = defaultCompositeValue;
4608
4625
  }
4609
4626
  }
4610
4627
  setContextSettings(settings) {
4611
- this._contextSettings = settings;
4628
+ this.#contextSettings = settings;
4612
4629
  }
4613
4630
  stop() {
4614
4631
  this.draw(ctx => {
4615
- clear(ctx, this._canvasManager.size);
4632
+ clear(ctx, this.#canvasManager.size);
4616
4633
  });
4617
4634
  }
4618
- _applyPostDrawUpdaters = particle => {
4619
- for (const updater of this._postDrawUpdaters) {
4635
+ #applyPostDrawUpdaters = particle => {
4636
+ for (const updater of this.#postDrawUpdaters) {
4620
4637
  updater.afterDraw?.(particle);
4621
4638
  }
4622
4639
  };
4623
- _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4624
- for (const updater of this._preDrawUpdaters) {
4640
+ #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4641
+ for (const updater of this.#preDrawUpdaters) {
4625
4642
  if (updater.getColorStyles) {
4626
4643
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
4627
4644
  if (fill) {
@@ -4640,22 +4657,22 @@
4640
4657
  updater.beforeDraw?.(particle);
4641
4658
  }
4642
4659
  };
4643
- _getPluginParticleColors = particle => {
4660
+ #getPluginParticleColors = particle => {
4644
4661
  let fColor, sColor;
4645
- for (const plugin of this._colorPlugins) {
4662
+ for (const plugin of this.#colorPlugins) {
4646
4663
  if (!fColor && plugin.particleFillColor) {
4647
- fColor = rangeColorToHsl(this._pluginManager, plugin.particleFillColor(particle));
4664
+ fColor = rangeColorToHsl(this.#pluginManager, plugin.particleFillColor(particle));
4648
4665
  }
4649
4666
  if (!sColor && plugin.particleStrokeColor) {
4650
- sColor = rangeColorToHsl(this._pluginManager, plugin.particleStrokeColor(particle));
4667
+ sColor = rangeColorToHsl(this.#pluginManager, plugin.particleStrokeColor(particle));
4651
4668
  }
4652
4669
  if (fColor && sColor) {
4653
4670
  break;
4654
4671
  }
4655
4672
  }
4656
- this._reusablePluginColors[fColorIndex] = fColor;
4657
- this._reusablePluginColors[sColorIndex] = sColor;
4658
- return this._reusablePluginColors;
4673
+ this.#reusablePluginColors[fColorIndex] = fColor;
4674
+ this.#reusablePluginColors[sColorIndex] = sColor;
4675
+ return this.#reusablePluginColors;
4659
4676
  };
4660
4677
  }
4661
4678
 
@@ -4713,53 +4730,53 @@
4713
4730
  renderCanvas;
4714
4731
  size;
4715
4732
  zoom = defaultZoom;
4716
- _container;
4717
- _generated;
4718
- _mutationObserver;
4719
- _originalStyle;
4720
- _pluginManager;
4721
- _pointerEvents;
4722
- _resizePlugins;
4723
- _standardSize;
4724
- _zoomCenter;
4733
+ #container;
4734
+ #generated;
4735
+ #mutationObserver;
4736
+ #originalStyle;
4737
+ #pluginManager;
4738
+ #pointerEvents;
4739
+ #resizePlugins;
4740
+ #standardSize;
4741
+ #zoomCenter;
4725
4742
  constructor(pluginManager, container) {
4726
- this._pluginManager = pluginManager;
4727
- this._container = container;
4743
+ this.#pluginManager = pluginManager;
4744
+ this.#container = container;
4728
4745
  this.render = new RenderManager(pluginManager, container, this);
4729
- this._standardSize = {
4746
+ this.#standardSize = {
4730
4747
  height: 0,
4731
4748
  width: 0,
4732
4749
  };
4733
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
4750
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
4734
4751
  this.size = {
4735
4752
  height: stdSize.height * pxRatio,
4736
4753
  width: stdSize.width * pxRatio,
4737
4754
  };
4738
- this._generated = false;
4739
- this._resizePlugins = [];
4740
- this._pointerEvents = "none";
4755
+ this.#generated = false;
4756
+ this.#resizePlugins = [];
4757
+ this.#pointerEvents = "none";
4741
4758
  }
4742
- get _fullScreen() {
4743
- return this._container.actualOptions.fullScreen.enable;
4759
+ get #fullScreen() {
4760
+ return this.#container.actualOptions.fullScreen.enable;
4744
4761
  }
4745
4762
  destroy() {
4746
4763
  this.stop();
4747
- if (this._generated) {
4764
+ if (this.#generated) {
4748
4765
  const element = this.domElement;
4749
4766
  element?.remove();
4750
4767
  this.domElement = undefined;
4751
4768
  this.renderCanvas = undefined;
4752
4769
  }
4753
4770
  else {
4754
- this._resetOriginalStyle();
4771
+ this.#resetOriginalStyle();
4755
4772
  }
4756
4773
  this.render.destroy();
4757
- this._resizePlugins = [];
4774
+ this.#resizePlugins = [];
4758
4775
  }
4759
4776
  getZoomCenter() {
4760
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
4761
- if (this._zoomCenter) {
4762
- return this._zoomCenter;
4777
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
4778
+ if (this.#zoomCenter) {
4779
+ return this.#zoomCenter;
4763
4780
  }
4764
4781
  return {
4765
4782
  x: (width * half) / pxRatio,
@@ -4767,20 +4784,20 @@
4767
4784
  };
4768
4785
  }
4769
4786
  init() {
4770
- this._safeMutationObserver(obs => {
4787
+ this.#safeMutationObserver(obs => {
4771
4788
  obs.disconnect();
4772
4789
  });
4773
- this._mutationObserver = safeMutationObserver(records => {
4790
+ this.#mutationObserver = safeMutationObserver(records => {
4774
4791
  for (const record of records) {
4775
4792
  if (record.type === "attributes" && record.attributeName === "style") {
4776
- this._repairStyle();
4793
+ this.#repairStyle();
4777
4794
  }
4778
4795
  }
4779
4796
  });
4780
4797
  this.resize();
4781
- this._initStyle();
4798
+ this.#initStyle();
4782
4799
  this.initBackground();
4783
- this._safeMutationObserver(obs => {
4800
+ this.#safeMutationObserver(obs => {
4784
4801
  const element = this.domElement;
4785
4802
  if (!element || !(element instanceof Node)) {
4786
4803
  return;
@@ -4791,13 +4808,13 @@
4791
4808
  this.render.init();
4792
4809
  }
4793
4810
  initBackground() {
4794
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
4811
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
4795
4812
  if (!element) {
4796
4813
  return;
4797
4814
  }
4798
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
4815
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
4799
4816
  if (color) {
4800
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
4817
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
4801
4818
  }
4802
4819
  else {
4803
4820
  elementStyle.backgroundColor = "";
@@ -4808,27 +4825,27 @@
4808
4825
  elementStyle.backgroundSize = background.size || "";
4809
4826
  }
4810
4827
  initPlugins() {
4811
- this._resizePlugins = [];
4812
- for (const plugin of this._container.plugins) {
4828
+ this.#resizePlugins = [];
4829
+ for (const plugin of this.#container.plugins) {
4813
4830
  if (plugin.resize) {
4814
- this._resizePlugins.push(plugin);
4831
+ this.#resizePlugins.push(plugin);
4815
4832
  }
4816
4833
  }
4817
4834
  }
4818
4835
  loadCanvas(canvas) {
4819
- if (this._generated && this.domElement) {
4836
+ if (this.#generated && this.domElement) {
4820
4837
  this.domElement.remove();
4821
4838
  }
4822
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4839
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4823
4840
  this.domElement = domCanvas;
4824
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4841
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4825
4842
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
4826
4843
  const domElement = this.domElement;
4827
4844
  if (domElement) {
4828
4845
  domElement.ariaHidden = "true";
4829
- this._originalStyle = cloneStyle(domElement.style);
4846
+ this.#originalStyle = cloneStyle(domElement.style);
4830
4847
  }
4831
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
4848
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
4832
4849
  if (domElement) {
4833
4850
  standardSize.height = domElement.offsetHeight;
4834
4851
  standardSize.width = domElement.offsetWidth;
@@ -4837,7 +4854,7 @@
4837
4854
  standardSize.height = renderCanvas.height;
4838
4855
  standardSize.width = renderCanvas.width;
4839
4856
  }
4840
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
4857
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
4841
4858
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
4842
4859
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
4843
4860
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -4848,12 +4865,12 @@
4848
4865
  willReadFrequently: false,
4849
4866
  });
4850
4867
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
4851
- this._safeMutationObserver(obs => {
4868
+ this.#safeMutationObserver(obs => {
4852
4869
  obs.disconnect();
4853
4870
  });
4854
4871
  container.retina.init();
4855
4872
  this.initBackground();
4856
- this._safeMutationObserver(obs => {
4873
+ this.#safeMutationObserver(obs => {
4857
4874
  const element = this.domElement;
4858
4875
  if (!element || !(element instanceof Node)) {
4859
4876
  return;
@@ -4866,11 +4883,11 @@
4866
4883
  if (!element) {
4867
4884
  return false;
4868
4885
  }
4869
- const container = this._container, renderCanvas = this.renderCanvas;
4886
+ const container = this.#container, renderCanvas = this.renderCanvas;
4870
4887
  if (renderCanvas === undefined) {
4871
4888
  return false;
4872
4889
  }
4873
- const currentSize = container.canvas._standardSize, newSize = {
4890
+ const currentSize = container.canvas.#standardSize, newSize = {
4874
4891
  width: element.offsetWidth,
4875
4892
  height: element.offsetHeight,
4876
4893
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -4889,7 +4906,7 @@
4889
4906
  const canvasSize = this.size;
4890
4907
  renderCanvas.width = canvasSize.width = retinaSize.width;
4891
4908
  renderCanvas.height = canvasSize.height = retinaSize.height;
4892
- if (this._container.started) {
4909
+ if (this.#container.started) {
4893
4910
  container.particles.setResizeFactor({
4894
4911
  width: currentSize.width / oldSize.width,
4895
4912
  height: currentSize.height / oldSize.height,
@@ -4902,46 +4919,46 @@
4902
4919
  if (!element) {
4903
4920
  return;
4904
4921
  }
4905
- this._pointerEvents = type;
4906
- this._repairStyle();
4922
+ this.#pointerEvents = type;
4923
+ this.#repairStyle();
4907
4924
  }
4908
4925
  setZoom(zoomLevel, center) {
4909
4926
  this.zoom = zoomLevel;
4910
- this._zoomCenter = center;
4927
+ this.#zoomCenter = center;
4911
4928
  }
4912
4929
  stop() {
4913
- this._safeMutationObserver(obs => {
4930
+ this.#safeMutationObserver(obs => {
4914
4931
  obs.disconnect();
4915
4932
  });
4916
- this._mutationObserver = undefined;
4933
+ this.#mutationObserver = undefined;
4917
4934
  this.render.stop();
4918
4935
  }
4919
4936
  async windowResize() {
4920
4937
  if (!this.domElement || !this.resize()) {
4921
4938
  return;
4922
4939
  }
4923
- const container = this._container, needsRefresh = container.updateActualOptions();
4940
+ const container = this.#container, needsRefresh = container.updateActualOptions();
4924
4941
  container.particles.setDensity();
4925
- this._applyResizePlugins();
4942
+ this.#applyResizePlugins();
4926
4943
  if (needsRefresh) {
4927
4944
  await container.refresh();
4928
4945
  }
4929
4946
  }
4930
- _applyResizePlugins = () => {
4931
- for (const plugin of this._resizePlugins) {
4947
+ #applyResizePlugins = () => {
4948
+ for (const plugin of this.#resizePlugins) {
4932
4949
  plugin.resize?.();
4933
4950
  }
4934
4951
  };
4935
- _initStyle = () => {
4936
- const element = this.domElement, options = this._container.actualOptions;
4952
+ #initStyle = () => {
4953
+ const element = this.domElement, options = this.#container.actualOptions;
4937
4954
  if (!element) {
4938
4955
  return;
4939
4956
  }
4940
- if (this._fullScreen) {
4941
- this._setFullScreenStyle();
4957
+ if (this.#fullScreen) {
4958
+ this.#setFullScreenStyle();
4942
4959
  }
4943
4960
  else {
4944
- this._resetOriginalStyle();
4961
+ this.#resetOriginalStyle();
4945
4962
  }
4946
4963
  for (const key in options.style) {
4947
4964
  if (!key || !(key in options.style)) {
@@ -4954,72 +4971,72 @@
4954
4971
  element.style.setProperty(key, value, "important");
4955
4972
  }
4956
4973
  };
4957
- _repairStyle = () => {
4974
+ #repairStyle = () => {
4958
4975
  const element = this.domElement;
4959
4976
  if (!element) {
4960
4977
  return;
4961
4978
  }
4962
- this._safeMutationObserver(observer => {
4979
+ this.#safeMutationObserver(observer => {
4963
4980
  observer.disconnect();
4964
4981
  });
4965
- this._initStyle();
4982
+ this.#initStyle();
4966
4983
  this.initBackground();
4967
- const pointerEvents = this._pointerEvents;
4984
+ const pointerEvents = this.#pointerEvents;
4968
4985
  element.style.pointerEvents = pointerEvents;
4969
4986
  element.style.setProperty("pointer-events", pointerEvents);
4970
- this._safeMutationObserver(observer => {
4987
+ this.#safeMutationObserver(observer => {
4971
4988
  if (!(element instanceof Node)) {
4972
4989
  return;
4973
4990
  }
4974
4991
  observer.observe(element, { attributes: true });
4975
4992
  });
4976
4993
  };
4977
- _resetOriginalStyle = () => {
4978
- const element = this.domElement, originalStyle = this._originalStyle;
4994
+ #resetOriginalStyle = () => {
4995
+ const element = this.domElement, originalStyle = this.#originalStyle;
4979
4996
  if (!element || !originalStyle) {
4980
4997
  return;
4981
4998
  }
4982
4999
  setStyle(element, originalStyle, true);
4983
5000
  };
4984
- _safeMutationObserver = callback => {
4985
- if (!this._mutationObserver) {
5001
+ #safeMutationObserver = callback => {
5002
+ if (!this.#mutationObserver) {
4986
5003
  return;
4987
5004
  }
4988
- callback(this._mutationObserver);
5005
+ callback(this.#mutationObserver);
4989
5006
  };
4990
- _setFullScreenStyle = () => {
5007
+ #setFullScreenStyle = () => {
4991
5008
  const element = this.domElement;
4992
5009
  if (!element) {
4993
5010
  return;
4994
5011
  }
4995
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
5012
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
4996
5013
  };
4997
5014
  }
4998
5015
 
4999
5016
  class EventListeners {
5000
- container;
5001
- _handlers;
5002
- _resizeObserver;
5003
- _resizeTimeout;
5017
+ #container;
5018
+ #handlers;
5019
+ #resizeObserver;
5020
+ #resizeTimeout;
5004
5021
  constructor(container) {
5005
- this.container = container;
5006
- this._handlers = {
5022
+ this.#container = container;
5023
+ this.#handlers = {
5007
5024
  visibilityChange: () => {
5008
- this._handleVisibilityChange();
5025
+ this.#handleVisibilityChange();
5009
5026
  },
5010
5027
  resize: () => {
5011
- this._handleWindowResize();
5028
+ this.#handleWindowResize();
5012
5029
  },
5013
5030
  };
5014
5031
  }
5015
5032
  addListeners() {
5016
- this._manageListeners(true);
5033
+ this.#manageListeners(true);
5017
5034
  }
5018
5035
  removeListeners() {
5019
- this._manageListeners(false);
5036
+ this.#manageListeners(false);
5020
5037
  }
5021
- _handleVisibilityChange = () => {
5022
- const container = this.container, options = container.actualOptions;
5038
+ #handleVisibilityChange = () => {
5039
+ const container = this.#container, options = container.actualOptions;
5023
5040
  if (!options.pauseOnBlur) {
5024
5041
  return;
5025
5042
  }
@@ -5037,24 +5054,24 @@
5037
5054
  }
5038
5055
  }
5039
5056
  };
5040
- _handleWindowResize = () => {
5041
- if (this._resizeTimeout) {
5042
- clearTimeout(this._resizeTimeout);
5043
- delete this._resizeTimeout;
5057
+ #handleWindowResize = () => {
5058
+ if (this.#resizeTimeout) {
5059
+ clearTimeout(this.#resizeTimeout);
5060
+ this.#resizeTimeout = undefined;
5044
5061
  }
5045
5062
  const handleResize = async () => {
5046
- const canvas = this.container.canvas;
5063
+ const canvas = this.#container.canvas;
5047
5064
  await canvas.windowResize();
5048
5065
  };
5049
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
5066
+ this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
5050
5067
  };
5051
- _manageListeners = add => {
5052
- const handlers = this._handlers;
5053
- this._manageResize(add);
5068
+ #manageListeners = add => {
5069
+ const handlers = this.#handlers;
5070
+ this.#manageResize(add);
5054
5071
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
5055
5072
  };
5056
- _manageResize = add => {
5057
- const handlers = this._handlers, container = this.container, options = container.actualOptions;
5073
+ #manageResize = add => {
5074
+ const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
5058
5075
  if (!options.resize.enable) {
5059
5076
  return;
5060
5077
  }
@@ -5063,22 +5080,22 @@
5063
5080
  return;
5064
5081
  }
5065
5082
  const canvasEl = container.canvas.domElement;
5066
- if (this._resizeObserver && !add) {
5083
+ if (this.#resizeObserver && !add) {
5067
5084
  if (canvasEl) {
5068
- this._resizeObserver.unobserve(canvasEl);
5085
+ this.#resizeObserver.unobserve(canvasEl);
5069
5086
  }
5070
- this._resizeObserver.disconnect();
5071
- delete this._resizeObserver;
5087
+ this.#resizeObserver.disconnect();
5088
+ this.#resizeObserver = undefined;
5072
5089
  }
5073
- else if (!this._resizeObserver && add && canvasEl) {
5074
- this._resizeObserver = new ResizeObserver((entries) => {
5090
+ else if (!this.#resizeObserver && add && canvasEl) {
5091
+ this.#resizeObserver = new ResizeObserver((entries) => {
5075
5092
  const entry = entries.find(e => e.target === canvasEl);
5076
5093
  if (!entry) {
5077
5094
  return;
5078
5095
  }
5079
- this._handleWindowResize();
5096
+ this.#handleWindowResize();
5080
5097
  });
5081
- this._resizeObserver.observe(canvasEl);
5098
+ this.#resizeObserver.observe(canvasEl);
5082
5099
  }
5083
5100
  };
5084
5101
  }
@@ -5151,24 +5168,24 @@
5151
5168
  unbreakable;
5152
5169
  velocity;
5153
5170
  zIndexFactor;
5154
- _cachedOpacityData = {
5171
+ #cachedOpacityData = {
5155
5172
  fillOpacity: defaultOpacity$1,
5156
5173
  opacity: defaultOpacity$1,
5157
5174
  strokeOpacity: defaultOpacity$1,
5158
5175
  };
5159
- _cachedPosition = Vector3d.origin;
5160
- _cachedRotateData = { sin: 0, cos: 0 };
5161
- _cachedTransform = {
5176
+ #cachedPosition = Vector3d.origin;
5177
+ #cachedRotateData = { sin: 0, cos: 0 };
5178
+ #cachedTransform = {
5162
5179
  a: 1,
5163
5180
  b: 0,
5164
5181
  c: 0,
5165
5182
  d: 1,
5166
5183
  };
5167
- _container;
5168
- _pluginManager;
5184
+ #container;
5185
+ #pluginManager;
5169
5186
  constructor(pluginManager, container) {
5170
- this._pluginManager = pluginManager;
5171
- this._container = container;
5187
+ this.#pluginManager = pluginManager;
5188
+ this.#container = container;
5172
5189
  }
5173
5190
  destroy(override) {
5174
5191
  if (this.unbreakable || this.destroyed) {
@@ -5177,7 +5194,7 @@
5177
5194
  this.destroyed = true;
5178
5195
  this.bubble.inRange = false;
5179
5196
  this.slow.inRange = false;
5180
- const container = this._container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
5197
+ const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
5181
5198
  shapeDrawer?.particleDestroy?.(this);
5182
5199
  for (const plugin of container.particleDestroyedPlugins) {
5183
5200
  plugin.particleDestroyed?.(this, override);
@@ -5185,12 +5202,12 @@
5185
5202
  for (const updater of container.particleUpdaters) {
5186
5203
  updater.particleDestroyed?.(this, override);
5187
5204
  }
5188
- this._container.dispatchEvent(EventType.particleDestroyed, {
5205
+ this.#container.dispatchEvent(EventType.particleDestroyed, {
5189
5206
  particle: this,
5190
5207
  });
5191
5208
  }
5192
5209
  draw(delta) {
5193
- const container = this._container, render = container.canvas.render;
5210
+ const container = this.#container, render = container.canvas.render;
5194
5211
  render.drawParticlePlugins(this, delta);
5195
5212
  render.drawParticle(this, delta);
5196
5213
  }
@@ -5198,50 +5215,50 @@
5198
5215
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
5199
5216
  }
5200
5217
  getFillColor() {
5201
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
5218
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
5202
5219
  }
5203
5220
  getMass() {
5204
5221
  return this.getRadius() ** squareExp * Math.PI * half;
5205
5222
  }
5206
5223
  getOpacity() {
5207
5224
  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;
5208
- this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
5209
- this._cachedOpacityData.opacity = opacity * zOpacityFactor;
5210
- this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
5211
- return this._cachedOpacityData;
5225
+ this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
5226
+ this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
5227
+ this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
5228
+ return this.#cachedOpacityData;
5212
5229
  }
5213
5230
  getPosition() {
5214
- this._cachedPosition.x = this.position.x + this.offset.x;
5215
- this._cachedPosition.y = this.position.y + this.offset.y;
5216
- this._cachedPosition.z = this.position.z;
5217
- return this._cachedPosition;
5231
+ this.#cachedPosition.x = this.position.x + this.offset.x;
5232
+ this.#cachedPosition.y = this.position.y + this.offset.y;
5233
+ this.#cachedPosition.z = this.position.z;
5234
+ return this.#cachedPosition;
5218
5235
  }
5219
5236
  getRadius() {
5220
5237
  return this.bubble.radius ?? this.size.value;
5221
5238
  }
5222
5239
  getRotateData() {
5223
5240
  const angle = this.getAngle();
5224
- this._cachedRotateData.sin = Math.sin(angle);
5225
- this._cachedRotateData.cos = Math.cos(angle);
5226
- return this._cachedRotateData;
5241
+ this.#cachedRotateData.sin = Math.sin(angle);
5242
+ this.#cachedRotateData.cos = Math.cos(angle);
5243
+ return this.#cachedRotateData;
5227
5244
  }
5228
5245
  getStrokeColor() {
5229
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
5246
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
5230
5247
  }
5231
5248
  getTransformData(externalTransform) {
5232
5249
  const rotateData = this.getRotateData(), rotating = this.isRotating;
5233
- this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
5234
- this._cachedTransform.b = rotating
5250
+ this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
5251
+ this.#cachedTransform.b = rotating
5235
5252
  ? rotateData.sin * (externalTransform.b ?? identity$2)
5236
5253
  : (externalTransform.b ?? defaultTransform.b);
5237
- this._cachedTransform.c = rotating
5254
+ this.#cachedTransform.c = rotating
5238
5255
  ? -rotateData.sin * (externalTransform.c ?? identity$2)
5239
5256
  : (externalTransform.c ?? defaultTransform.c);
5240
- this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
5241
- return this._cachedTransform;
5257
+ this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
5258
+ return this.#cachedTransform;
5242
5259
  }
5243
5260
  init(id, position, overrideOptions, group) {
5244
- const container = this._container;
5261
+ const container = this.#container;
5245
5262
  this.id = id;
5246
5263
  this.group = group;
5247
5264
  this.justWarped = false;
@@ -5261,21 +5278,27 @@
5261
5278
  moveSpeed: 0,
5262
5279
  sizeAnimationSpeed: 0,
5263
5280
  };
5281
+ this.size = {
5282
+ value: 1,
5283
+ max: 1,
5284
+ min: 1,
5285
+ enable: false,
5286
+ };
5264
5287
  this.outType = ParticleOutType.normal;
5265
5288
  this.ignoresResizeRatio = true;
5266
- 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;
5289
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
5267
5290
  this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
5268
5291
  this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
5269
5292
  const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
5270
5293
  if (overrideOptions) {
5271
- if (overrideOptions.effect?.type) {
5294
+ if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
5272
5295
  const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
5273
5296
  if (effect) {
5274
5297
  this.effect = effect;
5275
5298
  effectOptions.load(overrideOptions.effect);
5276
5299
  }
5277
5300
  }
5278
- if (overrideOptions.shape?.type) {
5301
+ if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
5279
5302
  const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
5280
5303
  if (shape) {
5281
5304
  this.shape = shape;
@@ -5284,21 +5307,20 @@
5284
5307
  }
5285
5308
  }
5286
5309
  if (this.effect === randomColorValue) {
5287
- const availableEffects = [...this._container.effectDrawers.keys()];
5310
+ const availableEffects = [...this.#container.effectDrawers.keys()];
5288
5311
  this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
5289
5312
  }
5290
5313
  if (this.shape === randomColorValue) {
5291
- const availableShapes = [...this._container.shapeDrawers.keys()];
5314
+ const availableShapes = [...this.#container.shapeDrawers.keys()];
5292
5315
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
5293
5316
  }
5294
5317
  this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
5295
5318
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
5296
5319
  particlesOptions.load(overrideOptions);
5297
- const effectData = this.effectData;
5320
+ const effectData = this.effectData, shapeData = this.shapeData;
5298
5321
  if (effectData) {
5299
5322
  particlesOptions.load(effectData.particles);
5300
5323
  }
5301
- const shapeData = this.shapeData;
5302
5324
  if (shapeData) {
5303
5325
  particlesOptions.load(shapeData.particles);
5304
5326
  }
@@ -5306,7 +5328,9 @@
5306
5328
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
5307
5329
  this.options = particlesOptions;
5308
5330
  container.retina.initParticle(this);
5309
- this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
5331
+ for (const updater of container.particleUpdaters) {
5332
+ updater.preInit?.(this);
5333
+ }
5310
5334
  this.bubble = {
5311
5335
  inRange: false,
5312
5336
  };
@@ -5314,8 +5338,8 @@
5314
5338
  inRange: false,
5315
5339
  factor: 1,
5316
5340
  };
5317
- this._initPosition(position);
5318
- this.initialVelocity = this._calculateVelocity();
5341
+ this.#initPosition(position);
5342
+ this.initialVelocity = this.#calculateVelocity();
5319
5343
  this.velocity = this.initialVelocity.copy();
5320
5344
  this.zIndexFactor = this.position.z / container.zLayers;
5321
5345
  this.sides = 24;
@@ -5346,12 +5370,11 @@
5346
5370
  plugin.particleCreated?.(this);
5347
5371
  }
5348
5372
  }
5349
- isInsideCanvas() {
5350
- const radius = this.getRadius(), canvasSize = this._container.canvas.size, position = this.position;
5351
- return (position.x >= -radius &&
5352
- position.y >= -radius &&
5353
- position.y <= canvasSize.height + radius &&
5354
- position.x <= canvasSize.width + radius);
5373
+ isInsideCanvas(direction) {
5374
+ return this.#getInsideCanvasResult({ direction }).inside;
5375
+ }
5376
+ isInsideCanvasForOutMode(outMode, direction) {
5377
+ return this.#getInsideCanvasResult({ direction, outMode }).inside;
5355
5378
  }
5356
5379
  isShowingBack() {
5357
5380
  if (!this.roll) {
@@ -5376,13 +5399,13 @@
5376
5399
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
5377
5400
  }
5378
5401
  reset() {
5379
- for (const updater of this._container.particleUpdaters) {
5402
+ for (const updater of this.#container.particleUpdaters) {
5380
5403
  updater.reset?.(this);
5381
5404
  }
5382
5405
  }
5383
- _calcPosition = (position, zIndex) => {
5406
+ #calcPosition = (position, zIndex) => {
5384
5407
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
5385
- const container = this._container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5408
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5386
5409
  while (!signal.aborted) {
5387
5410
  for (const plugin of plugins) {
5388
5411
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -5394,10 +5417,10 @@
5394
5417
  size: canvasSize,
5395
5418
  position: posVec,
5396
5419
  }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
5397
- this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
5398
- this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
5399
- this._fixVertical(pos, radius, outModes.top ?? outModes.default);
5400
- this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
5420
+ this.#fixHorizontal(pos, radius, outModes.left ?? outModes.default);
5421
+ this.#fixHorizontal(pos, radius, outModes.right ?? outModes.default);
5422
+ this.#fixVertical(pos, radius, outModes.top ?? outModes.default);
5423
+ this.#fixVertical(pos, radius, outModes.bottom ?? outModes.default);
5401
5424
  let isValidPosition = true;
5402
5425
  for (const plugin of container.particles.checkParticlePositionPlugins) {
5403
5426
  isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
@@ -5413,8 +5436,8 @@
5413
5436
  }
5414
5437
  return posVec;
5415
5438
  };
5416
- _calculateVelocity = () => {
5417
- const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
5439
+ #calculateVelocity = () => {
5440
+ const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
5418
5441
  if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
5419
5442
  return res;
5420
5443
  }
@@ -5430,27 +5453,86 @@
5430
5453
  }
5431
5454
  return res;
5432
5455
  };
5433
- _fixHorizontal = (pos, radius, outMode) => {
5456
+ #fixHorizontal = (pos, radius, outMode) => {
5434
5457
  fixOutMode({
5435
5458
  outMode,
5436
5459
  checkModes: [OutMode.bounce],
5437
5460
  coord: pos.x,
5438
- maxCoord: this._container.canvas.size.width,
5461
+ maxCoord: this.#container.canvas.size.width,
5439
5462
  setCb: (value) => (pos.x += value),
5440
5463
  radius,
5441
5464
  });
5442
5465
  };
5443
- _fixVertical = (pos, radius, outMode) => {
5466
+ #fixVertical = (pos, radius, outMode) => {
5444
5467
  fixOutMode({
5445
5468
  outMode,
5446
5469
  checkModes: [OutMode.bounce],
5447
5470
  coord: pos.y,
5448
- maxCoord: this._container.canvas.size.height,
5471
+ maxCoord: this.#container.canvas.size.height,
5449
5472
  setCb: (value) => (pos.y += value),
5450
5473
  radius,
5451
5474
  });
5452
5475
  };
5453
- _getRollColor = color => {
5476
+ #getDefaultInsideCanvasResult = (direction, outMode) => {
5477
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
5478
+ if (direction === OutModeDirection.bottom) {
5479
+ return {
5480
+ inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
5481
+ reason: "default",
5482
+ };
5483
+ }
5484
+ if (direction === OutModeDirection.left) {
5485
+ return {
5486
+ inside: isBounce ? position.x - radius > defaultAngle : position.x + radius > defaultAngle,
5487
+ reason: "default",
5488
+ };
5489
+ }
5490
+ if (direction === OutModeDirection.right) {
5491
+ return {
5492
+ inside: isBounce ? position.x + radius < canvasSize.width : position.x - radius < canvasSize.width,
5493
+ reason: "default",
5494
+ };
5495
+ }
5496
+ if (direction === OutModeDirection.top) {
5497
+ return {
5498
+ inside: isBounce ? position.y - radius > defaultAngle : position.y + radius > defaultAngle,
5499
+ reason: "default",
5500
+ };
5501
+ }
5502
+ return {
5503
+ inside: position.x >= -radius &&
5504
+ position.y >= -radius &&
5505
+ position.y <= canvasSize.height + radius &&
5506
+ position.x <= canvasSize.width + radius,
5507
+ reason: "default",
5508
+ };
5509
+ };
5510
+ #getInsideCanvasCallbackData = (direction, outMode) => {
5511
+ return {
5512
+ canvasSize: this.#container.canvas.size,
5513
+ direction,
5514
+ outMode,
5515
+ particle: this,
5516
+ radius: this.getRadius(),
5517
+ };
5518
+ };
5519
+ #getInsideCanvasResult = (data) => {
5520
+ 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;
5521
+ if (!shapeCheck && !effectCheck) {
5522
+ return defaultResult;
5523
+ }
5524
+ const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
5525
+ if (shapeResult && effectResult) {
5526
+ const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
5527
+ return {
5528
+ inside: shapeResult.inside && effectResult.inside,
5529
+ margin: margin > defaultAngle ? margin : undefined,
5530
+ reason: "combined",
5531
+ };
5532
+ }
5533
+ return shapeResult ?? effectResult ?? defaultResult;
5534
+ };
5535
+ #getRollColor = color => {
5454
5536
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
5455
5537
  return color;
5456
5538
  }
@@ -5465,8 +5547,8 @@
5465
5547
  }
5466
5548
  return color;
5467
5549
  };
5468
- _initPosition = position => {
5469
- const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5550
+ #initPosition = position => {
5551
+ const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5470
5552
  if (!initialPosition) {
5471
5553
  throw new Error("a valid position cannot be found for particle");
5472
5554
  }
@@ -5489,45 +5571,58 @@
5489
5571
  }
5490
5572
  this.offset = Vector.origin;
5491
5573
  };
5574
+ #normalizeInsideCanvasResult = (result, reason) => {
5575
+ if (typeof result === "boolean") {
5576
+ return {
5577
+ inside: result,
5578
+ reason,
5579
+ };
5580
+ }
5581
+ return {
5582
+ inside: result.inside,
5583
+ margin: result.margin,
5584
+ reason: result.reason ?? reason,
5585
+ };
5586
+ };
5492
5587
  }
5493
5588
 
5494
5589
  class SpatialHashGrid {
5495
- _cellSize;
5496
- _cells = new Map();
5497
- _circlePool = [];
5498
- _circlePoolIdx;
5499
- _pendingCellSize;
5500
- _rectanglePool = [];
5501
- _rectanglePoolIdx;
5590
+ #cellSize;
5591
+ #cells = new Map();
5592
+ #circlePool = [];
5593
+ #circlePoolIdx;
5594
+ #pendingCellSize;
5595
+ #rectanglePool = [];
5596
+ #rectanglePoolIdx;
5502
5597
  constructor(cellSize) {
5503
- this._cellSize = cellSize;
5504
- this._circlePoolIdx = 0;
5505
- this._rectanglePoolIdx = 0;
5598
+ this.#cellSize = cellSize;
5599
+ this.#circlePoolIdx = 0;
5600
+ this.#rectanglePoolIdx = 0;
5506
5601
  }
5507
5602
  clear() {
5508
- this._cells.clear();
5509
- const pendingCellSize = this._pendingCellSize;
5603
+ this.#cells.clear();
5604
+ const pendingCellSize = this.#pendingCellSize;
5510
5605
  if (pendingCellSize) {
5511
- this._cellSize = pendingCellSize;
5606
+ this.#cellSize = pendingCellSize;
5512
5607
  }
5513
- this._pendingCellSize = undefined;
5608
+ this.#pendingCellSize = undefined;
5514
5609
  }
5515
5610
  insert(particle) {
5516
- const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
5517
- if (!this._cells.has(key)) {
5518
- this._cells.set(key, []);
5611
+ const { x, y } = particle.getPosition(), key = this.#cellKeyFromCoords(x, y);
5612
+ if (!this.#cells.has(key)) {
5613
+ this.#cells.set(key, []);
5519
5614
  }
5520
- this._cells.get(key)?.push(particle);
5615
+ this.#cells.get(key)?.push(particle);
5521
5616
  }
5522
5617
  query(range, check, out = []) {
5523
- const bounds = this._getRangeBounds(range);
5618
+ const bounds = this.#getRangeBounds(range);
5524
5619
  if (!bounds) {
5525
5620
  return out;
5526
5621
  }
5527
- 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);
5622
+ 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);
5528
5623
  for (let cx = minCellX; cx <= maxCellX; cx++) {
5529
5624
  for (let cy = minCellY; cy <= maxCellY; cy++) {
5530
- const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
5625
+ const key = `${cx}_${cy}`, cellParticles = this.#cells.get(key);
5531
5626
  if (!cellParticles) {
5532
5627
  continue;
5533
5628
  }
@@ -5544,29 +5639,29 @@
5544
5639
  return out;
5545
5640
  }
5546
5641
  queryCircle(position, radius, check, out = []) {
5547
- const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5548
- this._releaseShapes();
5642
+ const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5643
+ this.#releaseShapes();
5549
5644
  return result;
5550
5645
  }
5551
5646
  queryRectangle(position, size, check, out = []) {
5552
- const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5553
- this._releaseShapes();
5647
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5648
+ this.#releaseShapes();
5554
5649
  return result;
5555
5650
  }
5556
5651
  setCellSize(cellSize) {
5557
- this._pendingCellSize = cellSize;
5652
+ this.#pendingCellSize = cellSize;
5558
5653
  }
5559
- _acquireCircle(x, y, r) {
5560
- return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5654
+ #acquireCircle(x, y, r) {
5655
+ return (this.#circlePool[this.#circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5561
5656
  }
5562
- _acquireRectangle(x, y, w, h) {
5563
- return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5657
+ #acquireRectangle(x, y, w, h) {
5658
+ return (this.#rectanglePool[this.#rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5564
5659
  }
5565
- _cellKeyFromCoords(x, y) {
5566
- const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
5660
+ #cellKeyFromCoords(x, y) {
5661
+ const cellX = Math.floor(x / this.#cellSize), cellY = Math.floor(y / this.#cellSize);
5567
5662
  return `${cellX}_${cellY}`;
5568
5663
  }
5569
- _getRangeBounds(range) {
5664
+ #getRangeBounds(range) {
5570
5665
  if (range instanceof Circle) {
5571
5666
  const r = range.radius, { x, y } = range.position;
5572
5667
  return {
@@ -5587,53 +5682,53 @@
5587
5682
  }
5588
5683
  return null;
5589
5684
  }
5590
- _releaseShapes() {
5591
- this._circlePoolIdx = 0;
5592
- this._rectanglePoolIdx = 0;
5685
+ #releaseShapes() {
5686
+ this.#circlePoolIdx = 0;
5687
+ this.#rectanglePoolIdx = 0;
5593
5688
  }
5594
5689
  }
5595
5690
 
5596
5691
  class ParticlesManager {
5597
5692
  checkParticlePositionPlugins;
5598
5693
  grid;
5599
- _array;
5600
- _container;
5601
- _groupLimits;
5602
- _limit;
5603
- _nextId;
5604
- _particleBuckets;
5605
- _particleResetPlugins;
5606
- _particleUpdatePlugins;
5607
- _pluginManager;
5608
- _pool;
5609
- _postParticleUpdatePlugins;
5610
- _postUpdatePlugins;
5611
- _resizeFactor;
5612
- _updatePlugins;
5613
- _zBuckets;
5694
+ #array;
5695
+ #container;
5696
+ #groupLimits;
5697
+ #limit;
5698
+ #nextId;
5699
+ #particleBuckets;
5700
+ #particleResetPlugins;
5701
+ #particleUpdatePlugins;
5702
+ #pluginManager;
5703
+ #pool;
5704
+ #postParticleUpdatePlugins;
5705
+ #postUpdatePlugins;
5706
+ #resizeFactor;
5707
+ #updatePlugins;
5708
+ #zBuckets;
5614
5709
  constructor(pluginManager, container) {
5615
- this._pluginManager = pluginManager;
5616
- this._container = container;
5617
- this._nextId = 0;
5618
- this._array = [];
5619
- this._pool = [];
5620
- this._limit = 0;
5621
- this._groupLimits = new Map();
5622
- this._particleBuckets = new Map();
5623
- this._zBuckets = this._createBuckets(this._container.zLayers);
5710
+ this.#pluginManager = pluginManager;
5711
+ this.#container = container;
5712
+ this.#nextId = 0;
5713
+ this.#array = [];
5714
+ this.#pool = [];
5715
+ this.#limit = 0;
5716
+ this.#groupLimits = new Map();
5717
+ this.#particleBuckets = new Map();
5718
+ this.#zBuckets = this.#createBuckets(this.#container.zLayers);
5624
5719
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
5625
5720
  this.checkParticlePositionPlugins = [];
5626
- this._particleResetPlugins = [];
5627
- this._particleUpdatePlugins = [];
5628
- this._postUpdatePlugins = [];
5629
- this._postParticleUpdatePlugins = [];
5630
- this._updatePlugins = [];
5721
+ this.#particleResetPlugins = [];
5722
+ this.#particleUpdatePlugins = [];
5723
+ this.#postUpdatePlugins = [];
5724
+ this.#postParticleUpdatePlugins = [];
5725
+ this.#updatePlugins = [];
5631
5726
  }
5632
5727
  get count() {
5633
- return this._array.length;
5728
+ return this.#array.length;
5634
5729
  }
5635
5730
  addParticle(position, overrideOptions, group, initializer) {
5636
- const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
5731
+ const limitMode = this.#container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this.#limit : (this.#groupLimits.get(group) ?? this.#limit), currentCount = this.count;
5637
5732
  if (limit > minLimit) {
5638
5733
  switch (limitMode) {
5639
5734
  case LimitMode.delete: {
@@ -5651,20 +5746,20 @@
5651
5746
  }
5652
5747
  }
5653
5748
  try {
5654
- const particle = this._pool.pop() ?? new Particle(this._pluginManager, this._container);
5655
- particle.init(this._nextId, position, overrideOptions, group);
5749
+ const particle = this.#pool.pop() ?? new Particle(this.#pluginManager, this.#container);
5750
+ particle.init(this.#nextId, position, overrideOptions, group);
5656
5751
  let canAdd = true;
5657
5752
  if (initializer) {
5658
5753
  canAdd = initializer(particle);
5659
5754
  }
5660
5755
  if (!canAdd) {
5661
- this._pool.push(particle);
5756
+ this.#pool.push(particle);
5662
5757
  return;
5663
5758
  }
5664
- this._array.push(particle);
5665
- this._insertParticleIntoBucket(particle);
5666
- this._nextId++;
5667
- this._container.dispatchEvent(EventType.particleAdded, {
5759
+ this.#array.push(particle);
5760
+ this.#insertParticleIntoBucket(particle);
5761
+ this.#nextId++;
5762
+ this.#container.dispatchEvent(EventType.particleAdded, {
5668
5763
  particle,
5669
5764
  });
5670
5765
  return particle;
@@ -5675,25 +5770,25 @@
5675
5770
  return undefined;
5676
5771
  }
5677
5772
  clear() {
5678
- this._array = [];
5679
- this._particleBuckets.clear();
5680
- this._resetBuckets(this._container.zLayers);
5773
+ this.#array = [];
5774
+ this.#particleBuckets.clear();
5775
+ this.#resetBuckets(this.#container.zLayers);
5681
5776
  }
5682
5777
  destroy() {
5683
- this._array = [];
5684
- this._pool.length = 0;
5685
- this._particleBuckets.clear();
5686
- this._zBuckets = [];
5778
+ this.#array = [];
5779
+ this.#pool.length = 0;
5780
+ this.#particleBuckets.clear();
5781
+ this.#zBuckets = [];
5687
5782
  this.checkParticlePositionPlugins = [];
5688
- this._particleResetPlugins = [];
5689
- this._particleUpdatePlugins = [];
5690
- this._postUpdatePlugins = [];
5691
- this._postParticleUpdatePlugins = [];
5692
- this._updatePlugins = [];
5783
+ this.#particleResetPlugins = [];
5784
+ this.#particleUpdatePlugins = [];
5785
+ this.#postUpdatePlugins = [];
5786
+ this.#postParticleUpdatePlugins = [];
5787
+ this.#updatePlugins = [];
5693
5788
  }
5694
5789
  drawParticles(delta) {
5695
- for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
5696
- const bucket = this._zBuckets[i];
5790
+ for (let i = this.#zBuckets.length - one; i >= minIndex; i--) {
5791
+ const bucket = this.#zBuckets[i];
5697
5792
  if (!bucket) {
5698
5793
  continue;
5699
5794
  }
@@ -5703,24 +5798,24 @@
5703
5798
  }
5704
5799
  }
5705
5800
  filter(condition) {
5706
- return this._array.filter(condition);
5801
+ return this.#array.filter(condition);
5707
5802
  }
5708
5803
  find(condition) {
5709
- return this._array.find(condition);
5804
+ return this.#array.find(condition);
5710
5805
  }
5711
5806
  get(index) {
5712
- return this._array[index];
5807
+ return this.#array[index];
5713
5808
  }
5714
5809
  async init() {
5715
- const container = this._container, options = container.actualOptions;
5810
+ const container = this.#container, options = container.actualOptions;
5716
5811
  this.checkParticlePositionPlugins = [];
5717
- this._updatePlugins = [];
5718
- this._particleUpdatePlugins = [];
5719
- this._postUpdatePlugins = [];
5720
- this._particleResetPlugins = [];
5721
- this._postParticleUpdatePlugins = [];
5722
- this._particleBuckets.clear();
5723
- this._resetBuckets(container.zLayers);
5812
+ this.#updatePlugins = [];
5813
+ this.#particleUpdatePlugins = [];
5814
+ this.#postUpdatePlugins = [];
5815
+ this.#particleResetPlugins = [];
5816
+ this.#postParticleUpdatePlugins = [];
5817
+ this.#particleBuckets.clear();
5818
+ this.#resetBuckets(container.zLayers);
5724
5819
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
5725
5820
  for (const plugin of container.plugins) {
5726
5821
  if (plugin.redrawInit) {
@@ -5730,26 +5825,26 @@
5730
5825
  this.checkParticlePositionPlugins.push(plugin);
5731
5826
  }
5732
5827
  if (plugin.update) {
5733
- this._updatePlugins.push(plugin);
5828
+ this.#updatePlugins.push(plugin);
5734
5829
  }
5735
5830
  if (plugin.particleUpdate) {
5736
- this._particleUpdatePlugins.push(plugin);
5831
+ this.#particleUpdatePlugins.push(plugin);
5737
5832
  }
5738
5833
  if (plugin.postUpdate) {
5739
- this._postUpdatePlugins.push(plugin);
5834
+ this.#postUpdatePlugins.push(plugin);
5740
5835
  }
5741
5836
  if (plugin.particleReset) {
5742
- this._particleResetPlugins.push(plugin);
5837
+ this.#particleResetPlugins.push(plugin);
5743
5838
  }
5744
5839
  if (plugin.postParticleUpdate) {
5745
- this._postParticleUpdatePlugins.push(plugin);
5840
+ this.#postParticleUpdatePlugins.push(plugin);
5746
5841
  }
5747
5842
  }
5748
- await this._container.initDrawersAndUpdaters();
5749
- for (const drawer of this._container.effectDrawers.values()) {
5843
+ await this.#container.initDrawersAndUpdaters();
5844
+ for (const drawer of this.#container.effectDrawers.values()) {
5750
5845
  await drawer.init?.(container);
5751
5846
  }
5752
- for (const drawer of this._container.shapeDrawers.values()) {
5847
+ for (const drawer of this.#container.shapeDrawers.values()) {
5753
5848
  await drawer.init?.(container);
5754
5849
  }
5755
5850
  let handled = false;
@@ -5783,10 +5878,10 @@
5783
5878
  async redraw() {
5784
5879
  this.clear();
5785
5880
  await this.init();
5786
- this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
5881
+ this.#container.canvas.render.drawParticles({ value: 0, factor: 0 });
5787
5882
  }
5788
5883
  remove(particle, group, override) {
5789
- this.removeAt(this._array.indexOf(particle), undefined, group, override);
5884
+ this.removeAt(this.#array.indexOf(particle), undefined, group, override);
5790
5885
  }
5791
5886
  removeAt(index, quantity = defaultRemoveQuantity, group, override) {
5792
5887
  if (index < minIndex || index > this.count) {
@@ -5794,7 +5889,7 @@
5794
5889
  }
5795
5890
  let deleted = 0;
5796
5891
  for (let i = index; deleted < quantity && i < this.count; i++) {
5797
- if (this._removeParticle(i, group, override)) {
5892
+ if (this.#removeParticle(i, group, override)) {
5798
5893
  i--;
5799
5894
  deleted++;
5800
5895
  }
@@ -5804,9 +5899,9 @@
5804
5899
  this.removeAt(minIndex, quantity, group);
5805
5900
  }
5806
5901
  setDensity() {
5807
- const options = this._container.actualOptions, groups = options.particles.groups;
5902
+ const options = this.#container.actualOptions, groups = options.particles.groups;
5808
5903
  let pluginsCount = 0;
5809
- for (const plugin of this._container.plugins) {
5904
+ for (const plugin of this.#container.plugins) {
5810
5905
  if (plugin.particlesDensityCount) {
5811
5906
  pluginsCount += plugin.particlesDensityCount();
5812
5907
  }
@@ -5816,51 +5911,51 @@
5816
5911
  if (!groupData) {
5817
5912
  continue;
5818
5913
  }
5819
- const groupDataOptions = loadParticlesOptions(this._pluginManager, this._container, groupData);
5820
- this._applyDensity(groupDataOptions, pluginsCount, group);
5914
+ const groupDataOptions = loadParticlesOptions(this.#pluginManager, this.#container, groupData);
5915
+ this.#applyDensity(groupDataOptions, pluginsCount, group);
5821
5916
  }
5822
- this._applyDensity(options.particles, pluginsCount);
5917
+ this.#applyDensity(options.particles, pluginsCount);
5823
5918
  }
5824
5919
  setResizeFactor(factor) {
5825
- this._resizeFactor = factor;
5920
+ this.#resizeFactor = factor;
5826
5921
  }
5827
5922
  update(delta) {
5828
5923
  this.grid.clear();
5829
- for (const plugin of this._updatePlugins) {
5924
+ for (const plugin of this.#updatePlugins) {
5830
5925
  plugin.update?.(delta);
5831
5926
  }
5832
- const particlesToDelete = this._updateParticlesPhase1(delta);
5833
- for (const plugin of this._postUpdatePlugins) {
5927
+ const particlesToDelete = this.#updateParticlesPhase1(delta);
5928
+ for (const plugin of this.#postUpdatePlugins) {
5834
5929
  plugin.postUpdate?.(delta);
5835
5930
  }
5836
- this._updateParticlesPhase2(delta, particlesToDelete);
5931
+ this.#updateParticlesPhase2(delta, particlesToDelete);
5837
5932
  if (particlesToDelete.size) {
5838
5933
  for (const particle of particlesToDelete) {
5839
5934
  this.remove(particle);
5840
5935
  }
5841
5936
  }
5842
- delete this._resizeFactor;
5937
+ this.#resizeFactor = undefined;
5843
5938
  }
5844
- _addToPool = (...particles) => {
5845
- this._pool.push(...particles);
5939
+ #addToPool = (...particles) => {
5940
+ this.#pool.push(...particles);
5846
5941
  };
5847
- _applyDensity = (options, pluginsCount, group, groupOptions) => {
5942
+ #applyDensity = (options, pluginsCount, group, groupOptions) => {
5848
5943
  const numberOptions = options.number;
5849
5944
  if (!numberOptions.density.enable) {
5850
5945
  if (group === undefined) {
5851
- this._limit = numberOptions.limit.value;
5946
+ this.#limit = numberOptions.limit.value;
5852
5947
  }
5853
5948
  else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
5854
- this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5949
+ this.#groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5855
5950
  }
5856
5951
  return;
5857
5952
  }
5858
- 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);
5953
+ 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);
5859
5954
  if (group === undefined) {
5860
- this._limit = numberOptions.limit.value * densityFactor;
5955
+ this.#limit = numberOptions.limit.value * densityFactor;
5861
5956
  }
5862
5957
  else {
5863
- this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
5958
+ this.#groupLimits.set(group, numberOptions.limit.value * densityFactor);
5864
5959
  }
5865
5960
  if (particlesCount < particlesNumber) {
5866
5961
  this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
@@ -5869,18 +5964,18 @@
5869
5964
  this.removeQuantity(particlesCount - particlesNumber, group);
5870
5965
  }
5871
5966
  };
5872
- _createBuckets = (zLayers) => {
5967
+ #createBuckets = (zLayers) => {
5873
5968
  const bucketCount = Math.max(Math.floor(zLayers), one);
5874
5969
  return Array.from({ length: bucketCount }, () => []);
5875
5970
  };
5876
- _getBucketIndex = (zIndex) => {
5877
- const maxBucketIndex = this._zBuckets.length - one;
5971
+ #getBucketIndex = (zIndex) => {
5972
+ const maxBucketIndex = this.#zBuckets.length - one;
5878
5973
  if (maxBucketIndex <= minIndex) {
5879
5974
  return minIndex;
5880
5975
  }
5881
5976
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
5882
5977
  };
5883
- _getParticleInsertIndex = (bucket, particleId) => {
5978
+ #getParticleInsertIndex = (bucket, particleId) => {
5884
5979
  let start = minIndex, end = bucket.length;
5885
5980
  while (start < end) {
5886
5981
  const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
@@ -5897,8 +5992,8 @@
5897
5992
  }
5898
5993
  return start;
5899
5994
  };
5900
- _initDensityFactor = densityOptions => {
5901
- const container = this._container;
5995
+ #initDensityFactor = densityOptions => {
5996
+ const container = this.#container;
5902
5997
  if (!densityOptions.enable) {
5903
5998
  return defaultDensityFactor;
5904
5999
  }
@@ -5908,82 +6003,82 @@
5908
6003
  }
5909
6004
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
5910
6005
  };
5911
- _insertParticleIntoBucket = (particle) => {
5912
- const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
6006
+ #insertParticleIntoBucket = (particle) => {
6007
+ const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5913
6008
  if (!bucket) {
5914
6009
  return;
5915
6010
  }
5916
- bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
5917
- this._particleBuckets.set(particle.id, bucketIndex);
6011
+ bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
6012
+ this.#particleBuckets.set(particle.id, bucketIndex);
5918
6013
  };
5919
- _removeParticle = (index, group, override) => {
5920
- const particle = this._array[index];
6014
+ #removeParticle = (index, group, override) => {
6015
+ const particle = this.#array[index];
5921
6016
  if (!particle) {
5922
6017
  return false;
5923
6018
  }
5924
6019
  if (particle.group !== group) {
5925
6020
  return false;
5926
6021
  }
5927
- this._array.splice(index, deleteCount);
5928
- this._removeParticleFromBucket(particle);
6022
+ this.#array.splice(index, deleteCount);
6023
+ this.#removeParticleFromBucket(particle);
5929
6024
  particle.destroy(override);
5930
- this._container.dispatchEvent(EventType.particleRemoved, {
6025
+ this.#container.dispatchEvent(EventType.particleRemoved, {
5931
6026
  particle,
5932
6027
  });
5933
- this._addToPool(particle);
6028
+ this.#addToPool(particle);
5934
6029
  return true;
5935
6030
  };
5936
- _removeParticleFromBucket = (particle) => {
5937
- const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
6031
+ #removeParticleFromBucket = (particle) => {
6032
+ const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5938
6033
  if (!bucket) {
5939
- this._particleBuckets.delete(particle.id);
6034
+ this.#particleBuckets.delete(particle.id);
5940
6035
  return;
5941
6036
  }
5942
- const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
6037
+ const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
5943
6038
  if (bucket[particleIndex]?.id !== particle.id) {
5944
- this._particleBuckets.delete(particle.id);
6039
+ this.#particleBuckets.delete(particle.id);
5945
6040
  return;
5946
6041
  }
5947
6042
  bucket.splice(particleIndex, deleteCount);
5948
- this._particleBuckets.delete(particle.id);
6043
+ this.#particleBuckets.delete(particle.id);
5949
6044
  };
5950
- _resetBuckets = (zLayers) => {
6045
+ #resetBuckets = (zLayers) => {
5951
6046
  const bucketCount = Math.max(Math.floor(zLayers), one);
5952
- if (this._zBuckets.length !== bucketCount) {
5953
- this._zBuckets = this._createBuckets(bucketCount);
6047
+ if (this.#zBuckets.length !== bucketCount) {
6048
+ this.#zBuckets = this.#createBuckets(bucketCount);
5954
6049
  return;
5955
6050
  }
5956
- for (const bucket of this._zBuckets) {
6051
+ for (const bucket of this.#zBuckets) {
5957
6052
  bucket.length = minIndex;
5958
6053
  }
5959
6054
  };
5960
- _updateParticleBucket = (particle) => {
5961
- const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
6055
+ #updateParticleBucket = (particle) => {
6056
+ const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
5962
6057
  if (currentBucketIndex === undefined) {
5963
- this._insertParticleIntoBucket(particle);
6058
+ this.#insertParticleIntoBucket(particle);
5964
6059
  return;
5965
6060
  }
5966
6061
  if (currentBucketIndex === newBucketIndex) {
5967
6062
  return;
5968
6063
  }
5969
- const currentBucket = this._zBuckets[currentBucketIndex];
6064
+ const currentBucket = this.#zBuckets[currentBucketIndex];
5970
6065
  if (currentBucket) {
5971
- const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
6066
+ const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
5972
6067
  if (currentBucket[particleIndex]?.id === particle.id) {
5973
6068
  currentBucket.splice(particleIndex, deleteCount);
5974
6069
  }
5975
6070
  }
5976
- const newBucket = this._zBuckets[newBucketIndex];
6071
+ const newBucket = this.#zBuckets[newBucketIndex];
5977
6072
  if (!newBucket) {
5978
- this._particleBuckets.set(particle.id, newBucketIndex);
6073
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5979
6074
  return;
5980
6075
  }
5981
- newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
5982
- this._particleBuckets.set(particle.id, newBucketIndex);
6076
+ newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
6077
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5983
6078
  };
5984
- _updateParticlesPhase1 = (delta) => {
5985
- const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
5986
- for (const particle of this._array) {
6079
+ #updateParticlesPhase1 = (delta) => {
6080
+ const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
6081
+ for (const particle of this.#array) {
5987
6082
  if (resizeFactor && !particle.ignoresResizeRatio) {
5988
6083
  particle.position.x *= resizeFactor.width;
5989
6084
  particle.position.y *= resizeFactor.height;
@@ -5991,10 +6086,10 @@
5991
6086
  particle.initialPosition.y *= resizeFactor.height;
5992
6087
  }
5993
6088
  particle.ignoresResizeRatio = false;
5994
- for (const plugin of this._particleResetPlugins) {
6089
+ for (const plugin of this.#particleResetPlugins) {
5995
6090
  plugin.particleReset?.(particle);
5996
6091
  }
5997
- for (const plugin of this._particleUpdatePlugins) {
6092
+ for (const plugin of this.#particleUpdatePlugins) {
5998
6093
  if (particle.destroyed) {
5999
6094
  break;
6000
6095
  }
@@ -6008,36 +6103,36 @@
6008
6103
  }
6009
6104
  return particlesToDelete;
6010
6105
  };
6011
- _updateParticlesPhase2 = (delta, particlesToDelete) => {
6012
- for (const particle of this._array) {
6106
+ #updateParticlesPhase2 = (delta, particlesToDelete) => {
6107
+ for (const particle of this.#array) {
6013
6108
  if (particle.destroyed) {
6014
6109
  particlesToDelete.add(particle);
6015
6110
  continue;
6016
6111
  }
6017
- for (const updater of this._container.particleUpdaters) {
6112
+ for (const updater of this.#container.particleUpdaters) {
6018
6113
  updater.update(particle, delta);
6019
6114
  }
6020
6115
  if (!particle.spawning) {
6021
- for (const plugin of this._postParticleUpdatePlugins) {
6116
+ for (const plugin of this.#postParticleUpdatePlugins) {
6022
6117
  plugin.postParticleUpdate?.(particle, delta);
6023
6118
  }
6024
6119
  }
6025
- this._updateParticleBucket(particle);
6120
+ this.#updateParticleBucket(particle);
6026
6121
  }
6027
6122
  };
6028
6123
  }
6029
6124
 
6030
6125
  class Retina {
6031
- container;
6032
6126
  pixelRatio;
6033
6127
  reduceFactor;
6128
+ #container;
6034
6129
  constructor(container) {
6035
- this.container = container;
6130
+ this.#container = container;
6036
6131
  this.pixelRatio = defaultRatio;
6037
6132
  this.reduceFactor = defaultReduceFactor;
6038
6133
  }
6039
6134
  init() {
6040
- const container = this.container, options = container.actualOptions;
6135
+ const container = this.#container, options = container.actualOptions;
6041
6136
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
6042
6137
  this.reduceFactor = defaultReduceFactor;
6043
6138
  const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
@@ -6051,7 +6146,6 @@
6051
6146
  props.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
6052
6147
  props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
6053
6148
  props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
6054
- props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
6055
6149
  const maxDistance = props.maxDistance;
6056
6150
  maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
6057
6151
  maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
@@ -6089,73 +6183,73 @@
6089
6183
  shapeDrawers;
6090
6184
  started;
6091
6185
  zLayers;
6092
- _delay;
6093
- _delayTimeout;
6094
- _delta = { value: 0, factor: 0 };
6095
- _dispatchCallback;
6096
- _drawAnimationFrame;
6097
- _duration;
6098
- _eventListeners;
6099
- _firstStart;
6100
- _initialSourceOptions;
6101
- _lastFrameTime;
6102
- _lifeTime;
6103
- _onDestroy;
6104
- _options;
6105
- _paused;
6106
- _pluginManager;
6107
- _smooth;
6108
- _sourceOptions;
6186
+ #delay;
6187
+ #delayTimeout;
6188
+ #delta = { value: 0, factor: 0 };
6189
+ #dispatchCallback;
6190
+ #drawAnimationFrame;
6191
+ #duration;
6192
+ #eventListeners;
6193
+ #firstStart;
6194
+ #initialSourceOptions;
6195
+ #lastFrameTime;
6196
+ #lifeTime;
6197
+ #onDestroy;
6198
+ #options;
6199
+ #paused;
6200
+ #pluginManager;
6201
+ #smooth;
6202
+ #sourceOptions;
6109
6203
  constructor(params) {
6110
6204
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
6111
- this._pluginManager = pluginManager;
6112
- this._dispatchCallback = dispatchCallback;
6113
- this._onDestroy = onDestroy;
6205
+ this.#pluginManager = pluginManager;
6206
+ this.#dispatchCallback = dispatchCallback;
6207
+ this.#onDestroy = onDestroy;
6114
6208
  this.id = Symbol(id);
6115
6209
  this.fpsLimit = 120;
6116
6210
  this.hdr = false;
6117
- this._smooth = false;
6118
- this._delay = 0;
6119
- this._duration = 0;
6120
- this._lifeTime = 0;
6121
- this._firstStart = true;
6211
+ this.#smooth = false;
6212
+ this.#delay = 0;
6213
+ this.#duration = 0;
6214
+ this.#lifeTime = 0;
6215
+ this.#firstStart = true;
6122
6216
  this.started = false;
6123
6217
  this.destroyed = false;
6124
- this._paused = true;
6125
- this._lastFrameTime = 0;
6218
+ this.#paused = true;
6219
+ this.#lastFrameTime = 0;
6126
6220
  this.zLayers = 100;
6127
6221
  this.pageHidden = false;
6128
- this._sourceOptions = sourceOptions;
6129
- this._initialSourceOptions = sourceOptions;
6222
+ this.#sourceOptions = sourceOptions;
6223
+ this.#initialSourceOptions = sourceOptions;
6130
6224
  this.effectDrawers = new Map();
6131
6225
  this.shapeDrawers = new Map();
6132
6226
  this.particleUpdaters = [];
6133
6227
  this.retina = new Retina(this);
6134
- this.canvas = new CanvasManager(this._pluginManager, this);
6135
- this.particles = new ParticlesManager(this._pluginManager, this);
6228
+ this.canvas = new CanvasManager(this.#pluginManager, this);
6229
+ this.particles = new ParticlesManager(this.#pluginManager, this);
6136
6230
  this.plugins = [];
6137
6231
  this.particleDestroyedPlugins = [];
6138
6232
  this.particleCreatedPlugins = [];
6139
6233
  this.particlePositionPlugins = [];
6140
- this._options = loadContainerOptions(this._pluginManager, this);
6141
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
6142
- this._eventListeners = new EventListeners(this);
6234
+ this.#options = loadContainerOptions(this.#pluginManager, this);
6235
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
6236
+ this.#eventListeners = new EventListeners(this);
6143
6237
  this.dispatchEvent(EventType.containerBuilt);
6144
6238
  }
6145
6239
  get animationStatus() {
6146
- return !this._paused && !this.pageHidden && guardCheck(this);
6240
+ return !this.#paused && !this.pageHidden && guardCheck(this);
6147
6241
  }
6148
6242
  get options() {
6149
- return this._options;
6243
+ return this.#options;
6150
6244
  }
6151
6245
  get sourceOptions() {
6152
- return this._sourceOptions;
6246
+ return this.#sourceOptions;
6153
6247
  }
6154
6248
  addLifeTime(value) {
6155
- this._lifeTime += value;
6249
+ this.#lifeTime += value;
6156
6250
  }
6157
6251
  alive() {
6158
- return !this._duration || this._lifeTime <= this._duration;
6252
+ return !this.#duration || this.#lifeTime <= this.#duration;
6159
6253
  }
6160
6254
  destroy(remove = true) {
6161
6255
  if (!guardCheck(this)) {
@@ -6177,13 +6271,13 @@
6177
6271
  this.shapeDrawers = new Map();
6178
6272
  this.particleUpdaters = [];
6179
6273
  this.plugins.length = 0;
6180
- this._pluginManager.clearPlugins(this);
6274
+ this.#pluginManager.clearPlugins(this);
6181
6275
  this.destroyed = true;
6182
- this._onDestroy(remove);
6276
+ this.#onDestroy(remove);
6183
6277
  this.dispatchEvent(EventType.containerDestroyed);
6184
6278
  }
6185
6279
  dispatchEvent(type, data) {
6186
- this._dispatchCallback(type, {
6280
+ this.#dispatchCallback(type, {
6187
6281
  container: this,
6188
6282
  data,
6189
6283
  });
@@ -6193,12 +6287,12 @@
6193
6287
  return;
6194
6288
  }
6195
6289
  let refreshTime = force;
6196
- this._drawAnimationFrame = animate((timestamp) => {
6290
+ this.#drawAnimationFrame = animate((timestamp) => {
6197
6291
  if (refreshTime) {
6198
- this._lastFrameTime = undefined;
6292
+ this.#lastFrameTime = undefined;
6199
6293
  refreshTime = false;
6200
6294
  }
6201
- this._nextFrame(timestamp);
6295
+ this.#nextFrame(timestamp);
6202
6296
  });
6203
6297
  }
6204
6298
  async export(type, options = {}) {
@@ -6220,7 +6314,7 @@
6220
6314
  return;
6221
6315
  }
6222
6316
  const allContainerPlugins = new Map();
6223
- for (const plugin of this._pluginManager.plugins) {
6317
+ for (const plugin of this.#pluginManager.plugins) {
6224
6318
  const containerPlugin = await plugin.getPlugin(this);
6225
6319
  if (containerPlugin.preInit) {
6226
6320
  await containerPlugin.preInit();
@@ -6228,8 +6322,8 @@
6228
6322
  allContainerPlugins.set(plugin, containerPlugin);
6229
6323
  }
6230
6324
  await this.initDrawersAndUpdaters();
6231
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
6232
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
6325
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
6326
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
6233
6327
  this.plugins.length = 0;
6234
6328
  this.particleDestroyedPlugins.length = 0;
6235
6329
  this.particleCreatedPlugins.length = 0;
@@ -6256,11 +6350,11 @@
6256
6350
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
6257
6351
  this.hdr = hdr;
6258
6352
  this.zLayers = zLayers;
6259
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
6260
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
6261
- this._lifeTime = 0;
6353
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
6354
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
6355
+ this.#lifeTime = 0;
6262
6356
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
6263
- this._smooth = smooth;
6357
+ this.#smooth = smooth;
6264
6358
  for (const plugin of this.plugins) {
6265
6359
  await plugin.init?.();
6266
6360
  }
@@ -6273,7 +6367,7 @@
6273
6367
  this.dispatchEvent(EventType.particlesSetup);
6274
6368
  }
6275
6369
  async initDrawersAndUpdaters() {
6276
- const pluginManager = this._pluginManager;
6370
+ const pluginManager = this.#pluginManager;
6277
6371
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
6278
6372
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
6279
6373
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -6282,18 +6376,18 @@
6282
6376
  if (!guardCheck(this)) {
6283
6377
  return;
6284
6378
  }
6285
- if (this._drawAnimationFrame !== undefined) {
6286
- cancelAnimation(this._drawAnimationFrame);
6287
- delete this._drawAnimationFrame;
6379
+ if (this.#drawAnimationFrame !== undefined) {
6380
+ cancelAnimation(this.#drawAnimationFrame);
6381
+ this.#drawAnimationFrame = undefined;
6288
6382
  }
6289
- if (this._paused) {
6383
+ if (this.#paused) {
6290
6384
  return;
6291
6385
  }
6292
6386
  for (const plugin of this.plugins) {
6293
6387
  plugin.pause?.();
6294
6388
  }
6295
6389
  if (!this.pageHidden) {
6296
- this._paused = true;
6390
+ this.#paused = true;
6297
6391
  }
6298
6392
  this.dispatchEvent(EventType.containerPaused);
6299
6393
  }
@@ -6301,13 +6395,13 @@
6301
6395
  if (!guardCheck(this)) {
6302
6396
  return;
6303
6397
  }
6304
- const needsUpdate = this._paused || force;
6305
- if (this._firstStart && !this.actualOptions.autoPlay) {
6306
- this._firstStart = false;
6398
+ const needsUpdate = this.#paused || force;
6399
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
6400
+ this.#firstStart = false;
6307
6401
  return;
6308
6402
  }
6309
- if (this._paused) {
6310
- this._paused = false;
6403
+ if (this.#paused) {
6404
+ this.#paused = false;
6311
6405
  }
6312
6406
  if (needsUpdate) {
6313
6407
  for (const plugin of this.plugins) {
@@ -6330,10 +6424,10 @@
6330
6424
  if (!guardCheck(this)) {
6331
6425
  return;
6332
6426
  }
6333
- this._initialSourceOptions = sourceOptions;
6334
- this._sourceOptions = sourceOptions;
6335
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
6336
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
6427
+ this.#initialSourceOptions = sourceOptions;
6428
+ this.#sourceOptions = sourceOptions;
6429
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
6430
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
6337
6431
  return this.refresh();
6338
6432
  }
6339
6433
  async start() {
@@ -6344,7 +6438,7 @@
6344
6438
  this.started = true;
6345
6439
  await new Promise(resolve => {
6346
6440
  const start = async () => {
6347
- this._eventListeners.addListeners();
6441
+ this.#eventListeners.addListeners();
6348
6442
  for (const plugin of this.plugins) {
6349
6443
  await plugin.start?.();
6350
6444
  }
@@ -6352,20 +6446,20 @@
6352
6446
  this.play();
6353
6447
  resolve();
6354
6448
  };
6355
- this._delayTimeout = setTimeout(() => void start(), this._delay);
6449
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
6356
6450
  });
6357
6451
  }
6358
6452
  stop() {
6359
6453
  if (!guardCheck(this) || !this.started) {
6360
6454
  return;
6361
6455
  }
6362
- if (this._delayTimeout) {
6363
- clearTimeout(this._delayTimeout);
6364
- delete this._delayTimeout;
6456
+ if (this.#delayTimeout) {
6457
+ clearTimeout(this.#delayTimeout);
6458
+ this.#delayTimeout = undefined;
6365
6459
  }
6366
- this._firstStart = true;
6460
+ this.#firstStart = true;
6367
6461
  this.started = false;
6368
- this._eventListeners.removeListeners();
6462
+ this.#eventListeners.removeListeners();
6369
6463
  this.pause();
6370
6464
  this.particles.clear();
6371
6465
  this.canvas.stop();
@@ -6375,7 +6469,7 @@
6375
6469
  this.particleCreatedPlugins.length = 0;
6376
6470
  this.particleDestroyedPlugins.length = 0;
6377
6471
  this.particlePositionPlugins.length = 0;
6378
- this._sourceOptions = this._options;
6472
+ this.#sourceOptions = this.#options;
6379
6473
  this.dispatchEvent(EventType.containerStopped);
6380
6474
  }
6381
6475
  updateActualOptions() {
@@ -6387,23 +6481,23 @@
6387
6481
  }
6388
6482
  return refresh;
6389
6483
  }
6390
- _nextFrame = (timestamp) => {
6484
+ #nextFrame = (timestamp) => {
6391
6485
  try {
6392
- if (!this._smooth &&
6393
- this._lastFrameTime !== undefined &&
6394
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
6486
+ if (!this.#smooth &&
6487
+ this.#lastFrameTime !== undefined &&
6488
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
6395
6489
  this.draw(false);
6396
6490
  return;
6397
6491
  }
6398
- this._lastFrameTime ??= timestamp;
6399
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
6400
- this.addLifeTime(this._delta.value);
6401
- this._lastFrameTime = timestamp;
6402
- if (this._delta.value > millisecondsToSeconds) {
6492
+ this.#lastFrameTime ??= timestamp;
6493
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
6494
+ this.addLifeTime(this.#delta.value);
6495
+ this.#lastFrameTime = timestamp;
6496
+ if (this.#delta.value > millisecondsToSeconds) {
6403
6497
  this.draw(false);
6404
6498
  return;
6405
6499
  }
6406
- this.canvas.render.drawParticles(this._delta);
6500
+ this.canvas.render.drawParticles(this.#delta);
6407
6501
  if (!this.alive()) {
6408
6502
  this.destroy();
6409
6503
  return;
@@ -6424,10 +6518,10 @@
6424
6518
  });
6425
6519
 
6426
6520
  class BlendPluginInstance {
6427
- _container;
6428
- _defaultCompositeValue;
6521
+ #container;
6522
+ #defaultCompositeValue;
6429
6523
  constructor(container) {
6430
- this._container = container;
6524
+ this.#container = container;
6431
6525
  }
6432
6526
  drawParticleCleanup(context, particle) {
6433
6527
  if (!particle.options.blend?.enable) {
@@ -6444,14 +6538,14 @@
6444
6538
  context.globalCompositeOperation = particle.options.blend.mode;
6445
6539
  }
6446
6540
  drawSettingsCleanup(context) {
6447
- if (!this._defaultCompositeValue) {
6541
+ if (!this.#defaultCompositeValue) {
6448
6542
  return;
6449
6543
  }
6450
- context.globalCompositeOperation = this._defaultCompositeValue;
6544
+ context.globalCompositeOperation = this.#defaultCompositeValue;
6451
6545
  }
6452
6546
  drawSettingsSetup(context) {
6453
- const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
6454
- this._defaultCompositeValue = previousComposite;
6547
+ const previousComposite = context.globalCompositeOperation, blend = this.#container.actualOptions.blend;
6548
+ this.#defaultCompositeValue = previousComposite;
6455
6549
  context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
6456
6550
  }
6457
6551
  }
@@ -6594,11 +6688,11 @@
6594
6688
  class MovePluginInstance {
6595
6689
  availablePathGenerators;
6596
6690
  pathGenerators;
6597
- _container;
6598
- _pluginManager;
6691
+ #container;
6692
+ #pluginManager;
6599
6693
  constructor(pluginManager, container) {
6600
- this._pluginManager = pluginManager;
6601
- this._container = container;
6694
+ this.#pluginManager = pluginManager;
6695
+ this.#container = container;
6602
6696
  this.availablePathGenerators = new Map();
6603
6697
  this.pathGenerators = new Map();
6604
6698
  }
@@ -6629,7 +6723,7 @@
6629
6723
  acceleration: getRangeValue(gravityOptions.acceleration),
6630
6724
  inverse: gravityOptions.inverse,
6631
6725
  };
6632
- initSpin(this._container, particle);
6726
+ initSpin(this.#container, particle);
6633
6727
  }
6634
6728
  particleDestroyed(particle) {
6635
6729
  const pathGenerator = particle.pathGenerator;
@@ -6640,7 +6734,7 @@
6640
6734
  if (!moveOptions.enable) {
6641
6735
  return;
6642
6736
  }
6643
- 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;
6737
+ 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;
6644
6738
  if (moveOptions.spin.enable) {
6645
6739
  spin(container, particle, moveSpeed, reduceFactor);
6646
6740
  }
@@ -6650,18 +6744,18 @@
6650
6744
  applyDistance(particle);
6651
6745
  }
6652
6746
  preInit() {
6653
- return this._init();
6747
+ return this.#init();
6654
6748
  }
6655
6749
  redrawInit() {
6656
- return this._init();
6750
+ return this.#init();
6657
6751
  }
6658
6752
  update() {
6659
6753
  for (const pathGenerator of this.pathGenerators.values()) {
6660
6754
  pathGenerator.update();
6661
6755
  }
6662
6756
  }
6663
- async _init() {
6664
- const availablePathGenerators = await this._pluginManager.getPathGenerators?.(this._container, true);
6757
+ async #init() {
6758
+ const availablePathGenerators = await this.#pluginManager.getPathGenerators?.(this.#container, true);
6665
6759
  if (!availablePathGenerators) {
6666
6760
  return;
6667
6761
  }
@@ -6679,44 +6773,44 @@
6679
6773
  });
6680
6774
 
6681
6775
  class EmittersPluginInstance {
6682
- container;
6683
- _instancesManager;
6776
+ #container;
6777
+ #instancesManager;
6684
6778
  constructor(instancesManager, container) {
6685
- this.container = container;
6686
- this._instancesManager = instancesManager;
6687
- this._instancesManager.initContainer(container);
6779
+ this.#instancesManager = instancesManager;
6780
+ this.#container = container;
6781
+ this.#instancesManager.initContainer(container);
6688
6782
  }
6689
6783
  async init() {
6690
- const emittersOptions = this.container.actualOptions.emitters;
6784
+ const emittersOptions = this.#container.actualOptions.emitters;
6691
6785
  if (isArray(emittersOptions)) {
6692
6786
  for (const emitterOptions of emittersOptions) {
6693
- await this._instancesManager.addEmitter(this.container, emitterOptions);
6787
+ await this.#instancesManager.addEmitter(this.#container, emitterOptions);
6694
6788
  }
6695
6789
  }
6696
6790
  else {
6697
- await this._instancesManager.addEmitter(this.container, emittersOptions);
6791
+ await this.#instancesManager.addEmitter(this.#container, emittersOptions);
6698
6792
  }
6699
6793
  }
6700
6794
  pause() {
6701
- for (const emitter of this._instancesManager.getArray(this.container)) {
6795
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
6702
6796
  emitter.pause();
6703
6797
  }
6704
6798
  }
6705
6799
  play() {
6706
- for (const emitter of this._instancesManager.getArray(this.container)) {
6800
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
6707
6801
  emitter.play();
6708
6802
  }
6709
6803
  }
6710
6804
  resize() {
6711
- for (const emitter of this._instancesManager.getArray(this.container)) {
6805
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
6712
6806
  emitter.resize();
6713
6807
  }
6714
6808
  }
6715
6809
  stop() {
6716
- this._instancesManager.clear(this.container);
6810
+ this.#instancesManager.clear(this.#container);
6717
6811
  }
6718
6812
  update(delta) {
6719
- this._instancesManager.getArray(this.container).forEach(emitter => {
6813
+ this.#instancesManager.getArray(this.#container).forEach(emitter => {
6720
6814
  emitter.update(delta);
6721
6815
  });
6722
6816
  }
@@ -6749,16 +6843,16 @@
6749
6843
 
6750
6844
  const defaultIndex = 0;
6751
6845
  class EmittersInstancesManager {
6752
- _containerArrays;
6753
- _pluginManager;
6846
+ #containerArrays;
6847
+ #pluginManager;
6754
6848
  constructor(pluginManager) {
6755
- this._containerArrays = new Map();
6756
- this._pluginManager = pluginManager;
6849
+ this.#containerArrays = new Map();
6850
+ this.#pluginManager = pluginManager;
6757
6851
  }
6758
6852
  async addEmitter(container, options, position) {
6759
6853
  const emitterOptions = new Emitter();
6760
6854
  emitterOptions.load(options);
6761
- const { EmitterInstance } = await Promise.resolve().then(function () { return EmitterInstance$1; }), emitter = new EmitterInstance(this._pluginManager, container, (emitter) => {
6855
+ const { EmitterInstance } = await Promise.resolve().then(function () { return EmitterInstance$1; }), emitter = new EmitterInstance(this.#pluginManager, container, (emitter) => {
6762
6856
  this.removeEmitter(container, emitter);
6763
6857
  }, emitterOptions, position);
6764
6858
  await emitter.init();
@@ -6767,22 +6861,22 @@
6767
6861
  }
6768
6862
  clear(container) {
6769
6863
  this.initContainer(container);
6770
- this._containerArrays.set(container, []);
6864
+ this.#containerArrays.set(container, []);
6771
6865
  }
6772
6866
  getArray(container) {
6773
6867
  this.initContainer(container);
6774
- let array = this._containerArrays.get(container);
6868
+ let array = this.#containerArrays.get(container);
6775
6869
  if (!array) {
6776
6870
  array = [];
6777
- this._containerArrays.set(container, array);
6871
+ this.#containerArrays.set(container, array);
6778
6872
  }
6779
6873
  return array;
6780
6874
  }
6781
6875
  initContainer(container) {
6782
- if (this._containerArrays.has(container)) {
6876
+ if (this.#containerArrays.has(container)) {
6783
6877
  return;
6784
6878
  }
6785
- this._containerArrays.set(container, []);
6879
+ this.#containerArrays.set(container, []);
6786
6880
  container.getEmitter = (idxOrName) => {
6787
6881
  const array = this.getArray(container);
6788
6882
  return idxOrName === undefined || isNumber(idxOrName)
@@ -6824,15 +6918,15 @@
6824
6918
 
6825
6919
  const minimumLength = 0;
6826
6920
  class TrailPluginInstance {
6827
- _container;
6828
- _pluginManager;
6829
- _trailFill;
6921
+ #container;
6922
+ #pluginManager;
6923
+ #trailFill;
6830
6924
  constructor(pluginManager, container) {
6831
- this._container = container;
6832
- this._pluginManager = pluginManager;
6925
+ this.#container = container;
6926
+ this.#pluginManager = pluginManager;
6833
6927
  }
6834
6928
  canvasClear() {
6835
- const container = this._container, trail = container.actualOptions.trail, trailFill = this._trailFill;
6929
+ const container = this.#container, trail = container.actualOptions.trail, trailFill = this.#trailFill;
6836
6930
  if (!trail?.enable || !trailFill || trail.length <= minimumLength) {
6837
6931
  return false;
6838
6932
  }
@@ -6850,24 +6944,24 @@
6850
6944
  }
6851
6945
  async init() {
6852
6946
  try {
6853
- await this._initTrail();
6947
+ await this.#initTrail();
6854
6948
  }
6855
6949
  catch (e) {
6856
6950
  getLogger().error(e);
6857
6951
  }
6858
6952
  }
6859
- _initTrail = async () => {
6860
- const options = this._container.actualOptions, trail = options.trail;
6953
+ #initTrail = async () => {
6954
+ const options = this.#container.actualOptions, trail = options.trail;
6861
6955
  if (!trail?.enable) {
6862
6956
  return;
6863
6957
  }
6864
6958
  const trailFill = trail.fill, opacity = inverseFactorNumerator / trail.length;
6865
6959
  if (trailFill.color) {
6866
- const fillColor = rangeColorToRgb(this._pluginManager, trailFill.color);
6960
+ const fillColor = rangeColorToRgb(this.#pluginManager, trailFill.color);
6867
6961
  if (!fillColor) {
6868
6962
  return;
6869
6963
  }
6870
- this._trailFill = {
6964
+ this.#trailFill = {
6871
6965
  color: {
6872
6966
  ...fillColor,
6873
6967
  },
@@ -6881,7 +6975,7 @@
6881
6975
  }
6882
6976
  const img = safeDocument().createElement("img");
6883
6977
  img.addEventListener("load", () => {
6884
- this._trailFill = {
6978
+ this.#trailFill = {
6885
6979
  image: img,
6886
6980
  opacity,
6887
6981
  };
@@ -6931,34 +7025,34 @@
6931
7025
  spawnStrokeColor;
6932
7026
  spawnStrokeOpacity;
6933
7027
  spawnStrokeWidth;
6934
- _container;
6935
- _currentDuration;
6936
- _currentEmitDelay;
6937
- _currentSpawnDelay;
6938
- _duration;
6939
- _emitDelay;
6940
- _firstSpawn;
6941
- _immortal;
6942
- _initialPosition;
6943
- _lifeCount;
6944
- _mutationObserver;
6945
- _particlesOptions;
6946
- _paused;
6947
- _pluginManager;
6948
- _removeCallback;
6949
- _resizeObserver;
6950
- _shape;
6951
- _size;
6952
- _spawnDelay;
6953
- _startParticlesAdded;
7028
+ #container;
7029
+ #currentDuration;
7030
+ #currentEmitDelay;
7031
+ #currentSpawnDelay;
7032
+ #duration;
7033
+ #emitDelay;
7034
+ #firstSpawn;
7035
+ #immortal;
7036
+ #initialPosition;
7037
+ #lifeCount;
7038
+ #mutationObserver;
7039
+ #particlesOptions;
7040
+ #paused;
7041
+ #pluginManager;
7042
+ #removeCallback;
7043
+ #resizeObserver;
7044
+ #shape;
7045
+ #size;
7046
+ #spawnDelay;
7047
+ #startParticlesAdded;
6954
7048
  constructor(pluginManager, container, removeCallback, options, position) {
6955
- this._pluginManager = pluginManager;
6956
- this._container = container;
6957
- this._removeCallback = removeCallback;
6958
- this._currentDuration = 0;
6959
- this._currentEmitDelay = 0;
6960
- this._currentSpawnDelay = 0;
6961
- this._initialPosition = position;
7049
+ this.#pluginManager = pluginManager;
7050
+ this.#container = container;
7051
+ this.#removeCallback = removeCallback;
7052
+ this.#currentDuration = 0;
7053
+ this.#currentEmitDelay = 0;
7054
+ this.#currentSpawnDelay = 0;
7055
+ this.#initialPosition = position;
6962
7056
  if (options instanceof Emitter) {
6963
7057
  this.options = options;
6964
7058
  }
@@ -6966,159 +7060,159 @@
6966
7060
  this.options = new Emitter();
6967
7061
  this.options.load(options);
6968
7062
  }
6969
- this._spawnDelay = container.retina.reduceFactor
7063
+ this.#spawnDelay = container.retina.reduceFactor
6970
7064
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
6971
7065
  container.retina.reduceFactor
6972
7066
  : Infinity;
6973
- this.position = this._initialPosition ?? this._calcPosition();
7067
+ this.position = this.#initialPosition ?? this.#calcPosition();
6974
7068
  this.name = this.options.name;
6975
7069
  this.fill = this.options.fill;
6976
- this._firstSpawn = !this.options.life.wait;
6977
- this._startParticlesAdded = false;
7070
+ this.#firstSpawn = !this.options.life.wait;
7071
+ this.#startParticlesAdded = false;
6978
7072
  const particlesOptions = deepExtend({}, this.options.particles);
6979
7073
  particlesOptions.move ??= {};
6980
7074
  particlesOptions.move.direction ??= this.options.direction;
6981
7075
  if (this.options.spawn.fill?.color) {
6982
- this.spawnFillColor = rangeColorToHsl(this._pluginManager, this.options.spawn.fill.color);
7076
+ this.spawnFillColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.fill.color);
6983
7077
  }
6984
7078
  if (this.options.spawn.stroke?.color) {
6985
- this.spawnStrokeColor = rangeColorToHsl(this._pluginManager, this.options.spawn.stroke.color);
6986
- }
6987
- this._paused = !this.options.autoPlay;
6988
- this._particlesOptions = particlesOptions;
6989
- this._size = this._calcSize();
6990
- this.size = getSize(this._size, this._container.canvas.size);
6991
- this._lifeCount = this.options.life.count ?? defaultLifeCount;
6992
- this._immortal = this._lifeCount <= minLifeCount;
7079
+ this.spawnStrokeColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.stroke.color);
7080
+ }
7081
+ this.#paused = !this.options.autoPlay;
7082
+ this.#particlesOptions = particlesOptions;
7083
+ this.#size = this.#calcSize();
7084
+ this.size = getSize(this.#size, this.#container.canvas.size);
7085
+ this.#lifeCount = this.options.life.count ?? defaultLifeCount;
7086
+ this.#immortal = this.#lifeCount <= minLifeCount;
6993
7087
  if (this.options.domId) {
6994
7088
  const element = safeDocument().getElementById(this.options.domId);
6995
7089
  if (element) {
6996
- this._mutationObserver = new MutationObserver(() => {
7090
+ this.#mutationObserver = new MutationObserver(() => {
6997
7091
  this.resize();
6998
7092
  });
6999
- this._resizeObserver = new ResizeObserver(() => {
7093
+ this.#resizeObserver = new ResizeObserver(() => {
7000
7094
  this.resize();
7001
7095
  });
7002
- this._mutationObserver.observe(element, {
7096
+ this.#mutationObserver.observe(element, {
7003
7097
  attributes: true,
7004
7098
  attributeFilter: ["style", "width", "height"],
7005
7099
  });
7006
- this._resizeObserver.observe(element);
7100
+ this.#resizeObserver.observe(element);
7007
7101
  }
7008
7102
  }
7009
- const shapeOptions = this.options.shape, shapeGenerator = this._pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
7103
+ const shapeOptions = this.options.shape, shapeGenerator = this.#pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
7010
7104
  if (shapeGenerator) {
7011
- this._shape = shapeGenerator.generate(this._container, this.position, this.size, this.fill, shapeOptions.options);
7105
+ this.#shape = shapeGenerator.generate(this.#container, this.position, this.size, this.fill, shapeOptions.options);
7012
7106
  }
7013
- this._container.dispatchEvent("emitterCreated", {
7107
+ this.#container.dispatchEvent("emitterCreated", {
7014
7108
  emitter: this,
7015
7109
  });
7016
7110
  this.play();
7017
7111
  }
7018
7112
  externalPause() {
7019
- this._paused = true;
7113
+ this.#paused = true;
7020
7114
  this.pause();
7021
7115
  }
7022
7116
  externalPlay() {
7023
- this._paused = false;
7117
+ this.#paused = false;
7024
7118
  this.play();
7025
7119
  }
7026
7120
  async init() {
7027
- await this._shape?.init();
7121
+ await this.#shape?.init();
7028
7122
  }
7029
7123
  pause() {
7030
- if (this._paused) {
7124
+ if (this.#paused) {
7031
7125
  return;
7032
7126
  }
7033
- delete this._emitDelay;
7127
+ this.#emitDelay = undefined;
7034
7128
  }
7035
7129
  play() {
7036
- if (this._paused) {
7130
+ if (this.#paused) {
7037
7131
  return;
7038
7132
  }
7039
- if (!((this._lifeCount > minLifeCount || this._immortal || !this.options.life.count) &&
7040
- (this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? defaultSpawnDelay)))) {
7133
+ if (!((this.#lifeCount > minLifeCount || this.#immortal || !this.options.life.count) &&
7134
+ (this.#firstSpawn || this.#currentSpawnDelay >= (this.#spawnDelay ?? defaultSpawnDelay)))) {
7041
7135
  return;
7042
7136
  }
7043
- const container = this._container;
7044
- if (this._emitDelay === undefined) {
7137
+ const container = this.#container;
7138
+ if (this.#emitDelay === undefined) {
7045
7139
  const delay = getRangeValue(this.options.rate.delay);
7046
- this._emitDelay = container.retina.reduceFactor
7140
+ this.#emitDelay = container.retina.reduceFactor
7047
7141
  ? (delay * millisecondsToSeconds) / container.retina.reduceFactor
7048
7142
  : Infinity;
7049
7143
  }
7050
- if (this._lifeCount > minLifeCount || this._immortal) {
7051
- this._prepareToDie();
7144
+ if (this.#lifeCount > minLifeCount || this.#immortal) {
7145
+ this.#prepareToDie();
7052
7146
  }
7053
7147
  }
7054
7148
  resize() {
7055
- const initialPosition = this._initialPosition, container = this._container;
7149
+ const initialPosition = this.#initialPosition, container = this.#container;
7056
7150
  this.position =
7057
7151
  initialPosition && isPointInside(initialPosition, container.canvas.size, Vector.origin)
7058
7152
  ? initialPosition
7059
- : this._calcPosition();
7060
- this._size = this._calcSize();
7061
- this.size = getSize(this._size, container.canvas.size);
7062
- this._shape?.resize(this.position, this.size);
7153
+ : this.#calcPosition();
7154
+ this.#size = this.#calcSize();
7155
+ this.size = getSize(this.#size, container.canvas.size);
7156
+ this.#shape?.resize(this.position, this.size);
7063
7157
  }
7064
7158
  update(delta) {
7065
- if (this._paused) {
7159
+ if (this.#paused) {
7066
7160
  return;
7067
7161
  }
7068
- const container = this._container;
7069
- if (this._firstSpawn) {
7070
- this._firstSpawn = false;
7071
- this._currentSpawnDelay = this._spawnDelay ?? defaultSpawnDelay;
7072
- this._currentEmitDelay = this._emitDelay ?? defaultEmitDelay;
7162
+ const container = this.#container;
7163
+ if (this.#firstSpawn) {
7164
+ this.#firstSpawn = false;
7165
+ this.#currentSpawnDelay = this.#spawnDelay ?? defaultSpawnDelay;
7166
+ this.#currentEmitDelay = this.#emitDelay ?? defaultEmitDelay;
7073
7167
  }
7074
- if (!this._startParticlesAdded) {
7075
- this._startParticlesAdded = true;
7076
- this._emitParticles(this.options.startCount);
7168
+ if (!this.#startParticlesAdded) {
7169
+ this.#startParticlesAdded = true;
7170
+ this.#emitParticles(this.options.startCount);
7077
7171
  }
7078
- if (this._duration !== undefined) {
7079
- this._currentDuration += delta.value;
7080
- if (this._currentDuration >= this._duration) {
7172
+ if (this.#duration !== undefined) {
7173
+ this.#currentDuration += delta.value;
7174
+ if (this.#currentDuration >= this.#duration) {
7081
7175
  this.pause();
7082
- if (this._spawnDelay !== undefined) {
7083
- delete this._spawnDelay;
7176
+ if (this.#spawnDelay !== undefined) {
7177
+ this.#spawnDelay = undefined;
7084
7178
  }
7085
- if (!this._immortal) {
7086
- this._lifeCount--;
7179
+ if (!this.#immortal) {
7180
+ this.#lifeCount--;
7087
7181
  }
7088
- if (this._lifeCount > minLifeCount || this._immortal) {
7089
- this.position = this._calcPosition();
7090
- this._shape?.resize(this.position, this.size);
7091
- this._spawnDelay = container.retina.reduceFactor
7182
+ if (this.#lifeCount > minLifeCount || this.#immortal) {
7183
+ this.position = this.#calcPosition();
7184
+ this.#shape?.resize(this.position, this.size);
7185
+ this.#spawnDelay = container.retina.reduceFactor
7092
7186
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
7093
7187
  container.retina.reduceFactor
7094
7188
  : Infinity;
7095
7189
  }
7096
7190
  else {
7097
- this._destroy();
7191
+ this.#destroy();
7098
7192
  }
7099
- this._currentDuration -= this._duration;
7100
- delete this._duration;
7193
+ this.#currentDuration -= this.#duration;
7194
+ this.#duration = undefined;
7101
7195
  }
7102
7196
  }
7103
- if (this._spawnDelay !== undefined) {
7104
- this._currentSpawnDelay += delta.value;
7105
- if (this._currentSpawnDelay >= this._spawnDelay) {
7106
- this._container.dispatchEvent("emitterPlay");
7197
+ if (this.#spawnDelay !== undefined) {
7198
+ this.#currentSpawnDelay += delta.value;
7199
+ if (this.#currentSpawnDelay >= this.#spawnDelay) {
7200
+ this.#container.dispatchEvent("emitterPlay");
7107
7201
  this.play();
7108
- this._currentSpawnDelay -= this._spawnDelay;
7109
- delete this._spawnDelay;
7202
+ this.#currentSpawnDelay -= this.#spawnDelay;
7203
+ this.#spawnDelay = undefined;
7110
7204
  }
7111
7205
  }
7112
- if (this._emitDelay !== undefined) {
7113
- this._currentEmitDelay += delta.value;
7114
- if (this._currentEmitDelay >= this._emitDelay) {
7115
- this._emit();
7116
- this._currentEmitDelay -= this._emitDelay;
7206
+ if (this.#emitDelay !== undefined) {
7207
+ this.#currentEmitDelay += delta.value;
7208
+ if (this.#currentEmitDelay >= this.#emitDelay) {
7209
+ this.#emit();
7210
+ this.#currentEmitDelay -= this.#emitDelay;
7117
7211
  }
7118
7212
  }
7119
7213
  }
7120
- _calcPosition() {
7121
- const container = this._container;
7214
+ #calcPosition() {
7215
+ const container = this.#container;
7122
7216
  if (this.options.domId) {
7123
7217
  const element = safeDocument().getElementById(this.options.domId);
7124
7218
  if (element) {
@@ -7134,8 +7228,8 @@
7134
7228
  position: this.options.position,
7135
7229
  });
7136
7230
  }
7137
- _calcSize() {
7138
- const container = this._container;
7231
+ #calcSize() {
7232
+ const container = this.#container;
7139
7233
  if (this.options.domId) {
7140
7234
  const element = safeDocument().getElementById(this.options.domId);
7141
7235
  if (element) {
@@ -7158,32 +7252,32 @@
7158
7252
  return size;
7159
7253
  })());
7160
7254
  }
7161
- _destroy = () => {
7162
- this._mutationObserver?.disconnect();
7163
- this._mutationObserver = undefined;
7164
- this._resizeObserver?.disconnect();
7165
- this._resizeObserver = undefined;
7166
- this._removeCallback(this);
7167
- this._container.dispatchEvent("emitterDestroyed", {
7255
+ #destroy = () => {
7256
+ this.#mutationObserver?.disconnect();
7257
+ this.#mutationObserver = undefined;
7258
+ this.#resizeObserver?.disconnect();
7259
+ this.#resizeObserver = undefined;
7260
+ this.#removeCallback(this);
7261
+ this.#container.dispatchEvent("emitterDestroyed", {
7168
7262
  emitter: this,
7169
7263
  });
7170
7264
  };
7171
- _emit() {
7172
- if (this._paused) {
7265
+ #emit() {
7266
+ if (this.#paused) {
7173
7267
  return;
7174
7268
  }
7175
7269
  const quantity = getRangeValue(this.options.rate.quantity);
7176
- this._emitParticles(quantity);
7270
+ this.#emitParticles(quantity);
7177
7271
  }
7178
- _emitParticles(quantity) {
7179
- const singleParticlesOptions = (itemFromSingleOrMultiple(this._particlesOptions) ??
7272
+ #emitParticles(quantity) {
7273
+ const singleParticlesOptions = (itemFromSingleOrMultiple(this.#particlesOptions) ??
7180
7274
  {}), fillHslAnimation = this.options.spawn.fill?.color?.animation, fillEnabled = this.options.spawn.fill?.enable ?? !!this.options.spawn.fill?.color, fillOpacity = this.options.spawn.fill?.opacity === undefined
7181
7275
  ? defaultOpacity$1
7182
7276
  : getRangeValue(this.options.spawn.fill.opacity), strokeHslAnimation = this.options.spawn.stroke?.color?.animation, strokeOpacity = this.options.spawn.stroke?.opacity === undefined
7183
7277
  ? defaultOpacity$1
7184
7278
  : getRangeValue(this.options.spawn.stroke.opacity), strokeWidth = this.options.spawn.stroke?.width === undefined
7185
7279
  ? defaultStrokeWidth
7186
- : getRangeValue(this.options.spawn.stroke.width), reduceFactor = this._container.retina.reduceFactor, needsFillColorAnimation = !!fillHslAnimation, needsStrokeColorAnimation = !!strokeHslAnimation, needsShapeData = !!this._shape, needsColorAnimation = needsFillColorAnimation || needsStrokeColorAnimation, needsCopy = needsColorAnimation || needsShapeData, maxValues = needsColorAnimation ? { h: hMax, s: sMax, l: lMax } : null, shapeOptions = this.options.shape;
7280
+ : getRangeValue(this.options.spawn.stroke.width), reduceFactor = this.#container.retina.reduceFactor, needsFillColorAnimation = !!fillHslAnimation, needsStrokeColorAnimation = !!strokeHslAnimation, needsShapeData = !!this.#shape, needsColorAnimation = needsFillColorAnimation || needsStrokeColorAnimation, needsCopy = needsColorAnimation || needsShapeData, maxValues = needsColorAnimation ? { h: hMax, s: sMax, l: lMax } : null, shapeOptions = this.options.shape;
7187
7281
  for (let i = 0; i < quantity * reduceFactor; i++) {
7188
7282
  const particlesOptions = needsCopy
7189
7283
  ? deepExtend({}, singleParticlesOptions)
@@ -7194,23 +7288,23 @@
7194
7288
  this.spawnStrokeWidth = strokeWidth;
7195
7289
  if (this.spawnFillColor) {
7196
7290
  if (fillHslAnimation && maxValues) {
7197
- this.spawnFillColor.h = this._setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
7198
- this.spawnFillColor.s = this._setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
7199
- this.spawnFillColor.l = this._setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
7291
+ this.spawnFillColor.h = this.#setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
7292
+ this.spawnFillColor.s = this.#setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
7293
+ this.spawnFillColor.l = this.#setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
7200
7294
  }
7201
7295
  setParticlesOptionsFillColor(particlesOptions, this.spawnFillColor, this.spawnFillOpacity, this.spawnFillEnabled);
7202
7296
  }
7203
7297
  if (this.spawnStrokeColor) {
7204
7298
  if (strokeHslAnimation && maxValues) {
7205
- this.spawnStrokeColor.h = this._setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
7206
- this.spawnStrokeColor.s = this._setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
7207
- this.spawnStrokeColor.l = this._setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
7299
+ this.spawnStrokeColor.h = this.#setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
7300
+ this.spawnStrokeColor.s = this.#setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
7301
+ this.spawnStrokeColor.l = this.#setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
7208
7302
  }
7209
7303
  setParticlesOptionsStrokeColor(particlesOptions, this.spawnStrokeColor, this.spawnStrokeOpacity, this.spawnStrokeWidth);
7210
7304
  }
7211
7305
  let position = this.position;
7212
- if (this._shape) {
7213
- const shapePosData = this._shape.randomPosition();
7306
+ if (this.#shape) {
7307
+ const shapePosData = this.#shape.randomPosition();
7214
7308
  if (shapePosData) {
7215
7309
  position = shapePosData.position;
7216
7310
  const replaceData = shapeOptions.replace;
@@ -7223,21 +7317,21 @@
7223
7317
  }
7224
7318
  }
7225
7319
  if (position) {
7226
- this._container.particles.addParticle(position, particlesOptions);
7320
+ this.#container.particles.addParticle(position, particlesOptions);
7227
7321
  }
7228
7322
  }
7229
7323
  }
7230
- _prepareToDie = () => {
7231
- if (this._paused) {
7324
+ #prepareToDie = () => {
7325
+ if (this.#paused) {
7232
7326
  return;
7233
7327
  }
7234
7328
  const duration = this.options.life.duration !== undefined ? getRangeValue(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
7235
- if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
7236
- this._duration = duration * millisecondsToSeconds;
7329
+ if ((this.#lifeCount > minLifeCount || this.#immortal) && duration !== undefined && duration > minDuration) {
7330
+ this.#duration = duration * millisecondsToSeconds;
7237
7331
  }
7238
7332
  };
7239
- _setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
7240
- const container = this._container;
7333
+ #setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
7334
+ const container = this.#container;
7241
7335
  if (!animation.enable) {
7242
7336
  return initValue;
7243
7337
  }