/*! * Author : Matteo Bruni * MIT license: https://opensource.org/licenses/MIT * Demo / Generator : https://particles.js.org/ * GitHub : https://www.github.com/matteobruni/tsparticles * How to use? : Check the GitHub README * v2.8.0 */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("tsparticles-engine")); else if(typeof define === 'function' && define.amd) define(["tsparticles-engine"], factory); else { var a = typeof exports === 'object' ? factory(require("tsparticles-engine")) : factory(root["window"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(this, (__WEBPACK_EXTERNAL_MODULE__961__) => { return /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ 961: /***/ ((module) => { module.exports = __WEBPACK_EXTERNAL_MODULE__961__; /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ (() => { /******/ // define __esModule on exports /******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "Connect": () => (/* reexport */ Connect), "ConnectLinks": () => (/* reexport */ ConnectLinks), "loadExternalConnectInteraction": () => (/* binding */ loadExternalConnectInteraction) }); // EXTERNAL MODULE: external {"commonjs":"tsparticles-engine","commonjs2":"tsparticles-engine","amd":"tsparticles-engine","root":"window"} var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(961); ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/ConnectLinks.js class ConnectLinks { constructor() { this.opacity = 0.5; } load(data) { if (!data) { return; } if (data.opacity !== undefined) { this.opacity = data.opacity; } } } ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Connect.js class Connect { constructor() { this.distance = 80; this.links = new ConnectLinks(); this.radius = 60; } get lineLinked() { return this.links; } set lineLinked(value) { this.links = value; } get line_linked() { return this.links; } set line_linked(value) { this.links = value; } load(data) { var _a, _b; if (!data) { return; } if (data.distance !== undefined) { this.distance = data.distance; } this.links.load((_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked); if (data.radius !== undefined) { this.radius = data.radius; } } } ;// CONCATENATED MODULE: ./dist/browser/Connector.js function gradient(context, p1, p2, opacity) { const gradStop = Math.floor(p2.getRadius() / p1.getRadius()), color1 = p1.getFillColor(), color2 = p2.getFillColor(); if (!color1 || !color2) { return; } const sourcePos = p1.getPosition(), destPos = p2.getPosition(), midRgb = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.colorMix)(color1, color2, p1.getRadius(), p2.getRadius()), grad = context.createLinearGradient(sourcePos.x, sourcePos.y, destPos.x, destPos.y); grad.addColorStop(0, (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getStyleFromHsl)(color1, opacity)); grad.addColorStop(gradStop > 1 ? 1 : gradStop, (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getStyleFromRgb)(midRgb, opacity)); grad.addColorStop(1, (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getStyleFromHsl)(color2, opacity)); return grad; } function drawConnectLine(context, width, lineStyle, begin, end) { (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.drawLine)(context, begin, end); context.lineWidth = width; context.strokeStyle = lineStyle; context.stroke(); } function lineStyle(container, ctx, p1, p2) { const options = container.actualOptions, connectOptions = options.interactivity.modes.connect; if (!connectOptions) { return; } return gradient(ctx, p1, p2, connectOptions.links.opacity); } function drawConnection(container, p1, p2) { container.canvas.draw(ctx => { var _a; const ls = lineStyle(container, ctx, p1, p2); if (!ls) { return; } const pos1 = p1.getPosition(), pos2 = p2.getPosition(); drawConnectLine(ctx, (_a = p1.retina.linksWidth) !== null && _a !== void 0 ? _a : 0, ls, pos1, pos2); }); } class Connector extends external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.ExternalInteractorBase { constructor(container) { super(container); } clear() {} init() { const container = this.container, connect = container.actualOptions.interactivity.modes.connect; if (!connect) { return; } container.retina.connectModeDistance = connect.distance * container.retina.pixelRatio; container.retina.connectModeRadius = connect.radius * container.retina.pixelRatio; } async interact() { const container = this.container, options = container.actualOptions; if (options.interactivity.events.onHover.enable && container.interactivity.status === "pointermove") { const mousePos = container.interactivity.mouse.position; if (!container.retina.connectModeDistance || container.retina.connectModeDistance < 0 || !container.retina.connectModeRadius || container.retina.connectModeRadius < 0 || !mousePos) { return; } const distance = Math.abs(container.retina.connectModeRadius), query = container.particles.quadTree.queryCircle(mousePos, distance, p => this.isEnabled(p)); let i = 0; for (const p1 of query) { const pos1 = p1.getPosition(); for (const p2 of query.slice(i + 1)) { const pos2 = p2.getPosition(), distMax = Math.abs(container.retina.connectModeDistance), xDiff = Math.abs(pos1.x - pos2.x), yDiff = Math.abs(pos1.y - pos2.y); if (xDiff < distMax && yDiff < distMax) { drawConnection(container, p1, p2); } } ++i; } } } isEnabled(particle) { var _a; 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; if (!(events.onHover.enable && mouse.position)) { return false; } return (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.isInArray)("connect", events.onHover.mode); } loadModeOptions(options, ...sources) { if (!options.connect) { options.connect = new Connect(); } for (const source of sources) { options.connect.load(source === null || source === void 0 ? void 0 : source.connect); } } reset() {} } ;// CONCATENATED MODULE: ./dist/browser/index.js async function loadExternalConnectInteraction(engine) { await engine.addInteractor("externalConnect", container => new Connector(container)); } })(); /******/ return __webpack_exports__; /******/ })() ; });