@tsparticles/basic 4.0.2 → 4.0.3

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.2 */
2
+ /* tsParticles v4.0.3 */
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) :
@@ -1118,7 +1118,7 @@
1118
1118
  return this._domArray;
1119
1119
  }
1120
1120
  get version() {
1121
- return "4.0.2";
1121
+ return "4.0.3";
1122
1122
  }
1123
1123
  addEventListener(type, listener) {
1124
1124
  this._eventDispatcher.addEventListener(type, listener);
@@ -3009,6 +3009,58 @@
3009
3009
 
3010
3010
  const tsParticles = initEngine();
3011
3011
 
3012
+ class Blend {
3013
+ enable;
3014
+ mode;
3015
+ constructor() {
3016
+ this.mode = "destination-out";
3017
+ this.enable = false;
3018
+ }
3019
+ load(data) {
3020
+ if (isNull(data)) {
3021
+ return;
3022
+ }
3023
+ if (data.mode !== undefined) {
3024
+ this.mode = data.mode;
3025
+ }
3026
+ if (data.enable !== undefined) {
3027
+ this.enable = data.enable;
3028
+ }
3029
+ }
3030
+ }
3031
+
3032
+ class BlendPlugin {
3033
+ id = "blend";
3034
+ async getPlugin(container) {
3035
+ const { BlendPluginInstance } = await Promise.resolve().then(function () { return BlendPluginInstance$1; });
3036
+ return new BlendPluginInstance(container);
3037
+ }
3038
+ loadOptions(_container, options, source) {
3039
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
3040
+ return;
3041
+ }
3042
+ let blendOptions = options.blend;
3043
+ if (!blendOptions?.load) {
3044
+ options.blend = blendOptions = new Blend();
3045
+ }
3046
+ blendOptions.load(source?.blend);
3047
+ }
3048
+ loadParticlesOptions(_container, options, source) {
3049
+ options.blend ??= new Blend();
3050
+ options.blend.load(source?.blend);
3051
+ }
3052
+ needsPlugin(options) {
3053
+ return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
3054
+ }
3055
+ }
3056
+
3057
+ async function loadBlendPlugin(engine) {
3058
+ engine.checkVersion("4.0.3");
3059
+ await engine.pluginManager.register(e => {
3060
+ e.pluginManager.addPlugin(new BlendPlugin());
3061
+ });
3062
+ }
3063
+
3012
3064
  const minAngle$1 = 0;
3013
3065
  function drawCircle(data) {
3014
3066
  const { context, particle, radius } = data;
@@ -3040,7 +3092,7 @@
3040
3092
  }
3041
3093
 
3042
3094
  async function loadCircleShape(engine) {
3043
- engine.checkVersion("4.0.2");
3095
+ engine.checkVersion("4.0.3");
3044
3096
  await engine.pluginManager.register(e => {
3045
3097
  e.pluginManager.addShape(["circle"], () => {
3046
3098
  return Promise.resolve(new CircleDrawer());
@@ -3088,7 +3140,7 @@
3088
3140
  }
3089
3141
 
3090
3142
  async function loadHexColorPlugin(engine) {
3091
- engine.checkVersion("4.0.2");
3143
+ engine.checkVersion("4.0.3");
3092
3144
  await engine.pluginManager.register(e => {
3093
3145
  e.pluginManager.addColorManager("hex", new HexColorManager());
3094
3146
  });
@@ -3141,7 +3193,7 @@
3141
3193
  }
3142
3194
 
3143
3195
  async function loadHslColorPlugin(engine) {
3144
- engine.checkVersion("4.0.2");
3196
+ engine.checkVersion("4.0.3");
3145
3197
  await engine.pluginManager.register(e => {
3146
3198
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3147
3199
  });
@@ -3165,7 +3217,7 @@
3165
3217
  }
3166
3218
 
3167
3219
  async function loadMovePlugin(engine) {
3168
- engine.checkVersion("4.0.2");
3220
+ engine.checkVersion("4.0.3");
3169
3221
  await engine.pluginManager.register(e => {
3170
3222
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3171
3223
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3226,7 +3278,7 @@
3226
3278
  }
3227
3279
 
3228
3280
  async function loadOpacityUpdater(engine) {
3229
- engine.checkVersion("4.0.2");
3281
+ engine.checkVersion("4.0.3");
3230
3282
  await engine.pluginManager.register(e => {
3231
3283
  e.pluginManager.addParticleUpdater("opacity", container => {
3232
3284
  return Promise.resolve(new OpacityUpdater(container));
@@ -3578,7 +3630,7 @@
3578
3630
  }
3579
3631
 
3580
3632
  async function loadOutModesUpdater(engine) {
3581
- engine.checkVersion("4.0.2");
3633
+ engine.checkVersion("4.0.3");
3582
3634
  await engine.pluginManager.register(e => {
3583
3635
  e.pluginManager.addParticleUpdater("outModes", container => {
3584
3636
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3649,7 +3701,7 @@
3649
3701
  }
3650
3702
 
3651
3703
  async function loadPaintUpdater(engine) {
3652
- engine.checkVersion("4.0.2");
3704
+ engine.checkVersion("4.0.3");
3653
3705
  await engine.pluginManager.register(e => {
3654
3706
  e.pluginManager.addParticleUpdater("paint", container => {
3655
3707
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3704,7 +3756,7 @@
3704
3756
  }
3705
3757
 
3706
3758
  async function loadRgbColorPlugin(engine) {
3707
- engine.checkVersion("4.0.2");
3759
+ engine.checkVersion("4.0.3");
3708
3760
  await engine.pluginManager.register(e => {
3709
3761
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3710
3762
  });
@@ -3747,7 +3799,7 @@
3747
3799
  }
3748
3800
 
3749
3801
  async function loadSizeUpdater(engine) {
3750
- engine.checkVersion("4.0.2");
3802
+ engine.checkVersion("4.0.3");
3751
3803
  await engine.pluginManager.register(e => {
3752
3804
  e.pluginManager.addParticleUpdater("size", container => {
3753
3805
  return Promise.resolve(new SizeUpdater(container));
@@ -3756,9 +3808,10 @@
3756
3808
  }
3757
3809
 
3758
3810
  async function loadBasic(engine) {
3759
- engine.checkVersion("4.0.2");
3811
+ engine.checkVersion("4.0.3");
3760
3812
  await engine.pluginManager.register(async (e) => {
3761
3813
  await Promise.all([
3814
+ loadBlendPlugin(e),
3762
3815
  loadHexColorPlugin(e),
3763
3816
  loadHslColorPlugin(e),
3764
3817
  loadRgbColorPlugin(e),
@@ -5841,6 +5894,44 @@
5841
5894
  Container: Container
5842
5895
  });
5843
5896
 
5897
+ class BlendPluginInstance {
5898
+ _container;
5899
+ _defaultCompositeValue;
5900
+ constructor(container) {
5901
+ this._container = container;
5902
+ }
5903
+ drawParticleCleanup(context, particle) {
5904
+ if (!particle.options.blend?.enable) {
5905
+ return;
5906
+ }
5907
+ context.globalCompositeOperation = particle.originalBlendMode ?? defaultCompositeValue;
5908
+ particle.originalBlendMode = undefined;
5909
+ }
5910
+ drawParticleSetup(context, particle) {
5911
+ if (!particle.options.blend?.enable) {
5912
+ return;
5913
+ }
5914
+ particle.originalBlendMode = context.globalCompositeOperation;
5915
+ context.globalCompositeOperation = particle.options.blend.mode;
5916
+ }
5917
+ drawSettingsCleanup(context) {
5918
+ if (!this._defaultCompositeValue) {
5919
+ return;
5920
+ }
5921
+ context.globalCompositeOperation = this._defaultCompositeValue;
5922
+ }
5923
+ drawSettingsSetup(context) {
5924
+ const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
5925
+ this._defaultCompositeValue = previousComposite;
5926
+ context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
5927
+ }
5928
+ }
5929
+
5930
+ var BlendPluginInstance$1 = /*#__PURE__*/Object.freeze({
5931
+ __proto__: null,
5932
+ BlendPluginInstance: BlendPluginInstance
5933
+ });
5934
+
5844
5935
  const minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
5845
5936
  function applyDistance(particle) {
5846
5937
  const initialPosition = particle.initialPosition, { dx, dy } = getDistances(initialPosition, particle.position), dxFixed = Math.abs(dx), dyFixed = Math.abs(dy), { maxDistance } = particle.retina, hDistance = maxDistance.horizontal, vDistance = maxDistance.vertical;