@tsparticles/preset-triangles 4.0.2 → 4.0.4

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.2 */
2
+ /* Preset v4.0.4 */
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) :
@@ -1005,7 +1005,7 @@
1005
1005
  return this._domArray;
1006
1006
  }
1007
1007
  get version() {
1008
- return "4.0.2";
1008
+ return "4.0.4";
1009
1009
  }
1010
1010
  addEventListener(type, listener) {
1011
1011
  this._eventDispatcher.addEventListener(type, listener);
@@ -2889,6 +2889,58 @@
2889
2889
 
2890
2890
  const tsParticles = initEngine();
2891
2891
 
2892
+ class Blend {
2893
+ enable;
2894
+ mode;
2895
+ constructor() {
2896
+ this.mode = "destination-out";
2897
+ this.enable = false;
2898
+ }
2899
+ load(data) {
2900
+ if (isNull(data)) {
2901
+ return;
2902
+ }
2903
+ if (data.mode !== undefined) {
2904
+ this.mode = data.mode;
2905
+ }
2906
+ if (data.enable !== undefined) {
2907
+ this.enable = data.enable;
2908
+ }
2909
+ }
2910
+ }
2911
+
2912
+ class BlendPlugin {
2913
+ id = "blend";
2914
+ async getPlugin(container) {
2915
+ const { BlendPluginInstance } = await Promise.resolve().then(function () { return BlendPluginInstance$1; });
2916
+ return new BlendPluginInstance(container);
2917
+ }
2918
+ loadOptions(_container, options, source) {
2919
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
2920
+ return;
2921
+ }
2922
+ let blendOptions = options.blend;
2923
+ if (!blendOptions?.load) {
2924
+ options.blend = blendOptions = new Blend();
2925
+ }
2926
+ blendOptions.load(source?.blend);
2927
+ }
2928
+ loadParticlesOptions(_container, options, source) {
2929
+ options.blend ??= new Blend();
2930
+ options.blend.load(source?.blend);
2931
+ }
2932
+ needsPlugin(options) {
2933
+ return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
2934
+ }
2935
+ }
2936
+
2937
+ async function loadBlendPlugin(engine) {
2938
+ engine.checkVersion("4.0.4");
2939
+ await engine.pluginManager.register(e => {
2940
+ e.pluginManager.addPlugin(new BlendPlugin());
2941
+ });
2942
+ }
2943
+
2892
2944
  const minAngle$1 = 0;
2893
2945
  function drawCircle(data) {
2894
2946
  const { context, particle, radius } = data;
@@ -2920,7 +2972,7 @@
2920
2972
  }
2921
2973
 
2922
2974
  async function loadCircleShape(engine) {
2923
- engine.checkVersion("4.0.2");
2975
+ engine.checkVersion("4.0.4");
2924
2976
  await engine.pluginManager.register(e => {
2925
2977
  e.pluginManager.addShape(["circle"], () => {
2926
2978
  return Promise.resolve(new CircleDrawer());
@@ -2968,7 +3020,7 @@
2968
3020
  }
2969
3021
 
2970
3022
  async function loadHexColorPlugin(engine) {
2971
- engine.checkVersion("4.0.2");
3023
+ engine.checkVersion("4.0.4");
2972
3024
  await engine.pluginManager.register(e => {
2973
3025
  e.pluginManager.addColorManager("hex", new HexColorManager());
2974
3026
  });
@@ -3021,7 +3073,7 @@
3021
3073
  }
3022
3074
 
3023
3075
  async function loadHslColorPlugin(engine) {
3024
- engine.checkVersion("4.0.2");
3076
+ engine.checkVersion("4.0.4");
3025
3077
  await engine.pluginManager.register(e => {
3026
3078
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3027
3079
  });
@@ -3045,7 +3097,7 @@
3045
3097
  }
3046
3098
 
3047
3099
  async function loadMovePlugin(engine) {
3048
- engine.checkVersion("4.0.2");
3100
+ engine.checkVersion("4.0.4");
3049
3101
  await engine.pluginManager.register(e => {
3050
3102
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3051
3103
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3106,7 +3158,7 @@
3106
3158
  }
3107
3159
 
3108
3160
  async function loadOpacityUpdater(engine) {
3109
- engine.checkVersion("4.0.2");
3161
+ engine.checkVersion("4.0.4");
3110
3162
  await engine.pluginManager.register(e => {
3111
3163
  e.pluginManager.addParticleUpdater("opacity", container => {
3112
3164
  return Promise.resolve(new OpacityUpdater(container));
@@ -3458,7 +3510,7 @@
3458
3510
  }
3459
3511
 
3460
3512
  async function loadOutModesUpdater(engine) {
3461
- engine.checkVersion("4.0.2");
3513
+ engine.checkVersion("4.0.4");
3462
3514
  await engine.pluginManager.register(e => {
3463
3515
  e.pluginManager.addParticleUpdater("outModes", container => {
3464
3516
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3529,7 +3581,7 @@
3529
3581
  }
3530
3582
 
3531
3583
  async function loadPaintUpdater(engine) {
3532
- engine.checkVersion("4.0.2");
3584
+ engine.checkVersion("4.0.4");
3533
3585
  await engine.pluginManager.register(e => {
3534
3586
  e.pluginManager.addParticleUpdater("paint", container => {
3535
3587
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3584,7 +3636,7 @@
3584
3636
  }
3585
3637
 
3586
3638
  async function loadRgbColorPlugin(engine) {
3587
- engine.checkVersion("4.0.2");
3639
+ engine.checkVersion("4.0.4");
3588
3640
  await engine.pluginManager.register(e => {
3589
3641
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3590
3642
  });
@@ -3627,7 +3679,7 @@
3627
3679
  }
3628
3680
 
3629
3681
  async function loadSizeUpdater(engine) {
3630
- engine.checkVersion("4.0.2");
3682
+ engine.checkVersion("4.0.4");
3631
3683
  await engine.pluginManager.register(e => {
3632
3684
  e.pluginManager.addParticleUpdater("size", container => {
3633
3685
  return Promise.resolve(new SizeUpdater(container));
@@ -3636,9 +3688,10 @@
3636
3688
  }
3637
3689
 
3638
3690
  async function loadBasic(engine) {
3639
- engine.checkVersion("4.0.2");
3691
+ engine.checkVersion("4.0.4");
3640
3692
  await engine.pluginManager.register(async (e) => {
3641
3693
  await Promise.all([
3694
+ loadBlendPlugin(e),
3642
3695
  loadHexColorPlugin(e),
3643
3696
  loadHslColorPlugin(e),
3644
3697
  loadRgbColorPlugin(e),
@@ -3873,7 +3926,7 @@
3873
3926
  const clickEvent = "click", mouseDownEvent = "pointerdown", mouseUpEvent = "pointerup", mouseLeaveEvent = "pointerleave", mouseMoveEvent = "pointermove", touchStartEvent = "touchstart", touchEndEvent = "touchend", touchMoveEvent = "touchmove", touchCancelEvent = "touchcancel";
3874
3927
 
3875
3928
  async function loadInteractivityPlugin(engine) {
3876
- engine.checkVersion("4.0.2");
3929
+ engine.checkVersion("4.0.4");
3877
3930
  await engine.pluginManager.register(e => {
3878
3931
  const interactivityEngine = e, interactivityPluginManager = interactivityEngine.pluginManager;
3879
3932
  interactivityPluginManager.addPlugin(new InteractivityPlugin(interactivityPluginManager));
@@ -4199,7 +4252,7 @@
4199
4252
  }
4200
4253
 
4201
4254
  async function loadParticlesLinksInteraction(engine) {
4202
- engine.checkVersion("4.0.2");
4255
+ engine.checkVersion("4.0.4");
4203
4256
  await engine.pluginManager.register((e) => {
4204
4257
  const pluginManager = e.pluginManager;
4205
4258
  ensureInteractivityPluginLoaded(e);
@@ -6330,6 +6383,44 @@
6330
6383
  Container: Container
6331
6384
  });
6332
6385
 
6386
+ class BlendPluginInstance {
6387
+ _container;
6388
+ _defaultCompositeValue;
6389
+ constructor(container) {
6390
+ this._container = container;
6391
+ }
6392
+ drawParticleCleanup(context, particle) {
6393
+ if (!particle.options.blend?.enable) {
6394
+ return;
6395
+ }
6396
+ context.globalCompositeOperation = particle.originalBlendMode ?? defaultCompositeValue;
6397
+ particle.originalBlendMode = undefined;
6398
+ }
6399
+ drawParticleSetup(context, particle) {
6400
+ if (!particle.options.blend?.enable) {
6401
+ return;
6402
+ }
6403
+ particle.originalBlendMode = context.globalCompositeOperation;
6404
+ context.globalCompositeOperation = particle.options.blend.mode;
6405
+ }
6406
+ drawSettingsCleanup(context) {
6407
+ if (!this._defaultCompositeValue) {
6408
+ return;
6409
+ }
6410
+ context.globalCompositeOperation = this._defaultCompositeValue;
6411
+ }
6412
+ drawSettingsSetup(context) {
6413
+ const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
6414
+ this._defaultCompositeValue = previousComposite;
6415
+ context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
6416
+ }
6417
+ }
6418
+
6419
+ var BlendPluginInstance$1 = /*#__PURE__*/Object.freeze({
6420
+ __proto__: null,
6421
+ BlendPluginInstance: BlendPluginInstance
6422
+ });
6423
+
6333
6424
  const minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
6334
6425
  function applyDistance(particle) {
6335
6426
  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;