@tsparticles/preset-fireworks 4.0.5 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* Preset v4.0.5 */
2
+ /* Preset v4.1.1 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5
5
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -51,13 +51,13 @@
51
51
  return Math.atan2(this.y, this.x);
52
52
  }
53
53
  set angle(angle) {
54
- this._updateFromAngle(angle, this.length);
54
+ this.#updateFromAngle(angle, this.length);
55
55
  }
56
56
  get length() {
57
57
  return Math.sqrt(this.getLengthSq());
58
58
  }
59
59
  set length(length) {
60
- this._updateFromAngle(this.angle, length);
60
+ this.#updateFromAngle(this.angle, length);
61
61
  }
62
62
  static clone(source) {
63
63
  return Vector3d.create(source.x, source.y, getZ(source));
@@ -120,7 +120,7 @@
120
120
  this.y -= v.y;
121
121
  this.z -= getZ(v);
122
122
  }
123
- _updateFromAngle(angle, length) {
123
+ #updateFromAngle(angle, length) {
124
124
  this.x = Math.cos(angle) * length;
125
125
  this.y = Math.sin(angle) * length;
126
126
  }
@@ -730,38 +730,38 @@
730
730
  }
731
731
 
732
732
  class EventDispatcher {
733
- _listeners;
733
+ #listeners;
734
734
  constructor() {
735
- this._listeners = new Map();
735
+ this.#listeners = new Map();
736
736
  }
737
737
  addEventListener(type, listener) {
738
738
  this.removeEventListener(type, listener);
739
- let arr = this._listeners.get(type);
739
+ let arr = this.#listeners.get(type);
740
740
  if (!arr) {
741
741
  arr = [];
742
- this._listeners.set(type, arr);
742
+ this.#listeners.set(type, arr);
743
743
  }
744
744
  arr.push(listener);
745
745
  }
746
746
  dispatchEvent(type, args) {
747
- const listeners = this._listeners.get(type);
747
+ const listeners = this.#listeners.get(type);
748
748
  listeners?.forEach(handler => {
749
749
  handler(args);
750
750
  });
751
751
  }
752
752
  hasEventListener(type) {
753
- return !!this._listeners.get(type);
753
+ return !!this.#listeners.get(type);
754
754
  }
755
755
  removeAllEventListeners(type) {
756
756
  if (!type) {
757
- this._listeners = new Map();
757
+ this.#listeners = new Map();
758
758
  }
759
759
  else {
760
- this._listeners.delete(type);
760
+ this.#listeners.delete(type);
761
761
  }
762
762
  }
763
763
  removeEventListener(type, listener) {
764
- const arr = this._listeners.get(type);
764
+ const arr = this.#listeners.get(type);
765
765
  if (!arr) {
766
766
  return;
767
767
  }
@@ -770,7 +770,7 @@
770
770
  return;
771
771
  }
772
772
  if (length === deleteCount) {
773
- this._listeners.delete(type);
773
+ this.#listeners.delete(type);
774
774
  }
775
775
  else {
776
776
  arr.splice(idx, deleteCount);
@@ -808,19 +808,19 @@
808
808
  presets = new Map();
809
809
  shapeDrawers = new Map();
810
810
  updaters = new Map();
811
- _allLoadersSet = new Set();
812
- _configs = new Map();
813
- _engine;
814
- _executedSet = new Set();
815
- _initialized = false;
816
- _isRunningLoaders = false;
817
- _loadPromises = new Set();
811
+ #allLoadersSet = new Set();
812
+ #configs = new Map();
813
+ #engine;
814
+ #executedSet = new Set();
815
+ #initialized = false;
816
+ #isRunningLoaders = false;
817
+ #loadPromises = new Set();
818
818
  constructor(engine) {
819
- this._engine = engine;
819
+ this.#engine = engine;
820
820
  }
821
821
  get configs() {
822
822
  const res = {};
823
- for (const [name, config] of this._configs) {
823
+ for (const [name, config] of this.#configs) {
824
824
  res[name] = config;
825
825
  }
826
826
  return res;
@@ -830,8 +830,8 @@
830
830
  }
831
831
  addConfig(config) {
832
832
  const key = config.key ?? config.name ?? "default";
833
- this._configs.set(key, config);
834
- this._engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
833
+ this.#configs.set(key, config);
834
+ this.#engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
835
835
  }
836
836
  addEasing(name, easing) {
837
837
  if (this.easingFunctions.get(name)) {
@@ -892,21 +892,21 @@
892
892
  return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
893
893
  }
894
894
  async init() {
895
- if (this._initialized || this._isRunningLoaders) {
895
+ if (this.#initialized || this.#isRunningLoaders) {
896
896
  return;
897
897
  }
898
- this._isRunningLoaders = true;
899
- this._executedSet = new Set();
900
- this._allLoadersSet = new Set(this._loadPromises);
898
+ this.#isRunningLoaders = true;
899
+ this.#executedSet = new Set();
900
+ this.#allLoadersSet = new Set(this.#loadPromises);
901
901
  try {
902
- for (const loader of this._allLoadersSet) {
903
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
902
+ for (const loader of this.#allLoadersSet) {
903
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
904
904
  }
905
905
  }
906
906
  finally {
907
- this._loadPromises.clear();
908
- this._isRunningLoaders = false;
909
- this._initialized = true;
907
+ this.#loadPromises.clear();
908
+ this.#isRunningLoaders = false;
909
+ this.#initialized = true;
910
910
  }
911
911
  }
912
912
  loadParticlesOptions(container, options, ...sourceOptions) {
@@ -917,24 +917,24 @@
917
917
  updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
918
918
  }
919
919
  async register(...loaders) {
920
- if (this._initialized) {
920
+ if (this.#initialized) {
921
921
  throw new Error("Register plugins can only be done before calling tsParticles.load()");
922
922
  }
923
923
  for (const loader of loaders) {
924
- if (this._isRunningLoaders) {
925
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
924
+ if (this.#isRunningLoaders) {
925
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
926
926
  }
927
927
  else {
928
- this._loadPromises.add(loader);
928
+ this.#loadPromises.add(loader);
929
929
  }
930
930
  }
931
931
  }
932
- async _runLoader(loader, executed, allLoaders) {
932
+ async #runLoader(loader, executed, allLoaders) {
933
933
  if (executed.has(loader))
934
934
  return;
935
935
  executed.add(loader);
936
936
  allLoaders.add(loader);
937
- await loader(this._engine);
937
+ await loader(this.#engine);
938
938
  }
939
939
  }
940
940
 
@@ -1014,17 +1014,17 @@
1014
1014
  };
1015
1015
  class Engine {
1016
1016
  pluginManager = new PluginManager(this);
1017
- _domArray = [];
1018
- _eventDispatcher = new EventDispatcher();
1019
- _initialized = false;
1017
+ #domArray = [];
1018
+ #eventDispatcher = new EventDispatcher();
1019
+ #initialized = false;
1020
1020
  get items() {
1021
- return this._domArray;
1021
+ return this.#domArray;
1022
1022
  }
1023
1023
  get version() {
1024
- return "4.0.5";
1024
+ return "4.1.1";
1025
1025
  }
1026
1026
  addEventListener(type, listener) {
1027
- this._eventDispatcher.addEventListener(type, listener);
1027
+ this.#eventDispatcher.addEventListener(type, listener);
1028
1028
  }
1029
1029
  checkVersion(pluginVersion) {
1030
1030
  if (this.version === pluginVersion) {
@@ -1033,17 +1033,17 @@
1033
1033
  throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
1034
1034
  }
1035
1035
  dispatchEvent(type, args) {
1036
- this._eventDispatcher.dispatchEvent(type, args);
1036
+ this.#eventDispatcher.dispatchEvent(type, args);
1037
1037
  }
1038
1038
  async init() {
1039
- if (this._initialized) {
1039
+ if (this.#initialized) {
1040
1040
  return;
1041
1041
  }
1042
1042
  await this.pluginManager.init();
1043
- this._initialized = true;
1043
+ this.#initialized = true;
1044
1044
  }
1045
1045
  item(index) {
1046
- const { items } = this, item = items[index];
1046
+ const items = this.items, item = items[index];
1047
1047
  if (item?.destroyed) {
1048
1048
  items.splice(index, removeDeleteCount);
1049
1049
  return;
@@ -1097,7 +1097,7 @@
1097
1097
  await Promise.all(this.items.map(t => t.refresh()));
1098
1098
  }
1099
1099
  removeEventListener(type, listener) {
1100
- this._eventDispatcher.removeEventListener(type, listener);
1100
+ this.#eventDispatcher.removeEventListener(type, listener);
1101
1101
  }
1102
1102
  }
1103
1103
 
@@ -1868,43 +1868,6 @@
1868
1868
  }
1869
1869
  }
1870
1870
 
1871
- class OpacityAnimation extends RangedAnimationOptions {
1872
- destroy;
1873
- constructor() {
1874
- super();
1875
- this.destroy = DestroyType.none;
1876
- this.speed = 2;
1877
- }
1878
- load(data) {
1879
- super.load(data);
1880
- if (isNull(data)) {
1881
- return;
1882
- }
1883
- if (data.destroy !== undefined) {
1884
- this.destroy = data.destroy;
1885
- }
1886
- }
1887
- }
1888
-
1889
- class Opacity extends RangedAnimationValueWithRandom {
1890
- animation;
1891
- constructor() {
1892
- super();
1893
- this.animation = new OpacityAnimation();
1894
- this.value = 1;
1895
- }
1896
- load(data) {
1897
- if (isNull(data)) {
1898
- return;
1899
- }
1900
- super.load(data);
1901
- const animation = data.animation;
1902
- if (animation !== undefined) {
1903
- this.animation.load(animation);
1904
- }
1905
- }
1906
- }
1907
-
1908
1871
  class Stroke {
1909
1872
  color;
1910
1873
  opacity;
@@ -2072,43 +2035,6 @@
2072
2035
  }
2073
2036
  }
2074
2037
 
2075
- class SizeAnimation extends RangedAnimationOptions {
2076
- destroy;
2077
- constructor() {
2078
- super();
2079
- this.destroy = DestroyType.none;
2080
- this.speed = 5;
2081
- }
2082
- load(data) {
2083
- super.load(data);
2084
- if (isNull(data)) {
2085
- return;
2086
- }
2087
- if (data.destroy !== undefined) {
2088
- this.destroy = data.destroy;
2089
- }
2090
- }
2091
- }
2092
-
2093
- class Size extends RangedAnimationValueWithRandom {
2094
- animation;
2095
- constructor() {
2096
- super();
2097
- this.animation = new SizeAnimation();
2098
- this.value = 3;
2099
- }
2100
- load(data) {
2101
- super.load(data);
2102
- if (isNull(data)) {
2103
- return;
2104
- }
2105
- const animation = data.animation;
2106
- if (animation !== undefined) {
2107
- this.animation.load(animation);
2108
- }
2109
- }
2110
- }
2111
-
2112
2038
  class ZIndex extends ValueWithRandom {
2113
2039
  opacityRate;
2114
2040
  sizeRate;
@@ -2142,24 +2068,21 @@
2142
2068
  groups;
2143
2069
  move;
2144
2070
  number;
2145
- opacity;
2146
2071
  paint;
2147
2072
  palette;
2148
2073
  reduceDuplicates;
2149
2074
  shape;
2150
- size;
2151
2075
  zIndex;
2152
- _container;
2153
- _pluginManager;
2076
+ #container;
2077
+ #pluginManager;
2154
2078
  constructor(pluginManager, container) {
2155
- this._pluginManager = pluginManager;
2156
- this._container = container;
2079
+ this.#pluginManager = pluginManager;
2080
+ this.#container = container;
2157
2081
  this.bounce = new ParticlesBounce();
2158
2082
  this.effect = new Effect();
2159
2083
  this.groups = {};
2160
2084
  this.move = new Move();
2161
2085
  this.number = new ParticlesNumber();
2162
- this.opacity = new Opacity();
2163
2086
  this.paint = new Paint();
2164
2087
  this.paint.color = new AnimatableColor();
2165
2088
  this.paint.color.value = "#fff";
@@ -2167,7 +2090,6 @@
2167
2090
  this.paint.fill.enable = true;
2168
2091
  this.reduceDuplicates = false;
2169
2092
  this.shape = new Shape();
2170
- this.size = new Size();
2171
2093
  this.zIndex = new ZIndex();
2172
2094
  }
2173
2095
  load(data) {
@@ -2176,7 +2098,7 @@
2176
2098
  }
2177
2099
  if (data.palette) {
2178
2100
  this.palette = data.palette;
2179
- this._importPalette(this.palette);
2101
+ this.#importPalette(this.palette);
2180
2102
  }
2181
2103
  if (data.groups !== undefined) {
2182
2104
  for (const group of Object.keys(data.groups)) {
@@ -2196,7 +2118,6 @@
2196
2118
  this.effect.load(data.effect);
2197
2119
  this.move.load(data.move);
2198
2120
  this.number.load(data.number);
2199
- this.opacity.load(data.opacity);
2200
2121
  const paintToLoad = data.paint;
2201
2122
  if (paintToLoad) {
2202
2123
  if (isArray(paintToLoad)) {
@@ -2215,15 +2136,14 @@
2215
2136
  }
2216
2137
  }
2217
2138
  this.shape.load(data.shape);
2218
- this.size.load(data.size);
2219
2139
  this.zIndex.load(data.zIndex);
2220
- if (this._container) {
2221
- for (const plugin of this._pluginManager.plugins) {
2140
+ if (this.#container) {
2141
+ for (const plugin of this.#pluginManager.plugins) {
2222
2142
  if (plugin.loadParticlesOptions) {
2223
- plugin.loadParticlesOptions(this._container, this, data);
2143
+ plugin.loadParticlesOptions(this.#container, this, data);
2224
2144
  }
2225
2145
  }
2226
- const updaters = this._pluginManager.updaters.get(this._container);
2146
+ const updaters = this.#pluginManager.updaters.get(this.#container);
2227
2147
  if (updaters) {
2228
2148
  for (const updater of updaters) {
2229
2149
  if (updater.loadOptions) {
@@ -2233,8 +2153,8 @@
2233
2153
  }
2234
2154
  }
2235
2155
  }
2236
- _importPalette = (palette) => {
2237
- const paletteData = this._pluginManager.getPalette(palette);
2156
+ #importPalette = (palette) => {
2157
+ const paletteData = this.#pluginManager.getPalette(palette);
2238
2158
  if (!paletteData) {
2239
2159
  return;
2240
2160
  }
@@ -2313,11 +2233,11 @@
2313
2233
  smooth;
2314
2234
  style;
2315
2235
  zLayers;
2316
- _container;
2317
- _pluginManager;
2236
+ #container;
2237
+ #pluginManager;
2318
2238
  constructor(pluginManager, container) {
2319
- this._pluginManager = pluginManager;
2320
- this._container = container;
2239
+ this.#pluginManager = pluginManager;
2240
+ this.#container = container;
2321
2241
  this.autoPlay = true;
2322
2242
  this.background = new Background();
2323
2243
  this.clear = true;
@@ -2328,7 +2248,7 @@
2328
2248
  this.duration = 0;
2329
2249
  this.fpsLimit = 120;
2330
2250
  this.hdr = true;
2331
- this.particles = loadParticlesOptions(this._pluginManager, this._container);
2251
+ this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2332
2252
  this.pauseOnBlur = true;
2333
2253
  this.pauseOnOutsideViewport = true;
2334
2254
  this.resize = new ResizeEvent();
@@ -2343,12 +2263,12 @@
2343
2263
  if (data.preset !== undefined) {
2344
2264
  this.preset = data.preset;
2345
2265
  executeOnSingleOrMultiple(this.preset, preset => {
2346
- this._importPreset(preset);
2266
+ this.#importPreset(preset);
2347
2267
  });
2348
2268
  }
2349
2269
  if (data.palette !== undefined) {
2350
2270
  this.palette = data.palette;
2351
- this._importPalette(this.palette);
2271
+ this.#importPalette(this.palette);
2352
2272
  }
2353
2273
  if (data.autoPlay !== undefined) {
2354
2274
  this.autoPlay = data.autoPlay;
@@ -2402,12 +2322,12 @@
2402
2322
  if (data.smooth !== undefined) {
2403
2323
  this.smooth = data.smooth;
2404
2324
  }
2405
- this._pluginManager.plugins.forEach(plugin => {
2406
- plugin.loadOptions(this._container, this, data);
2325
+ this.#pluginManager.plugins.forEach(plugin => {
2326
+ plugin.loadOptions(this.#container, this, data);
2407
2327
  });
2408
2328
  }
2409
- _importPalette = palette => {
2410
- const paletteData = this._pluginManager.getPalette(palette);
2329
+ #importPalette = palette => {
2330
+ const paletteData = this.#pluginManager.getPalette(palette);
2411
2331
  if (!paletteData) {
2412
2332
  return;
2413
2333
  }
@@ -2424,8 +2344,8 @@
2424
2344
  },
2425
2345
  });
2426
2346
  };
2427
- _importPreset = preset => {
2428
- this.load(this._pluginManager.getPreset(preset));
2347
+ #importPreset = preset => {
2348
+ this.load(this.#pluginManager.getPreset(preset));
2429
2349
  };
2430
2350
  }
2431
2351
 
@@ -3150,7 +3070,7 @@
3150
3070
  }
3151
3071
 
3152
3072
  async function loadBlendPlugin(engine) {
3153
- engine.checkVersion("4.0.5");
3073
+ engine.checkVersion("4.1.1");
3154
3074
  await engine.pluginManager.register(e => {
3155
3075
  e.pluginManager.addPlugin(new BlendPlugin());
3156
3076
  });
@@ -3187,7 +3107,7 @@
3187
3107
  }
3188
3108
 
3189
3109
  async function loadCircleShape(engine) {
3190
- engine.checkVersion("4.0.5");
3110
+ engine.checkVersion("4.1.1");
3191
3111
  await engine.pluginManager.register(e => {
3192
3112
  e.pluginManager.addShape(["circle"], () => {
3193
3113
  return Promise.resolve(new CircleDrawer());
@@ -3208,15 +3128,15 @@
3208
3128
  return input.startsWith("#");
3209
3129
  }
3210
3130
  handleColor(color) {
3211
- return this._parseString(color.value);
3131
+ return this.#parseString(color.value);
3212
3132
  }
3213
3133
  handleRangeColor(color) {
3214
- return this._parseString(color.value);
3134
+ return this.#parseString(color.value);
3215
3135
  }
3216
3136
  parseString(input) {
3217
- return this._parseString(input);
3137
+ return this.#parseString(input);
3218
3138
  }
3219
- _parseString(hexColor) {
3139
+ #parseString(hexColor) {
3220
3140
  if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
3221
3141
  return;
3222
3142
  }
@@ -3235,7 +3155,7 @@
3235
3155
  }
3236
3156
 
3237
3157
  async function loadHexColorPlugin(engine) {
3238
- engine.checkVersion("4.0.5");
3158
+ engine.checkVersion("4.1.1");
3239
3159
  await engine.pluginManager.register(e => {
3240
3160
  e.pluginManager.addColorManager("hex", new HexColorManager());
3241
3161
  });
@@ -3288,7 +3208,7 @@
3288
3208
  }
3289
3209
 
3290
3210
  async function loadHslColorPlugin(engine) {
3291
- engine.checkVersion("4.0.5");
3211
+ engine.checkVersion("4.1.1");
3292
3212
  await engine.pluginManager.register(e => {
3293
3213
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3294
3214
  });
@@ -3296,13 +3216,13 @@
3296
3216
 
3297
3217
  class MovePlugin {
3298
3218
  id = "move";
3299
- _pluginManager;
3219
+ #pluginManager;
3300
3220
  constructor(pluginManager) {
3301
- this._pluginManager = pluginManager;
3221
+ this.#pluginManager = pluginManager;
3302
3222
  }
3303
3223
  async getPlugin(container) {
3304
3224
  const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
3305
- return new MovePluginInstance(this._pluginManager, container);
3225
+ return new MovePluginInstance(this.#pluginManager, container);
3306
3226
  }
3307
3227
  loadOptions() {
3308
3228
  }
@@ -3312,7 +3232,7 @@
3312
3232
  }
3313
3233
 
3314
3234
  async function loadMovePlugin(engine) {
3315
- engine.checkVersion("4.0.5");
3235
+ engine.checkVersion("4.1.1");
3316
3236
  await engine.pluginManager.register(e => {
3317
3237
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3318
3238
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3330,18 +3250,58 @@
3330
3250
  });
3331
3251
  }
3332
3252
 
3253
+ class OpacityAnimation extends RangedAnimationOptions {
3254
+ destroy;
3255
+ constructor() {
3256
+ super();
3257
+ this.destroy = DestroyType.none;
3258
+ this.speed = 2;
3259
+ }
3260
+ load(data) {
3261
+ super.load(data);
3262
+ if (isNull(data)) {
3263
+ return;
3264
+ }
3265
+ if (data.destroy !== undefined) {
3266
+ this.destroy = data.destroy;
3267
+ }
3268
+ }
3269
+ }
3270
+
3271
+ class Opacity extends RangedAnimationValueWithRandom {
3272
+ animation;
3273
+ constructor() {
3274
+ super();
3275
+ this.animation = new OpacityAnimation();
3276
+ this.value = 1;
3277
+ }
3278
+ load(data) {
3279
+ if (isNull(data)) {
3280
+ return;
3281
+ }
3282
+ super.load(data);
3283
+ const animation = data.animation;
3284
+ if (animation !== undefined) {
3285
+ this.animation.load(animation);
3286
+ }
3287
+ }
3288
+ }
3289
+
3333
3290
  class OpacityUpdater {
3334
- container;
3291
+ #container;
3335
3292
  constructor(container) {
3336
- this.container = container;
3293
+ this.#container = container;
3337
3294
  }
3338
3295
  init(particle) {
3339
3296
  const opacityOptions = particle.options.opacity, pxRatio = 1;
3297
+ if (!opacityOptions) {
3298
+ return;
3299
+ }
3340
3300
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
3341
3301
  const opacityAnimation = opacityOptions.animation;
3342
3302
  if (opacityAnimation.enable) {
3343
3303
  particle.opacity.velocity =
3344
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
3304
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
3345
3305
  if (!opacityAnimation.sync) {
3346
3306
  particle.opacity.velocity *= getRandom();
3347
3307
  }
@@ -3357,6 +3317,12 @@
3357
3317
  ((particle.opacity.maxLoops ?? none) > none &&
3358
3318
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3359
3319
  }
3320
+ loadOptions(options, ...sources) {
3321
+ options.opacity ??= new Opacity();
3322
+ for (const source of sources) {
3323
+ options.opacity.load(source?.opacity);
3324
+ }
3325
+ }
3360
3326
  reset(particle) {
3361
3327
  if (!particle.opacity) {
3362
3328
  return;
@@ -3365,7 +3331,7 @@
3365
3331
  particle.opacity.loops = 0;
3366
3332
  }
3367
3333
  update(particle, delta) {
3368
- if (!this.isEnabled(particle) || !particle.opacity) {
3334
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
3369
3335
  return;
3370
3336
  }
3371
3337
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -3373,7 +3339,7 @@
3373
3339
  }
3374
3340
 
3375
3341
  async function loadOpacityUpdater(engine) {
3376
- engine.checkVersion("4.0.5");
3342
+ engine.checkVersion("4.1.1");
3377
3343
  await engine.pluginManager.register(e => {
3378
3344
  e.pluginManager.addParticleUpdater("opacity", container => {
3379
3345
  return Promise.resolve(new OpacityUpdater(container));
@@ -3395,10 +3361,9 @@
3395
3361
  }
3396
3362
  const velocity = data.particle.velocity.x;
3397
3363
  let bounced = false;
3398
- if ((data.direction === OutModeDirection.right &&
3399
- data.bounds.right >= data.canvasSize.width &&
3400
- velocity > minVelocity$4) ||
3401
- (data.direction === OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity$4)) {
3364
+ if (data.outOfCanvas &&
3365
+ ((data.direction === OutModeDirection.right && velocity > minVelocity$4) ||
3366
+ (data.direction === OutModeDirection.left && velocity < minVelocity$4))) {
3402
3367
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3403
3368
  data.particle.velocity.x *= -newVelocity;
3404
3369
  bounced = true;
@@ -3407,10 +3372,10 @@
3407
3372
  return;
3408
3373
  }
3409
3374
  const minPos = data.offset.x + data.size;
3410
- if (data.bounds.right >= data.canvasSize.width && data.direction === OutModeDirection.right) {
3375
+ if (data.outOfCanvas && data.direction === OutModeDirection.right) {
3411
3376
  data.particle.position.x = data.canvasSize.width - minPos;
3412
3377
  }
3413
- else if (data.bounds.left <= boundsMin && data.direction === OutModeDirection.left) {
3378
+ else if (data.outOfCanvas && data.direction === OutModeDirection.left) {
3414
3379
  data.particle.position.x = minPos;
3415
3380
  }
3416
3381
  if (data.outMode === OutMode.split) {
@@ -3430,10 +3395,9 @@
3430
3395
  }
3431
3396
  const velocity = data.particle.velocity.y;
3432
3397
  let bounced = false;
3433
- if ((data.direction === OutModeDirection.bottom &&
3434
- data.bounds.bottom >= data.canvasSize.height &&
3435
- velocity > minVelocity$4) ||
3436
- (data.direction === OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity$4)) {
3398
+ if (data.outOfCanvas &&
3399
+ ((data.direction === OutModeDirection.bottom && velocity > minVelocity$4) ||
3400
+ (data.direction === OutModeDirection.top && velocity < minVelocity$4))) {
3437
3401
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3438
3402
  data.particle.velocity.y *= -newVelocity;
3439
3403
  bounced = true;
@@ -3442,10 +3406,10 @@
3442
3406
  return;
3443
3407
  }
3444
3408
  const minPos = data.offset.y + data.size;
3445
- if (data.bounds.bottom >= data.canvasSize.height && data.direction === OutModeDirection.bottom) {
3409
+ if (data.outOfCanvas && data.direction === OutModeDirection.bottom) {
3446
3410
  data.particle.position.y = data.canvasSize.height - minPos;
3447
3411
  }
3448
- else if (data.bounds.top <= boundsMin && data.direction === OutModeDirection.top) {
3412
+ else if (data.outOfCanvas && data.direction === OutModeDirection.top) {
3449
3413
  data.particle.position.y = minPos;
3450
3414
  }
3451
3415
  if (data.outMode === OutMode.split) {
@@ -3454,24 +3418,24 @@
3454
3418
  }
3455
3419
 
3456
3420
  class BounceOutMode {
3457
- container;
3458
3421
  modes;
3459
- _particleBouncePlugins;
3422
+ #container;
3423
+ #particleBouncePlugins;
3460
3424
  constructor(container) {
3461
- this.container = container;
3425
+ this.#container = container;
3462
3426
  this.modes = [
3463
3427
  OutMode.bounce,
3464
3428
  OutMode.split,
3465
3429
  ];
3466
- this._particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3430
+ this.#particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3467
3431
  }
3468
3432
  update(particle, direction, delta, outMode) {
3469
3433
  if (!this.modes.includes(outMode)) {
3470
3434
  return;
3471
3435
  }
3472
- const container = this.container;
3436
+ const container = this.#container;
3473
3437
  let handled = false;
3474
- for (const plugin of this._particleBouncePlugins) {
3438
+ for (const plugin of this.#particleBouncePlugins) {
3475
3439
  handled = plugin.particleBounce?.(particle, delta, direction) ?? false;
3476
3440
  if (handled) {
3477
3441
  break;
@@ -3480,29 +3444,26 @@
3480
3444
  if (handled) {
3481
3445
  return;
3482
3446
  }
3483
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size;
3484
- bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
3485
- bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
3447
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, outOfCanvas = !particle.isInsideCanvasForOutMode(outMode, direction);
3448
+ bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3449
+ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3486
3450
  }
3487
3451
  }
3488
3452
 
3489
3453
  const minVelocity$3 = 0;
3490
3454
  class DestroyOutMode {
3491
- container;
3492
3455
  modes;
3493
- constructor(container) {
3494
- this.container = container;
3456
+ constructor(_container) {
3495
3457
  this.modes = [OutMode.destroy];
3496
3458
  }
3497
3459
  update(particle, direction, _delta, outMode) {
3498
3460
  if (!this.modes.includes(outMode)) {
3499
3461
  return;
3500
3462
  }
3501
- const container = this.container;
3502
3463
  switch (particle.outType) {
3503
3464
  case ParticleOutType.normal:
3504
3465
  case ParticleOutType.outside:
3505
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3466
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3506
3467
  return;
3507
3468
  }
3508
3469
  break;
@@ -3523,10 +3484,10 @@
3523
3484
 
3524
3485
  const minVelocity$2 = 0;
3525
3486
  class NoneOutMode {
3526
- container;
3527
3487
  modes;
3488
+ #container;
3528
3489
  constructor(container) {
3529
- this.container = container;
3490
+ this.#container = container;
3530
3491
  this.modes = [OutMode.none];
3531
3492
  }
3532
3493
  update(particle, direction, _delta, outMode) {
@@ -3539,7 +3500,7 @@
3539
3500
  (direction === OutModeDirection.top || direction === OutModeDirection.bottom))) {
3540
3501
  return;
3541
3502
  }
3542
- const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3503
+ const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3543
3504
  if (!gravityOptions.enable) {
3544
3505
  if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3545
3506
  (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
@@ -3565,17 +3526,17 @@
3565
3526
 
3566
3527
  const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
3567
3528
  class OutOutMode {
3568
- container;
3569
3529
  modes;
3530
+ #container;
3570
3531
  constructor(container) {
3571
- this.container = container;
3532
+ this.#container = container;
3572
3533
  this.modes = [OutMode.out];
3573
3534
  }
3574
3535
  update(particle, direction, _delta, outMode) {
3575
3536
  if (!this.modes.includes(outMode)) {
3576
3537
  return;
3577
3538
  }
3578
- const container = this.container;
3539
+ const container = this.#container;
3579
3540
  switch (particle.outType) {
3580
3541
  case ParticleOutType.inside: {
3581
3542
  const { x: vx, y: vy } = particle.velocity;
@@ -3605,7 +3566,7 @@
3605
3566
  break;
3606
3567
  }
3607
3568
  default: {
3608
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3569
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3609
3570
  return;
3610
3571
  }
3611
3572
  switch (particle.outType) {
@@ -3689,16 +3650,16 @@
3689
3650
  };
3690
3651
  class OutOfCanvasUpdater {
3691
3652
  updaters;
3692
- container;
3653
+ #container;
3693
3654
  constructor(container) {
3694
- this.container = container;
3655
+ this.#container = container;
3695
3656
  this.updaters = new Map();
3696
3657
  }
3697
3658
  init(particle) {
3698
- this._addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3699
- this._addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3700
- this._addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3701
- this._addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3659
+ this.#addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3660
+ this.#addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3661
+ this.#addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3662
+ this.#addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3702
3663
  }
3703
3664
  isEnabled(particle) {
3704
3665
  return !particle.destroyed && !particle.spawning;
@@ -3706,18 +3667,18 @@
3706
3667
  update(particle, delta) {
3707
3668
  const outModes = particle.options.move.outModes;
3708
3669
  particle.justWarped = false;
3709
- this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3710
- this._updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3711
- this._updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3712
- this._updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3670
+ this.#updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3671
+ this.#updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3672
+ this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3673
+ this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3713
3674
  }
3714
- _addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3675
+ #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3715
3676
  const outModes = particle.options.move.outModes;
3716
3677
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3717
- this.updaters.set(outMode, getUpdater(this.container));
3678
+ this.updaters.set(outMode, getUpdater(this.#container));
3718
3679
  }
3719
3680
  };
3720
- _updateOutMode = (particle, delta, outMode, direction) => {
3681
+ #updateOutMode = (particle, delta, outMode, direction) => {
3721
3682
  for (const updater of this.updaters.values()) {
3722
3683
  updater.update(particle, direction, delta, outMode);
3723
3684
  }
@@ -3725,7 +3686,7 @@
3725
3686
  }
3726
3687
 
3727
3688
  async function loadOutModesUpdater(engine) {
3728
- engine.checkVersion("4.0.5");
3689
+ engine.checkVersion("4.1.1");
3729
3690
  await engine.pluginManager.register(e => {
3730
3691
  e.pluginManager.addParticleUpdater("outModes", container => {
3731
3692
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3735,20 +3696,20 @@
3735
3696
 
3736
3697
  const defaultOpacity = 1;
3737
3698
  class PaintUpdater {
3738
- _container;
3739
- _pluginManager;
3699
+ #container;
3700
+ #pluginManager;
3740
3701
  constructor(pluginManager, container) {
3741
- this._container = container;
3742
- this._pluginManager = pluginManager;
3702
+ this.#container = container;
3703
+ this.#pluginManager = pluginManager;
3743
3704
  }
3744
3705
  init(particle) {
3745
- 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;
3706
+ 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;
3746
3707
  if (fill) {
3747
3708
  const fillColor = AnimatableColor.create(paintColor === undefined ? undefined : AnimatableColor.create(undefined, paintColor), fill.color);
3748
3709
  particle.fillEnabled = fill.enable;
3749
3710
  particle.fillOpacity = getRangeValue(fill.opacity);
3750
3711
  particle.fillAnimation = fillColor.animation;
3751
- const fillHslColor = rangeColorToHsl(this._pluginManager, fillColor);
3712
+ const fillHslColor = rangeColorToHsl(this.#pluginManager, fillColor);
3752
3713
  if (fillHslColor) {
3753
3714
  particle.fillColor = getHslAnimationFromHsl(fillHslColor, particle.fillAnimation, container.retina.reduceFactor);
3754
3715
  }
@@ -3764,7 +3725,7 @@
3764
3725
  particle.strokeWidth = getRangeValue(stroke.width) * container.retina.pixelRatio;
3765
3726
  particle.strokeOpacity = getRangeValue(stroke.opacity ?? defaultOpacity);
3766
3727
  particle.strokeAnimation = strokeColor.animation;
3767
- const strokeHslColor = rangeColorToHsl(this._pluginManager, strokeColor) ?? particle.getFillColor();
3728
+ const strokeHslColor = rangeColorToHsl(this.#pluginManager, strokeColor) ?? particle.getFillColor();
3768
3729
  if (strokeHslColor) {
3769
3730
  particle.strokeColor = getHslAnimationFromHsl(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
3770
3731
  }
@@ -3796,7 +3757,7 @@
3796
3757
  }
3797
3758
 
3798
3759
  async function loadPaintUpdater(engine) {
3799
- engine.checkVersion("4.0.5");
3760
+ engine.checkVersion("4.1.1");
3800
3761
  await engine.pluginManager.register(e => {
3801
3762
  e.pluginManager.addParticleUpdater("paint", container => {
3802
3763
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3851,27 +3812,69 @@
3851
3812
  }
3852
3813
 
3853
3814
  async function loadRgbColorPlugin(engine) {
3854
- engine.checkVersion("4.0.5");
3815
+ engine.checkVersion("4.1.1");
3855
3816
  await engine.pluginManager.register(e => {
3856
3817
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3857
3818
  });
3858
3819
  }
3859
3820
 
3821
+ class SizeAnimation extends RangedAnimationOptions {
3822
+ destroy;
3823
+ constructor() {
3824
+ super();
3825
+ this.destroy = DestroyType.none;
3826
+ this.speed = 5;
3827
+ }
3828
+ load(data) {
3829
+ super.load(data);
3830
+ if (isNull(data)) {
3831
+ return;
3832
+ }
3833
+ if (data.destroy !== undefined) {
3834
+ this.destroy = data.destroy;
3835
+ }
3836
+ }
3837
+ }
3838
+
3839
+ class Size extends RangedAnimationValueWithRandom {
3840
+ animation;
3841
+ constructor() {
3842
+ super();
3843
+ this.animation = new SizeAnimation();
3844
+ this.value = 3;
3845
+ }
3846
+ load(data) {
3847
+ super.load(data);
3848
+ if (isNull(data)) {
3849
+ return;
3850
+ }
3851
+ const animation = data.animation;
3852
+ if (animation !== undefined) {
3853
+ this.animation.load(animation);
3854
+ }
3855
+ }
3856
+ }
3857
+
3860
3858
  const minLoops = 0;
3861
3859
  class SizeUpdater {
3862
- _container;
3860
+ #container;
3863
3861
  constructor(container) {
3864
- this._container = container;
3862
+ this.#container = container;
3865
3863
  }
3866
3864
  init(particle) {
3867
- const container = this._container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
3868
- if (sizeAnimation.enable) {
3869
- particle.size.velocity =
3870
- (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3871
- if (!sizeAnimation.sync) {
3872
- particle.size.velocity *= getRandom();
3873
- }
3865
+ const container = this.#container, sizeOptions = particle.options.size;
3866
+ if (!sizeOptions) {
3867
+ return;
3874
3868
  }
3869
+ const sizeAnimation = sizeOptions.animation;
3870
+ if (!sizeAnimation.enable) {
3871
+ return;
3872
+ }
3873
+ particle.size.velocity = (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3874
+ if (sizeAnimation.sync) {
3875
+ return;
3876
+ }
3877
+ particle.size.velocity *= getRandom();
3875
3878
  }
3876
3879
  isEnabled(particle) {
3877
3880
  return (!particle.destroyed &&
@@ -3881,12 +3884,26 @@
3881
3884
  ((particle.size.maxLoops ?? minLoops) > minLoops &&
3882
3885
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3883
3886
  }
3887
+ loadOptions(options, ...sources) {
3888
+ options.size ??= new Size();
3889
+ for (const source of sources) {
3890
+ options.size.load(source?.size);
3891
+ }
3892
+ }
3893
+ preInit(particle) {
3894
+ const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
3895
+ if (!sizeOptions) {
3896
+ return;
3897
+ }
3898
+ particle.size = initParticleNumericAnimationValue(sizeOptions, pxRatio);
3899
+ particle.retina.sizeAnimationSpeed = getRangeValue(sizeOptions.animation.speed) * pxRatio;
3900
+ }
3884
3901
  reset(particle) {
3885
3902
  particle.size.time = 0;
3886
3903
  particle.size.loops = 0;
3887
3904
  }
3888
3905
  update(particle, delta) {
3889
- if (!this.isEnabled(particle)) {
3906
+ if (!this.isEnabled(particle) || !particle.options.size) {
3890
3907
  return;
3891
3908
  }
3892
3909
  updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
@@ -3894,7 +3911,7 @@
3894
3911
  }
3895
3912
 
3896
3913
  async function loadSizeUpdater(engine) {
3897
- engine.checkVersion("4.0.5");
3914
+ engine.checkVersion("4.1.1");
3898
3915
  await engine.pluginManager.register(e => {
3899
3916
  e.pluginManager.addParticleUpdater("size", container => {
3900
3917
  return Promise.resolve(new SizeUpdater(container));
@@ -3903,7 +3920,7 @@
3903
3920
  }
3904
3921
 
3905
3922
  async function loadBasic(engine) {
3906
- engine.checkVersion("4.0.5");
3923
+ engine.checkVersion("4.1.1");
3907
3924
  await engine.pluginManager.register(async (e) => {
3908
3925
  await Promise.all([
3909
3926
  loadBlendPlugin(e),
@@ -4120,13 +4137,15 @@
4120
4137
  mode: PixelMode.precise,
4121
4138
  },
4122
4139
  });
4123
- const factor = identity$2 / getRangeValue(splitOptions.factor.value);
4124
- if (isNumber(splitParticleOptions.size.value)) {
4125
- splitParticleOptions.size.value *= factor;
4126
- }
4127
- else {
4128
- splitParticleOptions.size.value.min *= factor;
4129
- splitParticleOptions.size.value.max *= factor;
4140
+ const factor = identity$2 / getRangeValue(splitOptions.factor.value), sizeOptions = splitParticleOptions["size"];
4141
+ if (sizeOptions) {
4142
+ if (isNumber(sizeOptions.value)) {
4143
+ sizeOptions.value *= factor;
4144
+ }
4145
+ else {
4146
+ sizeOptions.value.min *= factor;
4147
+ sizeOptions.value.max *= factor;
4148
+ }
4130
4149
  }
4131
4150
  splitParticleOptions.load(splitParticlesOptions);
4132
4151
  const splitParticlePaintOptions = itemFromSingleOrMultiple(splitParticleOptions.paint), splitParticleFillOptions = splitParticlePaintOptions?.fill, splitParticleStrokeOptions = splitParticlePaintOptions?.stroke, fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
@@ -4171,14 +4190,14 @@
4171
4190
 
4172
4191
  const defaultDeltaFactor$1 = 1, fpsFactor = 60, minExplodeSpeed = 0.01, maxExplodeProgress = 1;
4173
4192
  class DestroyUpdater {
4174
- _container;
4175
- _pluginManager;
4193
+ #container;
4194
+ #pluginManager;
4176
4195
  constructor(pluginManager, container) {
4177
- this._container = container;
4178
- this._pluginManager = pluginManager;
4196
+ this.#container = container;
4197
+ this.#pluginManager = pluginManager;
4179
4198
  }
4180
4199
  init(particle) {
4181
- const container = this._container, particlesOptions = particle.options, destroyOptions = particlesOptions.destroy;
4200
+ const container = this.#container, particlesOptions = particle.options, destroyOptions = particlesOptions.destroy;
4182
4201
  if (!destroyOptions) {
4183
4202
  return;
4184
4203
  }
@@ -4217,7 +4236,7 @@
4217
4236
  const destroyOptions = particle.options.destroy;
4218
4237
  switch (destroyOptions?.mode) {
4219
4238
  case DestroyMode.split:
4220
- split(this._pluginManager, this._container, particle);
4239
+ split(this.#pluginManager, this.#container, particle);
4221
4240
  break;
4222
4241
  case DestroyMode.explode: {
4223
4242
  if (particle.exploding) {
@@ -4273,7 +4292,7 @@
4273
4292
  }
4274
4293
 
4275
4294
  async function loadDestroyUpdater(engine) {
4276
- engine.checkVersion("4.0.5");
4295
+ engine.checkVersion("4.1.1");
4277
4296
  await engine.pluginManager.register(e => {
4278
4297
  e.pluginManager.addParticleUpdater("destroy", container => {
4279
4298
  return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
@@ -4490,13 +4509,13 @@
4490
4509
 
4491
4510
  class EmittersPlugin {
4492
4511
  id = "emitters";
4493
- _instancesManager;
4512
+ #instancesManager;
4494
4513
  constructor(instancesManager) {
4495
- this._instancesManager = instancesManager;
4514
+ this.#instancesManager = instancesManager;
4496
4515
  }
4497
4516
  async getPlugin(container) {
4498
4517
  const { EmittersPluginInstance } = await Promise.resolve().then(function () { return EmittersPluginInstance$1; });
4499
- return new EmittersPluginInstance(this._instancesManager, container);
4518
+ return new EmittersPluginInstance(this.#instancesManager, container);
4500
4519
  }
4501
4520
  loadOptions(_container, options, source) {
4502
4521
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
@@ -4566,7 +4585,7 @@
4566
4585
  })(EmitterClickMode || (EmitterClickMode = {}));
4567
4586
 
4568
4587
  async function loadEmittersPluginSimple(engine) {
4569
- engine.checkVersion("4.0.5");
4588
+ engine.checkVersion("4.1.1");
4570
4589
  await engine.pluginManager.register(async (e) => {
4571
4590
  const instancesManager = await getEmittersInstancesManager(e);
4572
4591
  await addEmittersShapesManager(e);
@@ -4654,7 +4673,7 @@
4654
4673
  }
4655
4674
 
4656
4675
  async function loadEmittersShapeSquare(engine) {
4657
- engine.checkVersion("4.0.5");
4676
+ engine.checkVersion("4.1.1");
4658
4677
  await engine.pluginManager.register((e) => {
4659
4678
  ensureEmittersPluginLoaded(e);
4660
4679
  e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
@@ -4771,12 +4790,12 @@
4771
4790
 
4772
4791
  const noTime = 0, identity$1 = 1, infiniteValue = -1;
4773
4792
  class LifeUpdater {
4774
- container;
4793
+ #container;
4775
4794
  constructor(container) {
4776
- this.container = container;
4795
+ this.#container = container;
4777
4796
  }
4778
4797
  init(particle) {
4779
- const container = this.container, particlesOptions = particle.options, lifeOptions = particlesOptions.life;
4798
+ const container = this.#container, particlesOptions = particle.options, lifeOptions = particlesOptions.life;
4780
4799
  if (!lifeOptions) {
4781
4800
  return;
4782
4801
  }
@@ -4815,12 +4834,12 @@
4815
4834
  if (!this.isEnabled(particle) || !particle.life) {
4816
4835
  return;
4817
4836
  }
4818
- updateLife(particle, delta, this.container.canvas.size);
4837
+ updateLife(particle, delta, this.#container.canvas.size);
4819
4838
  }
4820
4839
  }
4821
4840
 
4822
4841
  async function loadLifeUpdater(engine) {
4823
- engine.checkVersion("4.0.5");
4842
+ engine.checkVersion("4.1.1");
4824
4843
  await engine.pluginManager.register(e => {
4825
4844
  e.pluginManager.addParticleUpdater("life", container => {
4826
4845
  return Promise.resolve(new LifeUpdater(container));
@@ -4846,7 +4865,7 @@
4846
4865
  }
4847
4866
 
4848
4867
  async function loadLineShape(engine) {
4849
- engine.checkVersion("4.0.5");
4868
+ engine.checkVersion("4.1.1");
4850
4869
  await engine.pluginManager.register(e => {
4851
4870
  e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
4852
4871
  });
@@ -4910,9 +4929,9 @@
4910
4929
 
4911
4930
  const doublePIDeg = 360;
4912
4931
  class RotateUpdater {
4913
- container;
4932
+ #container;
4914
4933
  constructor(container) {
4915
- this.container = container;
4934
+ this.#container = container;
4916
4935
  }
4917
4936
  init(particle) {
4918
4937
  const rotateOptions = particle.options.rotate;
@@ -4944,7 +4963,7 @@
4944
4963
  if (rotateAnimation.enable) {
4945
4964
  particle.rotate.decay = identity$2 - getRangeValue(rotateAnimation.decay);
4946
4965
  particle.rotate.velocity =
4947
- (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
4966
+ (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.#container.retina.reduceFactor;
4948
4967
  if (!rotateAnimation.sync) {
4949
4968
  particle.rotate.velocity *= getRandom();
4950
4969
  }
@@ -4978,7 +4997,7 @@
4978
4997
  }
4979
4998
 
4980
4999
  async function loadRotateUpdater(engine) {
4981
- engine.checkVersion("4.0.5");
5000
+ engine.checkVersion("4.1.1");
4982
5001
  await engine.pluginManager.register(e => {
4983
5002
  e.pluginManager.addParticleUpdater("rotate", container => {
4984
5003
  return Promise.resolve(new RotateUpdater(container));
@@ -5329,9 +5348,9 @@
5329
5348
  };
5330
5349
  class SoundsPlugin {
5331
5350
  id = "sounds";
5332
- _engine;
5351
+ #engine;
5333
5352
  constructor(engine) {
5334
- this._engine = engine;
5353
+ this.#engine = engine;
5335
5354
  const listenerOptions = {
5336
5355
  capture: true,
5337
5356
  once: true,
@@ -5341,7 +5360,7 @@
5341
5360
  }
5342
5361
  async getPlugin(container) {
5343
5362
  const { SoundsPluginInstance } = await Promise.resolve().then(function () { return SoundsPluginInstance$1; });
5344
- return new SoundsPluginInstance(container, this._engine);
5363
+ return new SoundsPluginInstance(container, this.#engine);
5345
5364
  }
5346
5365
  loadOptions(_container, options, source) {
5347
5366
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
@@ -5359,13 +5378,13 @@
5359
5378
  }
5360
5379
 
5361
5380
  async function loadSoundsPlugin(engine) {
5362
- engine.checkVersion("4.0.5");
5381
+ engine.checkVersion("4.1.1");
5363
5382
  await engine.pluginManager.register(e => {
5364
5383
  e.pluginManager.addPlugin(new SoundsPlugin(e));
5365
5384
  });
5366
5385
  }
5367
5386
 
5368
- const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0;
5387
+ const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0, defaultWidth = 0, minBound = 0;
5369
5388
  const defaultTransform = {
5370
5389
  a: 1,
5371
5390
  b: 0,
@@ -5373,12 +5392,12 @@
5373
5392
  d: 1,
5374
5393
  };
5375
5394
  class TrailDrawer {
5376
- _container;
5395
+ #container;
5377
5396
  constructor(container) {
5378
- this._container = container;
5397
+ this.#container = container;
5379
5398
  }
5380
5399
  drawAfter(data) {
5381
- const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this._container, diameter = drawRadius * double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
5400
+ const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this.#container, diameter = drawRadius * double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
5382
5401
  if (!trail || !particle.trailLength) {
5383
5402
  return;
5384
5403
  }
@@ -5426,6 +5445,39 @@
5426
5445
  }
5427
5446
  context.restore();
5428
5447
  }
5448
+ isInsideCanvas(data) {
5449
+ const { canvasSize, direction, outMode, particle, radius } = data, position = particle.position, trail = particle.trail;
5450
+ let minX = position.x - radius, maxX = position.x + radius, minY = position.y - radius, maxY = position.y + radius;
5451
+ if (trail?.length) {
5452
+ const widthPadding = Math.max(radius, particle.trailMaxWidth ?? defaultWidth, particle.trailMinWidth ?? defaultWidth);
5453
+ for (const step of trail) {
5454
+ minX = Math.min(minX, step.position.x - widthPadding);
5455
+ maxX = Math.max(maxX, step.position.x + widthPadding);
5456
+ minY = Math.min(minY, step.position.y - widthPadding);
5457
+ maxY = Math.max(maxY, step.position.y + widthPadding);
5458
+ }
5459
+ }
5460
+ const strictBounds = outMode === OutMode.destroy;
5461
+ if (direction === OutModeDirection.bottom) {
5462
+ return minY <= canvasSize.height;
5463
+ }
5464
+ if (direction === OutModeDirection.left) {
5465
+ return maxX >= minBound;
5466
+ }
5467
+ if (direction === OutModeDirection.right) {
5468
+ return minX <= canvasSize.width;
5469
+ }
5470
+ if (direction === OutModeDirection.top) {
5471
+ return maxY >= minBound;
5472
+ }
5473
+ if (!strictBounds) {
5474
+ return (position.x + radius >= minBound &&
5475
+ position.y + radius >= minBound &&
5476
+ position.x - radius <= canvasSize.width &&
5477
+ position.y - radius <= canvasSize.height);
5478
+ }
5479
+ return maxX >= minBound && maxY >= minBound && minX <= canvasSize.width && minY <= canvasSize.height;
5480
+ }
5429
5481
  particleInit(container, particle) {
5430
5482
  particle.trail = [];
5431
5483
  const effectData = particle.effectData;
@@ -5442,7 +5494,7 @@
5442
5494
  }
5443
5495
 
5444
5496
  async function loadTrailEffect(engine) {
5445
- engine.checkVersion("4.0.5");
5497
+ engine.checkVersion("4.1.1");
5446
5498
  await engine.pluginManager.register(e => {
5447
5499
  e.pluginManager.addEffect("trail", container => {
5448
5500
  return Promise.resolve(new TrailDrawer(container));
@@ -5483,58 +5535,58 @@
5483
5535
  }
5484
5536
  }
5485
5537
  class RenderManager {
5486
- _canvasClearPlugins;
5487
- _canvasManager;
5488
- _canvasPaintPlugins;
5489
- _clearDrawPlugins;
5490
- _colorPlugins;
5491
- _container;
5492
- _context;
5493
- _contextSettings;
5494
- _drawParticlePlugins;
5495
- _drawParticlesCleanupPlugins;
5496
- _drawParticlesSetupPlugins;
5497
- _drawPlugins;
5498
- _drawSettingsCleanupPlugins;
5499
- _drawSettingsSetupPlugins;
5500
- _pluginManager;
5501
- _postDrawUpdaters;
5502
- _preDrawUpdaters;
5503
- _reusableColorStyles = {};
5504
- _reusablePluginColors = [undefined, undefined];
5505
- _reusableTransform = {};
5538
+ #canvasClearPlugins;
5539
+ #canvasManager;
5540
+ #canvasPaintPlugins;
5541
+ #clearDrawPlugins;
5542
+ #colorPlugins;
5543
+ #container;
5544
+ #context;
5545
+ #contextSettings;
5546
+ #drawParticlePlugins;
5547
+ #drawParticlesCleanupPlugins;
5548
+ #drawParticlesSetupPlugins;
5549
+ #drawPlugins;
5550
+ #drawSettingsCleanupPlugins;
5551
+ #drawSettingsSetupPlugins;
5552
+ #pluginManager;
5553
+ #postDrawUpdaters;
5554
+ #preDrawUpdaters;
5555
+ #reusableColorStyles = {};
5556
+ #reusablePluginColors = [undefined, undefined];
5557
+ #reusableTransform = {};
5506
5558
  constructor(pluginManager, container, canvasManager) {
5507
- this._pluginManager = pluginManager;
5508
- this._container = container;
5509
- this._canvasManager = canvasManager;
5510
- this._context = null;
5511
- this._preDrawUpdaters = [];
5512
- this._postDrawUpdaters = [];
5513
- this._colorPlugins = [];
5514
- this._canvasClearPlugins = [];
5515
- this._canvasPaintPlugins = [];
5516
- this._clearDrawPlugins = [];
5517
- this._drawParticlePlugins = [];
5518
- this._drawParticlesCleanupPlugins = [];
5519
- this._drawParticlesSetupPlugins = [];
5520
- this._drawPlugins = [];
5521
- this._drawSettingsSetupPlugins = [];
5522
- this._drawSettingsCleanupPlugins = [];
5559
+ this.#pluginManager = pluginManager;
5560
+ this.#container = container;
5561
+ this.#canvasManager = canvasManager;
5562
+ this.#context = null;
5563
+ this.#preDrawUpdaters = [];
5564
+ this.#postDrawUpdaters = [];
5565
+ this.#colorPlugins = [];
5566
+ this.#canvasClearPlugins = [];
5567
+ this.#canvasPaintPlugins = [];
5568
+ this.#clearDrawPlugins = [];
5569
+ this.#drawParticlePlugins = [];
5570
+ this.#drawParticlesCleanupPlugins = [];
5571
+ this.#drawParticlesSetupPlugins = [];
5572
+ this.#drawPlugins = [];
5573
+ this.#drawSettingsSetupPlugins = [];
5574
+ this.#drawSettingsCleanupPlugins = [];
5523
5575
  }
5524
5576
  get settings() {
5525
- return this._contextSettings;
5577
+ return this.#contextSettings;
5526
5578
  }
5527
5579
  canvasClear() {
5528
- if (!this._container.actualOptions.clear) {
5580
+ if (!this.#container.actualOptions.clear) {
5529
5581
  return;
5530
5582
  }
5531
5583
  this.draw(ctx => {
5532
- clear(ctx, this._canvasManager.size);
5584
+ clear(ctx, this.#canvasManager.size);
5533
5585
  });
5534
5586
  }
5535
5587
  clear() {
5536
5588
  let pluginHandled = false;
5537
- for (const plugin of this._canvasClearPlugins) {
5589
+ for (const plugin of this.#canvasClearPlugins) {
5538
5590
  pluginHandled = plugin.canvasClear?.() ?? false;
5539
5591
  if (pluginHandled) {
5540
5592
  break;
@@ -5547,21 +5599,21 @@
5547
5599
  }
5548
5600
  destroy() {
5549
5601
  this.stop();
5550
- this._preDrawUpdaters = [];
5551
- this._postDrawUpdaters = [];
5552
- this._colorPlugins = [];
5553
- this._canvasClearPlugins = [];
5554
- this._canvasPaintPlugins = [];
5555
- this._clearDrawPlugins = [];
5556
- this._drawParticlePlugins = [];
5557
- this._drawParticlesCleanupPlugins = [];
5558
- this._drawParticlesSetupPlugins = [];
5559
- this._drawPlugins = [];
5560
- this._drawSettingsSetupPlugins = [];
5561
- this._drawSettingsCleanupPlugins = [];
5602
+ this.#preDrawUpdaters = [];
5603
+ this.#postDrawUpdaters = [];
5604
+ this.#colorPlugins = [];
5605
+ this.#canvasClearPlugins = [];
5606
+ this.#canvasPaintPlugins = [];
5607
+ this.#clearDrawPlugins = [];
5608
+ this.#drawParticlePlugins = [];
5609
+ this.#drawParticlesCleanupPlugins = [];
5610
+ this.#drawParticlesSetupPlugins = [];
5611
+ this.#drawPlugins = [];
5612
+ this.#drawSettingsSetupPlugins = [];
5613
+ this.#drawSettingsCleanupPlugins = [];
5562
5614
  }
5563
5615
  draw(cb) {
5564
- const ctx = this._context;
5616
+ const ctx = this.#context;
5565
5617
  if (!ctx) {
5566
5618
  return;
5567
5619
  }
@@ -5576,21 +5628,21 @@
5576
5628
  return;
5577
5629
  }
5578
5630
  const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
5579
- let [fColor, sColor] = this._getPluginParticleColors(particle);
5631
+ let [fColor, sColor] = this.#getPluginParticleColors(particle);
5580
5632
  fColor ??= pfColor;
5581
5633
  sColor ??= psColor;
5582
5634
  if (!fColor && !sColor) {
5583
5635
  return;
5584
5636
  }
5585
- 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;
5637
+ 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;
5586
5638
  transform.a = transform.b = transform.c = transform.d = undefined;
5587
5639
  colorStyles.fill = fill;
5588
5640
  colorStyles.stroke = stroke;
5589
5641
  this.draw((context) => {
5590
- for (const plugin of this._drawParticlesSetupPlugins) {
5642
+ for (const plugin of this.#drawParticlesSetupPlugins) {
5591
5643
  plugin.drawParticleSetup?.(context, particle, delta);
5592
5644
  }
5593
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
5645
+ this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
5594
5646
  drawParticle({
5595
5647
  container,
5596
5648
  context,
@@ -5601,35 +5653,35 @@
5601
5653
  opacity: opacity,
5602
5654
  transform,
5603
5655
  });
5604
- this._applyPostDrawUpdaters(particle);
5605
- for (const plugin of this._drawParticlesCleanupPlugins) {
5656
+ this.#applyPostDrawUpdaters(particle);
5657
+ for (const plugin of this.#drawParticlesCleanupPlugins) {
5606
5658
  plugin.drawParticleCleanup?.(context, particle, delta);
5607
5659
  }
5608
5660
  });
5609
5661
  }
5610
5662
  drawParticlePlugins(particle, delta) {
5611
5663
  this.draw(ctx => {
5612
- for (const plugin of this._drawParticlePlugins) {
5664
+ for (const plugin of this.#drawParticlePlugins) {
5613
5665
  drawParticlePlugin(ctx, plugin, particle, delta);
5614
5666
  }
5615
5667
  });
5616
5668
  }
5617
5669
  drawParticles(delta) {
5618
- const { particles } = this._container;
5670
+ const { particles } = this.#container;
5619
5671
  this.clear();
5620
5672
  particles.update(delta);
5621
5673
  this.draw(ctx => {
5622
- for (const plugin of this._drawSettingsSetupPlugins) {
5674
+ for (const plugin of this.#drawSettingsSetupPlugins) {
5623
5675
  plugin.drawSettingsSetup?.(ctx, delta);
5624
5676
  }
5625
- for (const plugin of this._drawPlugins) {
5677
+ for (const plugin of this.#drawPlugins) {
5626
5678
  plugin.draw?.(ctx, delta);
5627
5679
  }
5628
5680
  particles.drawParticles(delta);
5629
- for (const plugin of this._clearDrawPlugins) {
5681
+ for (const plugin of this.#clearDrawPlugins) {
5630
5682
  plugin.clearDraw?.(ctx, delta);
5631
5683
  }
5632
- for (const plugin of this._drawSettingsCleanupPlugins) {
5684
+ for (const plugin of this.#drawSettingsCleanupPlugins) {
5633
5685
  plugin.drawSettingsCleanup?.(ctx, delta);
5634
5686
  }
5635
5687
  });
@@ -5640,64 +5692,64 @@
5640
5692
  this.paint();
5641
5693
  }
5642
5694
  initPlugins() {
5643
- this._colorPlugins = [];
5644
- this._canvasClearPlugins = [];
5645
- this._canvasPaintPlugins = [];
5646
- this._clearDrawPlugins = [];
5647
- this._drawParticlePlugins = [];
5648
- this._drawParticlesSetupPlugins = [];
5649
- this._drawParticlesCleanupPlugins = [];
5650
- this._drawPlugins = [];
5651
- this._drawSettingsSetupPlugins = [];
5652
- this._drawSettingsCleanupPlugins = [];
5653
- for (const plugin of this._container.plugins) {
5695
+ this.#colorPlugins = [];
5696
+ this.#canvasClearPlugins = [];
5697
+ this.#canvasPaintPlugins = [];
5698
+ this.#clearDrawPlugins = [];
5699
+ this.#drawParticlePlugins = [];
5700
+ this.#drawParticlesSetupPlugins = [];
5701
+ this.#drawParticlesCleanupPlugins = [];
5702
+ this.#drawPlugins = [];
5703
+ this.#drawSettingsSetupPlugins = [];
5704
+ this.#drawSettingsCleanupPlugins = [];
5705
+ for (const plugin of this.#container.plugins) {
5654
5706
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
5655
- this._colorPlugins.push(plugin);
5707
+ this.#colorPlugins.push(plugin);
5656
5708
  }
5657
5709
  if (plugin.canvasClear) {
5658
- this._canvasClearPlugins.push(plugin);
5710
+ this.#canvasClearPlugins.push(plugin);
5659
5711
  }
5660
5712
  if (plugin.canvasPaint) {
5661
- this._canvasPaintPlugins.push(plugin);
5713
+ this.#canvasPaintPlugins.push(plugin);
5662
5714
  }
5663
5715
  if (plugin.drawParticle) {
5664
- this._drawParticlePlugins.push(plugin);
5716
+ this.#drawParticlePlugins.push(plugin);
5665
5717
  }
5666
5718
  if (plugin.drawParticleSetup) {
5667
- this._drawParticlesSetupPlugins.push(plugin);
5719
+ this.#drawParticlesSetupPlugins.push(plugin);
5668
5720
  }
5669
5721
  if (plugin.drawParticleCleanup) {
5670
- this._drawParticlesCleanupPlugins.push(plugin);
5722
+ this.#drawParticlesCleanupPlugins.push(plugin);
5671
5723
  }
5672
5724
  if (plugin.draw) {
5673
- this._drawPlugins.push(plugin);
5725
+ this.#drawPlugins.push(plugin);
5674
5726
  }
5675
5727
  if (plugin.drawSettingsSetup) {
5676
- this._drawSettingsSetupPlugins.push(plugin);
5728
+ this.#drawSettingsSetupPlugins.push(plugin);
5677
5729
  }
5678
5730
  if (plugin.drawSettingsCleanup) {
5679
- this._drawSettingsCleanupPlugins.push(plugin);
5731
+ this.#drawSettingsCleanupPlugins.push(plugin);
5680
5732
  }
5681
5733
  if (plugin.clearDraw) {
5682
- this._clearDrawPlugins.push(plugin);
5734
+ this.#clearDrawPlugins.push(plugin);
5683
5735
  }
5684
5736
  }
5685
5737
  }
5686
5738
  initUpdaters() {
5687
- this._preDrawUpdaters = [];
5688
- this._postDrawUpdaters = [];
5689
- for (const updater of this._container.particleUpdaters) {
5739
+ this.#preDrawUpdaters = [];
5740
+ this.#postDrawUpdaters = [];
5741
+ for (const updater of this.#container.particleUpdaters) {
5690
5742
  if (updater.afterDraw) {
5691
- this._postDrawUpdaters.push(updater);
5743
+ this.#postDrawUpdaters.push(updater);
5692
5744
  }
5693
5745
  if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
5694
- this._preDrawUpdaters.push(updater);
5746
+ this.#preDrawUpdaters.push(updater);
5695
5747
  }
5696
5748
  }
5697
5749
  }
5698
5750
  paint() {
5699
5751
  let handled = false;
5700
- for (const plugin of this._canvasPaintPlugins) {
5752
+ for (const plugin of this.#canvasPaintPlugins) {
5701
5753
  handled = plugin.canvasPaint?.() ?? false;
5702
5754
  if (handled) {
5703
5755
  break;
@@ -5710,35 +5762,35 @@
5710
5762
  }
5711
5763
  paintBase(baseColor) {
5712
5764
  this.draw(ctx => {
5713
- paintBase(ctx, this._canvasManager.size, baseColor);
5765
+ paintBase(ctx, this.#canvasManager.size, baseColor);
5714
5766
  });
5715
5767
  }
5716
5768
  paintImage(image, opacity) {
5717
5769
  this.draw(ctx => {
5718
- paintImage(ctx, this._canvasManager.size, image, opacity);
5770
+ paintImage(ctx, this.#canvasManager.size, image, opacity);
5719
5771
  });
5720
5772
  }
5721
5773
  setContext(context) {
5722
- this._context = context;
5723
- if (this._context) {
5724
- this._context.globalCompositeOperation = defaultCompositeValue;
5774
+ this.#context = context;
5775
+ if (this.#context) {
5776
+ this.#context.globalCompositeOperation = defaultCompositeValue;
5725
5777
  }
5726
5778
  }
5727
5779
  setContextSettings(settings) {
5728
- this._contextSettings = settings;
5780
+ this.#contextSettings = settings;
5729
5781
  }
5730
5782
  stop() {
5731
5783
  this.draw(ctx => {
5732
- clear(ctx, this._canvasManager.size);
5784
+ clear(ctx, this.#canvasManager.size);
5733
5785
  });
5734
5786
  }
5735
- _applyPostDrawUpdaters = particle => {
5736
- for (const updater of this._postDrawUpdaters) {
5787
+ #applyPostDrawUpdaters = particle => {
5788
+ for (const updater of this.#postDrawUpdaters) {
5737
5789
  updater.afterDraw?.(particle);
5738
5790
  }
5739
5791
  };
5740
- _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
5741
- for (const updater of this._preDrawUpdaters) {
5792
+ #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
5793
+ for (const updater of this.#preDrawUpdaters) {
5742
5794
  if (updater.getColorStyles) {
5743
5795
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
5744
5796
  if (fill) {
@@ -5757,22 +5809,22 @@
5757
5809
  updater.beforeDraw?.(particle);
5758
5810
  }
5759
5811
  };
5760
- _getPluginParticleColors = particle => {
5812
+ #getPluginParticleColors = particle => {
5761
5813
  let fColor, sColor;
5762
- for (const plugin of this._colorPlugins) {
5814
+ for (const plugin of this.#colorPlugins) {
5763
5815
  if (!fColor && plugin.particleFillColor) {
5764
- fColor = rangeColorToHsl(this._pluginManager, plugin.particleFillColor(particle));
5816
+ fColor = rangeColorToHsl(this.#pluginManager, plugin.particleFillColor(particle));
5765
5817
  }
5766
5818
  if (!sColor && plugin.particleStrokeColor) {
5767
- sColor = rangeColorToHsl(this._pluginManager, plugin.particleStrokeColor(particle));
5819
+ sColor = rangeColorToHsl(this.#pluginManager, plugin.particleStrokeColor(particle));
5768
5820
  }
5769
5821
  if (fColor && sColor) {
5770
5822
  break;
5771
5823
  }
5772
5824
  }
5773
- this._reusablePluginColors[fColorIndex] = fColor;
5774
- this._reusablePluginColors[sColorIndex] = sColor;
5775
- return this._reusablePluginColors;
5825
+ this.#reusablePluginColors[fColorIndex] = fColor;
5826
+ this.#reusablePluginColors[sColorIndex] = sColor;
5827
+ return this.#reusablePluginColors;
5776
5828
  };
5777
5829
  }
5778
5830
 
@@ -5830,53 +5882,53 @@
5830
5882
  renderCanvas;
5831
5883
  size;
5832
5884
  zoom = defaultZoom;
5833
- _container;
5834
- _generated;
5835
- _mutationObserver;
5836
- _originalStyle;
5837
- _pluginManager;
5838
- _pointerEvents;
5839
- _resizePlugins;
5840
- _standardSize;
5841
- _zoomCenter;
5885
+ #container;
5886
+ #generated;
5887
+ #mutationObserver;
5888
+ #originalStyle;
5889
+ #pluginManager;
5890
+ #pointerEvents;
5891
+ #resizePlugins;
5892
+ #standardSize;
5893
+ #zoomCenter;
5842
5894
  constructor(pluginManager, container) {
5843
- this._pluginManager = pluginManager;
5844
- this._container = container;
5895
+ this.#pluginManager = pluginManager;
5896
+ this.#container = container;
5845
5897
  this.render = new RenderManager(pluginManager, container, this);
5846
- this._standardSize = {
5898
+ this.#standardSize = {
5847
5899
  height: 0,
5848
5900
  width: 0,
5849
5901
  };
5850
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
5902
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
5851
5903
  this.size = {
5852
5904
  height: stdSize.height * pxRatio,
5853
5905
  width: stdSize.width * pxRatio,
5854
5906
  };
5855
- this._generated = false;
5856
- this._resizePlugins = [];
5857
- this._pointerEvents = "none";
5907
+ this.#generated = false;
5908
+ this.#resizePlugins = [];
5909
+ this.#pointerEvents = "none";
5858
5910
  }
5859
- get _fullScreen() {
5860
- return this._container.actualOptions.fullScreen.enable;
5911
+ get #fullScreen() {
5912
+ return this.#container.actualOptions.fullScreen.enable;
5861
5913
  }
5862
5914
  destroy() {
5863
5915
  this.stop();
5864
- if (this._generated) {
5916
+ if (this.#generated) {
5865
5917
  const element = this.domElement;
5866
5918
  element?.remove();
5867
5919
  this.domElement = undefined;
5868
5920
  this.renderCanvas = undefined;
5869
5921
  }
5870
5922
  else {
5871
- this._resetOriginalStyle();
5923
+ this.#resetOriginalStyle();
5872
5924
  }
5873
5925
  this.render.destroy();
5874
- this._resizePlugins = [];
5926
+ this.#resizePlugins = [];
5875
5927
  }
5876
5928
  getZoomCenter() {
5877
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
5878
- if (this._zoomCenter) {
5879
- return this._zoomCenter;
5929
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
5930
+ if (this.#zoomCenter) {
5931
+ return this.#zoomCenter;
5880
5932
  }
5881
5933
  return {
5882
5934
  x: (width * half) / pxRatio,
@@ -5884,20 +5936,20 @@
5884
5936
  };
5885
5937
  }
5886
5938
  init() {
5887
- this._safeMutationObserver(obs => {
5939
+ this.#safeMutationObserver(obs => {
5888
5940
  obs.disconnect();
5889
5941
  });
5890
- this._mutationObserver = safeMutationObserver(records => {
5942
+ this.#mutationObserver = safeMutationObserver(records => {
5891
5943
  for (const record of records) {
5892
5944
  if (record.type === "attributes" && record.attributeName === "style") {
5893
- this._repairStyle();
5945
+ this.#repairStyle();
5894
5946
  }
5895
5947
  }
5896
5948
  });
5897
5949
  this.resize();
5898
- this._initStyle();
5950
+ this.#initStyle();
5899
5951
  this.initBackground();
5900
- this._safeMutationObserver(obs => {
5952
+ this.#safeMutationObserver(obs => {
5901
5953
  const element = this.domElement;
5902
5954
  if (!element || !(element instanceof Node)) {
5903
5955
  return;
@@ -5908,13 +5960,13 @@
5908
5960
  this.render.init();
5909
5961
  }
5910
5962
  initBackground() {
5911
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
5963
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
5912
5964
  if (!element) {
5913
5965
  return;
5914
5966
  }
5915
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
5967
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
5916
5968
  if (color) {
5917
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
5969
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
5918
5970
  }
5919
5971
  else {
5920
5972
  elementStyle.backgroundColor = "";
@@ -5925,27 +5977,27 @@
5925
5977
  elementStyle.backgroundSize = background.size || "";
5926
5978
  }
5927
5979
  initPlugins() {
5928
- this._resizePlugins = [];
5929
- for (const plugin of this._container.plugins) {
5980
+ this.#resizePlugins = [];
5981
+ for (const plugin of this.#container.plugins) {
5930
5982
  if (plugin.resize) {
5931
- this._resizePlugins.push(plugin);
5983
+ this.#resizePlugins.push(plugin);
5932
5984
  }
5933
5985
  }
5934
5986
  }
5935
5987
  loadCanvas(canvas) {
5936
- if (this._generated && this.domElement) {
5988
+ if (this.#generated && this.domElement) {
5937
5989
  this.domElement.remove();
5938
5990
  }
5939
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
5991
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
5940
5992
  this.domElement = domCanvas;
5941
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
5993
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
5942
5994
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
5943
5995
  const domElement = this.domElement;
5944
5996
  if (domElement) {
5945
5997
  domElement.ariaHidden = "true";
5946
- this._originalStyle = cloneStyle(domElement.style);
5998
+ this.#originalStyle = cloneStyle(domElement.style);
5947
5999
  }
5948
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
6000
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
5949
6001
  if (domElement) {
5950
6002
  standardSize.height = domElement.offsetHeight;
5951
6003
  standardSize.width = domElement.offsetWidth;
@@ -5954,7 +6006,7 @@
5954
6006
  standardSize.height = renderCanvas.height;
5955
6007
  standardSize.width = renderCanvas.width;
5956
6008
  }
5957
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
6009
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
5958
6010
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
5959
6011
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
5960
6012
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -5965,12 +6017,12 @@
5965
6017
  willReadFrequently: false,
5966
6018
  });
5967
6019
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
5968
- this._safeMutationObserver(obs => {
6020
+ this.#safeMutationObserver(obs => {
5969
6021
  obs.disconnect();
5970
6022
  });
5971
6023
  container.retina.init();
5972
6024
  this.initBackground();
5973
- this._safeMutationObserver(obs => {
6025
+ this.#safeMutationObserver(obs => {
5974
6026
  const element = this.domElement;
5975
6027
  if (!element || !(element instanceof Node)) {
5976
6028
  return;
@@ -5983,11 +6035,11 @@
5983
6035
  if (!element) {
5984
6036
  return false;
5985
6037
  }
5986
- const container = this._container, renderCanvas = this.renderCanvas;
6038
+ const container = this.#container, renderCanvas = this.renderCanvas;
5987
6039
  if (renderCanvas === undefined) {
5988
6040
  return false;
5989
6041
  }
5990
- const currentSize = container.canvas._standardSize, newSize = {
6042
+ const currentSize = container.canvas.#standardSize, newSize = {
5991
6043
  width: element.offsetWidth,
5992
6044
  height: element.offsetHeight,
5993
6045
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -6006,7 +6058,7 @@
6006
6058
  const canvasSize = this.size;
6007
6059
  renderCanvas.width = canvasSize.width = retinaSize.width;
6008
6060
  renderCanvas.height = canvasSize.height = retinaSize.height;
6009
- if (this._container.started) {
6061
+ if (this.#container.started) {
6010
6062
  container.particles.setResizeFactor({
6011
6063
  width: currentSize.width / oldSize.width,
6012
6064
  height: currentSize.height / oldSize.height,
@@ -6019,46 +6071,46 @@
6019
6071
  if (!element) {
6020
6072
  return;
6021
6073
  }
6022
- this._pointerEvents = type;
6023
- this._repairStyle();
6074
+ this.#pointerEvents = type;
6075
+ this.#repairStyle();
6024
6076
  }
6025
6077
  setZoom(zoomLevel, center) {
6026
6078
  this.zoom = zoomLevel;
6027
- this._zoomCenter = center;
6079
+ this.#zoomCenter = center;
6028
6080
  }
6029
6081
  stop() {
6030
- this._safeMutationObserver(obs => {
6082
+ this.#safeMutationObserver(obs => {
6031
6083
  obs.disconnect();
6032
6084
  });
6033
- this._mutationObserver = undefined;
6085
+ this.#mutationObserver = undefined;
6034
6086
  this.render.stop();
6035
6087
  }
6036
6088
  async windowResize() {
6037
6089
  if (!this.domElement || !this.resize()) {
6038
6090
  return;
6039
6091
  }
6040
- const container = this._container, needsRefresh = container.updateActualOptions();
6092
+ const container = this.#container, needsRefresh = container.updateActualOptions();
6041
6093
  container.particles.setDensity();
6042
- this._applyResizePlugins();
6094
+ this.#applyResizePlugins();
6043
6095
  if (needsRefresh) {
6044
6096
  await container.refresh();
6045
6097
  }
6046
6098
  }
6047
- _applyResizePlugins = () => {
6048
- for (const plugin of this._resizePlugins) {
6099
+ #applyResizePlugins = () => {
6100
+ for (const plugin of this.#resizePlugins) {
6049
6101
  plugin.resize?.();
6050
6102
  }
6051
6103
  };
6052
- _initStyle = () => {
6053
- const element = this.domElement, options = this._container.actualOptions;
6104
+ #initStyle = () => {
6105
+ const element = this.domElement, options = this.#container.actualOptions;
6054
6106
  if (!element) {
6055
6107
  return;
6056
6108
  }
6057
- if (this._fullScreen) {
6058
- this._setFullScreenStyle();
6109
+ if (this.#fullScreen) {
6110
+ this.#setFullScreenStyle();
6059
6111
  }
6060
6112
  else {
6061
- this._resetOriginalStyle();
6113
+ this.#resetOriginalStyle();
6062
6114
  }
6063
6115
  for (const key in options.style) {
6064
6116
  if (!key || !(key in options.style)) {
@@ -6071,72 +6123,72 @@
6071
6123
  element.style.setProperty(key, value, "important");
6072
6124
  }
6073
6125
  };
6074
- _repairStyle = () => {
6126
+ #repairStyle = () => {
6075
6127
  const element = this.domElement;
6076
6128
  if (!element) {
6077
6129
  return;
6078
6130
  }
6079
- this._safeMutationObserver(observer => {
6131
+ this.#safeMutationObserver(observer => {
6080
6132
  observer.disconnect();
6081
6133
  });
6082
- this._initStyle();
6134
+ this.#initStyle();
6083
6135
  this.initBackground();
6084
- const pointerEvents = this._pointerEvents;
6136
+ const pointerEvents = this.#pointerEvents;
6085
6137
  element.style.pointerEvents = pointerEvents;
6086
6138
  element.style.setProperty("pointer-events", pointerEvents);
6087
- this._safeMutationObserver(observer => {
6139
+ this.#safeMutationObserver(observer => {
6088
6140
  if (!(element instanceof Node)) {
6089
6141
  return;
6090
6142
  }
6091
6143
  observer.observe(element, { attributes: true });
6092
6144
  });
6093
6145
  };
6094
- _resetOriginalStyle = () => {
6095
- const element = this.domElement, originalStyle = this._originalStyle;
6146
+ #resetOriginalStyle = () => {
6147
+ const element = this.domElement, originalStyle = this.#originalStyle;
6096
6148
  if (!element || !originalStyle) {
6097
6149
  return;
6098
6150
  }
6099
6151
  setStyle(element, originalStyle, true);
6100
6152
  };
6101
- _safeMutationObserver = callback => {
6102
- if (!this._mutationObserver) {
6153
+ #safeMutationObserver = callback => {
6154
+ if (!this.#mutationObserver) {
6103
6155
  return;
6104
6156
  }
6105
- callback(this._mutationObserver);
6157
+ callback(this.#mutationObserver);
6106
6158
  };
6107
- _setFullScreenStyle = () => {
6159
+ #setFullScreenStyle = () => {
6108
6160
  const element = this.domElement;
6109
6161
  if (!element) {
6110
6162
  return;
6111
6163
  }
6112
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
6164
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
6113
6165
  };
6114
6166
  }
6115
6167
 
6116
6168
  class EventListeners {
6117
- container;
6118
- _handlers;
6119
- _resizeObserver;
6120
- _resizeTimeout;
6169
+ #container;
6170
+ #handlers;
6171
+ #resizeObserver;
6172
+ #resizeTimeout;
6121
6173
  constructor(container) {
6122
- this.container = container;
6123
- this._handlers = {
6174
+ this.#container = container;
6175
+ this.#handlers = {
6124
6176
  visibilityChange: () => {
6125
- this._handleVisibilityChange();
6177
+ this.#handleVisibilityChange();
6126
6178
  },
6127
6179
  resize: () => {
6128
- this._handleWindowResize();
6180
+ this.#handleWindowResize();
6129
6181
  },
6130
6182
  };
6131
6183
  }
6132
6184
  addListeners() {
6133
- this._manageListeners(true);
6185
+ this.#manageListeners(true);
6134
6186
  }
6135
6187
  removeListeners() {
6136
- this._manageListeners(false);
6188
+ this.#manageListeners(false);
6137
6189
  }
6138
- _handleVisibilityChange = () => {
6139
- const container = this.container, options = container.actualOptions;
6190
+ #handleVisibilityChange = () => {
6191
+ const container = this.#container, options = container.actualOptions;
6140
6192
  if (!options.pauseOnBlur) {
6141
6193
  return;
6142
6194
  }
@@ -6154,24 +6206,24 @@
6154
6206
  }
6155
6207
  }
6156
6208
  };
6157
- _handleWindowResize = () => {
6158
- if (this._resizeTimeout) {
6159
- clearTimeout(this._resizeTimeout);
6160
- delete this._resizeTimeout;
6209
+ #handleWindowResize = () => {
6210
+ if (this.#resizeTimeout) {
6211
+ clearTimeout(this.#resizeTimeout);
6212
+ this.#resizeTimeout = undefined;
6161
6213
  }
6162
6214
  const handleResize = async () => {
6163
- const canvas = this.container.canvas;
6215
+ const canvas = this.#container.canvas;
6164
6216
  await canvas.windowResize();
6165
6217
  };
6166
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
6218
+ this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
6167
6219
  };
6168
- _manageListeners = add => {
6169
- const handlers = this._handlers;
6170
- this._manageResize(add);
6220
+ #manageListeners = add => {
6221
+ const handlers = this.#handlers;
6222
+ this.#manageResize(add);
6171
6223
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
6172
6224
  };
6173
- _manageResize = add => {
6174
- const handlers = this._handlers, container = this.container, options = container.actualOptions;
6225
+ #manageResize = add => {
6226
+ const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
6175
6227
  if (!options.resize.enable) {
6176
6228
  return;
6177
6229
  }
@@ -6180,22 +6232,22 @@
6180
6232
  return;
6181
6233
  }
6182
6234
  const canvasEl = container.canvas.domElement;
6183
- if (this._resizeObserver && !add) {
6235
+ if (this.#resizeObserver && !add) {
6184
6236
  if (canvasEl) {
6185
- this._resizeObserver.unobserve(canvasEl);
6237
+ this.#resizeObserver.unobserve(canvasEl);
6186
6238
  }
6187
- this._resizeObserver.disconnect();
6188
- delete this._resizeObserver;
6239
+ this.#resizeObserver.disconnect();
6240
+ this.#resizeObserver = undefined;
6189
6241
  }
6190
- else if (!this._resizeObserver && add && canvasEl) {
6191
- this._resizeObserver = new ResizeObserver((entries) => {
6242
+ else if (!this.#resizeObserver && add && canvasEl) {
6243
+ this.#resizeObserver = new ResizeObserver((entries) => {
6192
6244
  const entry = entries.find(e => e.target === canvasEl);
6193
6245
  if (!entry) {
6194
6246
  return;
6195
6247
  }
6196
- this._handleWindowResize();
6248
+ this.#handleWindowResize();
6197
6249
  });
6198
- this._resizeObserver.observe(canvasEl);
6250
+ this.#resizeObserver.observe(canvasEl);
6199
6251
  }
6200
6252
  };
6201
6253
  }
@@ -6268,24 +6320,24 @@
6268
6320
  unbreakable;
6269
6321
  velocity;
6270
6322
  zIndexFactor;
6271
- _cachedOpacityData = {
6323
+ #cachedOpacityData = {
6272
6324
  fillOpacity: defaultOpacity$1,
6273
6325
  opacity: defaultOpacity$1,
6274
6326
  strokeOpacity: defaultOpacity$1,
6275
6327
  };
6276
- _cachedPosition = Vector3d.origin;
6277
- _cachedRotateData = { sin: 0, cos: 0 };
6278
- _cachedTransform = {
6328
+ #cachedPosition = Vector3d.origin;
6329
+ #cachedRotateData = { sin: 0, cos: 0 };
6330
+ #cachedTransform = {
6279
6331
  a: 1,
6280
6332
  b: 0,
6281
6333
  c: 0,
6282
6334
  d: 1,
6283
6335
  };
6284
- _container;
6285
- _pluginManager;
6336
+ #container;
6337
+ #pluginManager;
6286
6338
  constructor(pluginManager, container) {
6287
- this._pluginManager = pluginManager;
6288
- this._container = container;
6339
+ this.#pluginManager = pluginManager;
6340
+ this.#container = container;
6289
6341
  }
6290
6342
  destroy(override) {
6291
6343
  if (this.unbreakable || this.destroyed) {
@@ -6294,7 +6346,7 @@
6294
6346
  this.destroyed = true;
6295
6347
  this.bubble.inRange = false;
6296
6348
  this.slow.inRange = false;
6297
- const container = this._container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
6349
+ const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
6298
6350
  shapeDrawer?.particleDestroy?.(this);
6299
6351
  for (const plugin of container.particleDestroyedPlugins) {
6300
6352
  plugin.particleDestroyed?.(this, override);
@@ -6302,12 +6354,12 @@
6302
6354
  for (const updater of container.particleUpdaters) {
6303
6355
  updater.particleDestroyed?.(this, override);
6304
6356
  }
6305
- this._container.dispatchEvent(EventType.particleDestroyed, {
6357
+ this.#container.dispatchEvent(EventType.particleDestroyed, {
6306
6358
  particle: this,
6307
6359
  });
6308
6360
  }
6309
6361
  draw(delta) {
6310
- const container = this._container, render = container.canvas.render;
6362
+ const container = this.#container, render = container.canvas.render;
6311
6363
  render.drawParticlePlugins(this, delta);
6312
6364
  render.drawParticle(this, delta);
6313
6365
  }
@@ -6315,50 +6367,50 @@
6315
6367
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
6316
6368
  }
6317
6369
  getFillColor() {
6318
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
6370
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
6319
6371
  }
6320
6372
  getMass() {
6321
6373
  return this.getRadius() ** squareExp * Math.PI * half;
6322
6374
  }
6323
6375
  getOpacity() {
6324
6376
  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;
6325
- this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
6326
- this._cachedOpacityData.opacity = opacity * zOpacityFactor;
6327
- this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
6328
- return this._cachedOpacityData;
6377
+ this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
6378
+ this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
6379
+ this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
6380
+ return this.#cachedOpacityData;
6329
6381
  }
6330
6382
  getPosition() {
6331
- this._cachedPosition.x = this.position.x + this.offset.x;
6332
- this._cachedPosition.y = this.position.y + this.offset.y;
6333
- this._cachedPosition.z = this.position.z;
6334
- return this._cachedPosition;
6383
+ this.#cachedPosition.x = this.position.x + this.offset.x;
6384
+ this.#cachedPosition.y = this.position.y + this.offset.y;
6385
+ this.#cachedPosition.z = this.position.z;
6386
+ return this.#cachedPosition;
6335
6387
  }
6336
6388
  getRadius() {
6337
6389
  return this.bubble.radius ?? this.size.value;
6338
6390
  }
6339
6391
  getRotateData() {
6340
6392
  const angle = this.getAngle();
6341
- this._cachedRotateData.sin = Math.sin(angle);
6342
- this._cachedRotateData.cos = Math.cos(angle);
6343
- return this._cachedRotateData;
6393
+ this.#cachedRotateData.sin = Math.sin(angle);
6394
+ this.#cachedRotateData.cos = Math.cos(angle);
6395
+ return this.#cachedRotateData;
6344
6396
  }
6345
6397
  getStrokeColor() {
6346
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
6398
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
6347
6399
  }
6348
6400
  getTransformData(externalTransform) {
6349
6401
  const rotateData = this.getRotateData(), rotating = this.isRotating;
6350
- this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform$1.a);
6351
- this._cachedTransform.b = rotating
6402
+ this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform$1.a);
6403
+ this.#cachedTransform.b = rotating
6352
6404
  ? rotateData.sin * (externalTransform.b ?? identity$2)
6353
6405
  : (externalTransform.b ?? defaultTransform$1.b);
6354
- this._cachedTransform.c = rotating
6406
+ this.#cachedTransform.c = rotating
6355
6407
  ? -rotateData.sin * (externalTransform.c ?? identity$2)
6356
6408
  : (externalTransform.c ?? defaultTransform$1.c);
6357
- this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform$1.d);
6358
- return this._cachedTransform;
6409
+ this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform$1.d);
6410
+ return this.#cachedTransform;
6359
6411
  }
6360
6412
  init(id, position, overrideOptions, group) {
6361
- const container = this._container;
6413
+ const container = this.#container;
6362
6414
  this.id = id;
6363
6415
  this.group = group;
6364
6416
  this.justWarped = false;
@@ -6378,21 +6430,27 @@
6378
6430
  moveSpeed: 0,
6379
6431
  sizeAnimationSpeed: 0,
6380
6432
  };
6433
+ this.size = {
6434
+ value: 1,
6435
+ max: 1,
6436
+ min: 1,
6437
+ enable: false,
6438
+ };
6381
6439
  this.outType = ParticleOutType.normal;
6382
6440
  this.ignoresResizeRatio = true;
6383
- 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;
6441
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
6384
6442
  this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
6385
6443
  this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
6386
6444
  const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
6387
6445
  if (overrideOptions) {
6388
- if (overrideOptions.effect?.type) {
6446
+ if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
6389
6447
  const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
6390
6448
  if (effect) {
6391
6449
  this.effect = effect;
6392
6450
  effectOptions.load(overrideOptions.effect);
6393
6451
  }
6394
6452
  }
6395
- if (overrideOptions.shape?.type) {
6453
+ if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
6396
6454
  const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
6397
6455
  if (shape) {
6398
6456
  this.shape = shape;
@@ -6401,21 +6459,20 @@
6401
6459
  }
6402
6460
  }
6403
6461
  if (this.effect === randomColorValue) {
6404
- const availableEffects = [...this._container.effectDrawers.keys()];
6462
+ const availableEffects = [...this.#container.effectDrawers.keys()];
6405
6463
  this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
6406
6464
  }
6407
6465
  if (this.shape === randomColorValue) {
6408
- const availableShapes = [...this._container.shapeDrawers.keys()];
6466
+ const availableShapes = [...this.#container.shapeDrawers.keys()];
6409
6467
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
6410
6468
  }
6411
6469
  this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
6412
6470
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
6413
6471
  particlesOptions.load(overrideOptions);
6414
- const effectData = this.effectData;
6472
+ const effectData = this.effectData, shapeData = this.shapeData;
6415
6473
  if (effectData) {
6416
6474
  particlesOptions.load(effectData.particles);
6417
6475
  }
6418
- const shapeData = this.shapeData;
6419
6476
  if (shapeData) {
6420
6477
  particlesOptions.load(shapeData.particles);
6421
6478
  }
@@ -6423,7 +6480,9 @@
6423
6480
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
6424
6481
  this.options = particlesOptions;
6425
6482
  container.retina.initParticle(this);
6426
- this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
6483
+ for (const updater of container.particleUpdaters) {
6484
+ updater.preInit?.(this);
6485
+ }
6427
6486
  this.bubble = {
6428
6487
  inRange: false,
6429
6488
  };
@@ -6431,8 +6490,8 @@
6431
6490
  inRange: false,
6432
6491
  factor: 1,
6433
6492
  };
6434
- this._initPosition(position);
6435
- this.initialVelocity = this._calculateVelocity();
6493
+ this.#initPosition(position);
6494
+ this.initialVelocity = this.#calculateVelocity();
6436
6495
  this.velocity = this.initialVelocity.copy();
6437
6496
  this.zIndexFactor = this.position.z / container.zLayers;
6438
6497
  this.sides = 24;
@@ -6463,12 +6522,11 @@
6463
6522
  plugin.particleCreated?.(this);
6464
6523
  }
6465
6524
  }
6466
- isInsideCanvas() {
6467
- const radius = this.getRadius(), canvasSize = this._container.canvas.size, position = this.position;
6468
- return (position.x >= -radius &&
6469
- position.y >= -radius &&
6470
- position.y <= canvasSize.height + radius &&
6471
- position.x <= canvasSize.width + radius);
6525
+ isInsideCanvas(direction) {
6526
+ return this.#getInsideCanvasResult({ direction }).inside;
6527
+ }
6528
+ isInsideCanvasForOutMode(outMode, direction) {
6529
+ return this.#getInsideCanvasResult({ direction, outMode }).inside;
6472
6530
  }
6473
6531
  isShowingBack() {
6474
6532
  if (!this.roll) {
@@ -6493,13 +6551,13 @@
6493
6551
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
6494
6552
  }
6495
6553
  reset() {
6496
- for (const updater of this._container.particleUpdaters) {
6554
+ for (const updater of this.#container.particleUpdaters) {
6497
6555
  updater.reset?.(this);
6498
6556
  }
6499
6557
  }
6500
- _calcPosition = (position, zIndex) => {
6558
+ #calcPosition = (position, zIndex) => {
6501
6559
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
6502
- const container = this._container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
6560
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
6503
6561
  while (!signal.aborted) {
6504
6562
  for (const plugin of plugins) {
6505
6563
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -6511,10 +6569,10 @@
6511
6569
  size: canvasSize,
6512
6570
  position: posVec,
6513
6571
  }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
6514
- this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
6515
- this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
6516
- this._fixVertical(pos, radius, outModes.top ?? outModes.default);
6517
- this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
6572
+ this.#fixHorizontal(pos, radius, outModes.left ?? outModes.default);
6573
+ this.#fixHorizontal(pos, radius, outModes.right ?? outModes.default);
6574
+ this.#fixVertical(pos, radius, outModes.top ?? outModes.default);
6575
+ this.#fixVertical(pos, radius, outModes.bottom ?? outModes.default);
6518
6576
  let isValidPosition = true;
6519
6577
  for (const plugin of container.particles.checkParticlePositionPlugins) {
6520
6578
  isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
@@ -6530,8 +6588,8 @@
6530
6588
  }
6531
6589
  return posVec;
6532
6590
  };
6533
- _calculateVelocity = () => {
6534
- const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
6591
+ #calculateVelocity = () => {
6592
+ const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
6535
6593
  if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
6536
6594
  return res;
6537
6595
  }
@@ -6547,27 +6605,86 @@
6547
6605
  }
6548
6606
  return res;
6549
6607
  };
6550
- _fixHorizontal = (pos, radius, outMode) => {
6608
+ #fixHorizontal = (pos, radius, outMode) => {
6551
6609
  fixOutMode({
6552
6610
  outMode,
6553
6611
  checkModes: [OutMode.bounce],
6554
6612
  coord: pos.x,
6555
- maxCoord: this._container.canvas.size.width,
6613
+ maxCoord: this.#container.canvas.size.width,
6556
6614
  setCb: (value) => (pos.x += value),
6557
6615
  radius,
6558
6616
  });
6559
6617
  };
6560
- _fixVertical = (pos, radius, outMode) => {
6618
+ #fixVertical = (pos, radius, outMode) => {
6561
6619
  fixOutMode({
6562
6620
  outMode,
6563
6621
  checkModes: [OutMode.bounce],
6564
6622
  coord: pos.y,
6565
- maxCoord: this._container.canvas.size.height,
6623
+ maxCoord: this.#container.canvas.size.height,
6566
6624
  setCb: (value) => (pos.y += value),
6567
6625
  radius,
6568
6626
  });
6569
6627
  };
6570
- _getRollColor = color => {
6628
+ #getDefaultInsideCanvasResult = (direction, outMode) => {
6629
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
6630
+ if (direction === OutModeDirection.bottom) {
6631
+ return {
6632
+ inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
6633
+ reason: "default",
6634
+ };
6635
+ }
6636
+ if (direction === OutModeDirection.left) {
6637
+ return {
6638
+ inside: isBounce ? position.x - radius > defaultAngle : position.x + radius > defaultAngle,
6639
+ reason: "default",
6640
+ };
6641
+ }
6642
+ if (direction === OutModeDirection.right) {
6643
+ return {
6644
+ inside: isBounce ? position.x + radius < canvasSize.width : position.x - radius < canvasSize.width,
6645
+ reason: "default",
6646
+ };
6647
+ }
6648
+ if (direction === OutModeDirection.top) {
6649
+ return {
6650
+ inside: isBounce ? position.y - radius > defaultAngle : position.y + radius > defaultAngle,
6651
+ reason: "default",
6652
+ };
6653
+ }
6654
+ return {
6655
+ inside: position.x >= -radius &&
6656
+ position.y >= -radius &&
6657
+ position.y <= canvasSize.height + radius &&
6658
+ position.x <= canvasSize.width + radius,
6659
+ reason: "default",
6660
+ };
6661
+ };
6662
+ #getInsideCanvasCallbackData = (direction, outMode) => {
6663
+ return {
6664
+ canvasSize: this.#container.canvas.size,
6665
+ direction,
6666
+ outMode,
6667
+ particle: this,
6668
+ radius: this.getRadius(),
6669
+ };
6670
+ };
6671
+ #getInsideCanvasResult = (data) => {
6672
+ 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;
6673
+ if (!shapeCheck && !effectCheck) {
6674
+ return defaultResult;
6675
+ }
6676
+ const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
6677
+ if (shapeResult && effectResult) {
6678
+ const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
6679
+ return {
6680
+ inside: shapeResult.inside && effectResult.inside,
6681
+ margin: margin > defaultAngle ? margin : undefined,
6682
+ reason: "combined",
6683
+ };
6684
+ }
6685
+ return shapeResult ?? effectResult ?? defaultResult;
6686
+ };
6687
+ #getRollColor = color => {
6571
6688
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
6572
6689
  return color;
6573
6690
  }
@@ -6582,8 +6699,8 @@
6582
6699
  }
6583
6700
  return color;
6584
6701
  };
6585
- _initPosition = position => {
6586
- const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
6702
+ #initPosition = position => {
6703
+ const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
6587
6704
  if (!initialPosition) {
6588
6705
  throw new Error("a valid position cannot be found for particle");
6589
6706
  }
@@ -6606,45 +6723,58 @@
6606
6723
  }
6607
6724
  this.offset = Vector.origin;
6608
6725
  };
6726
+ #normalizeInsideCanvasResult = (result, reason) => {
6727
+ if (typeof result === "boolean") {
6728
+ return {
6729
+ inside: result,
6730
+ reason,
6731
+ };
6732
+ }
6733
+ return {
6734
+ inside: result.inside,
6735
+ margin: result.margin,
6736
+ reason: result.reason ?? reason,
6737
+ };
6738
+ };
6609
6739
  }
6610
6740
 
6611
6741
  class SpatialHashGrid {
6612
- _cellSize;
6613
- _cells = new Map();
6614
- _circlePool = [];
6615
- _circlePoolIdx;
6616
- _pendingCellSize;
6617
- _rectanglePool = [];
6618
- _rectanglePoolIdx;
6742
+ #cellSize;
6743
+ #cells = new Map();
6744
+ #circlePool = [];
6745
+ #circlePoolIdx;
6746
+ #pendingCellSize;
6747
+ #rectanglePool = [];
6748
+ #rectanglePoolIdx;
6619
6749
  constructor(cellSize) {
6620
- this._cellSize = cellSize;
6621
- this._circlePoolIdx = 0;
6622
- this._rectanglePoolIdx = 0;
6750
+ this.#cellSize = cellSize;
6751
+ this.#circlePoolIdx = 0;
6752
+ this.#rectanglePoolIdx = 0;
6623
6753
  }
6624
6754
  clear() {
6625
- this._cells.clear();
6626
- const pendingCellSize = this._pendingCellSize;
6755
+ this.#cells.clear();
6756
+ const pendingCellSize = this.#pendingCellSize;
6627
6757
  if (pendingCellSize) {
6628
- this._cellSize = pendingCellSize;
6758
+ this.#cellSize = pendingCellSize;
6629
6759
  }
6630
- this._pendingCellSize = undefined;
6760
+ this.#pendingCellSize = undefined;
6631
6761
  }
6632
6762
  insert(particle) {
6633
- const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
6634
- if (!this._cells.has(key)) {
6635
- this._cells.set(key, []);
6763
+ const { x, y } = particle.getPosition(), key = this.#cellKeyFromCoords(x, y);
6764
+ if (!this.#cells.has(key)) {
6765
+ this.#cells.set(key, []);
6636
6766
  }
6637
- this._cells.get(key)?.push(particle);
6767
+ this.#cells.get(key)?.push(particle);
6638
6768
  }
6639
6769
  query(range, check, out = []) {
6640
- const bounds = this._getRangeBounds(range);
6770
+ const bounds = this.#getRangeBounds(range);
6641
6771
  if (!bounds) {
6642
6772
  return out;
6643
6773
  }
6644
- 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);
6774
+ 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);
6645
6775
  for (let cx = minCellX; cx <= maxCellX; cx++) {
6646
6776
  for (let cy = minCellY; cy <= maxCellY; cy++) {
6647
- const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
6777
+ const key = `${cx}_${cy}`, cellParticles = this.#cells.get(key);
6648
6778
  if (!cellParticles) {
6649
6779
  continue;
6650
6780
  }
@@ -6661,29 +6791,29 @@
6661
6791
  return out;
6662
6792
  }
6663
6793
  queryCircle(position, radius, check, out = []) {
6664
- const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
6665
- this._releaseShapes();
6794
+ const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
6795
+ this.#releaseShapes();
6666
6796
  return result;
6667
6797
  }
6668
6798
  queryRectangle(position, size, check, out = []) {
6669
- const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
6670
- this._releaseShapes();
6799
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
6800
+ this.#releaseShapes();
6671
6801
  return result;
6672
6802
  }
6673
6803
  setCellSize(cellSize) {
6674
- this._pendingCellSize = cellSize;
6804
+ this.#pendingCellSize = cellSize;
6675
6805
  }
6676
- _acquireCircle(x, y, r) {
6677
- return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
6806
+ #acquireCircle(x, y, r) {
6807
+ return (this.#circlePool[this.#circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
6678
6808
  }
6679
- _acquireRectangle(x, y, w, h) {
6680
- return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
6809
+ #acquireRectangle(x, y, w, h) {
6810
+ return (this.#rectanglePool[this.#rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
6681
6811
  }
6682
- _cellKeyFromCoords(x, y) {
6683
- const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
6812
+ #cellKeyFromCoords(x, y) {
6813
+ const cellX = Math.floor(x / this.#cellSize), cellY = Math.floor(y / this.#cellSize);
6684
6814
  return `${cellX}_${cellY}`;
6685
6815
  }
6686
- _getRangeBounds(range) {
6816
+ #getRangeBounds(range) {
6687
6817
  if (range instanceof Circle) {
6688
6818
  const r = range.radius, { x, y } = range.position;
6689
6819
  return {
@@ -6704,53 +6834,53 @@
6704
6834
  }
6705
6835
  return null;
6706
6836
  }
6707
- _releaseShapes() {
6708
- this._circlePoolIdx = 0;
6709
- this._rectanglePoolIdx = 0;
6837
+ #releaseShapes() {
6838
+ this.#circlePoolIdx = 0;
6839
+ this.#rectanglePoolIdx = 0;
6710
6840
  }
6711
6841
  }
6712
6842
 
6713
6843
  class ParticlesManager {
6714
6844
  checkParticlePositionPlugins;
6715
6845
  grid;
6716
- _array;
6717
- _container;
6718
- _groupLimits;
6719
- _limit;
6720
- _nextId;
6721
- _particleBuckets;
6722
- _particleResetPlugins;
6723
- _particleUpdatePlugins;
6724
- _pluginManager;
6725
- _pool;
6726
- _postParticleUpdatePlugins;
6727
- _postUpdatePlugins;
6728
- _resizeFactor;
6729
- _updatePlugins;
6730
- _zBuckets;
6846
+ #array;
6847
+ #container;
6848
+ #groupLimits;
6849
+ #limit;
6850
+ #nextId;
6851
+ #particleBuckets;
6852
+ #particleResetPlugins;
6853
+ #particleUpdatePlugins;
6854
+ #pluginManager;
6855
+ #pool;
6856
+ #postParticleUpdatePlugins;
6857
+ #postUpdatePlugins;
6858
+ #resizeFactor;
6859
+ #updatePlugins;
6860
+ #zBuckets;
6731
6861
  constructor(pluginManager, container) {
6732
- this._pluginManager = pluginManager;
6733
- this._container = container;
6734
- this._nextId = 0;
6735
- this._array = [];
6736
- this._pool = [];
6737
- this._limit = 0;
6738
- this._groupLimits = new Map();
6739
- this._particleBuckets = new Map();
6740
- this._zBuckets = this._createBuckets(this._container.zLayers);
6862
+ this.#pluginManager = pluginManager;
6863
+ this.#container = container;
6864
+ this.#nextId = 0;
6865
+ this.#array = [];
6866
+ this.#pool = [];
6867
+ this.#limit = 0;
6868
+ this.#groupLimits = new Map();
6869
+ this.#particleBuckets = new Map();
6870
+ this.#zBuckets = this.#createBuckets(this.#container.zLayers);
6741
6871
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
6742
6872
  this.checkParticlePositionPlugins = [];
6743
- this._particleResetPlugins = [];
6744
- this._particleUpdatePlugins = [];
6745
- this._postUpdatePlugins = [];
6746
- this._postParticleUpdatePlugins = [];
6747
- this._updatePlugins = [];
6873
+ this.#particleResetPlugins = [];
6874
+ this.#particleUpdatePlugins = [];
6875
+ this.#postUpdatePlugins = [];
6876
+ this.#postParticleUpdatePlugins = [];
6877
+ this.#updatePlugins = [];
6748
6878
  }
6749
6879
  get count() {
6750
- return this._array.length;
6880
+ return this.#array.length;
6751
6881
  }
6752
6882
  addParticle(position, overrideOptions, group, initializer) {
6753
- const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
6883
+ const limitMode = this.#container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this.#limit : (this.#groupLimits.get(group) ?? this.#limit), currentCount = this.count;
6754
6884
  if (limit > minLimit) {
6755
6885
  switch (limitMode) {
6756
6886
  case LimitMode.delete: {
@@ -6768,20 +6898,20 @@
6768
6898
  }
6769
6899
  }
6770
6900
  try {
6771
- const particle = this._pool.pop() ?? new Particle(this._pluginManager, this._container);
6772
- particle.init(this._nextId, position, overrideOptions, group);
6901
+ const particle = this.#pool.pop() ?? new Particle(this.#pluginManager, this.#container);
6902
+ particle.init(this.#nextId, position, overrideOptions, group);
6773
6903
  let canAdd = true;
6774
6904
  if (initializer) {
6775
6905
  canAdd = initializer(particle);
6776
6906
  }
6777
6907
  if (!canAdd) {
6778
- this._pool.push(particle);
6908
+ this.#pool.push(particle);
6779
6909
  return;
6780
6910
  }
6781
- this._array.push(particle);
6782
- this._insertParticleIntoBucket(particle);
6783
- this._nextId++;
6784
- this._container.dispatchEvent(EventType.particleAdded, {
6911
+ this.#array.push(particle);
6912
+ this.#insertParticleIntoBucket(particle);
6913
+ this.#nextId++;
6914
+ this.#container.dispatchEvent(EventType.particleAdded, {
6785
6915
  particle,
6786
6916
  });
6787
6917
  return particle;
@@ -6792,25 +6922,25 @@
6792
6922
  return undefined;
6793
6923
  }
6794
6924
  clear() {
6795
- this._array = [];
6796
- this._particleBuckets.clear();
6797
- this._resetBuckets(this._container.zLayers);
6925
+ this.#array = [];
6926
+ this.#particleBuckets.clear();
6927
+ this.#resetBuckets(this.#container.zLayers);
6798
6928
  }
6799
6929
  destroy() {
6800
- this._array = [];
6801
- this._pool.length = 0;
6802
- this._particleBuckets.clear();
6803
- this._zBuckets = [];
6930
+ this.#array = [];
6931
+ this.#pool.length = 0;
6932
+ this.#particleBuckets.clear();
6933
+ this.#zBuckets = [];
6804
6934
  this.checkParticlePositionPlugins = [];
6805
- this._particleResetPlugins = [];
6806
- this._particleUpdatePlugins = [];
6807
- this._postUpdatePlugins = [];
6808
- this._postParticleUpdatePlugins = [];
6809
- this._updatePlugins = [];
6935
+ this.#particleResetPlugins = [];
6936
+ this.#particleUpdatePlugins = [];
6937
+ this.#postUpdatePlugins = [];
6938
+ this.#postParticleUpdatePlugins = [];
6939
+ this.#updatePlugins = [];
6810
6940
  }
6811
6941
  drawParticles(delta) {
6812
- for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
6813
- const bucket = this._zBuckets[i];
6942
+ for (let i = this.#zBuckets.length - one; i >= minIndex; i--) {
6943
+ const bucket = this.#zBuckets[i];
6814
6944
  if (!bucket) {
6815
6945
  continue;
6816
6946
  }
@@ -6820,24 +6950,24 @@
6820
6950
  }
6821
6951
  }
6822
6952
  filter(condition) {
6823
- return this._array.filter(condition);
6953
+ return this.#array.filter(condition);
6824
6954
  }
6825
6955
  find(condition) {
6826
- return this._array.find(condition);
6956
+ return this.#array.find(condition);
6827
6957
  }
6828
6958
  get(index) {
6829
- return this._array[index];
6959
+ return this.#array[index];
6830
6960
  }
6831
6961
  async init() {
6832
- const container = this._container, options = container.actualOptions;
6962
+ const container = this.#container, options = container.actualOptions;
6833
6963
  this.checkParticlePositionPlugins = [];
6834
- this._updatePlugins = [];
6835
- this._particleUpdatePlugins = [];
6836
- this._postUpdatePlugins = [];
6837
- this._particleResetPlugins = [];
6838
- this._postParticleUpdatePlugins = [];
6839
- this._particleBuckets.clear();
6840
- this._resetBuckets(container.zLayers);
6964
+ this.#updatePlugins = [];
6965
+ this.#particleUpdatePlugins = [];
6966
+ this.#postUpdatePlugins = [];
6967
+ this.#particleResetPlugins = [];
6968
+ this.#postParticleUpdatePlugins = [];
6969
+ this.#particleBuckets.clear();
6970
+ this.#resetBuckets(container.zLayers);
6841
6971
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
6842
6972
  for (const plugin of container.plugins) {
6843
6973
  if (plugin.redrawInit) {
@@ -6847,26 +6977,26 @@
6847
6977
  this.checkParticlePositionPlugins.push(plugin);
6848
6978
  }
6849
6979
  if (plugin.update) {
6850
- this._updatePlugins.push(plugin);
6980
+ this.#updatePlugins.push(plugin);
6851
6981
  }
6852
6982
  if (plugin.particleUpdate) {
6853
- this._particleUpdatePlugins.push(plugin);
6983
+ this.#particleUpdatePlugins.push(plugin);
6854
6984
  }
6855
6985
  if (plugin.postUpdate) {
6856
- this._postUpdatePlugins.push(plugin);
6986
+ this.#postUpdatePlugins.push(plugin);
6857
6987
  }
6858
6988
  if (plugin.particleReset) {
6859
- this._particleResetPlugins.push(plugin);
6989
+ this.#particleResetPlugins.push(plugin);
6860
6990
  }
6861
6991
  if (plugin.postParticleUpdate) {
6862
- this._postParticleUpdatePlugins.push(plugin);
6992
+ this.#postParticleUpdatePlugins.push(plugin);
6863
6993
  }
6864
6994
  }
6865
- await this._container.initDrawersAndUpdaters();
6866
- for (const drawer of this._container.effectDrawers.values()) {
6995
+ await this.#container.initDrawersAndUpdaters();
6996
+ for (const drawer of this.#container.effectDrawers.values()) {
6867
6997
  await drawer.init?.(container);
6868
6998
  }
6869
- for (const drawer of this._container.shapeDrawers.values()) {
6999
+ for (const drawer of this.#container.shapeDrawers.values()) {
6870
7000
  await drawer.init?.(container);
6871
7001
  }
6872
7002
  let handled = false;
@@ -6900,10 +7030,10 @@
6900
7030
  async redraw() {
6901
7031
  this.clear();
6902
7032
  await this.init();
6903
- this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
7033
+ this.#container.canvas.render.drawParticles({ value: 0, factor: 0 });
6904
7034
  }
6905
7035
  remove(particle, group, override) {
6906
- this.removeAt(this._array.indexOf(particle), undefined, group, override);
7036
+ this.removeAt(this.#array.indexOf(particle), undefined, group, override);
6907
7037
  }
6908
7038
  removeAt(index, quantity = defaultRemoveQuantity, group, override) {
6909
7039
  if (index < minIndex || index > this.count) {
@@ -6911,7 +7041,7 @@
6911
7041
  }
6912
7042
  let deleted = 0;
6913
7043
  for (let i = index; deleted < quantity && i < this.count; i++) {
6914
- if (this._removeParticle(i, group, override)) {
7044
+ if (this.#removeParticle(i, group, override)) {
6915
7045
  i--;
6916
7046
  deleted++;
6917
7047
  }
@@ -6921,9 +7051,9 @@
6921
7051
  this.removeAt(minIndex, quantity, group);
6922
7052
  }
6923
7053
  setDensity() {
6924
- const options = this._container.actualOptions, groups = options.particles.groups;
7054
+ const options = this.#container.actualOptions, groups = options.particles.groups;
6925
7055
  let pluginsCount = 0;
6926
- for (const plugin of this._container.plugins) {
7056
+ for (const plugin of this.#container.plugins) {
6927
7057
  if (plugin.particlesDensityCount) {
6928
7058
  pluginsCount += plugin.particlesDensityCount();
6929
7059
  }
@@ -6933,51 +7063,51 @@
6933
7063
  if (!groupData) {
6934
7064
  continue;
6935
7065
  }
6936
- const groupDataOptions = loadParticlesOptions(this._pluginManager, this._container, groupData);
6937
- this._applyDensity(groupDataOptions, pluginsCount, group);
7066
+ const groupDataOptions = loadParticlesOptions(this.#pluginManager, this.#container, groupData);
7067
+ this.#applyDensity(groupDataOptions, pluginsCount, group);
6938
7068
  }
6939
- this._applyDensity(options.particles, pluginsCount);
7069
+ this.#applyDensity(options.particles, pluginsCount);
6940
7070
  }
6941
7071
  setResizeFactor(factor) {
6942
- this._resizeFactor = factor;
7072
+ this.#resizeFactor = factor;
6943
7073
  }
6944
7074
  update(delta) {
6945
7075
  this.grid.clear();
6946
- for (const plugin of this._updatePlugins) {
7076
+ for (const plugin of this.#updatePlugins) {
6947
7077
  plugin.update?.(delta);
6948
7078
  }
6949
- const particlesToDelete = this._updateParticlesPhase1(delta);
6950
- for (const plugin of this._postUpdatePlugins) {
7079
+ const particlesToDelete = this.#updateParticlesPhase1(delta);
7080
+ for (const plugin of this.#postUpdatePlugins) {
6951
7081
  plugin.postUpdate?.(delta);
6952
7082
  }
6953
- this._updateParticlesPhase2(delta, particlesToDelete);
7083
+ this.#updateParticlesPhase2(delta, particlesToDelete);
6954
7084
  if (particlesToDelete.size) {
6955
7085
  for (const particle of particlesToDelete) {
6956
7086
  this.remove(particle);
6957
7087
  }
6958
7088
  }
6959
- delete this._resizeFactor;
7089
+ this.#resizeFactor = undefined;
6960
7090
  }
6961
- _addToPool = (...particles) => {
6962
- this._pool.push(...particles);
7091
+ #addToPool = (...particles) => {
7092
+ this.#pool.push(...particles);
6963
7093
  };
6964
- _applyDensity = (options, pluginsCount, group, groupOptions) => {
7094
+ #applyDensity = (options, pluginsCount, group, groupOptions) => {
6965
7095
  const numberOptions = options.number;
6966
7096
  if (!numberOptions.density.enable) {
6967
7097
  if (group === undefined) {
6968
- this._limit = numberOptions.limit.value;
7098
+ this.#limit = numberOptions.limit.value;
6969
7099
  }
6970
7100
  else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
6971
- this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
7101
+ this.#groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
6972
7102
  }
6973
7103
  return;
6974
7104
  }
6975
- 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);
7105
+ 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);
6976
7106
  if (group === undefined) {
6977
- this._limit = numberOptions.limit.value * densityFactor;
7107
+ this.#limit = numberOptions.limit.value * densityFactor;
6978
7108
  }
6979
7109
  else {
6980
- this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
7110
+ this.#groupLimits.set(group, numberOptions.limit.value * densityFactor);
6981
7111
  }
6982
7112
  if (particlesCount < particlesNumber) {
6983
7113
  this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
@@ -6986,18 +7116,18 @@
6986
7116
  this.removeQuantity(particlesCount - particlesNumber, group);
6987
7117
  }
6988
7118
  };
6989
- _createBuckets = (zLayers) => {
7119
+ #createBuckets = (zLayers) => {
6990
7120
  const bucketCount = Math.max(Math.floor(zLayers), one);
6991
7121
  return Array.from({ length: bucketCount }, () => []);
6992
7122
  };
6993
- _getBucketIndex = (zIndex) => {
6994
- const maxBucketIndex = this._zBuckets.length - one;
7123
+ #getBucketIndex = (zIndex) => {
7124
+ const maxBucketIndex = this.#zBuckets.length - one;
6995
7125
  if (maxBucketIndex <= minIndex) {
6996
7126
  return minIndex;
6997
7127
  }
6998
7128
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
6999
7129
  };
7000
- _getParticleInsertIndex = (bucket, particleId) => {
7130
+ #getParticleInsertIndex = (bucket, particleId) => {
7001
7131
  let start = minIndex, end = bucket.length;
7002
7132
  while (start < end) {
7003
7133
  const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
@@ -7014,8 +7144,8 @@
7014
7144
  }
7015
7145
  return start;
7016
7146
  };
7017
- _initDensityFactor = densityOptions => {
7018
- const container = this._container;
7147
+ #initDensityFactor = densityOptions => {
7148
+ const container = this.#container;
7019
7149
  if (!densityOptions.enable) {
7020
7150
  return defaultDensityFactor;
7021
7151
  }
@@ -7025,82 +7155,82 @@
7025
7155
  }
7026
7156
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
7027
7157
  };
7028
- _insertParticleIntoBucket = (particle) => {
7029
- const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
7158
+ #insertParticleIntoBucket = (particle) => {
7159
+ const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
7030
7160
  if (!bucket) {
7031
7161
  return;
7032
7162
  }
7033
- bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
7034
- this._particleBuckets.set(particle.id, bucketIndex);
7163
+ bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
7164
+ this.#particleBuckets.set(particle.id, bucketIndex);
7035
7165
  };
7036
- _removeParticle = (index, group, override) => {
7037
- const particle = this._array[index];
7166
+ #removeParticle = (index, group, override) => {
7167
+ const particle = this.#array[index];
7038
7168
  if (!particle) {
7039
7169
  return false;
7040
7170
  }
7041
7171
  if (particle.group !== group) {
7042
7172
  return false;
7043
7173
  }
7044
- this._array.splice(index, deleteCount);
7045
- this._removeParticleFromBucket(particle);
7174
+ this.#array.splice(index, deleteCount);
7175
+ this.#removeParticleFromBucket(particle);
7046
7176
  particle.destroy(override);
7047
- this._container.dispatchEvent(EventType.particleRemoved, {
7177
+ this.#container.dispatchEvent(EventType.particleRemoved, {
7048
7178
  particle,
7049
7179
  });
7050
- this._addToPool(particle);
7180
+ this.#addToPool(particle);
7051
7181
  return true;
7052
7182
  };
7053
- _removeParticleFromBucket = (particle) => {
7054
- const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
7183
+ #removeParticleFromBucket = (particle) => {
7184
+ const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
7055
7185
  if (!bucket) {
7056
- this._particleBuckets.delete(particle.id);
7186
+ this.#particleBuckets.delete(particle.id);
7057
7187
  return;
7058
7188
  }
7059
- const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
7189
+ const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
7060
7190
  if (bucket[particleIndex]?.id !== particle.id) {
7061
- this._particleBuckets.delete(particle.id);
7191
+ this.#particleBuckets.delete(particle.id);
7062
7192
  return;
7063
7193
  }
7064
7194
  bucket.splice(particleIndex, deleteCount);
7065
- this._particleBuckets.delete(particle.id);
7195
+ this.#particleBuckets.delete(particle.id);
7066
7196
  };
7067
- _resetBuckets = (zLayers) => {
7197
+ #resetBuckets = (zLayers) => {
7068
7198
  const bucketCount = Math.max(Math.floor(zLayers), one);
7069
- if (this._zBuckets.length !== bucketCount) {
7070
- this._zBuckets = this._createBuckets(bucketCount);
7199
+ if (this.#zBuckets.length !== bucketCount) {
7200
+ this.#zBuckets = this.#createBuckets(bucketCount);
7071
7201
  return;
7072
7202
  }
7073
- for (const bucket of this._zBuckets) {
7203
+ for (const bucket of this.#zBuckets) {
7074
7204
  bucket.length = minIndex;
7075
7205
  }
7076
7206
  };
7077
- _updateParticleBucket = (particle) => {
7078
- const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
7207
+ #updateParticleBucket = (particle) => {
7208
+ const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
7079
7209
  if (currentBucketIndex === undefined) {
7080
- this._insertParticleIntoBucket(particle);
7210
+ this.#insertParticleIntoBucket(particle);
7081
7211
  return;
7082
7212
  }
7083
7213
  if (currentBucketIndex === newBucketIndex) {
7084
7214
  return;
7085
7215
  }
7086
- const currentBucket = this._zBuckets[currentBucketIndex];
7216
+ const currentBucket = this.#zBuckets[currentBucketIndex];
7087
7217
  if (currentBucket) {
7088
- const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
7218
+ const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
7089
7219
  if (currentBucket[particleIndex]?.id === particle.id) {
7090
7220
  currentBucket.splice(particleIndex, deleteCount);
7091
7221
  }
7092
7222
  }
7093
- const newBucket = this._zBuckets[newBucketIndex];
7223
+ const newBucket = this.#zBuckets[newBucketIndex];
7094
7224
  if (!newBucket) {
7095
- this._particleBuckets.set(particle.id, newBucketIndex);
7225
+ this.#particleBuckets.set(particle.id, newBucketIndex);
7096
7226
  return;
7097
7227
  }
7098
- newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
7099
- this._particleBuckets.set(particle.id, newBucketIndex);
7228
+ newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
7229
+ this.#particleBuckets.set(particle.id, newBucketIndex);
7100
7230
  };
7101
- _updateParticlesPhase1 = (delta) => {
7102
- const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
7103
- for (const particle of this._array) {
7231
+ #updateParticlesPhase1 = (delta) => {
7232
+ const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
7233
+ for (const particle of this.#array) {
7104
7234
  if (resizeFactor && !particle.ignoresResizeRatio) {
7105
7235
  particle.position.x *= resizeFactor.width;
7106
7236
  particle.position.y *= resizeFactor.height;
@@ -7108,10 +7238,10 @@
7108
7238
  particle.initialPosition.y *= resizeFactor.height;
7109
7239
  }
7110
7240
  particle.ignoresResizeRatio = false;
7111
- for (const plugin of this._particleResetPlugins) {
7241
+ for (const plugin of this.#particleResetPlugins) {
7112
7242
  plugin.particleReset?.(particle);
7113
7243
  }
7114
- for (const plugin of this._particleUpdatePlugins) {
7244
+ for (const plugin of this.#particleUpdatePlugins) {
7115
7245
  if (particle.destroyed) {
7116
7246
  break;
7117
7247
  }
@@ -7125,36 +7255,36 @@
7125
7255
  }
7126
7256
  return particlesToDelete;
7127
7257
  };
7128
- _updateParticlesPhase2 = (delta, particlesToDelete) => {
7129
- for (const particle of this._array) {
7258
+ #updateParticlesPhase2 = (delta, particlesToDelete) => {
7259
+ for (const particle of this.#array) {
7130
7260
  if (particle.destroyed) {
7131
7261
  particlesToDelete.add(particle);
7132
7262
  continue;
7133
7263
  }
7134
- for (const updater of this._container.particleUpdaters) {
7264
+ for (const updater of this.#container.particleUpdaters) {
7135
7265
  updater.update(particle, delta);
7136
7266
  }
7137
7267
  if (!particle.spawning) {
7138
- for (const plugin of this._postParticleUpdatePlugins) {
7268
+ for (const plugin of this.#postParticleUpdatePlugins) {
7139
7269
  plugin.postParticleUpdate?.(particle, delta);
7140
7270
  }
7141
7271
  }
7142
- this._updateParticleBucket(particle);
7272
+ this.#updateParticleBucket(particle);
7143
7273
  }
7144
7274
  };
7145
7275
  }
7146
7276
 
7147
7277
  class Retina {
7148
- container;
7149
7278
  pixelRatio;
7150
7279
  reduceFactor;
7280
+ #container;
7151
7281
  constructor(container) {
7152
- this.container = container;
7282
+ this.#container = container;
7153
7283
  this.pixelRatio = defaultRatio;
7154
7284
  this.reduceFactor = defaultReduceFactor;
7155
7285
  }
7156
7286
  init() {
7157
- const container = this.container, options = container.actualOptions;
7287
+ const container = this.#container, options = container.actualOptions;
7158
7288
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
7159
7289
  this.reduceFactor = defaultReduceFactor;
7160
7290
  const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
@@ -7168,7 +7298,6 @@
7168
7298
  props.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
7169
7299
  props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
7170
7300
  props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
7171
- props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
7172
7301
  const maxDistance = props.maxDistance;
7173
7302
  maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
7174
7303
  maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
@@ -7206,73 +7335,73 @@
7206
7335
  shapeDrawers;
7207
7336
  started;
7208
7337
  zLayers;
7209
- _delay;
7210
- _delayTimeout;
7211
- _delta = { value: 0, factor: 0 };
7212
- _dispatchCallback;
7213
- _drawAnimationFrame;
7214
- _duration;
7215
- _eventListeners;
7216
- _firstStart;
7217
- _initialSourceOptions;
7218
- _lastFrameTime;
7219
- _lifeTime;
7220
- _onDestroy;
7221
- _options;
7222
- _paused;
7223
- _pluginManager;
7224
- _smooth;
7225
- _sourceOptions;
7338
+ #delay;
7339
+ #delayTimeout;
7340
+ #delta = { value: 0, factor: 0 };
7341
+ #dispatchCallback;
7342
+ #drawAnimationFrame;
7343
+ #duration;
7344
+ #eventListeners;
7345
+ #firstStart;
7346
+ #initialSourceOptions;
7347
+ #lastFrameTime;
7348
+ #lifeTime;
7349
+ #onDestroy;
7350
+ #options;
7351
+ #paused;
7352
+ #pluginManager;
7353
+ #smooth;
7354
+ #sourceOptions;
7226
7355
  constructor(params) {
7227
7356
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
7228
- this._pluginManager = pluginManager;
7229
- this._dispatchCallback = dispatchCallback;
7230
- this._onDestroy = onDestroy;
7357
+ this.#pluginManager = pluginManager;
7358
+ this.#dispatchCallback = dispatchCallback;
7359
+ this.#onDestroy = onDestroy;
7231
7360
  this.id = Symbol(id);
7232
7361
  this.fpsLimit = 120;
7233
7362
  this.hdr = false;
7234
- this._smooth = false;
7235
- this._delay = 0;
7236
- this._duration = 0;
7237
- this._lifeTime = 0;
7238
- this._firstStart = true;
7363
+ this.#smooth = false;
7364
+ this.#delay = 0;
7365
+ this.#duration = 0;
7366
+ this.#lifeTime = 0;
7367
+ this.#firstStart = true;
7239
7368
  this.started = false;
7240
7369
  this.destroyed = false;
7241
- this._paused = true;
7242
- this._lastFrameTime = 0;
7370
+ this.#paused = true;
7371
+ this.#lastFrameTime = 0;
7243
7372
  this.zLayers = 100;
7244
7373
  this.pageHidden = false;
7245
- this._sourceOptions = sourceOptions;
7246
- this._initialSourceOptions = sourceOptions;
7374
+ this.#sourceOptions = sourceOptions;
7375
+ this.#initialSourceOptions = sourceOptions;
7247
7376
  this.effectDrawers = new Map();
7248
7377
  this.shapeDrawers = new Map();
7249
7378
  this.particleUpdaters = [];
7250
7379
  this.retina = new Retina(this);
7251
- this.canvas = new CanvasManager(this._pluginManager, this);
7252
- this.particles = new ParticlesManager(this._pluginManager, this);
7380
+ this.canvas = new CanvasManager(this.#pluginManager, this);
7381
+ this.particles = new ParticlesManager(this.#pluginManager, this);
7253
7382
  this.plugins = [];
7254
7383
  this.particleDestroyedPlugins = [];
7255
7384
  this.particleCreatedPlugins = [];
7256
7385
  this.particlePositionPlugins = [];
7257
- this._options = loadContainerOptions(this._pluginManager, this);
7258
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
7259
- this._eventListeners = new EventListeners(this);
7386
+ this.#options = loadContainerOptions(this.#pluginManager, this);
7387
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
7388
+ this.#eventListeners = new EventListeners(this);
7260
7389
  this.dispatchEvent(EventType.containerBuilt);
7261
7390
  }
7262
7391
  get animationStatus() {
7263
- return !this._paused && !this.pageHidden && guardCheck(this);
7392
+ return !this.#paused && !this.pageHidden && guardCheck(this);
7264
7393
  }
7265
7394
  get options() {
7266
- return this._options;
7395
+ return this.#options;
7267
7396
  }
7268
7397
  get sourceOptions() {
7269
- return this._sourceOptions;
7398
+ return this.#sourceOptions;
7270
7399
  }
7271
7400
  addLifeTime(value) {
7272
- this._lifeTime += value;
7401
+ this.#lifeTime += value;
7273
7402
  }
7274
7403
  alive() {
7275
- return !this._duration || this._lifeTime <= this._duration;
7404
+ return !this.#duration || this.#lifeTime <= this.#duration;
7276
7405
  }
7277
7406
  destroy(remove = true) {
7278
7407
  if (!guardCheck(this)) {
@@ -7294,13 +7423,13 @@
7294
7423
  this.shapeDrawers = new Map();
7295
7424
  this.particleUpdaters = [];
7296
7425
  this.plugins.length = 0;
7297
- this._pluginManager.clearPlugins(this);
7426
+ this.#pluginManager.clearPlugins(this);
7298
7427
  this.destroyed = true;
7299
- this._onDestroy(remove);
7428
+ this.#onDestroy(remove);
7300
7429
  this.dispatchEvent(EventType.containerDestroyed);
7301
7430
  }
7302
7431
  dispatchEvent(type, data) {
7303
- this._dispatchCallback(type, {
7432
+ this.#dispatchCallback(type, {
7304
7433
  container: this,
7305
7434
  data,
7306
7435
  });
@@ -7310,12 +7439,12 @@
7310
7439
  return;
7311
7440
  }
7312
7441
  let refreshTime = force;
7313
- this._drawAnimationFrame = animate((timestamp) => {
7442
+ this.#drawAnimationFrame = animate((timestamp) => {
7314
7443
  if (refreshTime) {
7315
- this._lastFrameTime = undefined;
7444
+ this.#lastFrameTime = undefined;
7316
7445
  refreshTime = false;
7317
7446
  }
7318
- this._nextFrame(timestamp);
7447
+ this.#nextFrame(timestamp);
7319
7448
  });
7320
7449
  }
7321
7450
  async export(type, options = {}) {
@@ -7337,7 +7466,7 @@
7337
7466
  return;
7338
7467
  }
7339
7468
  const allContainerPlugins = new Map();
7340
- for (const plugin of this._pluginManager.plugins) {
7469
+ for (const plugin of this.#pluginManager.plugins) {
7341
7470
  const containerPlugin = await plugin.getPlugin(this);
7342
7471
  if (containerPlugin.preInit) {
7343
7472
  await containerPlugin.preInit();
@@ -7345,8 +7474,8 @@
7345
7474
  allContainerPlugins.set(plugin, containerPlugin);
7346
7475
  }
7347
7476
  await this.initDrawersAndUpdaters();
7348
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
7349
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
7477
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
7478
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
7350
7479
  this.plugins.length = 0;
7351
7480
  this.particleDestroyedPlugins.length = 0;
7352
7481
  this.particleCreatedPlugins.length = 0;
@@ -7373,11 +7502,11 @@
7373
7502
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
7374
7503
  this.hdr = hdr;
7375
7504
  this.zLayers = zLayers;
7376
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
7377
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
7378
- this._lifeTime = 0;
7505
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
7506
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
7507
+ this.#lifeTime = 0;
7379
7508
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
7380
- this._smooth = smooth;
7509
+ this.#smooth = smooth;
7381
7510
  for (const plugin of this.plugins) {
7382
7511
  await plugin.init?.();
7383
7512
  }
@@ -7390,7 +7519,7 @@
7390
7519
  this.dispatchEvent(EventType.particlesSetup);
7391
7520
  }
7392
7521
  async initDrawersAndUpdaters() {
7393
- const pluginManager = this._pluginManager;
7522
+ const pluginManager = this.#pluginManager;
7394
7523
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
7395
7524
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
7396
7525
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -7399,18 +7528,18 @@
7399
7528
  if (!guardCheck(this)) {
7400
7529
  return;
7401
7530
  }
7402
- if (this._drawAnimationFrame !== undefined) {
7403
- cancelAnimation(this._drawAnimationFrame);
7404
- delete this._drawAnimationFrame;
7531
+ if (this.#drawAnimationFrame !== undefined) {
7532
+ cancelAnimation(this.#drawAnimationFrame);
7533
+ this.#drawAnimationFrame = undefined;
7405
7534
  }
7406
- if (this._paused) {
7535
+ if (this.#paused) {
7407
7536
  return;
7408
7537
  }
7409
7538
  for (const plugin of this.plugins) {
7410
7539
  plugin.pause?.();
7411
7540
  }
7412
7541
  if (!this.pageHidden) {
7413
- this._paused = true;
7542
+ this.#paused = true;
7414
7543
  }
7415
7544
  this.dispatchEvent(EventType.containerPaused);
7416
7545
  }
@@ -7418,13 +7547,13 @@
7418
7547
  if (!guardCheck(this)) {
7419
7548
  return;
7420
7549
  }
7421
- const needsUpdate = this._paused || force;
7422
- if (this._firstStart && !this.actualOptions.autoPlay) {
7423
- this._firstStart = false;
7550
+ const needsUpdate = this.#paused || force;
7551
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
7552
+ this.#firstStart = false;
7424
7553
  return;
7425
7554
  }
7426
- if (this._paused) {
7427
- this._paused = false;
7555
+ if (this.#paused) {
7556
+ this.#paused = false;
7428
7557
  }
7429
7558
  if (needsUpdate) {
7430
7559
  for (const plugin of this.plugins) {
@@ -7447,10 +7576,10 @@
7447
7576
  if (!guardCheck(this)) {
7448
7577
  return;
7449
7578
  }
7450
- this._initialSourceOptions = sourceOptions;
7451
- this._sourceOptions = sourceOptions;
7452
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
7453
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
7579
+ this.#initialSourceOptions = sourceOptions;
7580
+ this.#sourceOptions = sourceOptions;
7581
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
7582
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
7454
7583
  return this.refresh();
7455
7584
  }
7456
7585
  async start() {
@@ -7461,7 +7590,7 @@
7461
7590
  this.started = true;
7462
7591
  await new Promise(resolve => {
7463
7592
  const start = async () => {
7464
- this._eventListeners.addListeners();
7593
+ this.#eventListeners.addListeners();
7465
7594
  for (const plugin of this.plugins) {
7466
7595
  await plugin.start?.();
7467
7596
  }
@@ -7469,20 +7598,20 @@
7469
7598
  this.play();
7470
7599
  resolve();
7471
7600
  };
7472
- this._delayTimeout = setTimeout(() => void start(), this._delay);
7601
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
7473
7602
  });
7474
7603
  }
7475
7604
  stop() {
7476
7605
  if (!guardCheck(this) || !this.started) {
7477
7606
  return;
7478
7607
  }
7479
- if (this._delayTimeout) {
7480
- clearTimeout(this._delayTimeout);
7481
- delete this._delayTimeout;
7608
+ if (this.#delayTimeout) {
7609
+ clearTimeout(this.#delayTimeout);
7610
+ this.#delayTimeout = undefined;
7482
7611
  }
7483
- this._firstStart = true;
7612
+ this.#firstStart = true;
7484
7613
  this.started = false;
7485
- this._eventListeners.removeListeners();
7614
+ this.#eventListeners.removeListeners();
7486
7615
  this.pause();
7487
7616
  this.particles.clear();
7488
7617
  this.canvas.stop();
@@ -7492,7 +7621,7 @@
7492
7621
  this.particleCreatedPlugins.length = 0;
7493
7622
  this.particleDestroyedPlugins.length = 0;
7494
7623
  this.particlePositionPlugins.length = 0;
7495
- this._sourceOptions = this._options;
7624
+ this.#sourceOptions = this.#options;
7496
7625
  this.dispatchEvent(EventType.containerStopped);
7497
7626
  }
7498
7627
  updateActualOptions() {
@@ -7504,23 +7633,23 @@
7504
7633
  }
7505
7634
  return refresh;
7506
7635
  }
7507
- _nextFrame = (timestamp) => {
7636
+ #nextFrame = (timestamp) => {
7508
7637
  try {
7509
- if (!this._smooth &&
7510
- this._lastFrameTime !== undefined &&
7511
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
7638
+ if (!this.#smooth &&
7639
+ this.#lastFrameTime !== undefined &&
7640
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
7512
7641
  this.draw(false);
7513
7642
  return;
7514
7643
  }
7515
- this._lastFrameTime ??= timestamp;
7516
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
7517
- this.addLifeTime(this._delta.value);
7518
- this._lastFrameTime = timestamp;
7519
- if (this._delta.value > millisecondsToSeconds) {
7644
+ this.#lastFrameTime ??= timestamp;
7645
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
7646
+ this.addLifeTime(this.#delta.value);
7647
+ this.#lastFrameTime = timestamp;
7648
+ if (this.#delta.value > millisecondsToSeconds) {
7520
7649
  this.draw(false);
7521
7650
  return;
7522
7651
  }
7523
- this.canvas.render.drawParticles(this._delta);
7652
+ this.canvas.render.drawParticles(this.#delta);
7524
7653
  if (!this.alive()) {
7525
7654
  this.destroy();
7526
7655
  return;
@@ -7541,10 +7670,10 @@
7541
7670
  });
7542
7671
 
7543
7672
  class BlendPluginInstance {
7544
- _container;
7545
- _defaultCompositeValue;
7673
+ #container;
7674
+ #defaultCompositeValue;
7546
7675
  constructor(container) {
7547
- this._container = container;
7676
+ this.#container = container;
7548
7677
  }
7549
7678
  drawParticleCleanup(context, particle) {
7550
7679
  if (!particle.options.blend?.enable) {
@@ -7561,14 +7690,14 @@
7561
7690
  context.globalCompositeOperation = particle.options.blend.mode;
7562
7691
  }
7563
7692
  drawSettingsCleanup(context) {
7564
- if (!this._defaultCompositeValue) {
7693
+ if (!this.#defaultCompositeValue) {
7565
7694
  return;
7566
7695
  }
7567
- context.globalCompositeOperation = this._defaultCompositeValue;
7696
+ context.globalCompositeOperation = this.#defaultCompositeValue;
7568
7697
  }
7569
7698
  drawSettingsSetup(context) {
7570
- const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
7571
- this._defaultCompositeValue = previousComposite;
7699
+ const previousComposite = context.globalCompositeOperation, blend = this.#container.actualOptions.blend;
7700
+ this.#defaultCompositeValue = previousComposite;
7572
7701
  context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
7573
7702
  }
7574
7703
  }
@@ -7711,11 +7840,11 @@
7711
7840
  class MovePluginInstance {
7712
7841
  availablePathGenerators;
7713
7842
  pathGenerators;
7714
- _container;
7715
- _pluginManager;
7843
+ #container;
7844
+ #pluginManager;
7716
7845
  constructor(pluginManager, container) {
7717
- this._pluginManager = pluginManager;
7718
- this._container = container;
7846
+ this.#pluginManager = pluginManager;
7847
+ this.#container = container;
7719
7848
  this.availablePathGenerators = new Map();
7720
7849
  this.pathGenerators = new Map();
7721
7850
  }
@@ -7746,7 +7875,7 @@
7746
7875
  acceleration: getRangeValue(gravityOptions.acceleration),
7747
7876
  inverse: gravityOptions.inverse,
7748
7877
  };
7749
- initSpin(this._container, particle);
7878
+ initSpin(this.#container, particle);
7750
7879
  }
7751
7880
  particleDestroyed(particle) {
7752
7881
  const pathGenerator = particle.pathGenerator;
@@ -7757,7 +7886,7 @@
7757
7886
  if (!moveOptions.enable) {
7758
7887
  return;
7759
7888
  }
7760
- 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;
7889
+ 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;
7761
7890
  if (moveOptions.spin.enable) {
7762
7891
  spin(container, particle, moveSpeed, reduceFactor);
7763
7892
  }
@@ -7767,18 +7896,18 @@
7767
7896
  applyDistance(particle);
7768
7897
  }
7769
7898
  preInit() {
7770
- return this._init();
7899
+ return this.#init();
7771
7900
  }
7772
7901
  redrawInit() {
7773
- return this._init();
7902
+ return this.#init();
7774
7903
  }
7775
7904
  update() {
7776
7905
  for (const pathGenerator of this.pathGenerators.values()) {
7777
7906
  pathGenerator.update();
7778
7907
  }
7779
7908
  }
7780
- async _init() {
7781
- const availablePathGenerators = await this._pluginManager.getPathGenerators?.(this._container, true);
7909
+ async #init() {
7910
+ const availablePathGenerators = await this.#pluginManager.getPathGenerators?.(this.#container, true);
7782
7911
  if (!availablePathGenerators) {
7783
7912
  return;
7784
7913
  }
@@ -7796,44 +7925,44 @@
7796
7925
  });
7797
7926
 
7798
7927
  class EmittersPluginInstance {
7799
- container;
7800
- _instancesManager;
7928
+ #container;
7929
+ #instancesManager;
7801
7930
  constructor(instancesManager, container) {
7802
- this.container = container;
7803
- this._instancesManager = instancesManager;
7804
- this._instancesManager.initContainer(container);
7931
+ this.#instancesManager = instancesManager;
7932
+ this.#container = container;
7933
+ this.#instancesManager.initContainer(container);
7805
7934
  }
7806
7935
  async init() {
7807
- const emittersOptions = this.container.actualOptions.emitters;
7936
+ const emittersOptions = this.#container.actualOptions.emitters;
7808
7937
  if (isArray(emittersOptions)) {
7809
7938
  for (const emitterOptions of emittersOptions) {
7810
- await this._instancesManager.addEmitter(this.container, emitterOptions);
7939
+ await this.#instancesManager.addEmitter(this.#container, emitterOptions);
7811
7940
  }
7812
7941
  }
7813
7942
  else {
7814
- await this._instancesManager.addEmitter(this.container, emittersOptions);
7943
+ await this.#instancesManager.addEmitter(this.#container, emittersOptions);
7815
7944
  }
7816
7945
  }
7817
7946
  pause() {
7818
- for (const emitter of this._instancesManager.getArray(this.container)) {
7947
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
7819
7948
  emitter.pause();
7820
7949
  }
7821
7950
  }
7822
7951
  play() {
7823
- for (const emitter of this._instancesManager.getArray(this.container)) {
7952
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
7824
7953
  emitter.play();
7825
7954
  }
7826
7955
  }
7827
7956
  resize() {
7828
- for (const emitter of this._instancesManager.getArray(this.container)) {
7957
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
7829
7958
  emitter.resize();
7830
7959
  }
7831
7960
  }
7832
7961
  stop() {
7833
- this._instancesManager.clear(this.container);
7962
+ this.#instancesManager.clear(this.#container);
7834
7963
  }
7835
7964
  update(delta) {
7836
- this._instancesManager.getArray(this.container).forEach(emitter => {
7965
+ this.#instancesManager.getArray(this.#container).forEach(emitter => {
7837
7966
  emitter.update(delta);
7838
7967
  });
7839
7968
  }
@@ -7866,16 +7995,16 @@
7866
7995
 
7867
7996
  const defaultIndex = 0;
7868
7997
  class EmittersInstancesManager {
7869
- _containerArrays;
7870
- _pluginManager;
7998
+ #containerArrays;
7999
+ #pluginManager;
7871
8000
  constructor(pluginManager) {
7872
- this._containerArrays = new Map();
7873
- this._pluginManager = pluginManager;
8001
+ this.#containerArrays = new Map();
8002
+ this.#pluginManager = pluginManager;
7874
8003
  }
7875
8004
  async addEmitter(container, options, position) {
7876
8005
  const emitterOptions = new Emitter();
7877
8006
  emitterOptions.load(options);
7878
- const { EmitterInstance } = await Promise.resolve().then(function () { return EmitterInstance$1; }), emitter = new EmitterInstance(this._pluginManager, container, (emitter) => {
8007
+ const { EmitterInstance } = await Promise.resolve().then(function () { return EmitterInstance$1; }), emitter = new EmitterInstance(this.#pluginManager, container, (emitter) => {
7879
8008
  this.removeEmitter(container, emitter);
7880
8009
  }, emitterOptions, position);
7881
8010
  await emitter.init();
@@ -7884,22 +8013,22 @@
7884
8013
  }
7885
8014
  clear(container) {
7886
8015
  this.initContainer(container);
7887
- this._containerArrays.set(container, []);
8016
+ this.#containerArrays.set(container, []);
7888
8017
  }
7889
8018
  getArray(container) {
7890
8019
  this.initContainer(container);
7891
- let array = this._containerArrays.get(container);
8020
+ let array = this.#containerArrays.get(container);
7892
8021
  if (!array) {
7893
8022
  array = [];
7894
- this._containerArrays.set(container, array);
8023
+ this.#containerArrays.set(container, array);
7895
8024
  }
7896
8025
  return array;
7897
8026
  }
7898
8027
  initContainer(container) {
7899
- if (this._containerArrays.has(container)) {
8028
+ if (this.#containerArrays.has(container)) {
7900
8029
  return;
7901
8030
  }
7902
- this._containerArrays.set(container, []);
8031
+ this.#containerArrays.set(container, []);
7903
8032
  container.getEmitter = (idxOrName) => {
7904
8033
  const array = this.getArray(container);
7905
8034
  return idxOrName === undefined || isNumber(idxOrName)
@@ -7979,25 +8108,25 @@
7979
8108
  icon.style.cssText += style;
7980
8109
  }
7981
8110
  class SoundsPluginInstance {
7982
- _audioMap;
7983
- _audioSources;
7984
- _container;
7985
- _engine;
7986
- _gain;
7987
- _muteImg;
7988
- _unmuteImg;
7989
- _volume;
7990
- _volumeDownImg;
7991
- _volumeUpImg;
8111
+ #audioMap;
8112
+ #audioSources;
8113
+ #container;
8114
+ #engine;
8115
+ #gain;
8116
+ #muteImg;
8117
+ #unmuteImg;
8118
+ #volume;
8119
+ #volumeDownImg;
8120
+ #volumeUpImg;
7992
8121
  constructor(container, engine) {
7993
- this._container = container;
7994
- this._engine = engine;
7995
- this._volume = 0;
7996
- this._audioSources = [];
7997
- this._audioMap = new Map();
8122
+ this.#container = container;
8123
+ this.#engine = engine;
8124
+ this.#volume = 0;
8125
+ this.#audioSources = [];
8126
+ this.#audioMap = new Map();
7998
8127
  }
7999
8128
  async init() {
8000
- const container = this._container, options = container.actualOptions, soundsOptions = options.sounds;
8129
+ const container = this.#container, options = container.actualOptions, soundsOptions = options.sounds;
8001
8130
  if (!soundsOptions?.enable) {
8002
8131
  return;
8003
8132
  }
@@ -8014,9 +8143,9 @@
8014
8143
  addEventListener(mouseDownEvent, firstClickHandler, listenerOptions);
8015
8144
  addEventListener(touchStartEvent, firstClickHandler, listenerOptions);
8016
8145
  }
8017
- this._volume = soundsOptions.volume.value;
8146
+ this.#volume = soundsOptions.volume.value;
8018
8147
  const events = soundsOptions.events;
8019
- this._audioMap = new Map();
8148
+ this.#audioMap = new Map();
8020
8149
  for (const event of events) {
8021
8150
  if (!event.audio) {
8022
8151
  continue;
@@ -8026,8 +8155,8 @@
8026
8155
  if (!response.ok) {
8027
8156
  return;
8028
8157
  }
8029
- const arrayBuffer = await response.arrayBuffer(), audioContext = this._getAudioContext(), audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
8030
- this._audioMap.set(audio.source, audioBuffer);
8158
+ const arrayBuffer = await response.arrayBuffer(), audioContext = this.#getAudioContext(), audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
8159
+ this.#audioMap.set(audio.source, audioBuffer);
8031
8160
  });
8032
8161
  if (promises instanceof Promise) {
8033
8162
  await promises;
@@ -8038,12 +8167,12 @@
8038
8167
  }
8039
8168
  }
8040
8169
  async mute() {
8041
- if (!this._container.muted) {
8170
+ if (!this.#container.muted) {
8042
8171
  await this.toggleMute();
8043
8172
  }
8044
8173
  }
8045
8174
  async start() {
8046
- const container = this._container, options = container.actualOptions, soundsOptions = options.sounds;
8175
+ const container = this.#container, options = container.actualOptions, soundsOptions = options.sounds;
8047
8176
  if (!soundsOptions?.enable || !container.canvas.domElement) {
8048
8177
  return;
8049
8178
  }
@@ -8054,7 +8183,7 @@
8054
8183
  }, { mute, unmute, volumeDown, volumeUp } = soundsOptions.icons, margin = 10, toggleMute = async () => {
8055
8184
  await this.toggleMute();
8056
8185
  }, enableIcons = soundsOptions.icons.enable, display = enableIcons ? ImageDisplay.Block : ImageDisplay.None;
8057
- this._muteImg = initImage({
8186
+ this.#muteImg = initImage({
8058
8187
  container,
8059
8188
  options,
8060
8189
  pos,
@@ -8064,7 +8193,7 @@
8064
8193
  rightOffsets: [volumeDown.width, volumeUp.width],
8065
8194
  clickCb: toggleMute,
8066
8195
  });
8067
- this._unmuteImg = initImage({
8196
+ this.#unmuteImg = initImage({
8068
8197
  container,
8069
8198
  options,
8070
8199
  pos,
@@ -8074,7 +8203,7 @@
8074
8203
  rightOffsets: [volumeDown.width, volumeUp.width],
8075
8204
  clickCb: toggleMute,
8076
8205
  });
8077
- this._volumeDownImg = initImage({
8206
+ this.#volumeDownImg = initImage({
8078
8207
  container,
8079
8208
  options,
8080
8209
  pos,
@@ -8086,7 +8215,7 @@
8086
8215
  await this.volumeDown();
8087
8216
  },
8088
8217
  });
8089
- this._volumeUpImg = initImage({
8218
+ this.#volumeUpImg = initImage({
8090
8219
  container,
8091
8220
  options,
8092
8221
  pos,
@@ -8103,62 +8232,62 @@
8103
8232
  }
8104
8233
  }
8105
8234
  stop() {
8106
- this._container.muted = true;
8235
+ this.#container.muted = true;
8107
8236
  void (async () => {
8108
- await this._mute();
8109
- removeImage(this._muteImg);
8110
- removeImage(this._unmuteImg);
8111
- removeImage(this._volumeDownImg);
8112
- removeImage(this._volumeUpImg);
8237
+ await this.#mute();
8238
+ removeImage(this.#muteImg);
8239
+ removeImage(this.#unmuteImg);
8240
+ removeImage(this.#volumeDownImg);
8241
+ removeImage(this.#volumeUpImg);
8113
8242
  })();
8114
8243
  }
8115
8244
  async toggleMute() {
8116
- const container = this._container;
8245
+ const container = this.#container;
8117
8246
  container.muted = !container.muted;
8118
- this._updateMuteIcons();
8119
- await this._updateMuteStatus();
8247
+ this.#updateMuteIcons();
8248
+ await this.#updateMuteStatus();
8120
8249
  }
8121
8250
  async unmute() {
8122
- if (this._container.muted) {
8251
+ if (this.#container.muted) {
8123
8252
  await this.toggleMute();
8124
8253
  }
8125
8254
  }
8126
8255
  async volumeDown() {
8127
- const container = this._container, soundsOptions = container.actualOptions.sounds;
8256
+ const container = this.#container, soundsOptions = container.actualOptions.sounds;
8128
8257
  if (!soundsOptions?.enable) {
8129
8258
  return;
8130
8259
  }
8131
8260
  if (container.muted) {
8132
- this._volume = 0;
8261
+ this.#volume = 0;
8133
8262
  }
8134
- this._volume -= soundsOptions.volume.step;
8135
- await this._updateVolume();
8263
+ this.#volume -= soundsOptions.volume.step;
8264
+ await this.#updateVolume();
8136
8265
  }
8137
8266
  async volumeUp() {
8138
- const container = this._container, soundsOptions = container.actualOptions.sounds;
8267
+ const container = this.#container, soundsOptions = container.actualOptions.sounds;
8139
8268
  if (!soundsOptions?.enable) {
8140
8269
  return;
8141
8270
  }
8142
- this._volume += soundsOptions.volume.step;
8143
- await this._updateVolume();
8271
+ this.#volume += soundsOptions.volume.step;
8272
+ await this.#updateVolume();
8144
8273
  }
8145
- _addBuffer = audioCtx => {
8274
+ #addBuffer = audioCtx => {
8146
8275
  const buffer = audioCtx.createBufferSource();
8147
- this._audioSources.push(buffer);
8276
+ this.#audioSources.push(buffer);
8148
8277
  return buffer;
8149
8278
  };
8150
- _addOscillator = audioCtx => {
8279
+ #addOscillator = audioCtx => {
8151
8280
  const oscillator = audioCtx.createOscillator();
8152
- this._audioSources.push(oscillator);
8281
+ this.#audioSources.push(oscillator);
8153
8282
  return oscillator;
8154
8283
  };
8155
- _getAudioContext() {
8156
- const container = this._container;
8284
+ #getAudioContext() {
8285
+ const container = this.#container;
8157
8286
  container.audioContext ??= new AudioContext();
8158
8287
  return container.audioContext;
8159
8288
  }
8160
- _initEvents = () => {
8161
- const container = this._container, soundsOptions = container.actualOptions.sounds;
8289
+ #initEvents = () => {
8290
+ const container = this.#container, soundsOptions = container.actualOptions.sounds;
8162
8291
  if (!soundsOptions?.enable || !container.canvas.domElement) {
8163
8292
  return;
8164
8293
  }
@@ -8169,12 +8298,12 @@
8169
8298
  }
8170
8299
  void (async () => {
8171
8300
  const filterNotValid = event.filter && !event.filter(args);
8172
- if (this._container !== args.container) {
8301
+ if (this.#container !== args.container) {
8173
8302
  return;
8174
8303
  }
8175
- if (!!this._container.muted || this._container.destroyed) {
8304
+ if (!!this.#container.muted || this.#container.destroyed) {
8176
8305
  executeOnSingleOrMultiple(event.event, item => {
8177
- this._engine.removeEventListener(item, cb);
8306
+ this.#engine.removeEventListener(item, cb);
8178
8307
  });
8179
8308
  return;
8180
8309
  }
@@ -8187,7 +8316,7 @@
8187
8316
  if (!audio) {
8188
8317
  return;
8189
8318
  }
8190
- this._playBuffer(audio);
8319
+ this.#playBuffer(audio);
8191
8320
  }
8192
8321
  else if (event.melodies) {
8193
8322
  const melody = itemFromArray(event.melodies);
@@ -8195,10 +8324,10 @@
8195
8324
  return;
8196
8325
  }
8197
8326
  if (melody.melodies.length) {
8198
- await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
8327
+ await Promise.allSettled(melody.melodies.map(m => this.#playNote(m.notes, defaultNoteIndex, melody.loop)));
8199
8328
  }
8200
8329
  else {
8201
- await this._playNote(melody.notes, defaultNoteIndex, melody.loop);
8330
+ await this.#playNote(melody.notes, defaultNoteIndex, melody.loop);
8202
8331
  }
8203
8332
  }
8204
8333
  else if (event.notes) {
@@ -8206,63 +8335,63 @@
8206
8335
  if (!note) {
8207
8336
  return;
8208
8337
  }
8209
- await this._playNote([note], defaultNoteIndex, false);
8338
+ await this.#playNote([note], defaultNoteIndex, false);
8210
8339
  }
8211
8340
  })();
8212
8341
  };
8213
8342
  executeOnSingleOrMultiple(event.event, item => {
8214
- this._engine.addEventListener(item, cb);
8343
+ this.#engine.addEventListener(item, cb);
8215
8344
  });
8216
8345
  }
8217
8346
  };
8218
- _mute = async () => {
8219
- const container = this._container, audioContext = this._getAudioContext();
8220
- for (const source of this._audioSources) {
8221
- this._removeAudioSource(source);
8347
+ #mute = async () => {
8348
+ const container = this.#container, audioContext = this.#getAudioContext();
8349
+ for (const source of this.#audioSources) {
8350
+ this.#removeAudioSource(source);
8222
8351
  }
8223
- if (this._gain) {
8224
- this._gain.disconnect();
8352
+ if (this.#gain) {
8353
+ this.#gain.disconnect();
8225
8354
  }
8226
8355
  await audioContext.close();
8227
8356
  container.audioContext = undefined;
8228
- this._container.dispatchEvent(SoundsEventType.mute);
8357
+ this.#container.dispatchEvent(SoundsEventType.mute);
8229
8358
  };
8230
- _playBuffer = audio => {
8231
- const audioBuffer = this._audioMap.get(audio.source);
8359
+ #playBuffer = audio => {
8360
+ const audioBuffer = this.#audioMap.get(audio.source);
8232
8361
  if (!audioBuffer) {
8233
8362
  return;
8234
8363
  }
8235
- const audioCtx = this._container.audioContext;
8364
+ const audioCtx = this.#container.audioContext;
8236
8365
  if (!audioCtx) {
8237
8366
  return;
8238
8367
  }
8239
- const source = this._addBuffer(audioCtx);
8368
+ const source = this.#addBuffer(audioCtx);
8240
8369
  source.loop = audio.loop;
8241
8370
  source.buffer = audioBuffer;
8242
- source.connect(this._gain ?? audioCtx.destination);
8371
+ source.connect(this.#gain ?? audioCtx.destination);
8243
8372
  source.start();
8244
8373
  };
8245
- _playFrequency = async (frequency, duration) => {
8246
- if (!this._gain || this._container.muted) {
8374
+ #playFrequency = async (frequency, duration) => {
8375
+ if (!this.#gain || this.#container.muted) {
8247
8376
  return;
8248
8377
  }
8249
- const audioContext = this._getAudioContext(), oscillator = this._addOscillator(audioContext);
8250
- oscillator.connect(this._gain);
8378
+ const audioContext = this.#getAudioContext(), oscillator = this.#addOscillator(audioContext);
8379
+ oscillator.connect(this.#gain);
8251
8380
  oscillator.type = "sine";
8252
8381
  oscillator.frequency.value = frequency;
8253
8382
  oscillator.start();
8254
8383
  return new Promise(resolve => {
8255
8384
  setTimeout(() => {
8256
- this._removeAudioSource(oscillator);
8385
+ this.#removeAudioSource(oscillator);
8257
8386
  resolve();
8258
8387
  }, duration);
8259
8388
  });
8260
8389
  };
8261
- _playMuteSound = () => {
8262
- if (this._container.muted) {
8390
+ #playMuteSound = () => {
8391
+ if (this.#container.muted) {
8263
8392
  return;
8264
8393
  }
8265
- const audioContext = this._getAudioContext(), gain = audioContext.createGain();
8394
+ const audioContext = this.#getAudioContext(), gain = audioContext.createGain();
8266
8395
  gain.connect(audioContext.destination);
8267
8396
  gain.gain.value = 0;
8268
8397
  const oscillator = audioContext.createOscillator();
@@ -8276,8 +8405,8 @@
8276
8405
  gain.disconnect();
8277
8406
  });
8278
8407
  };
8279
- _playNote = async (notes, noteIdx, loop) => {
8280
- if (this._container.muted) {
8408
+ #playNote = async (notes, noteIdx, loop) => {
8409
+ if (this.#container.muted) {
8281
8410
  return;
8282
8411
  }
8283
8412
  const note = notes[noteIdx];
@@ -8285,7 +8414,7 @@
8285
8414
  return;
8286
8415
  }
8287
8416
  const value = note.value, promises = executeOnSingleOrMultiple(value, async (_, idx) => {
8288
- return this._playNoteValue(notes, noteIdx, idx);
8417
+ return this.#playNoteValue(notes, noteIdx, idx);
8289
8418
  });
8290
8419
  await (isArray(promises) ? Promise.allSettled(promises) : promises);
8291
8420
  const indexOffset = 1;
@@ -8293,9 +8422,9 @@
8293
8422
  if (loop && nextNoteIdx >= notes.length) {
8294
8423
  nextNoteIdx = nextNoteIdx % notes.length;
8295
8424
  }
8296
- await this._playNote(notes, nextNoteIdx, loop);
8425
+ await this.#playNote(notes, nextNoteIdx, loop);
8297
8426
  };
8298
- _playNoteValue = async (notes, noteIdx, valueIdx) => {
8427
+ #playNoteValue = async (notes, noteIdx, valueIdx) => {
8299
8428
  const note = notes[noteIdx];
8300
8429
  if (!note) {
8301
8430
  return;
@@ -8309,36 +8438,36 @@
8309
8438
  if (!isNumber(freq)) {
8310
8439
  return;
8311
8440
  }
8312
- await this._playFrequency(freq, note.duration);
8441
+ await this.#playFrequency(freq, note.duration);
8313
8442
  }
8314
8443
  catch (e) {
8315
8444
  getLogger().error(e);
8316
8445
  }
8317
8446
  };
8318
- _removeAudioSource = source => {
8447
+ #removeAudioSource = source => {
8319
8448
  source.stop();
8320
8449
  source.disconnect();
8321
8450
  const deleteCount = 1;
8322
- this._audioSources.splice(this._audioSources.indexOf(source), deleteCount);
8451
+ this.#audioSources.splice(this.#audioSources.indexOf(source), deleteCount);
8323
8452
  };
8324
- _unmute = () => {
8325
- const container = this._container, options = container.actualOptions, soundsOptions = options.sounds;
8453
+ #unmute = () => {
8454
+ const container = this.#container, options = container.actualOptions, soundsOptions = options.sounds;
8326
8455
  if (!soundsOptions) {
8327
8456
  return;
8328
8457
  }
8329
- const audioContext = this._getAudioContext(), gain = audioContext.createGain();
8458
+ const audioContext = this.#getAudioContext(), gain = audioContext.createGain();
8330
8459
  gain.connect(audioContext.destination);
8331
8460
  gain.gain.value = soundsOptions.volume.value / percentDenominator;
8332
- this._gain = gain;
8333
- this._initEvents();
8334
- this._container.dispatchEvent(SoundsEventType.unmute);
8461
+ this.#gain = gain;
8462
+ this.#initEvents();
8463
+ this.#container.dispatchEvent(SoundsEventType.unmute);
8335
8464
  };
8336
- _updateMuteIcons = () => {
8337
- const container = this._container, soundsOptions = container.actualOptions.sounds;
8465
+ #updateMuteIcons = () => {
8466
+ const container = this.#container, soundsOptions = container.actualOptions.sounds;
8338
8467
  if (!soundsOptions?.enable || !soundsOptions.icons.enable) {
8339
8468
  return;
8340
8469
  }
8341
- const muteImg = this._muteImg, unmuteImg = this._unmuteImg;
8470
+ const muteImg = this.#muteImg, unmuteImg = this.#unmuteImg;
8342
8471
  if (muteImg) {
8343
8472
  muteImg.style.display = container.muted ? "block" : "none";
8344
8473
  }
@@ -8346,40 +8475,40 @@
8346
8475
  unmuteImg.style.display = container.muted ? "none" : "block";
8347
8476
  }
8348
8477
  };
8349
- _updateMuteStatus = async () => {
8350
- const container = this._container, audioContext = this._getAudioContext();
8478
+ #updateMuteStatus = async () => {
8479
+ const container = this.#container, audioContext = this.#getAudioContext();
8351
8480
  if (container.muted) {
8352
8481
  await audioContext.suspend();
8353
- await this._mute();
8482
+ await this.#mute();
8354
8483
  }
8355
8484
  else {
8356
8485
  await audioContext.resume();
8357
- this._unmute();
8358
- this._playMuteSound();
8486
+ this.#unmute();
8487
+ this.#playMuteSound();
8359
8488
  }
8360
8489
  };
8361
- _updateVolume = async () => {
8362
- const container = this._container, soundsOptions = container.actualOptions.sounds;
8490
+ #updateVolume = async () => {
8491
+ const container = this.#container, soundsOptions = container.actualOptions.sounds;
8363
8492
  if (!soundsOptions?.enable) {
8364
8493
  return;
8365
8494
  }
8366
- clamp(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
8495
+ clamp(this.#volume, soundsOptions.volume.min, soundsOptions.volume.max);
8367
8496
  let stateChanged = false;
8368
- if (this._volume <= minVolume && !container.muted) {
8369
- this._volume = 0;
8497
+ if (this.#volume <= minVolume && !container.muted) {
8498
+ this.#volume = 0;
8370
8499
  container.muted = true;
8371
8500
  stateChanged = true;
8372
8501
  }
8373
- else if (this._volume > minVolume && container.muted) {
8502
+ else if (this.#volume > minVolume && container.muted) {
8374
8503
  container.muted = false;
8375
8504
  stateChanged = true;
8376
8505
  }
8377
8506
  if (stateChanged) {
8378
- this._updateMuteIcons();
8379
- await this._updateMuteStatus();
8507
+ this.#updateMuteIcons();
8508
+ await this.#updateMuteStatus();
8380
8509
  }
8381
- if (this._gain?.gain) {
8382
- this._gain.gain.value = this._volume / percentDenominator;
8510
+ if (this.#gain?.gain) {
8511
+ this.#gain.gain.value = this.#volume / percentDenominator;
8383
8512
  }
8384
8513
  };
8385
8514
  }
@@ -8418,34 +8547,34 @@
8418
8547
  spawnStrokeColor;
8419
8548
  spawnStrokeOpacity;
8420
8549
  spawnStrokeWidth;
8421
- _container;
8422
- _currentDuration;
8423
- _currentEmitDelay;
8424
- _currentSpawnDelay;
8425
- _duration;
8426
- _emitDelay;
8427
- _firstSpawn;
8428
- _immortal;
8429
- _initialPosition;
8430
- _lifeCount;
8431
- _mutationObserver;
8432
- _particlesOptions;
8433
- _paused;
8434
- _pluginManager;
8435
- _removeCallback;
8436
- _resizeObserver;
8437
- _shape;
8438
- _size;
8439
- _spawnDelay;
8440
- _startParticlesAdded;
8550
+ #container;
8551
+ #currentDuration;
8552
+ #currentEmitDelay;
8553
+ #currentSpawnDelay;
8554
+ #duration;
8555
+ #emitDelay;
8556
+ #firstSpawn;
8557
+ #immortal;
8558
+ #initialPosition;
8559
+ #lifeCount;
8560
+ #mutationObserver;
8561
+ #particlesOptions;
8562
+ #paused;
8563
+ #pluginManager;
8564
+ #removeCallback;
8565
+ #resizeObserver;
8566
+ #shape;
8567
+ #size;
8568
+ #spawnDelay;
8569
+ #startParticlesAdded;
8441
8570
  constructor(pluginManager, container, removeCallback, options, position) {
8442
- this._pluginManager = pluginManager;
8443
- this._container = container;
8444
- this._removeCallback = removeCallback;
8445
- this._currentDuration = 0;
8446
- this._currentEmitDelay = 0;
8447
- this._currentSpawnDelay = 0;
8448
- this._initialPosition = position;
8571
+ this.#pluginManager = pluginManager;
8572
+ this.#container = container;
8573
+ this.#removeCallback = removeCallback;
8574
+ this.#currentDuration = 0;
8575
+ this.#currentEmitDelay = 0;
8576
+ this.#currentSpawnDelay = 0;
8577
+ this.#initialPosition = position;
8449
8578
  if (options instanceof Emitter) {
8450
8579
  this.options = options;
8451
8580
  }
@@ -8453,159 +8582,159 @@
8453
8582
  this.options = new Emitter();
8454
8583
  this.options.load(options);
8455
8584
  }
8456
- this._spawnDelay = container.retina.reduceFactor
8585
+ this.#spawnDelay = container.retina.reduceFactor
8457
8586
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
8458
8587
  container.retina.reduceFactor
8459
8588
  : Infinity;
8460
- this.position = this._initialPosition ?? this._calcPosition();
8589
+ this.position = this.#initialPosition ?? this.#calcPosition();
8461
8590
  this.name = this.options.name;
8462
8591
  this.fill = this.options.fill;
8463
- this._firstSpawn = !this.options.life.wait;
8464
- this._startParticlesAdded = false;
8592
+ this.#firstSpawn = !this.options.life.wait;
8593
+ this.#startParticlesAdded = false;
8465
8594
  const particlesOptions = deepExtend({}, this.options.particles);
8466
8595
  particlesOptions.move ??= {};
8467
8596
  particlesOptions.move.direction ??= this.options.direction;
8468
8597
  if (this.options.spawn.fill?.color) {
8469
- this.spawnFillColor = rangeColorToHsl(this._pluginManager, this.options.spawn.fill.color);
8598
+ this.spawnFillColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.fill.color);
8470
8599
  }
8471
8600
  if (this.options.spawn.stroke?.color) {
8472
- this.spawnStrokeColor = rangeColorToHsl(this._pluginManager, this.options.spawn.stroke.color);
8473
- }
8474
- this._paused = !this.options.autoPlay;
8475
- this._particlesOptions = particlesOptions;
8476
- this._size = this._calcSize();
8477
- this.size = getSize(this._size, this._container.canvas.size);
8478
- this._lifeCount = this.options.life.count ?? defaultLifeCount;
8479
- this._immortal = this._lifeCount <= minLifeCount;
8601
+ this.spawnStrokeColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.stroke.color);
8602
+ }
8603
+ this.#paused = !this.options.autoPlay;
8604
+ this.#particlesOptions = particlesOptions;
8605
+ this.#size = this.#calcSize();
8606
+ this.size = getSize(this.#size, this.#container.canvas.size);
8607
+ this.#lifeCount = this.options.life.count ?? defaultLifeCount;
8608
+ this.#immortal = this.#lifeCount <= minLifeCount;
8480
8609
  if (this.options.domId) {
8481
8610
  const element = safeDocument().getElementById(this.options.domId);
8482
8611
  if (element) {
8483
- this._mutationObserver = new MutationObserver(() => {
8612
+ this.#mutationObserver = new MutationObserver(() => {
8484
8613
  this.resize();
8485
8614
  });
8486
- this._resizeObserver = new ResizeObserver(() => {
8615
+ this.#resizeObserver = new ResizeObserver(() => {
8487
8616
  this.resize();
8488
8617
  });
8489
- this._mutationObserver.observe(element, {
8618
+ this.#mutationObserver.observe(element, {
8490
8619
  attributes: true,
8491
8620
  attributeFilter: ["style", "width", "height"],
8492
8621
  });
8493
- this._resizeObserver.observe(element);
8622
+ this.#resizeObserver.observe(element);
8494
8623
  }
8495
8624
  }
8496
- const shapeOptions = this.options.shape, shapeGenerator = this._pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
8625
+ const shapeOptions = this.options.shape, shapeGenerator = this.#pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
8497
8626
  if (shapeGenerator) {
8498
- this._shape = shapeGenerator.generate(this._container, this.position, this.size, this.fill, shapeOptions.options);
8627
+ this.#shape = shapeGenerator.generate(this.#container, this.position, this.size, this.fill, shapeOptions.options);
8499
8628
  }
8500
- this._container.dispatchEvent("emitterCreated", {
8629
+ this.#container.dispatchEvent("emitterCreated", {
8501
8630
  emitter: this,
8502
8631
  });
8503
8632
  this.play();
8504
8633
  }
8505
8634
  externalPause() {
8506
- this._paused = true;
8635
+ this.#paused = true;
8507
8636
  this.pause();
8508
8637
  }
8509
8638
  externalPlay() {
8510
- this._paused = false;
8639
+ this.#paused = false;
8511
8640
  this.play();
8512
8641
  }
8513
8642
  async init() {
8514
- await this._shape?.init();
8643
+ await this.#shape?.init();
8515
8644
  }
8516
8645
  pause() {
8517
- if (this._paused) {
8646
+ if (this.#paused) {
8518
8647
  return;
8519
8648
  }
8520
- delete this._emitDelay;
8649
+ this.#emitDelay = undefined;
8521
8650
  }
8522
8651
  play() {
8523
- if (this._paused) {
8652
+ if (this.#paused) {
8524
8653
  return;
8525
8654
  }
8526
- if (!((this._lifeCount > minLifeCount || this._immortal || !this.options.life.count) &&
8527
- (this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? defaultSpawnDelay)))) {
8655
+ if (!((this.#lifeCount > minLifeCount || this.#immortal || !this.options.life.count) &&
8656
+ (this.#firstSpawn || this.#currentSpawnDelay >= (this.#spawnDelay ?? defaultSpawnDelay)))) {
8528
8657
  return;
8529
8658
  }
8530
- const container = this._container;
8531
- if (this._emitDelay === undefined) {
8659
+ const container = this.#container;
8660
+ if (this.#emitDelay === undefined) {
8532
8661
  const delay = getRangeValue(this.options.rate.delay);
8533
- this._emitDelay = container.retina.reduceFactor
8662
+ this.#emitDelay = container.retina.reduceFactor
8534
8663
  ? (delay * millisecondsToSeconds) / container.retina.reduceFactor
8535
8664
  : Infinity;
8536
8665
  }
8537
- if (this._lifeCount > minLifeCount || this._immortal) {
8538
- this._prepareToDie();
8666
+ if (this.#lifeCount > minLifeCount || this.#immortal) {
8667
+ this.#prepareToDie();
8539
8668
  }
8540
8669
  }
8541
8670
  resize() {
8542
- const initialPosition = this._initialPosition, container = this._container;
8671
+ const initialPosition = this.#initialPosition, container = this.#container;
8543
8672
  this.position =
8544
8673
  initialPosition && isPointInside(initialPosition, container.canvas.size, Vector.origin)
8545
8674
  ? initialPosition
8546
- : this._calcPosition();
8547
- this._size = this._calcSize();
8548
- this.size = getSize(this._size, container.canvas.size);
8549
- this._shape?.resize(this.position, this.size);
8675
+ : this.#calcPosition();
8676
+ this.#size = this.#calcSize();
8677
+ this.size = getSize(this.#size, container.canvas.size);
8678
+ this.#shape?.resize(this.position, this.size);
8550
8679
  }
8551
8680
  update(delta) {
8552
- if (this._paused) {
8681
+ if (this.#paused) {
8553
8682
  return;
8554
8683
  }
8555
- const container = this._container;
8556
- if (this._firstSpawn) {
8557
- this._firstSpawn = false;
8558
- this._currentSpawnDelay = this._spawnDelay ?? defaultSpawnDelay;
8559
- this._currentEmitDelay = this._emitDelay ?? defaultEmitDelay;
8684
+ const container = this.#container;
8685
+ if (this.#firstSpawn) {
8686
+ this.#firstSpawn = false;
8687
+ this.#currentSpawnDelay = this.#spawnDelay ?? defaultSpawnDelay;
8688
+ this.#currentEmitDelay = this.#emitDelay ?? defaultEmitDelay;
8560
8689
  }
8561
- if (!this._startParticlesAdded) {
8562
- this._startParticlesAdded = true;
8563
- this._emitParticles(this.options.startCount);
8690
+ if (!this.#startParticlesAdded) {
8691
+ this.#startParticlesAdded = true;
8692
+ this.#emitParticles(this.options.startCount);
8564
8693
  }
8565
- if (this._duration !== undefined) {
8566
- this._currentDuration += delta.value;
8567
- if (this._currentDuration >= this._duration) {
8694
+ if (this.#duration !== undefined) {
8695
+ this.#currentDuration += delta.value;
8696
+ if (this.#currentDuration >= this.#duration) {
8568
8697
  this.pause();
8569
- if (this._spawnDelay !== undefined) {
8570
- delete this._spawnDelay;
8698
+ if (this.#spawnDelay !== undefined) {
8699
+ this.#spawnDelay = undefined;
8571
8700
  }
8572
- if (!this._immortal) {
8573
- this._lifeCount--;
8701
+ if (!this.#immortal) {
8702
+ this.#lifeCount--;
8574
8703
  }
8575
- if (this._lifeCount > minLifeCount || this._immortal) {
8576
- this.position = this._calcPosition();
8577
- this._shape?.resize(this.position, this.size);
8578
- this._spawnDelay = container.retina.reduceFactor
8704
+ if (this.#lifeCount > minLifeCount || this.#immortal) {
8705
+ this.position = this.#calcPosition();
8706
+ this.#shape?.resize(this.position, this.size);
8707
+ this.#spawnDelay = container.retina.reduceFactor
8579
8708
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
8580
8709
  container.retina.reduceFactor
8581
8710
  : Infinity;
8582
8711
  }
8583
8712
  else {
8584
- this._destroy();
8713
+ this.#destroy();
8585
8714
  }
8586
- this._currentDuration -= this._duration;
8587
- delete this._duration;
8715
+ this.#currentDuration -= this.#duration;
8716
+ this.#duration = undefined;
8588
8717
  }
8589
8718
  }
8590
- if (this._spawnDelay !== undefined) {
8591
- this._currentSpawnDelay += delta.value;
8592
- if (this._currentSpawnDelay >= this._spawnDelay) {
8593
- this._container.dispatchEvent("emitterPlay");
8719
+ if (this.#spawnDelay !== undefined) {
8720
+ this.#currentSpawnDelay += delta.value;
8721
+ if (this.#currentSpawnDelay >= this.#spawnDelay) {
8722
+ this.#container.dispatchEvent("emitterPlay");
8594
8723
  this.play();
8595
- this._currentSpawnDelay -= this._spawnDelay;
8596
- delete this._spawnDelay;
8724
+ this.#currentSpawnDelay -= this.#spawnDelay;
8725
+ this.#spawnDelay = undefined;
8597
8726
  }
8598
8727
  }
8599
- if (this._emitDelay !== undefined) {
8600
- this._currentEmitDelay += delta.value;
8601
- if (this._currentEmitDelay >= this._emitDelay) {
8602
- this._emit();
8603
- this._currentEmitDelay -= this._emitDelay;
8728
+ if (this.#emitDelay !== undefined) {
8729
+ this.#currentEmitDelay += delta.value;
8730
+ if (this.#currentEmitDelay >= this.#emitDelay) {
8731
+ this.#emit();
8732
+ this.#currentEmitDelay -= this.#emitDelay;
8604
8733
  }
8605
8734
  }
8606
8735
  }
8607
- _calcPosition() {
8608
- const container = this._container;
8736
+ #calcPosition() {
8737
+ const container = this.#container;
8609
8738
  if (this.options.domId) {
8610
8739
  const element = safeDocument().getElementById(this.options.domId);
8611
8740
  if (element) {
@@ -8621,8 +8750,8 @@
8621
8750
  position: this.options.position,
8622
8751
  });
8623
8752
  }
8624
- _calcSize() {
8625
- const container = this._container;
8753
+ #calcSize() {
8754
+ const container = this.#container;
8626
8755
  if (this.options.domId) {
8627
8756
  const element = safeDocument().getElementById(this.options.domId);
8628
8757
  if (element) {
@@ -8645,32 +8774,32 @@
8645
8774
  return size;
8646
8775
  })());
8647
8776
  }
8648
- _destroy = () => {
8649
- this._mutationObserver?.disconnect();
8650
- this._mutationObserver = undefined;
8651
- this._resizeObserver?.disconnect();
8652
- this._resizeObserver = undefined;
8653
- this._removeCallback(this);
8654
- this._container.dispatchEvent("emitterDestroyed", {
8777
+ #destroy = () => {
8778
+ this.#mutationObserver?.disconnect();
8779
+ this.#mutationObserver = undefined;
8780
+ this.#resizeObserver?.disconnect();
8781
+ this.#resizeObserver = undefined;
8782
+ this.#removeCallback(this);
8783
+ this.#container.dispatchEvent("emitterDestroyed", {
8655
8784
  emitter: this,
8656
8785
  });
8657
8786
  };
8658
- _emit() {
8659
- if (this._paused) {
8787
+ #emit() {
8788
+ if (this.#paused) {
8660
8789
  return;
8661
8790
  }
8662
8791
  const quantity = getRangeValue(this.options.rate.quantity);
8663
- this._emitParticles(quantity);
8792
+ this.#emitParticles(quantity);
8664
8793
  }
8665
- _emitParticles(quantity) {
8666
- const singleParticlesOptions = (itemFromSingleOrMultiple(this._particlesOptions) ??
8794
+ #emitParticles(quantity) {
8795
+ const singleParticlesOptions = (itemFromSingleOrMultiple(this.#particlesOptions) ??
8667
8796
  {}), 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
8668
8797
  ? defaultOpacity$1
8669
8798
  : getRangeValue(this.options.spawn.fill.opacity), strokeHslAnimation = this.options.spawn.stroke?.color?.animation, strokeOpacity = this.options.spawn.stroke?.opacity === undefined
8670
8799
  ? defaultOpacity$1
8671
8800
  : getRangeValue(this.options.spawn.stroke.opacity), strokeWidth = this.options.spawn.stroke?.width === undefined
8672
8801
  ? defaultStrokeWidth
8673
- : 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;
8802
+ : 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;
8674
8803
  for (let i = 0; i < quantity * reduceFactor; i++) {
8675
8804
  const particlesOptions = needsCopy
8676
8805
  ? deepExtend({}, singleParticlesOptions)
@@ -8681,23 +8810,23 @@
8681
8810
  this.spawnStrokeWidth = strokeWidth;
8682
8811
  if (this.spawnFillColor) {
8683
8812
  if (fillHslAnimation && maxValues) {
8684
- this.spawnFillColor.h = this._setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
8685
- this.spawnFillColor.s = this._setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
8686
- this.spawnFillColor.l = this._setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
8813
+ this.spawnFillColor.h = this.#setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
8814
+ this.spawnFillColor.s = this.#setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
8815
+ this.spawnFillColor.l = this.#setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
8687
8816
  }
8688
8817
  setParticlesOptionsFillColor(particlesOptions, this.spawnFillColor, this.spawnFillOpacity, this.spawnFillEnabled);
8689
8818
  }
8690
8819
  if (this.spawnStrokeColor) {
8691
8820
  if (strokeHslAnimation && maxValues) {
8692
- this.spawnStrokeColor.h = this._setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
8693
- this.spawnStrokeColor.s = this._setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
8694
- this.spawnStrokeColor.l = this._setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
8821
+ this.spawnStrokeColor.h = this.#setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
8822
+ this.spawnStrokeColor.s = this.#setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
8823
+ this.spawnStrokeColor.l = this.#setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
8695
8824
  }
8696
8825
  setParticlesOptionsStrokeColor(particlesOptions, this.spawnStrokeColor, this.spawnStrokeOpacity, this.spawnStrokeWidth);
8697
8826
  }
8698
8827
  let position = this.position;
8699
- if (this._shape) {
8700
- const shapePosData = this._shape.randomPosition();
8828
+ if (this.#shape) {
8829
+ const shapePosData = this.#shape.randomPosition();
8701
8830
  if (shapePosData) {
8702
8831
  position = shapePosData.position;
8703
8832
  const replaceData = shapeOptions.replace;
@@ -8710,21 +8839,21 @@
8710
8839
  }
8711
8840
  }
8712
8841
  if (position) {
8713
- this._container.particles.addParticle(position, particlesOptions);
8842
+ this.#container.particles.addParticle(position, particlesOptions);
8714
8843
  }
8715
8844
  }
8716
8845
  }
8717
- _prepareToDie = () => {
8718
- if (this._paused) {
8846
+ #prepareToDie = () => {
8847
+ if (this.#paused) {
8719
8848
  return;
8720
8849
  }
8721
8850
  const duration = this.options.life.duration !== undefined ? getRangeValue(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
8722
- if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
8723
- this._duration = duration * millisecondsToSeconds;
8851
+ if ((this.#lifeCount > minLifeCount || this.#immortal) && duration !== undefined && duration > minDuration) {
8852
+ this.#duration = duration * millisecondsToSeconds;
8724
8853
  }
8725
8854
  };
8726
- _setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
8727
- const container = this._container;
8855
+ #setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
8856
+ const container = this.#container;
8728
8857
  if (!animation.enable) {
8729
8858
  return initValue;
8730
8859
  }