@tsparticles/interaction-external-connect 3.0.0-alpha.1 → 3.0.0-beta.1
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/Connector.js +5 -40
- package/browser/Options/Classes/Connect.js +2 -15
- package/browser/Utils.js +35 -0
- package/browser/index.js +7 -7
- package/browser/package.json +1 -0
- package/cjs/Connector.js +26 -72
- package/cjs/Options/Classes/Connect.js +3 -16
- package/cjs/Utils.js +42 -0
- package/cjs/index.js +7 -18
- package/cjs/package.json +1 -0
- package/esm/Connector.js +5 -40
- package/esm/Options/Classes/Connect.js +2 -15
- package/esm/Utils.js +35 -0
- package/esm/index.js +7 -7
- package/esm/package.json +1 -0
- package/package.json +19 -6
- package/report.html +4 -4
- package/tsparticles.interaction.external.connect.js +15 -27
- package/tsparticles.interaction.external.connect.min.js +1 -1
- package/tsparticles.interaction.external.connect.min.js.LICENSE.txt +1 -8
- package/types/Connector.d.ts +2 -3
- package/types/Options/Classes/Connect.d.ts +2 -6
- package/types/Options/Classes/ConnectLinks.d.ts +1 -1
- package/types/Options/Classes/ConnectOptions.d.ts +1 -1
- package/types/Options/Interfaces/IConnect.d.ts +1 -3
- package/types/Types.d.ts +9 -4
- package/types/Utils.d.ts +6 -0
- package/types/index.d.ts +5 -5
- package/umd/Connector.js +7 -42
- package/umd/Options/Classes/Connect.js +4 -17
- package/umd/Utils.js +52 -0
- package/umd/index.js +8 -8
|
@@ -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.1
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -91,9 +91,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
Connect: () => (/* reexport */ Connect),
|
|
95
|
+
ConnectLinks: () => (/* reexport */ ConnectLinks),
|
|
96
|
+
loadExternalConnectInteraction: () => (/* binding */ loadExternalConnectInteraction)
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
@@ -120,34 +120,20 @@ class Connect {
|
|
|
120
120
|
this.links = new ConnectLinks();
|
|
121
121
|
this.radius = 60;
|
|
122
122
|
}
|
|
123
|
-
get lineLinked() {
|
|
124
|
-
return this.links;
|
|
125
|
-
}
|
|
126
|
-
set lineLinked(value) {
|
|
127
|
-
this.links = value;
|
|
128
|
-
}
|
|
129
|
-
get line_linked() {
|
|
130
|
-
return this.links;
|
|
131
|
-
}
|
|
132
|
-
set line_linked(value) {
|
|
133
|
-
this.links = value;
|
|
134
|
-
}
|
|
135
123
|
load(data) {
|
|
136
|
-
var _a, _b;
|
|
137
124
|
if (!data) {
|
|
138
125
|
return;
|
|
139
126
|
}
|
|
140
127
|
if (data.distance !== undefined) {
|
|
141
128
|
this.distance = data.distance;
|
|
142
129
|
}
|
|
143
|
-
this.links.load(
|
|
130
|
+
this.links.load(data.links);
|
|
144
131
|
if (data.radius !== undefined) {
|
|
145
132
|
this.radius = data.radius;
|
|
146
133
|
}
|
|
147
134
|
}
|
|
148
135
|
}
|
|
149
|
-
;// CONCATENATED MODULE: ./dist/browser/
|
|
150
|
-
|
|
136
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
151
137
|
|
|
152
138
|
function gradient(context, p1, p2, opacity) {
|
|
153
139
|
const gradStop = Math.floor(p2.getRadius() / p1.getRadius()),
|
|
@@ -181,16 +167,19 @@ function lineStyle(container, ctx, p1, p2) {
|
|
|
181
167
|
}
|
|
182
168
|
function drawConnection(container, p1, p2) {
|
|
183
169
|
container.canvas.draw(ctx => {
|
|
184
|
-
var _a;
|
|
185
170
|
const ls = lineStyle(container, ctx, p1, p2);
|
|
186
171
|
if (!ls) {
|
|
187
172
|
return;
|
|
188
173
|
}
|
|
189
174
|
const pos1 = p1.getPosition(),
|
|
190
175
|
pos2 = p2.getPosition();
|
|
191
|
-
drawConnectLine(ctx,
|
|
176
|
+
drawConnectLine(ctx, p1.retina.linksWidth ?? 0, ls, pos1, pos2);
|
|
192
177
|
});
|
|
193
178
|
}
|
|
179
|
+
;// CONCATENATED MODULE: ./dist/browser/Connector.js
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
194
183
|
class Connector extends engine_root_window_.ExternalInteractorBase {
|
|
195
184
|
constructor(container) {
|
|
196
185
|
super(container);
|
|
@@ -232,10 +221,9 @@ class Connector extends engine_root_window_.ExternalInteractorBase {
|
|
|
232
221
|
}
|
|
233
222
|
}
|
|
234
223
|
isEnabled(particle) {
|
|
235
|
-
var _a;
|
|
236
224
|
const container = this.container,
|
|
237
225
|
mouse = container.interactivity.mouse,
|
|
238
|
-
events = (
|
|
226
|
+
events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
239
227
|
if (!(events.onHover.enable && mouse.position)) {
|
|
240
228
|
return false;
|
|
241
229
|
}
|
|
@@ -246,15 +234,15 @@ class Connector extends engine_root_window_.ExternalInteractorBase {
|
|
|
246
234
|
options.connect = new Connect();
|
|
247
235
|
}
|
|
248
236
|
for (const source of sources) {
|
|
249
|
-
options.connect.load(source
|
|
237
|
+
options.connect.load(source?.connect);
|
|
250
238
|
}
|
|
251
239
|
}
|
|
252
240
|
reset() {}
|
|
253
241
|
}
|
|
254
242
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
255
243
|
|
|
256
|
-
async function loadExternalConnectInteraction(engine) {
|
|
257
|
-
await engine.addInteractor("externalConnect", container => new Connector(container));
|
|
244
|
+
async function loadExternalConnectInteraction(engine, refresh = true) {
|
|
245
|
+
await engine.addInteractor("externalConnect", container => new Connector(container), refresh);
|
|
258
246
|
}
|
|
259
247
|
|
|
260
248
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.interaction.external.connect.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var n="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var n="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},n={};function o(t){var i=n[t];if(void 0!==i)return i.exports;var r=n[t]={exports:{}};return e[t](r,r.exports,o),r.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{Connect:()=>n,ConnectLinks:()=>e,loadExternalConnectInteraction:()=>c});var t=o(533);class e{constructor(){this.opacity=.5}load(t){t&&void 0!==t.opacity&&(this.opacity=t.opacity)}}class n{constructor(){this.distance=80,this.links=new e,this.radius=60}load(t){t&&(void 0!==t.distance&&(this.distance=t.distance),this.links.load(t.links),void 0!==t.radius&&(this.radius=t.radius))}}function r(e,n,o,i){const r=e.actualOptions.interactivity.modes.connect;if(r)return function(e,n,o,i){const r=Math.floor(o.getRadius()/n.getRadius()),a=n.getFillColor(),s=o.getFillColor();if(!a||!s)return;const c=n.getPosition(),d=o.getPosition(),l=(0,t.colorMix)(a,s,n.getRadius(),o.getRadius()),u=e.createLinearGradient(c.x,c.y,d.x,d.y);return u.addColorStop(0,(0,t.getStyleFromHsl)(a,i)),u.addColorStop(r>1?1:r,(0,t.getStyleFromRgb)(l,i)),u.addColorStop(1,(0,t.getStyleFromHsl)(s,i)),u}(n,o,i,r.links.opacity)}function a(e,n,o){e.canvas.draw((i=>{const a=r(e,i,n,o);if(!a)return;const s=n.getPosition(),c=o.getPosition();!function(e,n,o,i,r){(0,t.drawLine)(e,i,r),e.lineWidth=n,e.strokeStyle=o,e.stroke()}(i,n.retina.linksWidth??0,a,s,c)}))}class s extends t.ExternalInteractorBase{constructor(t){super(t)}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity.modes.connect;e&&(t.retina.connectModeDistance=e.distance*t.retina.pixelRatio,t.retina.connectModeRadius=e.radius*t.retina.pixelRatio)}async interact(){const t=this.container;if(t.actualOptions.interactivity.events.onHover.enable&&"pointermove"===t.interactivity.status){const e=t.interactivity.mouse.position;if(!t.retina.connectModeDistance||t.retina.connectModeDistance<0||!t.retina.connectModeRadius||t.retina.connectModeRadius<0||!e)return;const n=Math.abs(t.retina.connectModeRadius),o=t.particles.quadTree.queryCircle(e,n,(t=>this.isEnabled(t)));let i=0;for(const e of o){const n=e.getPosition();for(const r of o.slice(i+1)){const o=r.getPosition(),i=Math.abs(t.retina.connectModeDistance),s=Math.abs(n.x-o.x),c=Math.abs(n.y-o.y);s<i&&c<i&&a(t,e,r)}++i}}}isEnabled(e){const n=this.container,o=n.interactivity.mouse,i=(e?.interactivity??n.actualOptions.interactivity).events;return!(!i.onHover.enable||!o.position)&&(0,t.isInArray)("connect",i.onHover.mode)}loadModeOptions(t,...e){t.connect||(t.connect=new n);for(const n of e)t.connect.load(n?.connect)}reset(){}}async function c(t,e=!0){await t.addInteractor("externalConnect",(t=>new s(t)),e)}})(),i})()));
|
|
@@ -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.1
|
|
8
|
-
*/
|
|
1
|
+
/*! tsParticles Connect External Interaction v3.0.0-beta.1 by Matteo Bruni */
|
package/types/Connector.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { ConnectContainer, ConnectMode, IConnectMode } from "./Types";
|
|
2
|
-
import { ExternalInteractorBase } from "@tsparticles/engine";
|
|
3
|
-
import type { IModes, Modes, Particle, RecursivePartial } from "@tsparticles/engine";
|
|
1
|
+
import type { ConnectContainer, ConnectMode, IConnectMode } from "./Types.js";
|
|
2
|
+
import { ExternalInteractorBase, type IModes, type Modes, type Particle, type RecursivePartial } from "@tsparticles/engine";
|
|
4
3
|
export declare class Connector extends ExternalInteractorBase<ConnectContainer> {
|
|
5
4
|
constructor(container: ConnectContainer);
|
|
6
5
|
clear(): void;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
-
import { ConnectLinks } from "./ConnectLinks";
|
|
3
|
-
import type { IConnect } from "../Interfaces/IConnect";
|
|
2
|
+
import { ConnectLinks } from "./ConnectLinks.js";
|
|
3
|
+
import type { IConnect } from "../Interfaces/IConnect.js";
|
|
4
4
|
export declare class Connect implements IConnect, IOptionLoader<IConnect> {
|
|
5
5
|
distance: number;
|
|
6
6
|
links: ConnectLinks;
|
|
7
7
|
radius: number;
|
|
8
8
|
constructor();
|
|
9
|
-
get lineLinked(): ConnectLinks;
|
|
10
|
-
set lineLinked(value: ConnectLinks);
|
|
11
|
-
get line_linked(): ConnectLinks;
|
|
12
|
-
set line_linked(value: ConnectLinks);
|
|
13
9
|
load(data?: RecursivePartial<IConnect>): void;
|
|
14
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
-
import type { IConnectLinks } from "../Interfaces/IConnectLinks";
|
|
2
|
+
import type { IConnectLinks } from "../Interfaces/IConnectLinks.js";
|
|
3
3
|
export declare class ConnectLinks implements IConnectLinks, IOptionLoader<IConnectLinks> {
|
|
4
4
|
opacity: number;
|
|
5
5
|
constructor();
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { IConnectLinks } from "./IConnectLinks";
|
|
1
|
+
import type { IConnectLinks } from "./IConnectLinks.js";
|
|
2
2
|
export interface IConnect {
|
|
3
3
|
distance: number;
|
|
4
|
-
lineLinked: IConnectLinks;
|
|
5
|
-
line_linked: IConnectLinks;
|
|
6
4
|
links: IConnectLinks;
|
|
7
5
|
radius: number;
|
|
8
6
|
}
|
package/types/Types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { IConnect } from "./Options/Interfaces/IConnect";
|
|
1
|
+
import type { Container, Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { Connect } from "./Options/Classes/Connect.js";
|
|
3
|
+
import type { ConnectOptions } from "./Options/Classes/ConnectOptions.js";
|
|
4
|
+
import type { IConnect } from "./Options/Interfaces/IConnect.js";
|
|
5
5
|
export type IConnectMode = {
|
|
6
6
|
connect: IConnect;
|
|
7
7
|
};
|
|
@@ -15,3 +15,8 @@ export type ConnectContainer = Container & {
|
|
|
15
15
|
connectModeRadius?: number;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
export type LinkParticle = Particle & {
|
|
19
|
+
retina: {
|
|
20
|
+
linksWidth?: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
package/types/Utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ConnectContainer, LinkParticle } from "./Types.js";
|
|
2
|
+
import { type ICoordinates, type Particle } from "@tsparticles/engine";
|
|
3
|
+
export declare function gradient(context: CanvasRenderingContext2D, p1: Particle, p2: Particle, opacity: number): CanvasGradient | undefined;
|
|
4
|
+
export declare function drawConnectLine(context: CanvasRenderingContext2D, width: number, lineStyle: CanvasGradient, begin: ICoordinates, end: ICoordinates): void;
|
|
5
|
+
export declare function lineStyle(container: ConnectContainer, ctx: CanvasRenderingContext2D, p1: Particle, p2: Particle): CanvasGradient | undefined;
|
|
6
|
+
export declare function drawConnection(container: ConnectContainer, p1: LinkParticle, p2: LinkParticle): void;
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadExternalConnectInteraction(engine: Engine): Promise<void>;
|
|
3
|
-
export * from "./Options/Classes/Connect";
|
|
4
|
-
export * from "./Options/Classes/ConnectLinks";
|
|
5
|
-
export * from "./Options/Interfaces/IConnect";
|
|
6
|
-
export * from "./Options/Interfaces/IConnectLinks";
|
|
2
|
+
export declare function loadExternalConnectInteraction(engine: Engine, refresh?: boolean): Promise<void>;
|
|
3
|
+
export * from "./Options/Classes/Connect.js";
|
|
4
|
+
export * from "./Options/Classes/ConnectLinks.js";
|
|
5
|
+
export * from "./Options/Interfaces/IConnect.js";
|
|
6
|
+
export * from "./Options/Interfaces/IConnectLinks.js";
|
package/umd/Connector.js
CHANGED
|
@@ -4,49 +4,15 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Connect"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Connect.js", "./Utils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Connector = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const gradStop = Math.floor(p2.getRadius() / p1.getRadius()), color1 = p1.getFillColor(), color2 = p2.getFillColor();
|
|
17
|
-
if (!color1 || !color2) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const sourcePos = p1.getPosition(), destPos = p2.getPosition(), midRgb = (0, engine_1.colorMix)(color1, color2, p1.getRadius(), p2.getRadius()), grad = context.createLinearGradient(sourcePos.x, sourcePos.y, destPos.x, destPos.y);
|
|
21
|
-
grad.addColorStop(0, (0, engine_1.getStyleFromHsl)(color1, opacity));
|
|
22
|
-
grad.addColorStop(gradStop > 1 ? 1 : gradStop, (0, engine_1.getStyleFromRgb)(midRgb, opacity));
|
|
23
|
-
grad.addColorStop(1, (0, engine_1.getStyleFromHsl)(color2, opacity));
|
|
24
|
-
return grad;
|
|
25
|
-
}
|
|
26
|
-
function drawConnectLine(context, width, lineStyle, begin, end) {
|
|
27
|
-
(0, engine_1.drawLine)(context, begin, end);
|
|
28
|
-
context.lineWidth = width;
|
|
29
|
-
context.strokeStyle = lineStyle;
|
|
30
|
-
context.stroke();
|
|
31
|
-
}
|
|
32
|
-
function lineStyle(container, ctx, p1, p2) {
|
|
33
|
-
const options = container.actualOptions, connectOptions = options.interactivity.modes.connect;
|
|
34
|
-
if (!connectOptions) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
return gradient(ctx, p1, p2, connectOptions.links.opacity);
|
|
38
|
-
}
|
|
39
|
-
function drawConnection(container, p1, p2) {
|
|
40
|
-
container.canvas.draw((ctx) => {
|
|
41
|
-
var _a;
|
|
42
|
-
const ls = lineStyle(container, ctx, p1, p2);
|
|
43
|
-
if (!ls) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const pos1 = p1.getPosition(), pos2 = p2.getPosition();
|
|
47
|
-
drawConnectLine(ctx, (_a = p1.retina.linksWidth) !== null && _a !== void 0 ? _a : 0, ls, pos1, pos2);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
14
|
+
const Connect_js_1 = require("./Options/Classes/Connect.js");
|
|
15
|
+
const Utils_js_1 = require("./Utils.js");
|
|
50
16
|
class Connector extends engine_1.ExternalInteractorBase {
|
|
51
17
|
constructor(container) {
|
|
52
18
|
super(container);
|
|
@@ -79,7 +45,7 @@
|
|
|
79
45
|
for (const p2 of query.slice(i + 1)) {
|
|
80
46
|
const pos2 = p2.getPosition(), distMax = Math.abs(container.retina.connectModeDistance), xDiff = Math.abs(pos1.x - pos2.x), yDiff = Math.abs(pos1.y - pos2.y);
|
|
81
47
|
if (xDiff < distMax && yDiff < distMax) {
|
|
82
|
-
drawConnection(container, p1, p2);
|
|
48
|
+
(0, Utils_js_1.drawConnection)(container, p1, p2);
|
|
83
49
|
}
|
|
84
50
|
}
|
|
85
51
|
++i;
|
|
@@ -87,8 +53,7 @@
|
|
|
87
53
|
}
|
|
88
54
|
}
|
|
89
55
|
isEnabled(particle) {
|
|
90
|
-
|
|
91
|
-
const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events;
|
|
56
|
+
const container = this.container, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
92
57
|
if (!(events.onHover.enable && mouse.position)) {
|
|
93
58
|
return false;
|
|
94
59
|
}
|
|
@@ -96,10 +61,10 @@
|
|
|
96
61
|
}
|
|
97
62
|
loadModeOptions(options, ...sources) {
|
|
98
63
|
if (!options.connect) {
|
|
99
|
-
options.connect = new
|
|
64
|
+
options.connect = new Connect_js_1.Connect();
|
|
100
65
|
}
|
|
101
66
|
for (const source of sources) {
|
|
102
|
-
options.connect.load(source
|
|
67
|
+
options.connect.load(source?.connect);
|
|
103
68
|
}
|
|
104
69
|
}
|
|
105
70
|
reset() {
|
|
@@ -4,40 +4,27 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./ConnectLinks"], factory);
|
|
7
|
+
define(["require", "exports", "./ConnectLinks.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Connect = void 0;
|
|
13
|
-
const
|
|
13
|
+
const ConnectLinks_js_1 = require("./ConnectLinks.js");
|
|
14
14
|
class Connect {
|
|
15
15
|
constructor() {
|
|
16
16
|
this.distance = 80;
|
|
17
|
-
this.links = new
|
|
17
|
+
this.links = new ConnectLinks_js_1.ConnectLinks();
|
|
18
18
|
this.radius = 60;
|
|
19
19
|
}
|
|
20
|
-
get lineLinked() {
|
|
21
|
-
return this.links;
|
|
22
|
-
}
|
|
23
|
-
set lineLinked(value) {
|
|
24
|
-
this.links = value;
|
|
25
|
-
}
|
|
26
|
-
get line_linked() {
|
|
27
|
-
return this.links;
|
|
28
|
-
}
|
|
29
|
-
set line_linked(value) {
|
|
30
|
-
this.links = value;
|
|
31
|
-
}
|
|
32
20
|
load(data) {
|
|
33
|
-
var _a, _b;
|
|
34
21
|
if (!data) {
|
|
35
22
|
return;
|
|
36
23
|
}
|
|
37
24
|
if (data.distance !== undefined) {
|
|
38
25
|
this.distance = data.distance;
|
|
39
26
|
}
|
|
40
|
-
this.links.load(
|
|
27
|
+
this.links.load(data.links);
|
|
41
28
|
if (data.radius !== undefined) {
|
|
42
29
|
this.radius = data.radius;
|
|
43
30
|
}
|
package/umd/Utils.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.drawConnection = exports.lineStyle = exports.drawConnectLine = exports.gradient = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
function gradient(context, p1, p2, opacity) {
|
|
15
|
+
const gradStop = Math.floor(p2.getRadius() / p1.getRadius()), color1 = p1.getFillColor(), color2 = p2.getFillColor();
|
|
16
|
+
if (!color1 || !color2) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const sourcePos = p1.getPosition(), destPos = p2.getPosition(), midRgb = (0, engine_1.colorMix)(color1, color2, p1.getRadius(), p2.getRadius()), grad = context.createLinearGradient(sourcePos.x, sourcePos.y, destPos.x, destPos.y);
|
|
20
|
+
grad.addColorStop(0, (0, engine_1.getStyleFromHsl)(color1, opacity));
|
|
21
|
+
grad.addColorStop(gradStop > 1 ? 1 : gradStop, (0, engine_1.getStyleFromRgb)(midRgb, opacity));
|
|
22
|
+
grad.addColorStop(1, (0, engine_1.getStyleFromHsl)(color2, opacity));
|
|
23
|
+
return grad;
|
|
24
|
+
}
|
|
25
|
+
exports.gradient = gradient;
|
|
26
|
+
function drawConnectLine(context, width, lineStyle, begin, end) {
|
|
27
|
+
(0, engine_1.drawLine)(context, begin, end);
|
|
28
|
+
context.lineWidth = width;
|
|
29
|
+
context.strokeStyle = lineStyle;
|
|
30
|
+
context.stroke();
|
|
31
|
+
}
|
|
32
|
+
exports.drawConnectLine = drawConnectLine;
|
|
33
|
+
function lineStyle(container, ctx, p1, p2) {
|
|
34
|
+
const options = container.actualOptions, connectOptions = options.interactivity.modes.connect;
|
|
35
|
+
if (!connectOptions) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
return gradient(ctx, p1, p2, connectOptions.links.opacity);
|
|
39
|
+
}
|
|
40
|
+
exports.lineStyle = lineStyle;
|
|
41
|
+
function drawConnection(container, p1, p2) {
|
|
42
|
+
container.canvas.draw((ctx) => {
|
|
43
|
+
const ls = lineStyle(container, ctx, p1, p2);
|
|
44
|
+
if (!ls) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const pos1 = p1.getPosition(), pos2 = p2.getPosition();
|
|
48
|
+
drawConnectLine(ctx, p1.retina.linksWidth ?? 0, ls, pos1, pos2);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.drawConnection = drawConnection;
|
|
52
|
+
});
|
package/umd/index.js
CHANGED
|
@@ -18,19 +18,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
if (v !== undefined) module.exports = v;
|
|
19
19
|
}
|
|
20
20
|
else if (typeof define === "function" && define.amd) {
|
|
21
|
-
define(["require", "exports", "./Connector", "./Options/Classes/Connect", "./Options/Classes/ConnectLinks", "./Options/Interfaces/IConnect", "./Options/Interfaces/IConnectLinks"], factory);
|
|
21
|
+
define(["require", "exports", "./Connector.js", "./Options/Classes/Connect.js", "./Options/Classes/ConnectLinks.js", "./Options/Interfaces/IConnect.js", "./Options/Interfaces/IConnectLinks.js"], factory);
|
|
22
22
|
}
|
|
23
23
|
})(function (require, exports) {
|
|
24
24
|
"use strict";
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.loadExternalConnectInteraction = void 0;
|
|
27
|
-
const
|
|
28
|
-
async function loadExternalConnectInteraction(engine) {
|
|
29
|
-
await engine.addInteractor("externalConnect", (container) => new
|
|
27
|
+
const Connector_js_1 = require("./Connector.js");
|
|
28
|
+
async function loadExternalConnectInteraction(engine, refresh = true) {
|
|
29
|
+
await engine.addInteractor("externalConnect", (container) => new Connector_js_1.Connector(container), refresh);
|
|
30
30
|
}
|
|
31
31
|
exports.loadExternalConnectInteraction = loadExternalConnectInteraction;
|
|
32
|
-
__exportStar(require("./Options/Classes/Connect"), exports);
|
|
33
|
-
__exportStar(require("./Options/Classes/ConnectLinks"), exports);
|
|
34
|
-
__exportStar(require("./Options/Interfaces/IConnect"), exports);
|
|
35
|
-
__exportStar(require("./Options/Interfaces/IConnectLinks"), exports);
|
|
32
|
+
__exportStar(require("./Options/Classes/Connect.js"), exports);
|
|
33
|
+
__exportStar(require("./Options/Classes/ConnectLinks.js"), exports);
|
|
34
|
+
__exportStar(require("./Options/Interfaces/IConnect.js"), exports);
|
|
35
|
+
__exportStar(require("./Options/Interfaces/IConnectLinks.js"), exports);
|
|
36
36
|
});
|