UNPKG

@tsparticles/interaction-external-grab

Version:

tsParticles grab external interaction

29 lines (28 loc) 1.19 kB
(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.drawGrabLine = drawGrabLine; exports.drawGrab = drawGrab; const engine_1 = require("@tsparticles/engine"); const defaultWidth = 0; function drawGrabLine(context, width, begin, end, colorLine, opacity) { (0, engine_1.drawLine)(context, begin, end); context.strokeStyle = (0, engine_1.getStyleFromRgb)(colorLine, opacity); context.lineWidth = width; context.stroke(); } function drawGrab(container, particle, lineColor, opacity, mousePos) { container.canvas.draw(ctx => { const beginPos = particle.getPosition(); drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity); }); } });