@tsparticles/preset-matrix 4.0.1 → 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
- /* Preset v4.0.1 */
2
+ /* Preset 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) :
@@ -996,7 +996,7 @@
996
996
  return this._domArray;
997
997
  }
998
998
  get version() {
999
- return "4.0.1";
999
+ return "4.0.3";
1000
1000
  }
1001
1001
  addEventListener(type, listener) {
1002
1002
  this._eventDispatcher.addEventListener(type, listener);
@@ -2823,6 +2823,58 @@
2823
2823
 
2824
2824
  const tsParticles = initEngine();
2825
2825
 
2826
+ class Blend {
2827
+ enable;
2828
+ mode;
2829
+ constructor() {
2830
+ this.mode = "destination-out";
2831
+ this.enable = false;
2832
+ }
2833
+ load(data) {
2834
+ if (isNull(data)) {
2835
+ return;
2836
+ }
2837
+ if (data.mode !== undefined) {
2838
+ this.mode = data.mode;
2839
+ }
2840
+ if (data.enable !== undefined) {
2841
+ this.enable = data.enable;
2842
+ }
2843
+ }
2844
+ }
2845
+
2846
+ class BlendPlugin {
2847
+ id = "blend";
2848
+ async getPlugin(container) {
2849
+ const { BlendPluginInstance } = await Promise.resolve().then(function () { return BlendPluginInstance$1; });
2850
+ return new BlendPluginInstance(container);
2851
+ }
2852
+ loadOptions(_container, options, source) {
2853
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
2854
+ return;
2855
+ }
2856
+ let blendOptions = options.blend;
2857
+ if (!blendOptions?.load) {
2858
+ options.blend = blendOptions = new Blend();
2859
+ }
2860
+ blendOptions.load(source?.blend);
2861
+ }
2862
+ loadParticlesOptions(_container, options, source) {
2863
+ options.blend ??= new Blend();
2864
+ options.blend.load(source?.blend);
2865
+ }
2866
+ needsPlugin(options) {
2867
+ return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
2868
+ }
2869
+ }
2870
+
2871
+ async function loadBlendPlugin(engine) {
2872
+ engine.checkVersion("4.0.3");
2873
+ await engine.pluginManager.register(e => {
2874
+ e.pluginManager.addPlugin(new BlendPlugin());
2875
+ });
2876
+ }
2877
+
2826
2878
  const minAngle$1 = 0;
2827
2879
  function drawCircle(data) {
2828
2880
  const { context, particle, radius } = data;
@@ -2854,7 +2906,7 @@
2854
2906
  }
2855
2907
 
2856
2908
  async function loadCircleShape(engine) {
2857
- engine.checkVersion("4.0.1");
2909
+ engine.checkVersion("4.0.3");
2858
2910
  await engine.pluginManager.register(e => {
2859
2911
  e.pluginManager.addShape(["circle"], () => {
2860
2912
  return Promise.resolve(new CircleDrawer());
@@ -2902,7 +2954,7 @@
2902
2954
  }
2903
2955
 
2904
2956
  async function loadHexColorPlugin(engine) {
2905
- engine.checkVersion("4.0.1");
2957
+ engine.checkVersion("4.0.3");
2906
2958
  await engine.pluginManager.register(e => {
2907
2959
  e.pluginManager.addColorManager("hex", new HexColorManager());
2908
2960
  });
@@ -2955,7 +3007,7 @@
2955
3007
  }
2956
3008
 
2957
3009
  async function loadHslColorPlugin(engine) {
2958
- engine.checkVersion("4.0.1");
3010
+ engine.checkVersion("4.0.3");
2959
3011
  await engine.pluginManager.register(e => {
2960
3012
  e.pluginManager.addColorManager("hsl", new HslColorManager());
2961
3013
  });
@@ -2979,7 +3031,7 @@
2979
3031
  }
2980
3032
 
2981
3033
  async function loadMovePlugin(engine) {
2982
- engine.checkVersion("4.0.1");
3034
+ engine.checkVersion("4.0.3");
2983
3035
  await engine.pluginManager.register(e => {
2984
3036
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
2985
3037
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3040,7 +3092,7 @@
3040
3092
  }
3041
3093
 
3042
3094
  async function loadOpacityUpdater(engine) {
3043
- engine.checkVersion("4.0.1");
3095
+ engine.checkVersion("4.0.3");
3044
3096
  await engine.pluginManager.register(e => {
3045
3097
  e.pluginManager.addParticleUpdater("opacity", container => {
3046
3098
  return Promise.resolve(new OpacityUpdater(container));
@@ -3392,7 +3444,7 @@
3392
3444
  }
3393
3445
 
3394
3446
  async function loadOutModesUpdater(engine) {
3395
- engine.checkVersion("4.0.1");
3447
+ engine.checkVersion("4.0.3");
3396
3448
  await engine.pluginManager.register(e => {
3397
3449
  e.pluginManager.addParticleUpdater("outModes", container => {
3398
3450
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3463,7 +3515,7 @@
3463
3515
  }
3464
3516
 
3465
3517
  async function loadPaintUpdater(engine) {
3466
- engine.checkVersion("4.0.1");
3518
+ engine.checkVersion("4.0.3");
3467
3519
  await engine.pluginManager.register(e => {
3468
3520
  e.pluginManager.addParticleUpdater("paint", container => {
3469
3521
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3518,7 +3570,7 @@
3518
3570
  }
3519
3571
 
3520
3572
  async function loadRgbColorPlugin(engine) {
3521
- engine.checkVersion("4.0.1");
3573
+ engine.checkVersion("4.0.3");
3522
3574
  await engine.pluginManager.register(e => {
3523
3575
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3524
3576
  });
@@ -3561,7 +3613,7 @@
3561
3613
  }
3562
3614
 
3563
3615
  async function loadSizeUpdater(engine) {
3564
- engine.checkVersion("4.0.1");
3616
+ engine.checkVersion("4.0.3");
3565
3617
  await engine.pluginManager.register(e => {
3566
3618
  e.pluginManager.addParticleUpdater("size", container => {
3567
3619
  return Promise.resolve(new SizeUpdater(container));
@@ -3570,9 +3622,10 @@
3570
3622
  }
3571
3623
 
3572
3624
  async function loadBasic(engine) {
3573
- engine.checkVersion("4.0.1");
3625
+ engine.checkVersion("4.0.3");
3574
3626
  await engine.pluginManager.register(async (e) => {
3575
3627
  await Promise.all([
3628
+ loadBlendPlugin(e),
3576
3629
  loadHexColorPlugin(e),
3577
3630
  loadHslColorPlugin(e),
3578
3631
  loadRgbColorPlugin(e),
@@ -3801,7 +3854,7 @@
3801
3854
  }
3802
3855
 
3803
3856
  async function loadMatrixShape(engine) {
3804
- engine.checkVersion("4.0.1");
3857
+ engine.checkVersion("4.0.3");
3805
3858
  await engine.pluginManager.register(e => {
3806
3859
  e.pluginManager.addShape(["matrix"], () => Promise.resolve(new MatrixDrawer()));
3807
3860
  });
@@ -3861,7 +3914,7 @@
3861
3914
  }
3862
3915
 
3863
3916
  async function loadPoissonDiscPlugin(engine) {
3864
- engine.checkVersion("4.0.1");
3917
+ engine.checkVersion("4.0.3");
3865
3918
  await engine.pluginManager.register(e => {
3866
3919
  e.pluginManager.addPlugin(new PoissonDiscPlugin());
3867
3920
  });
@@ -3899,7 +3952,7 @@
3899
3952
  }
3900
3953
 
3901
3954
  async function loadShadowEffect(engine) {
3902
- engine.checkVersion("4.0.1");
3955
+ engine.checkVersion("4.0.3");
3903
3956
  await engine.pluginManager.register(e => {
3904
3957
  e.pluginManager.addEffect("shadow", container => {
3905
3958
  return Promise.resolve(new ShadowDrawer(e.pluginManager, container));
@@ -3974,7 +4027,7 @@
3974
4027
  }
3975
4028
 
3976
4029
  async function loadTrailPlugin(engine) {
3977
- engine.checkVersion("4.0.1");
4030
+ engine.checkVersion("4.0.3");
3978
4031
  await engine.pluginManager.register(e => {
3979
4032
  e.pluginManager.addPlugin(new TrailPlugin(e.pluginManager));
3980
4033
  });
@@ -6141,6 +6194,44 @@
6141
6194
  Container: Container
6142
6195
  });
6143
6196
 
6197
+ class BlendPluginInstance {
6198
+ _container;
6199
+ _defaultCompositeValue;
6200
+ constructor(container) {
6201
+ this._container = container;
6202
+ }
6203
+ drawParticleCleanup(context, particle) {
6204
+ if (!particle.options.blend?.enable) {
6205
+ return;
6206
+ }
6207
+ context.globalCompositeOperation = particle.originalBlendMode ?? defaultCompositeValue;
6208
+ particle.originalBlendMode = undefined;
6209
+ }
6210
+ drawParticleSetup(context, particle) {
6211
+ if (!particle.options.blend?.enable) {
6212
+ return;
6213
+ }
6214
+ particle.originalBlendMode = context.globalCompositeOperation;
6215
+ context.globalCompositeOperation = particle.options.blend.mode;
6216
+ }
6217
+ drawSettingsCleanup(context) {
6218
+ if (!this._defaultCompositeValue) {
6219
+ return;
6220
+ }
6221
+ context.globalCompositeOperation = this._defaultCompositeValue;
6222
+ }
6223
+ drawSettingsSetup(context) {
6224
+ const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
6225
+ this._defaultCompositeValue = previousComposite;
6226
+ context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
6227
+ }
6228
+ }
6229
+
6230
+ var BlendPluginInstance$1 = /*#__PURE__*/Object.freeze({
6231
+ __proto__: null,
6232
+ BlendPluginInstance: BlendPluginInstance
6233
+ });
6234
+
6144
6235
  const minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
6145
6236
  function applyDistance(particle) {
6146
6237
  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;