@tsparticles/interaction-particles-links 3.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/LICENSE +21 -0
- package/README.md +69 -0
- package/browser/CircleWarp.js +50 -0
- package/browser/ILink.js +1 -0
- package/browser/LinkContainer.js +1 -0
- package/browser/LinkInstance.js +143 -0
- package/browser/LinkParticle.js +1 -0
- package/browser/Linker.js +119 -0
- package/browser/Options/Classes/Links.js +54 -0
- package/browser/Options/Classes/LinksShadow.js +21 -0
- package/browser/Options/Classes/LinksTriangle.js +24 -0
- package/browser/Options/Classes/ParticlesLinkOptions.js +1 -0
- package/browser/Options/Interfaces/ILinks.js +1 -0
- package/browser/Options/Interfaces/ILinksShadow.js +1 -0
- package/browser/Options/Interfaces/ILinksTriangle.js +1 -0
- package/browser/Options/Interfaces/IParticlesLinkOptions.js +1 -0
- package/browser/Utils.js +77 -0
- package/browser/index.js +12 -0
- package/browser/interaction.js +4 -0
- package/browser/plugin.js +18 -0
- package/cjs/CircleWarp.js +54 -0
- package/cjs/ILink.js +2 -0
- package/cjs/LinkContainer.js +2 -0
- package/cjs/LinkInstance.js +158 -0
- package/cjs/LinkParticle.js +2 -0
- package/cjs/Linker.js +134 -0
- package/cjs/Options/Classes/Links.js +58 -0
- package/cjs/Options/Classes/LinksShadow.js +25 -0
- package/cjs/Options/Classes/LinksTriangle.js +28 -0
- package/cjs/Options/Classes/ParticlesLinkOptions.js +2 -0
- package/cjs/Options/Interfaces/ILinks.js +2 -0
- package/cjs/Options/Interfaces/ILinksShadow.js +2 -0
- package/cjs/Options/Interfaces/ILinksTriangle.js +2 -0
- package/cjs/Options/Interfaces/IParticlesLinkOptions.js +2 -0
- package/cjs/Utils.js +82 -0
- package/cjs/index.js +41 -0
- package/cjs/interaction.js +19 -0
- package/cjs/plugin.js +33 -0
- package/esm/CircleWarp.js +50 -0
- package/esm/ILink.js +1 -0
- package/esm/LinkContainer.js +1 -0
- package/esm/LinkInstance.js +143 -0
- package/esm/LinkParticle.js +1 -0
- package/esm/Linker.js +119 -0
- package/esm/Options/Classes/Links.js +54 -0
- package/esm/Options/Classes/LinksShadow.js +21 -0
- package/esm/Options/Classes/LinksTriangle.js +24 -0
- package/esm/Options/Classes/ParticlesLinkOptions.js +1 -0
- package/esm/Options/Interfaces/ILinks.js +1 -0
- package/esm/Options/Interfaces/ILinksShadow.js +1 -0
- package/esm/Options/Interfaces/ILinksTriangle.js +1 -0
- package/esm/Options/Interfaces/IParticlesLinkOptions.js +1 -0
- package/esm/Utils.js +77 -0
- package/esm/index.js +12 -0
- package/esm/interaction.js +4 -0
- package/esm/plugin.js +18 -0
- package/package.json +82 -0
- package/report.html +39 -0
- package/tsparticles.interaction.particles.links.js +658 -0
- package/tsparticles.interaction.particles.links.min.js +2 -0
- package/tsparticles.interaction.particles.links.min.js.LICENSE.txt +8 -0
- package/types/CircleWarp.d.ts +8 -0
- package/types/ILink.d.ts +9 -0
- package/types/LinkContainer.d.ts +7 -0
- package/types/LinkInstance.d.ts +17 -0
- package/types/LinkParticle.d.ts +11 -0
- package/types/Linker.d.ts +17 -0
- package/types/Options/Classes/Links.d.ts +21 -0
- package/types/Options/Classes/LinksShadow.d.ts +10 -0
- package/types/Options/Classes/LinksTriangle.d.ts +11 -0
- package/types/Options/Classes/ParticlesLinkOptions.d.ts +5 -0
- package/types/Options/Interfaces/ILinks.d.ts +17 -0
- package/types/Options/Interfaces/ILinksShadow.d.ts +6 -0
- package/types/Options/Interfaces/ILinksTriangle.d.ts +7 -0
- package/types/Options/Interfaces/IParticlesLinkOptions.d.ts +7 -0
- package/types/Utils.d.ts +4 -0
- package/types/index.d.ts +8 -0
- package/types/interaction.d.ts +2 -0
- package/types/plugin.d.ts +2 -0
- package/umd/CircleWarp.js +64 -0
- package/umd/ILink.js +12 -0
- package/umd/LinkContainer.js +12 -0
- package/umd/LinkInstance.js +157 -0
- package/umd/LinkParticle.js +12 -0
- package/umd/Linker.js +133 -0
- package/umd/Options/Classes/Links.js +68 -0
- package/umd/Options/Classes/LinksShadow.js +35 -0
- package/umd/Options/Classes/LinksTriangle.js +38 -0
- package/umd/Options/Classes/ParticlesLinkOptions.js +12 -0
- package/umd/Options/Interfaces/ILinks.js +12 -0
- package/umd/Options/Interfaces/ILinksShadow.js +12 -0
- package/umd/Options/Interfaces/ILinksTriangle.js +12 -0
- package/umd/Options/Interfaces/IParticlesLinkOptions.js +12 -0
- package/umd/Utils.js +92 -0
- package/umd/index.js +40 -0
- package/umd/interaction.js +18 -0
- package/umd/plugin.js +32 -0
|
@@ -0,0 +1,658 @@
|
|
|
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
|
+
* v3.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
11
|
+
module.exports = factory(require("@tsparticles/engine"));
|
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
|
13
|
+
define(["@tsparticles/engine"], factory);
|
|
14
|
+
else {
|
|
15
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
|
+
}
|
|
18
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
|
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
|
20
|
+
/******/ "use strict";
|
|
21
|
+
/******/ var __webpack_modules__ = ({
|
|
22
|
+
|
|
23
|
+
/***/ 533:
|
|
24
|
+
/***/ ((module) => {
|
|
25
|
+
|
|
26
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
/******/ });
|
|
31
|
+
/************************************************************************/
|
|
32
|
+
/******/ // The module cache
|
|
33
|
+
/******/ var __webpack_module_cache__ = {};
|
|
34
|
+
/******/
|
|
35
|
+
/******/ // The require function
|
|
36
|
+
/******/ function __webpack_require__(moduleId) {
|
|
37
|
+
/******/ // Check if module is in cache
|
|
38
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
39
|
+
/******/ if (cachedModule !== undefined) {
|
|
40
|
+
/******/ return cachedModule.exports;
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ // Create a new module (and put it into the cache)
|
|
43
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
44
|
+
/******/ // no module.id needed
|
|
45
|
+
/******/ // no module.loaded needed
|
|
46
|
+
/******/ exports: {}
|
|
47
|
+
/******/ };
|
|
48
|
+
/******/
|
|
49
|
+
/******/ // Execute the module function
|
|
50
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // Return the exports of the module
|
|
53
|
+
/******/ return module.exports;
|
|
54
|
+
/******/ }
|
|
55
|
+
/******/
|
|
56
|
+
/************************************************************************/
|
|
57
|
+
/******/ /* webpack/runtime/define property getters */
|
|
58
|
+
/******/ (() => {
|
|
59
|
+
/******/ // define getter functions for harmony exports
|
|
60
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
61
|
+
/******/ for(var key in definition) {
|
|
62
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
63
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
64
|
+
/******/ }
|
|
65
|
+
/******/ }
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/ })();
|
|
68
|
+
/******/
|
|
69
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
|
+
/******/ (() => {
|
|
71
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
|
+
/******/ })();
|
|
73
|
+
/******/
|
|
74
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
75
|
+
/******/ (() => {
|
|
76
|
+
/******/ // define __esModule on exports
|
|
77
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
78
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
79
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
80
|
+
/******/ }
|
|
81
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
82
|
+
/******/ };
|
|
83
|
+
/******/ })();
|
|
84
|
+
/******/
|
|
85
|
+
/************************************************************************/
|
|
86
|
+
var __webpack_exports__ = {};
|
|
87
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
88
|
+
(() => {
|
|
89
|
+
// ESM COMPAT FLAG
|
|
90
|
+
__webpack_require__.r(__webpack_exports__);
|
|
91
|
+
|
|
92
|
+
// EXPORTS
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
+
"Links": () => (/* reexport */ Links),
|
|
95
|
+
"LinksShadow": () => (/* reexport */ LinksShadow),
|
|
96
|
+
"LinksTriangle": () => (/* reexport */ LinksTriangle),
|
|
97
|
+
"loadParticlesLinksInteraction": () => (/* binding */ loadParticlesLinksInteraction)
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
101
|
+
var engine_root_window_ = __webpack_require__(533);
|
|
102
|
+
;// CONCATENATED MODULE: ./dist/browser/CircleWarp.js
|
|
103
|
+
|
|
104
|
+
class CircleWarp extends engine_root_window_.Circle {
|
|
105
|
+
constructor(x, y, radius, canvasSize) {
|
|
106
|
+
super(x, y, radius);
|
|
107
|
+
this.canvasSize = canvasSize;
|
|
108
|
+
this.canvasSize = Object.assign({}, canvasSize);
|
|
109
|
+
}
|
|
110
|
+
contains(point) {
|
|
111
|
+
if (super.contains(point)) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const posNE = {
|
|
115
|
+
x: point.x - this.canvasSize.width,
|
|
116
|
+
y: point.y
|
|
117
|
+
};
|
|
118
|
+
if (super.contains(posNE)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
const posSE = {
|
|
122
|
+
x: point.x - this.canvasSize.width,
|
|
123
|
+
y: point.y - this.canvasSize.height
|
|
124
|
+
};
|
|
125
|
+
if (super.contains(posSE)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
const posSW = {
|
|
129
|
+
x: point.x,
|
|
130
|
+
y: point.y - this.canvasSize.height
|
|
131
|
+
};
|
|
132
|
+
return super.contains(posSW);
|
|
133
|
+
}
|
|
134
|
+
intersects(range) {
|
|
135
|
+
if (super.intersects(range)) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
const rect = range,
|
|
139
|
+
circle = range,
|
|
140
|
+
newPos = {
|
|
141
|
+
x: range.position.x - this.canvasSize.width,
|
|
142
|
+
y: range.position.y - this.canvasSize.height
|
|
143
|
+
};
|
|
144
|
+
if (circle.radius !== undefined) {
|
|
145
|
+
const biggerCircle = new engine_root_window_.Circle(newPos.x, newPos.y, circle.radius * 2);
|
|
146
|
+
return super.intersects(biggerCircle);
|
|
147
|
+
} else if (rect.size !== undefined) {
|
|
148
|
+
const rectSW = new engine_root_window_.Rectangle(newPos.x, newPos.y, rect.size.width * 2, rect.size.height * 2);
|
|
149
|
+
return super.intersects(rectSW);
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/LinksShadow.js
|
|
155
|
+
|
|
156
|
+
class LinksShadow {
|
|
157
|
+
constructor() {
|
|
158
|
+
this.blur = 5;
|
|
159
|
+
this.color = new engine_root_window_.OptionsColor();
|
|
160
|
+
this.color.value = "#000";
|
|
161
|
+
this.enable = false;
|
|
162
|
+
}
|
|
163
|
+
load(data) {
|
|
164
|
+
if (!data) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (data.blur !== undefined) {
|
|
168
|
+
this.blur = data.blur;
|
|
169
|
+
}
|
|
170
|
+
this.color = engine_root_window_.OptionsColor.create(this.color, data.color);
|
|
171
|
+
if (data.enable !== undefined) {
|
|
172
|
+
this.enable = data.enable;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/LinksTriangle.js
|
|
177
|
+
|
|
178
|
+
class LinksTriangle {
|
|
179
|
+
constructor() {
|
|
180
|
+
this.enable = false;
|
|
181
|
+
this.frequency = 1;
|
|
182
|
+
}
|
|
183
|
+
load(data) {
|
|
184
|
+
if (!data) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (data.color !== undefined) {
|
|
188
|
+
this.color = engine_root_window_.OptionsColor.create(this.color, data.color);
|
|
189
|
+
}
|
|
190
|
+
if (data.enable !== undefined) {
|
|
191
|
+
this.enable = data.enable;
|
|
192
|
+
}
|
|
193
|
+
if (data.frequency !== undefined) {
|
|
194
|
+
this.frequency = data.frequency;
|
|
195
|
+
}
|
|
196
|
+
if (data.opacity !== undefined) {
|
|
197
|
+
this.opacity = data.opacity;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Links.js
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class Links {
|
|
206
|
+
constructor() {
|
|
207
|
+
this.blink = false;
|
|
208
|
+
this.color = new engine_root_window_.OptionsColor();
|
|
209
|
+
this.color.value = "#fff";
|
|
210
|
+
this.consent = false;
|
|
211
|
+
this.distance = 100;
|
|
212
|
+
this.enable = false;
|
|
213
|
+
this.frequency = 1;
|
|
214
|
+
this.opacity = 1;
|
|
215
|
+
this.shadow = new LinksShadow();
|
|
216
|
+
this.triangles = new LinksTriangle();
|
|
217
|
+
this.width = 1;
|
|
218
|
+
this.warp = false;
|
|
219
|
+
}
|
|
220
|
+
load(data) {
|
|
221
|
+
if (!data) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (data.id !== undefined) {
|
|
225
|
+
this.id = data.id;
|
|
226
|
+
}
|
|
227
|
+
if (data.blink !== undefined) {
|
|
228
|
+
this.blink = data.blink;
|
|
229
|
+
}
|
|
230
|
+
this.color = engine_root_window_.OptionsColor.create(this.color, data.color);
|
|
231
|
+
if (data.consent !== undefined) {
|
|
232
|
+
this.consent = data.consent;
|
|
233
|
+
}
|
|
234
|
+
if (data.distance !== undefined) {
|
|
235
|
+
this.distance = data.distance;
|
|
236
|
+
}
|
|
237
|
+
if (data.enable !== undefined) {
|
|
238
|
+
this.enable = data.enable;
|
|
239
|
+
}
|
|
240
|
+
if (data.frequency !== undefined) {
|
|
241
|
+
this.frequency = data.frequency;
|
|
242
|
+
}
|
|
243
|
+
if (data.opacity !== undefined) {
|
|
244
|
+
this.opacity = data.opacity;
|
|
245
|
+
}
|
|
246
|
+
this.shadow.load(data.shadow);
|
|
247
|
+
this.triangles.load(data.triangles);
|
|
248
|
+
if (data.width !== undefined) {
|
|
249
|
+
this.width = data.width;
|
|
250
|
+
}
|
|
251
|
+
if (data.warp !== undefined) {
|
|
252
|
+
this.warp = data.warp;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
;// CONCATENATED MODULE: ./dist/browser/Linker.js
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
function getLinkDistance(pos1, pos2, optDistance, canvasSize, warp) {
|
|
261
|
+
let distance = (0,engine_root_window_.getDistance)(pos1, pos2);
|
|
262
|
+
if (!warp || distance <= optDistance) {
|
|
263
|
+
return distance;
|
|
264
|
+
}
|
|
265
|
+
const pos2NE = {
|
|
266
|
+
x: pos2.x - canvasSize.width,
|
|
267
|
+
y: pos2.y
|
|
268
|
+
};
|
|
269
|
+
distance = (0,engine_root_window_.getDistance)(pos1, pos2NE);
|
|
270
|
+
if (distance <= optDistance) {
|
|
271
|
+
return distance;
|
|
272
|
+
}
|
|
273
|
+
const pos2SE = {
|
|
274
|
+
x: pos2.x - canvasSize.width,
|
|
275
|
+
y: pos2.y - canvasSize.height
|
|
276
|
+
};
|
|
277
|
+
distance = (0,engine_root_window_.getDistance)(pos1, pos2SE);
|
|
278
|
+
if (distance <= optDistance) {
|
|
279
|
+
return distance;
|
|
280
|
+
}
|
|
281
|
+
const pos2SW = {
|
|
282
|
+
x: pos2.x,
|
|
283
|
+
y: pos2.y - canvasSize.height
|
|
284
|
+
};
|
|
285
|
+
distance = (0,engine_root_window_.getDistance)(pos1, pos2SW);
|
|
286
|
+
return distance;
|
|
287
|
+
}
|
|
288
|
+
class Linker extends engine_root_window_.ParticlesInteractorBase {
|
|
289
|
+
constructor(container) {
|
|
290
|
+
super(container);
|
|
291
|
+
this.linkContainer = container;
|
|
292
|
+
}
|
|
293
|
+
clear() {}
|
|
294
|
+
init() {
|
|
295
|
+
this.linkContainer.particles.linksColor = undefined;
|
|
296
|
+
this.linkContainer.particles.linksColors = new Map();
|
|
297
|
+
}
|
|
298
|
+
async interact(p1) {
|
|
299
|
+
var _a;
|
|
300
|
+
if (!p1.options.links) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
p1.links = [];
|
|
304
|
+
const pos1 = p1.getPosition(),
|
|
305
|
+
container = this.container,
|
|
306
|
+
canvasSize = container.canvas.size;
|
|
307
|
+
if (pos1.x < 0 || pos1.y < 0 || pos1.x > canvasSize.width || pos1.y > canvasSize.height) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const linkOpt1 = p1.options.links,
|
|
311
|
+
optOpacity = linkOpt1.opacity,
|
|
312
|
+
optDistance = (_a = p1.retina.linksDistance) !== null && _a !== void 0 ? _a : 0,
|
|
313
|
+
warp = linkOpt1.warp,
|
|
314
|
+
range = warp ? new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize) : new engine_root_window_.Circle(pos1.x, pos1.y, optDistance),
|
|
315
|
+
query = container.particles.quadTree.query(range);
|
|
316
|
+
for (const p2 of query) {
|
|
317
|
+
const linkOpt2 = p2.options.links;
|
|
318
|
+
if (p1 === p2 || !(linkOpt2 === null || linkOpt2 === void 0 ? void 0 : linkOpt2.enable) || linkOpt1.id !== linkOpt2.id || p2.spawning || p2.destroyed || !p2.links || p1.links.map(t => t.destination).indexOf(p2) !== -1 || p2.links.map(t => t.destination).indexOf(p1) !== -1) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const pos2 = p2.getPosition();
|
|
322
|
+
if (pos2.x < 0 || pos2.y < 0 || pos2.x > canvasSize.width || pos2.y > canvasSize.height) {
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
const distance = getLinkDistance(pos1, pos2, optDistance, canvasSize, warp && linkOpt2.warp);
|
|
326
|
+
if (distance > optDistance) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const opacityLine = (1 - distance / optDistance) * optOpacity;
|
|
330
|
+
this.setColor(p1);
|
|
331
|
+
p1.links.push({
|
|
332
|
+
destination: p2,
|
|
333
|
+
opacity: opacityLine
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
isEnabled(particle) {
|
|
338
|
+
var _a;
|
|
339
|
+
return !!((_a = particle.options.links) === null || _a === void 0 ? void 0 : _a.enable);
|
|
340
|
+
}
|
|
341
|
+
loadParticlesOptions(options, ...sources) {
|
|
342
|
+
var _a, _b;
|
|
343
|
+
if (!options.links) {
|
|
344
|
+
options.links = new Links();
|
|
345
|
+
}
|
|
346
|
+
for (const source of sources) {
|
|
347
|
+
options.links.load((_b = (_a = source === null || source === void 0 ? void 0 : source.links) !== null && _a !== void 0 ? _a : source === null || source === void 0 ? void 0 : source.lineLinked) !== null && _b !== void 0 ? _b : source === null || source === void 0 ? void 0 : source.line_linked);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
reset() {}
|
|
351
|
+
setColor(p1) {
|
|
352
|
+
if (!p1.options.links) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const container = this.linkContainer,
|
|
356
|
+
linksOptions = p1.options.links;
|
|
357
|
+
let linkColor = linksOptions.id === undefined ? container.particles.linksColor : container.particles.linksColors.get(linksOptions.id);
|
|
358
|
+
if (linkColor) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const optColor = linksOptions.color;
|
|
362
|
+
linkColor = (0,engine_root_window_.getLinkRandomColor)(optColor, linksOptions.blink, linksOptions.consent);
|
|
363
|
+
if (linksOptions.id === undefined) {
|
|
364
|
+
container.particles.linksColor = linkColor;
|
|
365
|
+
} else {
|
|
366
|
+
container.particles.linksColors.set(linksOptions.id, linkColor);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
;// CONCATENATED MODULE: ./dist/browser/interaction.js
|
|
371
|
+
|
|
372
|
+
async function loadInteraction(engine) {
|
|
373
|
+
await engine.addInteractor("particlesLinks", container => new Linker(container));
|
|
374
|
+
}
|
|
375
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
376
|
+
|
|
377
|
+
function drawLinkLine(context, width, begin, end, maxDistance, canvasSize, warp, backgroundMask, composite, colorLine, opacity, shadow) {
|
|
378
|
+
let drawn = false;
|
|
379
|
+
if ((0,engine_root_window_.getDistance)(begin, end) <= maxDistance) {
|
|
380
|
+
(0,engine_root_window_.drawLine)(context, begin, end);
|
|
381
|
+
drawn = true;
|
|
382
|
+
} else if (warp) {
|
|
383
|
+
let pi1;
|
|
384
|
+
let pi2;
|
|
385
|
+
const endNE = {
|
|
386
|
+
x: end.x - canvasSize.width,
|
|
387
|
+
y: end.y
|
|
388
|
+
};
|
|
389
|
+
const d1 = (0,engine_root_window_.getDistances)(begin, endNE);
|
|
390
|
+
if (d1.distance <= maxDistance) {
|
|
391
|
+
const yi = begin.y - d1.dy / d1.dx * begin.x;
|
|
392
|
+
pi1 = {
|
|
393
|
+
x: 0,
|
|
394
|
+
y: yi
|
|
395
|
+
};
|
|
396
|
+
pi2 = {
|
|
397
|
+
x: canvasSize.width,
|
|
398
|
+
y: yi
|
|
399
|
+
};
|
|
400
|
+
} else {
|
|
401
|
+
const endSW = {
|
|
402
|
+
x: end.x,
|
|
403
|
+
y: end.y - canvasSize.height
|
|
404
|
+
};
|
|
405
|
+
const d2 = (0,engine_root_window_.getDistances)(begin, endSW);
|
|
406
|
+
if (d2.distance <= maxDistance) {
|
|
407
|
+
const yi = begin.y - d2.dy / d2.dx * begin.x;
|
|
408
|
+
const xi = -yi / (d2.dy / d2.dx);
|
|
409
|
+
pi1 = {
|
|
410
|
+
x: xi,
|
|
411
|
+
y: 0
|
|
412
|
+
};
|
|
413
|
+
pi2 = {
|
|
414
|
+
x: xi,
|
|
415
|
+
y: canvasSize.height
|
|
416
|
+
};
|
|
417
|
+
} else {
|
|
418
|
+
const endSE = {
|
|
419
|
+
x: end.x - canvasSize.width,
|
|
420
|
+
y: end.y - canvasSize.height
|
|
421
|
+
};
|
|
422
|
+
const d3 = (0,engine_root_window_.getDistances)(begin, endSE);
|
|
423
|
+
if (d3.distance <= maxDistance) {
|
|
424
|
+
const yi = begin.y - d3.dy / d3.dx * begin.x;
|
|
425
|
+
const xi = -yi / (d3.dy / d3.dx);
|
|
426
|
+
pi1 = {
|
|
427
|
+
x: xi,
|
|
428
|
+
y: yi
|
|
429
|
+
};
|
|
430
|
+
pi2 = {
|
|
431
|
+
x: pi1.x + canvasSize.width,
|
|
432
|
+
y: pi1.y + canvasSize.height
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (pi1 && pi2) {
|
|
438
|
+
(0,engine_root_window_.drawLine)(context, begin, pi1);
|
|
439
|
+
(0,engine_root_window_.drawLine)(context, end, pi2);
|
|
440
|
+
drawn = true;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (!drawn) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
context.lineWidth = width;
|
|
447
|
+
if (backgroundMask) {
|
|
448
|
+
context.globalCompositeOperation = composite;
|
|
449
|
+
}
|
|
450
|
+
context.strokeStyle = (0,engine_root_window_.getStyleFromRgb)(colorLine, opacity);
|
|
451
|
+
if (shadow.enable) {
|
|
452
|
+
const shadowColor = (0,engine_root_window_.rangeColorToRgb)(shadow.color);
|
|
453
|
+
if (shadowColor) {
|
|
454
|
+
context.shadowBlur = shadow.blur;
|
|
455
|
+
context.shadowColor = (0,engine_root_window_.getStyleFromRgb)(shadowColor);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
context.stroke();
|
|
459
|
+
}
|
|
460
|
+
function drawLinkTriangle(context, pos1, pos2, pos3, backgroundMask, composite, colorTriangle, opacityTriangle) {
|
|
461
|
+
(0,engine_root_window_.drawTriangle)(context, pos1, pos2, pos3);
|
|
462
|
+
if (backgroundMask) {
|
|
463
|
+
context.globalCompositeOperation = composite;
|
|
464
|
+
}
|
|
465
|
+
context.fillStyle = (0,engine_root_window_.getStyleFromRgb)(colorTriangle, opacityTriangle);
|
|
466
|
+
context.fill();
|
|
467
|
+
}
|
|
468
|
+
;// CONCATENATED MODULE: ./dist/browser/LinkInstance.js
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
function getLinkKey(ids) {
|
|
472
|
+
ids.sort((a, b) => a - b);
|
|
473
|
+
return ids.join("_");
|
|
474
|
+
}
|
|
475
|
+
function setLinkFrequency(particles, dictionary) {
|
|
476
|
+
const key = getLinkKey(particles.map(t => t.id));
|
|
477
|
+
let res = dictionary.get(key);
|
|
478
|
+
if (res === undefined) {
|
|
479
|
+
res = (0,engine_root_window_.getRandom)();
|
|
480
|
+
dictionary.set(key, res);
|
|
481
|
+
}
|
|
482
|
+
return res;
|
|
483
|
+
}
|
|
484
|
+
class LinkInstance {
|
|
485
|
+
constructor(container) {
|
|
486
|
+
this.container = container;
|
|
487
|
+
this._freqs = {
|
|
488
|
+
links: new Map(),
|
|
489
|
+
triangles: new Map()
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
drawParticle(context, particle) {
|
|
493
|
+
var _a;
|
|
494
|
+
const pOptions = particle.options;
|
|
495
|
+
if (!particle.links || particle.links.length <= 0) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
const p1Links = particle.links.filter(l => pOptions.links && this.getLinkFrequency(particle, l.destination) <= pOptions.links.frequency);
|
|
499
|
+
for (const link of p1Links) {
|
|
500
|
+
this.drawTriangles(pOptions, particle, link, p1Links);
|
|
501
|
+
if (link.opacity > 0 && ((_a = particle.retina.linksWidth) !== null && _a !== void 0 ? _a : 0) > 0) {
|
|
502
|
+
this.drawLinkLine(particle, link);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
async init() {
|
|
507
|
+
this._freqs.links = new Map();
|
|
508
|
+
this._freqs.triangles = new Map();
|
|
509
|
+
}
|
|
510
|
+
particleCreated(particle) {
|
|
511
|
+
particle.links = [];
|
|
512
|
+
if (!particle.options.links) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const ratio = this.container.retina.pixelRatio;
|
|
516
|
+
particle.retina.linksDistance = particle.options.links.distance * ratio;
|
|
517
|
+
particle.retina.linksWidth = particle.options.links.width * ratio;
|
|
518
|
+
}
|
|
519
|
+
particleDestroyed(particle) {
|
|
520
|
+
particle.links = [];
|
|
521
|
+
}
|
|
522
|
+
drawLinkLine(p1, link) {
|
|
523
|
+
const container = this.container,
|
|
524
|
+
options = container.actualOptions,
|
|
525
|
+
p2 = link.destination,
|
|
526
|
+
pos1 = p1.getPosition(),
|
|
527
|
+
pos2 = p2.getPosition();
|
|
528
|
+
let opacity = link.opacity;
|
|
529
|
+
container.canvas.draw(ctx => {
|
|
530
|
+
var _a, _b, _c;
|
|
531
|
+
if (!p1.options.links) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
let colorLine;
|
|
535
|
+
const twinkle = (_a = p1.options.twinkle) === null || _a === void 0 ? void 0 : _a.lines;
|
|
536
|
+
if (twinkle === null || twinkle === void 0 ? void 0 : twinkle.enable) {
|
|
537
|
+
const twinkleFreq = twinkle.frequency,
|
|
538
|
+
twinkleRgb = (0,engine_root_window_.rangeColorToRgb)(twinkle.color),
|
|
539
|
+
twinkling = (0,engine_root_window_.getRandom)() < twinkleFreq;
|
|
540
|
+
if (twinkling && twinkleRgb) {
|
|
541
|
+
colorLine = twinkleRgb;
|
|
542
|
+
opacity = (0,engine_root_window_.getRangeValue)(twinkle.opacity);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (!colorLine) {
|
|
546
|
+
const linksOptions = p1.options.links,
|
|
547
|
+
linkColor = (linksOptions === null || linksOptions === void 0 ? void 0 : linksOptions.id) !== undefined ? container.particles.linksColors.get(linksOptions.id) : container.particles.linksColor;
|
|
548
|
+
colorLine = (0,engine_root_window_.getLinkColor)(p1, p2, linkColor);
|
|
549
|
+
}
|
|
550
|
+
if (!colorLine) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
const width = (_b = p1.retina.linksWidth) !== null && _b !== void 0 ? _b : 0,
|
|
554
|
+
maxDistance = (_c = p1.retina.linksDistance) !== null && _c !== void 0 ? _c : 0;
|
|
555
|
+
drawLinkLine(ctx, width, pos1, pos2, maxDistance, container.canvas.size, p1.options.links.warp, options.backgroundMask.enable, options.backgroundMask.composite, colorLine, opacity, p1.options.links.shadow);
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
drawLinkTriangle(p1, link1, link2) {
|
|
559
|
+
var _a;
|
|
560
|
+
if (!p1.options.links) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const container = this.container,
|
|
564
|
+
options = container.actualOptions,
|
|
565
|
+
p2 = link1.destination,
|
|
566
|
+
p3 = link2.destination,
|
|
567
|
+
triangleOptions = p1.options.links.triangles,
|
|
568
|
+
opacityTriangle = (_a = triangleOptions.opacity) !== null && _a !== void 0 ? _a : (link1.opacity + link2.opacity) / 2;
|
|
569
|
+
if (opacityTriangle <= 0) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
container.canvas.draw(ctx => {
|
|
573
|
+
var _a;
|
|
574
|
+
const pos1 = p1.getPosition(),
|
|
575
|
+
pos2 = p2.getPosition(),
|
|
576
|
+
pos3 = p3.getPosition(),
|
|
577
|
+
linksDistance = (_a = p1.retina.linksDistance) !== null && _a !== void 0 ? _a : 0;
|
|
578
|
+
if ((0,engine_root_window_.getDistance)(pos1, pos2) > linksDistance || (0,engine_root_window_.getDistance)(pos3, pos2) > linksDistance || (0,engine_root_window_.getDistance)(pos3, pos1) > linksDistance) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
let colorTriangle = (0,engine_root_window_.rangeColorToRgb)(triangleOptions.color);
|
|
582
|
+
if (!colorTriangle) {
|
|
583
|
+
const linksOptions = p1.options.links,
|
|
584
|
+
linkColor = (linksOptions === null || linksOptions === void 0 ? void 0 : linksOptions.id) !== undefined ? container.particles.linksColors.get(linksOptions.id) : container.particles.linksColor;
|
|
585
|
+
colorTriangle = (0,engine_root_window_.getLinkColor)(p1, p2, linkColor);
|
|
586
|
+
}
|
|
587
|
+
if (!colorTriangle) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
drawLinkTriangle(ctx, pos1, pos2, pos3, options.backgroundMask.enable, options.backgroundMask.composite, colorTriangle, opacityTriangle);
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
drawTriangles(options, p1, link, p1Links) {
|
|
594
|
+
var _a, _b, _c;
|
|
595
|
+
const p2 = link.destination;
|
|
596
|
+
if (!(((_a = options.links) === null || _a === void 0 ? void 0 : _a.triangles.enable) && ((_b = p2.options.links) === null || _b === void 0 ? void 0 : _b.triangles.enable))) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const vertices = (_c = p2.links) === null || _c === void 0 ? void 0 : _c.filter(t => {
|
|
600
|
+
const linkFreq = this.getLinkFrequency(p2, t.destination);
|
|
601
|
+
return p2.options.links && linkFreq <= p2.options.links.frequency && p1Links.findIndex(l => l.destination === t.destination) >= 0;
|
|
602
|
+
});
|
|
603
|
+
if (!(vertices === null || vertices === void 0 ? void 0 : vertices.length)) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
for (const vertex of vertices) {
|
|
607
|
+
const p3 = vertex.destination,
|
|
608
|
+
triangleFreq = this.getTriangleFrequency(p1, p2, p3);
|
|
609
|
+
if (triangleFreq > options.links.triangles.frequency) {
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
this.drawLinkTriangle(p1, link, vertex);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
getLinkFrequency(p1, p2) {
|
|
616
|
+
return setLinkFrequency([p1, p2], this._freqs.links);
|
|
617
|
+
}
|
|
618
|
+
getTriangleFrequency(p1, p2, p3) {
|
|
619
|
+
return setLinkFrequency([p1, p2, p3], this._freqs.triangles);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
;// CONCATENATED MODULE: ./dist/browser/plugin.js
|
|
623
|
+
|
|
624
|
+
class LinksPlugin {
|
|
625
|
+
constructor() {
|
|
626
|
+
this.id = "links";
|
|
627
|
+
}
|
|
628
|
+
getPlugin(container) {
|
|
629
|
+
return new LinkInstance(container);
|
|
630
|
+
}
|
|
631
|
+
loadOptions() {}
|
|
632
|
+
needsPlugin() {
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
async function loadPlugin(engine) {
|
|
637
|
+
const plugin = new LinksPlugin();
|
|
638
|
+
await engine.addPlugin(plugin);
|
|
639
|
+
}
|
|
640
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
async function loadParticlesLinksInteraction(engine) {
|
|
644
|
+
await loadInteraction(engine);
|
|
645
|
+
await loadPlugin(engine);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
})();
|
|
654
|
+
|
|
655
|
+
/******/ return __webpack_exports__;
|
|
656
|
+
/******/ })()
|
|
657
|
+
;
|
|
658
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.interaction.particles.links.min.js.LICENSE.txt */
|
|
2
|
+
!function(i,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var n="object"==typeof exports?t(require("@tsparticles/engine")):t(i.window);for(var e in n)("object"==typeof exports?exports:i)[e]=n[e]}}(this,(i=>(()=>{"use strict";var t={533:t=>{t.exports=i}},n={};function e(i){var s=n[i];if(void 0!==s)return s.exports;var o=n[i]={exports:{}};return t[i](o,o.exports,e),o.exports}e.d=(i,t)=>{for(var n in t)e.o(t,n)&&!e.o(i,n)&&Object.defineProperty(i,n,{enumerable:!0,get:t[n]})},e.o=(i,t)=>Object.prototype.hasOwnProperty.call(i,t),e.r=i=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var s={};return(()=>{e.r(s),e.d(s,{Links:()=>r,LinksShadow:()=>n,LinksTriangle:()=>o,loadParticlesLinksInteraction:()=>h});var i=e(533);class t extends i.Circle{constructor(i,t,n,e){super(i,t,n),this.canvasSize=e,this.canvasSize=Object.assign({},e)}contains(i){if(super.contains(i))return!0;const t={x:i.x-this.canvasSize.width,y:i.y};if(super.contains(t))return!0;const n={x:i.x-this.canvasSize.width,y:i.y-this.canvasSize.height};if(super.contains(n))return!0;const e={x:i.x,y:i.y-this.canvasSize.height};return super.contains(e)}intersects(t){if(super.intersects(t))return!0;const n=t,e=t,s={x:t.position.x-this.canvasSize.width,y:t.position.y-this.canvasSize.height};if(void 0!==e.radius){const t=new i.Circle(s.x,s.y,2*e.radius);return super.intersects(t)}if(void 0!==n.size){const t=new i.Rectangle(s.x,s.y,2*n.size.width,2*n.size.height);return super.intersects(t)}return!1}}class n{constructor(){this.blur=5,this.color=new i.OptionsColor,this.color.value="#000",this.enable=!1}load(t){t&&(void 0!==t.blur&&(this.blur=t.blur),this.color=i.OptionsColor.create(this.color,t.color),void 0!==t.enable&&(this.enable=t.enable))}}class o{constructor(){this.enable=!1,this.frequency=1}load(t){t&&(void 0!==t.color&&(this.color=i.OptionsColor.create(this.color,t.color)),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.frequency&&(this.frequency=t.frequency),void 0!==t.opacity&&(this.opacity=t.opacity))}}class r{constructor(){this.blink=!1,this.color=new i.OptionsColor,this.color.value="#fff",this.consent=!1,this.distance=100,this.enable=!1,this.frequency=1,this.opacity=1,this.shadow=new n,this.triangles=new o,this.width=1,this.warp=!1}load(t){t&&(void 0!==t.id&&(this.id=t.id),void 0!==t.blink&&(this.blink=t.blink),this.color=i.OptionsColor.create(this.color,t.color),void 0!==t.consent&&(this.consent=t.consent),void 0!==t.distance&&(this.distance=t.distance),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.frequency&&(this.frequency=t.frequency),void 0!==t.opacity&&(this.opacity=t.opacity),this.shadow.load(t.shadow),this.triangles.load(t.triangles),void 0!==t.width&&(this.width=t.width),void 0!==t.warp&&(this.warp=t.warp))}}function l(t,n,e,s,o){let r=(0,i.getDistance)(t,n);if(!o||r<=e)return r;const l={x:n.x-s.width,y:n.y};if(r=(0,i.getDistance)(t,l),r<=e)return r;const a={x:n.x-s.width,y:n.y-s.height};if(r=(0,i.getDistance)(t,a),r<=e)return r;const c={x:n.x,y:n.y-s.height};return r=(0,i.getDistance)(t,c),r}class a extends i.ParticlesInteractorBase{constructor(i){super(i),this.linkContainer=i}clear(){}init(){this.linkContainer.particles.linksColor=void 0,this.linkContainer.particles.linksColors=new Map}async interact(n){var e;if(!n.options.links)return;n.links=[];const s=n.getPosition(),o=this.container,r=o.canvas.size;if(s.x<0||s.y<0||s.x>r.width||s.y>r.height)return;const a=n.options.links,c=a.opacity,d=null!==(e=n.retina.linksDistance)&&void 0!==e?e:0,u=a.warp,h=u?new t(s.x,s.y,d,r):new i.Circle(s.x,s.y,d),p=o.particles.quadTree.query(h);for(const i of p){const t=i.options.links;if(n===i||!(null==t?void 0:t.enable)||a.id!==t.id||i.spawning||i.destroyed||!i.links||-1!==n.links.map((i=>i.destination)).indexOf(i)||-1!==i.links.map((i=>i.destination)).indexOf(n))continue;const e=i.getPosition();if(e.x<0||e.y<0||e.x>r.width||e.y>r.height)continue;const o=l(s,e,d,r,u&&t.warp);if(o>d)return;const h=(1-o/d)*c;this.setColor(n),n.links.push({destination:i,opacity:h})}}isEnabled(i){var t;return!!(null===(t=i.options.links)||void 0===t?void 0:t.enable)}loadParticlesOptions(i,...t){var n,e;i.links||(i.links=new r);for(const s of t)i.links.load(null!==(e=null!==(n=null==s?void 0:s.links)&&void 0!==n?n:null==s?void 0:s.lineLinked)&&void 0!==e?e:null==s?void 0:s.line_linked)}reset(){}setColor(t){if(!t.options.links)return;const n=this.linkContainer,e=t.options.links;let s=void 0===e.id?n.particles.linksColor:n.particles.linksColors.get(e.id);if(s)return;const o=e.color;s=(0,i.getLinkRandomColor)(o,e.blink,e.consent),void 0===e.id?n.particles.linksColor=s:n.particles.linksColors.set(e.id,s)}}function c(t,n){const e=((s=t.map((i=>i.id))).sort(((i,t)=>i-t)),s.join("_"));var s;let o=n.get(e);return void 0===o&&(o=(0,i.getRandom)(),n.set(e,o)),o}class d{constructor(i){this.container=i,this._freqs={links:new Map,triangles:new Map}}drawParticle(i,t){var n;const e=t.options;if(!t.links||t.links.length<=0)return;const s=t.links.filter((i=>e.links&&this.getLinkFrequency(t,i.destination)<=e.links.frequency));for(const i of s)this.drawTriangles(e,t,i,s),i.opacity>0&&(null!==(n=t.retina.linksWidth)&&void 0!==n?n:0)>0&&this.drawLinkLine(t,i)}async init(){this._freqs.links=new Map,this._freqs.triangles=new Map}particleCreated(i){if(i.links=[],!i.options.links)return;const t=this.container.retina.pixelRatio;i.retina.linksDistance=i.options.links.distance*t,i.retina.linksWidth=i.options.links.width*t}particleDestroyed(i){i.links=[]}drawLinkLine(t,n){const e=this.container,s=e.actualOptions,o=n.destination,r=t.getPosition(),l=o.getPosition();let a=n.opacity;e.canvas.draw((n=>{var c,d,u;if(!t.options.links)return;let h;const p=null===(c=t.options.twinkle)||void 0===c?void 0:c.lines;if(null==p?void 0:p.enable){const t=p.frequency,n=(0,i.rangeColorToRgb)(p.color);(0,i.getRandom)()<t&&n&&(h=n,a=(0,i.getRangeValue)(p.opacity))}if(!h){const n=t.options.links,s=void 0!==(null==n?void 0:n.id)?e.particles.linksColors.get(n.id):e.particles.linksColor;h=(0,i.getLinkColor)(t,o,s)}if(!h)return;const y=null!==(d=t.retina.linksWidth)&&void 0!==d?d:0,g=null!==(u=t.retina.linksDistance)&&void 0!==u?u:0;!function(t,n,e,s,o,r,l,a,c,d,u,h){let p=!1;if((0,i.getDistance)(e,s)<=o)(0,i.drawLine)(t,e,s),p=!0;else if(l){let n,l;const a={x:s.x-r.width,y:s.y},c=(0,i.getDistances)(e,a);if(c.distance<=o){const i=e.y-c.dy/c.dx*e.x;n={x:0,y:i},l={x:r.width,y:i}}else{const t={x:s.x,y:s.y-r.height},a=(0,i.getDistances)(e,t);if(a.distance<=o){const i=-(e.y-a.dy/a.dx*e.x)/(a.dy/a.dx);n={x:i,y:0},l={x:i,y:r.height}}else{const t={x:s.x-r.width,y:s.y-r.height},a=(0,i.getDistances)(e,t);if(a.distance<=o){const i=e.y-a.dy/a.dx*e.x;n={x:-i/(a.dy/a.dx),y:i},l={x:n.x+r.width,y:n.y+r.height}}}}n&&l&&((0,i.drawLine)(t,e,n),(0,i.drawLine)(t,s,l),p=!0)}if(p){if(t.lineWidth=n,a&&(t.globalCompositeOperation=c),t.strokeStyle=(0,i.getStyleFromRgb)(d,u),h.enable){const n=(0,i.rangeColorToRgb)(h.color);n&&(t.shadowBlur=h.blur,t.shadowColor=(0,i.getStyleFromRgb)(n))}t.stroke()}}(n,y,r,l,g,e.canvas.size,t.options.links.warp,s.backgroundMask.enable,s.backgroundMask.composite,h,a,t.options.links.shadow)}))}drawLinkTriangle(t,n,e){var s;if(!t.options.links)return;const o=this.container,r=o.actualOptions,l=n.destination,a=e.destination,c=t.options.links.triangles,d=null!==(s=c.opacity)&&void 0!==s?s:(n.opacity+e.opacity)/2;d<=0||o.canvas.draw((n=>{var e;const s=t.getPosition(),u=l.getPosition(),h=a.getPosition(),p=null!==(e=t.retina.linksDistance)&&void 0!==e?e:0;if((0,i.getDistance)(s,u)>p||(0,i.getDistance)(h,u)>p||(0,i.getDistance)(h,s)>p)return;let y=(0,i.rangeColorToRgb)(c.color);if(!y){const n=t.options.links,e=void 0!==(null==n?void 0:n.id)?o.particles.linksColors.get(n.id):o.particles.linksColor;y=(0,i.getLinkColor)(t,l,e)}y&&function(t,n,e,s,o,r,l,a){(0,i.drawTriangle)(t,n,e,s),o&&(t.globalCompositeOperation=r),t.fillStyle=(0,i.getStyleFromRgb)(l,a),t.fill()}(n,s,u,h,r.backgroundMask.enable,r.backgroundMask.composite,y,d)}))}drawTriangles(i,t,n,e){var s,o,r;const l=n.destination;if(!(null===(s=i.links)||void 0===s?void 0:s.triangles.enable)||!(null===(o=l.options.links)||void 0===o?void 0:o.triangles.enable))return;const a=null===(r=l.links)||void 0===r?void 0:r.filter((i=>{const t=this.getLinkFrequency(l,i.destination);return l.options.links&&t<=l.options.links.frequency&&e.findIndex((t=>t.destination===i.destination))>=0}));if(null==a?void 0:a.length)for(const e of a){const s=e.destination;this.getTriangleFrequency(t,l,s)>i.links.triangles.frequency||this.drawLinkTriangle(t,n,e)}}getLinkFrequency(i,t){return c([i,t],this._freqs.links)}getTriangleFrequency(i,t,n){return c([i,t,n],this._freqs.triangles)}}class u{constructor(){this.id="links"}getPlugin(i){return new d(i)}loadOptions(){}needsPlugin(){return!0}}async function h(i){await async function(i){await i.addInteractor("particlesLinks",(i=>new a(i)))}(i),await async function(i){const t=new u;await i.addPlugin(t)}(i)}})(),s})()));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Circle } from "@tsparticles/engine";
|
|
2
|
+
import type { ICoordinates, IDimension, Range } from "@tsparticles/engine";
|
|
3
|
+
export declare class CircleWarp extends Circle {
|
|
4
|
+
private readonly canvasSize;
|
|
5
|
+
constructor(x: number, y: number, radius: number, canvasSize: IDimension);
|
|
6
|
+
contains(point: ICoordinates): boolean;
|
|
7
|
+
intersects(range: Range): boolean;
|
|
8
|
+
}
|