@tsparticles/interaction-particles-links 3.0.0-alpha.1 → 3.0.0-beta.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.
Files changed (75) hide show
  1. package/README.md +25 -19
  2. package/browser/CircleWarp.js +7 -23
  3. package/browser/LinkInstance.js +121 -114
  4. package/browser/Linker.js +37 -54
  5. package/browser/Options/Classes/Links.js +1 -1
  6. package/browser/Utils.js +24 -8
  7. package/browser/index.js +5 -5
  8. package/browser/interaction.js +2 -2
  9. package/browser/plugin.js +2 -2
  10. package/cjs/CircleWarp.js +7 -23
  11. package/cjs/LinkInstance.js +123 -127
  12. package/cjs/Linker.js +66 -94
  13. package/cjs/Options/Classes/Links.js +1 -1
  14. package/cjs/Utils.js +26 -8
  15. package/cjs/index.js +3 -14
  16. package/cjs/interaction.js +4 -15
  17. package/cjs/plugin.js +5 -16
  18. package/esm/CircleWarp.js +7 -23
  19. package/esm/LinkInstance.js +121 -114
  20. package/esm/Linker.js +37 -54
  21. package/esm/Options/Classes/Links.js +1 -1
  22. package/esm/Utils.js +24 -8
  23. package/esm/index.js +5 -5
  24. package/esm/interaction.js +2 -2
  25. package/esm/plugin.js +2 -2
  26. package/package.json +6 -5
  27. package/report.html +4 -4
  28. package/tsparticles.interaction.particles.links.js +244 -204
  29. package/tsparticles.interaction.particles.links.min.js +1 -1
  30. package/tsparticles.interaction.particles.links.min.js.LICENSE.txt +1 -8
  31. package/types/CircleWarp.d.ts +1 -2
  32. package/types/Interfaces.d.ts +22 -0
  33. package/types/LinkInstance.d.ts +7 -8
  34. package/types/Linker.d.ts +3 -7
  35. package/types/Options/Classes/Links.d.ts +1 -2
  36. package/types/Options/Classes/LinksShadow.d.ts +1 -2
  37. package/types/Options/Classes/LinksTriangle.d.ts +1 -2
  38. package/types/Types.d.ts +47 -0
  39. package/types/Utils.d.ts +5 -4
  40. package/types/index.d.ts +1 -1
  41. package/types/interaction.d.ts +1 -1
  42. package/types/plugin.d.ts +1 -1
  43. package/umd/CircleWarp.js +7 -23
  44. package/umd/LinkInstance.js +121 -114
  45. package/umd/Linker.js +36 -53
  46. package/umd/Options/Classes/Links.js +2 -2
  47. package/umd/Utils.js +26 -8
  48. package/umd/index.js +3 -3
  49. package/umd/interaction.js +4 -4
  50. package/umd/plugin.js +4 -4
  51. package/browser/Options/Interfaces/IParticlesLinkOptions.js +0 -1
  52. package/cjs/LinkParticle.js +0 -2
  53. package/cjs/Options/Classes/ParticlesLinkOptions.js +0 -2
  54. package/cjs/Options/Interfaces/IParticlesLinkOptions.js +0 -2
  55. package/esm/ILink.js +0 -1
  56. package/esm/LinkContainer.js +0 -1
  57. package/esm/LinkParticle.js +0 -1
  58. package/esm/Options/Classes/ParticlesLinkOptions.js +0 -1
  59. package/esm/Options/Interfaces/IParticlesLinkOptions.js +0 -1
  60. package/types/ILink.d.ts +0 -9
  61. package/types/LinkContainer.d.ts +0 -7
  62. package/types/LinkParticle.d.ts +0 -11
  63. package/types/Options/Classes/ParticlesLinkOptions.d.ts +0 -5
  64. package/types/Options/Interfaces/IParticlesLinkOptions.d.ts +0 -7
  65. package/umd/LinkParticle.js +0 -12
  66. package/umd/Options/Classes/ParticlesLinkOptions.js +0 -12
  67. package/umd/Options/Interfaces/IParticlesLinkOptions.js +0 -12
  68. /package/browser/{ILink.js → Interfaces.js} +0 -0
  69. /package/browser/{LinkContainer.js → Types.js} +0 -0
  70. /package/cjs/{ILink.js → Interfaces.js} +0 -0
  71. /package/cjs/{LinkContainer.js → Types.js} +0 -0
  72. /package/{browser/LinkParticle.js → esm/Interfaces.js} +0 -0
  73. /package/{browser/Options/Classes/ParticlesLinkOptions.js → esm/Types.js} +0 -0
  74. /package/umd/{ILink.js → Interfaces.js} +0 -0
  75. /package/umd/{LinkContainer.js → Types.js} +0 -0
package/umd/Utils.js CHANGED
@@ -9,15 +9,16 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.drawLinkTriangle = exports.drawLinkLine = void 0;
12
+ exports.setLinkFrequency = exports.getLinkKey = exports.drawLinkTriangle = exports.drawLinkLine = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
- function drawLinkLine(context, width, begin, end, maxDistance, canvasSize, warp, backgroundMask, composite, colorLine, opacity, shadow) {
14
+ function drawLinkLine(params) {
15
15
  let drawn = false;
16
+ const { begin, end, maxDistance, context, canvasSize, width, backgroundMask, colorLine, opacity, links } = params;
16
17
  if ((0, engine_1.getDistance)(begin, end) <= maxDistance) {
17
18
  (0, engine_1.drawLine)(context, begin, end);
18
19
  drawn = true;
19
20
  }
20
- else if (warp) {
21
+ else if (links.warp) {
21
22
  let pi1;
22
23
  let pi2;
23
24
  const endNE = {
@@ -66,10 +67,11 @@
66
67
  return;
67
68
  }
68
69
  context.lineWidth = width;
69
- if (backgroundMask) {
70
- context.globalCompositeOperation = composite;
70
+ if (backgroundMask.enable) {
71
+ context.globalCompositeOperation = backgroundMask.composite;
71
72
  }
72
73
  context.strokeStyle = (0, engine_1.getStyleFromRgb)(colorLine, opacity);
74
+ const { shadow } = links;
73
75
  if (shadow.enable) {
74
76
  const shadowColor = (0, engine_1.rangeColorToRgb)(shadow.color);
75
77
  if (shadowColor) {
@@ -80,13 +82,29 @@
80
82
  context.stroke();
81
83
  }
82
84
  exports.drawLinkLine = drawLinkLine;
83
- function drawLinkTriangle(context, pos1, pos2, pos3, backgroundMask, composite, colorTriangle, opacityTriangle) {
85
+ function drawLinkTriangle(params) {
86
+ const { context, pos1, pos2, pos3, backgroundMask, colorTriangle, opacityTriangle } = params;
84
87
  (0, engine_1.drawTriangle)(context, pos1, pos2, pos3);
85
- if (backgroundMask) {
86
- context.globalCompositeOperation = composite;
88
+ if (backgroundMask.enable) {
89
+ context.globalCompositeOperation = backgroundMask.composite;
87
90
  }
88
91
  context.fillStyle = (0, engine_1.getStyleFromRgb)(colorTriangle, opacityTriangle);
89
92
  context.fill();
90
93
  }
91
94
  exports.drawLinkTriangle = drawLinkTriangle;
95
+ function getLinkKey(ids) {
96
+ ids.sort((a, b) => a - b);
97
+ return ids.join("_");
98
+ }
99
+ exports.getLinkKey = getLinkKey;
100
+ function setLinkFrequency(particles, dictionary) {
101
+ const key = getLinkKey(particles.map((t) => t.id));
102
+ let res = dictionary.get(key);
103
+ if (res === undefined) {
104
+ res = (0, engine_1.getRandom)();
105
+ dictionary.set(key, res);
106
+ }
107
+ return res;
108
+ }
109
+ exports.setLinkFrequency = setLinkFrequency;
92
110
  });
package/umd/index.js CHANGED
@@ -26,9 +26,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  exports.loadParticlesLinksInteraction = void 0;
27
27
  const interaction_1 = require("./interaction");
28
28
  const plugin_1 = require("./plugin");
29
- async function loadParticlesLinksInteraction(engine) {
30
- await (0, interaction_1.loadInteraction)(engine);
31
- await (0, plugin_1.loadPlugin)(engine);
29
+ async function loadParticlesLinksInteraction(engine, refresh = true) {
30
+ await (0, interaction_1.loadLinksInteraction)(engine, refresh);
31
+ await (0, plugin_1.loadLinksPlugin)(engine, refresh);
32
32
  }
33
33
  exports.loadParticlesLinksInteraction = loadParticlesLinksInteraction;
34
34
  __exportStar(require("./Options/Classes/Links"), exports);
@@ -9,10 +9,10 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.loadInteraction = void 0;
12
+ exports.loadLinksInteraction = void 0;
13
13
  const Linker_1 = require("./Linker");
14
- async function loadInteraction(engine) {
15
- await engine.addInteractor("particlesLinks", (container) => new Linker_1.Linker(container));
14
+ async function loadLinksInteraction(engine, refresh = true) {
15
+ await engine.addInteractor("particlesLinks", (container) => new Linker_1.Linker(container), refresh);
16
16
  }
17
- exports.loadInteraction = loadInteraction;
17
+ exports.loadLinksInteraction = loadLinksInteraction;
18
18
  });
package/umd/plugin.js CHANGED
@@ -9,7 +9,7 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.loadPlugin = void 0;
12
+ exports.loadLinksPlugin = void 0;
13
13
  const LinkInstance_1 = require("./LinkInstance");
14
14
  class LinksPlugin {
15
15
  constructor() {
@@ -24,9 +24,9 @@
24
24
  return true;
25
25
  }
26
26
  }
27
- async function loadPlugin(engine) {
27
+ async function loadLinksPlugin(engine, refresh = true) {
28
28
  const plugin = new LinksPlugin();
29
- await engine.addPlugin(plugin);
29
+ await engine.addPlugin(plugin, refresh);
30
30
  }
31
- exports.loadPlugin = loadPlugin;
31
+ exports.loadLinksPlugin = loadLinksPlugin;
32
32
  });
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/esm/ILink.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/types/ILink.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { LinkParticle } from "./LinkParticle";
2
- export interface ILink {
3
- destination: LinkParticle;
4
- opacity: number;
5
- }
6
- export interface ILinkTriangle {
7
- opacity: number;
8
- vertices: LinkParticle[];
9
- }
@@ -1,7 +0,0 @@
1
- import type { Container, IRgb } from "@tsparticles/engine";
2
- export type LinkContainer = Container & {
3
- particles: {
4
- linksColor?: IRgb | string;
5
- linksColors: Map<string, IRgb | string | undefined>;
6
- };
7
- };
@@ -1,11 +0,0 @@
1
- import type { ILink } from "./ILink";
2
- import type { Particle } from "@tsparticles/engine";
3
- import type { ParticlesLinkOptions } from "./Options/Classes/ParticlesLinkOptions";
4
- export type LinkParticle = Particle & {
5
- links?: ILink[];
6
- options: ParticlesLinkOptions;
7
- retina: {
8
- linksDistance?: number;
9
- linksWidth?: number;
10
- };
11
- };
@@ -1,5 +0,0 @@
1
- import type { Links } from "./Links";
2
- import type { ParticlesOptions } from "@tsparticles/engine";
3
- export type ParticlesLinkOptions = ParticlesOptions & {
4
- links?: Links;
5
- };
@@ -1,7 +0,0 @@
1
- import type { ILinks } from "./ILinks";
2
- import type { IParticlesOptions } from "@tsparticles/engine";
3
- export type IParticlesLinkOptions = IParticlesOptions & {
4
- lineLinked?: ILinks;
5
- line_linked?: ILinks;
6
- links?: ILinks;
7
- };
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes