@tsparticles/preset-squares 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
  }
@@ -713,38 +713,38 @@
713
713
  }
714
714
 
715
715
  class EventDispatcher {
716
- _listeners;
716
+ #listeners;
717
717
  constructor() {
718
- this._listeners = new Map();
718
+ this.#listeners = new Map();
719
719
  }
720
720
  addEventListener(type, listener) {
721
721
  this.removeEventListener(type, listener);
722
- let arr = this._listeners.get(type);
722
+ let arr = this.#listeners.get(type);
723
723
  if (!arr) {
724
724
  arr = [];
725
- this._listeners.set(type, arr);
725
+ this.#listeners.set(type, arr);
726
726
  }
727
727
  arr.push(listener);
728
728
  }
729
729
  dispatchEvent(type, args) {
730
- const listeners = this._listeners.get(type);
730
+ const listeners = this.#listeners.get(type);
731
731
  listeners?.forEach(handler => {
732
732
  handler(args);
733
733
  });
734
734
  }
735
735
  hasEventListener(type) {
736
- return !!this._listeners.get(type);
736
+ return !!this.#listeners.get(type);
737
737
  }
738
738
  removeAllEventListeners(type) {
739
739
  if (!type) {
740
- this._listeners = new Map();
740
+ this.#listeners = new Map();
741
741
  }
742
742
  else {
743
- this._listeners.delete(type);
743
+ this.#listeners.delete(type);
744
744
  }
745
745
  }
746
746
  removeEventListener(type, listener) {
747
- const arr = this._listeners.get(type);
747
+ const arr = this.#listeners.get(type);
748
748
  if (!arr) {
749
749
  return;
750
750
  }
@@ -753,7 +753,7 @@
753
753
  return;
754
754
  }
755
755
  if (length === deleteCount) {
756
- this._listeners.delete(type);
756
+ this.#listeners.delete(type);
757
757
  }
758
758
  else {
759
759
  arr.splice(idx, deleteCount);
@@ -791,19 +791,19 @@
791
791
  presets = new Map();
792
792
  shapeDrawers = new Map();
793
793
  updaters = new Map();
794
- _allLoadersSet = new Set();
795
- _configs = new Map();
796
- _engine;
797
- _executedSet = new Set();
798
- _initialized = false;
799
- _isRunningLoaders = false;
800
- _loadPromises = new Set();
794
+ #allLoadersSet = new Set();
795
+ #configs = new Map();
796
+ #engine;
797
+ #executedSet = new Set();
798
+ #initialized = false;
799
+ #isRunningLoaders = false;
800
+ #loadPromises = new Set();
801
801
  constructor(engine) {
802
- this._engine = engine;
802
+ this.#engine = engine;
803
803
  }
804
804
  get configs() {
805
805
  const res = {};
806
- for (const [name, config] of this._configs) {
806
+ for (const [name, config] of this.#configs) {
807
807
  res[name] = config;
808
808
  }
809
809
  return res;
@@ -813,8 +813,8 @@
813
813
  }
814
814
  addConfig(config) {
815
815
  const key = config.key ?? config.name ?? "default";
816
- this._configs.set(key, config);
817
- this._engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
816
+ this.#configs.set(key, config);
817
+ this.#engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
818
818
  }
819
819
  addEasing(name, easing) {
820
820
  if (this.easingFunctions.get(name)) {
@@ -875,21 +875,21 @@
875
875
  return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
876
876
  }
877
877
  async init() {
878
- if (this._initialized || this._isRunningLoaders) {
878
+ if (this.#initialized || this.#isRunningLoaders) {
879
879
  return;
880
880
  }
881
- this._isRunningLoaders = true;
882
- this._executedSet = new Set();
883
- this._allLoadersSet = new Set(this._loadPromises);
881
+ this.#isRunningLoaders = true;
882
+ this.#executedSet = new Set();
883
+ this.#allLoadersSet = new Set(this.#loadPromises);
884
884
  try {
885
- for (const loader of this._allLoadersSet) {
886
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
885
+ for (const loader of this.#allLoadersSet) {
886
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
887
887
  }
888
888
  }
889
889
  finally {
890
- this._loadPromises.clear();
891
- this._isRunningLoaders = false;
892
- this._initialized = true;
890
+ this.#loadPromises.clear();
891
+ this.#isRunningLoaders = false;
892
+ this.#initialized = true;
893
893
  }
894
894
  }
895
895
  loadParticlesOptions(container, options, ...sourceOptions) {
@@ -900,24 +900,24 @@
900
900
  updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
901
901
  }
902
902
  async register(...loaders) {
903
- if (this._initialized) {
903
+ if (this.#initialized) {
904
904
  throw new Error("Register plugins can only be done before calling tsParticles.load()");
905
905
  }
906
906
  for (const loader of loaders) {
907
- if (this._isRunningLoaders) {
908
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
907
+ if (this.#isRunningLoaders) {
908
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
909
909
  }
910
910
  else {
911
- this._loadPromises.add(loader);
911
+ this.#loadPromises.add(loader);
912
912
  }
913
913
  }
914
914
  }
915
- async _runLoader(loader, executed, allLoaders) {
915
+ async #runLoader(loader, executed, allLoaders) {
916
916
  if (executed.has(loader))
917
917
  return;
918
918
  executed.add(loader);
919
919
  allLoaders.add(loader);
920
- await loader(this._engine);
920
+ await loader(this.#engine);
921
921
  }
922
922
  }
923
923
 
@@ -997,17 +997,17 @@
997
997
  };
998
998
  class Engine {
999
999
  pluginManager = new PluginManager(this);
1000
- _domArray = [];
1001
- _eventDispatcher = new EventDispatcher();
1002
- _initialized = false;
1000
+ #domArray = [];
1001
+ #eventDispatcher = new EventDispatcher();
1002
+ #initialized = false;
1003
1003
  get items() {
1004
- return this._domArray;
1004
+ return this.#domArray;
1005
1005
  }
1006
1006
  get version() {
1007
- return "4.0.4";
1007
+ return "4.1.0";
1008
1008
  }
1009
1009
  addEventListener(type, listener) {
1010
- this._eventDispatcher.addEventListener(type, listener);
1010
+ this.#eventDispatcher.addEventListener(type, listener);
1011
1011
  }
1012
1012
  checkVersion(pluginVersion) {
1013
1013
  if (this.version === pluginVersion) {
@@ -1016,17 +1016,17 @@
1016
1016
  throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
1017
1017
  }
1018
1018
  dispatchEvent(type, args) {
1019
- this._eventDispatcher.dispatchEvent(type, args);
1019
+ this.#eventDispatcher.dispatchEvent(type, args);
1020
1020
  }
1021
1021
  async init() {
1022
- if (this._initialized) {
1022
+ if (this.#initialized) {
1023
1023
  return;
1024
1024
  }
1025
1025
  await this.pluginManager.init();
1026
- this._initialized = true;
1026
+ this.#initialized = true;
1027
1027
  }
1028
1028
  item(index) {
1029
- const { items } = this, item = items[index];
1029
+ const items = this.items, item = items[index];
1030
1030
  if (item?.destroyed) {
1031
1031
  items.splice(index, removeDeleteCount);
1032
1032
  return;
@@ -1080,7 +1080,7 @@
1080
1080
  await Promise.all(this.items.map(t => t.refresh()));
1081
1081
  }
1082
1082
  removeEventListener(type, listener) {
1083
- this._eventDispatcher.removeEventListener(type, listener);
1083
+ this.#eventDispatcher.removeEventListener(type, listener);
1084
1084
  }
1085
1085
  }
1086
1086
 
@@ -1851,43 +1851,6 @@
1851
1851
  }
1852
1852
  }
1853
1853
 
1854
- class OpacityAnimation extends RangedAnimationOptions {
1855
- destroy;
1856
- constructor() {
1857
- super();
1858
- this.destroy = DestroyType.none;
1859
- this.speed = 2;
1860
- }
1861
- load(data) {
1862
- super.load(data);
1863
- if (isNull(data)) {
1864
- return;
1865
- }
1866
- if (data.destroy !== undefined) {
1867
- this.destroy = data.destroy;
1868
- }
1869
- }
1870
- }
1871
-
1872
- class Opacity extends RangedAnimationValueWithRandom {
1873
- animation;
1874
- constructor() {
1875
- super();
1876
- this.animation = new OpacityAnimation();
1877
- this.value = 1;
1878
- }
1879
- load(data) {
1880
- if (isNull(data)) {
1881
- return;
1882
- }
1883
- super.load(data);
1884
- const animation = data.animation;
1885
- if (animation !== undefined) {
1886
- this.animation.load(animation);
1887
- }
1888
- }
1889
- }
1890
-
1891
1854
  class Stroke {
1892
1855
  color;
1893
1856
  opacity;
@@ -2055,43 +2018,6 @@
2055
2018
  }
2056
2019
  }
2057
2020
 
2058
- class SizeAnimation extends RangedAnimationOptions {
2059
- destroy;
2060
- constructor() {
2061
- super();
2062
- this.destroy = DestroyType.none;
2063
- this.speed = 5;
2064
- }
2065
- load(data) {
2066
- super.load(data);
2067
- if (isNull(data)) {
2068
- return;
2069
- }
2070
- if (data.destroy !== undefined) {
2071
- this.destroy = data.destroy;
2072
- }
2073
- }
2074
- }
2075
-
2076
- class Size extends RangedAnimationValueWithRandom {
2077
- animation;
2078
- constructor() {
2079
- super();
2080
- this.animation = new SizeAnimation();
2081
- this.value = 3;
2082
- }
2083
- load(data) {
2084
- super.load(data);
2085
- if (isNull(data)) {
2086
- return;
2087
- }
2088
- const animation = data.animation;
2089
- if (animation !== undefined) {
2090
- this.animation.load(animation);
2091
- }
2092
- }
2093
- }
2094
-
2095
2021
  class ZIndex extends ValueWithRandom {
2096
2022
  opacityRate;
2097
2023
  sizeRate;
@@ -2125,24 +2051,21 @@
2125
2051
  groups;
2126
2052
  move;
2127
2053
  number;
2128
- opacity;
2129
2054
  paint;
2130
2055
  palette;
2131
2056
  reduceDuplicates;
2132
2057
  shape;
2133
- size;
2134
2058
  zIndex;
2135
- _container;
2136
- _pluginManager;
2059
+ #container;
2060
+ #pluginManager;
2137
2061
  constructor(pluginManager, container) {
2138
- this._pluginManager = pluginManager;
2139
- this._container = container;
2062
+ this.#pluginManager = pluginManager;
2063
+ this.#container = container;
2140
2064
  this.bounce = new ParticlesBounce();
2141
2065
  this.effect = new Effect();
2142
2066
  this.groups = {};
2143
2067
  this.move = new Move();
2144
2068
  this.number = new ParticlesNumber();
2145
- this.opacity = new Opacity();
2146
2069
  this.paint = new Paint();
2147
2070
  this.paint.color = new AnimatableColor();
2148
2071
  this.paint.color.value = "#fff";
@@ -2150,7 +2073,6 @@
2150
2073
  this.paint.fill.enable = true;
2151
2074
  this.reduceDuplicates = false;
2152
2075
  this.shape = new Shape();
2153
- this.size = new Size();
2154
2076
  this.zIndex = new ZIndex();
2155
2077
  }
2156
2078
  load(data) {
@@ -2159,7 +2081,7 @@
2159
2081
  }
2160
2082
  if (data.palette) {
2161
2083
  this.palette = data.palette;
2162
- this._importPalette(this.palette);
2084
+ this.#importPalette(this.palette);
2163
2085
  }
2164
2086
  if (data.groups !== undefined) {
2165
2087
  for (const group of Object.keys(data.groups)) {
@@ -2179,7 +2101,6 @@
2179
2101
  this.effect.load(data.effect);
2180
2102
  this.move.load(data.move);
2181
2103
  this.number.load(data.number);
2182
- this.opacity.load(data.opacity);
2183
2104
  const paintToLoad = data.paint;
2184
2105
  if (paintToLoad) {
2185
2106
  if (isArray(paintToLoad)) {
@@ -2198,15 +2119,14 @@
2198
2119
  }
2199
2120
  }
2200
2121
  this.shape.load(data.shape);
2201
- this.size.load(data.size);
2202
2122
  this.zIndex.load(data.zIndex);
2203
- if (this._container) {
2204
- for (const plugin of this._pluginManager.plugins) {
2123
+ if (this.#container) {
2124
+ for (const plugin of this.#pluginManager.plugins) {
2205
2125
  if (plugin.loadParticlesOptions) {
2206
- plugin.loadParticlesOptions(this._container, this, data);
2126
+ plugin.loadParticlesOptions(this.#container, this, data);
2207
2127
  }
2208
2128
  }
2209
- const updaters = this._pluginManager.updaters.get(this._container);
2129
+ const updaters = this.#pluginManager.updaters.get(this.#container);
2210
2130
  if (updaters) {
2211
2131
  for (const updater of updaters) {
2212
2132
  if (updater.loadOptions) {
@@ -2216,8 +2136,8 @@
2216
2136
  }
2217
2137
  }
2218
2138
  }
2219
- _importPalette = (palette) => {
2220
- const paletteData = this._pluginManager.getPalette(palette);
2139
+ #importPalette = (palette) => {
2140
+ const paletteData = this.#pluginManager.getPalette(palette);
2221
2141
  if (!paletteData) {
2222
2142
  return;
2223
2143
  }
@@ -2296,11 +2216,11 @@
2296
2216
  smooth;
2297
2217
  style;
2298
2218
  zLayers;
2299
- _container;
2300
- _pluginManager;
2219
+ #container;
2220
+ #pluginManager;
2301
2221
  constructor(pluginManager, container) {
2302
- this._pluginManager = pluginManager;
2303
- this._container = container;
2222
+ this.#pluginManager = pluginManager;
2223
+ this.#container = container;
2304
2224
  this.autoPlay = true;
2305
2225
  this.background = new Background();
2306
2226
  this.clear = true;
@@ -2311,7 +2231,7 @@
2311
2231
  this.duration = 0;
2312
2232
  this.fpsLimit = 120;
2313
2233
  this.hdr = true;
2314
- this.particles = loadParticlesOptions(this._pluginManager, this._container);
2234
+ this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2315
2235
  this.pauseOnBlur = true;
2316
2236
  this.pauseOnOutsideViewport = true;
2317
2237
  this.resize = new ResizeEvent();
@@ -2326,12 +2246,12 @@
2326
2246
  if (data.preset !== undefined) {
2327
2247
  this.preset = data.preset;
2328
2248
  executeOnSingleOrMultiple(this.preset, preset => {
2329
- this._importPreset(preset);
2249
+ this.#importPreset(preset);
2330
2250
  });
2331
2251
  }
2332
2252
  if (data.palette !== undefined) {
2333
2253
  this.palette = data.palette;
2334
- this._importPalette(this.palette);
2254
+ this.#importPalette(this.palette);
2335
2255
  }
2336
2256
  if (data.autoPlay !== undefined) {
2337
2257
  this.autoPlay = data.autoPlay;
@@ -2385,12 +2305,12 @@
2385
2305
  if (data.smooth !== undefined) {
2386
2306
  this.smooth = data.smooth;
2387
2307
  }
2388
- this._pluginManager.plugins.forEach(plugin => {
2389
- plugin.loadOptions(this._container, this, data);
2308
+ this.#pluginManager.plugins.forEach(plugin => {
2309
+ plugin.loadOptions(this.#container, this, data);
2390
2310
  });
2391
2311
  }
2392
- _importPalette = palette => {
2393
- const paletteData = this._pluginManager.getPalette(palette);
2312
+ #importPalette = palette => {
2313
+ const paletteData = this.#pluginManager.getPalette(palette);
2394
2314
  if (!paletteData) {
2395
2315
  return;
2396
2316
  }
@@ -2407,8 +2327,8 @@
2407
2327
  },
2408
2328
  });
2409
2329
  };
2410
- _importPreset = preset => {
2411
- this.load(this._pluginManager.getPreset(preset));
2330
+ #importPreset = preset => {
2331
+ this.load(this.#pluginManager.getPreset(preset));
2412
2332
  };
2413
2333
  }
2414
2334
 
@@ -3031,13 +2951,13 @@
3031
2951
 
3032
2952
  class EmittersPlugin {
3033
2953
  id = "emitters";
3034
- _instancesManager;
2954
+ #instancesManager;
3035
2955
  constructor(instancesManager) {
3036
- this._instancesManager = instancesManager;
2956
+ this.#instancesManager = instancesManager;
3037
2957
  }
3038
2958
  async getPlugin(container) {
3039
2959
  const { EmittersPluginInstance } = await Promise.resolve().then(function () { return EmittersPluginInstance$1; });
3040
- return new EmittersPluginInstance(this._instancesManager, container);
2960
+ return new EmittersPluginInstance(this.#instancesManager, container);
3041
2961
  }
3042
2962
  loadOptions(_container, options, source) {
3043
2963
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
@@ -3090,7 +3010,7 @@
3090
3010
  })(EmitterClickMode || (EmitterClickMode = {}));
3091
3011
 
3092
3012
  async function loadEmittersPluginSimple(engine) {
3093
- engine.checkVersion("4.0.4");
3013
+ engine.checkVersion("4.1.0");
3094
3014
  await engine.pluginManager.register(async (e) => {
3095
3015
  const instancesManager = await getEmittersInstancesManager(e);
3096
3016
  await addEmittersShapesManager(e);
@@ -3111,15 +3031,15 @@
3111
3031
  return input.startsWith("#");
3112
3032
  }
3113
3033
  handleColor(color) {
3114
- return this._parseString(color.value);
3034
+ return this.#parseString(color.value);
3115
3035
  }
3116
3036
  handleRangeColor(color) {
3117
- return this._parseString(color.value);
3037
+ return this.#parseString(color.value);
3118
3038
  }
3119
3039
  parseString(input) {
3120
- return this._parseString(input);
3040
+ return this.#parseString(input);
3121
3041
  }
3122
- _parseString(hexColor) {
3042
+ #parseString(hexColor) {
3123
3043
  if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
3124
3044
  return;
3125
3045
  }
@@ -3138,7 +3058,7 @@
3138
3058
  }
3139
3059
 
3140
3060
  async function loadHexColorPlugin(engine) {
3141
- engine.checkVersion("4.0.4");
3061
+ engine.checkVersion("4.1.0");
3142
3062
  await engine.pluginManager.register(e => {
3143
3063
  e.pluginManager.addColorManager("hex", new HexColorManager());
3144
3064
  });
@@ -3146,20 +3066,20 @@
3146
3066
 
3147
3067
  const defaultOpacity = 1;
3148
3068
  class PaintUpdater {
3149
- _container;
3150
- _pluginManager;
3069
+ #container;
3070
+ #pluginManager;
3151
3071
  constructor(pluginManager, container) {
3152
- this._container = container;
3153
- this._pluginManager = pluginManager;
3072
+ this.#container = container;
3073
+ this.#pluginManager = pluginManager;
3154
3074
  }
3155
3075
  init(particle) {
3156
- 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;
3076
+ 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;
3157
3077
  if (fill) {
3158
3078
  const fillColor = AnimatableColor.create(paintColor === undefined ? undefined : AnimatableColor.create(undefined, paintColor), fill.color);
3159
3079
  particle.fillEnabled = fill.enable;
3160
3080
  particle.fillOpacity = getRangeValue(fill.opacity);
3161
3081
  particle.fillAnimation = fillColor.animation;
3162
- const fillHslColor = rangeColorToHsl(this._pluginManager, fillColor);
3082
+ const fillHslColor = rangeColorToHsl(this.#pluginManager, fillColor);
3163
3083
  if (fillHslColor) {
3164
3084
  particle.fillColor = getHslAnimationFromHsl(fillHslColor, particle.fillAnimation, container.retina.reduceFactor);
3165
3085
  }
@@ -3175,7 +3095,7 @@
3175
3095
  particle.strokeWidth = getRangeValue(stroke.width) * container.retina.pixelRatio;
3176
3096
  particle.strokeOpacity = getRangeValue(stroke.opacity ?? defaultOpacity);
3177
3097
  particle.strokeAnimation = strokeColor.animation;
3178
- const strokeHslColor = rangeColorToHsl(this._pluginManager, strokeColor) ?? particle.getFillColor();
3098
+ const strokeHslColor = rangeColorToHsl(this.#pluginManager, strokeColor) ?? particle.getFillColor();
3179
3099
  if (strokeHslColor) {
3180
3100
  particle.strokeColor = getHslAnimationFromHsl(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
3181
3101
  }
@@ -3207,7 +3127,7 @@
3207
3127
  }
3208
3128
 
3209
3129
  async function loadPaintUpdater(engine) {
3210
- engine.checkVersion("4.0.4");
3130
+ engine.checkVersion("4.1.0");
3211
3131
  await engine.pluginManager.register(e => {
3212
3132
  e.pluginManager.addParticleUpdater("paint", container => {
3213
3133
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3273,9 +3193,9 @@
3273
3193
 
3274
3194
  const doublePIDeg = 360;
3275
3195
  class RotateUpdater {
3276
- container;
3196
+ #container;
3277
3197
  constructor(container) {
3278
- this.container = container;
3198
+ this.#container = container;
3279
3199
  }
3280
3200
  init(particle) {
3281
3201
  const rotateOptions = particle.options.rotate;
@@ -3307,7 +3227,7 @@
3307
3227
  if (rotateAnimation.enable) {
3308
3228
  particle.rotate.decay = identity - getRangeValue(rotateAnimation.decay);
3309
3229
  particle.rotate.velocity =
3310
- (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
3230
+ (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.#container.retina.reduceFactor;
3311
3231
  if (!rotateAnimation.sync) {
3312
3232
  particle.rotate.velocity *= getRandom();
3313
3233
  }
@@ -3341,7 +3261,7 @@
3341
3261
  }
3342
3262
 
3343
3263
  async function loadRotateUpdater(engine) {
3344
- engine.checkVersion("4.0.4");
3264
+ engine.checkVersion("4.1.0");
3345
3265
  await engine.pluginManager.register(e => {
3346
3266
  e.pluginManager.addParticleUpdater("rotate", container => {
3347
3267
  return Promise.resolve(new RotateUpdater(container));
@@ -3349,21 +3269,63 @@
3349
3269
  });
3350
3270
  }
3351
3271
 
3272
+ class SizeAnimation extends RangedAnimationOptions {
3273
+ destroy;
3274
+ constructor() {
3275
+ super();
3276
+ this.destroy = DestroyType.none;
3277
+ this.speed = 5;
3278
+ }
3279
+ load(data) {
3280
+ super.load(data);
3281
+ if (isNull(data)) {
3282
+ return;
3283
+ }
3284
+ if (data.destroy !== undefined) {
3285
+ this.destroy = data.destroy;
3286
+ }
3287
+ }
3288
+ }
3289
+
3290
+ class Size extends RangedAnimationValueWithRandom {
3291
+ animation;
3292
+ constructor() {
3293
+ super();
3294
+ this.animation = new SizeAnimation();
3295
+ this.value = 3;
3296
+ }
3297
+ load(data) {
3298
+ super.load(data);
3299
+ if (isNull(data)) {
3300
+ return;
3301
+ }
3302
+ const animation = data.animation;
3303
+ if (animation !== undefined) {
3304
+ this.animation.load(animation);
3305
+ }
3306
+ }
3307
+ }
3308
+
3352
3309
  const minLoops = 0;
3353
3310
  class SizeUpdater {
3354
- _container;
3311
+ #container;
3355
3312
  constructor(container) {
3356
- this._container = container;
3313
+ this.#container = container;
3357
3314
  }
3358
3315
  init(particle) {
3359
- const container = this._container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
3360
- if (sizeAnimation.enable) {
3361
- particle.size.velocity =
3362
- (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3363
- if (!sizeAnimation.sync) {
3364
- particle.size.velocity *= getRandom();
3365
- }
3316
+ const container = this.#container, sizeOptions = particle.options.size;
3317
+ if (!sizeOptions) {
3318
+ return;
3319
+ }
3320
+ const sizeAnimation = sizeOptions.animation;
3321
+ if (!sizeAnimation.enable) {
3322
+ return;
3323
+ }
3324
+ particle.size.velocity = (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3325
+ if (sizeAnimation.sync) {
3326
+ return;
3366
3327
  }
3328
+ particle.size.velocity *= getRandom();
3367
3329
  }
3368
3330
  isEnabled(particle) {
3369
3331
  return (!particle.destroyed &&
@@ -3373,12 +3335,26 @@
3373
3335
  ((particle.size.maxLoops ?? minLoops) > minLoops &&
3374
3336
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3375
3337
  }
3338
+ loadOptions(options, ...sources) {
3339
+ options.size ??= new Size();
3340
+ for (const source of sources) {
3341
+ options.size.load(source?.size);
3342
+ }
3343
+ }
3344
+ preInit(particle) {
3345
+ const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
3346
+ if (!sizeOptions) {
3347
+ return;
3348
+ }
3349
+ particle.size = initParticleNumericAnimationValue(sizeOptions, pxRatio);
3350
+ particle.retina.sizeAnimationSpeed = getRangeValue(sizeOptions.animation.speed) * pxRatio;
3351
+ }
3376
3352
  reset(particle) {
3377
3353
  particle.size.time = 0;
3378
3354
  particle.size.loops = 0;
3379
3355
  }
3380
3356
  update(particle, delta) {
3381
- if (!this.isEnabled(particle)) {
3357
+ if (!this.isEnabled(particle) || !particle.options.size) {
3382
3358
  return;
3383
3359
  }
3384
3360
  updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
@@ -3386,7 +3362,7 @@
3386
3362
  }
3387
3363
 
3388
3364
  async function loadSizeUpdater(engine) {
3389
- engine.checkVersion("4.0.4");
3365
+ engine.checkVersion("4.1.0");
3390
3366
  await engine.pluginManager.register(e => {
3391
3367
  e.pluginManager.addParticleUpdater("size", container => {
3392
3368
  return Promise.resolve(new SizeUpdater(container));
@@ -3410,7 +3386,7 @@
3410
3386
  }
3411
3387
 
3412
3388
  async function loadSquareShape(engine) {
3413
- engine.checkVersion("4.0.4");
3389
+ engine.checkVersion("4.1.0");
3414
3390
  await engine.pluginManager.register(e => {
3415
3391
  e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
3416
3392
  });
@@ -3494,58 +3470,58 @@
3494
3470
  }
3495
3471
  }
3496
3472
  class RenderManager {
3497
- _canvasClearPlugins;
3498
- _canvasManager;
3499
- _canvasPaintPlugins;
3500
- _clearDrawPlugins;
3501
- _colorPlugins;
3502
- _container;
3503
- _context;
3504
- _contextSettings;
3505
- _drawParticlePlugins;
3506
- _drawParticlesCleanupPlugins;
3507
- _drawParticlesSetupPlugins;
3508
- _drawPlugins;
3509
- _drawSettingsCleanupPlugins;
3510
- _drawSettingsSetupPlugins;
3511
- _pluginManager;
3512
- _postDrawUpdaters;
3513
- _preDrawUpdaters;
3514
- _reusableColorStyles = {};
3515
- _reusablePluginColors = [undefined, undefined];
3516
- _reusableTransform = {};
3473
+ #canvasClearPlugins;
3474
+ #canvasManager;
3475
+ #canvasPaintPlugins;
3476
+ #clearDrawPlugins;
3477
+ #colorPlugins;
3478
+ #container;
3479
+ #context;
3480
+ #contextSettings;
3481
+ #drawParticlePlugins;
3482
+ #drawParticlesCleanupPlugins;
3483
+ #drawParticlesSetupPlugins;
3484
+ #drawPlugins;
3485
+ #drawSettingsCleanupPlugins;
3486
+ #drawSettingsSetupPlugins;
3487
+ #pluginManager;
3488
+ #postDrawUpdaters;
3489
+ #preDrawUpdaters;
3490
+ #reusableColorStyles = {};
3491
+ #reusablePluginColors = [undefined, undefined];
3492
+ #reusableTransform = {};
3517
3493
  constructor(pluginManager, container, canvasManager) {
3518
- this._pluginManager = pluginManager;
3519
- this._container = container;
3520
- this._canvasManager = canvasManager;
3521
- this._context = null;
3522
- this._preDrawUpdaters = [];
3523
- this._postDrawUpdaters = [];
3524
- this._colorPlugins = [];
3525
- this._canvasClearPlugins = [];
3526
- this._canvasPaintPlugins = [];
3527
- this._clearDrawPlugins = [];
3528
- this._drawParticlePlugins = [];
3529
- this._drawParticlesCleanupPlugins = [];
3530
- this._drawParticlesSetupPlugins = [];
3531
- this._drawPlugins = [];
3532
- this._drawSettingsSetupPlugins = [];
3533
- this._drawSettingsCleanupPlugins = [];
3494
+ this.#pluginManager = pluginManager;
3495
+ this.#container = container;
3496
+ this.#canvasManager = canvasManager;
3497
+ this.#context = null;
3498
+ this.#preDrawUpdaters = [];
3499
+ this.#postDrawUpdaters = [];
3500
+ this.#colorPlugins = [];
3501
+ this.#canvasClearPlugins = [];
3502
+ this.#canvasPaintPlugins = [];
3503
+ this.#clearDrawPlugins = [];
3504
+ this.#drawParticlePlugins = [];
3505
+ this.#drawParticlesCleanupPlugins = [];
3506
+ this.#drawParticlesSetupPlugins = [];
3507
+ this.#drawPlugins = [];
3508
+ this.#drawSettingsSetupPlugins = [];
3509
+ this.#drawSettingsCleanupPlugins = [];
3534
3510
  }
3535
3511
  get settings() {
3536
- return this._contextSettings;
3512
+ return this.#contextSettings;
3537
3513
  }
3538
3514
  canvasClear() {
3539
- if (!this._container.actualOptions.clear) {
3515
+ if (!this.#container.actualOptions.clear) {
3540
3516
  return;
3541
3517
  }
3542
3518
  this.draw(ctx => {
3543
- clear(ctx, this._canvasManager.size);
3519
+ clear(ctx, this.#canvasManager.size);
3544
3520
  });
3545
3521
  }
3546
3522
  clear() {
3547
3523
  let pluginHandled = false;
3548
- for (const plugin of this._canvasClearPlugins) {
3524
+ for (const plugin of this.#canvasClearPlugins) {
3549
3525
  pluginHandled = plugin.canvasClear?.() ?? false;
3550
3526
  if (pluginHandled) {
3551
3527
  break;
@@ -3558,21 +3534,21 @@
3558
3534
  }
3559
3535
  destroy() {
3560
3536
  this.stop();
3561
- this._preDrawUpdaters = [];
3562
- this._postDrawUpdaters = [];
3563
- this._colorPlugins = [];
3564
- this._canvasClearPlugins = [];
3565
- this._canvasPaintPlugins = [];
3566
- this._clearDrawPlugins = [];
3567
- this._drawParticlePlugins = [];
3568
- this._drawParticlesCleanupPlugins = [];
3569
- this._drawParticlesSetupPlugins = [];
3570
- this._drawPlugins = [];
3571
- this._drawSettingsSetupPlugins = [];
3572
- this._drawSettingsCleanupPlugins = [];
3537
+ this.#preDrawUpdaters = [];
3538
+ this.#postDrawUpdaters = [];
3539
+ this.#colorPlugins = [];
3540
+ this.#canvasClearPlugins = [];
3541
+ this.#canvasPaintPlugins = [];
3542
+ this.#clearDrawPlugins = [];
3543
+ this.#drawParticlePlugins = [];
3544
+ this.#drawParticlesCleanupPlugins = [];
3545
+ this.#drawParticlesSetupPlugins = [];
3546
+ this.#drawPlugins = [];
3547
+ this.#drawSettingsSetupPlugins = [];
3548
+ this.#drawSettingsCleanupPlugins = [];
3573
3549
  }
3574
3550
  draw(cb) {
3575
- const ctx = this._context;
3551
+ const ctx = this.#context;
3576
3552
  if (!ctx) {
3577
3553
  return;
3578
3554
  }
@@ -3587,21 +3563,21 @@
3587
3563
  return;
3588
3564
  }
3589
3565
  const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
3590
- let [fColor, sColor] = this._getPluginParticleColors(particle);
3566
+ let [fColor, sColor] = this.#getPluginParticleColors(particle);
3591
3567
  fColor ??= pfColor;
3592
3568
  sColor ??= psColor;
3593
3569
  if (!fColor && !sColor) {
3594
3570
  return;
3595
3571
  }
3596
- 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;
3572
+ 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;
3597
3573
  transform.a = transform.b = transform.c = transform.d = undefined;
3598
3574
  colorStyles.fill = fill;
3599
3575
  colorStyles.stroke = stroke;
3600
3576
  this.draw((context) => {
3601
- for (const plugin of this._drawParticlesSetupPlugins) {
3577
+ for (const plugin of this.#drawParticlesSetupPlugins) {
3602
3578
  plugin.drawParticleSetup?.(context, particle, delta);
3603
3579
  }
3604
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
3580
+ this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
3605
3581
  drawParticle({
3606
3582
  container,
3607
3583
  context,
@@ -3612,35 +3588,35 @@
3612
3588
  opacity: opacity,
3613
3589
  transform,
3614
3590
  });
3615
- this._applyPostDrawUpdaters(particle);
3616
- for (const plugin of this._drawParticlesCleanupPlugins) {
3591
+ this.#applyPostDrawUpdaters(particle);
3592
+ for (const plugin of this.#drawParticlesCleanupPlugins) {
3617
3593
  plugin.drawParticleCleanup?.(context, particle, delta);
3618
3594
  }
3619
3595
  });
3620
3596
  }
3621
3597
  drawParticlePlugins(particle, delta) {
3622
3598
  this.draw(ctx => {
3623
- for (const plugin of this._drawParticlePlugins) {
3599
+ for (const plugin of this.#drawParticlePlugins) {
3624
3600
  drawParticlePlugin(ctx, plugin, particle, delta);
3625
3601
  }
3626
3602
  });
3627
3603
  }
3628
3604
  drawParticles(delta) {
3629
- const { particles } = this._container;
3605
+ const { particles } = this.#container;
3630
3606
  this.clear();
3631
3607
  particles.update(delta);
3632
3608
  this.draw(ctx => {
3633
- for (const plugin of this._drawSettingsSetupPlugins) {
3609
+ for (const plugin of this.#drawSettingsSetupPlugins) {
3634
3610
  plugin.drawSettingsSetup?.(ctx, delta);
3635
3611
  }
3636
- for (const plugin of this._drawPlugins) {
3612
+ for (const plugin of this.#drawPlugins) {
3637
3613
  plugin.draw?.(ctx, delta);
3638
3614
  }
3639
3615
  particles.drawParticles(delta);
3640
- for (const plugin of this._clearDrawPlugins) {
3616
+ for (const plugin of this.#clearDrawPlugins) {
3641
3617
  plugin.clearDraw?.(ctx, delta);
3642
3618
  }
3643
- for (const plugin of this._drawSettingsCleanupPlugins) {
3619
+ for (const plugin of this.#drawSettingsCleanupPlugins) {
3644
3620
  plugin.drawSettingsCleanup?.(ctx, delta);
3645
3621
  }
3646
3622
  });
@@ -3651,64 +3627,64 @@
3651
3627
  this.paint();
3652
3628
  }
3653
3629
  initPlugins() {
3654
- this._colorPlugins = [];
3655
- this._canvasClearPlugins = [];
3656
- this._canvasPaintPlugins = [];
3657
- this._clearDrawPlugins = [];
3658
- this._drawParticlePlugins = [];
3659
- this._drawParticlesSetupPlugins = [];
3660
- this._drawParticlesCleanupPlugins = [];
3661
- this._drawPlugins = [];
3662
- this._drawSettingsSetupPlugins = [];
3663
- this._drawSettingsCleanupPlugins = [];
3664
- for (const plugin of this._container.plugins) {
3630
+ this.#colorPlugins = [];
3631
+ this.#canvasClearPlugins = [];
3632
+ this.#canvasPaintPlugins = [];
3633
+ this.#clearDrawPlugins = [];
3634
+ this.#drawParticlePlugins = [];
3635
+ this.#drawParticlesSetupPlugins = [];
3636
+ this.#drawParticlesCleanupPlugins = [];
3637
+ this.#drawPlugins = [];
3638
+ this.#drawSettingsSetupPlugins = [];
3639
+ this.#drawSettingsCleanupPlugins = [];
3640
+ for (const plugin of this.#container.plugins) {
3665
3641
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
3666
- this._colorPlugins.push(plugin);
3642
+ this.#colorPlugins.push(plugin);
3667
3643
  }
3668
3644
  if (plugin.canvasClear) {
3669
- this._canvasClearPlugins.push(plugin);
3645
+ this.#canvasClearPlugins.push(plugin);
3670
3646
  }
3671
3647
  if (plugin.canvasPaint) {
3672
- this._canvasPaintPlugins.push(plugin);
3648
+ this.#canvasPaintPlugins.push(plugin);
3673
3649
  }
3674
3650
  if (plugin.drawParticle) {
3675
- this._drawParticlePlugins.push(plugin);
3651
+ this.#drawParticlePlugins.push(plugin);
3676
3652
  }
3677
3653
  if (plugin.drawParticleSetup) {
3678
- this._drawParticlesSetupPlugins.push(plugin);
3654
+ this.#drawParticlesSetupPlugins.push(plugin);
3679
3655
  }
3680
3656
  if (plugin.drawParticleCleanup) {
3681
- this._drawParticlesCleanupPlugins.push(plugin);
3657
+ this.#drawParticlesCleanupPlugins.push(plugin);
3682
3658
  }
3683
3659
  if (plugin.draw) {
3684
- this._drawPlugins.push(plugin);
3660
+ this.#drawPlugins.push(plugin);
3685
3661
  }
3686
3662
  if (plugin.drawSettingsSetup) {
3687
- this._drawSettingsSetupPlugins.push(plugin);
3663
+ this.#drawSettingsSetupPlugins.push(plugin);
3688
3664
  }
3689
3665
  if (plugin.drawSettingsCleanup) {
3690
- this._drawSettingsCleanupPlugins.push(plugin);
3666
+ this.#drawSettingsCleanupPlugins.push(plugin);
3691
3667
  }
3692
3668
  if (plugin.clearDraw) {
3693
- this._clearDrawPlugins.push(plugin);
3669
+ this.#clearDrawPlugins.push(plugin);
3694
3670
  }
3695
3671
  }
3696
3672
  }
3697
3673
  initUpdaters() {
3698
- this._preDrawUpdaters = [];
3699
- this._postDrawUpdaters = [];
3700
- for (const updater of this._container.particleUpdaters) {
3674
+ this.#preDrawUpdaters = [];
3675
+ this.#postDrawUpdaters = [];
3676
+ for (const updater of this.#container.particleUpdaters) {
3701
3677
  if (updater.afterDraw) {
3702
- this._postDrawUpdaters.push(updater);
3678
+ this.#postDrawUpdaters.push(updater);
3703
3679
  }
3704
3680
  if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
3705
- this._preDrawUpdaters.push(updater);
3681
+ this.#preDrawUpdaters.push(updater);
3706
3682
  }
3707
3683
  }
3708
3684
  }
3709
3685
  paint() {
3710
3686
  let handled = false;
3711
- for (const plugin of this._canvasPaintPlugins) {
3687
+ for (const plugin of this.#canvasPaintPlugins) {
3712
3688
  handled = plugin.canvasPaint?.() ?? false;
3713
3689
  if (handled) {
3714
3690
  break;
@@ -3721,35 +3697,35 @@
3721
3697
  }
3722
3698
  paintBase(baseColor) {
3723
3699
  this.draw(ctx => {
3724
- paintBase(ctx, this._canvasManager.size, baseColor);
3700
+ paintBase(ctx, this.#canvasManager.size, baseColor);
3725
3701
  });
3726
3702
  }
3727
3703
  paintImage(image, opacity) {
3728
3704
  this.draw(ctx => {
3729
- paintImage(ctx, this._canvasManager.size, image, opacity);
3705
+ paintImage(ctx, this.#canvasManager.size, image, opacity);
3730
3706
  });
3731
3707
  }
3732
3708
  setContext(context) {
3733
- this._context = context;
3734
- if (this._context) {
3735
- this._context.globalCompositeOperation = defaultCompositeValue;
3709
+ this.#context = context;
3710
+ if (this.#context) {
3711
+ this.#context.globalCompositeOperation = defaultCompositeValue;
3736
3712
  }
3737
3713
  }
3738
3714
  setContextSettings(settings) {
3739
- this._contextSettings = settings;
3715
+ this.#contextSettings = settings;
3740
3716
  }
3741
3717
  stop() {
3742
3718
  this.draw(ctx => {
3743
- clear(ctx, this._canvasManager.size);
3719
+ clear(ctx, this.#canvasManager.size);
3744
3720
  });
3745
3721
  }
3746
- _applyPostDrawUpdaters = particle => {
3747
- for (const updater of this._postDrawUpdaters) {
3722
+ #applyPostDrawUpdaters = particle => {
3723
+ for (const updater of this.#postDrawUpdaters) {
3748
3724
  updater.afterDraw?.(particle);
3749
3725
  }
3750
3726
  };
3751
- _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
3752
- for (const updater of this._preDrawUpdaters) {
3727
+ #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
3728
+ for (const updater of this.#preDrawUpdaters) {
3753
3729
  if (updater.getColorStyles) {
3754
3730
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
3755
3731
  if (fill) {
@@ -3768,22 +3744,22 @@
3768
3744
  updater.beforeDraw?.(particle);
3769
3745
  }
3770
3746
  };
3771
- _getPluginParticleColors = particle => {
3747
+ #getPluginParticleColors = particle => {
3772
3748
  let fColor, sColor;
3773
- for (const plugin of this._colorPlugins) {
3749
+ for (const plugin of this.#colorPlugins) {
3774
3750
  if (!fColor && plugin.particleFillColor) {
3775
- fColor = rangeColorToHsl(this._pluginManager, plugin.particleFillColor(particle));
3751
+ fColor = rangeColorToHsl(this.#pluginManager, plugin.particleFillColor(particle));
3776
3752
  }
3777
3753
  if (!sColor && plugin.particleStrokeColor) {
3778
- sColor = rangeColorToHsl(this._pluginManager, plugin.particleStrokeColor(particle));
3754
+ sColor = rangeColorToHsl(this.#pluginManager, plugin.particleStrokeColor(particle));
3779
3755
  }
3780
3756
  if (fColor && sColor) {
3781
3757
  break;
3782
3758
  }
3783
3759
  }
3784
- this._reusablePluginColors[fColorIndex] = fColor;
3785
- this._reusablePluginColors[sColorIndex] = sColor;
3786
- return this._reusablePluginColors;
3760
+ this.#reusablePluginColors[fColorIndex] = fColor;
3761
+ this.#reusablePluginColors[sColorIndex] = sColor;
3762
+ return this.#reusablePluginColors;
3787
3763
  };
3788
3764
  }
3789
3765
 
@@ -3841,53 +3817,53 @@
3841
3817
  renderCanvas;
3842
3818
  size;
3843
3819
  zoom = defaultZoom;
3844
- _container;
3845
- _generated;
3846
- _mutationObserver;
3847
- _originalStyle;
3848
- _pluginManager;
3849
- _pointerEvents;
3850
- _resizePlugins;
3851
- _standardSize;
3852
- _zoomCenter;
3820
+ #container;
3821
+ #generated;
3822
+ #mutationObserver;
3823
+ #originalStyle;
3824
+ #pluginManager;
3825
+ #pointerEvents;
3826
+ #resizePlugins;
3827
+ #standardSize;
3828
+ #zoomCenter;
3853
3829
  constructor(pluginManager, container) {
3854
- this._pluginManager = pluginManager;
3855
- this._container = container;
3830
+ this.#pluginManager = pluginManager;
3831
+ this.#container = container;
3856
3832
  this.render = new RenderManager(pluginManager, container, this);
3857
- this._standardSize = {
3833
+ this.#standardSize = {
3858
3834
  height: 0,
3859
3835
  width: 0,
3860
3836
  };
3861
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
3837
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
3862
3838
  this.size = {
3863
3839
  height: stdSize.height * pxRatio,
3864
3840
  width: stdSize.width * pxRatio,
3865
3841
  };
3866
- this._generated = false;
3867
- this._resizePlugins = [];
3868
- this._pointerEvents = "none";
3842
+ this.#generated = false;
3843
+ this.#resizePlugins = [];
3844
+ this.#pointerEvents = "none";
3869
3845
  }
3870
- get _fullScreen() {
3871
- return this._container.actualOptions.fullScreen.enable;
3846
+ get #fullScreen() {
3847
+ return this.#container.actualOptions.fullScreen.enable;
3872
3848
  }
3873
3849
  destroy() {
3874
3850
  this.stop();
3875
- if (this._generated) {
3851
+ if (this.#generated) {
3876
3852
  const element = this.domElement;
3877
3853
  element?.remove();
3878
3854
  this.domElement = undefined;
3879
3855
  this.renderCanvas = undefined;
3880
3856
  }
3881
3857
  else {
3882
- this._resetOriginalStyle();
3858
+ this.#resetOriginalStyle();
3883
3859
  }
3884
3860
  this.render.destroy();
3885
- this._resizePlugins = [];
3861
+ this.#resizePlugins = [];
3886
3862
  }
3887
3863
  getZoomCenter() {
3888
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
3889
- if (this._zoomCenter) {
3890
- return this._zoomCenter;
3864
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
3865
+ if (this.#zoomCenter) {
3866
+ return this.#zoomCenter;
3891
3867
  }
3892
3868
  return {
3893
3869
  x: (width * half) / pxRatio,
@@ -3895,20 +3871,20 @@
3895
3871
  };
3896
3872
  }
3897
3873
  init() {
3898
- this._safeMutationObserver(obs => {
3874
+ this.#safeMutationObserver(obs => {
3899
3875
  obs.disconnect();
3900
3876
  });
3901
- this._mutationObserver = safeMutationObserver(records => {
3877
+ this.#mutationObserver = safeMutationObserver(records => {
3902
3878
  for (const record of records) {
3903
3879
  if (record.type === "attributes" && record.attributeName === "style") {
3904
- this._repairStyle();
3880
+ this.#repairStyle();
3905
3881
  }
3906
3882
  }
3907
3883
  });
3908
3884
  this.resize();
3909
- this._initStyle();
3885
+ this.#initStyle();
3910
3886
  this.initBackground();
3911
- this._safeMutationObserver(obs => {
3887
+ this.#safeMutationObserver(obs => {
3912
3888
  const element = this.domElement;
3913
3889
  if (!element || !(element instanceof Node)) {
3914
3890
  return;
@@ -3919,13 +3895,13 @@
3919
3895
  this.render.init();
3920
3896
  }
3921
3897
  initBackground() {
3922
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
3898
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
3923
3899
  if (!element) {
3924
3900
  return;
3925
3901
  }
3926
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
3902
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
3927
3903
  if (color) {
3928
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
3904
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
3929
3905
  }
3930
3906
  else {
3931
3907
  elementStyle.backgroundColor = "";
@@ -3936,27 +3912,27 @@
3936
3912
  elementStyle.backgroundSize = background.size || "";
3937
3913
  }
3938
3914
  initPlugins() {
3939
- this._resizePlugins = [];
3940
- for (const plugin of this._container.plugins) {
3915
+ this.#resizePlugins = [];
3916
+ for (const plugin of this.#container.plugins) {
3941
3917
  if (plugin.resize) {
3942
- this._resizePlugins.push(plugin);
3918
+ this.#resizePlugins.push(plugin);
3943
3919
  }
3944
3920
  }
3945
3921
  }
3946
3922
  loadCanvas(canvas) {
3947
- if (this._generated && this.domElement) {
3923
+ if (this.#generated && this.domElement) {
3948
3924
  this.domElement.remove();
3949
3925
  }
3950
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
3926
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
3951
3927
  this.domElement = domCanvas;
3952
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
3928
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
3953
3929
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
3954
3930
  const domElement = this.domElement;
3955
3931
  if (domElement) {
3956
3932
  domElement.ariaHidden = "true";
3957
- this._originalStyle = cloneStyle(domElement.style);
3933
+ this.#originalStyle = cloneStyle(domElement.style);
3958
3934
  }
3959
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
3935
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
3960
3936
  if (domElement) {
3961
3937
  standardSize.height = domElement.offsetHeight;
3962
3938
  standardSize.width = domElement.offsetWidth;
@@ -3965,7 +3941,7 @@
3965
3941
  standardSize.height = renderCanvas.height;
3966
3942
  standardSize.width = renderCanvas.width;
3967
3943
  }
3968
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
3944
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
3969
3945
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
3970
3946
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
3971
3947
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -3976,12 +3952,12 @@
3976
3952
  willReadFrequently: false,
3977
3953
  });
3978
3954
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
3979
- this._safeMutationObserver(obs => {
3955
+ this.#safeMutationObserver(obs => {
3980
3956
  obs.disconnect();
3981
3957
  });
3982
3958
  container.retina.init();
3983
3959
  this.initBackground();
3984
- this._safeMutationObserver(obs => {
3960
+ this.#safeMutationObserver(obs => {
3985
3961
  const element = this.domElement;
3986
3962
  if (!element || !(element instanceof Node)) {
3987
3963
  return;
@@ -3994,11 +3970,11 @@
3994
3970
  if (!element) {
3995
3971
  return false;
3996
3972
  }
3997
- const container = this._container, renderCanvas = this.renderCanvas;
3973
+ const container = this.#container, renderCanvas = this.renderCanvas;
3998
3974
  if (renderCanvas === undefined) {
3999
3975
  return false;
4000
3976
  }
4001
- const currentSize = container.canvas._standardSize, newSize = {
3977
+ const currentSize = container.canvas.#standardSize, newSize = {
4002
3978
  width: element.offsetWidth,
4003
3979
  height: element.offsetHeight,
4004
3980
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -4017,7 +3993,7 @@
4017
3993
  const canvasSize = this.size;
4018
3994
  renderCanvas.width = canvasSize.width = retinaSize.width;
4019
3995
  renderCanvas.height = canvasSize.height = retinaSize.height;
4020
- if (this._container.started) {
3996
+ if (this.#container.started) {
4021
3997
  container.particles.setResizeFactor({
4022
3998
  width: currentSize.width / oldSize.width,
4023
3999
  height: currentSize.height / oldSize.height,
@@ -4030,46 +4006,46 @@
4030
4006
  if (!element) {
4031
4007
  return;
4032
4008
  }
4033
- this._pointerEvents = type;
4034
- this._repairStyle();
4009
+ this.#pointerEvents = type;
4010
+ this.#repairStyle();
4035
4011
  }
4036
4012
  setZoom(zoomLevel, center) {
4037
4013
  this.zoom = zoomLevel;
4038
- this._zoomCenter = center;
4014
+ this.#zoomCenter = center;
4039
4015
  }
4040
4016
  stop() {
4041
- this._safeMutationObserver(obs => {
4017
+ this.#safeMutationObserver(obs => {
4042
4018
  obs.disconnect();
4043
4019
  });
4044
- this._mutationObserver = undefined;
4020
+ this.#mutationObserver = undefined;
4045
4021
  this.render.stop();
4046
4022
  }
4047
4023
  async windowResize() {
4048
4024
  if (!this.domElement || !this.resize()) {
4049
4025
  return;
4050
4026
  }
4051
- const container = this._container, needsRefresh = container.updateActualOptions();
4027
+ const container = this.#container, needsRefresh = container.updateActualOptions();
4052
4028
  container.particles.setDensity();
4053
- this._applyResizePlugins();
4029
+ this.#applyResizePlugins();
4054
4030
  if (needsRefresh) {
4055
4031
  await container.refresh();
4056
4032
  }
4057
4033
  }
4058
- _applyResizePlugins = () => {
4059
- for (const plugin of this._resizePlugins) {
4034
+ #applyResizePlugins = () => {
4035
+ for (const plugin of this.#resizePlugins) {
4060
4036
  plugin.resize?.();
4061
4037
  }
4062
4038
  };
4063
- _initStyle = () => {
4064
- const element = this.domElement, options = this._container.actualOptions;
4039
+ #initStyle = () => {
4040
+ const element = this.domElement, options = this.#container.actualOptions;
4065
4041
  if (!element) {
4066
4042
  return;
4067
4043
  }
4068
- if (this._fullScreen) {
4069
- this._setFullScreenStyle();
4044
+ if (this.#fullScreen) {
4045
+ this.#setFullScreenStyle();
4070
4046
  }
4071
4047
  else {
4072
- this._resetOriginalStyle();
4048
+ this.#resetOriginalStyle();
4073
4049
  }
4074
4050
  for (const key in options.style) {
4075
4051
  if (!key || !(key in options.style)) {
@@ -4082,72 +4058,72 @@
4082
4058
  element.style.setProperty(key, value, "important");
4083
4059
  }
4084
4060
  };
4085
- _repairStyle = () => {
4061
+ #repairStyle = () => {
4086
4062
  const element = this.domElement;
4087
4063
  if (!element) {
4088
4064
  return;
4089
4065
  }
4090
- this._safeMutationObserver(observer => {
4066
+ this.#safeMutationObserver(observer => {
4091
4067
  observer.disconnect();
4092
4068
  });
4093
- this._initStyle();
4069
+ this.#initStyle();
4094
4070
  this.initBackground();
4095
- const pointerEvents = this._pointerEvents;
4071
+ const pointerEvents = this.#pointerEvents;
4096
4072
  element.style.pointerEvents = pointerEvents;
4097
4073
  element.style.setProperty("pointer-events", pointerEvents);
4098
- this._safeMutationObserver(observer => {
4074
+ this.#safeMutationObserver(observer => {
4099
4075
  if (!(element instanceof Node)) {
4100
4076
  return;
4101
4077
  }
4102
4078
  observer.observe(element, { attributes: true });
4103
4079
  });
4104
4080
  };
4105
- _resetOriginalStyle = () => {
4106
- const element = this.domElement, originalStyle = this._originalStyle;
4081
+ #resetOriginalStyle = () => {
4082
+ const element = this.domElement, originalStyle = this.#originalStyle;
4107
4083
  if (!element || !originalStyle) {
4108
4084
  return;
4109
4085
  }
4110
4086
  setStyle(element, originalStyle, true);
4111
4087
  };
4112
- _safeMutationObserver = callback => {
4113
- if (!this._mutationObserver) {
4088
+ #safeMutationObserver = callback => {
4089
+ if (!this.#mutationObserver) {
4114
4090
  return;
4115
4091
  }
4116
- callback(this._mutationObserver);
4092
+ callback(this.#mutationObserver);
4117
4093
  };
4118
- _setFullScreenStyle = () => {
4094
+ #setFullScreenStyle = () => {
4119
4095
  const element = this.domElement;
4120
4096
  if (!element) {
4121
4097
  return;
4122
4098
  }
4123
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
4099
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
4124
4100
  };
4125
4101
  }
4126
4102
 
4127
4103
  class EventListeners {
4128
- container;
4129
- _handlers;
4130
- _resizeObserver;
4131
- _resizeTimeout;
4104
+ #container;
4105
+ #handlers;
4106
+ #resizeObserver;
4107
+ #resizeTimeout;
4132
4108
  constructor(container) {
4133
- this.container = container;
4134
- this._handlers = {
4109
+ this.#container = container;
4110
+ this.#handlers = {
4135
4111
  visibilityChange: () => {
4136
- this._handleVisibilityChange();
4112
+ this.#handleVisibilityChange();
4137
4113
  },
4138
4114
  resize: () => {
4139
- this._handleWindowResize();
4115
+ this.#handleWindowResize();
4140
4116
  },
4141
4117
  };
4142
4118
  }
4143
4119
  addListeners() {
4144
- this._manageListeners(true);
4120
+ this.#manageListeners(true);
4145
4121
  }
4146
4122
  removeListeners() {
4147
- this._manageListeners(false);
4123
+ this.#manageListeners(false);
4148
4124
  }
4149
- _handleVisibilityChange = () => {
4150
- const container = this.container, options = container.actualOptions;
4125
+ #handleVisibilityChange = () => {
4126
+ const container = this.#container, options = container.actualOptions;
4151
4127
  if (!options.pauseOnBlur) {
4152
4128
  return;
4153
4129
  }
@@ -4165,24 +4141,24 @@
4165
4141
  }
4166
4142
  }
4167
4143
  };
4168
- _handleWindowResize = () => {
4169
- if (this._resizeTimeout) {
4170
- clearTimeout(this._resizeTimeout);
4171
- delete this._resizeTimeout;
4144
+ #handleWindowResize = () => {
4145
+ if (this.#resizeTimeout) {
4146
+ clearTimeout(this.#resizeTimeout);
4147
+ this.#resizeTimeout = undefined;
4172
4148
  }
4173
4149
  const handleResize = async () => {
4174
- const canvas = this.container.canvas;
4150
+ const canvas = this.#container.canvas;
4175
4151
  await canvas.windowResize();
4176
4152
  };
4177
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
4153
+ this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
4178
4154
  };
4179
- _manageListeners = add => {
4180
- const handlers = this._handlers;
4181
- this._manageResize(add);
4155
+ #manageListeners = add => {
4156
+ const handlers = this.#handlers;
4157
+ this.#manageResize(add);
4182
4158
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
4183
4159
  };
4184
- _manageResize = add => {
4185
- const handlers = this._handlers, container = this.container, options = container.actualOptions;
4160
+ #manageResize = add => {
4161
+ const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
4186
4162
  if (!options.resize.enable) {
4187
4163
  return;
4188
4164
  }
@@ -4191,22 +4167,22 @@
4191
4167
  return;
4192
4168
  }
4193
4169
  const canvasEl = container.canvas.domElement;
4194
- if (this._resizeObserver && !add) {
4170
+ if (this.#resizeObserver && !add) {
4195
4171
  if (canvasEl) {
4196
- this._resizeObserver.unobserve(canvasEl);
4172
+ this.#resizeObserver.unobserve(canvasEl);
4197
4173
  }
4198
- this._resizeObserver.disconnect();
4199
- delete this._resizeObserver;
4174
+ this.#resizeObserver.disconnect();
4175
+ this.#resizeObserver = undefined;
4200
4176
  }
4201
- else if (!this._resizeObserver && add && canvasEl) {
4202
- this._resizeObserver = new ResizeObserver((entries) => {
4177
+ else if (!this.#resizeObserver && add && canvasEl) {
4178
+ this.#resizeObserver = new ResizeObserver((entries) => {
4203
4179
  const entry = entries.find(e => e.target === canvasEl);
4204
4180
  if (!entry) {
4205
4181
  return;
4206
4182
  }
4207
- this._handleWindowResize();
4183
+ this.#handleWindowResize();
4208
4184
  });
4209
- this._resizeObserver.observe(canvasEl);
4185
+ this.#resizeObserver.observe(canvasEl);
4210
4186
  }
4211
4187
  };
4212
4188
  }
@@ -4279,24 +4255,24 @@
4279
4255
  unbreakable;
4280
4256
  velocity;
4281
4257
  zIndexFactor;
4282
- _cachedOpacityData = {
4258
+ #cachedOpacityData = {
4283
4259
  fillOpacity: defaultOpacity$1,
4284
4260
  opacity: defaultOpacity$1,
4285
4261
  strokeOpacity: defaultOpacity$1,
4286
4262
  };
4287
- _cachedPosition = Vector3d.origin;
4288
- _cachedRotateData = { sin: 0, cos: 0 };
4289
- _cachedTransform = {
4263
+ #cachedPosition = Vector3d.origin;
4264
+ #cachedRotateData = { sin: 0, cos: 0 };
4265
+ #cachedTransform = {
4290
4266
  a: 1,
4291
4267
  b: 0,
4292
4268
  c: 0,
4293
4269
  d: 1,
4294
4270
  };
4295
- _container;
4296
- _pluginManager;
4271
+ #container;
4272
+ #pluginManager;
4297
4273
  constructor(pluginManager, container) {
4298
- this._pluginManager = pluginManager;
4299
- this._container = container;
4274
+ this.#pluginManager = pluginManager;
4275
+ this.#container = container;
4300
4276
  }
4301
4277
  destroy(override) {
4302
4278
  if (this.unbreakable || this.destroyed) {
@@ -4305,7 +4281,7 @@
4305
4281
  this.destroyed = true;
4306
4282
  this.bubble.inRange = false;
4307
4283
  this.slow.inRange = false;
4308
- const container = this._container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4284
+ const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4309
4285
  shapeDrawer?.particleDestroy?.(this);
4310
4286
  for (const plugin of container.particleDestroyedPlugins) {
4311
4287
  plugin.particleDestroyed?.(this, override);
@@ -4313,12 +4289,12 @@
4313
4289
  for (const updater of container.particleUpdaters) {
4314
4290
  updater.particleDestroyed?.(this, override);
4315
4291
  }
4316
- this._container.dispatchEvent(EventType.particleDestroyed, {
4292
+ this.#container.dispatchEvent(EventType.particleDestroyed, {
4317
4293
  particle: this,
4318
4294
  });
4319
4295
  }
4320
4296
  draw(delta) {
4321
- const container = this._container, render = container.canvas.render;
4297
+ const container = this.#container, render = container.canvas.render;
4322
4298
  render.drawParticlePlugins(this, delta);
4323
4299
  render.drawParticle(this, delta);
4324
4300
  }
@@ -4326,50 +4302,50 @@
4326
4302
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
4327
4303
  }
4328
4304
  getFillColor() {
4329
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4305
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4330
4306
  }
4331
4307
  getMass() {
4332
4308
  return this.getRadius() ** squareExp * Math.PI * half;
4333
4309
  }
4334
4310
  getOpacity() {
4335
4311
  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;
4336
- this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4337
- this._cachedOpacityData.opacity = opacity * zOpacityFactor;
4338
- this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4339
- return this._cachedOpacityData;
4312
+ this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4313
+ this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
4314
+ this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4315
+ return this.#cachedOpacityData;
4340
4316
  }
4341
4317
  getPosition() {
4342
- this._cachedPosition.x = this.position.x + this.offset.x;
4343
- this._cachedPosition.y = this.position.y + this.offset.y;
4344
- this._cachedPosition.z = this.position.z;
4345
- return this._cachedPosition;
4318
+ this.#cachedPosition.x = this.position.x + this.offset.x;
4319
+ this.#cachedPosition.y = this.position.y + this.offset.y;
4320
+ this.#cachedPosition.z = this.position.z;
4321
+ return this.#cachedPosition;
4346
4322
  }
4347
4323
  getRadius() {
4348
4324
  return this.bubble.radius ?? this.size.value;
4349
4325
  }
4350
4326
  getRotateData() {
4351
4327
  const angle = this.getAngle();
4352
- this._cachedRotateData.sin = Math.sin(angle);
4353
- this._cachedRotateData.cos = Math.cos(angle);
4354
- return this._cachedRotateData;
4328
+ this.#cachedRotateData.sin = Math.sin(angle);
4329
+ this.#cachedRotateData.cos = Math.cos(angle);
4330
+ return this.#cachedRotateData;
4355
4331
  }
4356
4332
  getStrokeColor() {
4357
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4333
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4358
4334
  }
4359
4335
  getTransformData(externalTransform) {
4360
4336
  const rotateData = this.getRotateData(), rotating = this.isRotating;
4361
- this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4362
- this._cachedTransform.b = rotating
4337
+ this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4338
+ this.#cachedTransform.b = rotating
4363
4339
  ? rotateData.sin * (externalTransform.b ?? identity)
4364
4340
  : (externalTransform.b ?? defaultTransform.b);
4365
- this._cachedTransform.c = rotating
4341
+ this.#cachedTransform.c = rotating
4366
4342
  ? -rotateData.sin * (externalTransform.c ?? identity)
4367
4343
  : (externalTransform.c ?? defaultTransform.c);
4368
- this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4369
- return this._cachedTransform;
4344
+ this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4345
+ return this.#cachedTransform;
4370
4346
  }
4371
4347
  init(id, position, overrideOptions, group) {
4372
- const container = this._container;
4348
+ const container = this.#container;
4373
4349
  this.id = id;
4374
4350
  this.group = group;
4375
4351
  this.justWarped = false;
@@ -4389,21 +4365,27 @@
4389
4365
  moveSpeed: 0,
4390
4366
  sizeAnimationSpeed: 0,
4391
4367
  };
4368
+ this.size = {
4369
+ value: 1,
4370
+ max: 1,
4371
+ min: 1,
4372
+ enable: false,
4373
+ };
4392
4374
  this.outType = ParticleOutType.normal;
4393
4375
  this.ignoresResizeRatio = true;
4394
- 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;
4376
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
4395
4377
  this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
4396
4378
  this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
4397
4379
  const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
4398
4380
  if (overrideOptions) {
4399
- if (overrideOptions.effect?.type) {
4381
+ if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
4400
4382
  const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
4401
4383
  if (effect) {
4402
4384
  this.effect = effect;
4403
4385
  effectOptions.load(overrideOptions.effect);
4404
4386
  }
4405
4387
  }
4406
- if (overrideOptions.shape?.type) {
4388
+ if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
4407
4389
  const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
4408
4390
  if (shape) {
4409
4391
  this.shape = shape;
@@ -4412,21 +4394,20 @@
4412
4394
  }
4413
4395
  }
4414
4396
  if (this.effect === randomColorValue) {
4415
- const availableEffects = [...this._container.effectDrawers.keys()];
4397
+ const availableEffects = [...this.#container.effectDrawers.keys()];
4416
4398
  this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
4417
4399
  }
4418
4400
  if (this.shape === randomColorValue) {
4419
- const availableShapes = [...this._container.shapeDrawers.keys()];
4401
+ const availableShapes = [...this.#container.shapeDrawers.keys()];
4420
4402
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
4421
4403
  }
4422
4404
  this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
4423
4405
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
4424
4406
  particlesOptions.load(overrideOptions);
4425
- const effectData = this.effectData;
4407
+ const effectData = this.effectData, shapeData = this.shapeData;
4426
4408
  if (effectData) {
4427
4409
  particlesOptions.load(effectData.particles);
4428
4410
  }
4429
- const shapeData = this.shapeData;
4430
4411
  if (shapeData) {
4431
4412
  particlesOptions.load(shapeData.particles);
4432
4413
  }
@@ -4434,7 +4415,9 @@
4434
4415
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
4435
4416
  this.options = particlesOptions;
4436
4417
  container.retina.initParticle(this);
4437
- this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
4418
+ for (const updater of container.particleUpdaters) {
4419
+ updater.preInit?.(this);
4420
+ }
4438
4421
  this.bubble = {
4439
4422
  inRange: false,
4440
4423
  };
@@ -4442,8 +4425,8 @@
4442
4425
  inRange: false,
4443
4426
  factor: 1,
4444
4427
  };
4445
- this._initPosition(position);
4446
- this.initialVelocity = this._calculateVelocity();
4428
+ this.#initPosition(position);
4429
+ this.initialVelocity = this.#calculateVelocity();
4447
4430
  this.velocity = this.initialVelocity.copy();
4448
4431
  this.zIndexFactor = this.position.z / container.zLayers;
4449
4432
  this.sides = 24;
@@ -4474,12 +4457,11 @@
4474
4457
  plugin.particleCreated?.(this);
4475
4458
  }
4476
4459
  }
4477
- isInsideCanvas() {
4478
- const radius = this.getRadius(), canvasSize = this._container.canvas.size, position = this.position;
4479
- return (position.x >= -radius &&
4480
- position.y >= -radius &&
4481
- position.y <= canvasSize.height + radius &&
4482
- position.x <= canvasSize.width + radius);
4460
+ isInsideCanvas(direction) {
4461
+ return this.#getInsideCanvasResult({ direction }).inside;
4462
+ }
4463
+ isInsideCanvasForOutMode(outMode, direction) {
4464
+ return this.#getInsideCanvasResult({ direction, outMode }).inside;
4483
4465
  }
4484
4466
  isShowingBack() {
4485
4467
  if (!this.roll) {
@@ -4504,13 +4486,13 @@
4504
4486
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
4505
4487
  }
4506
4488
  reset() {
4507
- for (const updater of this._container.particleUpdaters) {
4489
+ for (const updater of this.#container.particleUpdaters) {
4508
4490
  updater.reset?.(this);
4509
4491
  }
4510
4492
  }
4511
- _calcPosition = (position, zIndex) => {
4493
+ #calcPosition = (position, zIndex) => {
4512
4494
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
4513
- const container = this._container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
4495
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
4514
4496
  while (!signal.aborted) {
4515
4497
  for (const plugin of plugins) {
4516
4498
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -4522,10 +4504,10 @@
4522
4504
  size: canvasSize,
4523
4505
  position: posVec,
4524
4506
  }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
4525
- this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
4526
- this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
4527
- this._fixVertical(pos, radius, outModes.top ?? outModes.default);
4528
- this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
4507
+ this.#fixHorizontal(pos, radius, outModes.left ?? outModes.default);
4508
+ this.#fixHorizontal(pos, radius, outModes.right ?? outModes.default);
4509
+ this.#fixVertical(pos, radius, outModes.top ?? outModes.default);
4510
+ this.#fixVertical(pos, radius, outModes.bottom ?? outModes.default);
4529
4511
  let isValidPosition = true;
4530
4512
  for (const plugin of container.particles.checkParticlePositionPlugins) {
4531
4513
  isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
@@ -4541,8 +4523,8 @@
4541
4523
  }
4542
4524
  return posVec;
4543
4525
  };
4544
- _calculateVelocity = () => {
4545
- const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
4526
+ #calculateVelocity = () => {
4527
+ const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
4546
4528
  if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
4547
4529
  return res;
4548
4530
  }
@@ -4558,27 +4540,86 @@
4558
4540
  }
4559
4541
  return res;
4560
4542
  };
4561
- _fixHorizontal = (pos, radius, outMode) => {
4543
+ #fixHorizontal = (pos, radius, outMode) => {
4562
4544
  fixOutMode({
4563
4545
  outMode,
4564
4546
  checkModes: [OutMode.bounce],
4565
4547
  coord: pos.x,
4566
- maxCoord: this._container.canvas.size.width,
4548
+ maxCoord: this.#container.canvas.size.width,
4567
4549
  setCb: (value) => (pos.x += value),
4568
4550
  radius,
4569
4551
  });
4570
4552
  };
4571
- _fixVertical = (pos, radius, outMode) => {
4553
+ #fixVertical = (pos, radius, outMode) => {
4572
4554
  fixOutMode({
4573
4555
  outMode,
4574
4556
  checkModes: [OutMode.bounce],
4575
4557
  coord: pos.y,
4576
- maxCoord: this._container.canvas.size.height,
4558
+ maxCoord: this.#container.canvas.size.height,
4577
4559
  setCb: (value) => (pos.y += value),
4578
4560
  radius,
4579
4561
  });
4580
4562
  };
4581
- _getRollColor = color => {
4563
+ #getDefaultInsideCanvasResult = (direction, outMode) => {
4564
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
4565
+ if (direction === OutModeDirection.bottom) {
4566
+ return {
4567
+ inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
4568
+ reason: "default",
4569
+ };
4570
+ }
4571
+ if (direction === OutModeDirection.left) {
4572
+ return {
4573
+ inside: isBounce ? position.x - radius > defaultAngle : position.x + radius > defaultAngle,
4574
+ reason: "default",
4575
+ };
4576
+ }
4577
+ if (direction === OutModeDirection.right) {
4578
+ return {
4579
+ inside: isBounce ? position.x + radius < canvasSize.width : position.x - radius < canvasSize.width,
4580
+ reason: "default",
4581
+ };
4582
+ }
4583
+ if (direction === OutModeDirection.top) {
4584
+ return {
4585
+ inside: isBounce ? position.y - radius > defaultAngle : position.y + radius > defaultAngle,
4586
+ reason: "default",
4587
+ };
4588
+ }
4589
+ return {
4590
+ inside: position.x >= -radius &&
4591
+ position.y >= -radius &&
4592
+ position.y <= canvasSize.height + radius &&
4593
+ position.x <= canvasSize.width + radius,
4594
+ reason: "default",
4595
+ };
4596
+ };
4597
+ #getInsideCanvasCallbackData = (direction, outMode) => {
4598
+ return {
4599
+ canvasSize: this.#container.canvas.size,
4600
+ direction,
4601
+ outMode,
4602
+ particle: this,
4603
+ radius: this.getRadius(),
4604
+ };
4605
+ };
4606
+ #getInsideCanvasResult = (data) => {
4607
+ 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;
4608
+ if (!shapeCheck && !effectCheck) {
4609
+ return defaultResult;
4610
+ }
4611
+ const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
4612
+ if (shapeResult && effectResult) {
4613
+ const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
4614
+ return {
4615
+ inside: shapeResult.inside && effectResult.inside,
4616
+ margin: margin > defaultAngle ? margin : undefined,
4617
+ reason: "combined",
4618
+ };
4619
+ }
4620
+ return shapeResult ?? effectResult ?? defaultResult;
4621
+ };
4622
+ #getRollColor = color => {
4582
4623
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
4583
4624
  return color;
4584
4625
  }
@@ -4593,8 +4634,8 @@
4593
4634
  }
4594
4635
  return color;
4595
4636
  };
4596
- _initPosition = position => {
4597
- const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
4637
+ #initPosition = position => {
4638
+ const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
4598
4639
  if (!initialPosition) {
4599
4640
  throw new Error("a valid position cannot be found for particle");
4600
4641
  }
@@ -4617,45 +4658,58 @@
4617
4658
  }
4618
4659
  this.offset = Vector.origin;
4619
4660
  };
4661
+ #normalizeInsideCanvasResult = (result, reason) => {
4662
+ if (typeof result === "boolean") {
4663
+ return {
4664
+ inside: result,
4665
+ reason,
4666
+ };
4667
+ }
4668
+ return {
4669
+ inside: result.inside,
4670
+ margin: result.margin,
4671
+ reason: result.reason ?? reason,
4672
+ };
4673
+ };
4620
4674
  }
4621
4675
 
4622
4676
  class SpatialHashGrid {
4623
- _cellSize;
4624
- _cells = new Map();
4625
- _circlePool = [];
4626
- _circlePoolIdx;
4627
- _pendingCellSize;
4628
- _rectanglePool = [];
4629
- _rectanglePoolIdx;
4677
+ #cellSize;
4678
+ #cells = new Map();
4679
+ #circlePool = [];
4680
+ #circlePoolIdx;
4681
+ #pendingCellSize;
4682
+ #rectanglePool = [];
4683
+ #rectanglePoolIdx;
4630
4684
  constructor(cellSize) {
4631
- this._cellSize = cellSize;
4632
- this._circlePoolIdx = 0;
4633
- this._rectanglePoolIdx = 0;
4685
+ this.#cellSize = cellSize;
4686
+ this.#circlePoolIdx = 0;
4687
+ this.#rectanglePoolIdx = 0;
4634
4688
  }
4635
4689
  clear() {
4636
- this._cells.clear();
4637
- const pendingCellSize = this._pendingCellSize;
4690
+ this.#cells.clear();
4691
+ const pendingCellSize = this.#pendingCellSize;
4638
4692
  if (pendingCellSize) {
4639
- this._cellSize = pendingCellSize;
4693
+ this.#cellSize = pendingCellSize;
4640
4694
  }
4641
- this._pendingCellSize = undefined;
4695
+ this.#pendingCellSize = undefined;
4642
4696
  }
4643
4697
  insert(particle) {
4644
- const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
4645
- if (!this._cells.has(key)) {
4646
- this._cells.set(key, []);
4698
+ const { x, y } = particle.getPosition(), key = this.#cellKeyFromCoords(x, y);
4699
+ if (!this.#cells.has(key)) {
4700
+ this.#cells.set(key, []);
4647
4701
  }
4648
- this._cells.get(key)?.push(particle);
4702
+ this.#cells.get(key)?.push(particle);
4649
4703
  }
4650
4704
  query(range, check, out = []) {
4651
- const bounds = this._getRangeBounds(range);
4705
+ const bounds = this.#getRangeBounds(range);
4652
4706
  if (!bounds) {
4653
4707
  return out;
4654
4708
  }
4655
- 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);
4709
+ 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);
4656
4710
  for (let cx = minCellX; cx <= maxCellX; cx++) {
4657
4711
  for (let cy = minCellY; cy <= maxCellY; cy++) {
4658
- const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
4712
+ const key = `${cx}_${cy}`, cellParticles = this.#cells.get(key);
4659
4713
  if (!cellParticles) {
4660
4714
  continue;
4661
4715
  }
@@ -4672,29 +4726,29 @@
4672
4726
  return out;
4673
4727
  }
4674
4728
  queryCircle(position, radius, check, out = []) {
4675
- const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
4676
- this._releaseShapes();
4729
+ const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
4730
+ this.#releaseShapes();
4677
4731
  return result;
4678
4732
  }
4679
4733
  queryRectangle(position, size, check, out = []) {
4680
- const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
4681
- this._releaseShapes();
4734
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
4735
+ this.#releaseShapes();
4682
4736
  return result;
4683
4737
  }
4684
4738
  setCellSize(cellSize) {
4685
- this._pendingCellSize = cellSize;
4739
+ this.#pendingCellSize = cellSize;
4686
4740
  }
4687
- _acquireCircle(x, y, r) {
4688
- return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
4741
+ #acquireCircle(x, y, r) {
4742
+ return (this.#circlePool[this.#circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
4689
4743
  }
4690
- _acquireRectangle(x, y, w, h) {
4691
- return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
4744
+ #acquireRectangle(x, y, w, h) {
4745
+ return (this.#rectanglePool[this.#rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
4692
4746
  }
4693
- _cellKeyFromCoords(x, y) {
4694
- const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
4747
+ #cellKeyFromCoords(x, y) {
4748
+ const cellX = Math.floor(x / this.#cellSize), cellY = Math.floor(y / this.#cellSize);
4695
4749
  return `${cellX}_${cellY}`;
4696
4750
  }
4697
- _getRangeBounds(range) {
4751
+ #getRangeBounds(range) {
4698
4752
  if (range instanceof Circle) {
4699
4753
  const r = range.radius, { x, y } = range.position;
4700
4754
  return {
@@ -4715,53 +4769,53 @@
4715
4769
  }
4716
4770
  return null;
4717
4771
  }
4718
- _releaseShapes() {
4719
- this._circlePoolIdx = 0;
4720
- this._rectanglePoolIdx = 0;
4772
+ #releaseShapes() {
4773
+ this.#circlePoolIdx = 0;
4774
+ this.#rectanglePoolIdx = 0;
4721
4775
  }
4722
4776
  }
4723
4777
 
4724
4778
  class ParticlesManager {
4725
4779
  checkParticlePositionPlugins;
4726
4780
  grid;
4727
- _array;
4728
- _container;
4729
- _groupLimits;
4730
- _limit;
4731
- _nextId;
4732
- _particleBuckets;
4733
- _particleResetPlugins;
4734
- _particleUpdatePlugins;
4735
- _pluginManager;
4736
- _pool;
4737
- _postParticleUpdatePlugins;
4738
- _postUpdatePlugins;
4739
- _resizeFactor;
4740
- _updatePlugins;
4741
- _zBuckets;
4781
+ #array;
4782
+ #container;
4783
+ #groupLimits;
4784
+ #limit;
4785
+ #nextId;
4786
+ #particleBuckets;
4787
+ #particleResetPlugins;
4788
+ #particleUpdatePlugins;
4789
+ #pluginManager;
4790
+ #pool;
4791
+ #postParticleUpdatePlugins;
4792
+ #postUpdatePlugins;
4793
+ #resizeFactor;
4794
+ #updatePlugins;
4795
+ #zBuckets;
4742
4796
  constructor(pluginManager, container) {
4743
- this._pluginManager = pluginManager;
4744
- this._container = container;
4745
- this._nextId = 0;
4746
- this._array = [];
4747
- this._pool = [];
4748
- this._limit = 0;
4749
- this._groupLimits = new Map();
4750
- this._particleBuckets = new Map();
4751
- this._zBuckets = this._createBuckets(this._container.zLayers);
4797
+ this.#pluginManager = pluginManager;
4798
+ this.#container = container;
4799
+ this.#nextId = 0;
4800
+ this.#array = [];
4801
+ this.#pool = [];
4802
+ this.#limit = 0;
4803
+ this.#groupLimits = new Map();
4804
+ this.#particleBuckets = new Map();
4805
+ this.#zBuckets = this.#createBuckets(this.#container.zLayers);
4752
4806
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
4753
4807
  this.checkParticlePositionPlugins = [];
4754
- this._particleResetPlugins = [];
4755
- this._particleUpdatePlugins = [];
4756
- this._postUpdatePlugins = [];
4757
- this._postParticleUpdatePlugins = [];
4758
- this._updatePlugins = [];
4808
+ this.#particleResetPlugins = [];
4809
+ this.#particleUpdatePlugins = [];
4810
+ this.#postUpdatePlugins = [];
4811
+ this.#postParticleUpdatePlugins = [];
4812
+ this.#updatePlugins = [];
4759
4813
  }
4760
4814
  get count() {
4761
- return this._array.length;
4815
+ return this.#array.length;
4762
4816
  }
4763
4817
  addParticle(position, overrideOptions, group, initializer) {
4764
- const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
4818
+ const limitMode = this.#container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this.#limit : (this.#groupLimits.get(group) ?? this.#limit), currentCount = this.count;
4765
4819
  if (limit > minLimit) {
4766
4820
  switch (limitMode) {
4767
4821
  case LimitMode.delete: {
@@ -4779,20 +4833,20 @@
4779
4833
  }
4780
4834
  }
4781
4835
  try {
4782
- const particle = this._pool.pop() ?? new Particle(this._pluginManager, this._container);
4783
- particle.init(this._nextId, position, overrideOptions, group);
4836
+ const particle = this.#pool.pop() ?? new Particle(this.#pluginManager, this.#container);
4837
+ particle.init(this.#nextId, position, overrideOptions, group);
4784
4838
  let canAdd = true;
4785
4839
  if (initializer) {
4786
4840
  canAdd = initializer(particle);
4787
4841
  }
4788
4842
  if (!canAdd) {
4789
- this._pool.push(particle);
4843
+ this.#pool.push(particle);
4790
4844
  return;
4791
4845
  }
4792
- this._array.push(particle);
4793
- this._insertParticleIntoBucket(particle);
4794
- this._nextId++;
4795
- this._container.dispatchEvent(EventType.particleAdded, {
4846
+ this.#array.push(particle);
4847
+ this.#insertParticleIntoBucket(particle);
4848
+ this.#nextId++;
4849
+ this.#container.dispatchEvent(EventType.particleAdded, {
4796
4850
  particle,
4797
4851
  });
4798
4852
  return particle;
@@ -4803,25 +4857,25 @@
4803
4857
  return undefined;
4804
4858
  }
4805
4859
  clear() {
4806
- this._array = [];
4807
- this._particleBuckets.clear();
4808
- this._resetBuckets(this._container.zLayers);
4860
+ this.#array = [];
4861
+ this.#particleBuckets.clear();
4862
+ this.#resetBuckets(this.#container.zLayers);
4809
4863
  }
4810
4864
  destroy() {
4811
- this._array = [];
4812
- this._pool.length = 0;
4813
- this._particleBuckets.clear();
4814
- this._zBuckets = [];
4865
+ this.#array = [];
4866
+ this.#pool.length = 0;
4867
+ this.#particleBuckets.clear();
4868
+ this.#zBuckets = [];
4815
4869
  this.checkParticlePositionPlugins = [];
4816
- this._particleResetPlugins = [];
4817
- this._particleUpdatePlugins = [];
4818
- this._postUpdatePlugins = [];
4819
- this._postParticleUpdatePlugins = [];
4820
- this._updatePlugins = [];
4870
+ this.#particleResetPlugins = [];
4871
+ this.#particleUpdatePlugins = [];
4872
+ this.#postUpdatePlugins = [];
4873
+ this.#postParticleUpdatePlugins = [];
4874
+ this.#updatePlugins = [];
4821
4875
  }
4822
4876
  drawParticles(delta) {
4823
- for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
4824
- const bucket = this._zBuckets[i];
4877
+ for (let i = this.#zBuckets.length - one; i >= minIndex; i--) {
4878
+ const bucket = this.#zBuckets[i];
4825
4879
  if (!bucket) {
4826
4880
  continue;
4827
4881
  }
@@ -4831,24 +4885,24 @@
4831
4885
  }
4832
4886
  }
4833
4887
  filter(condition) {
4834
- return this._array.filter(condition);
4888
+ return this.#array.filter(condition);
4835
4889
  }
4836
4890
  find(condition) {
4837
- return this._array.find(condition);
4891
+ return this.#array.find(condition);
4838
4892
  }
4839
4893
  get(index) {
4840
- return this._array[index];
4894
+ return this.#array[index];
4841
4895
  }
4842
4896
  async init() {
4843
- const container = this._container, options = container.actualOptions;
4897
+ const container = this.#container, options = container.actualOptions;
4844
4898
  this.checkParticlePositionPlugins = [];
4845
- this._updatePlugins = [];
4846
- this._particleUpdatePlugins = [];
4847
- this._postUpdatePlugins = [];
4848
- this._particleResetPlugins = [];
4849
- this._postParticleUpdatePlugins = [];
4850
- this._particleBuckets.clear();
4851
- this._resetBuckets(container.zLayers);
4899
+ this.#updatePlugins = [];
4900
+ this.#particleUpdatePlugins = [];
4901
+ this.#postUpdatePlugins = [];
4902
+ this.#particleResetPlugins = [];
4903
+ this.#postParticleUpdatePlugins = [];
4904
+ this.#particleBuckets.clear();
4905
+ this.#resetBuckets(container.zLayers);
4852
4906
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
4853
4907
  for (const plugin of container.plugins) {
4854
4908
  if (plugin.redrawInit) {
@@ -4858,26 +4912,26 @@
4858
4912
  this.checkParticlePositionPlugins.push(plugin);
4859
4913
  }
4860
4914
  if (plugin.update) {
4861
- this._updatePlugins.push(plugin);
4915
+ this.#updatePlugins.push(plugin);
4862
4916
  }
4863
4917
  if (plugin.particleUpdate) {
4864
- this._particleUpdatePlugins.push(plugin);
4918
+ this.#particleUpdatePlugins.push(plugin);
4865
4919
  }
4866
4920
  if (plugin.postUpdate) {
4867
- this._postUpdatePlugins.push(plugin);
4921
+ this.#postUpdatePlugins.push(plugin);
4868
4922
  }
4869
4923
  if (plugin.particleReset) {
4870
- this._particleResetPlugins.push(plugin);
4924
+ this.#particleResetPlugins.push(plugin);
4871
4925
  }
4872
4926
  if (plugin.postParticleUpdate) {
4873
- this._postParticleUpdatePlugins.push(plugin);
4927
+ this.#postParticleUpdatePlugins.push(plugin);
4874
4928
  }
4875
4929
  }
4876
- await this._container.initDrawersAndUpdaters();
4877
- for (const drawer of this._container.effectDrawers.values()) {
4930
+ await this.#container.initDrawersAndUpdaters();
4931
+ for (const drawer of this.#container.effectDrawers.values()) {
4878
4932
  await drawer.init?.(container);
4879
4933
  }
4880
- for (const drawer of this._container.shapeDrawers.values()) {
4934
+ for (const drawer of this.#container.shapeDrawers.values()) {
4881
4935
  await drawer.init?.(container);
4882
4936
  }
4883
4937
  let handled = false;
@@ -4911,10 +4965,10 @@
4911
4965
  async redraw() {
4912
4966
  this.clear();
4913
4967
  await this.init();
4914
- this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
4968
+ this.#container.canvas.render.drawParticles({ value: 0, factor: 0 });
4915
4969
  }
4916
4970
  remove(particle, group, override) {
4917
- this.removeAt(this._array.indexOf(particle), undefined, group, override);
4971
+ this.removeAt(this.#array.indexOf(particle), undefined, group, override);
4918
4972
  }
4919
4973
  removeAt(index, quantity = defaultRemoveQuantity, group, override) {
4920
4974
  if (index < minIndex || index > this.count) {
@@ -4922,7 +4976,7 @@
4922
4976
  }
4923
4977
  let deleted = 0;
4924
4978
  for (let i = index; deleted < quantity && i < this.count; i++) {
4925
- if (this._removeParticle(i, group, override)) {
4979
+ if (this.#removeParticle(i, group, override)) {
4926
4980
  i--;
4927
4981
  deleted++;
4928
4982
  }
@@ -4932,9 +4986,9 @@
4932
4986
  this.removeAt(minIndex, quantity, group);
4933
4987
  }
4934
4988
  setDensity() {
4935
- const options = this._container.actualOptions, groups = options.particles.groups;
4989
+ const options = this.#container.actualOptions, groups = options.particles.groups;
4936
4990
  let pluginsCount = 0;
4937
- for (const plugin of this._container.plugins) {
4991
+ for (const plugin of this.#container.plugins) {
4938
4992
  if (plugin.particlesDensityCount) {
4939
4993
  pluginsCount += plugin.particlesDensityCount();
4940
4994
  }
@@ -4944,51 +4998,51 @@
4944
4998
  if (!groupData) {
4945
4999
  continue;
4946
5000
  }
4947
- const groupDataOptions = loadParticlesOptions(this._pluginManager, this._container, groupData);
4948
- this._applyDensity(groupDataOptions, pluginsCount, group);
5001
+ const groupDataOptions = loadParticlesOptions(this.#pluginManager, this.#container, groupData);
5002
+ this.#applyDensity(groupDataOptions, pluginsCount, group);
4949
5003
  }
4950
- this._applyDensity(options.particles, pluginsCount);
5004
+ this.#applyDensity(options.particles, pluginsCount);
4951
5005
  }
4952
5006
  setResizeFactor(factor) {
4953
- this._resizeFactor = factor;
5007
+ this.#resizeFactor = factor;
4954
5008
  }
4955
5009
  update(delta) {
4956
5010
  this.grid.clear();
4957
- for (const plugin of this._updatePlugins) {
5011
+ for (const plugin of this.#updatePlugins) {
4958
5012
  plugin.update?.(delta);
4959
5013
  }
4960
- const particlesToDelete = this._updateParticlesPhase1(delta);
4961
- for (const plugin of this._postUpdatePlugins) {
5014
+ const particlesToDelete = this.#updateParticlesPhase1(delta);
5015
+ for (const plugin of this.#postUpdatePlugins) {
4962
5016
  plugin.postUpdate?.(delta);
4963
5017
  }
4964
- this._updateParticlesPhase2(delta, particlesToDelete);
5018
+ this.#updateParticlesPhase2(delta, particlesToDelete);
4965
5019
  if (particlesToDelete.size) {
4966
5020
  for (const particle of particlesToDelete) {
4967
5021
  this.remove(particle);
4968
5022
  }
4969
5023
  }
4970
- delete this._resizeFactor;
5024
+ this.#resizeFactor = undefined;
4971
5025
  }
4972
- _addToPool = (...particles) => {
4973
- this._pool.push(...particles);
5026
+ #addToPool = (...particles) => {
5027
+ this.#pool.push(...particles);
4974
5028
  };
4975
- _applyDensity = (options, pluginsCount, group, groupOptions) => {
5029
+ #applyDensity = (options, pluginsCount, group, groupOptions) => {
4976
5030
  const numberOptions = options.number;
4977
5031
  if (!numberOptions.density.enable) {
4978
5032
  if (group === undefined) {
4979
- this._limit = numberOptions.limit.value;
5033
+ this.#limit = numberOptions.limit.value;
4980
5034
  }
4981
5035
  else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
4982
- this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5036
+ this.#groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
4983
5037
  }
4984
5038
  return;
4985
5039
  }
4986
- 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);
5040
+ 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);
4987
5041
  if (group === undefined) {
4988
- this._limit = numberOptions.limit.value * densityFactor;
5042
+ this.#limit = numberOptions.limit.value * densityFactor;
4989
5043
  }
4990
5044
  else {
4991
- this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
5045
+ this.#groupLimits.set(group, numberOptions.limit.value * densityFactor);
4992
5046
  }
4993
5047
  if (particlesCount < particlesNumber) {
4994
5048
  this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
@@ -4997,18 +5051,18 @@
4997
5051
  this.removeQuantity(particlesCount - particlesNumber, group);
4998
5052
  }
4999
5053
  };
5000
- _createBuckets = (zLayers) => {
5054
+ #createBuckets = (zLayers) => {
5001
5055
  const bucketCount = Math.max(Math.floor(zLayers), one);
5002
5056
  return Array.from({ length: bucketCount }, () => []);
5003
5057
  };
5004
- _getBucketIndex = (zIndex) => {
5005
- const maxBucketIndex = this._zBuckets.length - one;
5058
+ #getBucketIndex = (zIndex) => {
5059
+ const maxBucketIndex = this.#zBuckets.length - one;
5006
5060
  if (maxBucketIndex <= minIndex) {
5007
5061
  return minIndex;
5008
5062
  }
5009
5063
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
5010
5064
  };
5011
- _getParticleInsertIndex = (bucket, particleId) => {
5065
+ #getParticleInsertIndex = (bucket, particleId) => {
5012
5066
  let start = minIndex, end = bucket.length;
5013
5067
  while (start < end) {
5014
5068
  const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
@@ -5025,8 +5079,8 @@
5025
5079
  }
5026
5080
  return start;
5027
5081
  };
5028
- _initDensityFactor = densityOptions => {
5029
- const container = this._container;
5082
+ #initDensityFactor = densityOptions => {
5083
+ const container = this.#container;
5030
5084
  if (!densityOptions.enable) {
5031
5085
  return defaultDensityFactor;
5032
5086
  }
@@ -5036,82 +5090,82 @@
5036
5090
  }
5037
5091
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
5038
5092
  };
5039
- _insertParticleIntoBucket = (particle) => {
5040
- const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5093
+ #insertParticleIntoBucket = (particle) => {
5094
+ const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5041
5095
  if (!bucket) {
5042
5096
  return;
5043
5097
  }
5044
- bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
5045
- this._particleBuckets.set(particle.id, bucketIndex);
5098
+ bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
5099
+ this.#particleBuckets.set(particle.id, bucketIndex);
5046
5100
  };
5047
- _removeParticle = (index, group, override) => {
5048
- const particle = this._array[index];
5101
+ #removeParticle = (index, group, override) => {
5102
+ const particle = this.#array[index];
5049
5103
  if (!particle) {
5050
5104
  return false;
5051
5105
  }
5052
5106
  if (particle.group !== group) {
5053
5107
  return false;
5054
5108
  }
5055
- this._array.splice(index, deleteCount);
5056
- this._removeParticleFromBucket(particle);
5109
+ this.#array.splice(index, deleteCount);
5110
+ this.#removeParticleFromBucket(particle);
5057
5111
  particle.destroy(override);
5058
- this._container.dispatchEvent(EventType.particleRemoved, {
5112
+ this.#container.dispatchEvent(EventType.particleRemoved, {
5059
5113
  particle,
5060
5114
  });
5061
- this._addToPool(particle);
5115
+ this.#addToPool(particle);
5062
5116
  return true;
5063
5117
  };
5064
- _removeParticleFromBucket = (particle) => {
5065
- const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5118
+ #removeParticleFromBucket = (particle) => {
5119
+ const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5066
5120
  if (!bucket) {
5067
- this._particleBuckets.delete(particle.id);
5121
+ this.#particleBuckets.delete(particle.id);
5068
5122
  return;
5069
5123
  }
5070
- const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
5124
+ const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
5071
5125
  if (bucket[particleIndex]?.id !== particle.id) {
5072
- this._particleBuckets.delete(particle.id);
5126
+ this.#particleBuckets.delete(particle.id);
5073
5127
  return;
5074
5128
  }
5075
5129
  bucket.splice(particleIndex, deleteCount);
5076
- this._particleBuckets.delete(particle.id);
5130
+ this.#particleBuckets.delete(particle.id);
5077
5131
  };
5078
- _resetBuckets = (zLayers) => {
5132
+ #resetBuckets = (zLayers) => {
5079
5133
  const bucketCount = Math.max(Math.floor(zLayers), one);
5080
- if (this._zBuckets.length !== bucketCount) {
5081
- this._zBuckets = this._createBuckets(bucketCount);
5134
+ if (this.#zBuckets.length !== bucketCount) {
5135
+ this.#zBuckets = this.#createBuckets(bucketCount);
5082
5136
  return;
5083
5137
  }
5084
- for (const bucket of this._zBuckets) {
5138
+ for (const bucket of this.#zBuckets) {
5085
5139
  bucket.length = minIndex;
5086
5140
  }
5087
5141
  };
5088
- _updateParticleBucket = (particle) => {
5089
- const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
5142
+ #updateParticleBucket = (particle) => {
5143
+ const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
5090
5144
  if (currentBucketIndex === undefined) {
5091
- this._insertParticleIntoBucket(particle);
5145
+ this.#insertParticleIntoBucket(particle);
5092
5146
  return;
5093
5147
  }
5094
5148
  if (currentBucketIndex === newBucketIndex) {
5095
5149
  return;
5096
5150
  }
5097
- const currentBucket = this._zBuckets[currentBucketIndex];
5151
+ const currentBucket = this.#zBuckets[currentBucketIndex];
5098
5152
  if (currentBucket) {
5099
- const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
5153
+ const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
5100
5154
  if (currentBucket[particleIndex]?.id === particle.id) {
5101
5155
  currentBucket.splice(particleIndex, deleteCount);
5102
5156
  }
5103
5157
  }
5104
- const newBucket = this._zBuckets[newBucketIndex];
5158
+ const newBucket = this.#zBuckets[newBucketIndex];
5105
5159
  if (!newBucket) {
5106
- this._particleBuckets.set(particle.id, newBucketIndex);
5160
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5107
5161
  return;
5108
5162
  }
5109
- newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
5110
- this._particleBuckets.set(particle.id, newBucketIndex);
5163
+ newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
5164
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5111
5165
  };
5112
- _updateParticlesPhase1 = (delta) => {
5113
- const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
5114
- for (const particle of this._array) {
5166
+ #updateParticlesPhase1 = (delta) => {
5167
+ const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
5168
+ for (const particle of this.#array) {
5115
5169
  if (resizeFactor && !particle.ignoresResizeRatio) {
5116
5170
  particle.position.x *= resizeFactor.width;
5117
5171
  particle.position.y *= resizeFactor.height;
@@ -5119,10 +5173,10 @@
5119
5173
  particle.initialPosition.y *= resizeFactor.height;
5120
5174
  }
5121
5175
  particle.ignoresResizeRatio = false;
5122
- for (const plugin of this._particleResetPlugins) {
5176
+ for (const plugin of this.#particleResetPlugins) {
5123
5177
  plugin.particleReset?.(particle);
5124
5178
  }
5125
- for (const plugin of this._particleUpdatePlugins) {
5179
+ for (const plugin of this.#particleUpdatePlugins) {
5126
5180
  if (particle.destroyed) {
5127
5181
  break;
5128
5182
  }
@@ -5136,36 +5190,36 @@
5136
5190
  }
5137
5191
  return particlesToDelete;
5138
5192
  };
5139
- _updateParticlesPhase2 = (delta, particlesToDelete) => {
5140
- for (const particle of this._array) {
5193
+ #updateParticlesPhase2 = (delta, particlesToDelete) => {
5194
+ for (const particle of this.#array) {
5141
5195
  if (particle.destroyed) {
5142
5196
  particlesToDelete.add(particle);
5143
5197
  continue;
5144
5198
  }
5145
- for (const updater of this._container.particleUpdaters) {
5199
+ for (const updater of this.#container.particleUpdaters) {
5146
5200
  updater.update(particle, delta);
5147
5201
  }
5148
5202
  if (!particle.spawning) {
5149
- for (const plugin of this._postParticleUpdatePlugins) {
5203
+ for (const plugin of this.#postParticleUpdatePlugins) {
5150
5204
  plugin.postParticleUpdate?.(particle, delta);
5151
5205
  }
5152
5206
  }
5153
- this._updateParticleBucket(particle);
5207
+ this.#updateParticleBucket(particle);
5154
5208
  }
5155
5209
  };
5156
5210
  }
5157
5211
 
5158
5212
  class Retina {
5159
- container;
5160
5213
  pixelRatio;
5161
5214
  reduceFactor;
5215
+ #container;
5162
5216
  constructor(container) {
5163
- this.container = container;
5217
+ this.#container = container;
5164
5218
  this.pixelRatio = defaultRatio;
5165
5219
  this.reduceFactor = defaultReduceFactor;
5166
5220
  }
5167
5221
  init() {
5168
- const container = this.container, options = container.actualOptions;
5222
+ const container = this.#container, options = container.actualOptions;
5169
5223
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
5170
5224
  this.reduceFactor = defaultReduceFactor;
5171
5225
  const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
@@ -5179,7 +5233,6 @@
5179
5233
  props.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
5180
5234
  props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
5181
5235
  props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
5182
- props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
5183
5236
  const maxDistance = props.maxDistance;
5184
5237
  maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
5185
5238
  maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
@@ -5217,73 +5270,73 @@
5217
5270
  shapeDrawers;
5218
5271
  started;
5219
5272
  zLayers;
5220
- _delay;
5221
- _delayTimeout;
5222
- _delta = { value: 0, factor: 0 };
5223
- _dispatchCallback;
5224
- _drawAnimationFrame;
5225
- _duration;
5226
- _eventListeners;
5227
- _firstStart;
5228
- _initialSourceOptions;
5229
- _lastFrameTime;
5230
- _lifeTime;
5231
- _onDestroy;
5232
- _options;
5233
- _paused;
5234
- _pluginManager;
5235
- _smooth;
5236
- _sourceOptions;
5273
+ #delay;
5274
+ #delayTimeout;
5275
+ #delta = { value: 0, factor: 0 };
5276
+ #dispatchCallback;
5277
+ #drawAnimationFrame;
5278
+ #duration;
5279
+ #eventListeners;
5280
+ #firstStart;
5281
+ #initialSourceOptions;
5282
+ #lastFrameTime;
5283
+ #lifeTime;
5284
+ #onDestroy;
5285
+ #options;
5286
+ #paused;
5287
+ #pluginManager;
5288
+ #smooth;
5289
+ #sourceOptions;
5237
5290
  constructor(params) {
5238
5291
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
5239
- this._pluginManager = pluginManager;
5240
- this._dispatchCallback = dispatchCallback;
5241
- this._onDestroy = onDestroy;
5292
+ this.#pluginManager = pluginManager;
5293
+ this.#dispatchCallback = dispatchCallback;
5294
+ this.#onDestroy = onDestroy;
5242
5295
  this.id = Symbol(id);
5243
5296
  this.fpsLimit = 120;
5244
5297
  this.hdr = false;
5245
- this._smooth = false;
5246
- this._delay = 0;
5247
- this._duration = 0;
5248
- this._lifeTime = 0;
5249
- this._firstStart = true;
5298
+ this.#smooth = false;
5299
+ this.#delay = 0;
5300
+ this.#duration = 0;
5301
+ this.#lifeTime = 0;
5302
+ this.#firstStart = true;
5250
5303
  this.started = false;
5251
5304
  this.destroyed = false;
5252
- this._paused = true;
5253
- this._lastFrameTime = 0;
5305
+ this.#paused = true;
5306
+ this.#lastFrameTime = 0;
5254
5307
  this.zLayers = 100;
5255
5308
  this.pageHidden = false;
5256
- this._sourceOptions = sourceOptions;
5257
- this._initialSourceOptions = sourceOptions;
5309
+ this.#sourceOptions = sourceOptions;
5310
+ this.#initialSourceOptions = sourceOptions;
5258
5311
  this.effectDrawers = new Map();
5259
5312
  this.shapeDrawers = new Map();
5260
5313
  this.particleUpdaters = [];
5261
5314
  this.retina = new Retina(this);
5262
- this.canvas = new CanvasManager(this._pluginManager, this);
5263
- this.particles = new ParticlesManager(this._pluginManager, this);
5315
+ this.canvas = new CanvasManager(this.#pluginManager, this);
5316
+ this.particles = new ParticlesManager(this.#pluginManager, this);
5264
5317
  this.plugins = [];
5265
5318
  this.particleDestroyedPlugins = [];
5266
5319
  this.particleCreatedPlugins = [];
5267
5320
  this.particlePositionPlugins = [];
5268
- this._options = loadContainerOptions(this._pluginManager, this);
5269
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
5270
- this._eventListeners = new EventListeners(this);
5321
+ this.#options = loadContainerOptions(this.#pluginManager, this);
5322
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
5323
+ this.#eventListeners = new EventListeners(this);
5271
5324
  this.dispatchEvent(EventType.containerBuilt);
5272
5325
  }
5273
5326
  get animationStatus() {
5274
- return !this._paused && !this.pageHidden && guardCheck(this);
5327
+ return !this.#paused && !this.pageHidden && guardCheck(this);
5275
5328
  }
5276
5329
  get options() {
5277
- return this._options;
5330
+ return this.#options;
5278
5331
  }
5279
5332
  get sourceOptions() {
5280
- return this._sourceOptions;
5333
+ return this.#sourceOptions;
5281
5334
  }
5282
5335
  addLifeTime(value) {
5283
- this._lifeTime += value;
5336
+ this.#lifeTime += value;
5284
5337
  }
5285
5338
  alive() {
5286
- return !this._duration || this._lifeTime <= this._duration;
5339
+ return !this.#duration || this.#lifeTime <= this.#duration;
5287
5340
  }
5288
5341
  destroy(remove = true) {
5289
5342
  if (!guardCheck(this)) {
@@ -5305,13 +5358,13 @@
5305
5358
  this.shapeDrawers = new Map();
5306
5359
  this.particleUpdaters = [];
5307
5360
  this.plugins.length = 0;
5308
- this._pluginManager.clearPlugins(this);
5361
+ this.#pluginManager.clearPlugins(this);
5309
5362
  this.destroyed = true;
5310
- this._onDestroy(remove);
5363
+ this.#onDestroy(remove);
5311
5364
  this.dispatchEvent(EventType.containerDestroyed);
5312
5365
  }
5313
5366
  dispatchEvent(type, data) {
5314
- this._dispatchCallback(type, {
5367
+ this.#dispatchCallback(type, {
5315
5368
  container: this,
5316
5369
  data,
5317
5370
  });
@@ -5321,12 +5374,12 @@
5321
5374
  return;
5322
5375
  }
5323
5376
  let refreshTime = force;
5324
- this._drawAnimationFrame = animate((timestamp) => {
5377
+ this.#drawAnimationFrame = animate((timestamp) => {
5325
5378
  if (refreshTime) {
5326
- this._lastFrameTime = undefined;
5379
+ this.#lastFrameTime = undefined;
5327
5380
  refreshTime = false;
5328
5381
  }
5329
- this._nextFrame(timestamp);
5382
+ this.#nextFrame(timestamp);
5330
5383
  });
5331
5384
  }
5332
5385
  async export(type, options = {}) {
@@ -5348,7 +5401,7 @@
5348
5401
  return;
5349
5402
  }
5350
5403
  const allContainerPlugins = new Map();
5351
- for (const plugin of this._pluginManager.plugins) {
5404
+ for (const plugin of this.#pluginManager.plugins) {
5352
5405
  const containerPlugin = await plugin.getPlugin(this);
5353
5406
  if (containerPlugin.preInit) {
5354
5407
  await containerPlugin.preInit();
@@ -5356,8 +5409,8 @@
5356
5409
  allContainerPlugins.set(plugin, containerPlugin);
5357
5410
  }
5358
5411
  await this.initDrawersAndUpdaters();
5359
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
5360
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
5412
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
5413
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
5361
5414
  this.plugins.length = 0;
5362
5415
  this.particleDestroyedPlugins.length = 0;
5363
5416
  this.particleCreatedPlugins.length = 0;
@@ -5384,11 +5437,11 @@
5384
5437
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
5385
5438
  this.hdr = hdr;
5386
5439
  this.zLayers = zLayers;
5387
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
5388
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
5389
- this._lifeTime = 0;
5440
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
5441
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
5442
+ this.#lifeTime = 0;
5390
5443
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
5391
- this._smooth = smooth;
5444
+ this.#smooth = smooth;
5392
5445
  for (const plugin of this.plugins) {
5393
5446
  await plugin.init?.();
5394
5447
  }
@@ -5401,7 +5454,7 @@
5401
5454
  this.dispatchEvent(EventType.particlesSetup);
5402
5455
  }
5403
5456
  async initDrawersAndUpdaters() {
5404
- const pluginManager = this._pluginManager;
5457
+ const pluginManager = this.#pluginManager;
5405
5458
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
5406
5459
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
5407
5460
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -5410,18 +5463,18 @@
5410
5463
  if (!guardCheck(this)) {
5411
5464
  return;
5412
5465
  }
5413
- if (this._drawAnimationFrame !== undefined) {
5414
- cancelAnimation(this._drawAnimationFrame);
5415
- delete this._drawAnimationFrame;
5466
+ if (this.#drawAnimationFrame !== undefined) {
5467
+ cancelAnimation(this.#drawAnimationFrame);
5468
+ this.#drawAnimationFrame = undefined;
5416
5469
  }
5417
- if (this._paused) {
5470
+ if (this.#paused) {
5418
5471
  return;
5419
5472
  }
5420
5473
  for (const plugin of this.plugins) {
5421
5474
  plugin.pause?.();
5422
5475
  }
5423
5476
  if (!this.pageHidden) {
5424
- this._paused = true;
5477
+ this.#paused = true;
5425
5478
  }
5426
5479
  this.dispatchEvent(EventType.containerPaused);
5427
5480
  }
@@ -5429,13 +5482,13 @@
5429
5482
  if (!guardCheck(this)) {
5430
5483
  return;
5431
5484
  }
5432
- const needsUpdate = this._paused || force;
5433
- if (this._firstStart && !this.actualOptions.autoPlay) {
5434
- this._firstStart = false;
5485
+ const needsUpdate = this.#paused || force;
5486
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
5487
+ this.#firstStart = false;
5435
5488
  return;
5436
5489
  }
5437
- if (this._paused) {
5438
- this._paused = false;
5490
+ if (this.#paused) {
5491
+ this.#paused = false;
5439
5492
  }
5440
5493
  if (needsUpdate) {
5441
5494
  for (const plugin of this.plugins) {
@@ -5458,10 +5511,10 @@
5458
5511
  if (!guardCheck(this)) {
5459
5512
  return;
5460
5513
  }
5461
- this._initialSourceOptions = sourceOptions;
5462
- this._sourceOptions = sourceOptions;
5463
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
5464
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
5514
+ this.#initialSourceOptions = sourceOptions;
5515
+ this.#sourceOptions = sourceOptions;
5516
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
5517
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
5465
5518
  return this.refresh();
5466
5519
  }
5467
5520
  async start() {
@@ -5472,7 +5525,7 @@
5472
5525
  this.started = true;
5473
5526
  await new Promise(resolve => {
5474
5527
  const start = async () => {
5475
- this._eventListeners.addListeners();
5528
+ this.#eventListeners.addListeners();
5476
5529
  for (const plugin of this.plugins) {
5477
5530
  await plugin.start?.();
5478
5531
  }
@@ -5480,20 +5533,20 @@
5480
5533
  this.play();
5481
5534
  resolve();
5482
5535
  };
5483
- this._delayTimeout = setTimeout(() => void start(), this._delay);
5536
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
5484
5537
  });
5485
5538
  }
5486
5539
  stop() {
5487
5540
  if (!guardCheck(this) || !this.started) {
5488
5541
  return;
5489
5542
  }
5490
- if (this._delayTimeout) {
5491
- clearTimeout(this._delayTimeout);
5492
- delete this._delayTimeout;
5543
+ if (this.#delayTimeout) {
5544
+ clearTimeout(this.#delayTimeout);
5545
+ this.#delayTimeout = undefined;
5493
5546
  }
5494
- this._firstStart = true;
5547
+ this.#firstStart = true;
5495
5548
  this.started = false;
5496
- this._eventListeners.removeListeners();
5549
+ this.#eventListeners.removeListeners();
5497
5550
  this.pause();
5498
5551
  this.particles.clear();
5499
5552
  this.canvas.stop();
@@ -5503,7 +5556,7 @@
5503
5556
  this.particleCreatedPlugins.length = 0;
5504
5557
  this.particleDestroyedPlugins.length = 0;
5505
5558
  this.particlePositionPlugins.length = 0;
5506
- this._sourceOptions = this._options;
5559
+ this.#sourceOptions = this.#options;
5507
5560
  this.dispatchEvent(EventType.containerStopped);
5508
5561
  }
5509
5562
  updateActualOptions() {
@@ -5515,23 +5568,23 @@
5515
5568
  }
5516
5569
  return refresh;
5517
5570
  }
5518
- _nextFrame = (timestamp) => {
5571
+ #nextFrame = (timestamp) => {
5519
5572
  try {
5520
- if (!this._smooth &&
5521
- this._lastFrameTime !== undefined &&
5522
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
5573
+ if (!this.#smooth &&
5574
+ this.#lastFrameTime !== undefined &&
5575
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
5523
5576
  this.draw(false);
5524
5577
  return;
5525
5578
  }
5526
- this._lastFrameTime ??= timestamp;
5527
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
5528
- this.addLifeTime(this._delta.value);
5529
- this._lastFrameTime = timestamp;
5530
- if (this._delta.value > millisecondsToSeconds) {
5579
+ this.#lastFrameTime ??= timestamp;
5580
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
5581
+ this.addLifeTime(this.#delta.value);
5582
+ this.#lastFrameTime = timestamp;
5583
+ if (this.#delta.value > millisecondsToSeconds) {
5531
5584
  this.draw(false);
5532
5585
  return;
5533
5586
  }
5534
- this.canvas.render.drawParticles(this._delta);
5587
+ this.canvas.render.drawParticles(this.#delta);
5535
5588
  if (!this.alive()) {
5536
5589
  this.destroy();
5537
5590
  return;
@@ -5552,44 +5605,44 @@
5552
5605
  });
5553
5606
 
5554
5607
  class EmittersPluginInstance {
5555
- container;
5556
- _instancesManager;
5608
+ #container;
5609
+ #instancesManager;
5557
5610
  constructor(instancesManager, container) {
5558
- this.container = container;
5559
- this._instancesManager = instancesManager;
5560
- this._instancesManager.initContainer(container);
5611
+ this.#instancesManager = instancesManager;
5612
+ this.#container = container;
5613
+ this.#instancesManager.initContainer(container);
5561
5614
  }
5562
5615
  async init() {
5563
- const emittersOptions = this.container.actualOptions.emitters;
5616
+ const emittersOptions = this.#container.actualOptions.emitters;
5564
5617
  if (isArray(emittersOptions)) {
5565
5618
  for (const emitterOptions of emittersOptions) {
5566
- await this._instancesManager.addEmitter(this.container, emitterOptions);
5619
+ await this.#instancesManager.addEmitter(this.#container, emitterOptions);
5567
5620
  }
5568
5621
  }
5569
5622
  else {
5570
- await this._instancesManager.addEmitter(this.container, emittersOptions);
5623
+ await this.#instancesManager.addEmitter(this.#container, emittersOptions);
5571
5624
  }
5572
5625
  }
5573
5626
  pause() {
5574
- for (const emitter of this._instancesManager.getArray(this.container)) {
5627
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
5575
5628
  emitter.pause();
5576
5629
  }
5577
5630
  }
5578
5631
  play() {
5579
- for (const emitter of this._instancesManager.getArray(this.container)) {
5632
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
5580
5633
  emitter.play();
5581
5634
  }
5582
5635
  }
5583
5636
  resize() {
5584
- for (const emitter of this._instancesManager.getArray(this.container)) {
5637
+ for (const emitter of this.#instancesManager.getArray(this.#container)) {
5585
5638
  emitter.resize();
5586
5639
  }
5587
5640
  }
5588
5641
  stop() {
5589
- this._instancesManager.clear(this.container);
5642
+ this.#instancesManager.clear(this.#container);
5590
5643
  }
5591
5644
  update(delta) {
5592
- this._instancesManager.getArray(this.container).forEach(emitter => {
5645
+ this.#instancesManager.getArray(this.#container).forEach(emitter => {
5593
5646
  emitter.update(delta);
5594
5647
  });
5595
5648
  }
@@ -5622,16 +5675,16 @@
5622
5675
 
5623
5676
  const defaultIndex = 0;
5624
5677
  class EmittersInstancesManager {
5625
- _containerArrays;
5626
- _pluginManager;
5678
+ #containerArrays;
5679
+ #pluginManager;
5627
5680
  constructor(pluginManager) {
5628
- this._containerArrays = new Map();
5629
- this._pluginManager = pluginManager;
5681
+ this.#containerArrays = new Map();
5682
+ this.#pluginManager = pluginManager;
5630
5683
  }
5631
5684
  async addEmitter(container, options, position) {
5632
5685
  const emitterOptions = new Emitter();
5633
5686
  emitterOptions.load(options);
5634
- const { EmitterInstance } = await Promise.resolve().then(function () { return EmitterInstance$1; }), emitter = new EmitterInstance(this._pluginManager, container, (emitter) => {
5687
+ const { EmitterInstance } = await Promise.resolve().then(function () { return EmitterInstance$1; }), emitter = new EmitterInstance(this.#pluginManager, container, (emitter) => {
5635
5688
  this.removeEmitter(container, emitter);
5636
5689
  }, emitterOptions, position);
5637
5690
  await emitter.init();
@@ -5640,22 +5693,22 @@
5640
5693
  }
5641
5694
  clear(container) {
5642
5695
  this.initContainer(container);
5643
- this._containerArrays.set(container, []);
5696
+ this.#containerArrays.set(container, []);
5644
5697
  }
5645
5698
  getArray(container) {
5646
5699
  this.initContainer(container);
5647
- let array = this._containerArrays.get(container);
5700
+ let array = this.#containerArrays.get(container);
5648
5701
  if (!array) {
5649
5702
  array = [];
5650
- this._containerArrays.set(container, array);
5703
+ this.#containerArrays.set(container, array);
5651
5704
  }
5652
5705
  return array;
5653
5706
  }
5654
5707
  initContainer(container) {
5655
- if (this._containerArrays.has(container)) {
5708
+ if (this.#containerArrays.has(container)) {
5656
5709
  return;
5657
5710
  }
5658
- this._containerArrays.set(container, []);
5711
+ this.#containerArrays.set(container, []);
5659
5712
  container.getEmitter = (idxOrName) => {
5660
5713
  const array = this.getArray(container);
5661
5714
  return idxOrName === undefined || isNumber(idxOrName)
@@ -5724,34 +5777,34 @@
5724
5777
  spawnStrokeColor;
5725
5778
  spawnStrokeOpacity;
5726
5779
  spawnStrokeWidth;
5727
- _container;
5728
- _currentDuration;
5729
- _currentEmitDelay;
5730
- _currentSpawnDelay;
5731
- _duration;
5732
- _emitDelay;
5733
- _firstSpawn;
5734
- _immortal;
5735
- _initialPosition;
5736
- _lifeCount;
5737
- _mutationObserver;
5738
- _particlesOptions;
5739
- _paused;
5740
- _pluginManager;
5741
- _removeCallback;
5742
- _resizeObserver;
5743
- _shape;
5744
- _size;
5745
- _spawnDelay;
5746
- _startParticlesAdded;
5780
+ #container;
5781
+ #currentDuration;
5782
+ #currentEmitDelay;
5783
+ #currentSpawnDelay;
5784
+ #duration;
5785
+ #emitDelay;
5786
+ #firstSpawn;
5787
+ #immortal;
5788
+ #initialPosition;
5789
+ #lifeCount;
5790
+ #mutationObserver;
5791
+ #particlesOptions;
5792
+ #paused;
5793
+ #pluginManager;
5794
+ #removeCallback;
5795
+ #resizeObserver;
5796
+ #shape;
5797
+ #size;
5798
+ #spawnDelay;
5799
+ #startParticlesAdded;
5747
5800
  constructor(pluginManager, container, removeCallback, options, position) {
5748
- this._pluginManager = pluginManager;
5749
- this._container = container;
5750
- this._removeCallback = removeCallback;
5751
- this._currentDuration = 0;
5752
- this._currentEmitDelay = 0;
5753
- this._currentSpawnDelay = 0;
5754
- this._initialPosition = position;
5801
+ this.#pluginManager = pluginManager;
5802
+ this.#container = container;
5803
+ this.#removeCallback = removeCallback;
5804
+ this.#currentDuration = 0;
5805
+ this.#currentEmitDelay = 0;
5806
+ this.#currentSpawnDelay = 0;
5807
+ this.#initialPosition = position;
5755
5808
  if (options instanceof Emitter) {
5756
5809
  this.options = options;
5757
5810
  }
@@ -5759,159 +5812,159 @@
5759
5812
  this.options = new Emitter();
5760
5813
  this.options.load(options);
5761
5814
  }
5762
- this._spawnDelay = container.retina.reduceFactor
5815
+ this.#spawnDelay = container.retina.reduceFactor
5763
5816
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
5764
5817
  container.retina.reduceFactor
5765
5818
  : Infinity;
5766
- this.position = this._initialPosition ?? this._calcPosition();
5819
+ this.position = this.#initialPosition ?? this.#calcPosition();
5767
5820
  this.name = this.options.name;
5768
5821
  this.fill = this.options.fill;
5769
- this._firstSpawn = !this.options.life.wait;
5770
- this._startParticlesAdded = false;
5822
+ this.#firstSpawn = !this.options.life.wait;
5823
+ this.#startParticlesAdded = false;
5771
5824
  const particlesOptions = deepExtend({}, this.options.particles);
5772
5825
  particlesOptions.move ??= {};
5773
5826
  particlesOptions.move.direction ??= this.options.direction;
5774
5827
  if (this.options.spawn.fill?.color) {
5775
- this.spawnFillColor = rangeColorToHsl(this._pluginManager, this.options.spawn.fill.color);
5828
+ this.spawnFillColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.fill.color);
5776
5829
  }
5777
5830
  if (this.options.spawn.stroke?.color) {
5778
- this.spawnStrokeColor = rangeColorToHsl(this._pluginManager, this.options.spawn.stroke.color);
5779
- }
5780
- this._paused = !this.options.autoPlay;
5781
- this._particlesOptions = particlesOptions;
5782
- this._size = this._calcSize();
5783
- this.size = getSize(this._size, this._container.canvas.size);
5784
- this._lifeCount = this.options.life.count ?? defaultLifeCount;
5785
- this._immortal = this._lifeCount <= minLifeCount;
5831
+ this.spawnStrokeColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.stroke.color);
5832
+ }
5833
+ this.#paused = !this.options.autoPlay;
5834
+ this.#particlesOptions = particlesOptions;
5835
+ this.#size = this.#calcSize();
5836
+ this.size = getSize(this.#size, this.#container.canvas.size);
5837
+ this.#lifeCount = this.options.life.count ?? defaultLifeCount;
5838
+ this.#immortal = this.#lifeCount <= minLifeCount;
5786
5839
  if (this.options.domId) {
5787
5840
  const element = safeDocument().getElementById(this.options.domId);
5788
5841
  if (element) {
5789
- this._mutationObserver = new MutationObserver(() => {
5842
+ this.#mutationObserver = new MutationObserver(() => {
5790
5843
  this.resize();
5791
5844
  });
5792
- this._resizeObserver = new ResizeObserver(() => {
5845
+ this.#resizeObserver = new ResizeObserver(() => {
5793
5846
  this.resize();
5794
5847
  });
5795
- this._mutationObserver.observe(element, {
5848
+ this.#mutationObserver.observe(element, {
5796
5849
  attributes: true,
5797
5850
  attributeFilter: ["style", "width", "height"],
5798
5851
  });
5799
- this._resizeObserver.observe(element);
5852
+ this.#resizeObserver.observe(element);
5800
5853
  }
5801
5854
  }
5802
- const shapeOptions = this.options.shape, shapeGenerator = this._pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
5855
+ const shapeOptions = this.options.shape, shapeGenerator = this.#pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
5803
5856
  if (shapeGenerator) {
5804
- this._shape = shapeGenerator.generate(this._container, this.position, this.size, this.fill, shapeOptions.options);
5857
+ this.#shape = shapeGenerator.generate(this.#container, this.position, this.size, this.fill, shapeOptions.options);
5805
5858
  }
5806
- this._container.dispatchEvent("emitterCreated", {
5859
+ this.#container.dispatchEvent("emitterCreated", {
5807
5860
  emitter: this,
5808
5861
  });
5809
5862
  this.play();
5810
5863
  }
5811
5864
  externalPause() {
5812
- this._paused = true;
5865
+ this.#paused = true;
5813
5866
  this.pause();
5814
5867
  }
5815
5868
  externalPlay() {
5816
- this._paused = false;
5869
+ this.#paused = false;
5817
5870
  this.play();
5818
5871
  }
5819
5872
  async init() {
5820
- await this._shape?.init();
5873
+ await this.#shape?.init();
5821
5874
  }
5822
5875
  pause() {
5823
- if (this._paused) {
5876
+ if (this.#paused) {
5824
5877
  return;
5825
5878
  }
5826
- delete this._emitDelay;
5879
+ this.#emitDelay = undefined;
5827
5880
  }
5828
5881
  play() {
5829
- if (this._paused) {
5882
+ if (this.#paused) {
5830
5883
  return;
5831
5884
  }
5832
- if (!((this._lifeCount > minLifeCount || this._immortal || !this.options.life.count) &&
5833
- (this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? defaultSpawnDelay)))) {
5885
+ if (!((this.#lifeCount > minLifeCount || this.#immortal || !this.options.life.count) &&
5886
+ (this.#firstSpawn || this.#currentSpawnDelay >= (this.#spawnDelay ?? defaultSpawnDelay)))) {
5834
5887
  return;
5835
5888
  }
5836
- const container = this._container;
5837
- if (this._emitDelay === undefined) {
5889
+ const container = this.#container;
5890
+ if (this.#emitDelay === undefined) {
5838
5891
  const delay = getRangeValue(this.options.rate.delay);
5839
- this._emitDelay = container.retina.reduceFactor
5892
+ this.#emitDelay = container.retina.reduceFactor
5840
5893
  ? (delay * millisecondsToSeconds) / container.retina.reduceFactor
5841
5894
  : Infinity;
5842
5895
  }
5843
- if (this._lifeCount > minLifeCount || this._immortal) {
5844
- this._prepareToDie();
5896
+ if (this.#lifeCount > minLifeCount || this.#immortal) {
5897
+ this.#prepareToDie();
5845
5898
  }
5846
5899
  }
5847
5900
  resize() {
5848
- const initialPosition = this._initialPosition, container = this._container;
5901
+ const initialPosition = this.#initialPosition, container = this.#container;
5849
5902
  this.position =
5850
5903
  initialPosition && isPointInside(initialPosition, container.canvas.size, Vector.origin)
5851
5904
  ? initialPosition
5852
- : this._calcPosition();
5853
- this._size = this._calcSize();
5854
- this.size = getSize(this._size, container.canvas.size);
5855
- this._shape?.resize(this.position, this.size);
5905
+ : this.#calcPosition();
5906
+ this.#size = this.#calcSize();
5907
+ this.size = getSize(this.#size, container.canvas.size);
5908
+ this.#shape?.resize(this.position, this.size);
5856
5909
  }
5857
5910
  update(delta) {
5858
- if (this._paused) {
5911
+ if (this.#paused) {
5859
5912
  return;
5860
5913
  }
5861
- const container = this._container;
5862
- if (this._firstSpawn) {
5863
- this._firstSpawn = false;
5864
- this._currentSpawnDelay = this._spawnDelay ?? defaultSpawnDelay;
5865
- this._currentEmitDelay = this._emitDelay ?? defaultEmitDelay;
5914
+ const container = this.#container;
5915
+ if (this.#firstSpawn) {
5916
+ this.#firstSpawn = false;
5917
+ this.#currentSpawnDelay = this.#spawnDelay ?? defaultSpawnDelay;
5918
+ this.#currentEmitDelay = this.#emitDelay ?? defaultEmitDelay;
5866
5919
  }
5867
- if (!this._startParticlesAdded) {
5868
- this._startParticlesAdded = true;
5869
- this._emitParticles(this.options.startCount);
5920
+ if (!this.#startParticlesAdded) {
5921
+ this.#startParticlesAdded = true;
5922
+ this.#emitParticles(this.options.startCount);
5870
5923
  }
5871
- if (this._duration !== undefined) {
5872
- this._currentDuration += delta.value;
5873
- if (this._currentDuration >= this._duration) {
5924
+ if (this.#duration !== undefined) {
5925
+ this.#currentDuration += delta.value;
5926
+ if (this.#currentDuration >= this.#duration) {
5874
5927
  this.pause();
5875
- if (this._spawnDelay !== undefined) {
5876
- delete this._spawnDelay;
5928
+ if (this.#spawnDelay !== undefined) {
5929
+ this.#spawnDelay = undefined;
5877
5930
  }
5878
- if (!this._immortal) {
5879
- this._lifeCount--;
5931
+ if (!this.#immortal) {
5932
+ this.#lifeCount--;
5880
5933
  }
5881
- if (this._lifeCount > minLifeCount || this._immortal) {
5882
- this.position = this._calcPosition();
5883
- this._shape?.resize(this.position, this.size);
5884
- this._spawnDelay = container.retina.reduceFactor
5934
+ if (this.#lifeCount > minLifeCount || this.#immortal) {
5935
+ this.position = this.#calcPosition();
5936
+ this.#shape?.resize(this.position, this.size);
5937
+ this.#spawnDelay = container.retina.reduceFactor
5885
5938
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
5886
5939
  container.retina.reduceFactor
5887
5940
  : Infinity;
5888
5941
  }
5889
5942
  else {
5890
- this._destroy();
5943
+ this.#destroy();
5891
5944
  }
5892
- this._currentDuration -= this._duration;
5893
- delete this._duration;
5945
+ this.#currentDuration -= this.#duration;
5946
+ this.#duration = undefined;
5894
5947
  }
5895
5948
  }
5896
- if (this._spawnDelay !== undefined) {
5897
- this._currentSpawnDelay += delta.value;
5898
- if (this._currentSpawnDelay >= this._spawnDelay) {
5899
- this._container.dispatchEvent("emitterPlay");
5949
+ if (this.#spawnDelay !== undefined) {
5950
+ this.#currentSpawnDelay += delta.value;
5951
+ if (this.#currentSpawnDelay >= this.#spawnDelay) {
5952
+ this.#container.dispatchEvent("emitterPlay");
5900
5953
  this.play();
5901
- this._currentSpawnDelay -= this._spawnDelay;
5902
- delete this._spawnDelay;
5954
+ this.#currentSpawnDelay -= this.#spawnDelay;
5955
+ this.#spawnDelay = undefined;
5903
5956
  }
5904
5957
  }
5905
- if (this._emitDelay !== undefined) {
5906
- this._currentEmitDelay += delta.value;
5907
- if (this._currentEmitDelay >= this._emitDelay) {
5908
- this._emit();
5909
- this._currentEmitDelay -= this._emitDelay;
5958
+ if (this.#emitDelay !== undefined) {
5959
+ this.#currentEmitDelay += delta.value;
5960
+ if (this.#currentEmitDelay >= this.#emitDelay) {
5961
+ this.#emit();
5962
+ this.#currentEmitDelay -= this.#emitDelay;
5910
5963
  }
5911
5964
  }
5912
5965
  }
5913
- _calcPosition() {
5914
- const container = this._container;
5966
+ #calcPosition() {
5967
+ const container = this.#container;
5915
5968
  if (this.options.domId) {
5916
5969
  const element = safeDocument().getElementById(this.options.domId);
5917
5970
  if (element) {
@@ -5927,8 +5980,8 @@
5927
5980
  position: this.options.position,
5928
5981
  });
5929
5982
  }
5930
- _calcSize() {
5931
- const container = this._container;
5983
+ #calcSize() {
5984
+ const container = this.#container;
5932
5985
  if (this.options.domId) {
5933
5986
  const element = safeDocument().getElementById(this.options.domId);
5934
5987
  if (element) {
@@ -5951,32 +6004,32 @@
5951
6004
  return size;
5952
6005
  })());
5953
6006
  }
5954
- _destroy = () => {
5955
- this._mutationObserver?.disconnect();
5956
- this._mutationObserver = undefined;
5957
- this._resizeObserver?.disconnect();
5958
- this._resizeObserver = undefined;
5959
- this._removeCallback(this);
5960
- this._container.dispatchEvent("emitterDestroyed", {
6007
+ #destroy = () => {
6008
+ this.#mutationObserver?.disconnect();
6009
+ this.#mutationObserver = undefined;
6010
+ this.#resizeObserver?.disconnect();
6011
+ this.#resizeObserver = undefined;
6012
+ this.#removeCallback(this);
6013
+ this.#container.dispatchEvent("emitterDestroyed", {
5961
6014
  emitter: this,
5962
6015
  });
5963
6016
  };
5964
- _emit() {
5965
- if (this._paused) {
6017
+ #emit() {
6018
+ if (this.#paused) {
5966
6019
  return;
5967
6020
  }
5968
6021
  const quantity = getRangeValue(this.options.rate.quantity);
5969
- this._emitParticles(quantity);
6022
+ this.#emitParticles(quantity);
5970
6023
  }
5971
- _emitParticles(quantity) {
5972
- const singleParticlesOptions = (itemFromSingleOrMultiple(this._particlesOptions) ??
6024
+ #emitParticles(quantity) {
6025
+ const singleParticlesOptions = (itemFromSingleOrMultiple(this.#particlesOptions) ??
5973
6026
  {}), 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
5974
6027
  ? defaultOpacity$1
5975
6028
  : getRangeValue(this.options.spawn.fill.opacity), strokeHslAnimation = this.options.spawn.stroke?.color?.animation, strokeOpacity = this.options.spawn.stroke?.opacity === undefined
5976
6029
  ? defaultOpacity$1
5977
6030
  : getRangeValue(this.options.spawn.stroke.opacity), strokeWidth = this.options.spawn.stroke?.width === undefined
5978
6031
  ? defaultStrokeWidth
5979
- : 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;
6032
+ : 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;
5980
6033
  for (let i = 0; i < quantity * reduceFactor; i++) {
5981
6034
  const particlesOptions = needsCopy
5982
6035
  ? deepExtend({}, singleParticlesOptions)
@@ -5987,23 +6040,23 @@
5987
6040
  this.spawnStrokeWidth = strokeWidth;
5988
6041
  if (this.spawnFillColor) {
5989
6042
  if (fillHslAnimation && maxValues) {
5990
- this.spawnFillColor.h = this._setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
5991
- this.spawnFillColor.s = this._setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
5992
- this.spawnFillColor.l = this._setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
6043
+ this.spawnFillColor.h = this.#setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
6044
+ this.spawnFillColor.s = this.#setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
6045
+ this.spawnFillColor.l = this.#setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
5993
6046
  }
5994
6047
  setParticlesOptionsFillColor(particlesOptions, this.spawnFillColor, this.spawnFillOpacity, this.spawnFillEnabled);
5995
6048
  }
5996
6049
  if (this.spawnStrokeColor) {
5997
6050
  if (strokeHslAnimation && maxValues) {
5998
- this.spawnStrokeColor.h = this._setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
5999
- this.spawnStrokeColor.s = this._setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
6000
- this.spawnStrokeColor.l = this._setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
6051
+ this.spawnStrokeColor.h = this.#setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
6052
+ this.spawnStrokeColor.s = this.#setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
6053
+ this.spawnStrokeColor.l = this.#setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
6001
6054
  }
6002
6055
  setParticlesOptionsStrokeColor(particlesOptions, this.spawnStrokeColor, this.spawnStrokeOpacity, this.spawnStrokeWidth);
6003
6056
  }
6004
6057
  let position = this.position;
6005
- if (this._shape) {
6006
- const shapePosData = this._shape.randomPosition();
6058
+ if (this.#shape) {
6059
+ const shapePosData = this.#shape.randomPosition();
6007
6060
  if (shapePosData) {
6008
6061
  position = shapePosData.position;
6009
6062
  const replaceData = shapeOptions.replace;
@@ -6016,21 +6069,21 @@
6016
6069
  }
6017
6070
  }
6018
6071
  if (position) {
6019
- this._container.particles.addParticle(position, particlesOptions);
6072
+ this.#container.particles.addParticle(position, particlesOptions);
6020
6073
  }
6021
6074
  }
6022
6075
  }
6023
- _prepareToDie = () => {
6024
- if (this._paused) {
6076
+ #prepareToDie = () => {
6077
+ if (this.#paused) {
6025
6078
  return;
6026
6079
  }
6027
6080
  const duration = this.options.life.duration !== undefined ? getRangeValue(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
6028
- if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
6029
- this._duration = duration * millisecondsToSeconds;
6081
+ if ((this.#lifeCount > minLifeCount || this.#immortal) && duration !== undefined && duration > minDuration) {
6082
+ this.#duration = duration * millisecondsToSeconds;
6030
6083
  }
6031
6084
  };
6032
- _setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
6033
- const container = this._container;
6085
+ #setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
6086
+ const container = this.#container;
6034
6087
  if (!animation.enable) {
6035
6088
  return initValue;
6036
6089
  }