@tsparticles/preset-confetti-explosions 4.0.4 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* Preset v4.0.4 */
2
+ /* Preset v4.1.0 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5
5
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -51,13 +51,13 @@
51
51
  return Math.atan2(this.y, this.x);
52
52
  }
53
53
  set angle(angle) {
54
- this._updateFromAngle(angle, this.length);
54
+ this.#updateFromAngle(angle, this.length);
55
55
  }
56
56
  get length() {
57
57
  return Math.sqrt(this.getLengthSq());
58
58
  }
59
59
  set length(length) {
60
- this._updateFromAngle(this.angle, length);
60
+ this.#updateFromAngle(this.angle, length);
61
61
  }
62
62
  static clone(source) {
63
63
  return Vector3d.create(source.x, source.y, getZ(source));
@@ -120,7 +120,7 @@
120
120
  this.y -= v.y;
121
121
  this.z -= getZ(v);
122
122
  }
123
- _updateFromAngle(angle, length) {
123
+ #updateFromAngle(angle, length) {
124
124
  this.x = Math.cos(angle) * length;
125
125
  this.y = Math.sin(angle) * length;
126
126
  }
@@ -727,38 +727,38 @@
727
727
  }
728
728
 
729
729
  class EventDispatcher {
730
- _listeners;
730
+ #listeners;
731
731
  constructor() {
732
- this._listeners = new Map();
732
+ this.#listeners = new Map();
733
733
  }
734
734
  addEventListener(type, listener) {
735
735
  this.removeEventListener(type, listener);
736
- let arr = this._listeners.get(type);
736
+ let arr = this.#listeners.get(type);
737
737
  if (!arr) {
738
738
  arr = [];
739
- this._listeners.set(type, arr);
739
+ this.#listeners.set(type, arr);
740
740
  }
741
741
  arr.push(listener);
742
742
  }
743
743
  dispatchEvent(type, args) {
744
- const listeners = this._listeners.get(type);
744
+ const listeners = this.#listeners.get(type);
745
745
  listeners?.forEach(handler => {
746
746
  handler(args);
747
747
  });
748
748
  }
749
749
  hasEventListener(type) {
750
- return !!this._listeners.get(type);
750
+ return !!this.#listeners.get(type);
751
751
  }
752
752
  removeAllEventListeners(type) {
753
753
  if (!type) {
754
- this._listeners = new Map();
754
+ this.#listeners = new Map();
755
755
  }
756
756
  else {
757
- this._listeners.delete(type);
757
+ this.#listeners.delete(type);
758
758
  }
759
759
  }
760
760
  removeEventListener(type, listener) {
761
- const arr = this._listeners.get(type);
761
+ const arr = this.#listeners.get(type);
762
762
  if (!arr) {
763
763
  return;
764
764
  }
@@ -767,7 +767,7 @@
767
767
  return;
768
768
  }
769
769
  if (length === deleteCount) {
770
- this._listeners.delete(type);
770
+ this.#listeners.delete(type);
771
771
  }
772
772
  else {
773
773
  arr.splice(idx, deleteCount);
@@ -805,19 +805,19 @@
805
805
  presets = new Map();
806
806
  shapeDrawers = new Map();
807
807
  updaters = new Map();
808
- _allLoadersSet = new Set();
809
- _configs = new Map();
810
- _engine;
811
- _executedSet = new Set();
812
- _initialized = false;
813
- _isRunningLoaders = false;
814
- _loadPromises = new Set();
808
+ #allLoadersSet = new Set();
809
+ #configs = new Map();
810
+ #engine;
811
+ #executedSet = new Set();
812
+ #initialized = false;
813
+ #isRunningLoaders = false;
814
+ #loadPromises = new Set();
815
815
  constructor(engine) {
816
- this._engine = engine;
816
+ this.#engine = engine;
817
817
  }
818
818
  get configs() {
819
819
  const res = {};
820
- for (const [name, config] of this._configs) {
820
+ for (const [name, config] of this.#configs) {
821
821
  res[name] = config;
822
822
  }
823
823
  return res;
@@ -827,8 +827,8 @@
827
827
  }
828
828
  addConfig(config) {
829
829
  const key = config.key ?? config.name ?? "default";
830
- this._configs.set(key, config);
831
- this._engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
830
+ this.#configs.set(key, config);
831
+ this.#engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
832
832
  }
833
833
  addEasing(name, easing) {
834
834
  if (this.easingFunctions.get(name)) {
@@ -889,21 +889,21 @@
889
889
  return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
890
890
  }
891
891
  async init() {
892
- if (this._initialized || this._isRunningLoaders) {
892
+ if (this.#initialized || this.#isRunningLoaders) {
893
893
  return;
894
894
  }
895
- this._isRunningLoaders = true;
896
- this._executedSet = new Set();
897
- this._allLoadersSet = new Set(this._loadPromises);
895
+ this.#isRunningLoaders = true;
896
+ this.#executedSet = new Set();
897
+ this.#allLoadersSet = new Set(this.#loadPromises);
898
898
  try {
899
- for (const loader of this._allLoadersSet) {
900
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
899
+ for (const loader of this.#allLoadersSet) {
900
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
901
901
  }
902
902
  }
903
903
  finally {
904
- this._loadPromises.clear();
905
- this._isRunningLoaders = false;
906
- this._initialized = true;
904
+ this.#loadPromises.clear();
905
+ this.#isRunningLoaders = false;
906
+ this.#initialized = true;
907
907
  }
908
908
  }
909
909
  loadParticlesOptions(container, options, ...sourceOptions) {
@@ -914,24 +914,24 @@
914
914
  updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
915
915
  }
916
916
  async register(...loaders) {
917
- if (this._initialized) {
917
+ if (this.#initialized) {
918
918
  throw new Error("Register plugins can only be done before calling tsParticles.load()");
919
919
  }
920
920
  for (const loader of loaders) {
921
- if (this._isRunningLoaders) {
922
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
921
+ if (this.#isRunningLoaders) {
922
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
923
923
  }
924
924
  else {
925
- this._loadPromises.add(loader);
925
+ this.#loadPromises.add(loader);
926
926
  }
927
927
  }
928
928
  }
929
- async _runLoader(loader, executed, allLoaders) {
929
+ async #runLoader(loader, executed, allLoaders) {
930
930
  if (executed.has(loader))
931
931
  return;
932
932
  executed.add(loader);
933
933
  allLoaders.add(loader);
934
- await loader(this._engine);
934
+ await loader(this.#engine);
935
935
  }
936
936
  }
937
937
 
@@ -1011,17 +1011,17 @@
1011
1011
  };
1012
1012
  class Engine {
1013
1013
  pluginManager = new PluginManager(this);
1014
- _domArray = [];
1015
- _eventDispatcher = new EventDispatcher();
1016
- _initialized = false;
1014
+ #domArray = [];
1015
+ #eventDispatcher = new EventDispatcher();
1016
+ #initialized = false;
1017
1017
  get items() {
1018
- return this._domArray;
1018
+ return this.#domArray;
1019
1019
  }
1020
1020
  get version() {
1021
- return "4.0.4";
1021
+ return "4.1.0";
1022
1022
  }
1023
1023
  addEventListener(type, listener) {
1024
- this._eventDispatcher.addEventListener(type, listener);
1024
+ this.#eventDispatcher.addEventListener(type, listener);
1025
1025
  }
1026
1026
  checkVersion(pluginVersion) {
1027
1027
  if (this.version === pluginVersion) {
@@ -1030,17 +1030,17 @@
1030
1030
  throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
1031
1031
  }
1032
1032
  dispatchEvent(type, args) {
1033
- this._eventDispatcher.dispatchEvent(type, args);
1033
+ this.#eventDispatcher.dispatchEvent(type, args);
1034
1034
  }
1035
1035
  async init() {
1036
- if (this._initialized) {
1036
+ if (this.#initialized) {
1037
1037
  return;
1038
1038
  }
1039
1039
  await this.pluginManager.init();
1040
- this._initialized = true;
1040
+ this.#initialized = true;
1041
1041
  }
1042
1042
  item(index) {
1043
- const { items } = this, item = items[index];
1043
+ const items = this.items, item = items[index];
1044
1044
  if (item?.destroyed) {
1045
1045
  items.splice(index, removeDeleteCount);
1046
1046
  return;
@@ -1094,7 +1094,7 @@
1094
1094
  await Promise.all(this.items.map(t => t.refresh()));
1095
1095
  }
1096
1096
  removeEventListener(type, listener) {
1097
- this._eventDispatcher.removeEventListener(type, listener);
1097
+ this.#eventDispatcher.removeEventListener(type, listener);
1098
1098
  }
1099
1099
  }
1100
1100
 
@@ -1865,43 +1865,6 @@
1865
1865
  }
1866
1866
  }
1867
1867
 
1868
- class OpacityAnimation extends RangedAnimationOptions {
1869
- destroy;
1870
- constructor() {
1871
- super();
1872
- this.destroy = DestroyType.none;
1873
- this.speed = 2;
1874
- }
1875
- load(data) {
1876
- super.load(data);
1877
- if (isNull(data)) {
1878
- return;
1879
- }
1880
- if (data.destroy !== undefined) {
1881
- this.destroy = data.destroy;
1882
- }
1883
- }
1884
- }
1885
-
1886
- class Opacity extends RangedAnimationValueWithRandom {
1887
- animation;
1888
- constructor() {
1889
- super();
1890
- this.animation = new OpacityAnimation();
1891
- this.value = 1;
1892
- }
1893
- load(data) {
1894
- if (isNull(data)) {
1895
- return;
1896
- }
1897
- super.load(data);
1898
- const animation = data.animation;
1899
- if (animation !== undefined) {
1900
- this.animation.load(animation);
1901
- }
1902
- }
1903
- }
1904
-
1905
1868
  class Stroke {
1906
1869
  color;
1907
1870
  opacity;
@@ -2069,43 +2032,6 @@
2069
2032
  }
2070
2033
  }
2071
2034
 
2072
- class SizeAnimation extends RangedAnimationOptions {
2073
- destroy;
2074
- constructor() {
2075
- super();
2076
- this.destroy = DestroyType.none;
2077
- this.speed = 5;
2078
- }
2079
- load(data) {
2080
- super.load(data);
2081
- if (isNull(data)) {
2082
- return;
2083
- }
2084
- if (data.destroy !== undefined) {
2085
- this.destroy = data.destroy;
2086
- }
2087
- }
2088
- }
2089
-
2090
- class Size extends RangedAnimationValueWithRandom {
2091
- animation;
2092
- constructor() {
2093
- super();
2094
- this.animation = new SizeAnimation();
2095
- this.value = 3;
2096
- }
2097
- load(data) {
2098
- super.load(data);
2099
- if (isNull(data)) {
2100
- return;
2101
- }
2102
- const animation = data.animation;
2103
- if (animation !== undefined) {
2104
- this.animation.load(animation);
2105
- }
2106
- }
2107
- }
2108
-
2109
2035
  class ZIndex extends ValueWithRandom {
2110
2036
  opacityRate;
2111
2037
  sizeRate;
@@ -2139,24 +2065,21 @@
2139
2065
  groups;
2140
2066
  move;
2141
2067
  number;
2142
- opacity;
2143
2068
  paint;
2144
2069
  palette;
2145
2070
  reduceDuplicates;
2146
2071
  shape;
2147
- size;
2148
2072
  zIndex;
2149
- _container;
2150
- _pluginManager;
2073
+ #container;
2074
+ #pluginManager;
2151
2075
  constructor(pluginManager, container) {
2152
- this._pluginManager = pluginManager;
2153
- this._container = container;
2076
+ this.#pluginManager = pluginManager;
2077
+ this.#container = container;
2154
2078
  this.bounce = new ParticlesBounce();
2155
2079
  this.effect = new Effect();
2156
2080
  this.groups = {};
2157
2081
  this.move = new Move();
2158
2082
  this.number = new ParticlesNumber();
2159
- this.opacity = new Opacity();
2160
2083
  this.paint = new Paint();
2161
2084
  this.paint.color = new AnimatableColor();
2162
2085
  this.paint.color.value = "#fff";
@@ -2164,7 +2087,6 @@
2164
2087
  this.paint.fill.enable = true;
2165
2088
  this.reduceDuplicates = false;
2166
2089
  this.shape = new Shape();
2167
- this.size = new Size();
2168
2090
  this.zIndex = new ZIndex();
2169
2091
  }
2170
2092
  load(data) {
@@ -2173,7 +2095,7 @@
2173
2095
  }
2174
2096
  if (data.palette) {
2175
2097
  this.palette = data.palette;
2176
- this._importPalette(this.palette);
2098
+ this.#importPalette(this.palette);
2177
2099
  }
2178
2100
  if (data.groups !== undefined) {
2179
2101
  for (const group of Object.keys(data.groups)) {
@@ -2193,7 +2115,6 @@
2193
2115
  this.effect.load(data.effect);
2194
2116
  this.move.load(data.move);
2195
2117
  this.number.load(data.number);
2196
- this.opacity.load(data.opacity);
2197
2118
  const paintToLoad = data.paint;
2198
2119
  if (paintToLoad) {
2199
2120
  if (isArray(paintToLoad)) {
@@ -2212,15 +2133,14 @@
2212
2133
  }
2213
2134
  }
2214
2135
  this.shape.load(data.shape);
2215
- this.size.load(data.size);
2216
2136
  this.zIndex.load(data.zIndex);
2217
- if (this._container) {
2218
- for (const plugin of this._pluginManager.plugins) {
2137
+ if (this.#container) {
2138
+ for (const plugin of this.#pluginManager.plugins) {
2219
2139
  if (plugin.loadParticlesOptions) {
2220
- plugin.loadParticlesOptions(this._container, this, data);
2140
+ plugin.loadParticlesOptions(this.#container, this, data);
2221
2141
  }
2222
2142
  }
2223
- const updaters = this._pluginManager.updaters.get(this._container);
2143
+ const updaters = this.#pluginManager.updaters.get(this.#container);
2224
2144
  if (updaters) {
2225
2145
  for (const updater of updaters) {
2226
2146
  if (updater.loadOptions) {
@@ -2230,8 +2150,8 @@
2230
2150
  }
2231
2151
  }
2232
2152
  }
2233
- _importPalette = (palette) => {
2234
- const paletteData = this._pluginManager.getPalette(palette);
2153
+ #importPalette = (palette) => {
2154
+ const paletteData = this.#pluginManager.getPalette(palette);
2235
2155
  if (!paletteData) {
2236
2156
  return;
2237
2157
  }
@@ -2310,11 +2230,11 @@
2310
2230
  smooth;
2311
2231
  style;
2312
2232
  zLayers;
2313
- _container;
2314
- _pluginManager;
2233
+ #container;
2234
+ #pluginManager;
2315
2235
  constructor(pluginManager, container) {
2316
- this._pluginManager = pluginManager;
2317
- this._container = container;
2236
+ this.#pluginManager = pluginManager;
2237
+ this.#container = container;
2318
2238
  this.autoPlay = true;
2319
2239
  this.background = new Background();
2320
2240
  this.clear = true;
@@ -2325,7 +2245,7 @@
2325
2245
  this.duration = 0;
2326
2246
  this.fpsLimit = 120;
2327
2247
  this.hdr = true;
2328
- this.particles = loadParticlesOptions(this._pluginManager, this._container);
2248
+ this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2329
2249
  this.pauseOnBlur = true;
2330
2250
  this.pauseOnOutsideViewport = true;
2331
2251
  this.resize = new ResizeEvent();
@@ -2340,12 +2260,12 @@
2340
2260
  if (data.preset !== undefined) {
2341
2261
  this.preset = data.preset;
2342
2262
  executeOnSingleOrMultiple(this.preset, preset => {
2343
- this._importPreset(preset);
2263
+ this.#importPreset(preset);
2344
2264
  });
2345
2265
  }
2346
2266
  if (data.palette !== undefined) {
2347
2267
  this.palette = data.palette;
2348
- this._importPalette(this.palette);
2268
+ this.#importPalette(this.palette);
2349
2269
  }
2350
2270
  if (data.autoPlay !== undefined) {
2351
2271
  this.autoPlay = data.autoPlay;
@@ -2399,12 +2319,12 @@
2399
2319
  if (data.smooth !== undefined) {
2400
2320
  this.smooth = data.smooth;
2401
2321
  }
2402
- this._pluginManager.plugins.forEach(plugin => {
2403
- plugin.loadOptions(this._container, this, data);
2322
+ this.#pluginManager.plugins.forEach(plugin => {
2323
+ plugin.loadOptions(this.#container, this, data);
2404
2324
  });
2405
2325
  }
2406
- _importPalette = palette => {
2407
- const paletteData = this._pluginManager.getPalette(palette);
2326
+ #importPalette = palette => {
2327
+ const paletteData = this.#pluginManager.getPalette(palette);
2408
2328
  if (!paletteData) {
2409
2329
  return;
2410
2330
  }
@@ -2421,8 +2341,8 @@
2421
2341
  },
2422
2342
  });
2423
2343
  };
2424
- _importPreset = preset => {
2425
- this.load(this._pluginManager.getPreset(preset));
2344
+ #importPreset = preset => {
2345
+ this.load(this.#pluginManager.getPreset(preset));
2426
2346
  };
2427
2347
  }
2428
2348
 
@@ -2891,7 +2811,7 @@
2891
2811
  }
2892
2812
 
2893
2813
  async function loadBlendPlugin(engine) {
2894
- engine.checkVersion("4.0.4");
2814
+ engine.checkVersion("4.1.0");
2895
2815
  await engine.pluginManager.register(e => {
2896
2816
  e.pluginManager.addPlugin(new BlendPlugin());
2897
2817
  });
@@ -2928,7 +2848,7 @@
2928
2848
  }
2929
2849
 
2930
2850
  async function loadCircleShape(engine) {
2931
- engine.checkVersion("4.0.4");
2851
+ engine.checkVersion("4.1.0");
2932
2852
  await engine.pluginManager.register(e => {
2933
2853
  e.pluginManager.addShape(["circle"], () => {
2934
2854
  return Promise.resolve(new CircleDrawer());
@@ -2949,15 +2869,15 @@
2949
2869
  return input.startsWith("#");
2950
2870
  }
2951
2871
  handleColor(color) {
2952
- return this._parseString(color.value);
2872
+ return this.#parseString(color.value);
2953
2873
  }
2954
2874
  handleRangeColor(color) {
2955
- return this._parseString(color.value);
2875
+ return this.#parseString(color.value);
2956
2876
  }
2957
2877
  parseString(input) {
2958
- return this._parseString(input);
2878
+ return this.#parseString(input);
2959
2879
  }
2960
- _parseString(hexColor) {
2880
+ #parseString(hexColor) {
2961
2881
  if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
2962
2882
  return;
2963
2883
  }
@@ -2976,7 +2896,7 @@
2976
2896
  }
2977
2897
 
2978
2898
  async function loadHexColorPlugin(engine) {
2979
- engine.checkVersion("4.0.4");
2899
+ engine.checkVersion("4.1.0");
2980
2900
  await engine.pluginManager.register(e => {
2981
2901
  e.pluginManager.addColorManager("hex", new HexColorManager());
2982
2902
  });
@@ -3029,7 +2949,7 @@
3029
2949
  }
3030
2950
 
3031
2951
  async function loadHslColorPlugin(engine) {
3032
- engine.checkVersion("4.0.4");
2952
+ engine.checkVersion("4.1.0");
3033
2953
  await engine.pluginManager.register(e => {
3034
2954
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3035
2955
  });
@@ -3037,13 +2957,13 @@
3037
2957
 
3038
2958
  class MovePlugin {
3039
2959
  id = "move";
3040
- _pluginManager;
2960
+ #pluginManager;
3041
2961
  constructor(pluginManager) {
3042
- this._pluginManager = pluginManager;
2962
+ this.#pluginManager = pluginManager;
3043
2963
  }
3044
2964
  async getPlugin(container) {
3045
2965
  const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
3046
- return new MovePluginInstance(this._pluginManager, container);
2966
+ return new MovePluginInstance(this.#pluginManager, container);
3047
2967
  }
3048
2968
  loadOptions() {
3049
2969
  }
@@ -3053,7 +2973,7 @@
3053
2973
  }
3054
2974
 
3055
2975
  async function loadMovePlugin(engine) {
3056
- engine.checkVersion("4.0.4");
2976
+ engine.checkVersion("4.1.0");
3057
2977
  await engine.pluginManager.register(e => {
3058
2978
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3059
2979
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3071,18 +2991,58 @@
3071
2991
  });
3072
2992
  }
3073
2993
 
2994
+ class OpacityAnimation extends RangedAnimationOptions {
2995
+ destroy;
2996
+ constructor() {
2997
+ super();
2998
+ this.destroy = DestroyType.none;
2999
+ this.speed = 2;
3000
+ }
3001
+ load(data) {
3002
+ super.load(data);
3003
+ if (isNull(data)) {
3004
+ return;
3005
+ }
3006
+ if (data.destroy !== undefined) {
3007
+ this.destroy = data.destroy;
3008
+ }
3009
+ }
3010
+ }
3011
+
3012
+ class Opacity extends RangedAnimationValueWithRandom {
3013
+ animation;
3014
+ constructor() {
3015
+ super();
3016
+ this.animation = new OpacityAnimation();
3017
+ this.value = 1;
3018
+ }
3019
+ load(data) {
3020
+ if (isNull(data)) {
3021
+ return;
3022
+ }
3023
+ super.load(data);
3024
+ const animation = data.animation;
3025
+ if (animation !== undefined) {
3026
+ this.animation.load(animation);
3027
+ }
3028
+ }
3029
+ }
3030
+
3074
3031
  class OpacityUpdater {
3075
- container;
3032
+ #container;
3076
3033
  constructor(container) {
3077
- this.container = container;
3034
+ this.#container = container;
3078
3035
  }
3079
3036
  init(particle) {
3080
3037
  const opacityOptions = particle.options.opacity, pxRatio = 1;
3038
+ if (!opacityOptions) {
3039
+ return;
3040
+ }
3081
3041
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
3082
3042
  const opacityAnimation = opacityOptions.animation;
3083
3043
  if (opacityAnimation.enable) {
3084
3044
  particle.opacity.velocity =
3085
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
3045
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
3086
3046
  if (!opacityAnimation.sync) {
3087
3047
  particle.opacity.velocity *= getRandom();
3088
3048
  }
@@ -3098,6 +3058,12 @@
3098
3058
  ((particle.opacity.maxLoops ?? none) > none &&
3099
3059
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3100
3060
  }
3061
+ loadOptions(options, ...sources) {
3062
+ options.opacity ??= new Opacity();
3063
+ for (const source of sources) {
3064
+ options.opacity.load(source?.opacity);
3065
+ }
3066
+ }
3101
3067
  reset(particle) {
3102
3068
  if (!particle.opacity) {
3103
3069
  return;
@@ -3106,7 +3072,7 @@
3106
3072
  particle.opacity.loops = 0;
3107
3073
  }
3108
3074
  update(particle, delta) {
3109
- if (!this.isEnabled(particle) || !particle.opacity) {
3075
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
3110
3076
  return;
3111
3077
  }
3112
3078
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -3114,7 +3080,7 @@
3114
3080
  }
3115
3081
 
3116
3082
  async function loadOpacityUpdater(engine) {
3117
- engine.checkVersion("4.0.4");
3083
+ engine.checkVersion("4.1.0");
3118
3084
  await engine.pluginManager.register(e => {
3119
3085
  e.pluginManager.addParticleUpdater("opacity", container => {
3120
3086
  return Promise.resolve(new OpacityUpdater(container));
@@ -3136,10 +3102,9 @@
3136
3102
  }
3137
3103
  const velocity = data.particle.velocity.x;
3138
3104
  let bounced = false;
3139
- if ((data.direction === OutModeDirection.right &&
3140
- data.bounds.right >= data.canvasSize.width &&
3141
- velocity > minVelocity$4) ||
3142
- (data.direction === OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity$4)) {
3105
+ if (data.outOfCanvas &&
3106
+ ((data.direction === OutModeDirection.right && velocity > minVelocity$4) ||
3107
+ (data.direction === OutModeDirection.left && velocity < minVelocity$4))) {
3143
3108
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3144
3109
  data.particle.velocity.x *= -newVelocity;
3145
3110
  bounced = true;
@@ -3148,10 +3113,10 @@
3148
3113
  return;
3149
3114
  }
3150
3115
  const minPos = data.offset.x + data.size;
3151
- if (data.bounds.right >= data.canvasSize.width && data.direction === OutModeDirection.right) {
3116
+ if (data.outOfCanvas && data.direction === OutModeDirection.right) {
3152
3117
  data.particle.position.x = data.canvasSize.width - minPos;
3153
3118
  }
3154
- else if (data.bounds.left <= boundsMin && data.direction === OutModeDirection.left) {
3119
+ else if (data.outOfCanvas && data.direction === OutModeDirection.left) {
3155
3120
  data.particle.position.x = minPos;
3156
3121
  }
3157
3122
  if (data.outMode === OutMode.split) {
@@ -3171,10 +3136,9 @@
3171
3136
  }
3172
3137
  const velocity = data.particle.velocity.y;
3173
3138
  let bounced = false;
3174
- if ((data.direction === OutModeDirection.bottom &&
3175
- data.bounds.bottom >= data.canvasSize.height &&
3176
- velocity > minVelocity$4) ||
3177
- (data.direction === OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity$4)) {
3139
+ if (data.outOfCanvas &&
3140
+ ((data.direction === OutModeDirection.bottom && velocity > minVelocity$4) ||
3141
+ (data.direction === OutModeDirection.top && velocity < minVelocity$4))) {
3178
3142
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3179
3143
  data.particle.velocity.y *= -newVelocity;
3180
3144
  bounced = true;
@@ -3183,10 +3147,10 @@
3183
3147
  return;
3184
3148
  }
3185
3149
  const minPos = data.offset.y + data.size;
3186
- if (data.bounds.bottom >= data.canvasSize.height && data.direction === OutModeDirection.bottom) {
3150
+ if (data.outOfCanvas && data.direction === OutModeDirection.bottom) {
3187
3151
  data.particle.position.y = data.canvasSize.height - minPos;
3188
3152
  }
3189
- else if (data.bounds.top <= boundsMin && data.direction === OutModeDirection.top) {
3153
+ else if (data.outOfCanvas && data.direction === OutModeDirection.top) {
3190
3154
  data.particle.position.y = minPos;
3191
3155
  }
3192
3156
  if (data.outMode === OutMode.split) {
@@ -3195,24 +3159,24 @@
3195
3159
  }
3196
3160
 
3197
3161
  class BounceOutMode {
3198
- container;
3199
3162
  modes;
3200
- _particleBouncePlugins;
3163
+ #container;
3164
+ #particleBouncePlugins;
3201
3165
  constructor(container) {
3202
- this.container = container;
3166
+ this.#container = container;
3203
3167
  this.modes = [
3204
3168
  OutMode.bounce,
3205
3169
  OutMode.split,
3206
3170
  ];
3207
- this._particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3171
+ this.#particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3208
3172
  }
3209
3173
  update(particle, direction, delta, outMode) {
3210
3174
  if (!this.modes.includes(outMode)) {
3211
3175
  return;
3212
3176
  }
3213
- const container = this.container;
3177
+ const container = this.#container;
3214
3178
  let handled = false;
3215
- for (const plugin of this._particleBouncePlugins) {
3179
+ for (const plugin of this.#particleBouncePlugins) {
3216
3180
  handled = plugin.particleBounce?.(particle, delta, direction) ?? false;
3217
3181
  if (handled) {
3218
3182
  break;
@@ -3221,29 +3185,26 @@
3221
3185
  if (handled) {
3222
3186
  return;
3223
3187
  }
3224
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size;
3225
- bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
3226
- bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
3188
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, outOfCanvas = !particle.isInsideCanvasForOutMode(outMode, direction);
3189
+ bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3190
+ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3227
3191
  }
3228
3192
  }
3229
3193
 
3230
3194
  const minVelocity$3 = 0;
3231
3195
  class DestroyOutMode {
3232
- container;
3233
3196
  modes;
3234
- constructor(container) {
3235
- this.container = container;
3197
+ constructor(_container) {
3236
3198
  this.modes = [OutMode.destroy];
3237
3199
  }
3238
3200
  update(particle, direction, _delta, outMode) {
3239
3201
  if (!this.modes.includes(outMode)) {
3240
3202
  return;
3241
3203
  }
3242
- const container = this.container;
3243
3204
  switch (particle.outType) {
3244
3205
  case ParticleOutType.normal:
3245
3206
  case ParticleOutType.outside:
3246
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3207
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3247
3208
  return;
3248
3209
  }
3249
3210
  break;
@@ -3264,10 +3225,10 @@
3264
3225
 
3265
3226
  const minVelocity$2 = 0;
3266
3227
  class NoneOutMode {
3267
- container;
3268
3228
  modes;
3229
+ #container;
3269
3230
  constructor(container) {
3270
- this.container = container;
3231
+ this.#container = container;
3271
3232
  this.modes = [OutMode.none];
3272
3233
  }
3273
3234
  update(particle, direction, _delta, outMode) {
@@ -3280,7 +3241,7 @@
3280
3241
  (direction === OutModeDirection.top || direction === OutModeDirection.bottom))) {
3281
3242
  return;
3282
3243
  }
3283
- const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3244
+ const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3284
3245
  if (!gravityOptions.enable) {
3285
3246
  if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3286
3247
  (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
@@ -3306,17 +3267,17 @@
3306
3267
 
3307
3268
  const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
3308
3269
  class OutOutMode {
3309
- container;
3310
3270
  modes;
3271
+ #container;
3311
3272
  constructor(container) {
3312
- this.container = container;
3273
+ this.#container = container;
3313
3274
  this.modes = [OutMode.out];
3314
3275
  }
3315
3276
  update(particle, direction, _delta, outMode) {
3316
3277
  if (!this.modes.includes(outMode)) {
3317
3278
  return;
3318
3279
  }
3319
- const container = this.container;
3280
+ const container = this.#container;
3320
3281
  switch (particle.outType) {
3321
3282
  case ParticleOutType.inside: {
3322
3283
  const { x: vx, y: vy } = particle.velocity;
@@ -3346,7 +3307,7 @@
3346
3307
  break;
3347
3308
  }
3348
3309
  default: {
3349
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3310
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3350
3311
  return;
3351
3312
  }
3352
3313
  switch (particle.outType) {
@@ -3430,16 +3391,16 @@
3430
3391
  };
3431
3392
  class OutOfCanvasUpdater {
3432
3393
  updaters;
3433
- container;
3394
+ #container;
3434
3395
  constructor(container) {
3435
- this.container = container;
3396
+ this.#container = container;
3436
3397
  this.updaters = new Map();
3437
3398
  }
3438
3399
  init(particle) {
3439
- this._addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3440
- this._addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3441
- this._addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3442
- this._addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3400
+ this.#addUpdaterIfMissing(particle, OutMode.bounce, container => new BounceOutMode(container));
3401
+ this.#addUpdaterIfMissing(particle, OutMode.out, container => new OutOutMode(container));
3402
+ this.#addUpdaterIfMissing(particle, OutMode.destroy, container => new DestroyOutMode(container));
3403
+ this.#addUpdaterIfMissing(particle, OutMode.none, container => new NoneOutMode(container));
3443
3404
  }
3444
3405
  isEnabled(particle) {
3445
3406
  return !particle.destroyed && !particle.spawning;
@@ -3447,18 +3408,18 @@
3447
3408
  update(particle, delta) {
3448
3409
  const outModes = particle.options.move.outModes;
3449
3410
  particle.justWarped = false;
3450
- this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3451
- this._updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3452
- this._updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3453
- this._updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3411
+ this.#updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
3412
+ this.#updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
3413
+ this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
3414
+ this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
3454
3415
  }
3455
- _addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3416
+ #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3456
3417
  const outModes = particle.options.move.outModes;
3457
3418
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3458
- this.updaters.set(outMode, getUpdater(this.container));
3419
+ this.updaters.set(outMode, getUpdater(this.#container));
3459
3420
  }
3460
3421
  };
3461
- _updateOutMode = (particle, delta, outMode, direction) => {
3422
+ #updateOutMode = (particle, delta, outMode, direction) => {
3462
3423
  for (const updater of this.updaters.values()) {
3463
3424
  updater.update(particle, direction, delta, outMode);
3464
3425
  }
@@ -3466,7 +3427,7 @@
3466
3427
  }
3467
3428
 
3468
3429
  async function loadOutModesUpdater(engine) {
3469
- engine.checkVersion("4.0.4");
3430
+ engine.checkVersion("4.1.0");
3470
3431
  await engine.pluginManager.register(e => {
3471
3432
  e.pluginManager.addParticleUpdater("outModes", container => {
3472
3433
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3476,20 +3437,20 @@
3476
3437
 
3477
3438
  const defaultOpacity = 1;
3478
3439
  class PaintUpdater {
3479
- _container;
3480
- _pluginManager;
3440
+ #container;
3441
+ #pluginManager;
3481
3442
  constructor(pluginManager, container) {
3482
- this._container = container;
3483
- this._pluginManager = pluginManager;
3443
+ this.#container = container;
3444
+ this.#pluginManager = pluginManager;
3484
3445
  }
3485
3446
  init(particle) {
3486
- 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;
3447
+ 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;
3487
3448
  if (fill) {
3488
3449
  const fillColor = AnimatableColor.create(paintColor === undefined ? undefined : AnimatableColor.create(undefined, paintColor), fill.color);
3489
3450
  particle.fillEnabled = fill.enable;
3490
3451
  particle.fillOpacity = getRangeValue(fill.opacity);
3491
3452
  particle.fillAnimation = fillColor.animation;
3492
- const fillHslColor = rangeColorToHsl(this._pluginManager, fillColor);
3453
+ const fillHslColor = rangeColorToHsl(this.#pluginManager, fillColor);
3493
3454
  if (fillHslColor) {
3494
3455
  particle.fillColor = getHslAnimationFromHsl(fillHslColor, particle.fillAnimation, container.retina.reduceFactor);
3495
3456
  }
@@ -3505,7 +3466,7 @@
3505
3466
  particle.strokeWidth = getRangeValue(stroke.width) * container.retina.pixelRatio;
3506
3467
  particle.strokeOpacity = getRangeValue(stroke.opacity ?? defaultOpacity);
3507
3468
  particle.strokeAnimation = strokeColor.animation;
3508
- const strokeHslColor = rangeColorToHsl(this._pluginManager, strokeColor) ?? particle.getFillColor();
3469
+ const strokeHslColor = rangeColorToHsl(this.#pluginManager, strokeColor) ?? particle.getFillColor();
3509
3470
  if (strokeHslColor) {
3510
3471
  particle.strokeColor = getHslAnimationFromHsl(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
3511
3472
  }
@@ -3537,7 +3498,7 @@
3537
3498
  }
3538
3499
 
3539
3500
  async function loadPaintUpdater(engine) {
3540
- engine.checkVersion("4.0.4");
3501
+ engine.checkVersion("4.1.0");
3541
3502
  await engine.pluginManager.register(e => {
3542
3503
  e.pluginManager.addParticleUpdater("paint", container => {
3543
3504
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3592,27 +3553,69 @@
3592
3553
  }
3593
3554
 
3594
3555
  async function loadRgbColorPlugin(engine) {
3595
- engine.checkVersion("4.0.4");
3556
+ engine.checkVersion("4.1.0");
3596
3557
  await engine.pluginManager.register(e => {
3597
3558
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3598
3559
  });
3599
3560
  }
3600
3561
 
3562
+ class SizeAnimation extends RangedAnimationOptions {
3563
+ destroy;
3564
+ constructor() {
3565
+ super();
3566
+ this.destroy = DestroyType.none;
3567
+ this.speed = 5;
3568
+ }
3569
+ load(data) {
3570
+ super.load(data);
3571
+ if (isNull(data)) {
3572
+ return;
3573
+ }
3574
+ if (data.destroy !== undefined) {
3575
+ this.destroy = data.destroy;
3576
+ }
3577
+ }
3578
+ }
3579
+
3580
+ class Size extends RangedAnimationValueWithRandom {
3581
+ animation;
3582
+ constructor() {
3583
+ super();
3584
+ this.animation = new SizeAnimation();
3585
+ this.value = 3;
3586
+ }
3587
+ load(data) {
3588
+ super.load(data);
3589
+ if (isNull(data)) {
3590
+ return;
3591
+ }
3592
+ const animation = data.animation;
3593
+ if (animation !== undefined) {
3594
+ this.animation.load(animation);
3595
+ }
3596
+ }
3597
+ }
3598
+
3601
3599
  const minLoops = 0;
3602
3600
  class SizeUpdater {
3603
- _container;
3601
+ #container;
3604
3602
  constructor(container) {
3605
- this._container = container;
3603
+ this.#container = container;
3606
3604
  }
3607
3605
  init(particle) {
3608
- const container = this._container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
3609
- if (sizeAnimation.enable) {
3610
- particle.size.velocity =
3611
- (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3612
- if (!sizeAnimation.sync) {
3613
- particle.size.velocity *= getRandom();
3614
- }
3606
+ const container = this.#container, sizeOptions = particle.options.size;
3607
+ if (!sizeOptions) {
3608
+ return;
3609
+ }
3610
+ const sizeAnimation = sizeOptions.animation;
3611
+ if (!sizeAnimation.enable) {
3612
+ return;
3613
+ }
3614
+ particle.size.velocity = (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3615
+ if (sizeAnimation.sync) {
3616
+ return;
3615
3617
  }
3618
+ particle.size.velocity *= getRandom();
3616
3619
  }
3617
3620
  isEnabled(particle) {
3618
3621
  return (!particle.destroyed &&
@@ -3622,12 +3625,26 @@
3622
3625
  ((particle.size.maxLoops ?? minLoops) > minLoops &&
3623
3626
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3624
3627
  }
3628
+ loadOptions(options, ...sources) {
3629
+ options.size ??= new Size();
3630
+ for (const source of sources) {
3631
+ options.size.load(source?.size);
3632
+ }
3633
+ }
3634
+ preInit(particle) {
3635
+ const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
3636
+ if (!sizeOptions) {
3637
+ return;
3638
+ }
3639
+ particle.size = initParticleNumericAnimationValue(sizeOptions, pxRatio);
3640
+ particle.retina.sizeAnimationSpeed = getRangeValue(sizeOptions.animation.speed) * pxRatio;
3641
+ }
3625
3642
  reset(particle) {
3626
3643
  particle.size.time = 0;
3627
3644
  particle.size.loops = 0;
3628
3645
  }
3629
3646
  update(particle, delta) {
3630
- if (!this.isEnabled(particle)) {
3647
+ if (!this.isEnabled(particle) || !particle.options.size) {
3631
3648
  return;
3632
3649
  }
3633
3650
  updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
@@ -3635,7 +3652,7 @@
3635
3652
  }
3636
3653
 
3637
3654
  async function loadSizeUpdater(engine) {
3638
- engine.checkVersion("4.0.4");
3655
+ engine.checkVersion("4.1.0");
3639
3656
  await engine.pluginManager.register(e => {
3640
3657
  e.pluginManager.addParticleUpdater("size", container => {
3641
3658
  return Promise.resolve(new SizeUpdater(container));
@@ -3644,7 +3661,7 @@
3644
3661
  }
3645
3662
 
3646
3663
  async function loadBasic(engine) {
3647
- engine.checkVersion("4.0.4");
3664
+ engine.checkVersion("4.1.0");
3648
3665
  await engine.pluginManager.register(async (e) => {
3649
3666
  await Promise.all([
3650
3667
  loadBlendPlugin(e),
@@ -3900,13 +3917,13 @@
3900
3917
 
3901
3918
  class EmittersPlugin {
3902
3919
  id = "emitters";
3903
- _instancesManager;
3920
+ #instancesManager;
3904
3921
  constructor(instancesManager) {
3905
- this._instancesManager = instancesManager;
3922
+ this.#instancesManager = instancesManager;
3906
3923
  }
3907
3924
  async getPlugin(container) {
3908
3925
  const { EmittersPluginInstance } = await Promise.resolve().then(function () { return EmittersPluginInstance$1; });
3909
- return new EmittersPluginInstance(this._instancesManager, container);
3926
+ return new EmittersPluginInstance(this.#instancesManager, container);
3910
3927
  }
3911
3928
  loadOptions(_container, options, source) {
3912
3929
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
@@ -3959,7 +3976,7 @@
3959
3976
  })(EmitterClickMode || (EmitterClickMode = {}));
3960
3977
 
3961
3978
  async function loadEmittersPluginSimple(engine) {
3962
- engine.checkVersion("4.0.4");
3979
+ engine.checkVersion("4.1.0");
3963
3980
  await engine.pluginManager.register(async (e) => {
3964
3981
  const instancesManager = await getEmittersInstancesManager(e);
3965
3982
  await addEmittersShapesManager(e);
@@ -4027,7 +4044,7 @@
4027
4044
  }
4028
4045
 
4029
4046
  async function loadMotionPlugin(engine) {
4030
- engine.checkVersion("4.0.4");
4047
+ engine.checkVersion("4.1.0");
4031
4048
  await engine.pluginManager.register(e => {
4032
4049
  e.pluginManager.addPlugin(new MotionPlugin());
4033
4050
  });
@@ -4151,9 +4168,9 @@
4151
4168
  }
4152
4169
 
4153
4170
  class RollUpdater {
4154
- _pluginManager;
4171
+ #pluginManager;
4155
4172
  constructor(pluginManager) {
4156
- this._pluginManager = pluginManager;
4173
+ this.#pluginManager = pluginManager;
4157
4174
  }
4158
4175
  getTransformValues(particle) {
4159
4176
  const roll = particle.roll?.enable && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
@@ -4163,7 +4180,7 @@
4163
4180
  };
4164
4181
  }
4165
4182
  init(particle) {
4166
- initParticle(this._pluginManager, particle);
4183
+ initParticle(this.#pluginManager, particle);
4167
4184
  }
4168
4185
  isEnabled(particle) {
4169
4186
  const roll = particle.options.roll;
@@ -4184,7 +4201,7 @@
4184
4201
  }
4185
4202
 
4186
4203
  async function loadRollUpdater(engine) {
4187
- engine.checkVersion("4.0.4");
4204
+ engine.checkVersion("4.1.0");
4188
4205
  await engine.pluginManager.register(e => {
4189
4206
  e.pluginManager.addParticleUpdater("roll", () => {
4190
4207
  return Promise.resolve(new RollUpdater(e.pluginManager));
@@ -4250,9 +4267,9 @@
4250
4267
 
4251
4268
  const doublePIDeg = 360;
4252
4269
  class RotateUpdater {
4253
- container;
4270
+ #container;
4254
4271
  constructor(container) {
4255
- this.container = container;
4272
+ this.#container = container;
4256
4273
  }
4257
4274
  init(particle) {
4258
4275
  const rotateOptions = particle.options.rotate;
@@ -4284,7 +4301,7 @@
4284
4301
  if (rotateAnimation.enable) {
4285
4302
  particle.rotate.decay = identity$2 - getRangeValue(rotateAnimation.decay);
4286
4303
  particle.rotate.velocity =
4287
- (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
4304
+ (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.#container.retina.reduceFactor;
4288
4305
  if (!rotateAnimation.sync) {
4289
4306
  particle.rotate.velocity *= getRandom();
4290
4307
  }
@@ -4318,7 +4335,7 @@
4318
4335
  }
4319
4336
 
4320
4337
  async function loadRotateUpdater(engine) {
4321
- engine.checkVersion("4.0.4");
4338
+ engine.checkVersion("4.1.0");
4322
4339
  await engine.pluginManager.register(e => {
4323
4340
  e.pluginManager.addParticleUpdater("rotate", container => {
4324
4341
  return Promise.resolve(new RotateUpdater(container));
@@ -4342,7 +4359,7 @@
4342
4359
  }
4343
4360
 
4344
4361
  async function loadSquareShape(engine) {
4345
- engine.checkVersion("4.0.4");
4362
+ engine.checkVersion("4.1.0");
4346
4363
  await engine.pluginManager.register(e => {
4347
4364
  e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
4348
4365
  });
@@ -4413,9 +4430,9 @@
4413
4430
 
4414
4431
  const maxAngle$1 = 360;
4415
4432
  class TiltUpdater {
4416
- container;
4433
+ #container;
4417
4434
  constructor(container) {
4418
- this.container = container;
4435
+ this.#container = container;
4419
4436
  }
4420
4437
  getTransformValues(particle) {
4421
4438
  const tilt = particle.tilt?.enable && particle.tilt;
@@ -4454,7 +4471,7 @@
4454
4471
  const tiltAnimation = particle.options.tilt?.animation;
4455
4472
  if (tiltAnimation?.enable) {
4456
4473
  particle.tilt.decay = identity$2 - getRangeValue(tiltAnimation.decay);
4457
- particle.tilt.velocity = (getRangeValue(tiltAnimation.speed) / maxAngle$1) * this.container.retina.reduceFactor;
4474
+ particle.tilt.velocity = (getRangeValue(tiltAnimation.speed) / maxAngle$1) * this.#container.retina.reduceFactor;
4458
4475
  if (!tiltAnimation.sync) {
4459
4476
  particle.tilt.velocity *= getRandom();
4460
4477
  }
@@ -4479,7 +4496,7 @@
4479
4496
  }
4480
4497
 
4481
4498
  async function loadTiltUpdater(engine) {
4482
- engine.checkVersion("4.0.4");
4499
+ engine.checkVersion("4.1.0");
4483
4500
  await engine.pluginManager.register(e => {
4484
4501
  e.pluginManager.addParticleUpdater("tilt", container => {
4485
4502
  return Promise.resolve(new TiltUpdater(container));
@@ -4560,9 +4577,9 @@
4560
4577
 
4561
4578
  const maxAngle = 360, moveSpeedFactor$1 = 10, defaultDistance = 0;
4562
4579
  class WobbleUpdater {
4563
- _container;
4580
+ #container;
4564
4581
  constructor(container) {
4565
- this._container = container;
4582
+ this.#container = container;
4566
4583
  }
4567
4584
  init(particle) {
4568
4585
  const wobbleOpt = particle.options.wobble;
@@ -4581,7 +4598,7 @@
4581
4598
  };
4582
4599
  }
4583
4600
  particle.retina.wobbleDistance =
4584
- getRangeValue(wobbleOpt?.distance ?? defaultDistance) * this._container.retina.pixelRatio;
4601
+ getRangeValue(wobbleOpt?.distance ?? defaultDistance) * this.#container.retina.pixelRatio;
4585
4602
  }
4586
4603
  isEnabled(particle) {
4587
4604
  return !particle.destroyed && !particle.spawning && !!particle.options.wobble?.enable;
@@ -4596,12 +4613,12 @@
4596
4613
  if (!this.isEnabled(particle)) {
4597
4614
  return;
4598
4615
  }
4599
- updateWobble(this._container, particle, delta);
4616
+ updateWobble(this.#container, particle, delta);
4600
4617
  }
4601
4618
  }
4602
4619
 
4603
4620
  async function loadWobbleUpdater(engine) {
4604
- engine.checkVersion("4.0.4");
4621
+ engine.checkVersion("4.1.0");
4605
4622
  await engine.pluginManager.register(e => {
4606
4623
  e.pluginManager.addParticleUpdater("wobble", container => {
4607
4624
  return Promise.resolve(new WobbleUpdater(container));
@@ -4771,58 +4788,58 @@
4771
4788
  }
4772
4789
  }
4773
4790
  class RenderManager {
4774
- _canvasClearPlugins;
4775
- _canvasManager;
4776
- _canvasPaintPlugins;
4777
- _clearDrawPlugins;
4778
- _colorPlugins;
4779
- _container;
4780
- _context;
4781
- _contextSettings;
4782
- _drawParticlePlugins;
4783
- _drawParticlesCleanupPlugins;
4784
- _drawParticlesSetupPlugins;
4785
- _drawPlugins;
4786
- _drawSettingsCleanupPlugins;
4787
- _drawSettingsSetupPlugins;
4788
- _pluginManager;
4789
- _postDrawUpdaters;
4790
- _preDrawUpdaters;
4791
- _reusableColorStyles = {};
4792
- _reusablePluginColors = [undefined, undefined];
4793
- _reusableTransform = {};
4791
+ #canvasClearPlugins;
4792
+ #canvasManager;
4793
+ #canvasPaintPlugins;
4794
+ #clearDrawPlugins;
4795
+ #colorPlugins;
4796
+ #container;
4797
+ #context;
4798
+ #contextSettings;
4799
+ #drawParticlePlugins;
4800
+ #drawParticlesCleanupPlugins;
4801
+ #drawParticlesSetupPlugins;
4802
+ #drawPlugins;
4803
+ #drawSettingsCleanupPlugins;
4804
+ #drawSettingsSetupPlugins;
4805
+ #pluginManager;
4806
+ #postDrawUpdaters;
4807
+ #preDrawUpdaters;
4808
+ #reusableColorStyles = {};
4809
+ #reusablePluginColors = [undefined, undefined];
4810
+ #reusableTransform = {};
4794
4811
  constructor(pluginManager, container, canvasManager) {
4795
- this._pluginManager = pluginManager;
4796
- this._container = container;
4797
- this._canvasManager = canvasManager;
4798
- this._context = null;
4799
- this._preDrawUpdaters = [];
4800
- this._postDrawUpdaters = [];
4801
- this._colorPlugins = [];
4802
- this._canvasClearPlugins = [];
4803
- this._canvasPaintPlugins = [];
4804
- this._clearDrawPlugins = [];
4805
- this._drawParticlePlugins = [];
4806
- this._drawParticlesCleanupPlugins = [];
4807
- this._drawParticlesSetupPlugins = [];
4808
- this._drawPlugins = [];
4809
- this._drawSettingsSetupPlugins = [];
4810
- this._drawSettingsCleanupPlugins = [];
4812
+ this.#pluginManager = pluginManager;
4813
+ this.#container = container;
4814
+ this.#canvasManager = canvasManager;
4815
+ this.#context = null;
4816
+ this.#preDrawUpdaters = [];
4817
+ this.#postDrawUpdaters = [];
4818
+ this.#colorPlugins = [];
4819
+ this.#canvasClearPlugins = [];
4820
+ this.#canvasPaintPlugins = [];
4821
+ this.#clearDrawPlugins = [];
4822
+ this.#drawParticlePlugins = [];
4823
+ this.#drawParticlesCleanupPlugins = [];
4824
+ this.#drawParticlesSetupPlugins = [];
4825
+ this.#drawPlugins = [];
4826
+ this.#drawSettingsSetupPlugins = [];
4827
+ this.#drawSettingsCleanupPlugins = [];
4811
4828
  }
4812
4829
  get settings() {
4813
- return this._contextSettings;
4830
+ return this.#contextSettings;
4814
4831
  }
4815
4832
  canvasClear() {
4816
- if (!this._container.actualOptions.clear) {
4833
+ if (!this.#container.actualOptions.clear) {
4817
4834
  return;
4818
4835
  }
4819
4836
  this.draw(ctx => {
4820
- clear(ctx, this._canvasManager.size);
4837
+ clear(ctx, this.#canvasManager.size);
4821
4838
  });
4822
4839
  }
4823
4840
  clear() {
4824
4841
  let pluginHandled = false;
4825
- for (const plugin of this._canvasClearPlugins) {
4842
+ for (const plugin of this.#canvasClearPlugins) {
4826
4843
  pluginHandled = plugin.canvasClear?.() ?? false;
4827
4844
  if (pluginHandled) {
4828
4845
  break;
@@ -4835,21 +4852,21 @@
4835
4852
  }
4836
4853
  destroy() {
4837
4854
  this.stop();
4838
- this._preDrawUpdaters = [];
4839
- this._postDrawUpdaters = [];
4840
- this._colorPlugins = [];
4841
- this._canvasClearPlugins = [];
4842
- this._canvasPaintPlugins = [];
4843
- this._clearDrawPlugins = [];
4844
- this._drawParticlePlugins = [];
4845
- this._drawParticlesCleanupPlugins = [];
4846
- this._drawParticlesSetupPlugins = [];
4847
- this._drawPlugins = [];
4848
- this._drawSettingsSetupPlugins = [];
4849
- this._drawSettingsCleanupPlugins = [];
4855
+ this.#preDrawUpdaters = [];
4856
+ this.#postDrawUpdaters = [];
4857
+ this.#colorPlugins = [];
4858
+ this.#canvasClearPlugins = [];
4859
+ this.#canvasPaintPlugins = [];
4860
+ this.#clearDrawPlugins = [];
4861
+ this.#drawParticlePlugins = [];
4862
+ this.#drawParticlesCleanupPlugins = [];
4863
+ this.#drawParticlesSetupPlugins = [];
4864
+ this.#drawPlugins = [];
4865
+ this.#drawSettingsSetupPlugins = [];
4866
+ this.#drawSettingsCleanupPlugins = [];
4850
4867
  }
4851
4868
  draw(cb) {
4852
- const ctx = this._context;
4869
+ const ctx = this.#context;
4853
4870
  if (!ctx) {
4854
4871
  return;
4855
4872
  }
@@ -4864,21 +4881,21 @@
4864
4881
  return;
4865
4882
  }
4866
4883
  const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
4867
- let [fColor, sColor] = this._getPluginParticleColors(particle);
4884
+ let [fColor, sColor] = this.#getPluginParticleColors(particle);
4868
4885
  fColor ??= pfColor;
4869
4886
  sColor ??= psColor;
4870
4887
  if (!fColor && !sColor) {
4871
4888
  return;
4872
4889
  }
4873
- 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;
4890
+ 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;
4874
4891
  transform.a = transform.b = transform.c = transform.d = undefined;
4875
4892
  colorStyles.fill = fill;
4876
4893
  colorStyles.stroke = stroke;
4877
4894
  this.draw((context) => {
4878
- for (const plugin of this._drawParticlesSetupPlugins) {
4895
+ for (const plugin of this.#drawParticlesSetupPlugins) {
4879
4896
  plugin.drawParticleSetup?.(context, particle, delta);
4880
4897
  }
4881
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4898
+ this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
4882
4899
  drawParticle({
4883
4900
  container,
4884
4901
  context,
@@ -4889,35 +4906,35 @@
4889
4906
  opacity: opacity,
4890
4907
  transform,
4891
4908
  });
4892
- this._applyPostDrawUpdaters(particle);
4893
- for (const plugin of this._drawParticlesCleanupPlugins) {
4909
+ this.#applyPostDrawUpdaters(particle);
4910
+ for (const plugin of this.#drawParticlesCleanupPlugins) {
4894
4911
  plugin.drawParticleCleanup?.(context, particle, delta);
4895
4912
  }
4896
4913
  });
4897
4914
  }
4898
4915
  drawParticlePlugins(particle, delta) {
4899
4916
  this.draw(ctx => {
4900
- for (const plugin of this._drawParticlePlugins) {
4917
+ for (const plugin of this.#drawParticlePlugins) {
4901
4918
  drawParticlePlugin(ctx, plugin, particle, delta);
4902
4919
  }
4903
4920
  });
4904
4921
  }
4905
4922
  drawParticles(delta) {
4906
- const { particles } = this._container;
4923
+ const { particles } = this.#container;
4907
4924
  this.clear();
4908
4925
  particles.update(delta);
4909
4926
  this.draw(ctx => {
4910
- for (const plugin of this._drawSettingsSetupPlugins) {
4927
+ for (const plugin of this.#drawSettingsSetupPlugins) {
4911
4928
  plugin.drawSettingsSetup?.(ctx, delta);
4912
4929
  }
4913
- for (const plugin of this._drawPlugins) {
4930
+ for (const plugin of this.#drawPlugins) {
4914
4931
  plugin.draw?.(ctx, delta);
4915
4932
  }
4916
4933
  particles.drawParticles(delta);
4917
- for (const plugin of this._clearDrawPlugins) {
4934
+ for (const plugin of this.#clearDrawPlugins) {
4918
4935
  plugin.clearDraw?.(ctx, delta);
4919
4936
  }
4920
- for (const plugin of this._drawSettingsCleanupPlugins) {
4937
+ for (const plugin of this.#drawSettingsCleanupPlugins) {
4921
4938
  plugin.drawSettingsCleanup?.(ctx, delta);
4922
4939
  }
4923
4940
  });
@@ -4928,64 +4945,64 @@
4928
4945
  this.paint();
4929
4946
  }
4930
4947
  initPlugins() {
4931
- this._colorPlugins = [];
4932
- this._canvasClearPlugins = [];
4933
- this._canvasPaintPlugins = [];
4934
- this._clearDrawPlugins = [];
4935
- this._drawParticlePlugins = [];
4936
- this._drawParticlesSetupPlugins = [];
4937
- this._drawParticlesCleanupPlugins = [];
4938
- this._drawPlugins = [];
4939
- this._drawSettingsSetupPlugins = [];
4940
- this._drawSettingsCleanupPlugins = [];
4941
- for (const plugin of this._container.plugins) {
4948
+ this.#colorPlugins = [];
4949
+ this.#canvasClearPlugins = [];
4950
+ this.#canvasPaintPlugins = [];
4951
+ this.#clearDrawPlugins = [];
4952
+ this.#drawParticlePlugins = [];
4953
+ this.#drawParticlesSetupPlugins = [];
4954
+ this.#drawParticlesCleanupPlugins = [];
4955
+ this.#drawPlugins = [];
4956
+ this.#drawSettingsSetupPlugins = [];
4957
+ this.#drawSettingsCleanupPlugins = [];
4958
+ for (const plugin of this.#container.plugins) {
4942
4959
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
4943
- this._colorPlugins.push(plugin);
4960
+ this.#colorPlugins.push(plugin);
4944
4961
  }
4945
4962
  if (plugin.canvasClear) {
4946
- this._canvasClearPlugins.push(plugin);
4963
+ this.#canvasClearPlugins.push(plugin);
4947
4964
  }
4948
4965
  if (plugin.canvasPaint) {
4949
- this._canvasPaintPlugins.push(plugin);
4966
+ this.#canvasPaintPlugins.push(plugin);
4950
4967
  }
4951
4968
  if (plugin.drawParticle) {
4952
- this._drawParticlePlugins.push(plugin);
4969
+ this.#drawParticlePlugins.push(plugin);
4953
4970
  }
4954
4971
  if (plugin.drawParticleSetup) {
4955
- this._drawParticlesSetupPlugins.push(plugin);
4972
+ this.#drawParticlesSetupPlugins.push(plugin);
4956
4973
  }
4957
4974
  if (plugin.drawParticleCleanup) {
4958
- this._drawParticlesCleanupPlugins.push(plugin);
4975
+ this.#drawParticlesCleanupPlugins.push(plugin);
4959
4976
  }
4960
4977
  if (plugin.draw) {
4961
- this._drawPlugins.push(plugin);
4978
+ this.#drawPlugins.push(plugin);
4962
4979
  }
4963
4980
  if (plugin.drawSettingsSetup) {
4964
- this._drawSettingsSetupPlugins.push(plugin);
4981
+ this.#drawSettingsSetupPlugins.push(plugin);
4965
4982
  }
4966
4983
  if (plugin.drawSettingsCleanup) {
4967
- this._drawSettingsCleanupPlugins.push(plugin);
4984
+ this.#drawSettingsCleanupPlugins.push(plugin);
4968
4985
  }
4969
4986
  if (plugin.clearDraw) {
4970
- this._clearDrawPlugins.push(plugin);
4987
+ this.#clearDrawPlugins.push(plugin);
4971
4988
  }
4972
4989
  }
4973
4990
  }
4974
4991
  initUpdaters() {
4975
- this._preDrawUpdaters = [];
4976
- this._postDrawUpdaters = [];
4977
- for (const updater of this._container.particleUpdaters) {
4992
+ this.#preDrawUpdaters = [];
4993
+ this.#postDrawUpdaters = [];
4994
+ for (const updater of this.#container.particleUpdaters) {
4978
4995
  if (updater.afterDraw) {
4979
- this._postDrawUpdaters.push(updater);
4996
+ this.#postDrawUpdaters.push(updater);
4980
4997
  }
4981
4998
  if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
4982
- this._preDrawUpdaters.push(updater);
4999
+ this.#preDrawUpdaters.push(updater);
4983
5000
  }
4984
5001
  }
4985
5002
  }
4986
5003
  paint() {
4987
5004
  let handled = false;
4988
- for (const plugin of this._canvasPaintPlugins) {
5005
+ for (const plugin of this.#canvasPaintPlugins) {
4989
5006
  handled = plugin.canvasPaint?.() ?? false;
4990
5007
  if (handled) {
4991
5008
  break;
@@ -4998,35 +5015,35 @@
4998
5015
  }
4999
5016
  paintBase(baseColor) {
5000
5017
  this.draw(ctx => {
5001
- paintBase(ctx, this._canvasManager.size, baseColor);
5018
+ paintBase(ctx, this.#canvasManager.size, baseColor);
5002
5019
  });
5003
5020
  }
5004
5021
  paintImage(image, opacity) {
5005
5022
  this.draw(ctx => {
5006
- paintImage(ctx, this._canvasManager.size, image, opacity);
5023
+ paintImage(ctx, this.#canvasManager.size, image, opacity);
5007
5024
  });
5008
5025
  }
5009
5026
  setContext(context) {
5010
- this._context = context;
5011
- if (this._context) {
5012
- this._context.globalCompositeOperation = defaultCompositeValue;
5027
+ this.#context = context;
5028
+ if (this.#context) {
5029
+ this.#context.globalCompositeOperation = defaultCompositeValue;
5013
5030
  }
5014
5031
  }
5015
5032
  setContextSettings(settings) {
5016
- this._contextSettings = settings;
5033
+ this.#contextSettings = settings;
5017
5034
  }
5018
5035
  stop() {
5019
5036
  this.draw(ctx => {
5020
- clear(ctx, this._canvasManager.size);
5037
+ clear(ctx, this.#canvasManager.size);
5021
5038
  });
5022
5039
  }
5023
- _applyPostDrawUpdaters = particle => {
5024
- for (const updater of this._postDrawUpdaters) {
5040
+ #applyPostDrawUpdaters = particle => {
5041
+ for (const updater of this.#postDrawUpdaters) {
5025
5042
  updater.afterDraw?.(particle);
5026
5043
  }
5027
5044
  };
5028
- _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
5029
- for (const updater of this._preDrawUpdaters) {
5045
+ #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
5046
+ for (const updater of this.#preDrawUpdaters) {
5030
5047
  if (updater.getColorStyles) {
5031
5048
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
5032
5049
  if (fill) {
@@ -5045,22 +5062,22 @@
5045
5062
  updater.beforeDraw?.(particle);
5046
5063
  }
5047
5064
  };
5048
- _getPluginParticleColors = particle => {
5065
+ #getPluginParticleColors = particle => {
5049
5066
  let fColor, sColor;
5050
- for (const plugin of this._colorPlugins) {
5067
+ for (const plugin of this.#colorPlugins) {
5051
5068
  if (!fColor && plugin.particleFillColor) {
5052
- fColor = rangeColorToHsl(this._pluginManager, plugin.particleFillColor(particle));
5069
+ fColor = rangeColorToHsl(this.#pluginManager, plugin.particleFillColor(particle));
5053
5070
  }
5054
5071
  if (!sColor && plugin.particleStrokeColor) {
5055
- sColor = rangeColorToHsl(this._pluginManager, plugin.particleStrokeColor(particle));
5072
+ sColor = rangeColorToHsl(this.#pluginManager, plugin.particleStrokeColor(particle));
5056
5073
  }
5057
5074
  if (fColor && sColor) {
5058
5075
  break;
5059
5076
  }
5060
5077
  }
5061
- this._reusablePluginColors[fColorIndex] = fColor;
5062
- this._reusablePluginColors[sColorIndex] = sColor;
5063
- return this._reusablePluginColors;
5078
+ this.#reusablePluginColors[fColorIndex] = fColor;
5079
+ this.#reusablePluginColors[sColorIndex] = sColor;
5080
+ return this.#reusablePluginColors;
5064
5081
  };
5065
5082
  }
5066
5083
 
@@ -5118,53 +5135,53 @@
5118
5135
  renderCanvas;
5119
5136
  size;
5120
5137
  zoom = defaultZoom;
5121
- _container;
5122
- _generated;
5123
- _mutationObserver;
5124
- _originalStyle;
5125
- _pluginManager;
5126
- _pointerEvents;
5127
- _resizePlugins;
5128
- _standardSize;
5129
- _zoomCenter;
5138
+ #container;
5139
+ #generated;
5140
+ #mutationObserver;
5141
+ #originalStyle;
5142
+ #pluginManager;
5143
+ #pointerEvents;
5144
+ #resizePlugins;
5145
+ #standardSize;
5146
+ #zoomCenter;
5130
5147
  constructor(pluginManager, container) {
5131
- this._pluginManager = pluginManager;
5132
- this._container = container;
5148
+ this.#pluginManager = pluginManager;
5149
+ this.#container = container;
5133
5150
  this.render = new RenderManager(pluginManager, container, this);
5134
- this._standardSize = {
5151
+ this.#standardSize = {
5135
5152
  height: 0,
5136
5153
  width: 0,
5137
5154
  };
5138
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
5155
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
5139
5156
  this.size = {
5140
5157
  height: stdSize.height * pxRatio,
5141
5158
  width: stdSize.width * pxRatio,
5142
5159
  };
5143
- this._generated = false;
5144
- this._resizePlugins = [];
5145
- this._pointerEvents = "none";
5160
+ this.#generated = false;
5161
+ this.#resizePlugins = [];
5162
+ this.#pointerEvents = "none";
5146
5163
  }
5147
- get _fullScreen() {
5148
- return this._container.actualOptions.fullScreen.enable;
5164
+ get #fullScreen() {
5165
+ return this.#container.actualOptions.fullScreen.enable;
5149
5166
  }
5150
5167
  destroy() {
5151
5168
  this.stop();
5152
- if (this._generated) {
5169
+ if (this.#generated) {
5153
5170
  const element = this.domElement;
5154
5171
  element?.remove();
5155
5172
  this.domElement = undefined;
5156
5173
  this.renderCanvas = undefined;
5157
5174
  }
5158
5175
  else {
5159
- this._resetOriginalStyle();
5176
+ this.#resetOriginalStyle();
5160
5177
  }
5161
5178
  this.render.destroy();
5162
- this._resizePlugins = [];
5179
+ this.#resizePlugins = [];
5163
5180
  }
5164
5181
  getZoomCenter() {
5165
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
5166
- if (this._zoomCenter) {
5167
- return this._zoomCenter;
5182
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
5183
+ if (this.#zoomCenter) {
5184
+ return this.#zoomCenter;
5168
5185
  }
5169
5186
  return {
5170
5187
  x: (width * half) / pxRatio,
@@ -5172,20 +5189,20 @@
5172
5189
  };
5173
5190
  }
5174
5191
  init() {
5175
- this._safeMutationObserver(obs => {
5192
+ this.#safeMutationObserver(obs => {
5176
5193
  obs.disconnect();
5177
5194
  });
5178
- this._mutationObserver = safeMutationObserver(records => {
5195
+ this.#mutationObserver = safeMutationObserver(records => {
5179
5196
  for (const record of records) {
5180
5197
  if (record.type === "attributes" && record.attributeName === "style") {
5181
- this._repairStyle();
5198
+ this.#repairStyle();
5182
5199
  }
5183
5200
  }
5184
5201
  });
5185
5202
  this.resize();
5186
- this._initStyle();
5203
+ this.#initStyle();
5187
5204
  this.initBackground();
5188
- this._safeMutationObserver(obs => {
5205
+ this.#safeMutationObserver(obs => {
5189
5206
  const element = this.domElement;
5190
5207
  if (!element || !(element instanceof Node)) {
5191
5208
  return;
@@ -5196,13 +5213,13 @@
5196
5213
  this.render.init();
5197
5214
  }
5198
5215
  initBackground() {
5199
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
5216
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
5200
5217
  if (!element) {
5201
5218
  return;
5202
5219
  }
5203
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
5220
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
5204
5221
  if (color) {
5205
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
5222
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
5206
5223
  }
5207
5224
  else {
5208
5225
  elementStyle.backgroundColor = "";
@@ -5213,27 +5230,27 @@
5213
5230
  elementStyle.backgroundSize = background.size || "";
5214
5231
  }
5215
5232
  initPlugins() {
5216
- this._resizePlugins = [];
5217
- for (const plugin of this._container.plugins) {
5233
+ this.#resizePlugins = [];
5234
+ for (const plugin of this.#container.plugins) {
5218
5235
  if (plugin.resize) {
5219
- this._resizePlugins.push(plugin);
5236
+ this.#resizePlugins.push(plugin);
5220
5237
  }
5221
5238
  }
5222
5239
  }
5223
5240
  loadCanvas(canvas) {
5224
- if (this._generated && this.domElement) {
5241
+ if (this.#generated && this.domElement) {
5225
5242
  this.domElement.remove();
5226
5243
  }
5227
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
5244
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
5228
5245
  this.domElement = domCanvas;
5229
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
5246
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
5230
5247
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
5231
5248
  const domElement = this.domElement;
5232
5249
  if (domElement) {
5233
5250
  domElement.ariaHidden = "true";
5234
- this._originalStyle = cloneStyle(domElement.style);
5251
+ this.#originalStyle = cloneStyle(domElement.style);
5235
5252
  }
5236
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
5253
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
5237
5254
  if (domElement) {
5238
5255
  standardSize.height = domElement.offsetHeight;
5239
5256
  standardSize.width = domElement.offsetWidth;
@@ -5242,7 +5259,7 @@
5242
5259
  standardSize.height = renderCanvas.height;
5243
5260
  standardSize.width = renderCanvas.width;
5244
5261
  }
5245
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
5262
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
5246
5263
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
5247
5264
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
5248
5265
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -5253,12 +5270,12 @@
5253
5270
  willReadFrequently: false,
5254
5271
  });
5255
5272
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
5256
- this._safeMutationObserver(obs => {
5273
+ this.#safeMutationObserver(obs => {
5257
5274
  obs.disconnect();
5258
5275
  });
5259
5276
  container.retina.init();
5260
5277
  this.initBackground();
5261
- this._safeMutationObserver(obs => {
5278
+ this.#safeMutationObserver(obs => {
5262
5279
  const element = this.domElement;
5263
5280
  if (!element || !(element instanceof Node)) {
5264
5281
  return;
@@ -5271,11 +5288,11 @@
5271
5288
  if (!element) {
5272
5289
  return false;
5273
5290
  }
5274
- const container = this._container, renderCanvas = this.renderCanvas;
5291
+ const container = this.#container, renderCanvas = this.renderCanvas;
5275
5292
  if (renderCanvas === undefined) {
5276
5293
  return false;
5277
5294
  }
5278
- const currentSize = container.canvas._standardSize, newSize = {
5295
+ const currentSize = container.canvas.#standardSize, newSize = {
5279
5296
  width: element.offsetWidth,
5280
5297
  height: element.offsetHeight,
5281
5298
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -5294,7 +5311,7 @@
5294
5311
  const canvasSize = this.size;
5295
5312
  renderCanvas.width = canvasSize.width = retinaSize.width;
5296
5313
  renderCanvas.height = canvasSize.height = retinaSize.height;
5297
- if (this._container.started) {
5314
+ if (this.#container.started) {
5298
5315
  container.particles.setResizeFactor({
5299
5316
  width: currentSize.width / oldSize.width,
5300
5317
  height: currentSize.height / oldSize.height,
@@ -5307,46 +5324,46 @@
5307
5324
  if (!element) {
5308
5325
  return;
5309
5326
  }
5310
- this._pointerEvents = type;
5311
- this._repairStyle();
5327
+ this.#pointerEvents = type;
5328
+ this.#repairStyle();
5312
5329
  }
5313
5330
  setZoom(zoomLevel, center) {
5314
5331
  this.zoom = zoomLevel;
5315
- this._zoomCenter = center;
5332
+ this.#zoomCenter = center;
5316
5333
  }
5317
5334
  stop() {
5318
- this._safeMutationObserver(obs => {
5335
+ this.#safeMutationObserver(obs => {
5319
5336
  obs.disconnect();
5320
5337
  });
5321
- this._mutationObserver = undefined;
5338
+ this.#mutationObserver = undefined;
5322
5339
  this.render.stop();
5323
5340
  }
5324
5341
  async windowResize() {
5325
5342
  if (!this.domElement || !this.resize()) {
5326
5343
  return;
5327
5344
  }
5328
- const container = this._container, needsRefresh = container.updateActualOptions();
5345
+ const container = this.#container, needsRefresh = container.updateActualOptions();
5329
5346
  container.particles.setDensity();
5330
- this._applyResizePlugins();
5347
+ this.#applyResizePlugins();
5331
5348
  if (needsRefresh) {
5332
5349
  await container.refresh();
5333
5350
  }
5334
5351
  }
5335
- _applyResizePlugins = () => {
5336
- for (const plugin of this._resizePlugins) {
5352
+ #applyResizePlugins = () => {
5353
+ for (const plugin of this.#resizePlugins) {
5337
5354
  plugin.resize?.();
5338
5355
  }
5339
5356
  };
5340
- _initStyle = () => {
5341
- const element = this.domElement, options = this._container.actualOptions;
5357
+ #initStyle = () => {
5358
+ const element = this.domElement, options = this.#container.actualOptions;
5342
5359
  if (!element) {
5343
5360
  return;
5344
5361
  }
5345
- if (this._fullScreen) {
5346
- this._setFullScreenStyle();
5362
+ if (this.#fullScreen) {
5363
+ this.#setFullScreenStyle();
5347
5364
  }
5348
5365
  else {
5349
- this._resetOriginalStyle();
5366
+ this.#resetOriginalStyle();
5350
5367
  }
5351
5368
  for (const key in options.style) {
5352
5369
  if (!key || !(key in options.style)) {
@@ -5359,72 +5376,72 @@
5359
5376
  element.style.setProperty(key, value, "important");
5360
5377
  }
5361
5378
  };
5362
- _repairStyle = () => {
5379
+ #repairStyle = () => {
5363
5380
  const element = this.domElement;
5364
5381
  if (!element) {
5365
5382
  return;
5366
5383
  }
5367
- this._safeMutationObserver(observer => {
5384
+ this.#safeMutationObserver(observer => {
5368
5385
  observer.disconnect();
5369
5386
  });
5370
- this._initStyle();
5387
+ this.#initStyle();
5371
5388
  this.initBackground();
5372
- const pointerEvents = this._pointerEvents;
5389
+ const pointerEvents = this.#pointerEvents;
5373
5390
  element.style.pointerEvents = pointerEvents;
5374
5391
  element.style.setProperty("pointer-events", pointerEvents);
5375
- this._safeMutationObserver(observer => {
5392
+ this.#safeMutationObserver(observer => {
5376
5393
  if (!(element instanceof Node)) {
5377
5394
  return;
5378
5395
  }
5379
5396
  observer.observe(element, { attributes: true });
5380
5397
  });
5381
5398
  };
5382
- _resetOriginalStyle = () => {
5383
- const element = this.domElement, originalStyle = this._originalStyle;
5399
+ #resetOriginalStyle = () => {
5400
+ const element = this.domElement, originalStyle = this.#originalStyle;
5384
5401
  if (!element || !originalStyle) {
5385
5402
  return;
5386
5403
  }
5387
5404
  setStyle(element, originalStyle, true);
5388
5405
  };
5389
- _safeMutationObserver = callback => {
5390
- if (!this._mutationObserver) {
5406
+ #safeMutationObserver = callback => {
5407
+ if (!this.#mutationObserver) {
5391
5408
  return;
5392
5409
  }
5393
- callback(this._mutationObserver);
5410
+ callback(this.#mutationObserver);
5394
5411
  };
5395
- _setFullScreenStyle = () => {
5412
+ #setFullScreenStyle = () => {
5396
5413
  const element = this.domElement;
5397
5414
  if (!element) {
5398
5415
  return;
5399
5416
  }
5400
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
5417
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
5401
5418
  };
5402
5419
  }
5403
5420
 
5404
5421
  class EventListeners {
5405
- container;
5406
- _handlers;
5407
- _resizeObserver;
5408
- _resizeTimeout;
5422
+ #container;
5423
+ #handlers;
5424
+ #resizeObserver;
5425
+ #resizeTimeout;
5409
5426
  constructor(container) {
5410
- this.container = container;
5411
- this._handlers = {
5427
+ this.#container = container;
5428
+ this.#handlers = {
5412
5429
  visibilityChange: () => {
5413
- this._handleVisibilityChange();
5430
+ this.#handleVisibilityChange();
5414
5431
  },
5415
5432
  resize: () => {
5416
- this._handleWindowResize();
5433
+ this.#handleWindowResize();
5417
5434
  },
5418
5435
  };
5419
5436
  }
5420
5437
  addListeners() {
5421
- this._manageListeners(true);
5438
+ this.#manageListeners(true);
5422
5439
  }
5423
5440
  removeListeners() {
5424
- this._manageListeners(false);
5441
+ this.#manageListeners(false);
5425
5442
  }
5426
- _handleVisibilityChange = () => {
5427
- const container = this.container, options = container.actualOptions;
5443
+ #handleVisibilityChange = () => {
5444
+ const container = this.#container, options = container.actualOptions;
5428
5445
  if (!options.pauseOnBlur) {
5429
5446
  return;
5430
5447
  }
@@ -5442,24 +5459,24 @@
5442
5459
  }
5443
5460
  }
5444
5461
  };
5445
- _handleWindowResize = () => {
5446
- if (this._resizeTimeout) {
5447
- clearTimeout(this._resizeTimeout);
5448
- delete this._resizeTimeout;
5462
+ #handleWindowResize = () => {
5463
+ if (this.#resizeTimeout) {
5464
+ clearTimeout(this.#resizeTimeout);
5465
+ this.#resizeTimeout = undefined;
5449
5466
  }
5450
5467
  const handleResize = async () => {
5451
- const canvas = this.container.canvas;
5468
+ const canvas = this.#container.canvas;
5452
5469
  await canvas.windowResize();
5453
5470
  };
5454
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
5471
+ this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
5455
5472
  };
5456
- _manageListeners = add => {
5457
- const handlers = this._handlers;
5458
- this._manageResize(add);
5473
+ #manageListeners = add => {
5474
+ const handlers = this.#handlers;
5475
+ this.#manageResize(add);
5459
5476
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
5460
5477
  };
5461
- _manageResize = add => {
5462
- const handlers = this._handlers, container = this.container, options = container.actualOptions;
5478
+ #manageResize = add => {
5479
+ const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
5463
5480
  if (!options.resize.enable) {
5464
5481
  return;
5465
5482
  }
@@ -5468,22 +5485,22 @@
5468
5485
  return;
5469
5486
  }
5470
5487
  const canvasEl = container.canvas.domElement;
5471
- if (this._resizeObserver && !add) {
5488
+ if (this.#resizeObserver && !add) {
5472
5489
  if (canvasEl) {
5473
- this._resizeObserver.unobserve(canvasEl);
5490
+ this.#resizeObserver.unobserve(canvasEl);
5474
5491
  }
5475
- this._resizeObserver.disconnect();
5476
- delete this._resizeObserver;
5492
+ this.#resizeObserver.disconnect();
5493
+ this.#resizeObserver = undefined;
5477
5494
  }
5478
- else if (!this._resizeObserver && add && canvasEl) {
5479
- this._resizeObserver = new ResizeObserver((entries) => {
5495
+ else if (!this.#resizeObserver && add && canvasEl) {
5496
+ this.#resizeObserver = new ResizeObserver((entries) => {
5480
5497
  const entry = entries.find(e => e.target === canvasEl);
5481
5498
  if (!entry) {
5482
5499
  return;
5483
5500
  }
5484
- this._handleWindowResize();
5501
+ this.#handleWindowResize();
5485
5502
  });
5486
- this._resizeObserver.observe(canvasEl);
5503
+ this.#resizeObserver.observe(canvasEl);
5487
5504
  }
5488
5505
  };
5489
5506
  }
@@ -5556,24 +5573,24 @@
5556
5573
  unbreakable;
5557
5574
  velocity;
5558
5575
  zIndexFactor;
5559
- _cachedOpacityData = {
5576
+ #cachedOpacityData = {
5560
5577
  fillOpacity: defaultOpacity$1,
5561
5578
  opacity: defaultOpacity$1,
5562
5579
  strokeOpacity: defaultOpacity$1,
5563
5580
  };
5564
- _cachedPosition = Vector3d.origin;
5565
- _cachedRotateData = { sin: 0, cos: 0 };
5566
- _cachedTransform = {
5581
+ #cachedPosition = Vector3d.origin;
5582
+ #cachedRotateData = { sin: 0, cos: 0 };
5583
+ #cachedTransform = {
5567
5584
  a: 1,
5568
5585
  b: 0,
5569
5586
  c: 0,
5570
5587
  d: 1,
5571
5588
  };
5572
- _container;
5573
- _pluginManager;
5589
+ #container;
5590
+ #pluginManager;
5574
5591
  constructor(pluginManager, container) {
5575
- this._pluginManager = pluginManager;
5576
- this._container = container;
5592
+ this.#pluginManager = pluginManager;
5593
+ this.#container = container;
5577
5594
  }
5578
5595
  destroy(override) {
5579
5596
  if (this.unbreakable || this.destroyed) {
@@ -5582,7 +5599,7 @@
5582
5599
  this.destroyed = true;
5583
5600
  this.bubble.inRange = false;
5584
5601
  this.slow.inRange = false;
5585
- const container = this._container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
5602
+ const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
5586
5603
  shapeDrawer?.particleDestroy?.(this);
5587
5604
  for (const plugin of container.particleDestroyedPlugins) {
5588
5605
  plugin.particleDestroyed?.(this, override);
@@ -5590,12 +5607,12 @@
5590
5607
  for (const updater of container.particleUpdaters) {
5591
5608
  updater.particleDestroyed?.(this, override);
5592
5609
  }
5593
- this._container.dispatchEvent(EventType.particleDestroyed, {
5610
+ this.#container.dispatchEvent(EventType.particleDestroyed, {
5594
5611
  particle: this,
5595
5612
  });
5596
5613
  }
5597
5614
  draw(delta) {
5598
- const container = this._container, render = container.canvas.render;
5615
+ const container = this.#container, render = container.canvas.render;
5599
5616
  render.drawParticlePlugins(this, delta);
5600
5617
  render.drawParticle(this, delta);
5601
5618
  }
@@ -5603,50 +5620,50 @@
5603
5620
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
5604
5621
  }
5605
5622
  getFillColor() {
5606
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
5623
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
5607
5624
  }
5608
5625
  getMass() {
5609
5626
  return this.getRadius() ** squareExp * Math.PI * half;
5610
5627
  }
5611
5628
  getOpacity() {
5612
5629
  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;
5613
- this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
5614
- this._cachedOpacityData.opacity = opacity * zOpacityFactor;
5615
- this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
5616
- return this._cachedOpacityData;
5630
+ this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
5631
+ this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
5632
+ this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
5633
+ return this.#cachedOpacityData;
5617
5634
  }
5618
5635
  getPosition() {
5619
- this._cachedPosition.x = this.position.x + this.offset.x;
5620
- this._cachedPosition.y = this.position.y + this.offset.y;
5621
- this._cachedPosition.z = this.position.z;
5622
- return this._cachedPosition;
5636
+ this.#cachedPosition.x = this.position.x + this.offset.x;
5637
+ this.#cachedPosition.y = this.position.y + this.offset.y;
5638
+ this.#cachedPosition.z = this.position.z;
5639
+ return this.#cachedPosition;
5623
5640
  }
5624
5641
  getRadius() {
5625
5642
  return this.bubble.radius ?? this.size.value;
5626
5643
  }
5627
5644
  getRotateData() {
5628
5645
  const angle = this.getAngle();
5629
- this._cachedRotateData.sin = Math.sin(angle);
5630
- this._cachedRotateData.cos = Math.cos(angle);
5631
- return this._cachedRotateData;
5646
+ this.#cachedRotateData.sin = Math.sin(angle);
5647
+ this.#cachedRotateData.cos = Math.cos(angle);
5648
+ return this.#cachedRotateData;
5632
5649
  }
5633
5650
  getStrokeColor() {
5634
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
5651
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
5635
5652
  }
5636
5653
  getTransformData(externalTransform) {
5637
5654
  const rotateData = this.getRotateData(), rotating = this.isRotating;
5638
- this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
5639
- this._cachedTransform.b = rotating
5655
+ this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
5656
+ this.#cachedTransform.b = rotating
5640
5657
  ? rotateData.sin * (externalTransform.b ?? identity$2)
5641
5658
  : (externalTransform.b ?? defaultTransform.b);
5642
- this._cachedTransform.c = rotating
5659
+ this.#cachedTransform.c = rotating
5643
5660
  ? -rotateData.sin * (externalTransform.c ?? identity$2)
5644
5661
  : (externalTransform.c ?? defaultTransform.c);
5645
- this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
5646
- return this._cachedTransform;
5662
+ this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
5663
+ return this.#cachedTransform;
5647
5664
  }
5648
5665
  init(id, position, overrideOptions, group) {
5649
- const container = this._container;
5666
+ const container = this.#container;
5650
5667
  this.id = id;
5651
5668
  this.group = group;
5652
5669
  this.justWarped = false;
@@ -5666,21 +5683,27 @@
5666
5683
  moveSpeed: 0,
5667
5684
  sizeAnimationSpeed: 0,
5668
5685
  };
5686
+ this.size = {
5687
+ value: 1,
5688
+ max: 1,
5689
+ min: 1,
5690
+ enable: false,
5691
+ };
5669
5692
  this.outType = ParticleOutType.normal;
5670
5693
  this.ignoresResizeRatio = true;
5671
- 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;
5694
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
5672
5695
  this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
5673
5696
  this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
5674
5697
  const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
5675
5698
  if (overrideOptions) {
5676
- if (overrideOptions.effect?.type) {
5699
+ if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
5677
5700
  const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
5678
5701
  if (effect) {
5679
5702
  this.effect = effect;
5680
5703
  effectOptions.load(overrideOptions.effect);
5681
5704
  }
5682
5705
  }
5683
- if (overrideOptions.shape?.type) {
5706
+ if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
5684
5707
  const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
5685
5708
  if (shape) {
5686
5709
  this.shape = shape;
@@ -5689,21 +5712,20 @@
5689
5712
  }
5690
5713
  }
5691
5714
  if (this.effect === randomColorValue) {
5692
- const availableEffects = [...this._container.effectDrawers.keys()];
5715
+ const availableEffects = [...this.#container.effectDrawers.keys()];
5693
5716
  this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
5694
5717
  }
5695
5718
  if (this.shape === randomColorValue) {
5696
- const availableShapes = [...this._container.shapeDrawers.keys()];
5719
+ const availableShapes = [...this.#container.shapeDrawers.keys()];
5697
5720
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
5698
5721
  }
5699
5722
  this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
5700
5723
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
5701
5724
  particlesOptions.load(overrideOptions);
5702
- const effectData = this.effectData;
5725
+ const effectData = this.effectData, shapeData = this.shapeData;
5703
5726
  if (effectData) {
5704
5727
  particlesOptions.load(effectData.particles);
5705
5728
  }
5706
- const shapeData = this.shapeData;
5707
5729
  if (shapeData) {
5708
5730
  particlesOptions.load(shapeData.particles);
5709
5731
  }
@@ -5711,7 +5733,9 @@
5711
5733
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
5712
5734
  this.options = particlesOptions;
5713
5735
  container.retina.initParticle(this);
5714
- this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
5736
+ for (const updater of container.particleUpdaters) {
5737
+ updater.preInit?.(this);
5738
+ }
5715
5739
  this.bubble = {
5716
5740
  inRange: false,
5717
5741
  };
@@ -5719,8 +5743,8 @@
5719
5743
  inRange: false,
5720
5744
  factor: 1,
5721
5745
  };
5722
- this._initPosition(position);
5723
- this.initialVelocity = this._calculateVelocity();
5746
+ this.#initPosition(position);
5747
+ this.initialVelocity = this.#calculateVelocity();
5724
5748
  this.velocity = this.initialVelocity.copy();
5725
5749
  this.zIndexFactor = this.position.z / container.zLayers;
5726
5750
  this.sides = 24;
@@ -5751,12 +5775,11 @@
5751
5775
  plugin.particleCreated?.(this);
5752
5776
  }
5753
5777
  }
5754
- isInsideCanvas() {
5755
- const radius = this.getRadius(), canvasSize = this._container.canvas.size, position = this.position;
5756
- return (position.x >= -radius &&
5757
- position.y >= -radius &&
5758
- position.y <= canvasSize.height + radius &&
5759
- position.x <= canvasSize.width + radius);
5778
+ isInsideCanvas(direction) {
5779
+ return this.#getInsideCanvasResult({ direction }).inside;
5780
+ }
5781
+ isInsideCanvasForOutMode(outMode, direction) {
5782
+ return this.#getInsideCanvasResult({ direction, outMode }).inside;
5760
5783
  }
5761
5784
  isShowingBack() {
5762
5785
  if (!this.roll) {
@@ -5781,13 +5804,13 @@
5781
5804
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
5782
5805
  }
5783
5806
  reset() {
5784
- for (const updater of this._container.particleUpdaters) {
5807
+ for (const updater of this.#container.particleUpdaters) {
5785
5808
  updater.reset?.(this);
5786
5809
  }
5787
5810
  }
5788
- _calcPosition = (position, zIndex) => {
5811
+ #calcPosition = (position, zIndex) => {
5789
5812
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
5790
- const container = this._container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5813
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
5791
5814
  while (!signal.aborted) {
5792
5815
  for (const plugin of plugins) {
5793
5816
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -5799,10 +5822,10 @@
5799
5822
  size: canvasSize,
5800
5823
  position: posVec,
5801
5824
  }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
5802
- this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
5803
- this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
5804
- this._fixVertical(pos, radius, outModes.top ?? outModes.default);
5805
- this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
5825
+ this.#fixHorizontal(pos, radius, outModes.left ?? outModes.default);
5826
+ this.#fixHorizontal(pos, radius, outModes.right ?? outModes.default);
5827
+ this.#fixVertical(pos, radius, outModes.top ?? outModes.default);
5828
+ this.#fixVertical(pos, radius, outModes.bottom ?? outModes.default);
5806
5829
  let isValidPosition = true;
5807
5830
  for (const plugin of container.particles.checkParticlePositionPlugins) {
5808
5831
  isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
@@ -5818,8 +5841,8 @@
5818
5841
  }
5819
5842
  return posVec;
5820
5843
  };
5821
- _calculateVelocity = () => {
5822
- const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
5844
+ #calculateVelocity = () => {
5845
+ const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
5823
5846
  if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
5824
5847
  return res;
5825
5848
  }
@@ -5835,27 +5858,86 @@
5835
5858
  }
5836
5859
  return res;
5837
5860
  };
5838
- _fixHorizontal = (pos, radius, outMode) => {
5861
+ #fixHorizontal = (pos, radius, outMode) => {
5839
5862
  fixOutMode({
5840
5863
  outMode,
5841
5864
  checkModes: [OutMode.bounce],
5842
5865
  coord: pos.x,
5843
- maxCoord: this._container.canvas.size.width,
5866
+ maxCoord: this.#container.canvas.size.width,
5844
5867
  setCb: (value) => (pos.x += value),
5845
5868
  radius,
5846
5869
  });
5847
5870
  };
5848
- _fixVertical = (pos, radius, outMode) => {
5871
+ #fixVertical = (pos, radius, outMode) => {
5849
5872
  fixOutMode({
5850
5873
  outMode,
5851
5874
  checkModes: [OutMode.bounce],
5852
5875
  coord: pos.y,
5853
- maxCoord: this._container.canvas.size.height,
5876
+ maxCoord: this.#container.canvas.size.height,
5854
5877
  setCb: (value) => (pos.y += value),
5855
5878
  radius,
5856
5879
  });
5857
5880
  };
5858
- _getRollColor = color => {
5881
+ #getDefaultInsideCanvasResult = (direction, outMode) => {
5882
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
5883
+ if (direction === OutModeDirection.bottom) {
5884
+ return {
5885
+ inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
5886
+ reason: "default",
5887
+ };
5888
+ }
5889
+ if (direction === OutModeDirection.left) {
5890
+ return {
5891
+ inside: isBounce ? position.x - radius > defaultAngle : position.x + radius > defaultAngle,
5892
+ reason: "default",
5893
+ };
5894
+ }
5895
+ if (direction === OutModeDirection.right) {
5896
+ return {
5897
+ inside: isBounce ? position.x + radius < canvasSize.width : position.x - radius < canvasSize.width,
5898
+ reason: "default",
5899
+ };
5900
+ }
5901
+ if (direction === OutModeDirection.top) {
5902
+ return {
5903
+ inside: isBounce ? position.y - radius > defaultAngle : position.y + radius > defaultAngle,
5904
+ reason: "default",
5905
+ };
5906
+ }
5907
+ return {
5908
+ inside: position.x >= -radius &&
5909
+ position.y >= -radius &&
5910
+ position.y <= canvasSize.height + radius &&
5911
+ position.x <= canvasSize.width + radius,
5912
+ reason: "default",
5913
+ };
5914
+ };
5915
+ #getInsideCanvasCallbackData = (direction, outMode) => {
5916
+ return {
5917
+ canvasSize: this.#container.canvas.size,
5918
+ direction,
5919
+ outMode,
5920
+ particle: this,
5921
+ radius: this.getRadius(),
5922
+ };
5923
+ };
5924
+ #getInsideCanvasResult = (data) => {
5925
+ 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;
5926
+ if (!shapeCheck && !effectCheck) {
5927
+ return defaultResult;
5928
+ }
5929
+ const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
5930
+ if (shapeResult && effectResult) {
5931
+ const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
5932
+ return {
5933
+ inside: shapeResult.inside && effectResult.inside,
5934
+ margin: margin > defaultAngle ? margin : undefined,
5935
+ reason: "combined",
5936
+ };
5937
+ }
5938
+ return shapeResult ?? effectResult ?? defaultResult;
5939
+ };
5940
+ #getRollColor = color => {
5859
5941
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
5860
5942
  return color;
5861
5943
  }
@@ -5870,8 +5952,8 @@
5870
5952
  }
5871
5953
  return color;
5872
5954
  };
5873
- _initPosition = position => {
5874
- const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5955
+ #initPosition = position => {
5956
+ const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5875
5957
  if (!initialPosition) {
5876
5958
  throw new Error("a valid position cannot be found for particle");
5877
5959
  }
@@ -5894,45 +5976,58 @@
5894
5976
  }
5895
5977
  this.offset = Vector.origin;
5896
5978
  };
5979
+ #normalizeInsideCanvasResult = (result, reason) => {
5980
+ if (typeof result === "boolean") {
5981
+ return {
5982
+ inside: result,
5983
+ reason,
5984
+ };
5985
+ }
5986
+ return {
5987
+ inside: result.inside,
5988
+ margin: result.margin,
5989
+ reason: result.reason ?? reason,
5990
+ };
5991
+ };
5897
5992
  }
5898
5993
 
5899
5994
  class SpatialHashGrid {
5900
- _cellSize;
5901
- _cells = new Map();
5902
- _circlePool = [];
5903
- _circlePoolIdx;
5904
- _pendingCellSize;
5905
- _rectanglePool = [];
5906
- _rectanglePoolIdx;
5995
+ #cellSize;
5996
+ #cells = new Map();
5997
+ #circlePool = [];
5998
+ #circlePoolIdx;
5999
+ #pendingCellSize;
6000
+ #rectanglePool = [];
6001
+ #rectanglePoolIdx;
5907
6002
  constructor(cellSize) {
5908
- this._cellSize = cellSize;
5909
- this._circlePoolIdx = 0;
5910
- this._rectanglePoolIdx = 0;
6003
+ this.#cellSize = cellSize;
6004
+ this.#circlePoolIdx = 0;
6005
+ this.#rectanglePoolIdx = 0;
5911
6006
  }
5912
6007
  clear() {
5913
- this._cells.clear();
5914
- const pendingCellSize = this._pendingCellSize;
6008
+ this.#cells.clear();
6009
+ const pendingCellSize = this.#pendingCellSize;
5915
6010
  if (pendingCellSize) {
5916
- this._cellSize = pendingCellSize;
6011
+ this.#cellSize = pendingCellSize;
5917
6012
  }
5918
- this._pendingCellSize = undefined;
6013
+ this.#pendingCellSize = undefined;
5919
6014
  }
5920
6015
  insert(particle) {
5921
- const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
5922
- if (!this._cells.has(key)) {
5923
- this._cells.set(key, []);
6016
+ const { x, y } = particle.getPosition(), key = this.#cellKeyFromCoords(x, y);
6017
+ if (!this.#cells.has(key)) {
6018
+ this.#cells.set(key, []);
5924
6019
  }
5925
- this._cells.get(key)?.push(particle);
6020
+ this.#cells.get(key)?.push(particle);
5926
6021
  }
5927
6022
  query(range, check, out = []) {
5928
- const bounds = this._getRangeBounds(range);
6023
+ const bounds = this.#getRangeBounds(range);
5929
6024
  if (!bounds) {
5930
6025
  return out;
5931
6026
  }
5932
- 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);
6027
+ 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);
5933
6028
  for (let cx = minCellX; cx <= maxCellX; cx++) {
5934
6029
  for (let cy = minCellY; cy <= maxCellY; cy++) {
5935
- const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
6030
+ const key = `${cx}_${cy}`, cellParticles = this.#cells.get(key);
5936
6031
  if (!cellParticles) {
5937
6032
  continue;
5938
6033
  }
@@ -5949,29 +6044,29 @@
5949
6044
  return out;
5950
6045
  }
5951
6046
  queryCircle(position, radius, check, out = []) {
5952
- const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5953
- this._releaseShapes();
6047
+ const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
6048
+ this.#releaseShapes();
5954
6049
  return result;
5955
6050
  }
5956
6051
  queryRectangle(position, size, check, out = []) {
5957
- const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5958
- this._releaseShapes();
6052
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
6053
+ this.#releaseShapes();
5959
6054
  return result;
5960
6055
  }
5961
6056
  setCellSize(cellSize) {
5962
- this._pendingCellSize = cellSize;
6057
+ this.#pendingCellSize = cellSize;
5963
6058
  }
5964
- _acquireCircle(x, y, r) {
5965
- return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
6059
+ #acquireCircle(x, y, r) {
6060
+ return (this.#circlePool[this.#circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5966
6061
  }
5967
- _acquireRectangle(x, y, w, h) {
5968
- return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
6062
+ #acquireRectangle(x, y, w, h) {
6063
+ return (this.#rectanglePool[this.#rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5969
6064
  }
5970
- _cellKeyFromCoords(x, y) {
5971
- const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
6065
+ #cellKeyFromCoords(x, y) {
6066
+ const cellX = Math.floor(x / this.#cellSize), cellY = Math.floor(y / this.#cellSize);
5972
6067
  return `${cellX}_${cellY}`;
5973
6068
  }
5974
- _getRangeBounds(range) {
6069
+ #getRangeBounds(range) {
5975
6070
  if (range instanceof Circle) {
5976
6071
  const r = range.radius, { x, y } = range.position;
5977
6072
  return {
@@ -5992,53 +6087,53 @@
5992
6087
  }
5993
6088
  return null;
5994
6089
  }
5995
- _releaseShapes() {
5996
- this._circlePoolIdx = 0;
5997
- this._rectanglePoolIdx = 0;
6090
+ #releaseShapes() {
6091
+ this.#circlePoolIdx = 0;
6092
+ this.#rectanglePoolIdx = 0;
5998
6093
  }
5999
6094
  }
6000
6095
 
6001
6096
  class ParticlesManager {
6002
6097
  checkParticlePositionPlugins;
6003
6098
  grid;
6004
- _array;
6005
- _container;
6006
- _groupLimits;
6007
- _limit;
6008
- _nextId;
6009
- _particleBuckets;
6010
- _particleResetPlugins;
6011
- _particleUpdatePlugins;
6012
- _pluginManager;
6013
- _pool;
6014
- _postParticleUpdatePlugins;
6015
- _postUpdatePlugins;
6016
- _resizeFactor;
6017
- _updatePlugins;
6018
- _zBuckets;
6099
+ #array;
6100
+ #container;
6101
+ #groupLimits;
6102
+ #limit;
6103
+ #nextId;
6104
+ #particleBuckets;
6105
+ #particleResetPlugins;
6106
+ #particleUpdatePlugins;
6107
+ #pluginManager;
6108
+ #pool;
6109
+ #postParticleUpdatePlugins;
6110
+ #postUpdatePlugins;
6111
+ #resizeFactor;
6112
+ #updatePlugins;
6113
+ #zBuckets;
6019
6114
  constructor(pluginManager, container) {
6020
- this._pluginManager = pluginManager;
6021
- this._container = container;
6022
- this._nextId = 0;
6023
- this._array = [];
6024
- this._pool = [];
6025
- this._limit = 0;
6026
- this._groupLimits = new Map();
6027
- this._particleBuckets = new Map();
6028
- this._zBuckets = this._createBuckets(this._container.zLayers);
6115
+ this.#pluginManager = pluginManager;
6116
+ this.#container = container;
6117
+ this.#nextId = 0;
6118
+ this.#array = [];
6119
+ this.#pool = [];
6120
+ this.#limit = 0;
6121
+ this.#groupLimits = new Map();
6122
+ this.#particleBuckets = new Map();
6123
+ this.#zBuckets = this.#createBuckets(this.#container.zLayers);
6029
6124
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
6030
6125
  this.checkParticlePositionPlugins = [];
6031
- this._particleResetPlugins = [];
6032
- this._particleUpdatePlugins = [];
6033
- this._postUpdatePlugins = [];
6034
- this._postParticleUpdatePlugins = [];
6035
- this._updatePlugins = [];
6126
+ this.#particleResetPlugins = [];
6127
+ this.#particleUpdatePlugins = [];
6128
+ this.#postUpdatePlugins = [];
6129
+ this.#postParticleUpdatePlugins = [];
6130
+ this.#updatePlugins = [];
6036
6131
  }
6037
6132
  get count() {
6038
- return this._array.length;
6133
+ return this.#array.length;
6039
6134
  }
6040
6135
  addParticle(position, overrideOptions, group, initializer) {
6041
- const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
6136
+ const limitMode = this.#container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this.#limit : (this.#groupLimits.get(group) ?? this.#limit), currentCount = this.count;
6042
6137
  if (limit > minLimit) {
6043
6138
  switch (limitMode) {
6044
6139
  case LimitMode.delete: {
@@ -6056,20 +6151,20 @@
6056
6151
  }
6057
6152
  }
6058
6153
  try {
6059
- const particle = this._pool.pop() ?? new Particle(this._pluginManager, this._container);
6060
- particle.init(this._nextId, position, overrideOptions, group);
6154
+ const particle = this.#pool.pop() ?? new Particle(this.#pluginManager, this.#container);
6155
+ particle.init(this.#nextId, position, overrideOptions, group);
6061
6156
  let canAdd = true;
6062
6157
  if (initializer) {
6063
6158
  canAdd = initializer(particle);
6064
6159
  }
6065
6160
  if (!canAdd) {
6066
- this._pool.push(particle);
6161
+ this.#pool.push(particle);
6067
6162
  return;
6068
6163
  }
6069
- this._array.push(particle);
6070
- this._insertParticleIntoBucket(particle);
6071
- this._nextId++;
6072
- this._container.dispatchEvent(EventType.particleAdded, {
6164
+ this.#array.push(particle);
6165
+ this.#insertParticleIntoBucket(particle);
6166
+ this.#nextId++;
6167
+ this.#container.dispatchEvent(EventType.particleAdded, {
6073
6168
  particle,
6074
6169
  });
6075
6170
  return particle;
@@ -6080,25 +6175,25 @@
6080
6175
  return undefined;
6081
6176
  }
6082
6177
  clear() {
6083
- this._array = [];
6084
- this._particleBuckets.clear();
6085
- this._resetBuckets(this._container.zLayers);
6178
+ this.#array = [];
6179
+ this.#particleBuckets.clear();
6180
+ this.#resetBuckets(this.#container.zLayers);
6086
6181
  }
6087
6182
  destroy() {
6088
- this._array = [];
6089
- this._pool.length = 0;
6090
- this._particleBuckets.clear();
6091
- this._zBuckets = [];
6183
+ this.#array = [];
6184
+ this.#pool.length = 0;
6185
+ this.#particleBuckets.clear();
6186
+ this.#zBuckets = [];
6092
6187
  this.checkParticlePositionPlugins = [];
6093
- this._particleResetPlugins = [];
6094
- this._particleUpdatePlugins = [];
6095
- this._postUpdatePlugins = [];
6096
- this._postParticleUpdatePlugins = [];
6097
- this._updatePlugins = [];
6188
+ this.#particleResetPlugins = [];
6189
+ this.#particleUpdatePlugins = [];
6190
+ this.#postUpdatePlugins = [];
6191
+ this.#postParticleUpdatePlugins = [];
6192
+ this.#updatePlugins = [];
6098
6193
  }
6099
6194
  drawParticles(delta) {
6100
- for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
6101
- const bucket = this._zBuckets[i];
6195
+ for (let i = this.#zBuckets.length - one; i >= minIndex; i--) {
6196
+ const bucket = this.#zBuckets[i];
6102
6197
  if (!bucket) {
6103
6198
  continue;
6104
6199
  }
@@ -6108,24 +6203,24 @@
6108
6203
  }
6109
6204
  }
6110
6205
  filter(condition) {
6111
- return this._array.filter(condition);
6206
+ return this.#array.filter(condition);
6112
6207
  }
6113
6208
  find(condition) {
6114
- return this._array.find(condition);
6209
+ return this.#array.find(condition);
6115
6210
  }
6116
6211
  get(index) {
6117
- return this._array[index];
6212
+ return this.#array[index];
6118
6213
  }
6119
6214
  async init() {
6120
- const container = this._container, options = container.actualOptions;
6215
+ const container = this.#container, options = container.actualOptions;
6121
6216
  this.checkParticlePositionPlugins = [];
6122
- this._updatePlugins = [];
6123
- this._particleUpdatePlugins = [];
6124
- this._postUpdatePlugins = [];
6125
- this._particleResetPlugins = [];
6126
- this._postParticleUpdatePlugins = [];
6127
- this._particleBuckets.clear();
6128
- this._resetBuckets(container.zLayers);
6217
+ this.#updatePlugins = [];
6218
+ this.#particleUpdatePlugins = [];
6219
+ this.#postUpdatePlugins = [];
6220
+ this.#particleResetPlugins = [];
6221
+ this.#postParticleUpdatePlugins = [];
6222
+ this.#particleBuckets.clear();
6223
+ this.#resetBuckets(container.zLayers);
6129
6224
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
6130
6225
  for (const plugin of container.plugins) {
6131
6226
  if (plugin.redrawInit) {
@@ -6135,26 +6230,26 @@
6135
6230
  this.checkParticlePositionPlugins.push(plugin);
6136
6231
  }
6137
6232
  if (plugin.update) {
6138
- this._updatePlugins.push(plugin);
6233
+ this.#updatePlugins.push(plugin);
6139
6234
  }
6140
6235
  if (plugin.particleUpdate) {
6141
- this._particleUpdatePlugins.push(plugin);
6236
+ this.#particleUpdatePlugins.push(plugin);
6142
6237
  }
6143
6238
  if (plugin.postUpdate) {
6144
- this._postUpdatePlugins.push(plugin);
6239
+ this.#postUpdatePlugins.push(plugin);
6145
6240
  }
6146
6241
  if (plugin.particleReset) {
6147
- this._particleResetPlugins.push(plugin);
6242
+ this.#particleResetPlugins.push(plugin);
6148
6243
  }
6149
6244
  if (plugin.postParticleUpdate) {
6150
- this._postParticleUpdatePlugins.push(plugin);
6245
+ this.#postParticleUpdatePlugins.push(plugin);
6151
6246
  }
6152
6247
  }
6153
- await this._container.initDrawersAndUpdaters();
6154
- for (const drawer of this._container.effectDrawers.values()) {
6248
+ await this.#container.initDrawersAndUpdaters();
6249
+ for (const drawer of this.#container.effectDrawers.values()) {
6155
6250
  await drawer.init?.(container);
6156
6251
  }
6157
- for (const drawer of this._container.shapeDrawers.values()) {
6252
+ for (const drawer of this.#container.shapeDrawers.values()) {
6158
6253
  await drawer.init?.(container);
6159
6254
  }
6160
6255
  let handled = false;
@@ -6188,10 +6283,10 @@
6188
6283
  async redraw() {
6189
6284
  this.clear();
6190
6285
  await this.init();
6191
- this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
6286
+ this.#container.canvas.render.drawParticles({ value: 0, factor: 0 });
6192
6287
  }
6193
6288
  remove(particle, group, override) {
6194
- this.removeAt(this._array.indexOf(particle), undefined, group, override);
6289
+ this.removeAt(this.#array.indexOf(particle), undefined, group, override);
6195
6290
  }
6196
6291
  removeAt(index, quantity = defaultRemoveQuantity, group, override) {
6197
6292
  if (index < minIndex || index > this.count) {
@@ -6199,7 +6294,7 @@
6199
6294
  }
6200
6295
  let deleted = 0;
6201
6296
  for (let i = index; deleted < quantity && i < this.count; i++) {
6202
- if (this._removeParticle(i, group, override)) {
6297
+ if (this.#removeParticle(i, group, override)) {
6203
6298
  i--;
6204
6299
  deleted++;
6205
6300
  }
@@ -6209,9 +6304,9 @@
6209
6304
  this.removeAt(minIndex, quantity, group);
6210
6305
  }
6211
6306
  setDensity() {
6212
- const options = this._container.actualOptions, groups = options.particles.groups;
6307
+ const options = this.#container.actualOptions, groups = options.particles.groups;
6213
6308
  let pluginsCount = 0;
6214
- for (const plugin of this._container.plugins) {
6309
+ for (const plugin of this.#container.plugins) {
6215
6310
  if (plugin.particlesDensityCount) {
6216
6311
  pluginsCount += plugin.particlesDensityCount();
6217
6312
  }
@@ -6221,51 +6316,51 @@
6221
6316
  if (!groupData) {
6222
6317
  continue;
6223
6318
  }
6224
- const groupDataOptions = loadParticlesOptions(this._pluginManager, this._container, groupData);
6225
- this._applyDensity(groupDataOptions, pluginsCount, group);
6319
+ const groupDataOptions = loadParticlesOptions(this.#pluginManager, this.#container, groupData);
6320
+ this.#applyDensity(groupDataOptions, pluginsCount, group);
6226
6321
  }
6227
- this._applyDensity(options.particles, pluginsCount);
6322
+ this.#applyDensity(options.particles, pluginsCount);
6228
6323
  }
6229
6324
  setResizeFactor(factor) {
6230
- this._resizeFactor = factor;
6325
+ this.#resizeFactor = factor;
6231
6326
  }
6232
6327
  update(delta) {
6233
6328
  this.grid.clear();
6234
- for (const plugin of this._updatePlugins) {
6329
+ for (const plugin of this.#updatePlugins) {
6235
6330
  plugin.update?.(delta);
6236
6331
  }
6237
- const particlesToDelete = this._updateParticlesPhase1(delta);
6238
- for (const plugin of this._postUpdatePlugins) {
6332
+ const particlesToDelete = this.#updateParticlesPhase1(delta);
6333
+ for (const plugin of this.#postUpdatePlugins) {
6239
6334
  plugin.postUpdate?.(delta);
6240
6335
  }
6241
- this._updateParticlesPhase2(delta, particlesToDelete);
6336
+ this.#updateParticlesPhase2(delta, particlesToDelete);
6242
6337
  if (particlesToDelete.size) {
6243
6338
  for (const particle of particlesToDelete) {
6244
6339
  this.remove(particle);
6245
6340
  }
6246
6341
  }
6247
- delete this._resizeFactor;
6342
+ this.#resizeFactor = undefined;
6248
6343
  }
6249
- _addToPool = (...particles) => {
6250
- this._pool.push(...particles);
6344
+ #addToPool = (...particles) => {
6345
+ this.#pool.push(...particles);
6251
6346
  };
6252
- _applyDensity = (options, pluginsCount, group, groupOptions) => {
6347
+ #applyDensity = (options, pluginsCount, group, groupOptions) => {
6253
6348
  const numberOptions = options.number;
6254
6349
  if (!numberOptions.density.enable) {
6255
6350
  if (group === undefined) {
6256
- this._limit = numberOptions.limit.value;
6351
+ this.#limit = numberOptions.limit.value;
6257
6352
  }
6258
6353
  else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
6259
- this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
6354
+ this.#groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
6260
6355
  }
6261
6356
  return;
6262
6357
  }
6263
- 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);
6358
+ 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);
6264
6359
  if (group === undefined) {
6265
- this._limit = numberOptions.limit.value * densityFactor;
6360
+ this.#limit = numberOptions.limit.value * densityFactor;
6266
6361
  }
6267
6362
  else {
6268
- this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
6363
+ this.#groupLimits.set(group, numberOptions.limit.value * densityFactor);
6269
6364
  }
6270
6365
  if (particlesCount < particlesNumber) {
6271
6366
  this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
@@ -6274,18 +6369,18 @@
6274
6369
  this.removeQuantity(particlesCount - particlesNumber, group);
6275
6370
  }
6276
6371
  };
6277
- _createBuckets = (zLayers) => {
6372
+ #createBuckets = (zLayers) => {
6278
6373
  const bucketCount = Math.max(Math.floor(zLayers), one);
6279
6374
  return Array.from({ length: bucketCount }, () => []);
6280
6375
  };
6281
- _getBucketIndex = (zIndex) => {
6282
- const maxBucketIndex = this._zBuckets.length - one;
6376
+ #getBucketIndex = (zIndex) => {
6377
+ const maxBucketIndex = this.#zBuckets.length - one;
6283
6378
  if (maxBucketIndex <= minIndex) {
6284
6379
  return minIndex;
6285
6380
  }
6286
6381
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
6287
6382
  };
6288
- _getParticleInsertIndex = (bucket, particleId) => {
6383
+ #getParticleInsertIndex = (bucket, particleId) => {
6289
6384
  let start = minIndex, end = bucket.length;
6290
6385
  while (start < end) {
6291
6386
  const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
@@ -6302,8 +6397,8 @@
6302
6397
  }
6303
6398
  return start;
6304
6399
  };
6305
- _initDensityFactor = densityOptions => {
6306
- const container = this._container;
6400
+ #initDensityFactor = densityOptions => {
6401
+ const container = this.#container;
6307
6402
  if (!densityOptions.enable) {
6308
6403
  return defaultDensityFactor;
6309
6404
  }
@@ -6313,82 +6408,82 @@
6313
6408
  }
6314
6409
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
6315
6410
  };
6316
- _insertParticleIntoBucket = (particle) => {
6317
- const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
6411
+ #insertParticleIntoBucket = (particle) => {
6412
+ const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
6318
6413
  if (!bucket) {
6319
6414
  return;
6320
6415
  }
6321
- bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
6322
- this._particleBuckets.set(particle.id, bucketIndex);
6416
+ bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
6417
+ this.#particleBuckets.set(particle.id, bucketIndex);
6323
6418
  };
6324
- _removeParticle = (index, group, override) => {
6325
- const particle = this._array[index];
6419
+ #removeParticle = (index, group, override) => {
6420
+ const particle = this.#array[index];
6326
6421
  if (!particle) {
6327
6422
  return false;
6328
6423
  }
6329
6424
  if (particle.group !== group) {
6330
6425
  return false;
6331
6426
  }
6332
- this._array.splice(index, deleteCount);
6333
- this._removeParticleFromBucket(particle);
6427
+ this.#array.splice(index, deleteCount);
6428
+ this.#removeParticleFromBucket(particle);
6334
6429
  particle.destroy(override);
6335
- this._container.dispatchEvent(EventType.particleRemoved, {
6430
+ this.#container.dispatchEvent(EventType.particleRemoved, {
6336
6431
  particle,
6337
6432
  });
6338
- this._addToPool(particle);
6433
+ this.#addToPool(particle);
6339
6434
  return true;
6340
6435
  };
6341
- _removeParticleFromBucket = (particle) => {
6342
- const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
6436
+ #removeParticleFromBucket = (particle) => {
6437
+ const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
6343
6438
  if (!bucket) {
6344
- this._particleBuckets.delete(particle.id);
6439
+ this.#particleBuckets.delete(particle.id);
6345
6440
  return;
6346
6441
  }
6347
- const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
6442
+ const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
6348
6443
  if (bucket[particleIndex]?.id !== particle.id) {
6349
- this._particleBuckets.delete(particle.id);
6444
+ this.#particleBuckets.delete(particle.id);
6350
6445
  return;
6351
6446
  }
6352
6447
  bucket.splice(particleIndex, deleteCount);
6353
- this._particleBuckets.delete(particle.id);
6448
+ this.#particleBuckets.delete(particle.id);
6354
6449
  };
6355
- _resetBuckets = (zLayers) => {
6450
+ #resetBuckets = (zLayers) => {
6356
6451
  const bucketCount = Math.max(Math.floor(zLayers), one);
6357
- if (this._zBuckets.length !== bucketCount) {
6358
- this._zBuckets = this._createBuckets(bucketCount);
6452
+ if (this.#zBuckets.length !== bucketCount) {
6453
+ this.#zBuckets = this.#createBuckets(bucketCount);
6359
6454
  return;
6360
6455
  }
6361
- for (const bucket of this._zBuckets) {
6456
+ for (const bucket of this.#zBuckets) {
6362
6457
  bucket.length = minIndex;
6363
6458
  }
6364
6459
  };
6365
- _updateParticleBucket = (particle) => {
6366
- const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
6460
+ #updateParticleBucket = (particle) => {
6461
+ const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
6367
6462
  if (currentBucketIndex === undefined) {
6368
- this._insertParticleIntoBucket(particle);
6463
+ this.#insertParticleIntoBucket(particle);
6369
6464
  return;
6370
6465
  }
6371
6466
  if (currentBucketIndex === newBucketIndex) {
6372
6467
  return;
6373
6468
  }
6374
- const currentBucket = this._zBuckets[currentBucketIndex];
6469
+ const currentBucket = this.#zBuckets[currentBucketIndex];
6375
6470
  if (currentBucket) {
6376
- const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
6471
+ const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
6377
6472
  if (currentBucket[particleIndex]?.id === particle.id) {
6378
6473
  currentBucket.splice(particleIndex, deleteCount);
6379
6474
  }
6380
6475
  }
6381
- const newBucket = this._zBuckets[newBucketIndex];
6476
+ const newBucket = this.#zBuckets[newBucketIndex];
6382
6477
  if (!newBucket) {
6383
- this._particleBuckets.set(particle.id, newBucketIndex);
6478
+ this.#particleBuckets.set(particle.id, newBucketIndex);
6384
6479
  return;
6385
6480
  }
6386
- newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
6387
- this._particleBuckets.set(particle.id, newBucketIndex);
6481
+ newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
6482
+ this.#particleBuckets.set(particle.id, newBucketIndex);
6388
6483
  };
6389
- _updateParticlesPhase1 = (delta) => {
6390
- const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
6391
- for (const particle of this._array) {
6484
+ #updateParticlesPhase1 = (delta) => {
6485
+ const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
6486
+ for (const particle of this.#array) {
6392
6487
  if (resizeFactor && !particle.ignoresResizeRatio) {
6393
6488
  particle.position.x *= resizeFactor.width;
6394
6489
  particle.position.y *= resizeFactor.height;
@@ -6396,10 +6491,10 @@
6396
6491
  particle.initialPosition.y *= resizeFactor.height;
6397
6492
  }
6398
6493
  particle.ignoresResizeRatio = false;
6399
- for (const plugin of this._particleResetPlugins) {
6494
+ for (const plugin of this.#particleResetPlugins) {
6400
6495
  plugin.particleReset?.(particle);
6401
6496
  }
6402
- for (const plugin of this._particleUpdatePlugins) {
6497
+ for (const plugin of this.#particleUpdatePlugins) {
6403
6498
  if (particle.destroyed) {
6404
6499
  break;
6405
6500
  }
@@ -6413,36 +6508,36 @@
6413
6508
  }
6414
6509
  return particlesToDelete;
6415
6510
  };
6416
- _updateParticlesPhase2 = (delta, particlesToDelete) => {
6417
- for (const particle of this._array) {
6511
+ #updateParticlesPhase2 = (delta, particlesToDelete) => {
6512
+ for (const particle of this.#array) {
6418
6513
  if (particle.destroyed) {
6419
6514
  particlesToDelete.add(particle);
6420
6515
  continue;
6421
6516
  }
6422
- for (const updater of this._container.particleUpdaters) {
6517
+ for (const updater of this.#container.particleUpdaters) {
6423
6518
  updater.update(particle, delta);
6424
6519
  }
6425
6520
  if (!particle.spawning) {
6426
- for (const plugin of this._postParticleUpdatePlugins) {
6521
+ for (const plugin of this.#postParticleUpdatePlugins) {
6427
6522
  plugin.postParticleUpdate?.(particle, delta);
6428
6523
  }
6429
6524
  }
6430
- this._updateParticleBucket(particle);
6525
+ this.#updateParticleBucket(particle);
6431
6526
  }
6432
6527
  };
6433
6528
  }
6434
6529
 
6435
6530
  class Retina {
6436
- container;
6437
6531
  pixelRatio;
6438
6532
  reduceFactor;
6533
+ #container;
6439
6534
  constructor(container) {
6440
- this.container = container;
6535
+ this.#container = container;
6441
6536
  this.pixelRatio = defaultRatio;
6442
6537
  this.reduceFactor = defaultReduceFactor;
6443
6538
  }
6444
6539
  init() {
6445
- const container = this.container, options = container.actualOptions;
6540
+ const container = this.#container, options = container.actualOptions;
6446
6541
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
6447
6542
  this.reduceFactor = defaultReduceFactor;
6448
6543
  const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
@@ -6456,7 +6551,6 @@
6456
6551
  props.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
6457
6552
  props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
6458
6553
  props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
6459
- props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
6460
6554
  const maxDistance = props.maxDistance;
6461
6555
  maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
6462
6556
  maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
@@ -6494,73 +6588,73 @@
6494
6588
  shapeDrawers;
6495
6589
  started;
6496
6590
  zLayers;
6497
- _delay;
6498
- _delayTimeout;
6499
- _delta = { value: 0, factor: 0 };
6500
- _dispatchCallback;
6501
- _drawAnimationFrame;
6502
- _duration;
6503
- _eventListeners;
6504
- _firstStart;
6505
- _initialSourceOptions;
6506
- _lastFrameTime;
6507
- _lifeTime;
6508
- _onDestroy;
6509
- _options;
6510
- _paused;
6511
- _pluginManager;
6512
- _smooth;
6513
- _sourceOptions;
6591
+ #delay;
6592
+ #delayTimeout;
6593
+ #delta = { value: 0, factor: 0 };
6594
+ #dispatchCallback;
6595
+ #drawAnimationFrame;
6596
+ #duration;
6597
+ #eventListeners;
6598
+ #firstStart;
6599
+ #initialSourceOptions;
6600
+ #lastFrameTime;
6601
+ #lifeTime;
6602
+ #onDestroy;
6603
+ #options;
6604
+ #paused;
6605
+ #pluginManager;
6606
+ #smooth;
6607
+ #sourceOptions;
6514
6608
  constructor(params) {
6515
6609
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
6516
- this._pluginManager = pluginManager;
6517
- this._dispatchCallback = dispatchCallback;
6518
- this._onDestroy = onDestroy;
6610
+ this.#pluginManager = pluginManager;
6611
+ this.#dispatchCallback = dispatchCallback;
6612
+ this.#onDestroy = onDestroy;
6519
6613
  this.id = Symbol(id);
6520
6614
  this.fpsLimit = 120;
6521
6615
  this.hdr = false;
6522
- this._smooth = false;
6523
- this._delay = 0;
6524
- this._duration = 0;
6525
- this._lifeTime = 0;
6526
- this._firstStart = true;
6616
+ this.#smooth = false;
6617
+ this.#delay = 0;
6618
+ this.#duration = 0;
6619
+ this.#lifeTime = 0;
6620
+ this.#firstStart = true;
6527
6621
  this.started = false;
6528
6622
  this.destroyed = false;
6529
- this._paused = true;
6530
- this._lastFrameTime = 0;
6623
+ this.#paused = true;
6624
+ this.#lastFrameTime = 0;
6531
6625
  this.zLayers = 100;
6532
6626
  this.pageHidden = false;
6533
- this._sourceOptions = sourceOptions;
6534
- this._initialSourceOptions = sourceOptions;
6627
+ this.#sourceOptions = sourceOptions;
6628
+ this.#initialSourceOptions = sourceOptions;
6535
6629
  this.effectDrawers = new Map();
6536
6630
  this.shapeDrawers = new Map();
6537
6631
  this.particleUpdaters = [];
6538
6632
  this.retina = new Retina(this);
6539
- this.canvas = new CanvasManager(this._pluginManager, this);
6540
- this.particles = new ParticlesManager(this._pluginManager, this);
6633
+ this.canvas = new CanvasManager(this.#pluginManager, this);
6634
+ this.particles = new ParticlesManager(this.#pluginManager, this);
6541
6635
  this.plugins = [];
6542
6636
  this.particleDestroyedPlugins = [];
6543
6637
  this.particleCreatedPlugins = [];
6544
6638
  this.particlePositionPlugins = [];
6545
- this._options = loadContainerOptions(this._pluginManager, this);
6546
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
6547
- this._eventListeners = new EventListeners(this);
6639
+ this.#options = loadContainerOptions(this.#pluginManager, this);
6640
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
6641
+ this.#eventListeners = new EventListeners(this);
6548
6642
  this.dispatchEvent(EventType.containerBuilt);
6549
6643
  }
6550
6644
  get animationStatus() {
6551
- return !this._paused && !this.pageHidden && guardCheck(this);
6645
+ return !this.#paused && !this.pageHidden && guardCheck(this);
6552
6646
  }
6553
6647
  get options() {
6554
- return this._options;
6648
+ return this.#options;
6555
6649
  }
6556
6650
  get sourceOptions() {
6557
- return this._sourceOptions;
6651
+ return this.#sourceOptions;
6558
6652
  }
6559
6653
  addLifeTime(value) {
6560
- this._lifeTime += value;
6654
+ this.#lifeTime += value;
6561
6655
  }
6562
6656
  alive() {
6563
- return !this._duration || this._lifeTime <= this._duration;
6657
+ return !this.#duration || this.#lifeTime <= this.#duration;
6564
6658
  }
6565
6659
  destroy(remove = true) {
6566
6660
  if (!guardCheck(this)) {
@@ -6582,13 +6676,13 @@
6582
6676
  this.shapeDrawers = new Map();
6583
6677
  this.particleUpdaters = [];
6584
6678
  this.plugins.length = 0;
6585
- this._pluginManager.clearPlugins(this);
6679
+ this.#pluginManager.clearPlugins(this);
6586
6680
  this.destroyed = true;
6587
- this._onDestroy(remove);
6681
+ this.#onDestroy(remove);
6588
6682
  this.dispatchEvent(EventType.containerDestroyed);
6589
6683
  }
6590
6684
  dispatchEvent(type, data) {
6591
- this._dispatchCallback(type, {
6685
+ this.#dispatchCallback(type, {
6592
6686
  container: this,
6593
6687
  data,
6594
6688
  });
@@ -6598,12 +6692,12 @@
6598
6692
  return;
6599
6693
  }
6600
6694
  let refreshTime = force;
6601
- this._drawAnimationFrame = animate((timestamp) => {
6695
+ this.#drawAnimationFrame = animate((timestamp) => {
6602
6696
  if (refreshTime) {
6603
- this._lastFrameTime = undefined;
6697
+ this.#lastFrameTime = undefined;
6604
6698
  refreshTime = false;
6605
6699
  }
6606
- this._nextFrame(timestamp);
6700
+ this.#nextFrame(timestamp);
6607
6701
  });
6608
6702
  }
6609
6703
  async export(type, options = {}) {
@@ -6625,7 +6719,7 @@
6625
6719
  return;
6626
6720
  }
6627
6721
  const allContainerPlugins = new Map();
6628
- for (const plugin of this._pluginManager.plugins) {
6722
+ for (const plugin of this.#pluginManager.plugins) {
6629
6723
  const containerPlugin = await plugin.getPlugin(this);
6630
6724
  if (containerPlugin.preInit) {
6631
6725
  await containerPlugin.preInit();
@@ -6633,8 +6727,8 @@
6633
6727
  allContainerPlugins.set(plugin, containerPlugin);
6634
6728
  }
6635
6729
  await this.initDrawersAndUpdaters();
6636
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
6637
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
6730
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
6731
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
6638
6732
  this.plugins.length = 0;
6639
6733
  this.particleDestroyedPlugins.length = 0;
6640
6734
  this.particleCreatedPlugins.length = 0;
@@ -6661,11 +6755,11 @@
6661
6755
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
6662
6756
  this.hdr = hdr;
6663
6757
  this.zLayers = zLayers;
6664
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
6665
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
6666
- this._lifeTime = 0;
6758
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
6759
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
6760
+ this.#lifeTime = 0;
6667
6761
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
6668
- this._smooth = smooth;
6762
+ this.#smooth = smooth;
6669
6763
  for (const plugin of this.plugins) {
6670
6764
  await plugin.init?.();
6671
6765
  }
@@ -6678,7 +6772,7 @@
6678
6772
  this.dispatchEvent(EventType.particlesSetup);
6679
6773
  }
6680
6774
  async initDrawersAndUpdaters() {
6681
- const pluginManager = this._pluginManager;
6775
+ const pluginManager = this.#pluginManager;
6682
6776
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
6683
6777
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
6684
6778
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -6687,18 +6781,18 @@
6687
6781
  if (!guardCheck(this)) {
6688
6782
  return;
6689
6783
  }
6690
- if (this._drawAnimationFrame !== undefined) {
6691
- cancelAnimation(this._drawAnimationFrame);
6692
- delete this._drawAnimationFrame;
6784
+ if (this.#drawAnimationFrame !== undefined) {
6785
+ cancelAnimation(this.#drawAnimationFrame);
6786
+ this.#drawAnimationFrame = undefined;
6693
6787
  }
6694
- if (this._paused) {
6788
+ if (this.#paused) {
6695
6789
  return;
6696
6790
  }
6697
6791
  for (const plugin of this.plugins) {
6698
6792
  plugin.pause?.();
6699
6793
  }
6700
6794
  if (!this.pageHidden) {
6701
- this._paused = true;
6795
+ this.#paused = true;
6702
6796
  }
6703
6797
  this.dispatchEvent(EventType.containerPaused);
6704
6798
  }
@@ -6706,13 +6800,13 @@
6706
6800
  if (!guardCheck(this)) {
6707
6801
  return;
6708
6802
  }
6709
- const needsUpdate = this._paused || force;
6710
- if (this._firstStart && !this.actualOptions.autoPlay) {
6711
- this._firstStart = false;
6803
+ const needsUpdate = this.#paused || force;
6804
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
6805
+ this.#firstStart = false;
6712
6806
  return;
6713
6807
  }
6714
- if (this._paused) {
6715
- this._paused = false;
6808
+ if (this.#paused) {
6809
+ this.#paused = false;
6716
6810
  }
6717
6811
  if (needsUpdate) {
6718
6812
  for (const plugin of this.plugins) {
@@ -6735,10 +6829,10 @@
6735
6829
  if (!guardCheck(this)) {
6736
6830
  return;
6737
6831
  }
6738
- this._initialSourceOptions = sourceOptions;
6739
- this._sourceOptions = sourceOptions;
6740
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
6741
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
6832
+ this.#initialSourceOptions = sourceOptions;
6833
+ this.#sourceOptions = sourceOptions;
6834
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
6835
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
6742
6836
  return this.refresh();
6743
6837
  }
6744
6838
  async start() {
@@ -6749,7 +6843,7 @@
6749
6843
  this.started = true;
6750
6844
  await new Promise(resolve => {
6751
6845
  const start = async () => {
6752
- this._eventListeners.addListeners();
6846
+ this.#eventListeners.addListeners();
6753
6847
  for (const plugin of this.plugins) {
6754
6848
  await plugin.start?.();
6755
6849
  }
@@ -6757,20 +6851,20 @@
6757
6851
  this.play();
6758
6852
  resolve();
6759
6853
  };
6760
- this._delayTimeout = setTimeout(() => void start(), this._delay);
6854
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
6761
6855
  });
6762
6856
  }
6763
6857
  stop() {
6764
6858
  if (!guardCheck(this) || !this.started) {
6765
6859
  return;
6766
6860
  }
6767
- if (this._delayTimeout) {
6768
- clearTimeout(this._delayTimeout);
6769
- delete this._delayTimeout;
6861
+ if (this.#delayTimeout) {
6862
+ clearTimeout(this.#delayTimeout);
6863
+ this.#delayTimeout = undefined;
6770
6864
  }
6771
- this._firstStart = true;
6865
+ this.#firstStart = true;
6772
6866
  this.started = false;
6773
- this._eventListeners.removeListeners();
6867
+ this.#eventListeners.removeListeners();
6774
6868
  this.pause();
6775
6869
  this.particles.clear();
6776
6870
  this.canvas.stop();
@@ -6780,7 +6874,7 @@
6780
6874
  this.particleCreatedPlugins.length = 0;
6781
6875
  this.particleDestroyedPlugins.length = 0;
6782
6876
  this.particlePositionPlugins.length = 0;
6783
- this._sourceOptions = this._options;
6877
+ this.#sourceOptions = this.#options;
6784
6878
  this.dispatchEvent(EventType.containerStopped);
6785
6879
  }
6786
6880
  updateActualOptions() {
@@ -6792,23 +6886,23 @@
6792
6886
  }
6793
6887
  return refresh;
6794
6888
  }
6795
- _nextFrame = (timestamp) => {
6889
+ #nextFrame = (timestamp) => {
6796
6890
  try {
6797
- if (!this._smooth &&
6798
- this._lastFrameTime !== undefined &&
6799
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
6891
+ if (!this.#smooth &&
6892
+ this.#lastFrameTime !== undefined &&
6893
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
6800
6894
  this.draw(false);
6801
6895
  return;
6802
6896
  }
6803
- this._lastFrameTime ??= timestamp;
6804
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
6805
- this.addLifeTime(this._delta.value);
6806
- this._lastFrameTime = timestamp;
6807
- if (this._delta.value > millisecondsToSeconds) {
6897
+ this.#lastFrameTime ??= timestamp;
6898
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
6899
+ this.addLifeTime(this.#delta.value);
6900
+ this.#lastFrameTime = timestamp;
6901
+ if (this.#delta.value > millisecondsToSeconds) {
6808
6902
  this.draw(false);
6809
6903
  return;
6810
6904
  }
6811
- this.canvas.render.drawParticles(this._delta);
6905
+ this.canvas.render.drawParticles(this.#delta);
6812
6906
  if (!this.alive()) {
6813
6907
  this.destroy();
6814
6908
  return;
@@ -6829,10 +6923,10 @@
6829
6923
  });
6830
6924
 
6831
6925
  class BlendPluginInstance {
6832
- _container;
6833
- _defaultCompositeValue;
6926
+ #container;
6927
+ #defaultCompositeValue;
6834
6928
  constructor(container) {
6835
- this._container = container;
6929
+ this.#container = container;
6836
6930
  }
6837
6931
  drawParticleCleanup(context, particle) {
6838
6932
  if (!particle.options.blend?.enable) {
@@ -6849,14 +6943,14 @@
6849
6943
  context.globalCompositeOperation = particle.options.blend.mode;
6850
6944
  }
6851
6945
  drawSettingsCleanup(context) {
6852
- if (!this._defaultCompositeValue) {
6946
+ if (!this.#defaultCompositeValue) {
6853
6947
  return;
6854
6948
  }
6855
- context.globalCompositeOperation = this._defaultCompositeValue;
6949
+ context.globalCompositeOperation = this.#defaultCompositeValue;
6856
6950
  }
6857
6951
  drawSettingsSetup(context) {
6858
- const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
6859
- this._defaultCompositeValue = previousComposite;
6952
+ const previousComposite = context.globalCompositeOperation, blend = this.#container.actualOptions.blend;
6953
+ this.#defaultCompositeValue = previousComposite;
6860
6954
  context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
6861
6955
  }
6862
6956
  }
@@ -6999,11 +7093,11 @@
6999
7093
  class MovePluginInstance {
7000
7094
  availablePathGenerators;
7001
7095
  pathGenerators;
7002
- _container;
7003
- _pluginManager;
7096
+ #container;
7097
+ #pluginManager;
7004
7098
  constructor(pluginManager, container) {
7005
- this._pluginManager = pluginManager;
7006
- this._container = container;
7099
+ this.#pluginManager = pluginManager;
7100
+ this.#container = container;
7007
7101
  this.availablePathGenerators = new Map();
7008
7102
  this.pathGenerators = new Map();
7009
7103
  }
@@ -7034,7 +7128,7 @@
7034
7128
  acceleration: getRangeValue(gravityOptions.acceleration),
7035
7129
  inverse: gravityOptions.inverse,
7036
7130
  };
7037
- initSpin(this._container, particle);
7131
+ initSpin(this.#container, particle);
7038
7132
  }
7039
7133
  particleDestroyed(particle) {
7040
7134
  const pathGenerator = particle.pathGenerator;
@@ -7045,7 +7139,7 @@
7045
7139
  if (!moveOptions.enable) {
7046
7140
  return;
7047
7141
  }
7048
- 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;
7142
+ 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;
7049
7143
  if (moveOptions.spin.enable) {
7050
7144
  spin(container, particle, moveSpeed, reduceFactor);
7051
7145
  }
@@ -7055,18 +7149,18 @@
7055
7149
  applyDistance(particle);
7056
7150
  }
7057
7151
  preInit() {
7058
- return this._init();
7152
+ return this.#init();
7059
7153
  }
7060
7154
  redrawInit() {
7061
- return this._init();
7155
+ return this.#init();
7062
7156
  }
7063
7157
  update() {
7064
7158
  for (const pathGenerator of this.pathGenerators.values()) {
7065
7159
  pathGenerator.update();
7066
7160
  }
7067
7161
  }
7068
- async _init() {
7069
- const availablePathGenerators = await this._pluginManager.getPathGenerators?.(this._container, true);
7162
+ async #init() {
7163
+ const availablePathGenerators = await this.#pluginManager.getPathGenerators?.(this.#container, true);
7070
7164
  if (!availablePathGenerators) {
7071
7165
  return;
7072
7166
  }
@@ -7084,44 +7178,44 @@
7084
7178
  });
7085
7179
 
7086
7180
  class EmittersPluginInstance {
7087
- container;
7088
- _instancesManager;
7181
+ #container;
7182
+ #instancesManager;
7089
7183
  constructor(instancesManager, container) {
7090
- this.container = container;
7091
- this._instancesManager = instancesManager;
7092
- this._instancesManager.initContainer(container);
7184
+ this.#instancesManager = instancesManager;
7185
+ this.#container = container;
7186
+ this.#instancesManager.initContainer(container);
7093
7187
  }
7094
7188
  async init() {
7095
- const emittersOptions = this.container.actualOptions.emitters;
7189
+ const emittersOptions = this.#container.actualOptions.emitters;
7096
7190
  if (isArray(emittersOptions)) {
7097
7191
  for (const emitterOptions of emittersOptions) {
7098
- await this._instancesManager.addEmitter(this.container, emitterOptions);
7192
+ await this.#instancesManager.addEmitter(this.#container, emitterOptions);
7099
7193
  }
7100
7194
  }
7101
7195
  else {
7102
- await this._instancesManager.addEmitter(this.container, emittersOptions);
7196
+ await this.#instancesManager.addEmitter(this.#container, emittersOptions);
7103
7197
  }
7104
7198
  }
7105
7199
  pause() {
7106
- for (const emitter of this._instancesManager.getArray(this.container)) {
7200
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
7107
7201
  emitter.pause();
7108
7202
  }
7109
7203
  }
7110
7204
  play() {
7111
- for (const emitter of this._instancesManager.getArray(this.container)) {
7205
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
7112
7206
  emitter.play();
7113
7207
  }
7114
7208
  }
7115
7209
  resize() {
7116
- for (const emitter of this._instancesManager.getArray(this.container)) {
7210
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
7117
7211
  emitter.resize();
7118
7212
  }
7119
7213
  }
7120
7214
  stop() {
7121
- this._instancesManager.clear(this.container);
7215
+ this.#instancesManager.clear(this.#container);
7122
7216
  }
7123
7217
  update(delta) {
7124
- this._instancesManager.getArray(this.container).forEach(emitter => {
7218
+ this.#instancesManager.getArray(this.#container).forEach(emitter => {
7125
7219
  emitter.update(delta);
7126
7220
  });
7127
7221
  }
@@ -7154,16 +7248,16 @@
7154
7248
 
7155
7249
  const defaultIndex = 0;
7156
7250
  class EmittersInstancesManager {
7157
- _containerArrays;
7158
- _pluginManager;
7251
+ #containerArrays;
7252
+ #pluginManager;
7159
7253
  constructor(pluginManager) {
7160
- this._containerArrays = new Map();
7161
- this._pluginManager = pluginManager;
7254
+ this.#containerArrays = new Map();
7255
+ this.#pluginManager = pluginManager;
7162
7256
  }
7163
7257
  async addEmitter(container, options, position) {
7164
7258
  const emitterOptions = new Emitter();
7165
7259
  emitterOptions.load(options);
7166
- const { EmitterInstance } = await Promise.resolve().then(function () { return EmitterInstance$1; }), emitter = new EmitterInstance(this._pluginManager, container, (emitter) => {
7260
+ const { EmitterInstance } = await Promise.resolve().then(function () { return EmitterInstance$1; }), emitter = new EmitterInstance(this.#pluginManager, container, (emitter) => {
7167
7261
  this.removeEmitter(container, emitter);
7168
7262
  }, emitterOptions, position);
7169
7263
  await emitter.init();
@@ -7172,22 +7266,22 @@
7172
7266
  }
7173
7267
  clear(container) {
7174
7268
  this.initContainer(container);
7175
- this._containerArrays.set(container, []);
7269
+ this.#containerArrays.set(container, []);
7176
7270
  }
7177
7271
  getArray(container) {
7178
7272
  this.initContainer(container);
7179
- let array = this._containerArrays.get(container);
7273
+ let array = this.#containerArrays.get(container);
7180
7274
  if (!array) {
7181
7275
  array = [];
7182
- this._containerArrays.set(container, array);
7276
+ this.#containerArrays.set(container, array);
7183
7277
  }
7184
7278
  return array;
7185
7279
  }
7186
7280
  initContainer(container) {
7187
- if (this._containerArrays.has(container)) {
7281
+ if (this.#containerArrays.has(container)) {
7188
7282
  return;
7189
7283
  }
7190
- this._containerArrays.set(container, []);
7284
+ this.#containerArrays.set(container, []);
7191
7285
  container.getEmitter = (idxOrName) => {
7192
7286
  const array = this.getArray(container);
7193
7287
  return idxOrName === undefined || isNumber(idxOrName)
@@ -7229,12 +7323,12 @@
7229
7323
 
7230
7324
  const defaultFactor = 1, defaultReduce = 1, disableReduce = 0, identity = 1;
7231
7325
  class MotionPluginInstance {
7232
- _container;
7326
+ #container;
7233
7327
  constructor(container) {
7234
- this._container = container;
7328
+ this.#container = container;
7235
7329
  }
7236
7330
  async init() {
7237
- const container = this._container, options = container.actualOptions.motion;
7331
+ const container = this.#container, options = container.actualOptions.motion;
7238
7332
  if (!(options && (options.disable || options.reduce.value))) {
7239
7333
  container.retina.reduceFactor = 1;
7240
7334
  return;
@@ -7244,10 +7338,10 @@
7244
7338
  container.retina.reduceFactor = defaultFactor;
7245
7339
  return;
7246
7340
  }
7247
- this._handleMotionChange(mediaQuery);
7341
+ this.#handleMotionChange(mediaQuery);
7248
7342
  const handleChange = () => {
7249
7343
  void (async () => {
7250
- this._handleMotionChange(mediaQuery);
7344
+ this.#handleMotionChange(mediaQuery);
7251
7345
  try {
7252
7346
  await container.refresh();
7253
7347
  }
@@ -7258,8 +7352,8 @@
7258
7352
  mediaQuery.addEventListener("change", handleChange);
7259
7353
  await Promise.resolve();
7260
7354
  }
7261
- _handleMotionChange = mediaQuery => {
7262
- const container = this._container, motion = container.actualOptions.motion;
7355
+ #handleMotionChange = mediaQuery => {
7356
+ const container = this.#container, motion = container.actualOptions.motion;
7263
7357
  if (!motion) {
7264
7358
  return;
7265
7359
  }
@@ -7311,34 +7405,34 @@
7311
7405
  spawnStrokeColor;
7312
7406
  spawnStrokeOpacity;
7313
7407
  spawnStrokeWidth;
7314
- _container;
7315
- _currentDuration;
7316
- _currentEmitDelay;
7317
- _currentSpawnDelay;
7318
- _duration;
7319
- _emitDelay;
7320
- _firstSpawn;
7321
- _immortal;
7322
- _initialPosition;
7323
- _lifeCount;
7324
- _mutationObserver;
7325
- _particlesOptions;
7326
- _paused;
7327
- _pluginManager;
7328
- _removeCallback;
7329
- _resizeObserver;
7330
- _shape;
7331
- _size;
7332
- _spawnDelay;
7333
- _startParticlesAdded;
7408
+ #container;
7409
+ #currentDuration;
7410
+ #currentEmitDelay;
7411
+ #currentSpawnDelay;
7412
+ #duration;
7413
+ #emitDelay;
7414
+ #firstSpawn;
7415
+ #immortal;
7416
+ #initialPosition;
7417
+ #lifeCount;
7418
+ #mutationObserver;
7419
+ #particlesOptions;
7420
+ #paused;
7421
+ #pluginManager;
7422
+ #removeCallback;
7423
+ #resizeObserver;
7424
+ #shape;
7425
+ #size;
7426
+ #spawnDelay;
7427
+ #startParticlesAdded;
7334
7428
  constructor(pluginManager, container, removeCallback, options, position) {
7335
- this._pluginManager = pluginManager;
7336
- this._container = container;
7337
- this._removeCallback = removeCallback;
7338
- this._currentDuration = 0;
7339
- this._currentEmitDelay = 0;
7340
- this._currentSpawnDelay = 0;
7341
- this._initialPosition = position;
7429
+ this.#pluginManager = pluginManager;
7430
+ this.#container = container;
7431
+ this.#removeCallback = removeCallback;
7432
+ this.#currentDuration = 0;
7433
+ this.#currentEmitDelay = 0;
7434
+ this.#currentSpawnDelay = 0;
7435
+ this.#initialPosition = position;
7342
7436
  if (options instanceof Emitter) {
7343
7437
  this.options = options;
7344
7438
  }
@@ -7346,159 +7440,159 @@
7346
7440
  this.options = new Emitter();
7347
7441
  this.options.load(options);
7348
7442
  }
7349
- this._spawnDelay = container.retina.reduceFactor
7443
+ this.#spawnDelay = container.retina.reduceFactor
7350
7444
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
7351
7445
  container.retina.reduceFactor
7352
7446
  : Infinity;
7353
- this.position = this._initialPosition ?? this._calcPosition();
7447
+ this.position = this.#initialPosition ?? this.#calcPosition();
7354
7448
  this.name = this.options.name;
7355
7449
  this.fill = this.options.fill;
7356
- this._firstSpawn = !this.options.life.wait;
7357
- this._startParticlesAdded = false;
7450
+ this.#firstSpawn = !this.options.life.wait;
7451
+ this.#startParticlesAdded = false;
7358
7452
  const particlesOptions = deepExtend({}, this.options.particles);
7359
7453
  particlesOptions.move ??= {};
7360
7454
  particlesOptions.move.direction ??= this.options.direction;
7361
7455
  if (this.options.spawn.fill?.color) {
7362
- this.spawnFillColor = rangeColorToHsl(this._pluginManager, this.options.spawn.fill.color);
7456
+ this.spawnFillColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.fill.color);
7363
7457
  }
7364
7458
  if (this.options.spawn.stroke?.color) {
7365
- this.spawnStrokeColor = rangeColorToHsl(this._pluginManager, this.options.spawn.stroke.color);
7366
- }
7367
- this._paused = !this.options.autoPlay;
7368
- this._particlesOptions = particlesOptions;
7369
- this._size = this._calcSize();
7370
- this.size = getSize(this._size, this._container.canvas.size);
7371
- this._lifeCount = this.options.life.count ?? defaultLifeCount;
7372
- this._immortal = this._lifeCount <= minLifeCount;
7459
+ this.spawnStrokeColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.stroke.color);
7460
+ }
7461
+ this.#paused = !this.options.autoPlay;
7462
+ this.#particlesOptions = particlesOptions;
7463
+ this.#size = this.#calcSize();
7464
+ this.size = getSize(this.#size, this.#container.canvas.size);
7465
+ this.#lifeCount = this.options.life.count ?? defaultLifeCount;
7466
+ this.#immortal = this.#lifeCount <= minLifeCount;
7373
7467
  if (this.options.domId) {
7374
7468
  const element = safeDocument().getElementById(this.options.domId);
7375
7469
  if (element) {
7376
- this._mutationObserver = new MutationObserver(() => {
7470
+ this.#mutationObserver = new MutationObserver(() => {
7377
7471
  this.resize();
7378
7472
  });
7379
- this._resizeObserver = new ResizeObserver(() => {
7473
+ this.#resizeObserver = new ResizeObserver(() => {
7380
7474
  this.resize();
7381
7475
  });
7382
- this._mutationObserver.observe(element, {
7476
+ this.#mutationObserver.observe(element, {
7383
7477
  attributes: true,
7384
7478
  attributeFilter: ["style", "width", "height"],
7385
7479
  });
7386
- this._resizeObserver.observe(element);
7480
+ this.#resizeObserver.observe(element);
7387
7481
  }
7388
7482
  }
7389
- const shapeOptions = this.options.shape, shapeGenerator = this._pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
7483
+ const shapeOptions = this.options.shape, shapeGenerator = this.#pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
7390
7484
  if (shapeGenerator) {
7391
- this._shape = shapeGenerator.generate(this._container, this.position, this.size, this.fill, shapeOptions.options);
7485
+ this.#shape = shapeGenerator.generate(this.#container, this.position, this.size, this.fill, shapeOptions.options);
7392
7486
  }
7393
- this._container.dispatchEvent("emitterCreated", {
7487
+ this.#container.dispatchEvent("emitterCreated", {
7394
7488
  emitter: this,
7395
7489
  });
7396
7490
  this.play();
7397
7491
  }
7398
7492
  externalPause() {
7399
- this._paused = true;
7493
+ this.#paused = true;
7400
7494
  this.pause();
7401
7495
  }
7402
7496
  externalPlay() {
7403
- this._paused = false;
7497
+ this.#paused = false;
7404
7498
  this.play();
7405
7499
  }
7406
7500
  async init() {
7407
- await this._shape?.init();
7501
+ await this.#shape?.init();
7408
7502
  }
7409
7503
  pause() {
7410
- if (this._paused) {
7504
+ if (this.#paused) {
7411
7505
  return;
7412
7506
  }
7413
- delete this._emitDelay;
7507
+ this.#emitDelay = undefined;
7414
7508
  }
7415
7509
  play() {
7416
- if (this._paused) {
7510
+ if (this.#paused) {
7417
7511
  return;
7418
7512
  }
7419
- if (!((this._lifeCount > minLifeCount || this._immortal || !this.options.life.count) &&
7420
- (this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? defaultSpawnDelay)))) {
7513
+ if (!((this.#lifeCount > minLifeCount || this.#immortal || !this.options.life.count) &&
7514
+ (this.#firstSpawn || this.#currentSpawnDelay >= (this.#spawnDelay ?? defaultSpawnDelay)))) {
7421
7515
  return;
7422
7516
  }
7423
- const container = this._container;
7424
- if (this._emitDelay === undefined) {
7517
+ const container = this.#container;
7518
+ if (this.#emitDelay === undefined) {
7425
7519
  const delay = getRangeValue(this.options.rate.delay);
7426
- this._emitDelay = container.retina.reduceFactor
7520
+ this.#emitDelay = container.retina.reduceFactor
7427
7521
  ? (delay * millisecondsToSeconds) / container.retina.reduceFactor
7428
7522
  : Infinity;
7429
7523
  }
7430
- if (this._lifeCount > minLifeCount || this._immortal) {
7431
- this._prepareToDie();
7524
+ if (this.#lifeCount > minLifeCount || this.#immortal) {
7525
+ this.#prepareToDie();
7432
7526
  }
7433
7527
  }
7434
7528
  resize() {
7435
- const initialPosition = this._initialPosition, container = this._container;
7529
+ const initialPosition = this.#initialPosition, container = this.#container;
7436
7530
  this.position =
7437
7531
  initialPosition && isPointInside(initialPosition, container.canvas.size, Vector.origin)
7438
7532
  ? initialPosition
7439
- : this._calcPosition();
7440
- this._size = this._calcSize();
7441
- this.size = getSize(this._size, container.canvas.size);
7442
- this._shape?.resize(this.position, this.size);
7533
+ : this.#calcPosition();
7534
+ this.#size = this.#calcSize();
7535
+ this.size = getSize(this.#size, container.canvas.size);
7536
+ this.#shape?.resize(this.position, this.size);
7443
7537
  }
7444
7538
  update(delta) {
7445
- if (this._paused) {
7539
+ if (this.#paused) {
7446
7540
  return;
7447
7541
  }
7448
- const container = this._container;
7449
- if (this._firstSpawn) {
7450
- this._firstSpawn = false;
7451
- this._currentSpawnDelay = this._spawnDelay ?? defaultSpawnDelay;
7452
- this._currentEmitDelay = this._emitDelay ?? defaultEmitDelay;
7542
+ const container = this.#container;
7543
+ if (this.#firstSpawn) {
7544
+ this.#firstSpawn = false;
7545
+ this.#currentSpawnDelay = this.#spawnDelay ?? defaultSpawnDelay;
7546
+ this.#currentEmitDelay = this.#emitDelay ?? defaultEmitDelay;
7453
7547
  }
7454
- if (!this._startParticlesAdded) {
7455
- this._startParticlesAdded = true;
7456
- this._emitParticles(this.options.startCount);
7548
+ if (!this.#startParticlesAdded) {
7549
+ this.#startParticlesAdded = true;
7550
+ this.#emitParticles(this.options.startCount);
7457
7551
  }
7458
- if (this._duration !== undefined) {
7459
- this._currentDuration += delta.value;
7460
- if (this._currentDuration >= this._duration) {
7552
+ if (this.#duration !== undefined) {
7553
+ this.#currentDuration += delta.value;
7554
+ if (this.#currentDuration >= this.#duration) {
7461
7555
  this.pause();
7462
- if (this._spawnDelay !== undefined) {
7463
- delete this._spawnDelay;
7556
+ if (this.#spawnDelay !== undefined) {
7557
+ this.#spawnDelay = undefined;
7464
7558
  }
7465
- if (!this._immortal) {
7466
- this._lifeCount--;
7559
+ if (!this.#immortal) {
7560
+ this.#lifeCount--;
7467
7561
  }
7468
- if (this._lifeCount > minLifeCount || this._immortal) {
7469
- this.position = this._calcPosition();
7470
- this._shape?.resize(this.position, this.size);
7471
- this._spawnDelay = container.retina.reduceFactor
7562
+ if (this.#lifeCount > minLifeCount || this.#immortal) {
7563
+ this.position = this.#calcPosition();
7564
+ this.#shape?.resize(this.position, this.size);
7565
+ this.#spawnDelay = container.retina.reduceFactor
7472
7566
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
7473
7567
  container.retina.reduceFactor
7474
7568
  : Infinity;
7475
7569
  }
7476
7570
  else {
7477
- this._destroy();
7571
+ this.#destroy();
7478
7572
  }
7479
- this._currentDuration -= this._duration;
7480
- delete this._duration;
7573
+ this.#currentDuration -= this.#duration;
7574
+ this.#duration = undefined;
7481
7575
  }
7482
7576
  }
7483
- if (this._spawnDelay !== undefined) {
7484
- this._currentSpawnDelay += delta.value;
7485
- if (this._currentSpawnDelay >= this._spawnDelay) {
7486
- this._container.dispatchEvent("emitterPlay");
7577
+ if (this.#spawnDelay !== undefined) {
7578
+ this.#currentSpawnDelay += delta.value;
7579
+ if (this.#currentSpawnDelay >= this.#spawnDelay) {
7580
+ this.#container.dispatchEvent("emitterPlay");
7487
7581
  this.play();
7488
- this._currentSpawnDelay -= this._spawnDelay;
7489
- delete this._spawnDelay;
7582
+ this.#currentSpawnDelay -= this.#spawnDelay;
7583
+ this.#spawnDelay = undefined;
7490
7584
  }
7491
7585
  }
7492
- if (this._emitDelay !== undefined) {
7493
- this._currentEmitDelay += delta.value;
7494
- if (this._currentEmitDelay >= this._emitDelay) {
7495
- this._emit();
7496
- this._currentEmitDelay -= this._emitDelay;
7586
+ if (this.#emitDelay !== undefined) {
7587
+ this.#currentEmitDelay += delta.value;
7588
+ if (this.#currentEmitDelay >= this.#emitDelay) {
7589
+ this.#emit();
7590
+ this.#currentEmitDelay -= this.#emitDelay;
7497
7591
  }
7498
7592
  }
7499
7593
  }
7500
- _calcPosition() {
7501
- const container = this._container;
7594
+ #calcPosition() {
7595
+ const container = this.#container;
7502
7596
  if (this.options.domId) {
7503
7597
  const element = safeDocument().getElementById(this.options.domId);
7504
7598
  if (element) {
@@ -7514,8 +7608,8 @@
7514
7608
  position: this.options.position,
7515
7609
  });
7516
7610
  }
7517
- _calcSize() {
7518
- const container = this._container;
7611
+ #calcSize() {
7612
+ const container = this.#container;
7519
7613
  if (this.options.domId) {
7520
7614
  const element = safeDocument().getElementById(this.options.domId);
7521
7615
  if (element) {
@@ -7538,32 +7632,32 @@
7538
7632
  return size;
7539
7633
  })());
7540
7634
  }
7541
- _destroy = () => {
7542
- this._mutationObserver?.disconnect();
7543
- this._mutationObserver = undefined;
7544
- this._resizeObserver?.disconnect();
7545
- this._resizeObserver = undefined;
7546
- this._removeCallback(this);
7547
- this._container.dispatchEvent("emitterDestroyed", {
7635
+ #destroy = () => {
7636
+ this.#mutationObserver?.disconnect();
7637
+ this.#mutationObserver = undefined;
7638
+ this.#resizeObserver?.disconnect();
7639
+ this.#resizeObserver = undefined;
7640
+ this.#removeCallback(this);
7641
+ this.#container.dispatchEvent("emitterDestroyed", {
7548
7642
  emitter: this,
7549
7643
  });
7550
7644
  };
7551
- _emit() {
7552
- if (this._paused) {
7645
+ #emit() {
7646
+ if (this.#paused) {
7553
7647
  return;
7554
7648
  }
7555
7649
  const quantity = getRangeValue(this.options.rate.quantity);
7556
- this._emitParticles(quantity);
7650
+ this.#emitParticles(quantity);
7557
7651
  }
7558
- _emitParticles(quantity) {
7559
- const singleParticlesOptions = (itemFromSingleOrMultiple(this._particlesOptions) ??
7652
+ #emitParticles(quantity) {
7653
+ const singleParticlesOptions = (itemFromSingleOrMultiple(this.#particlesOptions) ??
7560
7654
  {}), 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
7561
7655
  ? defaultOpacity$1
7562
7656
  : getRangeValue(this.options.spawn.fill.opacity), strokeHslAnimation = this.options.spawn.stroke?.color?.animation, strokeOpacity = this.options.spawn.stroke?.opacity === undefined
7563
7657
  ? defaultOpacity$1
7564
7658
  : getRangeValue(this.options.spawn.stroke.opacity), strokeWidth = this.options.spawn.stroke?.width === undefined
7565
7659
  ? defaultStrokeWidth
7566
- : 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;
7660
+ : 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;
7567
7661
  for (let i = 0; i < quantity * reduceFactor; i++) {
7568
7662
  const particlesOptions = needsCopy
7569
7663
  ? deepExtend({}, singleParticlesOptions)
@@ -7574,23 +7668,23 @@
7574
7668
  this.spawnStrokeWidth = strokeWidth;
7575
7669
  if (this.spawnFillColor) {
7576
7670
  if (fillHslAnimation && maxValues) {
7577
- this.spawnFillColor.h = this._setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
7578
- this.spawnFillColor.s = this._setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
7579
- this.spawnFillColor.l = this._setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
7671
+ this.spawnFillColor.h = this.#setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
7672
+ this.spawnFillColor.s = this.#setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
7673
+ this.spawnFillColor.l = this.#setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
7580
7674
  }
7581
7675
  setParticlesOptionsFillColor(particlesOptions, this.spawnFillColor, this.spawnFillOpacity, this.spawnFillEnabled);
7582
7676
  }
7583
7677
  if (this.spawnStrokeColor) {
7584
7678
  if (strokeHslAnimation && maxValues) {
7585
- this.spawnStrokeColor.h = this._setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
7586
- this.spawnStrokeColor.s = this._setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
7587
- this.spawnStrokeColor.l = this._setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
7679
+ this.spawnStrokeColor.h = this.#setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
7680
+ this.spawnStrokeColor.s = this.#setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
7681
+ this.spawnStrokeColor.l = this.#setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
7588
7682
  }
7589
7683
  setParticlesOptionsStrokeColor(particlesOptions, this.spawnStrokeColor, this.spawnStrokeOpacity, this.spawnStrokeWidth);
7590
7684
  }
7591
7685
  let position = this.position;
7592
- if (this._shape) {
7593
- const shapePosData = this._shape.randomPosition();
7686
+ if (this.#shape) {
7687
+ const shapePosData = this.#shape.randomPosition();
7594
7688
  if (shapePosData) {
7595
7689
  position = shapePosData.position;
7596
7690
  const replaceData = shapeOptions.replace;
@@ -7603,21 +7697,21 @@
7603
7697
  }
7604
7698
  }
7605
7699
  if (position) {
7606
- this._container.particles.addParticle(position, particlesOptions);
7700
+ this.#container.particles.addParticle(position, particlesOptions);
7607
7701
  }
7608
7702
  }
7609
7703
  }
7610
- _prepareToDie = () => {
7611
- if (this._paused) {
7704
+ #prepareToDie = () => {
7705
+ if (this.#paused) {
7612
7706
  return;
7613
7707
  }
7614
7708
  const duration = this.options.life.duration !== undefined ? getRangeValue(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
7615
- if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
7616
- this._duration = duration * millisecondsToSeconds;
7709
+ if ((this.#lifeCount > minLifeCount || this.#immortal) && duration !== undefined && duration > minDuration) {
7710
+ this.#duration = duration * millisecondsToSeconds;
7617
7711
  }
7618
7712
  };
7619
- _setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
7620
- const container = this._container;
7713
+ #setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
7714
+ const container = this.#container;
7621
7715
  if (!animation.enable) {
7622
7716
  return initValue;
7623
7717
  }