@tsparticles/basic 4.0.5 → 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
- /* tsParticles v4.0.5 */
2
+ /* tsParticles 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
  }
@@ -804,38 +804,38 @@
804
804
  }
805
805
 
806
806
  class EventDispatcher {
807
- _listeners;
807
+ #listeners;
808
808
  constructor() {
809
- this._listeners = new Map();
809
+ this.#listeners = new Map();
810
810
  }
811
811
  addEventListener(type, listener) {
812
812
  this.removeEventListener(type, listener);
813
- let arr = this._listeners.get(type);
813
+ let arr = this.#listeners.get(type);
814
814
  if (!arr) {
815
815
  arr = [];
816
- this._listeners.set(type, arr);
816
+ this.#listeners.set(type, arr);
817
817
  }
818
818
  arr.push(listener);
819
819
  }
820
820
  dispatchEvent(type, args) {
821
- const listeners = this._listeners.get(type);
821
+ const listeners = this.#listeners.get(type);
822
822
  listeners?.forEach(handler => {
823
823
  handler(args);
824
824
  });
825
825
  }
826
826
  hasEventListener(type) {
827
- return !!this._listeners.get(type);
827
+ return !!this.#listeners.get(type);
828
828
  }
829
829
  removeAllEventListeners(type) {
830
830
  if (!type) {
831
- this._listeners = new Map();
831
+ this.#listeners = new Map();
832
832
  }
833
833
  else {
834
- this._listeners.delete(type);
834
+ this.#listeners.delete(type);
835
835
  }
836
836
  }
837
837
  removeEventListener(type, listener) {
838
- const arr = this._listeners.get(type);
838
+ const arr = this.#listeners.get(type);
839
839
  if (!arr) {
840
840
  return;
841
841
  }
@@ -844,7 +844,7 @@
844
844
  return;
845
845
  }
846
846
  if (length === deleteCount) {
847
- this._listeners.delete(type);
847
+ this.#listeners.delete(type);
848
848
  }
849
849
  else {
850
850
  arr.splice(idx, deleteCount);
@@ -882,19 +882,19 @@
882
882
  presets = new Map();
883
883
  shapeDrawers = new Map();
884
884
  updaters = new Map();
885
- _allLoadersSet = new Set();
886
- _configs = new Map();
887
- _engine;
888
- _executedSet = new Set();
889
- _initialized = false;
890
- _isRunningLoaders = false;
891
- _loadPromises = new Set();
885
+ #allLoadersSet = new Set();
886
+ #configs = new Map();
887
+ #engine;
888
+ #executedSet = new Set();
889
+ #initialized = false;
890
+ #isRunningLoaders = false;
891
+ #loadPromises = new Set();
892
892
  constructor(engine) {
893
- this._engine = engine;
893
+ this.#engine = engine;
894
894
  }
895
895
  get configs() {
896
896
  const res = {};
897
- for (const [name, config] of this._configs) {
897
+ for (const [name, config] of this.#configs) {
898
898
  res[name] = config;
899
899
  }
900
900
  return res;
@@ -904,8 +904,8 @@
904
904
  }
905
905
  addConfig(config) {
906
906
  const key = config.key ?? config.name ?? "default";
907
- this._configs.set(key, config);
908
- this._engine.dispatchEvent(exports.EventType.configAdded, { data: { name: key, config } });
907
+ this.#configs.set(key, config);
908
+ this.#engine.dispatchEvent(exports.EventType.configAdded, { data: { name: key, config } });
909
909
  }
910
910
  addEasing(name, easing) {
911
911
  if (this.easingFunctions.get(name)) {
@@ -966,21 +966,21 @@
966
966
  return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
967
967
  }
968
968
  async init() {
969
- if (this._initialized || this._isRunningLoaders) {
969
+ if (this.#initialized || this.#isRunningLoaders) {
970
970
  return;
971
971
  }
972
- this._isRunningLoaders = true;
973
- this._executedSet = new Set();
974
- this._allLoadersSet = new Set(this._loadPromises);
972
+ this.#isRunningLoaders = true;
973
+ this.#executedSet = new Set();
974
+ this.#allLoadersSet = new Set(this.#loadPromises);
975
975
  try {
976
- for (const loader of this._allLoadersSet) {
977
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
976
+ for (const loader of this.#allLoadersSet) {
977
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
978
978
  }
979
979
  }
980
980
  finally {
981
- this._loadPromises.clear();
982
- this._isRunningLoaders = false;
983
- this._initialized = true;
981
+ this.#loadPromises.clear();
982
+ this.#isRunningLoaders = false;
983
+ this.#initialized = true;
984
984
  }
985
985
  }
986
986
  loadParticlesOptions(container, options, ...sourceOptions) {
@@ -991,24 +991,24 @@
991
991
  updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
992
992
  }
993
993
  async register(...loaders) {
994
- if (this._initialized) {
994
+ if (this.#initialized) {
995
995
  throw new Error("Register plugins can only be done before calling tsParticles.load()");
996
996
  }
997
997
  for (const loader of loaders) {
998
- if (this._isRunningLoaders) {
999
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
998
+ if (this.#isRunningLoaders) {
999
+ await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
1000
1000
  }
1001
1001
  else {
1002
- this._loadPromises.add(loader);
1002
+ this.#loadPromises.add(loader);
1003
1003
  }
1004
1004
  }
1005
1005
  }
1006
- async _runLoader(loader, executed, allLoaders) {
1006
+ async #runLoader(loader, executed, allLoaders) {
1007
1007
  if (executed.has(loader))
1008
1008
  return;
1009
1009
  executed.add(loader);
1010
1010
  allLoaders.add(loader);
1011
- await loader(this._engine);
1011
+ await loader(this.#engine);
1012
1012
  }
1013
1013
  }
1014
1014
 
@@ -1111,17 +1111,17 @@
1111
1111
  };
1112
1112
  class Engine {
1113
1113
  pluginManager = new PluginManager(this);
1114
- _domArray = [];
1115
- _eventDispatcher = new EventDispatcher();
1116
- _initialized = false;
1114
+ #domArray = [];
1115
+ #eventDispatcher = new EventDispatcher();
1116
+ #initialized = false;
1117
1117
  get items() {
1118
- return this._domArray;
1118
+ return this.#domArray;
1119
1119
  }
1120
1120
  get version() {
1121
- return "4.0.5";
1121
+ return "4.1.0";
1122
1122
  }
1123
1123
  addEventListener(type, listener) {
1124
- this._eventDispatcher.addEventListener(type, listener);
1124
+ this.#eventDispatcher.addEventListener(type, listener);
1125
1125
  }
1126
1126
  checkVersion(pluginVersion) {
1127
1127
  if (this.version === pluginVersion) {
@@ -1130,17 +1130,17 @@
1130
1130
  throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
1131
1131
  }
1132
1132
  dispatchEvent(type, args) {
1133
- this._eventDispatcher.dispatchEvent(type, args);
1133
+ this.#eventDispatcher.dispatchEvent(type, args);
1134
1134
  }
1135
1135
  async init() {
1136
- if (this._initialized) {
1136
+ if (this.#initialized) {
1137
1137
  return;
1138
1138
  }
1139
1139
  await this.pluginManager.init();
1140
- this._initialized = true;
1140
+ this.#initialized = true;
1141
1141
  }
1142
1142
  item(index) {
1143
- const { items } = this, item = items[index];
1143
+ const items = this.items, item = items[index];
1144
1144
  if (item?.destroyed) {
1145
1145
  items.splice(index, removeDeleteCount);
1146
1146
  return;
@@ -1194,7 +1194,7 @@
1194
1194
  await Promise.all(this.items.map(t => t.refresh()));
1195
1195
  }
1196
1196
  removeEventListener(type, listener) {
1197
- this._eventDispatcher.removeEventListener(type, listener);
1197
+ this.#eventDispatcher.removeEventListener(type, listener);
1198
1198
  }
1199
1199
  }
1200
1200
 
@@ -1965,43 +1965,6 @@
1965
1965
  }
1966
1966
  }
1967
1967
 
1968
- class OpacityAnimation extends RangedAnimationOptions {
1969
- destroy;
1970
- constructor() {
1971
- super();
1972
- this.destroy = exports.DestroyType.none;
1973
- this.speed = 2;
1974
- }
1975
- load(data) {
1976
- super.load(data);
1977
- if (isNull(data)) {
1978
- return;
1979
- }
1980
- if (data.destroy !== undefined) {
1981
- this.destroy = data.destroy;
1982
- }
1983
- }
1984
- }
1985
-
1986
- class Opacity extends RangedAnimationValueWithRandom {
1987
- animation;
1988
- constructor() {
1989
- super();
1990
- this.animation = new OpacityAnimation();
1991
- this.value = 1;
1992
- }
1993
- load(data) {
1994
- if (isNull(data)) {
1995
- return;
1996
- }
1997
- super.load(data);
1998
- const animation = data.animation;
1999
- if (animation !== undefined) {
2000
- this.animation.load(animation);
2001
- }
2002
- }
2003
- }
2004
-
2005
1968
  class Stroke {
2006
1969
  color;
2007
1970
  opacity;
@@ -2169,43 +2132,6 @@
2169
2132
  }
2170
2133
  }
2171
2134
 
2172
- class SizeAnimation extends RangedAnimationOptions {
2173
- destroy;
2174
- constructor() {
2175
- super();
2176
- this.destroy = exports.DestroyType.none;
2177
- this.speed = 5;
2178
- }
2179
- load(data) {
2180
- super.load(data);
2181
- if (isNull(data)) {
2182
- return;
2183
- }
2184
- if (data.destroy !== undefined) {
2185
- this.destroy = data.destroy;
2186
- }
2187
- }
2188
- }
2189
-
2190
- class Size extends RangedAnimationValueWithRandom {
2191
- animation;
2192
- constructor() {
2193
- super();
2194
- this.animation = new SizeAnimation();
2195
- this.value = 3;
2196
- }
2197
- load(data) {
2198
- super.load(data);
2199
- if (isNull(data)) {
2200
- return;
2201
- }
2202
- const animation = data.animation;
2203
- if (animation !== undefined) {
2204
- this.animation.load(animation);
2205
- }
2206
- }
2207
- }
2208
-
2209
2135
  class ZIndex extends ValueWithRandom {
2210
2136
  opacityRate;
2211
2137
  sizeRate;
@@ -2239,24 +2165,21 @@
2239
2165
  groups;
2240
2166
  move;
2241
2167
  number;
2242
- opacity;
2243
2168
  paint;
2244
2169
  palette;
2245
2170
  reduceDuplicates;
2246
2171
  shape;
2247
- size;
2248
2172
  zIndex;
2249
- _container;
2250
- _pluginManager;
2173
+ #container;
2174
+ #pluginManager;
2251
2175
  constructor(pluginManager, container) {
2252
- this._pluginManager = pluginManager;
2253
- this._container = container;
2176
+ this.#pluginManager = pluginManager;
2177
+ this.#container = container;
2254
2178
  this.bounce = new ParticlesBounce();
2255
2179
  this.effect = new Effect();
2256
2180
  this.groups = {};
2257
2181
  this.move = new Move();
2258
2182
  this.number = new ParticlesNumber();
2259
- this.opacity = new Opacity();
2260
2183
  this.paint = new Paint();
2261
2184
  this.paint.color = new AnimatableColor();
2262
2185
  this.paint.color.value = "#fff";
@@ -2264,7 +2187,6 @@
2264
2187
  this.paint.fill.enable = true;
2265
2188
  this.reduceDuplicates = false;
2266
2189
  this.shape = new Shape();
2267
- this.size = new Size();
2268
2190
  this.zIndex = new ZIndex();
2269
2191
  }
2270
2192
  load(data) {
@@ -2273,7 +2195,7 @@
2273
2195
  }
2274
2196
  if (data.palette) {
2275
2197
  this.palette = data.palette;
2276
- this._importPalette(this.palette);
2198
+ this.#importPalette(this.palette);
2277
2199
  }
2278
2200
  if (data.groups !== undefined) {
2279
2201
  for (const group of Object.keys(data.groups)) {
@@ -2293,7 +2215,6 @@
2293
2215
  this.effect.load(data.effect);
2294
2216
  this.move.load(data.move);
2295
2217
  this.number.load(data.number);
2296
- this.opacity.load(data.opacity);
2297
2218
  const paintToLoad = data.paint;
2298
2219
  if (paintToLoad) {
2299
2220
  if (isArray(paintToLoad)) {
@@ -2312,15 +2233,14 @@
2312
2233
  }
2313
2234
  }
2314
2235
  this.shape.load(data.shape);
2315
- this.size.load(data.size);
2316
2236
  this.zIndex.load(data.zIndex);
2317
- if (this._container) {
2318
- for (const plugin of this._pluginManager.plugins) {
2237
+ if (this.#container) {
2238
+ for (const plugin of this.#pluginManager.plugins) {
2319
2239
  if (plugin.loadParticlesOptions) {
2320
- plugin.loadParticlesOptions(this._container, this, data);
2240
+ plugin.loadParticlesOptions(this.#container, this, data);
2321
2241
  }
2322
2242
  }
2323
- const updaters = this._pluginManager.updaters.get(this._container);
2243
+ const updaters = this.#pluginManager.updaters.get(this.#container);
2324
2244
  if (updaters) {
2325
2245
  for (const updater of updaters) {
2326
2246
  if (updater.loadOptions) {
@@ -2330,8 +2250,8 @@
2330
2250
  }
2331
2251
  }
2332
2252
  }
2333
- _importPalette = (palette) => {
2334
- const paletteData = this._pluginManager.getPalette(palette);
2253
+ #importPalette = (palette) => {
2254
+ const paletteData = this.#pluginManager.getPalette(palette);
2335
2255
  if (!paletteData) {
2336
2256
  return;
2337
2257
  }
@@ -2410,11 +2330,11 @@
2410
2330
  smooth;
2411
2331
  style;
2412
2332
  zLayers;
2413
- _container;
2414
- _pluginManager;
2333
+ #container;
2334
+ #pluginManager;
2415
2335
  constructor(pluginManager, container) {
2416
- this._pluginManager = pluginManager;
2417
- this._container = container;
2336
+ this.#pluginManager = pluginManager;
2337
+ this.#container = container;
2418
2338
  this.autoPlay = true;
2419
2339
  this.background = new Background();
2420
2340
  this.clear = true;
@@ -2425,7 +2345,7 @@
2425
2345
  this.duration = 0;
2426
2346
  this.fpsLimit = 120;
2427
2347
  this.hdr = true;
2428
- this.particles = loadParticlesOptions(this._pluginManager, this._container);
2348
+ this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
2429
2349
  this.pauseOnBlur = true;
2430
2350
  this.pauseOnOutsideViewport = true;
2431
2351
  this.resize = new ResizeEvent();
@@ -2440,12 +2360,12 @@
2440
2360
  if (data.preset !== undefined) {
2441
2361
  this.preset = data.preset;
2442
2362
  executeOnSingleOrMultiple(this.preset, preset => {
2443
- this._importPreset(preset);
2363
+ this.#importPreset(preset);
2444
2364
  });
2445
2365
  }
2446
2366
  if (data.palette !== undefined) {
2447
2367
  this.palette = data.palette;
2448
- this._importPalette(this.palette);
2368
+ this.#importPalette(this.palette);
2449
2369
  }
2450
2370
  if (data.autoPlay !== undefined) {
2451
2371
  this.autoPlay = data.autoPlay;
@@ -2499,12 +2419,12 @@
2499
2419
  if (data.smooth !== undefined) {
2500
2420
  this.smooth = data.smooth;
2501
2421
  }
2502
- this._pluginManager.plugins.forEach(plugin => {
2503
- plugin.loadOptions(this._container, this, data);
2422
+ this.#pluginManager.plugins.forEach(plugin => {
2423
+ plugin.loadOptions(this.#container, this, data);
2504
2424
  });
2505
2425
  }
2506
- _importPalette = palette => {
2507
- const paletteData = this._pluginManager.getPalette(palette);
2426
+ #importPalette = palette => {
2427
+ const paletteData = this.#pluginManager.getPalette(palette);
2508
2428
  if (!paletteData) {
2509
2429
  return;
2510
2430
  }
@@ -2521,8 +2441,8 @@
2521
2441
  },
2522
2442
  });
2523
2443
  };
2524
- _importPreset = preset => {
2525
- this.load(this._pluginManager.getPreset(preset));
2444
+ #importPreset = preset => {
2445
+ this.load(this.#pluginManager.getPreset(preset));
2526
2446
  };
2527
2447
  }
2528
2448
 
@@ -3055,7 +2975,7 @@
3055
2975
  }
3056
2976
 
3057
2977
  async function loadBlendPlugin(engine) {
3058
- engine.checkVersion("4.0.5");
2978
+ engine.checkVersion("4.1.0");
3059
2979
  await engine.pluginManager.register(e => {
3060
2980
  e.pluginManager.addPlugin(new BlendPlugin());
3061
2981
  });
@@ -3092,7 +3012,7 @@
3092
3012
  }
3093
3013
 
3094
3014
  async function loadCircleShape(engine) {
3095
- engine.checkVersion("4.0.5");
3015
+ engine.checkVersion("4.1.0");
3096
3016
  await engine.pluginManager.register(e => {
3097
3017
  e.pluginManager.addShape(["circle"], () => {
3098
3018
  return Promise.resolve(new CircleDrawer());
@@ -3113,15 +3033,15 @@
3113
3033
  return input.startsWith("#");
3114
3034
  }
3115
3035
  handleColor(color) {
3116
- return this._parseString(color.value);
3036
+ return this.#parseString(color.value);
3117
3037
  }
3118
3038
  handleRangeColor(color) {
3119
- return this._parseString(color.value);
3039
+ return this.#parseString(color.value);
3120
3040
  }
3121
3041
  parseString(input) {
3122
- return this._parseString(input);
3042
+ return this.#parseString(input);
3123
3043
  }
3124
- _parseString(hexColor) {
3044
+ #parseString(hexColor) {
3125
3045
  if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
3126
3046
  return;
3127
3047
  }
@@ -3140,7 +3060,7 @@
3140
3060
  }
3141
3061
 
3142
3062
  async function loadHexColorPlugin(engine) {
3143
- engine.checkVersion("4.0.5");
3063
+ engine.checkVersion("4.1.0");
3144
3064
  await engine.pluginManager.register(e => {
3145
3065
  e.pluginManager.addColorManager("hex", new HexColorManager());
3146
3066
  });
@@ -3193,7 +3113,7 @@
3193
3113
  }
3194
3114
 
3195
3115
  async function loadHslColorPlugin(engine) {
3196
- engine.checkVersion("4.0.5");
3116
+ engine.checkVersion("4.1.0");
3197
3117
  await engine.pluginManager.register(e => {
3198
3118
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3199
3119
  });
@@ -3201,13 +3121,13 @@
3201
3121
 
3202
3122
  class MovePlugin {
3203
3123
  id = "move";
3204
- _pluginManager;
3124
+ #pluginManager;
3205
3125
  constructor(pluginManager) {
3206
- this._pluginManager = pluginManager;
3126
+ this.#pluginManager = pluginManager;
3207
3127
  }
3208
3128
  async getPlugin(container) {
3209
3129
  const { MovePluginInstance } = await Promise.resolve().then(function () { return MovePluginInstance$1; });
3210
- return new MovePluginInstance(this._pluginManager, container);
3130
+ return new MovePluginInstance(this.#pluginManager, container);
3211
3131
  }
3212
3132
  loadOptions() {
3213
3133
  }
@@ -3217,7 +3137,7 @@
3217
3137
  }
3218
3138
 
3219
3139
  async function loadMovePlugin(engine) {
3220
- engine.checkVersion("4.0.5");
3140
+ engine.checkVersion("4.1.0");
3221
3141
  await engine.pluginManager.register(e => {
3222
3142
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3223
3143
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3235,18 +3155,58 @@
3235
3155
  });
3236
3156
  }
3237
3157
 
3158
+ class OpacityAnimation extends RangedAnimationOptions {
3159
+ destroy;
3160
+ constructor() {
3161
+ super();
3162
+ this.destroy = exports.DestroyType.none;
3163
+ this.speed = 2;
3164
+ }
3165
+ load(data) {
3166
+ super.load(data);
3167
+ if (isNull(data)) {
3168
+ return;
3169
+ }
3170
+ if (data.destroy !== undefined) {
3171
+ this.destroy = data.destroy;
3172
+ }
3173
+ }
3174
+ }
3175
+
3176
+ class Opacity extends RangedAnimationValueWithRandom {
3177
+ animation;
3178
+ constructor() {
3179
+ super();
3180
+ this.animation = new OpacityAnimation();
3181
+ this.value = 1;
3182
+ }
3183
+ load(data) {
3184
+ if (isNull(data)) {
3185
+ return;
3186
+ }
3187
+ super.load(data);
3188
+ const animation = data.animation;
3189
+ if (animation !== undefined) {
3190
+ this.animation.load(animation);
3191
+ }
3192
+ }
3193
+ }
3194
+
3238
3195
  class OpacityUpdater {
3239
- container;
3196
+ #container;
3240
3197
  constructor(container) {
3241
- this.container = container;
3198
+ this.#container = container;
3242
3199
  }
3243
3200
  init(particle) {
3244
3201
  const opacityOptions = particle.options.opacity, pxRatio = 1;
3202
+ if (!opacityOptions) {
3203
+ return;
3204
+ }
3245
3205
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
3246
3206
  const opacityAnimation = opacityOptions.animation;
3247
3207
  if (opacityAnimation.enable) {
3248
3208
  particle.opacity.velocity =
3249
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
3209
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
3250
3210
  if (!opacityAnimation.sync) {
3251
3211
  particle.opacity.velocity *= getRandom();
3252
3212
  }
@@ -3262,6 +3222,12 @@
3262
3222
  ((particle.opacity.maxLoops ?? none) > none &&
3263
3223
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
3264
3224
  }
3225
+ loadOptions(options, ...sources) {
3226
+ options.opacity ??= new Opacity();
3227
+ for (const source of sources) {
3228
+ options.opacity.load(source?.opacity);
3229
+ }
3230
+ }
3265
3231
  reset(particle) {
3266
3232
  if (!particle.opacity) {
3267
3233
  return;
@@ -3270,7 +3236,7 @@
3270
3236
  particle.opacity.loops = 0;
3271
3237
  }
3272
3238
  update(particle, delta) {
3273
- if (!this.isEnabled(particle) || !particle.opacity) {
3239
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
3274
3240
  return;
3275
3241
  }
3276
3242
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -3278,7 +3244,7 @@
3278
3244
  }
3279
3245
 
3280
3246
  async function loadOpacityUpdater(engine) {
3281
- engine.checkVersion("4.0.5");
3247
+ engine.checkVersion("4.1.0");
3282
3248
  await engine.pluginManager.register(e => {
3283
3249
  e.pluginManager.addParticleUpdater("opacity", container => {
3284
3250
  return Promise.resolve(new OpacityUpdater(container));
@@ -3300,10 +3266,9 @@
3300
3266
  }
3301
3267
  const velocity = data.particle.velocity.x;
3302
3268
  let bounced = false;
3303
- if ((data.direction === exports.OutModeDirection.right &&
3304
- data.bounds.right >= data.canvasSize.width &&
3305
- velocity > minVelocity$4) ||
3306
- (data.direction === exports.OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity$4)) {
3269
+ if (data.outOfCanvas &&
3270
+ ((data.direction === exports.OutModeDirection.right && velocity > minVelocity$4) ||
3271
+ (data.direction === exports.OutModeDirection.left && velocity < minVelocity$4))) {
3307
3272
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
3308
3273
  data.particle.velocity.x *= -newVelocity;
3309
3274
  bounced = true;
@@ -3312,10 +3277,10 @@
3312
3277
  return;
3313
3278
  }
3314
3279
  const minPos = data.offset.x + data.size;
3315
- if (data.bounds.right >= data.canvasSize.width && data.direction === exports.OutModeDirection.right) {
3280
+ if (data.outOfCanvas && data.direction === exports.OutModeDirection.right) {
3316
3281
  data.particle.position.x = data.canvasSize.width - minPos;
3317
3282
  }
3318
- else if (data.bounds.left <= boundsMin && data.direction === exports.OutModeDirection.left) {
3283
+ else if (data.outOfCanvas && data.direction === exports.OutModeDirection.left) {
3319
3284
  data.particle.position.x = minPos;
3320
3285
  }
3321
3286
  if (data.outMode === exports.OutMode.split) {
@@ -3335,10 +3300,9 @@
3335
3300
  }
3336
3301
  const velocity = data.particle.velocity.y;
3337
3302
  let bounced = false;
3338
- if ((data.direction === exports.OutModeDirection.bottom &&
3339
- data.bounds.bottom >= data.canvasSize.height &&
3340
- velocity > minVelocity$4) ||
3341
- (data.direction === exports.OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity$4)) {
3303
+ if (data.outOfCanvas &&
3304
+ ((data.direction === exports.OutModeDirection.bottom && velocity > minVelocity$4) ||
3305
+ (data.direction === exports.OutModeDirection.top && velocity < minVelocity$4))) {
3342
3306
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
3343
3307
  data.particle.velocity.y *= -newVelocity;
3344
3308
  bounced = true;
@@ -3347,10 +3311,10 @@
3347
3311
  return;
3348
3312
  }
3349
3313
  const minPos = data.offset.y + data.size;
3350
- if (data.bounds.bottom >= data.canvasSize.height && data.direction === exports.OutModeDirection.bottom) {
3314
+ if (data.outOfCanvas && data.direction === exports.OutModeDirection.bottom) {
3351
3315
  data.particle.position.y = data.canvasSize.height - minPos;
3352
3316
  }
3353
- else if (data.bounds.top <= boundsMin && data.direction === exports.OutModeDirection.top) {
3317
+ else if (data.outOfCanvas && data.direction === exports.OutModeDirection.top) {
3354
3318
  data.particle.position.y = minPos;
3355
3319
  }
3356
3320
  if (data.outMode === exports.OutMode.split) {
@@ -3359,24 +3323,24 @@
3359
3323
  }
3360
3324
 
3361
3325
  class BounceOutMode {
3362
- container;
3363
3326
  modes;
3364
- _particleBouncePlugins;
3327
+ #container;
3328
+ #particleBouncePlugins;
3365
3329
  constructor(container) {
3366
- this.container = container;
3330
+ this.#container = container;
3367
3331
  this.modes = [
3368
3332
  exports.OutMode.bounce,
3369
3333
  exports.OutMode.split,
3370
3334
  ];
3371
- this._particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3335
+ this.#particleBouncePlugins = container.plugins.filter(p => p.particleBounce !== undefined);
3372
3336
  }
3373
3337
  update(particle, direction, delta, outMode) {
3374
3338
  if (!this.modes.includes(outMode)) {
3375
3339
  return;
3376
3340
  }
3377
- const container = this.container;
3341
+ const container = this.#container;
3378
3342
  let handled = false;
3379
- for (const plugin of this._particleBouncePlugins) {
3343
+ for (const plugin of this.#particleBouncePlugins) {
3380
3344
  handled = plugin.particleBounce?.(particle, delta, direction) ?? false;
3381
3345
  if (handled) {
3382
3346
  break;
@@ -3385,29 +3349,26 @@
3385
3349
  if (handled) {
3386
3350
  return;
3387
3351
  }
3388
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size;
3389
- bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
3390
- bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
3352
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, outOfCanvas = !particle.isInsideCanvasForOutMode(outMode, direction);
3353
+ bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3354
+ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, outOfCanvas, size });
3391
3355
  }
3392
3356
  }
3393
3357
 
3394
3358
  const minVelocity$3 = 0;
3395
3359
  class DestroyOutMode {
3396
- container;
3397
3360
  modes;
3398
- constructor(container) {
3399
- this.container = container;
3361
+ constructor(_container) {
3400
3362
  this.modes = [exports.OutMode.destroy];
3401
3363
  }
3402
3364
  update(particle, direction, _delta, outMode) {
3403
3365
  if (!this.modes.includes(outMode)) {
3404
3366
  return;
3405
3367
  }
3406
- const container = this.container;
3407
3368
  switch (particle.outType) {
3408
3369
  case exports.ParticleOutType.normal:
3409
3370
  case exports.ParticleOutType.outside:
3410
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3371
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3411
3372
  return;
3412
3373
  }
3413
3374
  break;
@@ -3428,10 +3389,10 @@
3428
3389
 
3429
3390
  const minVelocity$2 = 0;
3430
3391
  class NoneOutMode {
3431
- container;
3432
3392
  modes;
3393
+ #container;
3433
3394
  constructor(container) {
3434
- this.container = container;
3395
+ this.#container = container;
3435
3396
  this.modes = [exports.OutMode.none];
3436
3397
  }
3437
3398
  update(particle, direction, _delta, outMode) {
@@ -3444,7 +3405,7 @@
3444
3405
  (direction === exports.OutModeDirection.top || direction === exports.OutModeDirection.bottom))) {
3445
3406
  return;
3446
3407
  }
3447
- const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3408
+ const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
3448
3409
  if (!gravityOptions.enable) {
3449
3410
  if ((particle.velocity.y > minVelocity$2 && particle.position.y <= canvasSize.height + pRadius) ||
3450
3411
  (particle.velocity.y < minVelocity$2 && particle.position.y >= -pRadius) ||
@@ -3470,17 +3431,17 @@
3470
3431
 
3471
3432
  const minVelocity$1 = 0, minDistance = 0, updateVector = Vector.origin;
3472
3433
  class OutOutMode {
3473
- container;
3474
3434
  modes;
3435
+ #container;
3475
3436
  constructor(container) {
3476
- this.container = container;
3437
+ this.#container = container;
3477
3438
  this.modes = [exports.OutMode.out];
3478
3439
  }
3479
3440
  update(particle, direction, _delta, outMode) {
3480
3441
  if (!this.modes.includes(outMode)) {
3481
3442
  return;
3482
3443
  }
3483
- const container = this.container;
3444
+ const container = this.#container;
3484
3445
  switch (particle.outType) {
3485
3446
  case exports.ParticleOutType.inside: {
3486
3447
  const { x: vx, y: vy } = particle.velocity;
@@ -3510,7 +3471,7 @@
3510
3471
  break;
3511
3472
  }
3512
3473
  default: {
3513
- if (isPointInside(particle.position, container.canvas.size, originPoint, particle.getRadius(), direction)) {
3474
+ if (particle.isInsideCanvasForOutMode(outMode, direction)) {
3514
3475
  return;
3515
3476
  }
3516
3477
  switch (particle.outType) {
@@ -3594,16 +3555,16 @@
3594
3555
  };
3595
3556
  class OutOfCanvasUpdater {
3596
3557
  updaters;
3597
- container;
3558
+ #container;
3598
3559
  constructor(container) {
3599
- this.container = container;
3560
+ this.#container = container;
3600
3561
  this.updaters = new Map();
3601
3562
  }
3602
3563
  init(particle) {
3603
- this._addUpdaterIfMissing(particle, exports.OutMode.bounce, container => new BounceOutMode(container));
3604
- this._addUpdaterIfMissing(particle, exports.OutMode.out, container => new OutOutMode(container));
3605
- this._addUpdaterIfMissing(particle, exports.OutMode.destroy, container => new DestroyOutMode(container));
3606
- this._addUpdaterIfMissing(particle, exports.OutMode.none, container => new NoneOutMode(container));
3564
+ this.#addUpdaterIfMissing(particle, exports.OutMode.bounce, container => new BounceOutMode(container));
3565
+ this.#addUpdaterIfMissing(particle, exports.OutMode.out, container => new OutOutMode(container));
3566
+ this.#addUpdaterIfMissing(particle, exports.OutMode.destroy, container => new DestroyOutMode(container));
3567
+ this.#addUpdaterIfMissing(particle, exports.OutMode.none, container => new NoneOutMode(container));
3607
3568
  }
3608
3569
  isEnabled(particle) {
3609
3570
  return !particle.destroyed && !particle.spawning;
@@ -3611,18 +3572,18 @@
3611
3572
  update(particle, delta) {
3612
3573
  const outModes = particle.options.move.outModes;
3613
3574
  particle.justWarped = false;
3614
- this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, exports.OutModeDirection.bottom);
3615
- this._updateOutMode(particle, delta, outModes.left ?? outModes.default, exports.OutModeDirection.left);
3616
- this._updateOutMode(particle, delta, outModes.right ?? outModes.default, exports.OutModeDirection.right);
3617
- this._updateOutMode(particle, delta, outModes.top ?? outModes.default, exports.OutModeDirection.top);
3575
+ this.#updateOutMode(particle, delta, outModes.bottom ?? outModes.default, exports.OutModeDirection.bottom);
3576
+ this.#updateOutMode(particle, delta, outModes.left ?? outModes.default, exports.OutModeDirection.left);
3577
+ this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, exports.OutModeDirection.right);
3578
+ this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, exports.OutModeDirection.top);
3618
3579
  }
3619
- _addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3580
+ #addUpdaterIfMissing = (particle, outMode, getUpdater) => {
3620
3581
  const outModes = particle.options.move.outModes;
3621
3582
  if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
3622
- this.updaters.set(outMode, getUpdater(this.container));
3583
+ this.updaters.set(outMode, getUpdater(this.#container));
3623
3584
  }
3624
3585
  };
3625
- _updateOutMode = (particle, delta, outMode, direction) => {
3586
+ #updateOutMode = (particle, delta, outMode, direction) => {
3626
3587
  for (const updater of this.updaters.values()) {
3627
3588
  updater.update(particle, direction, delta, outMode);
3628
3589
  }
@@ -3630,7 +3591,7 @@
3630
3591
  }
3631
3592
 
3632
3593
  async function loadOutModesUpdater(engine) {
3633
- engine.checkVersion("4.0.5");
3594
+ engine.checkVersion("4.1.0");
3634
3595
  await engine.pluginManager.register(e => {
3635
3596
  e.pluginManager.addParticleUpdater("outModes", container => {
3636
3597
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3640,20 +3601,20 @@
3640
3601
 
3641
3602
  const defaultOpacity = 1;
3642
3603
  class PaintUpdater {
3643
- _container;
3644
- _pluginManager;
3604
+ #container;
3605
+ #pluginManager;
3645
3606
  constructor(pluginManager, container) {
3646
- this._container = container;
3647
- this._pluginManager = pluginManager;
3607
+ this.#container = container;
3608
+ this.#pluginManager = pluginManager;
3648
3609
  }
3649
3610
  init(particle) {
3650
- 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;
3611
+ 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;
3651
3612
  if (fill) {
3652
3613
  const fillColor = AnimatableColor.create(paintColor === undefined ? undefined : AnimatableColor.create(undefined, paintColor), fill.color);
3653
3614
  particle.fillEnabled = fill.enable;
3654
3615
  particle.fillOpacity = getRangeValue(fill.opacity);
3655
3616
  particle.fillAnimation = fillColor.animation;
3656
- const fillHslColor = rangeColorToHsl(this._pluginManager, fillColor);
3617
+ const fillHslColor = rangeColorToHsl(this.#pluginManager, fillColor);
3657
3618
  if (fillHslColor) {
3658
3619
  particle.fillColor = getHslAnimationFromHsl(fillHslColor, particle.fillAnimation, container.retina.reduceFactor);
3659
3620
  }
@@ -3669,7 +3630,7 @@
3669
3630
  particle.strokeWidth = getRangeValue(stroke.width) * container.retina.pixelRatio;
3670
3631
  particle.strokeOpacity = getRangeValue(stroke.opacity ?? defaultOpacity);
3671
3632
  particle.strokeAnimation = strokeColor.animation;
3672
- const strokeHslColor = rangeColorToHsl(this._pluginManager, strokeColor) ?? particle.getFillColor();
3633
+ const strokeHslColor = rangeColorToHsl(this.#pluginManager, strokeColor) ?? particle.getFillColor();
3673
3634
  if (strokeHslColor) {
3674
3635
  particle.strokeColor = getHslAnimationFromHsl(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
3675
3636
  }
@@ -3701,7 +3662,7 @@
3701
3662
  }
3702
3663
 
3703
3664
  async function loadPaintUpdater(engine) {
3704
- engine.checkVersion("4.0.5");
3665
+ engine.checkVersion("4.1.0");
3705
3666
  await engine.pluginManager.register(e => {
3706
3667
  e.pluginManager.addParticleUpdater("paint", container => {
3707
3668
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3756,27 +3717,69 @@
3756
3717
  }
3757
3718
 
3758
3719
  async function loadRgbColorPlugin(engine) {
3759
- engine.checkVersion("4.0.5");
3720
+ engine.checkVersion("4.1.0");
3760
3721
  await engine.pluginManager.register(e => {
3761
3722
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3762
3723
  });
3763
3724
  }
3764
3725
 
3726
+ class SizeAnimation extends RangedAnimationOptions {
3727
+ destroy;
3728
+ constructor() {
3729
+ super();
3730
+ this.destroy = exports.DestroyType.none;
3731
+ this.speed = 5;
3732
+ }
3733
+ load(data) {
3734
+ super.load(data);
3735
+ if (isNull(data)) {
3736
+ return;
3737
+ }
3738
+ if (data.destroy !== undefined) {
3739
+ this.destroy = data.destroy;
3740
+ }
3741
+ }
3742
+ }
3743
+
3744
+ class Size extends RangedAnimationValueWithRandom {
3745
+ animation;
3746
+ constructor() {
3747
+ super();
3748
+ this.animation = new SizeAnimation();
3749
+ this.value = 3;
3750
+ }
3751
+ load(data) {
3752
+ super.load(data);
3753
+ if (isNull(data)) {
3754
+ return;
3755
+ }
3756
+ const animation = data.animation;
3757
+ if (animation !== undefined) {
3758
+ this.animation.load(animation);
3759
+ }
3760
+ }
3761
+ }
3762
+
3765
3763
  const minLoops = 0;
3766
3764
  class SizeUpdater {
3767
- _container;
3765
+ #container;
3768
3766
  constructor(container) {
3769
- this._container = container;
3767
+ this.#container = container;
3770
3768
  }
3771
3769
  init(particle) {
3772
- const container = this._container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
3773
- if (sizeAnimation.enable) {
3774
- particle.size.velocity =
3775
- (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3776
- if (!sizeAnimation.sync) {
3777
- particle.size.velocity *= getRandom();
3778
- }
3770
+ const container = this.#container, sizeOptions = particle.options.size;
3771
+ if (!sizeOptions) {
3772
+ return;
3779
3773
  }
3774
+ const sizeAnimation = sizeOptions.animation;
3775
+ if (!sizeAnimation.enable) {
3776
+ return;
3777
+ }
3778
+ particle.size.velocity = (particle.retina.sizeAnimationSpeed / percentDenominator) * container.retina.reduceFactor;
3779
+ if (sizeAnimation.sync) {
3780
+ return;
3781
+ }
3782
+ particle.size.velocity *= getRandom();
3780
3783
  }
3781
3784
  isEnabled(particle) {
3782
3785
  return (!particle.destroyed &&
@@ -3786,12 +3789,26 @@
3786
3789
  ((particle.size.maxLoops ?? minLoops) > minLoops &&
3787
3790
  (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
3788
3791
  }
3792
+ loadOptions(options, ...sources) {
3793
+ options.size ??= new Size();
3794
+ for (const source of sources) {
3795
+ options.size.load(source?.size);
3796
+ }
3797
+ }
3798
+ preInit(particle) {
3799
+ const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
3800
+ if (!sizeOptions) {
3801
+ return;
3802
+ }
3803
+ particle.size = initParticleNumericAnimationValue(sizeOptions, pxRatio);
3804
+ particle.retina.sizeAnimationSpeed = getRangeValue(sizeOptions.animation.speed) * pxRatio;
3805
+ }
3789
3806
  reset(particle) {
3790
3807
  particle.size.time = 0;
3791
3808
  particle.size.loops = 0;
3792
3809
  }
3793
3810
  update(particle, delta) {
3794
- if (!this.isEnabled(particle)) {
3811
+ if (!this.isEnabled(particle) || !particle.options.size) {
3795
3812
  return;
3796
3813
  }
3797
3814
  updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
@@ -3799,7 +3816,7 @@
3799
3816
  }
3800
3817
 
3801
3818
  async function loadSizeUpdater(engine) {
3802
- engine.checkVersion("4.0.5");
3819
+ engine.checkVersion("4.1.0");
3803
3820
  await engine.pluginManager.register(e => {
3804
3821
  e.pluginManager.addParticleUpdater("size", container => {
3805
3822
  return Promise.resolve(new SizeUpdater(container));
@@ -3808,7 +3825,7 @@
3808
3825
  }
3809
3826
 
3810
3827
  async function loadBasic(engine) {
3811
- engine.checkVersion("4.0.5");
3828
+ engine.checkVersion("4.1.0");
3812
3829
  await engine.pluginManager.register(async (e) => {
3813
3830
  await Promise.all([
3814
3831
  loadBlendPlugin(e),
@@ -3837,58 +3854,58 @@
3837
3854
  }
3838
3855
  }
3839
3856
  class RenderManager {
3840
- _canvasClearPlugins;
3841
- _canvasManager;
3842
- _canvasPaintPlugins;
3843
- _clearDrawPlugins;
3844
- _colorPlugins;
3845
- _container;
3846
- _context;
3847
- _contextSettings;
3848
- _drawParticlePlugins;
3849
- _drawParticlesCleanupPlugins;
3850
- _drawParticlesSetupPlugins;
3851
- _drawPlugins;
3852
- _drawSettingsCleanupPlugins;
3853
- _drawSettingsSetupPlugins;
3854
- _pluginManager;
3855
- _postDrawUpdaters;
3856
- _preDrawUpdaters;
3857
- _reusableColorStyles = {};
3858
- _reusablePluginColors = [undefined, undefined];
3859
- _reusableTransform = {};
3857
+ #canvasClearPlugins;
3858
+ #canvasManager;
3859
+ #canvasPaintPlugins;
3860
+ #clearDrawPlugins;
3861
+ #colorPlugins;
3862
+ #container;
3863
+ #context;
3864
+ #contextSettings;
3865
+ #drawParticlePlugins;
3866
+ #drawParticlesCleanupPlugins;
3867
+ #drawParticlesSetupPlugins;
3868
+ #drawPlugins;
3869
+ #drawSettingsCleanupPlugins;
3870
+ #drawSettingsSetupPlugins;
3871
+ #pluginManager;
3872
+ #postDrawUpdaters;
3873
+ #preDrawUpdaters;
3874
+ #reusableColorStyles = {};
3875
+ #reusablePluginColors = [undefined, undefined];
3876
+ #reusableTransform = {};
3860
3877
  constructor(pluginManager, container, canvasManager) {
3861
- this._pluginManager = pluginManager;
3862
- this._container = container;
3863
- this._canvasManager = canvasManager;
3864
- this._context = null;
3865
- this._preDrawUpdaters = [];
3866
- this._postDrawUpdaters = [];
3867
- this._colorPlugins = [];
3868
- this._canvasClearPlugins = [];
3869
- this._canvasPaintPlugins = [];
3870
- this._clearDrawPlugins = [];
3871
- this._drawParticlePlugins = [];
3872
- this._drawParticlesCleanupPlugins = [];
3873
- this._drawParticlesSetupPlugins = [];
3874
- this._drawPlugins = [];
3875
- this._drawSettingsSetupPlugins = [];
3876
- this._drawSettingsCleanupPlugins = [];
3878
+ this.#pluginManager = pluginManager;
3879
+ this.#container = container;
3880
+ this.#canvasManager = canvasManager;
3881
+ this.#context = null;
3882
+ this.#preDrawUpdaters = [];
3883
+ this.#postDrawUpdaters = [];
3884
+ this.#colorPlugins = [];
3885
+ this.#canvasClearPlugins = [];
3886
+ this.#canvasPaintPlugins = [];
3887
+ this.#clearDrawPlugins = [];
3888
+ this.#drawParticlePlugins = [];
3889
+ this.#drawParticlesCleanupPlugins = [];
3890
+ this.#drawParticlesSetupPlugins = [];
3891
+ this.#drawPlugins = [];
3892
+ this.#drawSettingsSetupPlugins = [];
3893
+ this.#drawSettingsCleanupPlugins = [];
3877
3894
  }
3878
3895
  get settings() {
3879
- return this._contextSettings;
3896
+ return this.#contextSettings;
3880
3897
  }
3881
3898
  canvasClear() {
3882
- if (!this._container.actualOptions.clear) {
3899
+ if (!this.#container.actualOptions.clear) {
3883
3900
  return;
3884
3901
  }
3885
3902
  this.draw(ctx => {
3886
- clear(ctx, this._canvasManager.size);
3903
+ clear(ctx, this.#canvasManager.size);
3887
3904
  });
3888
3905
  }
3889
3906
  clear() {
3890
3907
  let pluginHandled = false;
3891
- for (const plugin of this._canvasClearPlugins) {
3908
+ for (const plugin of this.#canvasClearPlugins) {
3892
3909
  pluginHandled = plugin.canvasClear?.() ?? false;
3893
3910
  if (pluginHandled) {
3894
3911
  break;
@@ -3901,21 +3918,21 @@
3901
3918
  }
3902
3919
  destroy() {
3903
3920
  this.stop();
3904
- this._preDrawUpdaters = [];
3905
- this._postDrawUpdaters = [];
3906
- this._colorPlugins = [];
3907
- this._canvasClearPlugins = [];
3908
- this._canvasPaintPlugins = [];
3909
- this._clearDrawPlugins = [];
3910
- this._drawParticlePlugins = [];
3911
- this._drawParticlesCleanupPlugins = [];
3912
- this._drawParticlesSetupPlugins = [];
3913
- this._drawPlugins = [];
3914
- this._drawSettingsSetupPlugins = [];
3915
- this._drawSettingsCleanupPlugins = [];
3921
+ this.#preDrawUpdaters = [];
3922
+ this.#postDrawUpdaters = [];
3923
+ this.#colorPlugins = [];
3924
+ this.#canvasClearPlugins = [];
3925
+ this.#canvasPaintPlugins = [];
3926
+ this.#clearDrawPlugins = [];
3927
+ this.#drawParticlePlugins = [];
3928
+ this.#drawParticlesCleanupPlugins = [];
3929
+ this.#drawParticlesSetupPlugins = [];
3930
+ this.#drawPlugins = [];
3931
+ this.#drawSettingsSetupPlugins = [];
3932
+ this.#drawSettingsCleanupPlugins = [];
3916
3933
  }
3917
3934
  draw(cb) {
3918
- const ctx = this._context;
3935
+ const ctx = this.#context;
3919
3936
  if (!ctx) {
3920
3937
  return;
3921
3938
  }
@@ -3930,21 +3947,21 @@
3930
3947
  return;
3931
3948
  }
3932
3949
  const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
3933
- let [fColor, sColor] = this._getPluginParticleColors(particle);
3950
+ let [fColor, sColor] = this.#getPluginParticleColors(particle);
3934
3951
  fColor ??= pfColor;
3935
3952
  sColor ??= psColor;
3936
3953
  if (!fColor && !sColor) {
3937
3954
  return;
3938
3955
  }
3939
- 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;
3956
+ 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;
3940
3957
  transform.a = transform.b = transform.c = transform.d = undefined;
3941
3958
  colorStyles.fill = fill;
3942
3959
  colorStyles.stroke = stroke;
3943
3960
  this.draw((context) => {
3944
- for (const plugin of this._drawParticlesSetupPlugins) {
3961
+ for (const plugin of this.#drawParticlesSetupPlugins) {
3945
3962
  plugin.drawParticleSetup?.(context, particle, delta);
3946
3963
  }
3947
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
3964
+ this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
3948
3965
  drawParticle({
3949
3966
  container,
3950
3967
  context,
@@ -3955,35 +3972,35 @@
3955
3972
  opacity: opacity,
3956
3973
  transform,
3957
3974
  });
3958
- this._applyPostDrawUpdaters(particle);
3959
- for (const plugin of this._drawParticlesCleanupPlugins) {
3975
+ this.#applyPostDrawUpdaters(particle);
3976
+ for (const plugin of this.#drawParticlesCleanupPlugins) {
3960
3977
  plugin.drawParticleCleanup?.(context, particle, delta);
3961
3978
  }
3962
3979
  });
3963
3980
  }
3964
3981
  drawParticlePlugins(particle, delta) {
3965
3982
  this.draw(ctx => {
3966
- for (const plugin of this._drawParticlePlugins) {
3983
+ for (const plugin of this.#drawParticlePlugins) {
3967
3984
  drawParticlePlugin(ctx, plugin, particle, delta);
3968
3985
  }
3969
3986
  });
3970
3987
  }
3971
3988
  drawParticles(delta) {
3972
- const { particles } = this._container;
3989
+ const { particles } = this.#container;
3973
3990
  this.clear();
3974
3991
  particles.update(delta);
3975
3992
  this.draw(ctx => {
3976
- for (const plugin of this._drawSettingsSetupPlugins) {
3993
+ for (const plugin of this.#drawSettingsSetupPlugins) {
3977
3994
  plugin.drawSettingsSetup?.(ctx, delta);
3978
3995
  }
3979
- for (const plugin of this._drawPlugins) {
3996
+ for (const plugin of this.#drawPlugins) {
3980
3997
  plugin.draw?.(ctx, delta);
3981
3998
  }
3982
3999
  particles.drawParticles(delta);
3983
- for (const plugin of this._clearDrawPlugins) {
4000
+ for (const plugin of this.#clearDrawPlugins) {
3984
4001
  plugin.clearDraw?.(ctx, delta);
3985
4002
  }
3986
- for (const plugin of this._drawSettingsCleanupPlugins) {
4003
+ for (const plugin of this.#drawSettingsCleanupPlugins) {
3987
4004
  plugin.drawSettingsCleanup?.(ctx, delta);
3988
4005
  }
3989
4006
  });
@@ -3994,64 +4011,64 @@
3994
4011
  this.paint();
3995
4012
  }
3996
4013
  initPlugins() {
3997
- this._colorPlugins = [];
3998
- this._canvasClearPlugins = [];
3999
- this._canvasPaintPlugins = [];
4000
- this._clearDrawPlugins = [];
4001
- this._drawParticlePlugins = [];
4002
- this._drawParticlesSetupPlugins = [];
4003
- this._drawParticlesCleanupPlugins = [];
4004
- this._drawPlugins = [];
4005
- this._drawSettingsSetupPlugins = [];
4006
- this._drawSettingsCleanupPlugins = [];
4007
- for (const plugin of this._container.plugins) {
4014
+ this.#colorPlugins = [];
4015
+ this.#canvasClearPlugins = [];
4016
+ this.#canvasPaintPlugins = [];
4017
+ this.#clearDrawPlugins = [];
4018
+ this.#drawParticlePlugins = [];
4019
+ this.#drawParticlesSetupPlugins = [];
4020
+ this.#drawParticlesCleanupPlugins = [];
4021
+ this.#drawPlugins = [];
4022
+ this.#drawSettingsSetupPlugins = [];
4023
+ this.#drawSettingsCleanupPlugins = [];
4024
+ for (const plugin of this.#container.plugins) {
4008
4025
  if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
4009
- this._colorPlugins.push(plugin);
4026
+ this.#colorPlugins.push(plugin);
4010
4027
  }
4011
4028
  if (plugin.canvasClear) {
4012
- this._canvasClearPlugins.push(plugin);
4029
+ this.#canvasClearPlugins.push(plugin);
4013
4030
  }
4014
4031
  if (plugin.canvasPaint) {
4015
- this._canvasPaintPlugins.push(plugin);
4032
+ this.#canvasPaintPlugins.push(plugin);
4016
4033
  }
4017
4034
  if (plugin.drawParticle) {
4018
- this._drawParticlePlugins.push(plugin);
4035
+ this.#drawParticlePlugins.push(plugin);
4019
4036
  }
4020
4037
  if (plugin.drawParticleSetup) {
4021
- this._drawParticlesSetupPlugins.push(plugin);
4038
+ this.#drawParticlesSetupPlugins.push(plugin);
4022
4039
  }
4023
4040
  if (plugin.drawParticleCleanup) {
4024
- this._drawParticlesCleanupPlugins.push(plugin);
4041
+ this.#drawParticlesCleanupPlugins.push(plugin);
4025
4042
  }
4026
4043
  if (plugin.draw) {
4027
- this._drawPlugins.push(plugin);
4044
+ this.#drawPlugins.push(plugin);
4028
4045
  }
4029
4046
  if (plugin.drawSettingsSetup) {
4030
- this._drawSettingsSetupPlugins.push(plugin);
4047
+ this.#drawSettingsSetupPlugins.push(plugin);
4031
4048
  }
4032
4049
  if (plugin.drawSettingsCleanup) {
4033
- this._drawSettingsCleanupPlugins.push(plugin);
4050
+ this.#drawSettingsCleanupPlugins.push(plugin);
4034
4051
  }
4035
4052
  if (plugin.clearDraw) {
4036
- this._clearDrawPlugins.push(plugin);
4053
+ this.#clearDrawPlugins.push(plugin);
4037
4054
  }
4038
4055
  }
4039
4056
  }
4040
4057
  initUpdaters() {
4041
- this._preDrawUpdaters = [];
4042
- this._postDrawUpdaters = [];
4043
- for (const updater of this._container.particleUpdaters) {
4058
+ this.#preDrawUpdaters = [];
4059
+ this.#postDrawUpdaters = [];
4060
+ for (const updater of this.#container.particleUpdaters) {
4044
4061
  if (updater.afterDraw) {
4045
- this._postDrawUpdaters.push(updater);
4062
+ this.#postDrawUpdaters.push(updater);
4046
4063
  }
4047
4064
  if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
4048
- this._preDrawUpdaters.push(updater);
4065
+ this.#preDrawUpdaters.push(updater);
4049
4066
  }
4050
4067
  }
4051
4068
  }
4052
4069
  paint() {
4053
4070
  let handled = false;
4054
- for (const plugin of this._canvasPaintPlugins) {
4071
+ for (const plugin of this.#canvasPaintPlugins) {
4055
4072
  handled = plugin.canvasPaint?.() ?? false;
4056
4073
  if (handled) {
4057
4074
  break;
@@ -4064,35 +4081,35 @@
4064
4081
  }
4065
4082
  paintBase(baseColor) {
4066
4083
  this.draw(ctx => {
4067
- paintBase(ctx, this._canvasManager.size, baseColor);
4084
+ paintBase(ctx, this.#canvasManager.size, baseColor);
4068
4085
  });
4069
4086
  }
4070
4087
  paintImage(image, opacity) {
4071
4088
  this.draw(ctx => {
4072
- paintImage(ctx, this._canvasManager.size, image, opacity);
4089
+ paintImage(ctx, this.#canvasManager.size, image, opacity);
4073
4090
  });
4074
4091
  }
4075
4092
  setContext(context) {
4076
- this._context = context;
4077
- if (this._context) {
4078
- this._context.globalCompositeOperation = defaultCompositeValue;
4093
+ this.#context = context;
4094
+ if (this.#context) {
4095
+ this.#context.globalCompositeOperation = defaultCompositeValue;
4079
4096
  }
4080
4097
  }
4081
4098
  setContextSettings(settings) {
4082
- this._contextSettings = settings;
4099
+ this.#contextSettings = settings;
4083
4100
  }
4084
4101
  stop() {
4085
4102
  this.draw(ctx => {
4086
- clear(ctx, this._canvasManager.size);
4103
+ clear(ctx, this.#canvasManager.size);
4087
4104
  });
4088
4105
  }
4089
- _applyPostDrawUpdaters = particle => {
4090
- for (const updater of this._postDrawUpdaters) {
4106
+ #applyPostDrawUpdaters = particle => {
4107
+ for (const updater of this.#postDrawUpdaters) {
4091
4108
  updater.afterDraw?.(particle);
4092
4109
  }
4093
4110
  };
4094
- _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4095
- for (const updater of this._preDrawUpdaters) {
4111
+ #applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
4112
+ for (const updater of this.#preDrawUpdaters) {
4096
4113
  if (updater.getColorStyles) {
4097
4114
  const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
4098
4115
  if (fill) {
@@ -4111,22 +4128,22 @@
4111
4128
  updater.beforeDraw?.(particle);
4112
4129
  }
4113
4130
  };
4114
- _getPluginParticleColors = particle => {
4131
+ #getPluginParticleColors = particle => {
4115
4132
  let fColor, sColor;
4116
- for (const plugin of this._colorPlugins) {
4133
+ for (const plugin of this.#colorPlugins) {
4117
4134
  if (!fColor && plugin.particleFillColor) {
4118
- fColor = rangeColorToHsl(this._pluginManager, plugin.particleFillColor(particle));
4135
+ fColor = rangeColorToHsl(this.#pluginManager, plugin.particleFillColor(particle));
4119
4136
  }
4120
4137
  if (!sColor && plugin.particleStrokeColor) {
4121
- sColor = rangeColorToHsl(this._pluginManager, plugin.particleStrokeColor(particle));
4138
+ sColor = rangeColorToHsl(this.#pluginManager, plugin.particleStrokeColor(particle));
4122
4139
  }
4123
4140
  if (fColor && sColor) {
4124
4141
  break;
4125
4142
  }
4126
4143
  }
4127
- this._reusablePluginColors[fColorIndex] = fColor;
4128
- this._reusablePluginColors[sColorIndex] = sColor;
4129
- return this._reusablePluginColors;
4144
+ this.#reusablePluginColors[fColorIndex] = fColor;
4145
+ this.#reusablePluginColors[sColorIndex] = sColor;
4146
+ return this.#reusablePluginColors;
4130
4147
  };
4131
4148
  }
4132
4149
 
@@ -4184,53 +4201,53 @@
4184
4201
  renderCanvas;
4185
4202
  size;
4186
4203
  zoom = defaultZoom;
4187
- _container;
4188
- _generated;
4189
- _mutationObserver;
4190
- _originalStyle;
4191
- _pluginManager;
4192
- _pointerEvents;
4193
- _resizePlugins;
4194
- _standardSize;
4195
- _zoomCenter;
4204
+ #container;
4205
+ #generated;
4206
+ #mutationObserver;
4207
+ #originalStyle;
4208
+ #pluginManager;
4209
+ #pointerEvents;
4210
+ #resizePlugins;
4211
+ #standardSize;
4212
+ #zoomCenter;
4196
4213
  constructor(pluginManager, container) {
4197
- this._pluginManager = pluginManager;
4198
- this._container = container;
4214
+ this.#pluginManager = pluginManager;
4215
+ this.#container = container;
4199
4216
  this.render = new RenderManager(pluginManager, container, this);
4200
- this._standardSize = {
4217
+ this.#standardSize = {
4201
4218
  height: 0,
4202
4219
  width: 0,
4203
4220
  };
4204
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
4221
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
4205
4222
  this.size = {
4206
4223
  height: stdSize.height * pxRatio,
4207
4224
  width: stdSize.width * pxRatio,
4208
4225
  };
4209
- this._generated = false;
4210
- this._resizePlugins = [];
4211
- this._pointerEvents = "none";
4226
+ this.#generated = false;
4227
+ this.#resizePlugins = [];
4228
+ this.#pointerEvents = "none";
4212
4229
  }
4213
- get _fullScreen() {
4214
- return this._container.actualOptions.fullScreen.enable;
4230
+ get #fullScreen() {
4231
+ return this.#container.actualOptions.fullScreen.enable;
4215
4232
  }
4216
4233
  destroy() {
4217
4234
  this.stop();
4218
- if (this._generated) {
4235
+ if (this.#generated) {
4219
4236
  const element = this.domElement;
4220
4237
  element?.remove();
4221
4238
  this.domElement = undefined;
4222
4239
  this.renderCanvas = undefined;
4223
4240
  }
4224
4241
  else {
4225
- this._resetOriginalStyle();
4242
+ this.#resetOriginalStyle();
4226
4243
  }
4227
4244
  this.render.destroy();
4228
- this._resizePlugins = [];
4245
+ this.#resizePlugins = [];
4229
4246
  }
4230
4247
  getZoomCenter() {
4231
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
4232
- if (this._zoomCenter) {
4233
- return this._zoomCenter;
4248
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
4249
+ if (this.#zoomCenter) {
4250
+ return this.#zoomCenter;
4234
4251
  }
4235
4252
  return {
4236
4253
  x: (width * half) / pxRatio,
@@ -4238,20 +4255,20 @@
4238
4255
  };
4239
4256
  }
4240
4257
  init() {
4241
- this._safeMutationObserver(obs => {
4258
+ this.#safeMutationObserver(obs => {
4242
4259
  obs.disconnect();
4243
4260
  });
4244
- this._mutationObserver = safeMutationObserver(records => {
4261
+ this.#mutationObserver = safeMutationObserver(records => {
4245
4262
  for (const record of records) {
4246
4263
  if (record.type === "attributes" && record.attributeName === "style") {
4247
- this._repairStyle();
4264
+ this.#repairStyle();
4248
4265
  }
4249
4266
  }
4250
4267
  });
4251
4268
  this.resize();
4252
- this._initStyle();
4269
+ this.#initStyle();
4253
4270
  this.initBackground();
4254
- this._safeMutationObserver(obs => {
4271
+ this.#safeMutationObserver(obs => {
4255
4272
  const element = this.domElement;
4256
4273
  if (!element || !(element instanceof Node)) {
4257
4274
  return;
@@ -4262,13 +4279,13 @@
4262
4279
  this.render.init();
4263
4280
  }
4264
4281
  initBackground() {
4265
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
4282
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
4266
4283
  if (!element) {
4267
4284
  return;
4268
4285
  }
4269
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
4286
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
4270
4287
  if (color) {
4271
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
4288
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
4272
4289
  }
4273
4290
  else {
4274
4291
  elementStyle.backgroundColor = "";
@@ -4279,27 +4296,27 @@
4279
4296
  elementStyle.backgroundSize = background.size || "";
4280
4297
  }
4281
4298
  initPlugins() {
4282
- this._resizePlugins = [];
4283
- for (const plugin of this._container.plugins) {
4299
+ this.#resizePlugins = [];
4300
+ for (const plugin of this.#container.plugins) {
4284
4301
  if (plugin.resize) {
4285
- this._resizePlugins.push(plugin);
4302
+ this.#resizePlugins.push(plugin);
4286
4303
  }
4287
4304
  }
4288
4305
  }
4289
4306
  loadCanvas(canvas) {
4290
- if (this._generated && this.domElement) {
4307
+ if (this.#generated && this.domElement) {
4291
4308
  this.domElement.remove();
4292
4309
  }
4293
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4310
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
4294
4311
  this.domElement = domCanvas;
4295
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4312
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
4296
4313
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
4297
4314
  const domElement = this.domElement;
4298
4315
  if (domElement) {
4299
4316
  domElement.ariaHidden = "true";
4300
- this._originalStyle = cloneStyle(domElement.style);
4317
+ this.#originalStyle = cloneStyle(domElement.style);
4301
4318
  }
4302
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
4319
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
4303
4320
  if (domElement) {
4304
4321
  standardSize.height = domElement.offsetHeight;
4305
4322
  standardSize.width = domElement.offsetWidth;
@@ -4308,7 +4325,7 @@
4308
4325
  standardSize.height = renderCanvas.height;
4309
4326
  standardSize.width = renderCanvas.width;
4310
4327
  }
4311
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
4328
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
4312
4329
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
4313
4330
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
4314
4331
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -4319,12 +4336,12 @@
4319
4336
  willReadFrequently: false,
4320
4337
  });
4321
4338
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
4322
- this._safeMutationObserver(obs => {
4339
+ this.#safeMutationObserver(obs => {
4323
4340
  obs.disconnect();
4324
4341
  });
4325
4342
  container.retina.init();
4326
4343
  this.initBackground();
4327
- this._safeMutationObserver(obs => {
4344
+ this.#safeMutationObserver(obs => {
4328
4345
  const element = this.domElement;
4329
4346
  if (!element || !(element instanceof Node)) {
4330
4347
  return;
@@ -4337,11 +4354,11 @@
4337
4354
  if (!element) {
4338
4355
  return false;
4339
4356
  }
4340
- const container = this._container, renderCanvas = this.renderCanvas;
4357
+ const container = this.#container, renderCanvas = this.renderCanvas;
4341
4358
  if (renderCanvas === undefined) {
4342
4359
  return false;
4343
4360
  }
4344
- const currentSize = container.canvas._standardSize, newSize = {
4361
+ const currentSize = container.canvas.#standardSize, newSize = {
4345
4362
  width: element.offsetWidth,
4346
4363
  height: element.offsetHeight,
4347
4364
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -4360,7 +4377,7 @@
4360
4377
  const canvasSize = this.size;
4361
4378
  renderCanvas.width = canvasSize.width = retinaSize.width;
4362
4379
  renderCanvas.height = canvasSize.height = retinaSize.height;
4363
- if (this._container.started) {
4380
+ if (this.#container.started) {
4364
4381
  container.particles.setResizeFactor({
4365
4382
  width: currentSize.width / oldSize.width,
4366
4383
  height: currentSize.height / oldSize.height,
@@ -4373,46 +4390,46 @@
4373
4390
  if (!element) {
4374
4391
  return;
4375
4392
  }
4376
- this._pointerEvents = type;
4377
- this._repairStyle();
4393
+ this.#pointerEvents = type;
4394
+ this.#repairStyle();
4378
4395
  }
4379
4396
  setZoom(zoomLevel, center) {
4380
4397
  this.zoom = zoomLevel;
4381
- this._zoomCenter = center;
4398
+ this.#zoomCenter = center;
4382
4399
  }
4383
4400
  stop() {
4384
- this._safeMutationObserver(obs => {
4401
+ this.#safeMutationObserver(obs => {
4385
4402
  obs.disconnect();
4386
4403
  });
4387
- this._mutationObserver = undefined;
4404
+ this.#mutationObserver = undefined;
4388
4405
  this.render.stop();
4389
4406
  }
4390
4407
  async windowResize() {
4391
4408
  if (!this.domElement || !this.resize()) {
4392
4409
  return;
4393
4410
  }
4394
- const container = this._container, needsRefresh = container.updateActualOptions();
4411
+ const container = this.#container, needsRefresh = container.updateActualOptions();
4395
4412
  container.particles.setDensity();
4396
- this._applyResizePlugins();
4413
+ this.#applyResizePlugins();
4397
4414
  if (needsRefresh) {
4398
4415
  await container.refresh();
4399
4416
  }
4400
4417
  }
4401
- _applyResizePlugins = () => {
4402
- for (const plugin of this._resizePlugins) {
4418
+ #applyResizePlugins = () => {
4419
+ for (const plugin of this.#resizePlugins) {
4403
4420
  plugin.resize?.();
4404
4421
  }
4405
4422
  };
4406
- _initStyle = () => {
4407
- const element = this.domElement, options = this._container.actualOptions;
4423
+ #initStyle = () => {
4424
+ const element = this.domElement, options = this.#container.actualOptions;
4408
4425
  if (!element) {
4409
4426
  return;
4410
4427
  }
4411
- if (this._fullScreen) {
4412
- this._setFullScreenStyle();
4428
+ if (this.#fullScreen) {
4429
+ this.#setFullScreenStyle();
4413
4430
  }
4414
4431
  else {
4415
- this._resetOriginalStyle();
4432
+ this.#resetOriginalStyle();
4416
4433
  }
4417
4434
  for (const key in options.style) {
4418
4435
  if (!key || !(key in options.style)) {
@@ -4425,72 +4442,72 @@
4425
4442
  element.style.setProperty(key, value, "important");
4426
4443
  }
4427
4444
  };
4428
- _repairStyle = () => {
4445
+ #repairStyle = () => {
4429
4446
  const element = this.domElement;
4430
4447
  if (!element) {
4431
4448
  return;
4432
4449
  }
4433
- this._safeMutationObserver(observer => {
4450
+ this.#safeMutationObserver(observer => {
4434
4451
  observer.disconnect();
4435
4452
  });
4436
- this._initStyle();
4453
+ this.#initStyle();
4437
4454
  this.initBackground();
4438
- const pointerEvents = this._pointerEvents;
4455
+ const pointerEvents = this.#pointerEvents;
4439
4456
  element.style.pointerEvents = pointerEvents;
4440
4457
  element.style.setProperty("pointer-events", pointerEvents);
4441
- this._safeMutationObserver(observer => {
4458
+ this.#safeMutationObserver(observer => {
4442
4459
  if (!(element instanceof Node)) {
4443
4460
  return;
4444
4461
  }
4445
4462
  observer.observe(element, { attributes: true });
4446
4463
  });
4447
4464
  };
4448
- _resetOriginalStyle = () => {
4449
- const element = this.domElement, originalStyle = this._originalStyle;
4465
+ #resetOriginalStyle = () => {
4466
+ const element = this.domElement, originalStyle = this.#originalStyle;
4450
4467
  if (!element || !originalStyle) {
4451
4468
  return;
4452
4469
  }
4453
4470
  setStyle(element, originalStyle, true);
4454
4471
  };
4455
- _safeMutationObserver = callback => {
4456
- if (!this._mutationObserver) {
4472
+ #safeMutationObserver = callback => {
4473
+ if (!this.#mutationObserver) {
4457
4474
  return;
4458
4475
  }
4459
- callback(this._mutationObserver);
4476
+ callback(this.#mutationObserver);
4460
4477
  };
4461
- _setFullScreenStyle = () => {
4478
+ #setFullScreenStyle = () => {
4462
4479
  const element = this.domElement;
4463
4480
  if (!element) {
4464
4481
  return;
4465
4482
  }
4466
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
4483
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
4467
4484
  };
4468
4485
  }
4469
4486
 
4470
4487
  class EventListeners {
4471
- container;
4472
- _handlers;
4473
- _resizeObserver;
4474
- _resizeTimeout;
4488
+ #container;
4489
+ #handlers;
4490
+ #resizeObserver;
4491
+ #resizeTimeout;
4475
4492
  constructor(container) {
4476
- this.container = container;
4477
- this._handlers = {
4493
+ this.#container = container;
4494
+ this.#handlers = {
4478
4495
  visibilityChange: () => {
4479
- this._handleVisibilityChange();
4496
+ this.#handleVisibilityChange();
4480
4497
  },
4481
4498
  resize: () => {
4482
- this._handleWindowResize();
4499
+ this.#handleWindowResize();
4483
4500
  },
4484
4501
  };
4485
4502
  }
4486
4503
  addListeners() {
4487
- this._manageListeners(true);
4504
+ this.#manageListeners(true);
4488
4505
  }
4489
4506
  removeListeners() {
4490
- this._manageListeners(false);
4507
+ this.#manageListeners(false);
4491
4508
  }
4492
- _handleVisibilityChange = () => {
4493
- const container = this.container, options = container.actualOptions;
4509
+ #handleVisibilityChange = () => {
4510
+ const container = this.#container, options = container.actualOptions;
4494
4511
  if (!options.pauseOnBlur) {
4495
4512
  return;
4496
4513
  }
@@ -4508,24 +4525,24 @@
4508
4525
  }
4509
4526
  }
4510
4527
  };
4511
- _handleWindowResize = () => {
4512
- if (this._resizeTimeout) {
4513
- clearTimeout(this._resizeTimeout);
4514
- delete this._resizeTimeout;
4528
+ #handleWindowResize = () => {
4529
+ if (this.#resizeTimeout) {
4530
+ clearTimeout(this.#resizeTimeout);
4531
+ this.#resizeTimeout = undefined;
4515
4532
  }
4516
4533
  const handleResize = async () => {
4517
- const canvas = this.container.canvas;
4534
+ const canvas = this.#container.canvas;
4518
4535
  await canvas.windowResize();
4519
4536
  };
4520
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
4537
+ this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
4521
4538
  };
4522
- _manageListeners = add => {
4523
- const handlers = this._handlers;
4524
- this._manageResize(add);
4539
+ #manageListeners = add => {
4540
+ const handlers = this.#handlers;
4541
+ this.#manageResize(add);
4525
4542
  manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
4526
4543
  };
4527
- _manageResize = add => {
4528
- const handlers = this._handlers, container = this.container, options = container.actualOptions;
4544
+ #manageResize = add => {
4545
+ const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
4529
4546
  if (!options.resize.enable) {
4530
4547
  return;
4531
4548
  }
@@ -4534,22 +4551,22 @@
4534
4551
  return;
4535
4552
  }
4536
4553
  const canvasEl = container.canvas.domElement;
4537
- if (this._resizeObserver && !add) {
4554
+ if (this.#resizeObserver && !add) {
4538
4555
  if (canvasEl) {
4539
- this._resizeObserver.unobserve(canvasEl);
4556
+ this.#resizeObserver.unobserve(canvasEl);
4540
4557
  }
4541
- this._resizeObserver.disconnect();
4542
- delete this._resizeObserver;
4558
+ this.#resizeObserver.disconnect();
4559
+ this.#resizeObserver = undefined;
4543
4560
  }
4544
- else if (!this._resizeObserver && add && canvasEl) {
4545
- this._resizeObserver = new ResizeObserver((entries) => {
4561
+ else if (!this.#resizeObserver && add && canvasEl) {
4562
+ this.#resizeObserver = new ResizeObserver((entries) => {
4546
4563
  const entry = entries.find(e => e.target === canvasEl);
4547
4564
  if (!entry) {
4548
4565
  return;
4549
4566
  }
4550
- this._handleWindowResize();
4567
+ this.#handleWindowResize();
4551
4568
  });
4552
- this._resizeObserver.observe(canvasEl);
4569
+ this.#resizeObserver.observe(canvasEl);
4553
4570
  }
4554
4571
  };
4555
4572
  }
@@ -4622,24 +4639,24 @@
4622
4639
  unbreakable;
4623
4640
  velocity;
4624
4641
  zIndexFactor;
4625
- _cachedOpacityData = {
4642
+ #cachedOpacityData = {
4626
4643
  fillOpacity: defaultOpacity$1,
4627
4644
  opacity: defaultOpacity$1,
4628
4645
  strokeOpacity: defaultOpacity$1,
4629
4646
  };
4630
- _cachedPosition = Vector3d.origin;
4631
- _cachedRotateData = { sin: 0, cos: 0 };
4632
- _cachedTransform = {
4647
+ #cachedPosition = Vector3d.origin;
4648
+ #cachedRotateData = { sin: 0, cos: 0 };
4649
+ #cachedTransform = {
4633
4650
  a: 1,
4634
4651
  b: 0,
4635
4652
  c: 0,
4636
4653
  d: 1,
4637
4654
  };
4638
- _container;
4639
- _pluginManager;
4655
+ #container;
4656
+ #pluginManager;
4640
4657
  constructor(pluginManager, container) {
4641
- this._pluginManager = pluginManager;
4642
- this._container = container;
4658
+ this.#pluginManager = pluginManager;
4659
+ this.#container = container;
4643
4660
  }
4644
4661
  destroy(override) {
4645
4662
  if (this.unbreakable || this.destroyed) {
@@ -4648,7 +4665,7 @@
4648
4665
  this.destroyed = true;
4649
4666
  this.bubble.inRange = false;
4650
4667
  this.slow.inRange = false;
4651
- const container = this._container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4668
+ const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
4652
4669
  shapeDrawer?.particleDestroy?.(this);
4653
4670
  for (const plugin of container.particleDestroyedPlugins) {
4654
4671
  plugin.particleDestroyed?.(this, override);
@@ -4656,12 +4673,12 @@
4656
4673
  for (const updater of container.particleUpdaters) {
4657
4674
  updater.particleDestroyed?.(this, override);
4658
4675
  }
4659
- this._container.dispatchEvent(exports.EventType.particleDestroyed, {
4676
+ this.#container.dispatchEvent(exports.EventType.particleDestroyed, {
4660
4677
  particle: this,
4661
4678
  });
4662
4679
  }
4663
4680
  draw(delta) {
4664
- const container = this._container, render = container.canvas.render;
4681
+ const container = this.#container, render = container.canvas.render;
4665
4682
  render.drawParticlePlugins(this, delta);
4666
4683
  render.drawParticle(this, delta);
4667
4684
  }
@@ -4669,50 +4686,50 @@
4669
4686
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
4670
4687
  }
4671
4688
  getFillColor() {
4672
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4689
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
4673
4690
  }
4674
4691
  getMass() {
4675
4692
  return this.getRadius() ** squareExp * Math.PI * half;
4676
4693
  }
4677
4694
  getOpacity() {
4678
4695
  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;
4679
- this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4680
- this._cachedOpacityData.opacity = opacity * zOpacityFactor;
4681
- this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4682
- return this._cachedOpacityData;
4696
+ this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
4697
+ this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
4698
+ this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
4699
+ return this.#cachedOpacityData;
4683
4700
  }
4684
4701
  getPosition() {
4685
- this._cachedPosition.x = this.position.x + this.offset.x;
4686
- this._cachedPosition.y = this.position.y + this.offset.y;
4687
- this._cachedPosition.z = this.position.z;
4688
- return this._cachedPosition;
4702
+ this.#cachedPosition.x = this.position.x + this.offset.x;
4703
+ this.#cachedPosition.y = this.position.y + this.offset.y;
4704
+ this.#cachedPosition.z = this.position.z;
4705
+ return this.#cachedPosition;
4689
4706
  }
4690
4707
  getRadius() {
4691
4708
  return this.bubble.radius ?? this.size.value;
4692
4709
  }
4693
4710
  getRotateData() {
4694
4711
  const angle = this.getAngle();
4695
- this._cachedRotateData.sin = Math.sin(angle);
4696
- this._cachedRotateData.cos = Math.cos(angle);
4697
- return this._cachedRotateData;
4712
+ this.#cachedRotateData.sin = Math.sin(angle);
4713
+ this.#cachedRotateData.cos = Math.cos(angle);
4714
+ return this.#cachedRotateData;
4698
4715
  }
4699
4716
  getStrokeColor() {
4700
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4717
+ return this.#getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
4701
4718
  }
4702
4719
  getTransformData(externalTransform) {
4703
4720
  const rotateData = this.getRotateData(), rotating = this.isRotating;
4704
- this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4705
- this._cachedTransform.b = rotating
4721
+ this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
4722
+ this.#cachedTransform.b = rotating
4706
4723
  ? rotateData.sin * (externalTransform.b ?? identity$1)
4707
4724
  : (externalTransform.b ?? defaultTransform.b);
4708
- this._cachedTransform.c = rotating
4725
+ this.#cachedTransform.c = rotating
4709
4726
  ? -rotateData.sin * (externalTransform.c ?? identity$1)
4710
4727
  : (externalTransform.c ?? defaultTransform.c);
4711
- this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4712
- return this._cachedTransform;
4728
+ this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
4729
+ return this.#cachedTransform;
4713
4730
  }
4714
4731
  init(id, position, overrideOptions, group) {
4715
- const container = this._container;
4732
+ const container = this.#container;
4716
4733
  this.id = id;
4717
4734
  this.group = group;
4718
4735
  this.justWarped = false;
@@ -4732,21 +4749,27 @@
4732
4749
  moveSpeed: 0,
4733
4750
  sizeAnimationSpeed: 0,
4734
4751
  };
4752
+ this.size = {
4753
+ value: 1,
4754
+ max: 1,
4755
+ min: 1,
4756
+ enable: false,
4757
+ };
4735
4758
  this.outType = exports.ParticleOutType.normal;
4736
4759
  this.ignoresResizeRatio = true;
4737
- 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;
4760
+ const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
4738
4761
  this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
4739
4762
  this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
4740
4763
  const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
4741
4764
  if (overrideOptions) {
4742
- if (overrideOptions.effect?.type) {
4765
+ if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
4743
4766
  const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
4744
4767
  if (effect) {
4745
4768
  this.effect = effect;
4746
4769
  effectOptions.load(overrideOptions.effect);
4747
4770
  }
4748
4771
  }
4749
- if (overrideOptions.shape?.type) {
4772
+ if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
4750
4773
  const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
4751
4774
  if (shape) {
4752
4775
  this.shape = shape;
@@ -4755,21 +4778,20 @@
4755
4778
  }
4756
4779
  }
4757
4780
  if (this.effect === randomColorValue) {
4758
- const availableEffects = [...this._container.effectDrawers.keys()];
4781
+ const availableEffects = [...this.#container.effectDrawers.keys()];
4759
4782
  this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
4760
4783
  }
4761
4784
  if (this.shape === randomColorValue) {
4762
- const availableShapes = [...this._container.shapeDrawers.keys()];
4785
+ const availableShapes = [...this.#container.shapeDrawers.keys()];
4763
4786
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
4764
4787
  }
4765
4788
  this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
4766
4789
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
4767
4790
  particlesOptions.load(overrideOptions);
4768
- const effectData = this.effectData;
4791
+ const effectData = this.effectData, shapeData = this.shapeData;
4769
4792
  if (effectData) {
4770
4793
  particlesOptions.load(effectData.particles);
4771
4794
  }
4772
- const shapeData = this.shapeData;
4773
4795
  if (shapeData) {
4774
4796
  particlesOptions.load(shapeData.particles);
4775
4797
  }
@@ -4777,7 +4799,9 @@
4777
4799
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
4778
4800
  this.options = particlesOptions;
4779
4801
  container.retina.initParticle(this);
4780
- this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
4802
+ for (const updater of container.particleUpdaters) {
4803
+ updater.preInit?.(this);
4804
+ }
4781
4805
  this.bubble = {
4782
4806
  inRange: false,
4783
4807
  };
@@ -4785,8 +4809,8 @@
4785
4809
  inRange: false,
4786
4810
  factor: 1,
4787
4811
  };
4788
- this._initPosition(position);
4789
- this.initialVelocity = this._calculateVelocity();
4812
+ this.#initPosition(position);
4813
+ this.initialVelocity = this.#calculateVelocity();
4790
4814
  this.velocity = this.initialVelocity.copy();
4791
4815
  this.zIndexFactor = this.position.z / container.zLayers;
4792
4816
  this.sides = 24;
@@ -4817,12 +4841,11 @@
4817
4841
  plugin.particleCreated?.(this);
4818
4842
  }
4819
4843
  }
4820
- isInsideCanvas() {
4821
- const radius = this.getRadius(), canvasSize = this._container.canvas.size, position = this.position;
4822
- return (position.x >= -radius &&
4823
- position.y >= -radius &&
4824
- position.y <= canvasSize.height + radius &&
4825
- position.x <= canvasSize.width + radius);
4844
+ isInsideCanvas(direction) {
4845
+ return this.#getInsideCanvasResult({ direction }).inside;
4846
+ }
4847
+ isInsideCanvasForOutMode(outMode, direction) {
4848
+ return this.#getInsideCanvasResult({ direction, outMode }).inside;
4826
4849
  }
4827
4850
  isShowingBack() {
4828
4851
  if (!this.roll) {
@@ -4847,13 +4870,13 @@
4847
4870
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
4848
4871
  }
4849
4872
  reset() {
4850
- for (const updater of this._container.particleUpdaters) {
4873
+ for (const updater of this.#container.particleUpdaters) {
4851
4874
  updater.reset?.(this);
4852
4875
  }
4853
4876
  }
4854
- _calcPosition = (position, zIndex) => {
4877
+ #calcPosition = (position, zIndex) => {
4855
4878
  let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
4856
- const container = this._container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
4879
+ const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
4857
4880
  while (!signal.aborted) {
4858
4881
  for (const plugin of plugins) {
4859
4882
  const pluginPos = plugin.particlePosition?.(posVec, this);
@@ -4865,10 +4888,10 @@
4865
4888
  size: canvasSize,
4866
4889
  position: posVec,
4867
4890
  }), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
4868
- this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
4869
- this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
4870
- this._fixVertical(pos, radius, outModes.top ?? outModes.default);
4871
- this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
4891
+ this.#fixHorizontal(pos, radius, outModes.left ?? outModes.default);
4892
+ this.#fixHorizontal(pos, radius, outModes.right ?? outModes.default);
4893
+ this.#fixVertical(pos, radius, outModes.top ?? outModes.default);
4894
+ this.#fixVertical(pos, radius, outModes.bottom ?? outModes.default);
4872
4895
  let isValidPosition = true;
4873
4896
  for (const plugin of container.particles.checkParticlePositionPlugins) {
4874
4897
  isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
@@ -4884,8 +4907,8 @@
4884
4907
  }
4885
4908
  return posVec;
4886
4909
  };
4887
- _calculateVelocity = () => {
4888
- const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
4910
+ #calculateVelocity = () => {
4911
+ const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
4889
4912
  if (moveOptions.direction === exports.MoveDirection.inside || moveOptions.direction === exports.MoveDirection.outside) {
4890
4913
  return res;
4891
4914
  }
@@ -4901,27 +4924,86 @@
4901
4924
  }
4902
4925
  return res;
4903
4926
  };
4904
- _fixHorizontal = (pos, radius, outMode) => {
4927
+ #fixHorizontal = (pos, radius, outMode) => {
4905
4928
  fixOutMode({
4906
4929
  outMode,
4907
4930
  checkModes: [exports.OutMode.bounce],
4908
4931
  coord: pos.x,
4909
- maxCoord: this._container.canvas.size.width,
4932
+ maxCoord: this.#container.canvas.size.width,
4910
4933
  setCb: (value) => (pos.x += value),
4911
4934
  radius,
4912
4935
  });
4913
4936
  };
4914
- _fixVertical = (pos, radius, outMode) => {
4937
+ #fixVertical = (pos, radius, outMode) => {
4915
4938
  fixOutMode({
4916
4939
  outMode,
4917
4940
  checkModes: [exports.OutMode.bounce],
4918
4941
  coord: pos.y,
4919
- maxCoord: this._container.canvas.size.height,
4942
+ maxCoord: this.#container.canvas.size.height,
4920
4943
  setCb: (value) => (pos.y += value),
4921
4944
  radius,
4922
4945
  });
4923
4946
  };
4924
- _getRollColor = color => {
4947
+ #getDefaultInsideCanvasResult = (direction, outMode) => {
4948
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === exports.OutMode.bounce;
4949
+ if (direction === exports.OutModeDirection.bottom) {
4950
+ return {
4951
+ inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
4952
+ reason: "default",
4953
+ };
4954
+ }
4955
+ if (direction === exports.OutModeDirection.left) {
4956
+ return {
4957
+ inside: isBounce ? position.x - radius > defaultAngle : position.x + radius > defaultAngle,
4958
+ reason: "default",
4959
+ };
4960
+ }
4961
+ if (direction === exports.OutModeDirection.right) {
4962
+ return {
4963
+ inside: isBounce ? position.x + radius < canvasSize.width : position.x - radius < canvasSize.width,
4964
+ reason: "default",
4965
+ };
4966
+ }
4967
+ if (direction === exports.OutModeDirection.top) {
4968
+ return {
4969
+ inside: isBounce ? position.y - radius > defaultAngle : position.y + radius > defaultAngle,
4970
+ reason: "default",
4971
+ };
4972
+ }
4973
+ return {
4974
+ inside: position.x >= -radius &&
4975
+ position.y >= -radius &&
4976
+ position.y <= canvasSize.height + radius &&
4977
+ position.x <= canvasSize.width + radius,
4978
+ reason: "default",
4979
+ };
4980
+ };
4981
+ #getInsideCanvasCallbackData = (direction, outMode) => {
4982
+ return {
4983
+ canvasSize: this.#container.canvas.size,
4984
+ direction,
4985
+ outMode,
4986
+ particle: this,
4987
+ radius: this.getRadius(),
4988
+ };
4989
+ };
4990
+ #getInsideCanvasResult = (data) => {
4991
+ 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;
4992
+ if (!shapeCheck && !effectCheck) {
4993
+ return defaultResult;
4994
+ }
4995
+ const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
4996
+ if (shapeResult && effectResult) {
4997
+ const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
4998
+ return {
4999
+ inside: shapeResult.inside && effectResult.inside,
5000
+ margin: margin > defaultAngle ? margin : undefined,
5001
+ reason: "combined",
5002
+ };
5003
+ }
5004
+ return shapeResult ?? effectResult ?? defaultResult;
5005
+ };
5006
+ #getRollColor = color => {
4925
5007
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
4926
5008
  return color;
4927
5009
  }
@@ -4936,8 +5018,8 @@
4936
5018
  }
4937
5019
  return color;
4938
5020
  };
4939
- _initPosition = position => {
4940
- const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
5021
+ #initPosition = position => {
5022
+ const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
4941
5023
  if (!initialPosition) {
4942
5024
  throw new Error("a valid position cannot be found for particle");
4943
5025
  }
@@ -4960,45 +5042,58 @@
4960
5042
  }
4961
5043
  this.offset = Vector.origin;
4962
5044
  };
5045
+ #normalizeInsideCanvasResult = (result, reason) => {
5046
+ if (typeof result === "boolean") {
5047
+ return {
5048
+ inside: result,
5049
+ reason,
5050
+ };
5051
+ }
5052
+ return {
5053
+ inside: result.inside,
5054
+ margin: result.margin,
5055
+ reason: result.reason ?? reason,
5056
+ };
5057
+ };
4963
5058
  }
4964
5059
 
4965
5060
  class SpatialHashGrid {
4966
- _cellSize;
4967
- _cells = new Map();
4968
- _circlePool = [];
4969
- _circlePoolIdx;
4970
- _pendingCellSize;
4971
- _rectanglePool = [];
4972
- _rectanglePoolIdx;
5061
+ #cellSize;
5062
+ #cells = new Map();
5063
+ #circlePool = [];
5064
+ #circlePoolIdx;
5065
+ #pendingCellSize;
5066
+ #rectanglePool = [];
5067
+ #rectanglePoolIdx;
4973
5068
  constructor(cellSize) {
4974
- this._cellSize = cellSize;
4975
- this._circlePoolIdx = 0;
4976
- this._rectanglePoolIdx = 0;
5069
+ this.#cellSize = cellSize;
5070
+ this.#circlePoolIdx = 0;
5071
+ this.#rectanglePoolIdx = 0;
4977
5072
  }
4978
5073
  clear() {
4979
- this._cells.clear();
4980
- const pendingCellSize = this._pendingCellSize;
5074
+ this.#cells.clear();
5075
+ const pendingCellSize = this.#pendingCellSize;
4981
5076
  if (pendingCellSize) {
4982
- this._cellSize = pendingCellSize;
5077
+ this.#cellSize = pendingCellSize;
4983
5078
  }
4984
- this._pendingCellSize = undefined;
5079
+ this.#pendingCellSize = undefined;
4985
5080
  }
4986
5081
  insert(particle) {
4987
- const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
4988
- if (!this._cells.has(key)) {
4989
- this._cells.set(key, []);
5082
+ const { x, y } = particle.getPosition(), key = this.#cellKeyFromCoords(x, y);
5083
+ if (!this.#cells.has(key)) {
5084
+ this.#cells.set(key, []);
4990
5085
  }
4991
- this._cells.get(key)?.push(particle);
5086
+ this.#cells.get(key)?.push(particle);
4992
5087
  }
4993
5088
  query(range, check, out = []) {
4994
- const bounds = this._getRangeBounds(range);
5089
+ const bounds = this.#getRangeBounds(range);
4995
5090
  if (!bounds) {
4996
5091
  return out;
4997
5092
  }
4998
- 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);
5093
+ 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);
4999
5094
  for (let cx = minCellX; cx <= maxCellX; cx++) {
5000
5095
  for (let cy = minCellY; cy <= maxCellY; cy++) {
5001
- const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
5096
+ const key = `${cx}_${cy}`, cellParticles = this.#cells.get(key);
5002
5097
  if (!cellParticles) {
5003
5098
  continue;
5004
5099
  }
@@ -5015,29 +5110,29 @@
5015
5110
  return out;
5016
5111
  }
5017
5112
  queryCircle(position, radius, check, out = []) {
5018
- const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5019
- this._releaseShapes();
5113
+ const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5114
+ this.#releaseShapes();
5020
5115
  return result;
5021
5116
  }
5022
5117
  queryRectangle(position, size, check, out = []) {
5023
- const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5024
- this._releaseShapes();
5118
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5119
+ this.#releaseShapes();
5025
5120
  return result;
5026
5121
  }
5027
5122
  setCellSize(cellSize) {
5028
- this._pendingCellSize = cellSize;
5123
+ this.#pendingCellSize = cellSize;
5029
5124
  }
5030
- _acquireCircle(x, y, r) {
5031
- return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5125
+ #acquireCircle(x, y, r) {
5126
+ return (this.#circlePool[this.#circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
5032
5127
  }
5033
- _acquireRectangle(x, y, w, h) {
5034
- return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5128
+ #acquireRectangle(x, y, w, h) {
5129
+ return (this.#rectanglePool[this.#rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
5035
5130
  }
5036
- _cellKeyFromCoords(x, y) {
5037
- const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
5131
+ #cellKeyFromCoords(x, y) {
5132
+ const cellX = Math.floor(x / this.#cellSize), cellY = Math.floor(y / this.#cellSize);
5038
5133
  return `${cellX}_${cellY}`;
5039
5134
  }
5040
- _getRangeBounds(range) {
5135
+ #getRangeBounds(range) {
5041
5136
  if (range instanceof Circle) {
5042
5137
  const r = range.radius, { x, y } = range.position;
5043
5138
  return {
@@ -5058,53 +5153,53 @@
5058
5153
  }
5059
5154
  return null;
5060
5155
  }
5061
- _releaseShapes() {
5062
- this._circlePoolIdx = 0;
5063
- this._rectanglePoolIdx = 0;
5156
+ #releaseShapes() {
5157
+ this.#circlePoolIdx = 0;
5158
+ this.#rectanglePoolIdx = 0;
5064
5159
  }
5065
5160
  }
5066
5161
 
5067
5162
  class ParticlesManager {
5068
5163
  checkParticlePositionPlugins;
5069
5164
  grid;
5070
- _array;
5071
- _container;
5072
- _groupLimits;
5073
- _limit;
5074
- _nextId;
5075
- _particleBuckets;
5076
- _particleResetPlugins;
5077
- _particleUpdatePlugins;
5078
- _pluginManager;
5079
- _pool;
5080
- _postParticleUpdatePlugins;
5081
- _postUpdatePlugins;
5082
- _resizeFactor;
5083
- _updatePlugins;
5084
- _zBuckets;
5165
+ #array;
5166
+ #container;
5167
+ #groupLimits;
5168
+ #limit;
5169
+ #nextId;
5170
+ #particleBuckets;
5171
+ #particleResetPlugins;
5172
+ #particleUpdatePlugins;
5173
+ #pluginManager;
5174
+ #pool;
5175
+ #postParticleUpdatePlugins;
5176
+ #postUpdatePlugins;
5177
+ #resizeFactor;
5178
+ #updatePlugins;
5179
+ #zBuckets;
5085
5180
  constructor(pluginManager, container) {
5086
- this._pluginManager = pluginManager;
5087
- this._container = container;
5088
- this._nextId = 0;
5089
- this._array = [];
5090
- this._pool = [];
5091
- this._limit = 0;
5092
- this._groupLimits = new Map();
5093
- this._particleBuckets = new Map();
5094
- this._zBuckets = this._createBuckets(this._container.zLayers);
5181
+ this.#pluginManager = pluginManager;
5182
+ this.#container = container;
5183
+ this.#nextId = 0;
5184
+ this.#array = [];
5185
+ this.#pool = [];
5186
+ this.#limit = 0;
5187
+ this.#groupLimits = new Map();
5188
+ this.#particleBuckets = new Map();
5189
+ this.#zBuckets = this.#createBuckets(this.#container.zLayers);
5095
5190
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
5096
5191
  this.checkParticlePositionPlugins = [];
5097
- this._particleResetPlugins = [];
5098
- this._particleUpdatePlugins = [];
5099
- this._postUpdatePlugins = [];
5100
- this._postParticleUpdatePlugins = [];
5101
- this._updatePlugins = [];
5192
+ this.#particleResetPlugins = [];
5193
+ this.#particleUpdatePlugins = [];
5194
+ this.#postUpdatePlugins = [];
5195
+ this.#postParticleUpdatePlugins = [];
5196
+ this.#updatePlugins = [];
5102
5197
  }
5103
5198
  get count() {
5104
- return this._array.length;
5199
+ return this.#array.length;
5105
5200
  }
5106
5201
  addParticle(position, overrideOptions, group, initializer) {
5107
- const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
5202
+ const limitMode = this.#container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this.#limit : (this.#groupLimits.get(group) ?? this.#limit), currentCount = this.count;
5108
5203
  if (limit > minLimit) {
5109
5204
  switch (limitMode) {
5110
5205
  case exports.LimitMode.delete: {
@@ -5122,20 +5217,20 @@
5122
5217
  }
5123
5218
  }
5124
5219
  try {
5125
- const particle = this._pool.pop() ?? new Particle(this._pluginManager, this._container);
5126
- particle.init(this._nextId, position, overrideOptions, group);
5220
+ const particle = this.#pool.pop() ?? new Particle(this.#pluginManager, this.#container);
5221
+ particle.init(this.#nextId, position, overrideOptions, group);
5127
5222
  let canAdd = true;
5128
5223
  if (initializer) {
5129
5224
  canAdd = initializer(particle);
5130
5225
  }
5131
5226
  if (!canAdd) {
5132
- this._pool.push(particle);
5227
+ this.#pool.push(particle);
5133
5228
  return;
5134
5229
  }
5135
- this._array.push(particle);
5136
- this._insertParticleIntoBucket(particle);
5137
- this._nextId++;
5138
- this._container.dispatchEvent(exports.EventType.particleAdded, {
5230
+ this.#array.push(particle);
5231
+ this.#insertParticleIntoBucket(particle);
5232
+ this.#nextId++;
5233
+ this.#container.dispatchEvent(exports.EventType.particleAdded, {
5139
5234
  particle,
5140
5235
  });
5141
5236
  return particle;
@@ -5146,25 +5241,25 @@
5146
5241
  return undefined;
5147
5242
  }
5148
5243
  clear() {
5149
- this._array = [];
5150
- this._particleBuckets.clear();
5151
- this._resetBuckets(this._container.zLayers);
5244
+ this.#array = [];
5245
+ this.#particleBuckets.clear();
5246
+ this.#resetBuckets(this.#container.zLayers);
5152
5247
  }
5153
5248
  destroy() {
5154
- this._array = [];
5155
- this._pool.length = 0;
5156
- this._particleBuckets.clear();
5157
- this._zBuckets = [];
5249
+ this.#array = [];
5250
+ this.#pool.length = 0;
5251
+ this.#particleBuckets.clear();
5252
+ this.#zBuckets = [];
5158
5253
  this.checkParticlePositionPlugins = [];
5159
- this._particleResetPlugins = [];
5160
- this._particleUpdatePlugins = [];
5161
- this._postUpdatePlugins = [];
5162
- this._postParticleUpdatePlugins = [];
5163
- this._updatePlugins = [];
5254
+ this.#particleResetPlugins = [];
5255
+ this.#particleUpdatePlugins = [];
5256
+ this.#postUpdatePlugins = [];
5257
+ this.#postParticleUpdatePlugins = [];
5258
+ this.#updatePlugins = [];
5164
5259
  }
5165
5260
  drawParticles(delta) {
5166
- for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
5167
- const bucket = this._zBuckets[i];
5261
+ for (let i = this.#zBuckets.length - one; i >= minIndex; i--) {
5262
+ const bucket = this.#zBuckets[i];
5168
5263
  if (!bucket) {
5169
5264
  continue;
5170
5265
  }
@@ -5174,24 +5269,24 @@
5174
5269
  }
5175
5270
  }
5176
5271
  filter(condition) {
5177
- return this._array.filter(condition);
5272
+ return this.#array.filter(condition);
5178
5273
  }
5179
5274
  find(condition) {
5180
- return this._array.find(condition);
5275
+ return this.#array.find(condition);
5181
5276
  }
5182
5277
  get(index) {
5183
- return this._array[index];
5278
+ return this.#array[index];
5184
5279
  }
5185
5280
  async init() {
5186
- const container = this._container, options = container.actualOptions;
5281
+ const container = this.#container, options = container.actualOptions;
5187
5282
  this.checkParticlePositionPlugins = [];
5188
- this._updatePlugins = [];
5189
- this._particleUpdatePlugins = [];
5190
- this._postUpdatePlugins = [];
5191
- this._particleResetPlugins = [];
5192
- this._postParticleUpdatePlugins = [];
5193
- this._particleBuckets.clear();
5194
- this._resetBuckets(container.zLayers);
5283
+ this.#updatePlugins = [];
5284
+ this.#particleUpdatePlugins = [];
5285
+ this.#postUpdatePlugins = [];
5286
+ this.#particleResetPlugins = [];
5287
+ this.#postParticleUpdatePlugins = [];
5288
+ this.#particleBuckets.clear();
5289
+ this.#resetBuckets(container.zLayers);
5195
5290
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
5196
5291
  for (const plugin of container.plugins) {
5197
5292
  if (plugin.redrawInit) {
@@ -5201,26 +5296,26 @@
5201
5296
  this.checkParticlePositionPlugins.push(plugin);
5202
5297
  }
5203
5298
  if (plugin.update) {
5204
- this._updatePlugins.push(plugin);
5299
+ this.#updatePlugins.push(plugin);
5205
5300
  }
5206
5301
  if (plugin.particleUpdate) {
5207
- this._particleUpdatePlugins.push(plugin);
5302
+ this.#particleUpdatePlugins.push(plugin);
5208
5303
  }
5209
5304
  if (plugin.postUpdate) {
5210
- this._postUpdatePlugins.push(plugin);
5305
+ this.#postUpdatePlugins.push(plugin);
5211
5306
  }
5212
5307
  if (plugin.particleReset) {
5213
- this._particleResetPlugins.push(plugin);
5308
+ this.#particleResetPlugins.push(plugin);
5214
5309
  }
5215
5310
  if (plugin.postParticleUpdate) {
5216
- this._postParticleUpdatePlugins.push(plugin);
5311
+ this.#postParticleUpdatePlugins.push(plugin);
5217
5312
  }
5218
5313
  }
5219
- await this._container.initDrawersAndUpdaters();
5220
- for (const drawer of this._container.effectDrawers.values()) {
5314
+ await this.#container.initDrawersAndUpdaters();
5315
+ for (const drawer of this.#container.effectDrawers.values()) {
5221
5316
  await drawer.init?.(container);
5222
5317
  }
5223
- for (const drawer of this._container.shapeDrawers.values()) {
5318
+ for (const drawer of this.#container.shapeDrawers.values()) {
5224
5319
  await drawer.init?.(container);
5225
5320
  }
5226
5321
  let handled = false;
@@ -5254,10 +5349,10 @@
5254
5349
  async redraw() {
5255
5350
  this.clear();
5256
5351
  await this.init();
5257
- this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
5352
+ this.#container.canvas.render.drawParticles({ value: 0, factor: 0 });
5258
5353
  }
5259
5354
  remove(particle, group, override) {
5260
- this.removeAt(this._array.indexOf(particle), undefined, group, override);
5355
+ this.removeAt(this.#array.indexOf(particle), undefined, group, override);
5261
5356
  }
5262
5357
  removeAt(index, quantity = defaultRemoveQuantity, group, override) {
5263
5358
  if (index < minIndex || index > this.count) {
@@ -5265,7 +5360,7 @@
5265
5360
  }
5266
5361
  let deleted = 0;
5267
5362
  for (let i = index; deleted < quantity && i < this.count; i++) {
5268
- if (this._removeParticle(i, group, override)) {
5363
+ if (this.#removeParticle(i, group, override)) {
5269
5364
  i--;
5270
5365
  deleted++;
5271
5366
  }
@@ -5275,9 +5370,9 @@
5275
5370
  this.removeAt(minIndex, quantity, group);
5276
5371
  }
5277
5372
  setDensity() {
5278
- const options = this._container.actualOptions, groups = options.particles.groups;
5373
+ const options = this.#container.actualOptions, groups = options.particles.groups;
5279
5374
  let pluginsCount = 0;
5280
- for (const plugin of this._container.plugins) {
5375
+ for (const plugin of this.#container.plugins) {
5281
5376
  if (plugin.particlesDensityCount) {
5282
5377
  pluginsCount += plugin.particlesDensityCount();
5283
5378
  }
@@ -5287,51 +5382,51 @@
5287
5382
  if (!groupData) {
5288
5383
  continue;
5289
5384
  }
5290
- const groupDataOptions = loadParticlesOptions(this._pluginManager, this._container, groupData);
5291
- this._applyDensity(groupDataOptions, pluginsCount, group);
5385
+ const groupDataOptions = loadParticlesOptions(this.#pluginManager, this.#container, groupData);
5386
+ this.#applyDensity(groupDataOptions, pluginsCount, group);
5292
5387
  }
5293
- this._applyDensity(options.particles, pluginsCount);
5388
+ this.#applyDensity(options.particles, pluginsCount);
5294
5389
  }
5295
5390
  setResizeFactor(factor) {
5296
- this._resizeFactor = factor;
5391
+ this.#resizeFactor = factor;
5297
5392
  }
5298
5393
  update(delta) {
5299
5394
  this.grid.clear();
5300
- for (const plugin of this._updatePlugins) {
5395
+ for (const plugin of this.#updatePlugins) {
5301
5396
  plugin.update?.(delta);
5302
5397
  }
5303
- const particlesToDelete = this._updateParticlesPhase1(delta);
5304
- for (const plugin of this._postUpdatePlugins) {
5398
+ const particlesToDelete = this.#updateParticlesPhase1(delta);
5399
+ for (const plugin of this.#postUpdatePlugins) {
5305
5400
  plugin.postUpdate?.(delta);
5306
5401
  }
5307
- this._updateParticlesPhase2(delta, particlesToDelete);
5402
+ this.#updateParticlesPhase2(delta, particlesToDelete);
5308
5403
  if (particlesToDelete.size) {
5309
5404
  for (const particle of particlesToDelete) {
5310
5405
  this.remove(particle);
5311
5406
  }
5312
5407
  }
5313
- delete this._resizeFactor;
5408
+ this.#resizeFactor = undefined;
5314
5409
  }
5315
- _addToPool = (...particles) => {
5316
- this._pool.push(...particles);
5410
+ #addToPool = (...particles) => {
5411
+ this.#pool.push(...particles);
5317
5412
  };
5318
- _applyDensity = (options, pluginsCount, group, groupOptions) => {
5413
+ #applyDensity = (options, pluginsCount, group, groupOptions) => {
5319
5414
  const numberOptions = options.number;
5320
5415
  if (!numberOptions.density.enable) {
5321
5416
  if (group === undefined) {
5322
- this._limit = numberOptions.limit.value;
5417
+ this.#limit = numberOptions.limit.value;
5323
5418
  }
5324
5419
  else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
5325
- this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5420
+ this.#groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
5326
5421
  }
5327
5422
  return;
5328
5423
  }
5329
- 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);
5424
+ 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);
5330
5425
  if (group === undefined) {
5331
- this._limit = numberOptions.limit.value * densityFactor;
5426
+ this.#limit = numberOptions.limit.value * densityFactor;
5332
5427
  }
5333
5428
  else {
5334
- this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
5429
+ this.#groupLimits.set(group, numberOptions.limit.value * densityFactor);
5335
5430
  }
5336
5431
  if (particlesCount < particlesNumber) {
5337
5432
  this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
@@ -5340,18 +5435,18 @@
5340
5435
  this.removeQuantity(particlesCount - particlesNumber, group);
5341
5436
  }
5342
5437
  };
5343
- _createBuckets = (zLayers) => {
5438
+ #createBuckets = (zLayers) => {
5344
5439
  const bucketCount = Math.max(Math.floor(zLayers), one);
5345
5440
  return Array.from({ length: bucketCount }, () => []);
5346
5441
  };
5347
- _getBucketIndex = (zIndex) => {
5348
- const maxBucketIndex = this._zBuckets.length - one;
5442
+ #getBucketIndex = (zIndex) => {
5443
+ const maxBucketIndex = this.#zBuckets.length - one;
5349
5444
  if (maxBucketIndex <= minIndex) {
5350
5445
  return minIndex;
5351
5446
  }
5352
5447
  return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
5353
5448
  };
5354
- _getParticleInsertIndex = (bucket, particleId) => {
5449
+ #getParticleInsertIndex = (bucket, particleId) => {
5355
5450
  let start = minIndex, end = bucket.length;
5356
5451
  while (start < end) {
5357
5452
  const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
@@ -5368,8 +5463,8 @@
5368
5463
  }
5369
5464
  return start;
5370
5465
  };
5371
- _initDensityFactor = densityOptions => {
5372
- const container = this._container;
5466
+ #initDensityFactor = densityOptions => {
5467
+ const container = this.#container;
5373
5468
  if (!densityOptions.enable) {
5374
5469
  return defaultDensityFactor;
5375
5470
  }
@@ -5379,82 +5474,82 @@
5379
5474
  }
5380
5475
  return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
5381
5476
  };
5382
- _insertParticleIntoBucket = (particle) => {
5383
- const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5477
+ #insertParticleIntoBucket = (particle) => {
5478
+ const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5384
5479
  if (!bucket) {
5385
5480
  return;
5386
5481
  }
5387
- bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
5388
- this._particleBuckets.set(particle.id, bucketIndex);
5482
+ bucket.splice(this.#getParticleInsertIndex(bucket, particle.id), empty, particle);
5483
+ this.#particleBuckets.set(particle.id, bucketIndex);
5389
5484
  };
5390
- _removeParticle = (index, group, override) => {
5391
- const particle = this._array[index];
5485
+ #removeParticle = (index, group, override) => {
5486
+ const particle = this.#array[index];
5392
5487
  if (!particle) {
5393
5488
  return false;
5394
5489
  }
5395
5490
  if (particle.group !== group) {
5396
5491
  return false;
5397
5492
  }
5398
- this._array.splice(index, deleteCount);
5399
- this._removeParticleFromBucket(particle);
5493
+ this.#array.splice(index, deleteCount);
5494
+ this.#removeParticleFromBucket(particle);
5400
5495
  particle.destroy(override);
5401
- this._container.dispatchEvent(exports.EventType.particleRemoved, {
5496
+ this.#container.dispatchEvent(exports.EventType.particleRemoved, {
5402
5497
  particle,
5403
5498
  });
5404
- this._addToPool(particle);
5499
+ this.#addToPool(particle);
5405
5500
  return true;
5406
5501
  };
5407
- _removeParticleFromBucket = (particle) => {
5408
- const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
5502
+ #removeParticleFromBucket = (particle) => {
5503
+ const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
5409
5504
  if (!bucket) {
5410
- this._particleBuckets.delete(particle.id);
5505
+ this.#particleBuckets.delete(particle.id);
5411
5506
  return;
5412
5507
  }
5413
- const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
5508
+ const particleIndex = this.#getParticleInsertIndex(bucket, particle.id);
5414
5509
  if (bucket[particleIndex]?.id !== particle.id) {
5415
- this._particleBuckets.delete(particle.id);
5510
+ this.#particleBuckets.delete(particle.id);
5416
5511
  return;
5417
5512
  }
5418
5513
  bucket.splice(particleIndex, deleteCount);
5419
- this._particleBuckets.delete(particle.id);
5514
+ this.#particleBuckets.delete(particle.id);
5420
5515
  };
5421
- _resetBuckets = (zLayers) => {
5516
+ #resetBuckets = (zLayers) => {
5422
5517
  const bucketCount = Math.max(Math.floor(zLayers), one);
5423
- if (this._zBuckets.length !== bucketCount) {
5424
- this._zBuckets = this._createBuckets(bucketCount);
5518
+ if (this.#zBuckets.length !== bucketCount) {
5519
+ this.#zBuckets = this.#createBuckets(bucketCount);
5425
5520
  return;
5426
5521
  }
5427
- for (const bucket of this._zBuckets) {
5522
+ for (const bucket of this.#zBuckets) {
5428
5523
  bucket.length = minIndex;
5429
5524
  }
5430
5525
  };
5431
- _updateParticleBucket = (particle) => {
5432
- const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
5526
+ #updateParticleBucket = (particle) => {
5527
+ const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
5433
5528
  if (currentBucketIndex === undefined) {
5434
- this._insertParticleIntoBucket(particle);
5529
+ this.#insertParticleIntoBucket(particle);
5435
5530
  return;
5436
5531
  }
5437
5532
  if (currentBucketIndex === newBucketIndex) {
5438
5533
  return;
5439
5534
  }
5440
- const currentBucket = this._zBuckets[currentBucketIndex];
5535
+ const currentBucket = this.#zBuckets[currentBucketIndex];
5441
5536
  if (currentBucket) {
5442
- const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
5537
+ const particleIndex = this.#getParticleInsertIndex(currentBucket, particle.id);
5443
5538
  if (currentBucket[particleIndex]?.id === particle.id) {
5444
5539
  currentBucket.splice(particleIndex, deleteCount);
5445
5540
  }
5446
5541
  }
5447
- const newBucket = this._zBuckets[newBucketIndex];
5542
+ const newBucket = this.#zBuckets[newBucketIndex];
5448
5543
  if (!newBucket) {
5449
- this._particleBuckets.set(particle.id, newBucketIndex);
5544
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5450
5545
  return;
5451
5546
  }
5452
- newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
5453
- this._particleBuckets.set(particle.id, newBucketIndex);
5547
+ newBucket.splice(this.#getParticleInsertIndex(newBucket, particle.id), empty, particle);
5548
+ this.#particleBuckets.set(particle.id, newBucketIndex);
5454
5549
  };
5455
- _updateParticlesPhase1 = (delta) => {
5456
- const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
5457
- for (const particle of this._array) {
5550
+ #updateParticlesPhase1 = (delta) => {
5551
+ const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
5552
+ for (const particle of this.#array) {
5458
5553
  if (resizeFactor && !particle.ignoresResizeRatio) {
5459
5554
  particle.position.x *= resizeFactor.width;
5460
5555
  particle.position.y *= resizeFactor.height;
@@ -5462,10 +5557,10 @@
5462
5557
  particle.initialPosition.y *= resizeFactor.height;
5463
5558
  }
5464
5559
  particle.ignoresResizeRatio = false;
5465
- for (const plugin of this._particleResetPlugins) {
5560
+ for (const plugin of this.#particleResetPlugins) {
5466
5561
  plugin.particleReset?.(particle);
5467
5562
  }
5468
- for (const plugin of this._particleUpdatePlugins) {
5563
+ for (const plugin of this.#particleUpdatePlugins) {
5469
5564
  if (particle.destroyed) {
5470
5565
  break;
5471
5566
  }
@@ -5479,36 +5574,36 @@
5479
5574
  }
5480
5575
  return particlesToDelete;
5481
5576
  };
5482
- _updateParticlesPhase2 = (delta, particlesToDelete) => {
5483
- for (const particle of this._array) {
5577
+ #updateParticlesPhase2 = (delta, particlesToDelete) => {
5578
+ for (const particle of this.#array) {
5484
5579
  if (particle.destroyed) {
5485
5580
  particlesToDelete.add(particle);
5486
5581
  continue;
5487
5582
  }
5488
- for (const updater of this._container.particleUpdaters) {
5583
+ for (const updater of this.#container.particleUpdaters) {
5489
5584
  updater.update(particle, delta);
5490
5585
  }
5491
5586
  if (!particle.spawning) {
5492
- for (const plugin of this._postParticleUpdatePlugins) {
5587
+ for (const plugin of this.#postParticleUpdatePlugins) {
5493
5588
  plugin.postParticleUpdate?.(particle, delta);
5494
5589
  }
5495
5590
  }
5496
- this._updateParticleBucket(particle);
5591
+ this.#updateParticleBucket(particle);
5497
5592
  }
5498
5593
  };
5499
5594
  }
5500
5595
 
5501
5596
  class Retina {
5502
- container;
5503
5597
  pixelRatio;
5504
5598
  reduceFactor;
5599
+ #container;
5505
5600
  constructor(container) {
5506
- this.container = container;
5601
+ this.#container = container;
5507
5602
  this.pixelRatio = defaultRatio;
5508
5603
  this.reduceFactor = defaultReduceFactor;
5509
5604
  }
5510
5605
  init() {
5511
- const container = this.container, options = container.actualOptions;
5606
+ const container = this.#container, options = container.actualOptions;
5512
5607
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
5513
5608
  this.reduceFactor = defaultReduceFactor;
5514
5609
  const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
@@ -5522,7 +5617,6 @@
5522
5617
  props.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
5523
5618
  props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
5524
5619
  props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
5525
- props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
5526
5620
  const maxDistance = props.maxDistance;
5527
5621
  maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
5528
5622
  maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
@@ -5560,73 +5654,73 @@
5560
5654
  shapeDrawers;
5561
5655
  started;
5562
5656
  zLayers;
5563
- _delay;
5564
- _delayTimeout;
5565
- _delta = { value: 0, factor: 0 };
5566
- _dispatchCallback;
5567
- _drawAnimationFrame;
5568
- _duration;
5569
- _eventListeners;
5570
- _firstStart;
5571
- _initialSourceOptions;
5572
- _lastFrameTime;
5573
- _lifeTime;
5574
- _onDestroy;
5575
- _options;
5576
- _paused;
5577
- _pluginManager;
5578
- _smooth;
5579
- _sourceOptions;
5657
+ #delay;
5658
+ #delayTimeout;
5659
+ #delta = { value: 0, factor: 0 };
5660
+ #dispatchCallback;
5661
+ #drawAnimationFrame;
5662
+ #duration;
5663
+ #eventListeners;
5664
+ #firstStart;
5665
+ #initialSourceOptions;
5666
+ #lastFrameTime;
5667
+ #lifeTime;
5668
+ #onDestroy;
5669
+ #options;
5670
+ #paused;
5671
+ #pluginManager;
5672
+ #smooth;
5673
+ #sourceOptions;
5580
5674
  constructor(params) {
5581
5675
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
5582
- this._pluginManager = pluginManager;
5583
- this._dispatchCallback = dispatchCallback;
5584
- this._onDestroy = onDestroy;
5676
+ this.#pluginManager = pluginManager;
5677
+ this.#dispatchCallback = dispatchCallback;
5678
+ this.#onDestroy = onDestroy;
5585
5679
  this.id = Symbol(id);
5586
5680
  this.fpsLimit = 120;
5587
5681
  this.hdr = false;
5588
- this._smooth = false;
5589
- this._delay = 0;
5590
- this._duration = 0;
5591
- this._lifeTime = 0;
5592
- this._firstStart = true;
5682
+ this.#smooth = false;
5683
+ this.#delay = 0;
5684
+ this.#duration = 0;
5685
+ this.#lifeTime = 0;
5686
+ this.#firstStart = true;
5593
5687
  this.started = false;
5594
5688
  this.destroyed = false;
5595
- this._paused = true;
5596
- this._lastFrameTime = 0;
5689
+ this.#paused = true;
5690
+ this.#lastFrameTime = 0;
5597
5691
  this.zLayers = 100;
5598
5692
  this.pageHidden = false;
5599
- this._sourceOptions = sourceOptions;
5600
- this._initialSourceOptions = sourceOptions;
5693
+ this.#sourceOptions = sourceOptions;
5694
+ this.#initialSourceOptions = sourceOptions;
5601
5695
  this.effectDrawers = new Map();
5602
5696
  this.shapeDrawers = new Map();
5603
5697
  this.particleUpdaters = [];
5604
5698
  this.retina = new Retina(this);
5605
- this.canvas = new CanvasManager(this._pluginManager, this);
5606
- this.particles = new ParticlesManager(this._pluginManager, this);
5699
+ this.canvas = new CanvasManager(this.#pluginManager, this);
5700
+ this.particles = new ParticlesManager(this.#pluginManager, this);
5607
5701
  this.plugins = [];
5608
5702
  this.particleDestroyedPlugins = [];
5609
5703
  this.particleCreatedPlugins = [];
5610
5704
  this.particlePositionPlugins = [];
5611
- this._options = loadContainerOptions(this._pluginManager, this);
5612
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
5613
- this._eventListeners = new EventListeners(this);
5705
+ this.#options = loadContainerOptions(this.#pluginManager, this);
5706
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
5707
+ this.#eventListeners = new EventListeners(this);
5614
5708
  this.dispatchEvent(exports.EventType.containerBuilt);
5615
5709
  }
5616
5710
  get animationStatus() {
5617
- return !this._paused && !this.pageHidden && guardCheck(this);
5711
+ return !this.#paused && !this.pageHidden && guardCheck(this);
5618
5712
  }
5619
5713
  get options() {
5620
- return this._options;
5714
+ return this.#options;
5621
5715
  }
5622
5716
  get sourceOptions() {
5623
- return this._sourceOptions;
5717
+ return this.#sourceOptions;
5624
5718
  }
5625
5719
  addLifeTime(value) {
5626
- this._lifeTime += value;
5720
+ this.#lifeTime += value;
5627
5721
  }
5628
5722
  alive() {
5629
- return !this._duration || this._lifeTime <= this._duration;
5723
+ return !this.#duration || this.#lifeTime <= this.#duration;
5630
5724
  }
5631
5725
  destroy(remove = true) {
5632
5726
  if (!guardCheck(this)) {
@@ -5648,13 +5742,13 @@
5648
5742
  this.shapeDrawers = new Map();
5649
5743
  this.particleUpdaters = [];
5650
5744
  this.plugins.length = 0;
5651
- this._pluginManager.clearPlugins(this);
5745
+ this.#pluginManager.clearPlugins(this);
5652
5746
  this.destroyed = true;
5653
- this._onDestroy(remove);
5747
+ this.#onDestroy(remove);
5654
5748
  this.dispatchEvent(exports.EventType.containerDestroyed);
5655
5749
  }
5656
5750
  dispatchEvent(type, data) {
5657
- this._dispatchCallback(type, {
5751
+ this.#dispatchCallback(type, {
5658
5752
  container: this,
5659
5753
  data,
5660
5754
  });
@@ -5664,12 +5758,12 @@
5664
5758
  return;
5665
5759
  }
5666
5760
  let refreshTime = force;
5667
- this._drawAnimationFrame = animate((timestamp) => {
5761
+ this.#drawAnimationFrame = animate((timestamp) => {
5668
5762
  if (refreshTime) {
5669
- this._lastFrameTime = undefined;
5763
+ this.#lastFrameTime = undefined;
5670
5764
  refreshTime = false;
5671
5765
  }
5672
- this._nextFrame(timestamp);
5766
+ this.#nextFrame(timestamp);
5673
5767
  });
5674
5768
  }
5675
5769
  async export(type, options = {}) {
@@ -5691,7 +5785,7 @@
5691
5785
  return;
5692
5786
  }
5693
5787
  const allContainerPlugins = new Map();
5694
- for (const plugin of this._pluginManager.plugins) {
5788
+ for (const plugin of this.#pluginManager.plugins) {
5695
5789
  const containerPlugin = await plugin.getPlugin(this);
5696
5790
  if (containerPlugin.preInit) {
5697
5791
  await containerPlugin.preInit();
@@ -5699,8 +5793,8 @@
5699
5793
  allContainerPlugins.set(plugin, containerPlugin);
5700
5794
  }
5701
5795
  await this.initDrawersAndUpdaters();
5702
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
5703
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
5796
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
5797
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
5704
5798
  this.plugins.length = 0;
5705
5799
  this.particleDestroyedPlugins.length = 0;
5706
5800
  this.particleCreatedPlugins.length = 0;
@@ -5727,11 +5821,11 @@
5727
5821
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
5728
5822
  this.hdr = hdr;
5729
5823
  this.zLayers = zLayers;
5730
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
5731
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
5732
- this._lifeTime = 0;
5824
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
5825
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
5826
+ this.#lifeTime = 0;
5733
5827
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
5734
- this._smooth = smooth;
5828
+ this.#smooth = smooth;
5735
5829
  for (const plugin of this.plugins) {
5736
5830
  await plugin.init?.();
5737
5831
  }
@@ -5744,7 +5838,7 @@
5744
5838
  this.dispatchEvent(exports.EventType.particlesSetup);
5745
5839
  }
5746
5840
  async initDrawersAndUpdaters() {
5747
- const pluginManager = this._pluginManager;
5841
+ const pluginManager = this.#pluginManager;
5748
5842
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
5749
5843
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
5750
5844
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -5753,18 +5847,18 @@
5753
5847
  if (!guardCheck(this)) {
5754
5848
  return;
5755
5849
  }
5756
- if (this._drawAnimationFrame !== undefined) {
5757
- cancelAnimation(this._drawAnimationFrame);
5758
- delete this._drawAnimationFrame;
5850
+ if (this.#drawAnimationFrame !== undefined) {
5851
+ cancelAnimation(this.#drawAnimationFrame);
5852
+ this.#drawAnimationFrame = undefined;
5759
5853
  }
5760
- if (this._paused) {
5854
+ if (this.#paused) {
5761
5855
  return;
5762
5856
  }
5763
5857
  for (const plugin of this.plugins) {
5764
5858
  plugin.pause?.();
5765
5859
  }
5766
5860
  if (!this.pageHidden) {
5767
- this._paused = true;
5861
+ this.#paused = true;
5768
5862
  }
5769
5863
  this.dispatchEvent(exports.EventType.containerPaused);
5770
5864
  }
@@ -5772,13 +5866,13 @@
5772
5866
  if (!guardCheck(this)) {
5773
5867
  return;
5774
5868
  }
5775
- const needsUpdate = this._paused || force;
5776
- if (this._firstStart && !this.actualOptions.autoPlay) {
5777
- this._firstStart = false;
5869
+ const needsUpdate = this.#paused || force;
5870
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
5871
+ this.#firstStart = false;
5778
5872
  return;
5779
5873
  }
5780
- if (this._paused) {
5781
- this._paused = false;
5874
+ if (this.#paused) {
5875
+ this.#paused = false;
5782
5876
  }
5783
5877
  if (needsUpdate) {
5784
5878
  for (const plugin of this.plugins) {
@@ -5801,10 +5895,10 @@
5801
5895
  if (!guardCheck(this)) {
5802
5896
  return;
5803
5897
  }
5804
- this._initialSourceOptions = sourceOptions;
5805
- this._sourceOptions = sourceOptions;
5806
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
5807
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
5898
+ this.#initialSourceOptions = sourceOptions;
5899
+ this.#sourceOptions = sourceOptions;
5900
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
5901
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
5808
5902
  return this.refresh();
5809
5903
  }
5810
5904
  async start() {
@@ -5815,7 +5909,7 @@
5815
5909
  this.started = true;
5816
5910
  await new Promise(resolve => {
5817
5911
  const start = async () => {
5818
- this._eventListeners.addListeners();
5912
+ this.#eventListeners.addListeners();
5819
5913
  for (const plugin of this.plugins) {
5820
5914
  await plugin.start?.();
5821
5915
  }
@@ -5823,20 +5917,20 @@
5823
5917
  this.play();
5824
5918
  resolve();
5825
5919
  };
5826
- this._delayTimeout = setTimeout(() => void start(), this._delay);
5920
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
5827
5921
  });
5828
5922
  }
5829
5923
  stop() {
5830
5924
  if (!guardCheck(this) || !this.started) {
5831
5925
  return;
5832
5926
  }
5833
- if (this._delayTimeout) {
5834
- clearTimeout(this._delayTimeout);
5835
- delete this._delayTimeout;
5927
+ if (this.#delayTimeout) {
5928
+ clearTimeout(this.#delayTimeout);
5929
+ this.#delayTimeout = undefined;
5836
5930
  }
5837
- this._firstStart = true;
5931
+ this.#firstStart = true;
5838
5932
  this.started = false;
5839
- this._eventListeners.removeListeners();
5933
+ this.#eventListeners.removeListeners();
5840
5934
  this.pause();
5841
5935
  this.particles.clear();
5842
5936
  this.canvas.stop();
@@ -5846,7 +5940,7 @@
5846
5940
  this.particleCreatedPlugins.length = 0;
5847
5941
  this.particleDestroyedPlugins.length = 0;
5848
5942
  this.particlePositionPlugins.length = 0;
5849
- this._sourceOptions = this._options;
5943
+ this.#sourceOptions = this.#options;
5850
5944
  this.dispatchEvent(exports.EventType.containerStopped);
5851
5945
  }
5852
5946
  updateActualOptions() {
@@ -5858,23 +5952,23 @@
5858
5952
  }
5859
5953
  return refresh;
5860
5954
  }
5861
- _nextFrame = (timestamp) => {
5955
+ #nextFrame = (timestamp) => {
5862
5956
  try {
5863
- if (!this._smooth &&
5864
- this._lastFrameTime !== undefined &&
5865
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
5957
+ if (!this.#smooth &&
5958
+ this.#lastFrameTime !== undefined &&
5959
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
5866
5960
  this.draw(false);
5867
5961
  return;
5868
5962
  }
5869
- this._lastFrameTime ??= timestamp;
5870
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
5871
- this.addLifeTime(this._delta.value);
5872
- this._lastFrameTime = timestamp;
5873
- if (this._delta.value > millisecondsToSeconds) {
5963
+ this.#lastFrameTime ??= timestamp;
5964
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
5965
+ this.addLifeTime(this.#delta.value);
5966
+ this.#lastFrameTime = timestamp;
5967
+ if (this.#delta.value > millisecondsToSeconds) {
5874
5968
  this.draw(false);
5875
5969
  return;
5876
5970
  }
5877
- this.canvas.render.drawParticles(this._delta);
5971
+ this.canvas.render.drawParticles(this.#delta);
5878
5972
  if (!this.alive()) {
5879
5973
  this.destroy();
5880
5974
  return;
@@ -5895,10 +5989,10 @@
5895
5989
  });
5896
5990
 
5897
5991
  class BlendPluginInstance {
5898
- _container;
5899
- _defaultCompositeValue;
5992
+ #container;
5993
+ #defaultCompositeValue;
5900
5994
  constructor(container) {
5901
- this._container = container;
5995
+ this.#container = container;
5902
5996
  }
5903
5997
  drawParticleCleanup(context, particle) {
5904
5998
  if (!particle.options.blend?.enable) {
@@ -5915,14 +6009,14 @@
5915
6009
  context.globalCompositeOperation = particle.options.blend.mode;
5916
6010
  }
5917
6011
  drawSettingsCleanup(context) {
5918
- if (!this._defaultCompositeValue) {
6012
+ if (!this.#defaultCompositeValue) {
5919
6013
  return;
5920
6014
  }
5921
- context.globalCompositeOperation = this._defaultCompositeValue;
6015
+ context.globalCompositeOperation = this.#defaultCompositeValue;
5922
6016
  }
5923
6017
  drawSettingsSetup(context) {
5924
- const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
5925
- this._defaultCompositeValue = previousComposite;
6018
+ const previousComposite = context.globalCompositeOperation, blend = this.#container.actualOptions.blend;
6019
+ this.#defaultCompositeValue = previousComposite;
5926
6020
  context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
5927
6021
  }
5928
6022
  }
@@ -6065,11 +6159,11 @@
6065
6159
  class MovePluginInstance {
6066
6160
  availablePathGenerators;
6067
6161
  pathGenerators;
6068
- _container;
6069
- _pluginManager;
6162
+ #container;
6163
+ #pluginManager;
6070
6164
  constructor(pluginManager, container) {
6071
- this._pluginManager = pluginManager;
6072
- this._container = container;
6165
+ this.#pluginManager = pluginManager;
6166
+ this.#container = container;
6073
6167
  this.availablePathGenerators = new Map();
6074
6168
  this.pathGenerators = new Map();
6075
6169
  }
@@ -6100,7 +6194,7 @@
6100
6194
  acceleration: getRangeValue(gravityOptions.acceleration),
6101
6195
  inverse: gravityOptions.inverse,
6102
6196
  };
6103
- initSpin(this._container, particle);
6197
+ initSpin(this.#container, particle);
6104
6198
  }
6105
6199
  particleDestroyed(particle) {
6106
6200
  const pathGenerator = particle.pathGenerator;
@@ -6111,7 +6205,7 @@
6111
6205
  if (!moveOptions.enable) {
6112
6206
  return;
6113
6207
  }
6114
- const container = this._container, pxRatio = container.retina.pixelRatio, slowFactor = getProximitySpeedFactor(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = getRangeMax(particleOptions.size.value) * pxRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = baseSpeed * sizeFactor * slowFactor * deltaFactor * half, maxSpeed = particle.retina.maxSpeed;
6208
+ const container = this.#container, slowFactor = getProximitySpeedFactor(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = particle.size.max, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = baseSpeed * sizeFactor * slowFactor * deltaFactor * half, maxSpeed = particle.retina.maxSpeed;
6115
6209
  if (moveOptions.spin.enable) {
6116
6210
  spin(container, particle, moveSpeed, reduceFactor);
6117
6211
  }
@@ -6121,18 +6215,18 @@
6121
6215
  applyDistance(particle);
6122
6216
  }
6123
6217
  preInit() {
6124
- return this._init();
6218
+ return this.#init();
6125
6219
  }
6126
6220
  redrawInit() {
6127
- return this._init();
6221
+ return this.#init();
6128
6222
  }
6129
6223
  update() {
6130
6224
  for (const pathGenerator of this.pathGenerators.values()) {
6131
6225
  pathGenerator.update();
6132
6226
  }
6133
6227
  }
6134
- async _init() {
6135
- const availablePathGenerators = await this._pluginManager.getPathGenerators?.(this._container, true);
6228
+ async #init() {
6229
+ const availablePathGenerators = await this.#pluginManager.getPathGenerators?.(this.#container, true);
6136
6230
  if (!availablePathGenerators) {
6137
6231
  return;
6138
6232
  }
@@ -6164,8 +6258,6 @@
6164
6258
  exports.MoveCenter = MoveCenter;
6165
6259
  exports.MoveGravity = MoveGravity;
6166
6260
  exports.MovePath = MovePath;
6167
- exports.Opacity = Opacity;
6168
- exports.OpacityAnimation = OpacityAnimation;
6169
6261
  exports.Options = Options;
6170
6262
  exports.OptionsColor = OptionsColor;
6171
6263
  exports.OutModes = OutModes;
@@ -6181,8 +6273,6 @@
6181
6273
  exports.Rectangle = Rectangle;
6182
6274
  exports.ResizeEvent = ResizeEvent;
6183
6275
  exports.Shape = Shape;
6184
- exports.Size = Size;
6185
- exports.SizeAnimation = SizeAnimation;
6186
6276
  exports.Spin = Spin;
6187
6277
  exports.Stroke = Stroke;
6188
6278
  exports.ValueWithRandom = ValueWithRandom;