(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "tsparticles-engine"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.drawLinkTriangle = exports.drawLinkLine = void 0; const tsparticles_engine_1 = require("tsparticles-engine"); function drawLinkLine(context, width, begin, end, maxDistance, canvasSize, warp, backgroundMask, composite, colorLine, opacity, shadow) { let drawn = false; if ((0, tsparticles_engine_1.getDistance)(begin, end) <= maxDistance) { (0, tsparticles_engine_1.drawLine)(context, begin, end); drawn = true; } else if (warp) { let pi1; let pi2; const endNE = { x: end.x - canvasSize.width, y: end.y, }; const d1 = (0, tsparticles_engine_1.getDistances)(begin, endNE); if (d1.distance <= maxDistance) { const yi = begin.y - (d1.dy / d1.dx) * begin.x; pi1 = { x: 0, y: yi }; pi2 = { x: canvasSize.width, y: yi }; } else { const endSW = { x: end.x, y: end.y - canvasSize.height, }; const d2 = (0, tsparticles_engine_1.getDistances)(begin, endSW); if (d2.distance <= maxDistance) { const yi = begin.y - (d2.dy / d2.dx) * begin.x; const xi = -yi / (d2.dy / d2.dx); pi1 = { x: xi, y: 0 }; pi2 = { x: xi, y: canvasSize.height }; } else { const endSE = { x: end.x - canvasSize.width, y: end.y - canvasSize.height, }; const d3 = (0, tsparticles_engine_1.getDistances)(begin, endSE); if (d3.distance <= maxDistance) { const yi = begin.y - (d3.dy / d3.dx) * begin.x; const xi = -yi / (d3.dy / d3.dx); pi1 = { x: xi, y: yi }; pi2 = { x: pi1.x + canvasSize.width, y: pi1.y + canvasSize.height }; } } } if (pi1 && pi2) { (0, tsparticles_engine_1.drawLine)(context, begin, pi1); (0, tsparticles_engine_1.drawLine)(context, end, pi2); drawn = true; } } if (!drawn) { return; } context.lineWidth = width; if (backgroundMask) { context.globalCompositeOperation = composite; } context.strokeStyle = (0, tsparticles_engine_1.getStyleFromRgb)(colorLine, opacity); if (shadow.enable) { const shadowColor = (0, tsparticles_engine_1.rangeColorToRgb)(shadow.color); if (shadowColor) { context.shadowBlur = shadow.blur; context.shadowColor = (0, tsparticles_engine_1.getStyleFromRgb)(shadowColor); } } context.stroke(); } exports.drawLinkLine = drawLinkLine; function drawLinkTriangle(context, pos1, pos2, pos3, backgroundMask, composite, colorTriangle, opacityTriangle) { (0, tsparticles_engine_1.drawTriangle)(context, pos1, pos2, pos3); if (backgroundMask) { context.globalCompositeOperation = composite; } context.fillStyle = (0, tsparticles_engine_1.getStyleFromRgb)(colorTriangle, opacityTriangle); context.fill(); } exports.drawLinkTriangle = drawLinkTriangle; });