@tsparticles/interaction-particles-links 3.9.1 → 4.0.0-alpha.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.
- package/418.min.js +2 -0
- package/418.min.js.LICENSE.txt +1 -0
- package/497.min.js +2 -0
- package/497.min.js.LICENSE.txt +1 -0
- package/711.min.js +2 -0
- package/711.min.js.LICENSE.txt +1 -0
- package/956.min.js +2 -0
- package/956.min.js.LICENSE.txt +1 -0
- package/browser/CircleWarp.js +2 -2
- package/browser/LinkInstance.js +7 -7
- package/browser/Linker.js +4 -7
- package/browser/Utils.js +5 -11
- package/browser/index.js +7 -9
- package/browser/interaction.js +7 -5
- package/browser/plugin.js +5 -4
- package/cjs/CircleWarp.js +6 -10
- package/cjs/Interfaces.js +1 -2
- package/cjs/LinkInstance.js +22 -26
- package/cjs/Linker.js +12 -19
- package/cjs/LinksPlugin.js +3 -7
- package/cjs/Options/Classes/Links.js +9 -13
- package/cjs/Options/Classes/LinksShadow.js +5 -9
- package/cjs/Options/Classes/LinksTriangle.js +4 -8
- package/cjs/Options/Interfaces/ILinks.js +1 -2
- package/cjs/Options/Interfaces/ILinksShadow.js +1 -2
- package/cjs/Options/Interfaces/ILinksTriangle.js +1 -2
- package/cjs/Types.js +1 -2
- package/cjs/Utils.js +20 -33
- package/cjs/index.js +10 -29
- package/cjs/interaction.js +7 -8
- package/cjs/plugin.js +5 -7
- package/dist_browser_Linker_js.js +40 -0
- package/dist_browser_LinksPlugin_js.js +50 -0
- package/dist_browser_interaction_js.js +30 -0
- package/dist_browser_plugin_js.js +30 -0
- package/esm/CircleWarp.js +2 -2
- package/esm/LinkInstance.js +7 -7
- package/esm/Linker.js +4 -7
- package/esm/Utils.js +5 -11
- package/esm/index.js +7 -9
- package/esm/interaction.js +7 -5
- package/esm/plugin.js +5 -4
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.interaction.particles.links.js +221 -102
- package/tsparticles.interaction.particles.links.min.js +1 -1
- package/tsparticles.interaction.particles.links.min.js.LICENSE.txt +1 -1
- package/types/LinkInstance.d.ts +1 -1
- package/types/Linker.d.ts +1 -2
- package/types/Types.d.ts +3 -3
- package/types/index.d.ts +4 -4
- package/types/interaction.d.ts +1 -1
- package/types/plugin.d.ts +1 -1
- package/umd/CircleWarp.js +2 -2
- package/umd/LinkInstance.js +7 -7
- package/umd/Linker.js +4 -7
- package/umd/Utils.js +5 -11
- package/umd/index.js +31 -10
- package/umd/interaction.js +42 -6
- package/umd/plugin.js +40 -5
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Utils.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.drawTriangle = drawTriangle;
|
|
4
|
-
exports.drawLinkLine = drawLinkLine;
|
|
5
|
-
exports.drawLinkTriangle = drawLinkTriangle;
|
|
6
|
-
exports.getLinkKey = getLinkKey;
|
|
7
|
-
exports.setLinkFrequency = setLinkFrequency;
|
|
8
|
-
const engine_1 = require("@tsparticles/engine");
|
|
9
|
-
function drawTriangle(context, p1, p2, p3) {
|
|
1
|
+
import { drawLine, getDistance, getDistances, getRandom, getStyleFromRgb, rangeColorToRgb, } from "@tsparticles/engine";
|
|
2
|
+
export function drawTriangle(context, p1, p2, p3) {
|
|
10
3
|
context.beginPath();
|
|
11
4
|
context.moveTo(p1.x, p1.y);
|
|
12
5
|
context.lineTo(p2.x, p2.y);
|
|
13
6
|
context.lineTo(p3.x, p3.y);
|
|
14
7
|
context.closePath();
|
|
15
8
|
}
|
|
16
|
-
function drawLinkLine(params) {
|
|
9
|
+
export function drawLinkLine(params) {
|
|
17
10
|
let drawn = false;
|
|
18
|
-
const { begin, end, engine, maxDistance, context, canvasSize, width,
|
|
19
|
-
if (
|
|
20
|
-
|
|
11
|
+
const { begin, end, engine, maxDistance, context, canvasSize, width, colorLine, opacity, links, hdr } = params;
|
|
12
|
+
if (getDistance(begin, end) <= maxDistance) {
|
|
13
|
+
drawLine(context, begin, end);
|
|
21
14
|
drawn = true;
|
|
22
15
|
}
|
|
23
16
|
else if (links.warp) {
|
|
@@ -27,7 +20,7 @@ function drawLinkLine(params) {
|
|
|
27
20
|
x: end.x - canvasSize.width,
|
|
28
21
|
y: end.y,
|
|
29
22
|
};
|
|
30
|
-
const d1 =
|
|
23
|
+
const d1 = getDistances(begin, endNE);
|
|
31
24
|
if (d1.distance <= maxDistance) {
|
|
32
25
|
const yi = begin.y - (d1.dy / d1.dx) * begin.x;
|
|
33
26
|
pi1 = { x: 0, y: yi };
|
|
@@ -38,7 +31,7 @@ function drawLinkLine(params) {
|
|
|
38
31
|
x: end.x,
|
|
39
32
|
y: end.y - canvasSize.height,
|
|
40
33
|
};
|
|
41
|
-
const d2 =
|
|
34
|
+
const d2 = getDistances(begin, endSW);
|
|
42
35
|
if (d2.distance <= maxDistance) {
|
|
43
36
|
const yi = begin.y - (d2.dy / d2.dx) * begin.x;
|
|
44
37
|
const xi = -yi / (d2.dy / d2.dx);
|
|
@@ -50,7 +43,7 @@ function drawLinkLine(params) {
|
|
|
50
43
|
x: end.x - canvasSize.width,
|
|
51
44
|
y: end.y - canvasSize.height,
|
|
52
45
|
};
|
|
53
|
-
const d3 =
|
|
46
|
+
const d3 = getDistances(begin, endSE);
|
|
54
47
|
if (d3.distance <= maxDistance) {
|
|
55
48
|
const yi = begin.y - (d3.dy / d3.dx) * begin.x;
|
|
56
49
|
const xi = -yi / (d3.dy / d3.dx);
|
|
@@ -60,8 +53,8 @@ function drawLinkLine(params) {
|
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
if (pi1 && pi2) {
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
drawLine(context, begin, pi1);
|
|
57
|
+
drawLine(context, end, pi2);
|
|
65
58
|
drawn = true;
|
|
66
59
|
}
|
|
67
60
|
}
|
|
@@ -69,38 +62,32 @@ function drawLinkLine(params) {
|
|
|
69
62
|
return;
|
|
70
63
|
}
|
|
71
64
|
context.lineWidth = width;
|
|
72
|
-
|
|
73
|
-
context.globalCompositeOperation = backgroundMask.composite;
|
|
74
|
-
}
|
|
75
|
-
context.strokeStyle = (0, engine_1.getStyleFromRgb)(colorLine, opacity);
|
|
65
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
76
66
|
const { shadow } = links;
|
|
77
67
|
if (shadow.enable) {
|
|
78
|
-
const shadowColor =
|
|
68
|
+
const shadowColor = rangeColorToRgb(engine, shadow.color);
|
|
79
69
|
if (shadowColor) {
|
|
80
70
|
context.shadowBlur = shadow.blur;
|
|
81
|
-
context.shadowColor = (
|
|
71
|
+
context.shadowColor = getStyleFromRgb(shadowColor, hdr);
|
|
82
72
|
}
|
|
83
73
|
}
|
|
84
74
|
context.stroke();
|
|
85
75
|
}
|
|
86
|
-
function drawLinkTriangle(params) {
|
|
87
|
-
const { context, pos1, pos2, pos3,
|
|
76
|
+
export function drawLinkTriangle(params) {
|
|
77
|
+
const { context, hdr, pos1, pos2, pos3, colorTriangle, opacityTriangle } = params;
|
|
88
78
|
drawTriangle(context, pos1, pos2, pos3);
|
|
89
|
-
|
|
90
|
-
context.globalCompositeOperation = backgroundMask.composite;
|
|
91
|
-
}
|
|
92
|
-
context.fillStyle = (0, engine_1.getStyleFromRgb)(colorTriangle, opacityTriangle);
|
|
79
|
+
context.fillStyle = getStyleFromRgb(colorTriangle, hdr, opacityTriangle);
|
|
93
80
|
context.fill();
|
|
94
81
|
}
|
|
95
|
-
function getLinkKey(ids) {
|
|
82
|
+
export function getLinkKey(ids) {
|
|
96
83
|
ids.sort((a, b) => a - b);
|
|
97
84
|
return ids.join("_");
|
|
98
85
|
}
|
|
99
|
-
function setLinkFrequency(particles, dictionary) {
|
|
86
|
+
export function setLinkFrequency(particles, dictionary) {
|
|
100
87
|
const key = getLinkKey(particles.map(t => t.id));
|
|
101
88
|
let res = dictionary.get(key);
|
|
102
89
|
if (res === undefined) {
|
|
103
|
-
res =
|
|
90
|
+
res = getRandom();
|
|
104
91
|
dictionary.set(key, res);
|
|
105
92
|
}
|
|
106
93
|
return res;
|
package/cjs/index.js
CHANGED
|
@@ -1,30 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.loadParticlesLinksInteraction = loadParticlesLinksInteraction;
|
|
18
|
-
const interaction_js_1 = require("./interaction.js");
|
|
19
|
-
const plugin_js_1 = require("./plugin.js");
|
|
20
|
-
async function loadParticlesLinksInteraction(engine, refresh = true) {
|
|
21
|
-
engine.checkVersion("3.9.1");
|
|
22
|
-
await (0, interaction_js_1.loadLinksInteraction)(engine, refresh);
|
|
23
|
-
await (0, plugin_js_1.loadLinksPlugin)(engine, refresh);
|
|
1
|
+
export function loadParticlesLinksInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { loadLinksInteraction } = await import("./interaction.js"), { loadLinksPlugin } = await import("./plugin.js");
|
|
5
|
+
loadLinksInteraction(e);
|
|
6
|
+
loadLinksPlugin(e);
|
|
7
|
+
});
|
|
24
8
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
__exportStar(require("./Options/Interfaces/ILinks.js"), exports);
|
|
29
|
-
__exportStar(require("./Options/Interfaces/ILinksShadow.js"), exports);
|
|
30
|
-
__exportStar(require("./Options/Interfaces/ILinksTriangle.js"), exports);
|
|
9
|
+
export * from "./Options/Classes/Links.js";
|
|
10
|
+
export * from "./Options/Classes/LinksShadow.js";
|
|
11
|
+
export * from "./Options/Classes/LinksTriangle.js";
|
package/cjs/interaction.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, refresh);
|
|
1
|
+
export function loadLinksInteraction(engine) {
|
|
2
|
+
engine.register(e => {
|
|
3
|
+
e.addInteractor("particlesLinks", async (container) => {
|
|
4
|
+
const { Linker } = await import("./Linker.js");
|
|
5
|
+
return new Linker(container, engine);
|
|
6
|
+
});
|
|
7
|
+
});
|
|
9
8
|
}
|
package/cjs/plugin.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const plugin = new LinksPlugin_js_1.LinksPlugin(engine);
|
|
7
|
-
await engine.addPlugin(plugin, refresh);
|
|
1
|
+
export function loadLinksPlugin(engine) {
|
|
2
|
+
engine.register(async (e) => {
|
|
3
|
+
const { LinksPlugin } = await import("./LinksPlugin.js");
|
|
4
|
+
e.addPlugin(new LinksPlugin(e));
|
|
5
|
+
});
|
|
8
6
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_interaction_particles_links"] = this["webpackChunk_tsparticles_interaction_particles_links"] || []).push([["dist_browser_Linker_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/CircleWarp.js"
|
|
21
|
+
/*!************************************!*\
|
|
22
|
+
!*** ./dist/browser/CircleWarp.js ***!
|
|
23
|
+
\************************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CircleWarp: () => (/* binding */ CircleWarp)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst double = 2;\nclass CircleWarp extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle {\n constructor(x, y, radius, canvasSize) {\n super(x, y, radius);\n this.canvasSize = canvasSize;\n this.canvasSize = {\n ...canvasSize\n };\n }\n contains(point) {\n const {\n width,\n height\n } = this.canvasSize,\n {\n x,\n y\n } = point;\n return super.contains(point) || super.contains({\n x: x - width,\n y\n }) || super.contains({\n x: x - width,\n y: y - height\n }) || super.contains({\n x,\n y: y - height\n });\n }\n intersects(range) {\n if (super.intersects(range)) {\n return true;\n }\n const rect = range,\n circle = range,\n newPos = {\n x: range.position.x - this.canvasSize.width,\n y: range.position.y - this.canvasSize.height\n };\n if (Object.hasOwn(circle, \"radius\")) {\n const biggerCircle = new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(newPos.x, newPos.y, circle.radius * double);\n return super.intersects(biggerCircle);\n } else if (Object.hasOwn(rect, \"size\")) {\n const rectSW = new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Rectangle(newPos.x, newPos.y, rect.size.width * double, rect.size.height * double);\n return super.intersects(rectSW);\n }\n return false;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-links/./dist/browser/CircleWarp.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Linker.js"
|
|
31
|
+
/*!********************************!*\
|
|
32
|
+
!*** ./dist/browser/Linker.js ***!
|
|
33
|
+
\********************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Linker: () => (/* binding */ Linker)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _CircleWarp_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CircleWarp.js */ \"./dist/browser/CircleWarp.js\");\n/* harmony import */ var _Options_Classes_Links_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Links.js */ \"./dist/browser/Options/Classes/Links.js\");\n\n\n\nconst squarePower = 2,\n opacityOffset = 1,\n origin = {\n x: 0,\n y: 0\n },\n minDistance = 0;\nfunction getLinkDistance(pos1, pos2, optDistance, canvasSize, warp) {\n const {\n dx,\n dy,\n distance\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(pos1, pos2);\n if (!warp || distance <= optDistance) {\n return distance;\n }\n const absDiffs = {\n x: Math.abs(dx),\n y: Math.abs(dy)\n },\n warpDistances = {\n x: Math.min(absDiffs.x, canvasSize.width - absDiffs.x),\n y: Math.min(absDiffs.y, canvasSize.height - absDiffs.y)\n };\n return Math.sqrt(warpDistances.x ** squarePower + warpDistances.y ** squarePower);\n}\nclass Linker extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticlesInteractorBase {\n constructor(container, engine) {\n super(container);\n this._setColor = p1 => {\n if (!p1.options.links) {\n return;\n }\n const container = this.container,\n linksOptions = p1.options.links;\n let linkColor = linksOptions.id === undefined ? container.particles.linksColor : container.particles.linksColors.get(linksOptions.id);\n if (linkColor) {\n return;\n }\n const optColor = linksOptions.color;\n linkColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLinkRandomColor)(this._engine, optColor, linksOptions.blink, linksOptions.consent);\n if (linksOptions.id === undefined) {\n container.particles.linksColor = linkColor;\n } else {\n container.particles.linksColors.set(linksOptions.id, linkColor);\n }\n };\n this._engine = engine;\n }\n clear() {}\n init() {\n this.container.particles.linksColor = undefined;\n this.container.particles.linksColors = new Map();\n }\n interact(p1) {\n if (!p1.options.links) {\n return;\n }\n p1.links = [];\n const pos1 = p1.getPosition(),\n container = this.container,\n canvasSize = container.canvas.size;\n if (pos1.x < origin.x || pos1.y < origin.y || pos1.x > canvasSize.width || pos1.y > canvasSize.height) {\n return;\n }\n const linkOpt1 = p1.options.links,\n optOpacity = linkOpt1.opacity,\n optDistance = p1.retina.linksDistance ?? minDistance,\n warp = linkOpt1.warp;\n let range;\n if (warp) {\n range = new _CircleWarp_js__WEBPACK_IMPORTED_MODULE_1__.CircleWarp(pos1.x, pos1.y, optDistance, canvasSize);\n } else {\n range = new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(pos1.x, pos1.y, optDistance);\n }\n const query = container.particles.quadTree.query(range);\n for (const p2 of query) {\n const linkOpt2 = p2.options.links;\n if (p1 === p2 || !linkOpt2?.enable || linkOpt1.id !== linkOpt2.id || p2.spawning || p2.destroyed || !p2.links || p1.links.some(t => t.destination === p2) || p2.links.some(t => t.destination === p1)) {\n continue;\n }\n const pos2 = p2.getPosition();\n if (pos2.x < origin.x || pos2.y < origin.y || pos2.x > canvasSize.width || pos2.y > canvasSize.height) {\n continue;\n }\n const distance = getLinkDistance(pos1, pos2, optDistance, canvasSize, warp && linkOpt2.warp);\n if (distance > optDistance) {\n continue;\n }\n const opacityLine = (opacityOffset - distance / optDistance) * optOpacity;\n this._setColor(p1);\n p1.links.push({\n destination: p2,\n opacity: opacityLine\n });\n }\n }\n isEnabled(particle) {\n return !!particle.options.links?.enable;\n }\n loadParticlesOptions(options, ...sources) {\n options.links ??= new _Options_Classes_Links_js__WEBPACK_IMPORTED_MODULE_2__.Links();\n for (const source of sources) {\n options.links.load(source?.links);\n }\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-links/./dist/browser/Linker.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ }
|
|
39
|
+
|
|
40
|
+
}]);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_interaction_particles_links"] = this["webpackChunk_tsparticles_interaction_particles_links"] || []).push([["dist_browser_LinksPlugin_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/LinkInstance.js"
|
|
21
|
+
/*!**************************************!*\
|
|
22
|
+
!*** ./dist/browser/LinkInstance.js ***!
|
|
23
|
+
\**************************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LinkInstance: () => (/* binding */ LinkInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst minOpacity = 0,\n minWidth = 0,\n minDistance = 0,\n half = 0.5,\n maxFrequency = 1;\nclass LinkInstance {\n constructor(container, engine) {\n this._drawLinkLine = (p1, link) => {\n const p1LinksOptions = p1.options.links;\n if (!p1LinksOptions?.enable) {\n return;\n }\n const container = this._container,\n p2 = link.destination,\n pos1 = p1.getPosition(),\n pos2 = p2.getPosition();\n let opacity = link.opacity;\n container.canvas.draw(ctx => {\n let colorLine;\n const twinkle = p1.options[\"twinkle\"]?.lines;\n if (twinkle?.enable) {\n const twinkleFreq = twinkle.frequency,\n twinkleRgb = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToRgb)(this._engine, twinkle.color),\n twinkling = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() < twinkleFreq;\n if (twinkling && twinkleRgb) {\n colorLine = twinkleRgb;\n opacity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(twinkle.opacity);\n }\n }\n if (!colorLine) {\n const linkColor = p1LinksOptions.id !== undefined ? container.particles.linksColors.get(p1LinksOptions.id) : container.particles.linksColor;\n colorLine = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLinkColor)(p1, p2, linkColor);\n }\n if (!colorLine) {\n return;\n }\n const width = p1.retina.linksWidth ?? minWidth,\n maxDistance = p1.retina.linksDistance ?? minDistance;\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawLinkLine)({\n context: ctx,\n width,\n begin: pos1,\n end: pos2,\n engine: this._engine,\n maxDistance,\n canvasSize: container.canvas.size,\n links: p1LinksOptions,\n colorLine,\n opacity,\n hdr: container.hdr\n });\n });\n };\n this._drawLinkTriangle = (p1, link1, link2) => {\n const linksOptions = p1.options.links;\n if (!linksOptions?.enable) {\n return;\n }\n const triangleOptions = linksOptions.triangles;\n if (!triangleOptions.enable) {\n return;\n }\n const container = this._container,\n p2 = link1.destination,\n p3 = link2.destination,\n opacityTriangle = triangleOptions.opacity ?? (link1.opacity + link2.opacity) * half;\n if (opacityTriangle <= minOpacity) {\n return;\n }\n container.canvas.draw(ctx => {\n const pos1 = p1.getPosition(),\n pos2 = p2.getPosition(),\n pos3 = p3.getPosition(),\n linksDistance = p1.retina.linksDistance ?? minDistance;\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(pos1, pos2) > linksDistance || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(pos3, pos2) > linksDistance || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(pos3, pos1) > linksDistance) {\n return;\n }\n let colorTriangle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToRgb)(this._engine, triangleOptions.color);\n if (!colorTriangle) {\n const linkColor = linksOptions.id !== undefined ? container.particles.linksColors.get(linksOptions.id) : container.particles.linksColor;\n colorTriangle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLinkColor)(p1, p2, linkColor);\n }\n if (!colorTriangle) {\n return;\n }\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawLinkTriangle)({\n context: ctx,\n pos1,\n pos2,\n pos3,\n colorTriangle,\n opacityTriangle,\n hdr: container.hdr\n });\n });\n };\n this._drawTriangles = (options, p1, link, p1Links) => {\n const p2 = link.destination;\n if (!(options.links?.triangles.enable && p2.options.links?.triangles.enable)) {\n return;\n }\n const vertices = p2.links?.filter(t => {\n const linkFreq = this._getLinkFrequency(p2, t.destination),\n minCount = 0;\n return p2.options.links && linkFreq <= p2.options.links.frequency && p1Links.findIndex(l => l.destination === t.destination) >= minCount;\n });\n if (!vertices?.length) {\n return;\n }\n for (const vertex of vertices) {\n const p3 = vertex.destination,\n triangleFreq = this._getTriangleFrequency(p1, p2, p3);\n if (triangleFreq > options.links.triangles.frequency) {\n continue;\n }\n this._drawLinkTriangle(p1, link, vertex);\n }\n };\n this._getLinkFrequency = (p1, p2) => {\n return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.setLinkFrequency)([p1, p2], this._freqs.links);\n };\n this._getTriangleFrequency = (p1, p2, p3) => {\n return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.setLinkFrequency)([p1, p2, p3], this._freqs.triangles);\n };\n this._container = container;\n this._engine = engine;\n this._freqs = {\n links: new Map(),\n triangles: new Map()\n };\n }\n drawParticle(_context, particle) {\n const {\n links,\n options\n } = particle;\n if (!links?.length) {\n return;\n }\n const p1Links = links.filter(l => options.links && (options.links.frequency >= maxFrequency || this._getLinkFrequency(particle, l.destination) <= options.links.frequency));\n for (const link of p1Links) {\n this._drawTriangles(options, particle, link, p1Links);\n if (link.opacity > minOpacity && (particle.retina.linksWidth ?? minWidth) > minWidth) {\n this._drawLinkLine(particle, link);\n }\n }\n }\n async init() {\n this._freqs.links = new Map();\n this._freqs.triangles = new Map();\n await Promise.resolve();\n }\n particleCreated(particle) {\n particle.links = [];\n if (!particle.options.links) {\n return;\n }\n const ratio = this._container.retina.pixelRatio,\n {\n retina\n } = particle,\n {\n distance,\n width\n } = particle.options.links;\n retina.linksDistance = distance * ratio;\n retina.linksWidth = width * ratio;\n }\n particleDestroyed(particle) {\n particle.links = [];\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-links/./dist/browser/LinkInstance.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/LinksPlugin.js"
|
|
31
|
+
/*!*************************************!*\
|
|
32
|
+
!*** ./dist/browser/LinksPlugin.js ***!
|
|
33
|
+
\*************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LinksPlugin: () => (/* binding */ LinksPlugin)\n/* harmony export */ });\n/* harmony import */ var _LinkInstance_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./LinkInstance.js */ \"./dist/browser/LinkInstance.js\");\n\nclass LinksPlugin {\n constructor(engine) {\n this.id = \"links\";\n this._engine = engine;\n }\n getPlugin(container) {\n return Promise.resolve(new _LinkInstance_js__WEBPACK_IMPORTED_MODULE_0__.LinkInstance(container, this._engine));\n }\n loadOptions() {}\n needsPlugin() {\n return true;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-links/./dist/browser/LinksPlugin.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ },
|
|
39
|
+
|
|
40
|
+
/***/ "./dist/browser/Utils.js"
|
|
41
|
+
/*!*******************************!*\
|
|
42
|
+
!*** ./dist/browser/Utils.js ***!
|
|
43
|
+
\*******************************/
|
|
44
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
+
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawLinkLine: () => (/* binding */ drawLinkLine),\n/* harmony export */ drawLinkTriangle: () => (/* binding */ drawLinkTriangle),\n/* harmony export */ drawTriangle: () => (/* binding */ drawTriangle),\n/* harmony export */ getLinkKey: () => (/* binding */ getLinkKey),\n/* harmony export */ setLinkFrequency: () => (/* binding */ setLinkFrequency)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nfunction drawTriangle(context, p1, p2, p3) {\n context.beginPath();\n context.moveTo(p1.x, p1.y);\n context.lineTo(p2.x, p2.y);\n context.lineTo(p3.x, p3.y);\n context.closePath();\n}\nfunction drawLinkLine(params) {\n let drawn = false;\n const {\n begin,\n end,\n engine,\n maxDistance,\n context,\n canvasSize,\n width,\n colorLine,\n opacity,\n links,\n hdr\n } = params;\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(begin, end) <= maxDistance) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.drawLine)(context, begin, end);\n drawn = true;\n } else if (links.warp) {\n let pi1;\n let pi2;\n const endNE = {\n x: end.x - canvasSize.width,\n y: end.y\n };\n const d1 = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(begin, endNE);\n if (d1.distance <= maxDistance) {\n const yi = begin.y - d1.dy / d1.dx * begin.x;\n pi1 = {\n x: 0,\n y: yi\n };\n pi2 = {\n x: canvasSize.width,\n y: yi\n };\n } else {\n const endSW = {\n x: end.x,\n y: end.y - canvasSize.height\n };\n const d2 = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(begin, endSW);\n if (d2.distance <= maxDistance) {\n const yi = begin.y - d2.dy / d2.dx * begin.x;\n const xi = -yi / (d2.dy / d2.dx);\n pi1 = {\n x: xi,\n y: 0\n };\n pi2 = {\n x: xi,\n y: canvasSize.height\n };\n } else {\n const endSE = {\n x: end.x - canvasSize.width,\n y: end.y - canvasSize.height\n };\n const d3 = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(begin, endSE);\n if (d3.distance <= maxDistance) {\n const yi = begin.y - d3.dy / d3.dx * begin.x;\n const xi = -yi / (d3.dy / d3.dx);\n pi1 = {\n x: xi,\n y: yi\n };\n pi2 = {\n x: pi1.x + canvasSize.width,\n y: pi1.y + canvasSize.height\n };\n }\n }\n }\n if (pi1 && pi2) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.drawLine)(context, begin, pi1);\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.drawLine)(context, end, pi2);\n drawn = true;\n }\n }\n if (!drawn) {\n return;\n }\n context.lineWidth = width;\n context.strokeStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(colorLine, hdr, opacity);\n const {\n shadow\n } = links;\n if (shadow.enable) {\n const shadowColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToRgb)(engine, shadow.color);\n if (shadowColor) {\n context.shadowBlur = shadow.blur;\n context.shadowColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(shadowColor, hdr);\n }\n }\n context.stroke();\n}\nfunction drawLinkTriangle(params) {\n const {\n context,\n hdr,\n pos1,\n pos2,\n pos3,\n colorTriangle,\n opacityTriangle\n } = params;\n drawTriangle(context, pos1, pos2, pos3);\n context.fillStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(colorTriangle, hdr, opacityTriangle);\n context.fill();\n}\nfunction getLinkKey(ids) {\n ids.sort((a, b) => a - b);\n return ids.join(\"_\");\n}\nfunction setLinkFrequency(particles, dictionary) {\n const key = getLinkKey(particles.map(t => t.id));\n let res = dictionary.get(key);\n if (res === undefined) {\n res = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n dictionary.set(key, res);\n }\n return res;\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-links/./dist/browser/Utils.js?\n}");
|
|
47
|
+
|
|
48
|
+
/***/ }
|
|
49
|
+
|
|
50
|
+
}]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_interaction_particles_links"] = this["webpackChunk_tsparticles_interaction_particles_links"] || []).push([["dist_browser_interaction_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/interaction.js"
|
|
21
|
+
/*!*************************************!*\
|
|
22
|
+
!*** ./dist/browser/interaction.js ***!
|
|
23
|
+
\*************************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadLinksInteraction: () => (/* binding */ loadLinksInteraction)\n/* harmony export */ });\nfunction loadLinksInteraction(engine) {\n engine.register(e => {\n e.addInteractor(\"particlesLinks\", async container => {\n const {\n Linker\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_Linker_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Linker.js */ \"./dist/browser/Linker.js\"));\n return new Linker(container, engine);\n });\n });\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-links/./dist/browser/interaction.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ }
|
|
29
|
+
|
|
30
|
+
}]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_interaction_particles_links"] = this["webpackChunk_tsparticles_interaction_particles_links"] || []).push([["dist_browser_plugin_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/plugin.js"
|
|
21
|
+
/*!********************************!*\
|
|
22
|
+
!*** ./dist/browser/plugin.js ***!
|
|
23
|
+
\********************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadLinksPlugin: () => (/* binding */ loadLinksPlugin)\n/* harmony export */ });\nfunction loadLinksPlugin(engine) {\n engine.register(async e => {\n const {\n LinksPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_LinksPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./LinksPlugin.js */ \"./dist/browser/LinksPlugin.js\"));\n e.addPlugin(new LinksPlugin(e));\n });\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-links/./dist/browser/plugin.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ }
|
|
29
|
+
|
|
30
|
+
}]);
|
package/esm/CircleWarp.js
CHANGED
|
@@ -21,11 +21,11 @@ export class CircleWarp extends Circle {
|
|
|
21
21
|
x: range.position.x - this.canvasSize.width,
|
|
22
22
|
y: range.position.y - this.canvasSize.height,
|
|
23
23
|
};
|
|
24
|
-
if (circle
|
|
24
|
+
if (Object.hasOwn(circle, "radius")) {
|
|
25
25
|
const biggerCircle = new Circle(newPos.x, newPos.y, circle.radius * double);
|
|
26
26
|
return super.intersects(biggerCircle);
|
|
27
27
|
}
|
|
28
|
-
else if (rect
|
|
28
|
+
else if (Object.hasOwn(rect, "size")) {
|
|
29
29
|
const rectSW = new Rectangle(newPos.x, newPos.y, rect.size.width * double, rect.size.height * double);
|
|
30
30
|
return super.intersects(rectSW);
|
|
31
31
|
}
|
package/esm/LinkInstance.js
CHANGED
|
@@ -8,11 +8,11 @@ export class LinkInstance {
|
|
|
8
8
|
if (!p1LinksOptions?.enable) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const container = this._container,
|
|
11
|
+
const container = this._container, p2 = link.destination, pos1 = p1.getPosition(), pos2 = p2.getPosition();
|
|
12
12
|
let opacity = link.opacity;
|
|
13
13
|
container.canvas.draw(ctx => {
|
|
14
14
|
let colorLine;
|
|
15
|
-
const twinkle = p1.options
|
|
15
|
+
const twinkle = p1.options["twinkle"]?.lines;
|
|
16
16
|
if (twinkle?.enable) {
|
|
17
17
|
const twinkleFreq = twinkle.frequency, twinkleRgb = rangeColorToRgb(this._engine, twinkle.color), twinkling = getRandom() < twinkleFreq;
|
|
18
18
|
if (twinkling && twinkleRgb) {
|
|
@@ -29,7 +29,7 @@ export class LinkInstance {
|
|
|
29
29
|
if (!colorLine) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const width = p1.retina.linksWidth ?? minWidth, maxDistance = p1.retina.linksDistance ?? minDistance
|
|
32
|
+
const width = p1.retina.linksWidth ?? minWidth, maxDistance = p1.retina.linksDistance ?? minDistance;
|
|
33
33
|
drawLinkLine({
|
|
34
34
|
context: ctx,
|
|
35
35
|
width,
|
|
@@ -39,9 +39,9 @@ export class LinkInstance {
|
|
|
39
39
|
maxDistance,
|
|
40
40
|
canvasSize: container.canvas.size,
|
|
41
41
|
links: p1LinksOptions,
|
|
42
|
-
backgroundMask: backgroundMask,
|
|
43
42
|
colorLine,
|
|
44
43
|
opacity,
|
|
44
|
+
hdr: container.hdr,
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
};
|
|
@@ -54,7 +54,7 @@ export class LinkInstance {
|
|
|
54
54
|
if (!triangleOptions.enable) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
const container = this._container,
|
|
57
|
+
const container = this._container, p2 = link1.destination, p3 = link2.destination, opacityTriangle = triangleOptions.opacity ?? (link1.opacity + link2.opacity) * half;
|
|
58
58
|
if (opacityTriangle <= minOpacity) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
@@ -80,9 +80,9 @@ export class LinkInstance {
|
|
|
80
80
|
pos1,
|
|
81
81
|
pos2,
|
|
82
82
|
pos3,
|
|
83
|
-
backgroundMask: options.backgroundMask,
|
|
84
83
|
colorTriangle,
|
|
85
84
|
opacityTriangle,
|
|
85
|
+
hdr: container.hdr,
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
};
|
|
@@ -121,7 +121,7 @@ export class LinkInstance {
|
|
|
121
121
|
triangles: new Map(),
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
drawParticle(
|
|
124
|
+
drawParticle(_context, particle) {
|
|
125
125
|
const { links, options } = particle;
|
|
126
126
|
if (!links?.length) {
|
|
127
127
|
return;
|
package/esm/Linker.js
CHANGED
|
@@ -26,7 +26,7 @@ export class Linker extends ParticlesInteractorBase {
|
|
|
26
26
|
if (!p1.options.links) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
const container = this.
|
|
29
|
+
const container = this.container, linksOptions = p1.options.links;
|
|
30
30
|
let linkColor = linksOptions.id === undefined
|
|
31
31
|
? container.particles.linksColor
|
|
32
32
|
: container.particles.linksColors.get(linksOptions.id);
|
|
@@ -42,14 +42,13 @@ export class Linker extends ParticlesInteractorBase {
|
|
|
42
42
|
container.particles.linksColors.set(linksOptions.id, linkColor);
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
this._linkContainer = container;
|
|
46
45
|
this._engine = engine;
|
|
47
46
|
}
|
|
48
47
|
clear() {
|
|
49
48
|
}
|
|
50
49
|
init() {
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
50
|
+
this.container.particles.linksColor = undefined;
|
|
51
|
+
this.container.particles.linksColors = new Map();
|
|
53
52
|
}
|
|
54
53
|
interact(p1) {
|
|
55
54
|
if (!p1.options.links) {
|
|
@@ -101,9 +100,7 @@ export class Linker extends ParticlesInteractorBase {
|
|
|
101
100
|
return !!particle.options.links?.enable;
|
|
102
101
|
}
|
|
103
102
|
loadParticlesOptions(options, ...sources) {
|
|
104
|
-
|
|
105
|
-
options.links = new Links();
|
|
106
|
-
}
|
|
103
|
+
options.links ??= new Links();
|
|
107
104
|
for (const source of sources) {
|
|
108
105
|
options.links.load(source?.links);
|
|
109
106
|
}
|
package/esm/Utils.js
CHANGED
|
@@ -8,7 +8,7 @@ export function drawTriangle(context, p1, p2, p3) {
|
|
|
8
8
|
}
|
|
9
9
|
export function drawLinkLine(params) {
|
|
10
10
|
let drawn = false;
|
|
11
|
-
const { begin, end, engine, maxDistance, context, canvasSize, width,
|
|
11
|
+
const { begin, end, engine, maxDistance, context, canvasSize, width, colorLine, opacity, links, hdr } = params;
|
|
12
12
|
if (getDistance(begin, end) <= maxDistance) {
|
|
13
13
|
drawLine(context, begin, end);
|
|
14
14
|
drawn = true;
|
|
@@ -62,27 +62,21 @@ export function drawLinkLine(params) {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
context.lineWidth = width;
|
|
65
|
-
|
|
66
|
-
context.globalCompositeOperation = backgroundMask.composite;
|
|
67
|
-
}
|
|
68
|
-
context.strokeStyle = getStyleFromRgb(colorLine, opacity);
|
|
65
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
69
66
|
const { shadow } = links;
|
|
70
67
|
if (shadow.enable) {
|
|
71
68
|
const shadowColor = rangeColorToRgb(engine, shadow.color);
|
|
72
69
|
if (shadowColor) {
|
|
73
70
|
context.shadowBlur = shadow.blur;
|
|
74
|
-
context.shadowColor = getStyleFromRgb(shadowColor);
|
|
71
|
+
context.shadowColor = getStyleFromRgb(shadowColor, hdr);
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
context.stroke();
|
|
78
75
|
}
|
|
79
76
|
export function drawLinkTriangle(params) {
|
|
80
|
-
const { context, pos1, pos2, pos3,
|
|
77
|
+
const { context, hdr, pos1, pos2, pos3, colorTriangle, opacityTriangle } = params;
|
|
81
78
|
drawTriangle(context, pos1, pos2, pos3);
|
|
82
|
-
|
|
83
|
-
context.globalCompositeOperation = backgroundMask.composite;
|
|
84
|
-
}
|
|
85
|
-
context.fillStyle = getStyleFromRgb(colorTriangle, opacityTriangle);
|
|
79
|
+
context.fillStyle = getStyleFromRgb(colorTriangle, hdr, opacityTriangle);
|
|
86
80
|
context.fill();
|
|
87
81
|
}
|
|
88
82
|
export function getLinkKey(ids) {
|
package/esm/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadParticlesLinksInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { loadLinksInteraction } = await import("./interaction.js"), { loadLinksPlugin } = await import("./plugin.js");
|
|
5
|
+
loadLinksInteraction(e);
|
|
6
|
+
loadLinksPlugin(e);
|
|
7
|
+
});
|
|
7
8
|
}
|
|
8
9
|
export * from "./Options/Classes/Links.js";
|
|
9
10
|
export * from "./Options/Classes/LinksShadow.js";
|
|
10
11
|
export * from "./Options/Classes/LinksTriangle.js";
|
|
11
|
-
export * from "./Options/Interfaces/ILinks.js";
|
|
12
|
-
export * from "./Options/Interfaces/ILinksShadow.js";
|
|
13
|
-
export * from "./Options/Interfaces/ILinksTriangle.js";
|
package/esm/interaction.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export function loadLinksInteraction(engine) {
|
|
2
|
+
engine.register(e => {
|
|
3
|
+
e.addInteractor("particlesLinks", async (container) => {
|
|
4
|
+
const { Linker } = await import("./Linker.js");
|
|
5
|
+
return new Linker(container, engine);
|
|
6
|
+
});
|
|
7
|
+
});
|
|
6
8
|
}
|
package/esm/plugin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export function loadLinksPlugin(engine) {
|
|
2
|
+
engine.register(async (e) => {
|
|
3
|
+
const { LinksPlugin } = await import("./LinksPlugin.js");
|
|
4
|
+
e.addPlugin(new LinksPlugin(e));
|
|
5
|
+
});
|
|
5
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-particles-links",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles links particles interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,9 +87,10 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "
|
|
90
|
+
"@tsparticles/engine": "4.0.0-alpha.0"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
|
+
"type": "module"
|
|
95
96
|
}
|