@tsparticles/interaction-particles-links 3.0.0-alpha.0 → 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.
- package/README.md +25 -19
- package/browser/CircleWarp.js +7 -23
- package/browser/LinkInstance.js +121 -114
- package/browser/Linker.js +37 -54
- package/browser/Options/Classes/Links.js +1 -1
- package/browser/Utils.js +24 -8
- package/browser/index.js +5 -5
- package/browser/interaction.js +2 -2
- package/browser/plugin.js +2 -2
- package/cjs/CircleWarp.js +7 -23
- package/cjs/LinkInstance.js +123 -127
- package/cjs/Linker.js +66 -94
- package/cjs/Options/Classes/Links.js +1 -1
- package/cjs/Utils.js +26 -8
- package/cjs/index.js +3 -14
- package/cjs/interaction.js +4 -15
- package/cjs/plugin.js +5 -16
- package/esm/CircleWarp.js +7 -23
- package/esm/LinkInstance.js +121 -114
- package/esm/Linker.js +37 -54
- package/esm/Options/Classes/Links.js +1 -1
- package/esm/Utils.js +24 -8
- package/esm/index.js +5 -5
- package/esm/interaction.js +2 -2
- package/esm/plugin.js +2 -2
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.interaction.particles.links.js +244 -204
- package/tsparticles.interaction.particles.links.min.js +1 -1
- package/tsparticles.interaction.particles.links.min.js.LICENSE.txt +1 -8
- package/types/CircleWarp.d.ts +1 -2
- package/types/Interfaces.d.ts +22 -0
- package/types/LinkInstance.d.ts +7 -8
- package/types/Linker.d.ts +3 -7
- package/types/Options/Classes/Links.d.ts +1 -2
- package/types/Options/Classes/LinksShadow.d.ts +1 -2
- package/types/Options/Classes/LinksTriangle.d.ts +1 -2
- package/types/Types.d.ts +47 -0
- package/types/Utils.d.ts +5 -4
- package/types/index.d.ts +1 -1
- package/types/interaction.d.ts +1 -1
- package/types/plugin.d.ts +1 -1
- package/umd/CircleWarp.js +7 -23
- package/umd/LinkInstance.js +121 -114
- package/umd/Linker.js +36 -53
- package/umd/Options/Classes/Links.js +2 -2
- package/umd/Utils.js +26 -8
- package/umd/index.js +3 -3
- package/umd/interaction.js +4 -4
- package/umd/plugin.js +4 -4
- package/browser/Options/Interfaces/IParticlesLinkOptions.js +0 -1
- package/cjs/LinkParticle.js +0 -2
- package/cjs/Options/Classes/ParticlesLinkOptions.js +0 -2
- package/cjs/Options/Interfaces/IParticlesLinkOptions.js +0 -2
- package/esm/ILink.js +0 -1
- package/esm/LinkContainer.js +0 -1
- package/esm/LinkParticle.js +0 -1
- package/esm/Options/Classes/ParticlesLinkOptions.js +0 -1
- package/esm/Options/Interfaces/IParticlesLinkOptions.js +0 -1
- package/types/ILink.d.ts +0 -9
- package/types/LinkContainer.d.ts +0 -7
- package/types/LinkParticle.d.ts +0 -11
- package/types/Options/Classes/ParticlesLinkOptions.d.ts +0 -5
- package/types/Options/Interfaces/IParticlesLinkOptions.d.ts +0 -7
- package/umd/LinkParticle.js +0 -12
- package/umd/Options/Classes/ParticlesLinkOptions.js +0 -12
- package/umd/Options/Interfaces/IParticlesLinkOptions.js +0 -12
- /package/browser/{ILink.js → Interfaces.js} +0 -0
- /package/browser/{LinkContainer.js → Types.js} +0 -0
- /package/cjs/{ILink.js → Interfaces.js} +0 -0
- /package/cjs/{LinkContainer.js → Types.js} +0 -0
- /package/{browser/LinkParticle.js → esm/Interfaces.js} +0 -0
- /package/{browser/Options/Classes/ParticlesLinkOptions.js → esm/Types.js} +0 -0
- /package/umd/{ILink.js → Interfaces.js} +0 -0
- /package/umd/{LinkContainer.js → Types.js} +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0.0-
|
|
7
|
+
* v3.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -91,10 +91,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
Links: () => (/* reexport */ Links),
|
|
95
|
+
LinksShadow: () => (/* reexport */ LinksShadow),
|
|
96
|
+
LinksTriangle: () => (/* reexport */ LinksTriangle),
|
|
97
|
+
loadParticlesLinksInteraction: () => (/* binding */ loadParticlesLinksInteraction)
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
@@ -105,31 +105,29 @@ class CircleWarp extends engine_root_window_.Circle {
|
|
|
105
105
|
constructor(x, y, radius, canvasSize) {
|
|
106
106
|
super(x, y, radius);
|
|
107
107
|
this.canvasSize = canvasSize;
|
|
108
|
-
this.canvasSize =
|
|
108
|
+
this.canvasSize = {
|
|
109
|
+
...canvasSize
|
|
110
|
+
};
|
|
109
111
|
}
|
|
110
112
|
contains(point) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
x: point.x,
|
|
130
|
-
y: point.y - this.canvasSize.height
|
|
131
|
-
};
|
|
132
|
-
return super.contains(posSW);
|
|
113
|
+
const {
|
|
114
|
+
width,
|
|
115
|
+
height
|
|
116
|
+
} = this.canvasSize;
|
|
117
|
+
const {
|
|
118
|
+
x,
|
|
119
|
+
y
|
|
120
|
+
} = point;
|
|
121
|
+
return super.contains(point) || super.contains({
|
|
122
|
+
x: x - width,
|
|
123
|
+
y
|
|
124
|
+
}) || super.contains({
|
|
125
|
+
x: x - width,
|
|
126
|
+
y: y - height
|
|
127
|
+
}) || super.contains({
|
|
128
|
+
x,
|
|
129
|
+
y: y - height
|
|
130
|
+
});
|
|
133
131
|
}
|
|
134
132
|
intersects(range) {
|
|
135
133
|
if (super.intersects(range)) {
|
|
@@ -258,36 +256,45 @@ class Links {
|
|
|
258
256
|
|
|
259
257
|
|
|
260
258
|
function getLinkDistance(pos1, pos2, optDistance, canvasSize, warp) {
|
|
261
|
-
|
|
259
|
+
const {
|
|
260
|
+
dx,
|
|
261
|
+
dy,
|
|
262
|
+
distance
|
|
263
|
+
} = (0,engine_root_window_.getDistances)(pos1, pos2);
|
|
262
264
|
if (!warp || distance <= optDistance) {
|
|
263
265
|
return distance;
|
|
264
266
|
}
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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;
|
|
267
|
+
const absDiffs = {
|
|
268
|
+
x: Math.abs(dx),
|
|
269
|
+
y: Math.abs(dy)
|
|
270
|
+
},
|
|
271
|
+
warpDistances = {
|
|
272
|
+
x: Math.min(absDiffs.x, canvasSize.width - absDiffs.x),
|
|
273
|
+
y: Math.min(absDiffs.y, canvasSize.height - absDiffs.y)
|
|
274
|
+
};
|
|
275
|
+
return Math.sqrt(warpDistances.x ** 2 + warpDistances.y ** 2);
|
|
287
276
|
}
|
|
288
277
|
class Linker extends engine_root_window_.ParticlesInteractorBase {
|
|
289
278
|
constructor(container) {
|
|
290
279
|
super(container);
|
|
280
|
+
this._setColor = p1 => {
|
|
281
|
+
if (!p1.options.links) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const container = this.linkContainer,
|
|
285
|
+
linksOptions = p1.options.links;
|
|
286
|
+
let linkColor = linksOptions.id === undefined ? container.particles.linksColor : container.particles.linksColors.get(linksOptions.id);
|
|
287
|
+
if (linkColor) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const optColor = linksOptions.color;
|
|
291
|
+
linkColor = (0,engine_root_window_.getLinkRandomColor)(optColor, linksOptions.blink, linksOptions.consent);
|
|
292
|
+
if (linksOptions.id === undefined) {
|
|
293
|
+
container.particles.linksColor = linkColor;
|
|
294
|
+
} else {
|
|
295
|
+
container.particles.linksColors.set(linksOptions.id, linkColor);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
291
298
|
this.linkContainer = container;
|
|
292
299
|
}
|
|
293
300
|
clear() {}
|
|
@@ -296,7 +303,6 @@ class Linker extends engine_root_window_.ParticlesInteractorBase {
|
|
|
296
303
|
this.linkContainer.particles.linksColors = new Map();
|
|
297
304
|
}
|
|
298
305
|
async interact(p1) {
|
|
299
|
-
var _a;
|
|
300
306
|
if (!p1.options.links) {
|
|
301
307
|
return;
|
|
302
308
|
}
|
|
@@ -309,13 +315,13 @@ class Linker extends engine_root_window_.ParticlesInteractorBase {
|
|
|
309
315
|
}
|
|
310
316
|
const linkOpt1 = p1.options.links,
|
|
311
317
|
optOpacity = linkOpt1.opacity,
|
|
312
|
-
optDistance =
|
|
318
|
+
optDistance = p1.retina.linksDistance ?? 0,
|
|
313
319
|
warp = linkOpt1.warp,
|
|
314
320
|
range = warp ? new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize) : new engine_root_window_.Circle(pos1.x, pos1.y, optDistance),
|
|
315
321
|
query = container.particles.quadTree.query(range);
|
|
316
322
|
for (const p2 of query) {
|
|
317
323
|
const linkOpt2 = p2.options.links;
|
|
318
|
-
if (p1 === p2 || !
|
|
324
|
+
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)) {
|
|
319
325
|
continue;
|
|
320
326
|
}
|
|
321
327
|
const pos2 = p2.getPosition();
|
|
@@ -324,10 +330,10 @@ class Linker extends engine_root_window_.ParticlesInteractorBase {
|
|
|
324
330
|
}
|
|
325
331
|
const distance = getLinkDistance(pos1, pos2, optDistance, canvasSize, warp && linkOpt2.warp);
|
|
326
332
|
if (distance > optDistance) {
|
|
327
|
-
|
|
333
|
+
continue;
|
|
328
334
|
}
|
|
329
335
|
const opacityLine = (1 - distance / optDistance) * optOpacity;
|
|
330
|
-
this.
|
|
336
|
+
this._setColor(p1);
|
|
331
337
|
p1.links.push({
|
|
332
338
|
destination: p2,
|
|
333
339
|
opacity: opacityLine
|
|
@@ -335,51 +341,43 @@ class Linker extends engine_root_window_.ParticlesInteractorBase {
|
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
343
|
isEnabled(particle) {
|
|
338
|
-
|
|
339
|
-
return !!((_a = particle.options.links) === null || _a === void 0 ? void 0 : _a.enable);
|
|
344
|
+
return !!particle.options.links?.enable;
|
|
340
345
|
}
|
|
341
346
|
loadParticlesOptions(options, ...sources) {
|
|
342
|
-
var _a, _b;
|
|
343
347
|
if (!options.links) {
|
|
344
348
|
options.links = new Links();
|
|
345
349
|
}
|
|
346
350
|
for (const source of sources) {
|
|
347
|
-
options.links.load(
|
|
351
|
+
options.links.load(source?.links ?? source?.lineLinked ?? source?.line_linked);
|
|
348
352
|
}
|
|
349
353
|
}
|
|
350
354
|
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
355
|
}
|
|
370
356
|
;// CONCATENATED MODULE: ./dist/browser/interaction.js
|
|
371
357
|
|
|
372
|
-
async function
|
|
373
|
-
await engine.addInteractor("particlesLinks", container => new Linker(container));
|
|
358
|
+
async function loadLinksInteraction(engine, refresh = true) {
|
|
359
|
+
await engine.addInteractor("particlesLinks", container => new Linker(container), refresh);
|
|
374
360
|
}
|
|
375
361
|
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
376
362
|
|
|
377
|
-
function drawLinkLine(
|
|
363
|
+
function drawLinkLine(params) {
|
|
378
364
|
let drawn = false;
|
|
365
|
+
const {
|
|
366
|
+
begin,
|
|
367
|
+
end,
|
|
368
|
+
maxDistance,
|
|
369
|
+
context,
|
|
370
|
+
canvasSize,
|
|
371
|
+
width,
|
|
372
|
+
backgroundMask,
|
|
373
|
+
colorLine,
|
|
374
|
+
opacity,
|
|
375
|
+
links
|
|
376
|
+
} = params;
|
|
379
377
|
if ((0,engine_root_window_.getDistance)(begin, end) <= maxDistance) {
|
|
380
378
|
(0,engine_root_window_.drawLine)(context, begin, end);
|
|
381
379
|
drawn = true;
|
|
382
|
-
} else if (warp) {
|
|
380
|
+
} else if (links.warp) {
|
|
383
381
|
let pi1;
|
|
384
382
|
let pi2;
|
|
385
383
|
const endNE = {
|
|
@@ -444,10 +442,13 @@ function drawLinkLine(context, width, begin, end, maxDistance, canvasSize, warp,
|
|
|
444
442
|
return;
|
|
445
443
|
}
|
|
446
444
|
context.lineWidth = width;
|
|
447
|
-
if (backgroundMask) {
|
|
448
|
-
context.globalCompositeOperation = composite;
|
|
445
|
+
if (backgroundMask.enable) {
|
|
446
|
+
context.globalCompositeOperation = backgroundMask.composite;
|
|
449
447
|
}
|
|
450
448
|
context.strokeStyle = (0,engine_root_window_.getStyleFromRgb)(colorLine, opacity);
|
|
449
|
+
const {
|
|
450
|
+
shadow
|
|
451
|
+
} = links;
|
|
451
452
|
if (shadow.enable) {
|
|
452
453
|
const shadowColor = (0,engine_root_window_.rangeColorToRgb)(shadow.color);
|
|
453
454
|
if (shadowColor) {
|
|
@@ -457,17 +458,23 @@ function drawLinkLine(context, width, begin, end, maxDistance, canvasSize, warp,
|
|
|
457
458
|
}
|
|
458
459
|
context.stroke();
|
|
459
460
|
}
|
|
460
|
-
function drawLinkTriangle(
|
|
461
|
+
function drawLinkTriangle(params) {
|
|
462
|
+
const {
|
|
463
|
+
context,
|
|
464
|
+
pos1,
|
|
465
|
+
pos2,
|
|
466
|
+
pos3,
|
|
467
|
+
backgroundMask,
|
|
468
|
+
colorTriangle,
|
|
469
|
+
opacityTriangle
|
|
470
|
+
} = params;
|
|
461
471
|
(0,engine_root_window_.drawTriangle)(context, pos1, pos2, pos3);
|
|
462
|
-
if (backgroundMask) {
|
|
463
|
-
context.globalCompositeOperation = composite;
|
|
472
|
+
if (backgroundMask.enable) {
|
|
473
|
+
context.globalCompositeOperation = backgroundMask.composite;
|
|
464
474
|
}
|
|
465
475
|
context.fillStyle = (0,engine_root_window_.getStyleFromRgb)(colorTriangle, opacityTriangle);
|
|
466
476
|
context.fill();
|
|
467
477
|
}
|
|
468
|
-
;// CONCATENATED MODULE: ./dist/browser/LinkInstance.js
|
|
469
|
-
|
|
470
|
-
|
|
471
478
|
function getLinkKey(ids) {
|
|
472
479
|
ids.sort((a, b) => a - b);
|
|
473
480
|
return ids.join("_");
|
|
@@ -481,25 +488,150 @@ function setLinkFrequency(particles, dictionary) {
|
|
|
481
488
|
}
|
|
482
489
|
return res;
|
|
483
490
|
}
|
|
491
|
+
;// CONCATENATED MODULE: ./dist/browser/LinkInstance.js
|
|
492
|
+
|
|
493
|
+
|
|
484
494
|
class LinkInstance {
|
|
485
495
|
constructor(container) {
|
|
486
496
|
this.container = container;
|
|
497
|
+
this._drawLinkLine = (p1, link) => {
|
|
498
|
+
const p1LinksOptions = p1.options.links;
|
|
499
|
+
if (!p1LinksOptions?.enable) {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
const container = this.container,
|
|
503
|
+
options = container.actualOptions,
|
|
504
|
+
p2 = link.destination,
|
|
505
|
+
pos1 = p1.getPosition(),
|
|
506
|
+
pos2 = p2.getPosition();
|
|
507
|
+
let opacity = link.opacity;
|
|
508
|
+
container.canvas.draw(ctx => {
|
|
509
|
+
let colorLine;
|
|
510
|
+
const twinkle = p1.options.twinkle?.lines;
|
|
511
|
+
if (twinkle?.enable) {
|
|
512
|
+
const twinkleFreq = twinkle.frequency,
|
|
513
|
+
twinkleRgb = (0,engine_root_window_.rangeColorToRgb)(twinkle.color),
|
|
514
|
+
twinkling = (0,engine_root_window_.getRandom)() < twinkleFreq;
|
|
515
|
+
if (twinkling && twinkleRgb) {
|
|
516
|
+
colorLine = twinkleRgb;
|
|
517
|
+
opacity = (0,engine_root_window_.getRangeValue)(twinkle.opacity);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (!colorLine) {
|
|
521
|
+
const linkColor = p1LinksOptions.id !== undefined ? container.particles.linksColors.get(p1LinksOptions.id) : container.particles.linksColor;
|
|
522
|
+
colorLine = (0,engine_root_window_.getLinkColor)(p1, p2, linkColor);
|
|
523
|
+
}
|
|
524
|
+
if (!colorLine) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const width = p1.retina.linksWidth ?? 0,
|
|
528
|
+
maxDistance = p1.retina.linksDistance ?? 0,
|
|
529
|
+
{
|
|
530
|
+
backgroundMask
|
|
531
|
+
} = options;
|
|
532
|
+
drawLinkLine({
|
|
533
|
+
context: ctx,
|
|
534
|
+
width,
|
|
535
|
+
begin: pos1,
|
|
536
|
+
end: pos2,
|
|
537
|
+
maxDistance,
|
|
538
|
+
canvasSize: container.canvas.size,
|
|
539
|
+
links: p1LinksOptions,
|
|
540
|
+
backgroundMask: backgroundMask,
|
|
541
|
+
colorLine,
|
|
542
|
+
opacity
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
this._drawLinkTriangle = (p1, link1, link2) => {
|
|
547
|
+
const linksOptions = p1.options.links;
|
|
548
|
+
if (!linksOptions?.enable) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const triangleOptions = linksOptions.triangles;
|
|
552
|
+
if (!triangleOptions.enable) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const container = this.container,
|
|
556
|
+
options = container.actualOptions,
|
|
557
|
+
p2 = link1.destination,
|
|
558
|
+
p3 = link2.destination,
|
|
559
|
+
opacityTriangle = triangleOptions.opacity ?? (link1.opacity + link2.opacity) / 2;
|
|
560
|
+
if (opacityTriangle <= 0) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
container.canvas.draw(ctx => {
|
|
564
|
+
const pos1 = p1.getPosition(),
|
|
565
|
+
pos2 = p2.getPosition(),
|
|
566
|
+
pos3 = p3.getPosition(),
|
|
567
|
+
linksDistance = p1.retina.linksDistance ?? 0;
|
|
568
|
+
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) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
let colorTriangle = (0,engine_root_window_.rangeColorToRgb)(triangleOptions.color);
|
|
572
|
+
if (!colorTriangle) {
|
|
573
|
+
const linkColor = linksOptions.id !== undefined ? container.particles.linksColors.get(linksOptions.id) : container.particles.linksColor;
|
|
574
|
+
colorTriangle = (0,engine_root_window_.getLinkColor)(p1, p2, linkColor);
|
|
575
|
+
}
|
|
576
|
+
if (!colorTriangle) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
drawLinkTriangle({
|
|
580
|
+
context: ctx,
|
|
581
|
+
pos1,
|
|
582
|
+
pos2,
|
|
583
|
+
pos3,
|
|
584
|
+
backgroundMask: options.backgroundMask,
|
|
585
|
+
colorTriangle,
|
|
586
|
+
opacityTriangle
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
this._drawTriangles = (options, p1, link, p1Links) => {
|
|
591
|
+
const p2 = link.destination;
|
|
592
|
+
if (!(options.links?.triangles.enable && p2.options.links?.triangles.enable)) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const vertices = p2.links?.filter(t => {
|
|
596
|
+
const linkFreq = this._getLinkFrequency(p2, t.destination);
|
|
597
|
+
return p2.options.links && linkFreq <= p2.options.links.frequency && p1Links.findIndex(l => l.destination === t.destination) >= 0;
|
|
598
|
+
});
|
|
599
|
+
if (!vertices?.length) {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
for (const vertex of vertices) {
|
|
603
|
+
const p3 = vertex.destination,
|
|
604
|
+
triangleFreq = this._getTriangleFrequency(p1, p2, p3);
|
|
605
|
+
if (triangleFreq > options.links.triangles.frequency) {
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
this._drawLinkTriangle(p1, link, vertex);
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
this._getLinkFrequency = (p1, p2) => {
|
|
612
|
+
return setLinkFrequency([p1, p2], this._freqs.links);
|
|
613
|
+
};
|
|
614
|
+
this._getTriangleFrequency = (p1, p2, p3) => {
|
|
615
|
+
return setLinkFrequency([p1, p2, p3], this._freqs.triangles);
|
|
616
|
+
};
|
|
487
617
|
this._freqs = {
|
|
488
618
|
links: new Map(),
|
|
489
619
|
triangles: new Map()
|
|
490
620
|
};
|
|
491
621
|
}
|
|
492
622
|
drawParticle(context, particle) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
623
|
+
const {
|
|
624
|
+
links,
|
|
625
|
+
options
|
|
626
|
+
} = particle;
|
|
627
|
+
if (!links || links.length <= 0) {
|
|
496
628
|
return;
|
|
497
629
|
}
|
|
498
|
-
const p1Links =
|
|
630
|
+
const p1Links = links.filter(l => options.links && this._getLinkFrequency(particle, l.destination) <= options.links.frequency);
|
|
499
631
|
for (const link of p1Links) {
|
|
500
|
-
this.
|
|
501
|
-
if (link.opacity > 0 && (
|
|
502
|
-
this.
|
|
632
|
+
this._drawTriangles(options, particle, link, p1Links);
|
|
633
|
+
if (link.opacity > 0 && (particle.retina.linksWidth ?? 0) > 0) {
|
|
634
|
+
this._drawLinkLine(particle, link);
|
|
503
635
|
}
|
|
504
636
|
}
|
|
505
637
|
}
|
|
@@ -512,112 +644,20 @@ class LinkInstance {
|
|
|
512
644
|
if (!particle.options.links) {
|
|
513
645
|
return;
|
|
514
646
|
}
|
|
515
|
-
const ratio = this.container.retina.pixelRatio
|
|
516
|
-
|
|
517
|
-
|
|
647
|
+
const ratio = this.container.retina.pixelRatio,
|
|
648
|
+
{
|
|
649
|
+
retina
|
|
650
|
+
} = particle,
|
|
651
|
+
{
|
|
652
|
+
distance,
|
|
653
|
+
width
|
|
654
|
+
} = particle.options.links;
|
|
655
|
+
retina.linksDistance = distance * ratio;
|
|
656
|
+
retina.linksWidth = width * ratio;
|
|
518
657
|
}
|
|
519
658
|
particleDestroyed(particle) {
|
|
520
659
|
particle.links = [];
|
|
521
660
|
}
|
|
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
661
|
}
|
|
622
662
|
;// CONCATENATED MODULE: ./dist/browser/plugin.js
|
|
623
663
|
|
|
@@ -633,16 +673,16 @@ class LinksPlugin {
|
|
|
633
673
|
return true;
|
|
634
674
|
}
|
|
635
675
|
}
|
|
636
|
-
async function
|
|
676
|
+
async function loadLinksPlugin(engine, refresh = true) {
|
|
637
677
|
const plugin = new LinksPlugin();
|
|
638
|
-
await engine.addPlugin(plugin);
|
|
678
|
+
await engine.addPlugin(plugin, refresh);
|
|
639
679
|
}
|
|
640
680
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
641
681
|
|
|
642
682
|
|
|
643
|
-
async function loadParticlesLinksInteraction(engine) {
|
|
644
|
-
await
|
|
645
|
-
await
|
|
683
|
+
async function loadParticlesLinksInteraction(engine, refresh = true) {
|
|
684
|
+
await loadLinksInteraction(engine, refresh);
|
|
685
|
+
await loadLinksPlugin(engine, refresh);
|
|
646
686
|
}
|
|
647
687
|
|
|
648
688
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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:()=>
|
|
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:()=>p});var i=e(533);class t extends i.Circle{constructor(i,t,n,e){super(i,t,n),this.canvasSize=e,this.canvasSize={...e}}contains(i){const{width:t,height:n}=this.canvasSize,{x:e,y:s}=i;return super.contains(i)||super.contains({x:e-t,y:s})||super.contains({x:e-t,y:s-n})||super.contains({x:e,y:s-n})}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 a(t,n,e,s,o){const{dx:r,dy:a,distance:l}=(0,i.getDistances)(t,n);if(!o||l<=e)return l;const c={x:Math.abs(r),y:Math.abs(a)},d=Math.min(c.x,s.width-c.x),h=Math.min(c.y,s.height-c.y);return Math.sqrt(d**2+h**2)}class l extends i.ParticlesInteractorBase{constructor(t){super(t),this._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)},this.linkContainer=t}clear(){}init(){this.linkContainer.particles.linksColor=void 0,this.linkContainer.particles.linksColors=new Map}async interact(n){if(!n.options.links)return;n.links=[];const e=n.getPosition(),s=this.container,o=s.canvas.size;if(e.x<0||e.y<0||e.x>o.width||e.y>o.height)return;const r=n.options.links,l=r.opacity,c=n.retina.linksDistance??0,d=r.warp,h=d?new t(e.x,e.y,c,o):new i.Circle(e.x,e.y,c),p=s.particles.quadTree.query(h);for(const i of p){const t=i.options.links;if(n===i||!t?.enable||r.id!==t.id||i.spawning||i.destroyed||!i.links||n.links.some((t=>t.destination===i))||i.links.some((i=>i.destination===n)))continue;const s=i.getPosition();if(s.x<0||s.y<0||s.x>o.width||s.y>o.height)continue;const h=a(e,s,c,o,d&&t.warp);if(h>c)continue;const p=(1-h/c)*l;this._setColor(n),n.links.push({destination:i,opacity:p})}}isEnabled(i){return!!i.options.links?.enable}loadParticlesOptions(i,...t){i.links||(i.links=new r);for(const n of t)i.links.load(n?.links??n?.lineLinked??n?.line_linked)}reset(){}}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(t){this.container=t,this._drawLinkLine=(t,n)=>{const e=t.options.links;if(!e?.enable)return;const s=this.container,o=s.actualOptions,r=n.destination,a=t.getPosition(),l=r.getPosition();let c=n.opacity;s.canvas.draw((n=>{let d;const h=t.options.twinkle?.lines;if(h?.enable){const t=h.frequency,n=(0,i.rangeColorToRgb)(h.color);(0,i.getRandom)()<t&&n&&(d=n,c=(0,i.getRangeValue)(h.opacity))}if(!d){const n=void 0!==e.id?s.particles.linksColors.get(e.id):s.particles.linksColor;d=(0,i.getLinkColor)(t,r,n)}if(!d)return;const p=t.retina.linksWidth??0,u=t.retina.linksDistance??0,{backgroundMask:y}=o;!function(t){let n=!1;const{begin:e,end:s,maxDistance:o,context:r,canvasSize:a,width:l,backgroundMask:c,colorLine:d,opacity:h,links:p}=t;if((0,i.getDistance)(e,s)<=o)(0,i.drawLine)(r,e,s),n=!0;else if(p.warp){let t,l;const c={x:s.x-a.width,y:s.y},d=(0,i.getDistances)(e,c);if(d.distance<=o){const i=e.y-d.dy/d.dx*e.x;t={x:0,y:i},l={x:a.width,y:i}}else{const n={x:s.x,y:s.y-a.height},r=(0,i.getDistances)(e,n);if(r.distance<=o){const i=-(e.y-r.dy/r.dx*e.x)/(r.dy/r.dx);t={x:i,y:0},l={x:i,y:a.height}}else{const n={x:s.x-a.width,y:s.y-a.height},r=(0,i.getDistances)(e,n);if(r.distance<=o){const i=e.y-r.dy/r.dx*e.x;t={x:-i/(r.dy/r.dx),y:i},l={x:t.x+a.width,y:t.y+a.height}}}}t&&l&&((0,i.drawLine)(r,e,t),(0,i.drawLine)(r,s,l),n=!0)}if(!n)return;r.lineWidth=l,c.enable&&(r.globalCompositeOperation=c.composite),r.strokeStyle=(0,i.getStyleFromRgb)(d,h);const{shadow:u}=p;if(u.enable){const t=(0,i.rangeColorToRgb)(u.color);t&&(r.shadowBlur=u.blur,r.shadowColor=(0,i.getStyleFromRgb)(t))}r.stroke()}({context:n,width:p,begin:a,end:l,maxDistance:u,canvasSize:s.canvas.size,links:e,backgroundMask:y,colorLine:d,opacity:c})}))},this._drawLinkTriangle=(t,n,e)=>{const s=t.options.links;if(!s?.enable)return;const o=s.triangles;if(!o.enable)return;const r=this.container,a=r.actualOptions,l=n.destination,c=e.destination,d=o.opacity??(n.opacity+e.opacity)/2;d<=0||r.canvas.draw((n=>{const e=t.getPosition(),h=l.getPosition(),p=c.getPosition(),u=t.retina.linksDistance??0;if((0,i.getDistance)(e,h)>u||(0,i.getDistance)(p,h)>u||(0,i.getDistance)(p,e)>u)return;let y=(0,i.rangeColorToRgb)(o.color);if(!y){const n=void 0!==s.id?r.particles.linksColors.get(s.id):r.particles.linksColor;y=(0,i.getLinkColor)(t,l,n)}y&&function(t){const{context:n,pos1:e,pos2:s,pos3:o,backgroundMask:r,colorTriangle:a,opacityTriangle:l}=t;(0,i.drawTriangle)(n,e,s,o),r.enable&&(n.globalCompositeOperation=r.composite),n.fillStyle=(0,i.getStyleFromRgb)(a,l),n.fill()}({context:n,pos1:e,pos2:h,pos3:p,backgroundMask:a.backgroundMask,colorTriangle:y,opacityTriangle:d})}))},this._drawTriangles=(i,t,n,e)=>{const s=n.destination;if(!i.links?.triangles.enable||!s.options.links?.triangles.enable)return;const o=s.links?.filter((i=>{const t=this._getLinkFrequency(s,i.destination);return s.options.links&&t<=s.options.links.frequency&&e.findIndex((t=>t.destination===i.destination))>=0}));if(o?.length)for(const e of o){const o=e.destination;this._getTriangleFrequency(t,s,o)>i.links.triangles.frequency||this._drawLinkTriangle(t,n,e)}},this._getLinkFrequency=(i,t)=>c([i,t],this._freqs.links),this._getTriangleFrequency=(i,t,n)=>c([i,t,n],this._freqs.triangles),this._freqs={links:new Map,triangles:new Map}}drawParticle(i,t){const{links:n,options:e}=t;if(!n||n.length<=0)return;const s=n.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&&(t.retina.linksWidth??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,{retina:n}=i,{distance:e,width:s}=i.options.links;n.linksDistance=e*t,n.linksWidth=s*t}particleDestroyed(i){i.links=[]}}class h{constructor(){this.id="links"}getPlugin(i){return new d(i)}loadOptions(){}needsPlugin(){return!0}}async function p(i,t=!0){await async function(i,t=!0){await i.addInteractor("particlesLinks",(i=>new l(i)),t)}(i,t),await async function(i,t=!0){const n=new h;await i.addPlugin(n,t)}(i,t)}})(),s})()));
|
|
@@ -1,8 +1 @@
|
|
|
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
|
-
*/
|
|
1
|
+
/*! tsParticles Links Particles Interaction v3.0.0-beta.0 by Matteo Bruni */
|
package/types/CircleWarp.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Circle } from "@tsparticles/engine";
|
|
2
|
-
import type { ICoordinates, IDimension, Range } from "@tsparticles/engine";
|
|
1
|
+
import { Circle, type ICoordinates, type IDimension, type Range } from "@tsparticles/engine";
|
|
3
2
|
export declare class CircleWarp extends Circle {
|
|
4
3
|
private readonly canvasSize;
|
|
5
4
|
constructor(x: number, y: number, radius: number, canvasSize: IDimension);
|