1( function( $ ) { 2 /*! 3 * Author : Matteo Bruni - https://www.matteobruni.it 4 * MIT license: https://opensource.org/licenses/MIT 5 * Demo / Generator : https://particles.matteobruni.it/ 6 * GitHub : https://www.github.com/matteobruni/tsparticles 7 * How to use? : Check the GitHub README 8 * v1.18.11 9 */ 10 (function webpackUniversalModuleDefinition(root, factory) { 11 if(typeof exports === 'object' && typeof module === 'object') 12 module.exports = factory(); 13 else if(typeof define === 'function' && define.amd) 14 define([], factory); 15 else { 16 var a = factory(); 17 for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; 18 } 19 })(this, function() { 20 return /******/ (() => { // webpackBootstrap 21 /******/ "use strict"; 22 /******/ var __webpack_modules__ = ({ 23 24 /***/ 714: 25 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 26 27 // ESM COMPAT FLAG 28 __webpack_require__.r(__webpack_exports__); 29 30 // EXPORTS 31 __webpack_require__.d(__webpack_exports__, { 32 "AbsorberClickMode": () => /* reexport */ AbsorberClickMode, 33 "AnimationStatus": () => /* reexport */ AnimationStatus, 34 "CanvasUtils": () => /* reexport */ CanvasUtils, 35 "ClickMode": () => /* reexport */ ClickMode, 36 "CollisionMode": () => /* reexport */ CollisionMode, 37 "ColorUtils": () => /* reexport */ ColorUtils, 38 "Constants": () => /* reexport */ Constants, 39 "Container": () => /* reexport */ Container, 40 "DestroyType": () => /* reexport */ DestroyType, 41 "DivMode": () => /* reexport */ DivMode, 42 "DivType": () => /* reexport */ DivType, 43 "EmitterClickMode": () => /* reexport */ EmitterClickMode, 44 "HoverMode": () => /* reexport */ HoverMode, 45 "InlineArrangement": () => /* reexport */ InlineArrangement, 46 "InteractivityDetect": () => /* reexport */ InteractivityDetect, 47 "MoveDirection": () => /* reexport */ MoveDirection, 48 "MoveType": () => /* reexport */ MoveType, 49 "OutMode": () => /* reexport */ OutMode, 50 "ProcessBubbleType": () => /* reexport */ ProcessBubbleType, 51 "RotateDirection": () => /* reexport */ RotateDirection, 52 "ShapeType": () => /* reexport */ ShapeType, 53 "SizeMode": () => /* reexport */ SizeMode, 54 "StartValueType": () => /* reexport */ StartValueType, 55 "ThemeMode": () => /* reexport */ ThemeMode, 56 "Type": () => /* reexport */ Type, 57 "Utils": () => /* reexport */ Utils, 58 "pJSDom": () => /* binding */ pJSDom, 59 "particlesJS": () => /* binding */ particlesJS, 60 "tsParticles": () => /* binding */ tsParticles 61 }); 62 63 // CONCATENATED MODULE: ./dist/browser/pjs.js 64 const initPjs = main => { 65 const particlesJS = (tagId, options) => { 66 return main.load(tagId, options); 67 }; 68 69 particlesJS.load = (tagId, pathConfigJson, callback) => { 70 main.loadJSON(tagId, pathConfigJson).then(container => { 71 if (container) { 72 callback(container); 73 } 74 }); 75 }; 76 77 particlesJS.setOnClickHandler = callback => { 78 main.setOnClickHandler(callback); 79 }; 80 81 const pJSDom = main.dom(); 82 return { 83 particlesJS, 84 pJSDom 85 }; 86 }; 87 88 89 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/SquareDrawer.js 90 class SquareDrawer { 91 getSidesCount() { 92 return 4; 93 } 94 95 draw(context, particle, radius) { 96 context.rect(-radius, -radius, radius * 2, radius * 2); 97 } 98 99 } 100 // CONCATENATED MODULE: ./dist/browser/Enums/Directions/OutModeDirection.js 101 var OutModeDirection; 102 103 (function (OutModeDirection) { 104 OutModeDirection["bottom"] = "bottom"; 105 OutModeDirection["left"] = "left"; 106 OutModeDirection["right"] = "right"; 107 OutModeDirection["top"] = "top"; 108 })(OutModeDirection || (OutModeDirection = {})); 109 // CONCATENATED MODULE: ./dist/browser/Enums/Directions/MoveDirection.js 110 var MoveDirection; 111 112 (function (MoveDirection) { 113 MoveDirection["bottom"] = "bottom"; 114 MoveDirection["bottomLeft"] = "bottom-left"; 115 MoveDirection["bottomRight"] = "bottom-right"; 116 MoveDirection["left"] = "left"; 117 MoveDirection["none"] = "none"; 118 MoveDirection["right"] = "right";
119 MoveDirection["top"] = "top"; 120 MoveDirection["topLeft"] = "top-left"; 121 MoveDirection["topRight"] = "top-right"; 122 })(MoveDirection || (MoveDirection = {})); 123 // CONCATENATED MODULE: ./dist/browser/Enums/Directions/RotateDirection.js 124 var RotateDirection; 125 126 (function (RotateDirection) { 127 RotateDirection["clockwise"] = "clockwise"; 128 RotateDirection["counterClockwise"] = "counter-clockwise"; 129 RotateDirection["random"] = "random"; 130 })(RotateDirection || (RotateDirection = {})); 131 // CONCATENATED MODULE: ./dist/browser/Enums/Directions/index.js 132 133 134 // CONCATENATED MODULE: ./dist/browser/Utils/NumberUtils.js 135 136 class NumberUtils { 137 static clamp(num, min, max) { 138 return Math.min(Math.max(num, min), max); 139 } 140 141 static mix(comp1, comp2, weight1, weight2) { 142 return Math.floor((comp1 * weight1 + comp2 * weight2) / (weight1 + weight2)); 143 } 144 145 static randomInRange(r1, r2) { 146 const max = Math.max(r1, r2), 147 min = Math.min(r1, r2); 148 return Math.random() * (max - min) + min; 149 } 150 151 static getValue(options) { 152 const random = options.random; 153 const { 154 enable, 155 minimumValue 156 } = typeof random === "boolean" ? { 157 enable: random, 158 minimumValue: 0 159 } : random; 160 return enable ? NumberUtils.randomInRange(minimumValue, options.value) : options.value; 161 } 162 163 static getDistances(pointA, pointB) { 164 const dx = pointA.x - pointB.x; 165 const dy = pointA.y - pointB.y; 166 return { 167 dx: dx, 168 dy: dy, 169 distance: Math.sqrt(dx * dx + dy * dy) 170 }; 171 } 172 173 static getDistance(pointA, pointB) { 174 return NumberUtils.getDistances(pointA, pointB).distance; 175 } 176 177 static getParticleBaseVelocity(particle) { 178 let velocityBase; 179 180 switch (particle.direction) { 181 case MoveDirection.top: 182 velocityBase = { 183 x: 0, 184 y: -1 185 }; 186 break; 187 188 case MoveDirection.topRight: 189 velocityBase = { 190 x: 0.5, 191 y: -0.5 192 }; 193 break; 194 195 case MoveDirection.right: 196 velocityBase = { 197 x: 1, 198 y: -0 199 }; 200 break; 201 202 case MoveDirection.bottomRight: 203 velocityBase = { 204 x: 0.5, 205 y: 0.5 206 }; 207 break; 208 209 case MoveDirection.bottom: 210 velocityBase = { 211 x: 0, 212 y: 1 213 }; 214 break; 215 216 case MoveDirection.bottomLeft: 217 velocityBase = { 218 x: -0.5, 219 y: 1 220 }; 221 break; 222 223 case MoveDirection.left: 224 velocityBase = { 225 x: -1, 226 y: 0 227 }; 228 break; 229 230 case MoveDirection.topLeft: 231 velocityBase = { 232 x: -0.5, 233 y: -0.5 234 }; 235 break; 236 237 default: 238 velocityBase = { 239 x: 0, 240 y: 0 241 }; 242 break; 243 } 244 245 return velocityBase; 246 } 247 248 static rotateVelocity(velocity, angle) { 249 return { 250 horizontal: velocity.horizontal * Math.cos(angle) - velocity.vertical * Math.sin(angle), 251 vertical: velocity.horizontal * Math.sin(angle) + velocity.vertical * Math.cos(angle) 252 }; 253 } 254 255 static collisionVelocity(v1, v2, m1, m2) { 256 return { 257 horizontal: v1.horizontal * (m1 - m2) / (m1 + m2) + v2.horizontal * 2 * m2 / (m1 + m2), 258 vertical: v1.vertical 259 }; 260 } 261 262 } 263 // CONCATENATED MODULE: ./dist/browser/Utils/Utils.js 264 var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { 265 function adopt(value) { 266 return value instanceof P ? value : new P(function (resolve) { 267 resolve(value); 268 }); 269 } 270 271 return new (P || (P = Promise))(function (resolve, reject) { 272 function fulfilled(value) { 273 try { 274 step(generator.next(value)); 275 } catch (e) { 276 reject(e); 277 } 278 } 279 280 function rejected(value) { 281 try { 282 step(generator["throw"](value)); 283 } catch (e) { 284 reject(e); 285 } 286 } 287 288 function step(result) { 289 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 290 } 291 292 step((generator = generator.apply(thisArg, _arguments || [])).next()); 293 }); 294 }; 295 296 297 function rectSideBounce(pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor) { 298 const res = {
299 bounced: false 300 }; 301 302 if (pOtherSide.min >= rectOtherSide.min && pOtherSide.min <= rectOtherSide.max && pOtherSide.max >= rectOtherSide.min && pOtherSide.max <= rectOtherSide.max) { 303 if (pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) / 2 && velocity > 0 || pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) / 2 && velocity < 0) { 304 res.velocity = velocity * -factor; 305 res.bounced = true; 306 } 307 } 308 309 return res; 310 } 311 312 function checkSelector(element, selectors) { 313 if (selectors instanceof Array) { 314 for (const selector of selectors) { 315 if (element.matches(selector)) { 316 return true; 317 } 318 } 319 320 return false; 321 } else { 322 return element.matches(selectors); 323 } 324 } 325 326 class Utils { 327 static isSsr() { 328 return typeof window === "undefined" || !window; 329 } 330 331 static get animate() { 332 return Utils.isSsr() ? callback => setTimeout(callback) : callback => (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || window.setTimeout)(callback); 333 } 334 335 static get cancelAnimation() { 336 return Utils.isSsr() ? handle => clearTimeout(handle) : handle => (window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.clearTimeout)(handle); 337 } 338 339 static isInArray(value, array) { 340 return value === array || array instanceof Array && array.indexOf(value) > -1; 341 } 342 343 static loadFont(character) { 344 return __awaiter(this, void 0, void 0, function* () { 345 try { 346 yield document.fonts.load(`${character.weight} 36px '${character.font}'`); 347 } catch (_a) {} 348 }); 349 } 350 351 static arrayRandomIndex(array) { 352 return Math.floor(Math.random() * array.length); 353 } 354 355 static itemFromArray(array, index, useIndex = true) { 356 const fixedIndex = index !== undefined && useIndex ? index % array.length : Utils.arrayRandomIndex(array); 357 return array[fixedIndex]; 358 } 359 360 static isPointInside(point, size, radius, direction) { 361 return Utils.areBoundsInside(Utils.calculateBounds(point, radius !== null && radius !== void 0 ? radius : 0), size, direction); 362 } 363 364 static areBoundsInside(bounds, size, direction) { 365 let inside = true; 366 367 if (!direction || direction === OutModeDirection.bottom) { 368 inside = bounds.top < size.height; 369 } 370 371 if (inside && (!direction || direction === OutModeDirection.left)) { 372 inside = bounds.right > 0; 373 } 374 375 if (inside && (!direction || direction === OutModeDirection.right)) { 376 inside = bounds.left < size.width; 377 } 378 379 if (inside && (!direction || direction === OutModeDirection.top)) { 380 inside = bounds.bottom > 0; 381 } 382 383 return inside; 384 } 385 386 static calculateBounds(point, radius) { 387 return { 388 bottom: point.y + radius, 389 left: point.x - radius, 390 right: point.x + radius, 391 top: point.y - radius 392 }; 393 } 394 395 static loadImage(source) { 396 return new Promise((resolve, reject) => { 397 if (!source) { 398 reject("Error tsParticles - No image.src"); 399 return; 400 } 401 402 const image = { 403 source: source, 404 type: source.substr(source.length - 3) 405 }; 406 const img = new Image(); 407 img.addEventListener("load", () => { 408 image.element = img; 409 resolve(image); 410 }); 411 img.addEventListener("error", () => { 412 reject(`Error tsParticles - loading image: ${source}`); 413 }); 414 img.src = source; 415 }); 416 } 417 418 static downloadSvgImage(source) { 419 return __awaiter(this, void 0, void 0, function* () { 420 if (!source) { 421 throw new Error("Error tsParticles - No image.src"); 422 } 423 424 const image = { 425 source: source, 426 type: source.substr(source.length - 3) 427 }; 428 429 if (image.type !== "svg") { 430 return Utils.loadImage(source); 431 } 432 433 const response = yield fetch(image.source); 434 435 if (!response.ok) { 436 throw new Error("Error tsParticles - Image not found"); 437 } 438 439 image.svgData = yield response.text(); 440 return image; 441 }); 442 } 443 444 static deepExtend(destination, ...sources) { 445 for (const source of sources) { 446 if (source === undefined || source === null) { 447 continue; 448 } 449 450 if (typeof source !== "object") { 451 destination = source; 452 continue; 453 } 454 455 const sourceIsArray = Array.isArray(source); 456 457 if (sourceIsArray && (typeof destination !== "object" || !destination || !Array.isArray(destination))) { 458 destination = []; 459 } else if (!sourceIsArray && (typeof destination !== "object" || !destination || Array.isArray(destination))) { 460 destination = {}; 461 } 462 463 for (const key in source) { 464 if (key === "__proto__") { 465 continue; 466 } 467 468 const sourceDict = source; 469 const value = sourceDict[key]; 470 const isObject = typeof value === "object"; 471 const destDict = destination; 472 destDict[key] = isObject && Array.isArray(value) ? value.map(v => Utils.deepExtend(destDict[key], v)) : Utils.deepExtend(destDict[key], value); 473 } 474 } 475 476 return destination; 477 } 478 479 static isDivModeEnabled(mode, divs) { 480 return divs instanceof Array ? !!divs.find(t => t.enable && Utils.isInArray(mode, t.mode)) : Utils.isInArray(mode, divs.mode); 481 } 482 483 static divModeExecute(mode, divs, callback) { 484 if (divs instanceof Array) { 485 for (const div of divs) { 486 const divMode = div.mode; 487 const divEnabled = div.enable; 488 489 if (divEnabled && Utils.isInArray(mode, divMode)) {
490 Utils.singleDivModeExecute(div, callback); 491 } 492 } 493 } else { 494 const divMode = divs.mode; 495 const divEnabled = divs.enable; 496 497 if (divEnabled && Utils.isInArray(mode, divMode)) { 498 Utils.singleDivModeExecute(divs, callback); 499 } 500 } 501 } 502 503 static singleDivModeExecute(div, callback) { 504 const selectors = div.selectors; 505 506 if (selectors instanceof Array) { 507 for (const selector of selectors) { 508 callback(selector, div); 509 } 510 } else { 511 callback(selectors, div); 512 } 513 } 514 515 static divMode(divs, element) { 516 if (!element || !divs) { 517 return; 518 } 519 520 if (divs instanceof Array) { 521 return divs.find(d => checkSelector(element, d.selectors)); 522 } else if (checkSelector(element, divs.selectors)) { 523 return divs; 524 } 525 } 526 527 static circleBounceDataFromParticle(p) { 528 return { 529 position: p.getPosition(), 530 radius: p.getRadius(), 531 velocity: p.velocity, 532 factor: { 533 horizontal: NumberUtils.getValue(p.particlesOptions.bounce.horizontal), 534 vertical: NumberUtils.getValue(p.particlesOptions.bounce.vertical) 535 } 536 }; 537 } 538 539 static circleBounce(p1, p2) { 540 const xVelocityDiff = p1.velocity.horizontal; 541 const yVelocityDiff = p1.velocity.vertical; 542 const pos1 = p1.position; 543 const pos2 = p2.position; 544 const xDist = pos2.x - pos1.x; 545 const yDist = pos2.y - pos1.y; 546 547 if (xVelocityDiff * xDist + yVelocityDiff * yDist >= 0) { 548 const angle = -Math.atan2(pos2.y - pos1.y, pos2.x - pos1.x); 549 const m1 = p1.radius; 550 const m2 = p2.radius; 551 const u1 = NumberUtils.rotateVelocity(p1.velocity, angle); 552 const u2 = NumberUtils.rotateVelocity(p2.velocity, angle); 553 const v1 = NumberUtils.collisionVelocity(u1, u2, m1, m2); 554 const v2 = NumberUtils.collisionVelocity(u2, u1, m1, m2); 555 const vFinal1 = NumberUtils.rotateVelocity(v1, -angle); 556 const vFinal2 = NumberUtils.rotateVelocity(v2, -angle); 557 p1.velocity.horizontal = vFinal1.horizontal * p1.factor.horizontal; 558 p1.velocity.vertical = vFinal1.vertical * p1.factor.vertical; 559 p2.velocity.horizontal = vFinal2.horizontal * p2.factor.horizontal; 560 p2.velocity.vertical = vFinal2.vertical * p2.factor.vertical; 561 } 562 } 563 564 static rectBounce(particle, divBounds) { 565 const pPos = particle.getPosition(); 566 const size = particle.getRadius(); 567 const bounds = Utils.calculateBounds(pPos, size); 568 const resH = rectSideBounce({ 569 min: bounds.left, 570 max: bounds.right 571 }, { 572 min: bounds.top, 573 max: bounds.bottom 574 }, { 575 min: divBounds.left, 576 max: divBounds.right 577 }, { 578 min: divBounds.top, 579 max: divBounds.bottom 580 }, particle.velocity.horizontal, NumberUtils.getValue(particle.particlesOptions.bounce.horizontal)); 581 582 if (resH.bounced) { 583 if (resH.velocity !== undefined) { 584 particle.velocity.horizontal = resH.velocity; 585 } 586 587 if (resH.position !== undefined) { 588 particle.position.x = resH.position; 589 } 590 } 591 592 const resV = rectSideBounce({ 593 min: bounds.top, 594 max: bounds.bottom 595 }, { 596 min: bounds.left, 597 max: bounds.right 598 }, { 599 min: divBounds.top, 600 max: divBounds.bottom 601 }, { 602 min: divBounds.left, 603 max: divBounds.right 604 }, particle.velocity.vertical, NumberUtils.getValue(particle.particlesOptions.bounce.vertical)); 605 606 if (resV.bounced) { 607 if (resV.velocity !== undefined) { 608 particle.velocity.vertical = resV.velocity; 609 } 610 611 if (resV.position !== undefined) { 612 particle.position.y = resV.position; 613 } 614 } 615 } 616 617 } 618 // CONCATENATED MODULE: ./dist/browser/Utils/Constants.js 619 class Constants {} 620 Constants.canvasClass = "tsparticles-canvas-el"; 621 Constants.randomColorValue = "random"; 622 Constants.midColorValue = "mid"; 623 Constants.touchEndEvent = "touchend"; 624 Constants.mouseDownEvent = "mousedown"; 625 Constants.mouseUpEvent = "mouseup"; 626 Constants.mouseMoveEvent = "mousemove"; 627 Constants.touchStartEvent = "touchstart"; 628 Constants.touchMoveEvent = "touchmove"; 629 Constants.mouseLeaveEvent = "mouseleave"; 630 Constants.mouseOutEvent = "mouseout"; 631 Constants.touchCancelEvent = "touchcancel"; 632 Constants.resizeEvent = "resize"; 633 Constants.visibilityChangeEvent = "visibilitychange"; 634 Constants.noPolygonDataLoaded = "No polygon data loaded.";
635 Constants.noPolygonFound = "No polygon found, you need to specify SVG url in config."; 636 // CONCATENATED MODULE: ./dist/browser/Utils/ColorUtils.js 637 638 function hue2rgb(p, q, t) { 639 let tCalc = t; 640 641 if (tCalc < 0) { 642 tCalc += 1; 643 } 644 645 if (tCalc > 1) { 646 tCalc -= 1; 647 } 648 649 if (tCalc < 1 / 6) { 650 return p + (q - p) * 6 * tCalc; 651 } 652 653 if (tCalc < 1 / 2) { 654 return q; 655 } 656 657 if (tCalc < 2 / 3) { 658 return p + (q - p) * (2 / 3 - tCalc) * 6; 659 } 660 661 return p; 662 } 663 664 function stringToRgba(input) { 665 if (input.startsWith("rgb")) { 666 const regex = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([\d.]+)\s*)?\)/i; 667 const result = regex.exec(input); 668 return result ? { 669 a: result.length > 4 ? parseFloat(result[5]) : 1, 670 b: parseInt(result[3], 10), 671 g: parseInt(result[2], 10), 672 r: parseInt(result[1], 10) 673 } : undefined; 674 } else if (input.startsWith("hsl")) { 675 const regex = /hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.]+)\s*)?\)/i; 676 const result = regex.exec(input); 677 return result ? ColorUtils.hslaToRgba({ 678 a: result.length > 4 ? parseFloat(result[5]) : 1, 679 h: parseInt(result[1], 10), 680 l: parseInt(result[3], 10), 681 s: parseInt(result[2], 10) 682 }) : undefined; 683 } else if (input.startsWith("hsv")) { 684 const regex = /hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.]+)\s*)?\)/i; 685 const result = regex.exec(input); 686 return result ? ColorUtils.hsvaToRgba({ 687 a: result.length > 4 ? parseFloat(result[5]) : 1, 688 h: parseInt(result[1], 10), 689 s: parseInt(result[2], 10), 690 v: parseInt(result[3], 10) 691 }) : undefined; 692 } else { 693 const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i; 694 const hexFixed = input.replace(shorthandRegex, (_m, r, g, b, a) => { 695 return r + r + g + g + b + b + (a !== undefined ? a + a : ""); 696 }); 697 const regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i; 698 const result = regex.exec(hexFixed); 699 return result ? { 700 a: result[4] !== undefined ? parseInt(result[4], 16) / 0xff : 1, 701 b: parseInt(result[3], 16), 702 g: parseInt(result[2], 16), 703 r: parseInt(result[1], 16) 704 } : undefined; 705 } 706 } 707 708 class ColorUtils { 709 static colorToRgb(input, index, useIndex = true) { 710 var _a, _b, _c; 711 712 if (input === undefined) { 713 return; 714 } 715 716 const color = typeof input === "string" ? { 717 value: input 718 } : input; 719 let res; 720 721 if (typeof color.value === "string") { 722 if (color.value === Constants.randomColorValue) { 723 res = ColorUtils.getRandomRgbColor(); 724 } else { 725 res = ColorUtils.stringToRgb(color.value); 726 } 727 } else { 728 if (color.value instanceof Array) { 729 const colorSelected = Utils.itemFromArray(color.value, index, useIndex); 730 res = ColorUtils.colorToRgb({ 731 value: colorSelected 732 }); 733 } else { 734 const colorValue = color.value; 735 const rgbColor = (_a = colorValue.rgb) !== null && _a !== void 0 ? _a : color.value; 736 737 if (rgbColor.r !== undefined) { 738 res = rgbColor; 739 } else { 740 const hslColor = (_b = colorValue.hsl) !== null && _b !== void 0 ? _b : color.value; 741 742 if (hslColor.h !== undefined && hslColor.l !== undefined) { 743 res = ColorUtils.hslToRgb(hslColor); 744 } else { 745 const hsvColor = (_c = colorValue.hsv) !== null && _c !== void 0 ? _c : color.value; 746 747 if (hsvColor.h !== undefined && hsvColor.v !== undefined) { 748 res = ColorUtils.hsvToRgb(hsvColor); 749 } 750 } 751 } 752 } 753 } 754 755 return res; 756 } 757 758 static colorToHsl(color, index, useIndex = true) { 759 const rgb = ColorUtils.colorToRgb(color, index, useIndex); 760 return rgb !== undefined ? ColorUtils.rgbToHsl(rgb) : undefined; 761 } 762 763 static rgbToHsl(color) { 764 const r1 = color.r / 255; 765 const g1 = color.g / 255; 766 const b1 = color.b / 255; 767 const max = Math.max(r1, g1, b1); 768 const min = Math.min(r1, g1, b1); 769 const res = { 770 h: 0, 771 l: (max + min) / 2, 772 s: 0 773 }; 774 775 if (max != min) { 776 res.s = res.l < 0.5 ? (max - min) / (max + min) : (max - min) / (2.0 - max - min); 777 res.h = r1 === max ? (g1 - b1) / (max - min) : res.h = g1 === max ? 2.0 + (b1 - r1) / (max - min) : 4.0 + (r1 - g1) / (max - min); 778 } 779 780 res.l *= 100; 781 res.s *= 100; 782 res.h *= 60; 783 784 if (res.h < 0) { 785 res.h += 360; 786 } 787 788 return res; 789 } 790 791 static stringToAlpha(input) { 792 var _a; 793 794 return (_a = stringToRgba(input)) === null || _a === void 0 ? void 0 : _a.a; 795 } 796 797 static stringToRgb(input) { 798 return stringToRgba(input); 799 } 800 801 static hslToRgb(hsl) { 802 const result = { 803 b: 0, 804 g: 0, 805 r: 0 806 }; 807 const hslPercent = { 808 h: hsl.h / 360, 809 l: hsl.l / 100, 810 s: hsl.s / 100 811 }; 812 813 if (hslPercent.s === 0) { 814 result.b = hslPercent.l; 815 result.g = hslPercent.l; 816 result.r = hslPercent.l; 817 } else { 818 const q = hslPercent.l < 0.5 ? hslPercent.l * (1 + hslPercent.s) : hslPercent.l + hslPercent.s - hslPercent.l * hslPercent.s; 819 const p = 2 * hslPercent.l - q; 820 result.r = hue2rgb(p, q, hslPercent.h + 1 / 3); 821 result.g = hue2rgb(p, q, hslPercent.h); 822 result.b = hue2rgb(p, q, hslPercent.h - 1 / 3); 823 } 824 825 result.r = Math.floor(result.r * 255); 826 result.g = Math.floor(result.g * 255); 827 result.b = Math.floor(result.b * 255); 828 return result; 829 } 830 831 static hslaToRgba(hsla) { 832 const rgbResult = ColorUtils.hslToRgb(hsla); 833 return { 834 a: hsla.a,
835 b: rgbResult.b, 836 g: rgbResult.g, 837 r: rgbResult.r 838 }; 839 } 840 841 static hslToHsv(hsl) { 842 const l = hsl.l / 100, 843 sl = hsl.s / 100; 844 const v = l + sl * Math.min(l, 1 - l), 845 sv = !v ? 0 : 2 * (1 - l / v); 846 return { 847 h: hsl.h, 848 s: sv * 100, 849 v: v * 100 850 }; 851 } 852 853 static hslaToHsva(hsla) { 854 const hsvResult = ColorUtils.hslToHsv(hsla); 855 return { 856 a: hsla.a, 857 h: hsvResult.h, 858 s: hsvResult.s, 859 v: hsvResult.v 860 }; 861 } 862 863 static hsvToHsl(hsv) { 864 const v = hsv.v / 100, 865 sv = hsv.s / 100; 866 const l = v * (1 - sv / 2), 867 sl = l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l); 868 return { 869 h: hsv.h, 870 l: l * 100, 871 s: sl * 100 872 }; 873 } 874 875 static hsvaToHsla(hsva) { 876 const hslResult = ColorUtils.hsvToHsl(hsva); 877 return { 878 a: hsva.a, 879 h: hslResult.h, 880 l: hslResult.l, 881 s: hslResult.s 882 }; 883 } 884 885 static hsvToRgb(hsv) { 886 const result = { 887 b: 0, 888 g: 0, 889 r: 0 890 }; 891 const hsvPercent = { 892 h: hsv.h / 60, 893 s: hsv.s / 100, 894 v: hsv.v / 100 895 }; 896 const c = hsvPercent.v * hsvPercent.s, 897 x = c * (1 - Math.abs(hsvPercent.h % 2 - 1)); 898 let tempRgb; 899 900 if (hsvPercent.h >= 0 && hsvPercent.h <= 1) { 901 tempRgb = { 902 r: c, 903 g: x, 904 b: 0 905 }; 906 } else if (hsvPercent.h > 1 && hsvPercent.h <= 2) { 907 tempRgb = { 908 r: x, 909 g: c, 910 b: 0 911 }; 912 } else if (hsvPercent.h > 2 && hsvPercent.h <= 3) { 913 tempRgb = { 914 r: 0, 915 g: c, 916 b: x 917 }; 918 } else if (hsvPercent.h > 3 && hsvPercent.h <= 4) { 919 tempRgb = { 920 r: 0, 921 g: x, 922 b: c 923 }; 924 } else if (hsvPercent.h > 4 && hsvPercent.h <= 5) { 925 tempRgb = { 926 r: x, 927 g: 0, 928 b: c 929 }; 930 } else if (hsvPercent.h > 5 && hsvPercent.h <= 6) { 931 tempRgb = { 932 r: c, 933 g: 0, 934 b: x 935 }; 936 } 937 938 if (tempRgb) { 939 const m = hsvPercent.v - c; 940 result.r = Math.floor((tempRgb.r + m) * 255); 941 result.g = Math.floor((tempRgb.g + m) * 255); 942 result.b = Math.floor((tempRgb.b + m) * 255); 943 } 944 945 return result; 946 } 947 948 static hsvaToRgba(hsva) { 949 const rgbResult = ColorUtils.hsvToRgb(hsva); 950 return { 951 a: hsva.a, 952 b: rgbResult.b, 953 g: rgbResult.g, 954 r: rgbResult.r 955 }; 956 } 957 958 static rgbToHsv(rgb) { 959 const rgbPercent = { 960 r: rgb.r / 255, 961 g: rgb.g / 255, 962 b: rgb.b / 255 963 }, 964 xMax = Math.max(rgbPercent.r, rgbPercent.g, rgbPercent.b), 965 xMin = Math.min(rgbPercent.r, rgbPercent.g, rgbPercent.b), 966 v = xMax, 967 c = xMax - xMin; 968 let h = 0; 969 970 if (v === rgbPercent.r) { 971 h = 60 * ((rgbPercent.g - rgbPercent.b) / c); 972 } else if (v === rgbPercent.g) { 973 h = 60 * (2 + (rgbPercent.b - rgbPercent.r) / c); 974 } else if (v === rgbPercent.b) { 975 h = 60 * (4 + (rgbPercent.r - rgbPercent.g) / c); 976 } 977 978 const s = !v ? 0 : c / v; 979 return { 980 h, 981 s: s * 100, 982 v: v * 100 983 }; 984 } 985 986 static rgbaToHsva(rgba) { 987 const hsvResult = ColorUtils.rgbToHsv(rgba); 988 return { 989 a: rgba.a, 990 h: hsvResult.h, 991 s: hsvResult.s, 992 v: hsvResult.v 993 }; 994 } 995 996 static getRandomRgbColor(min) { 997 const fixedMin = min !== null && min !== void 0 ? min : 0; 998 return { 999 b: Math.floor(NumberUtils.randomInRange(fixedMin, 256)), 1000 g: Math.floor(NumberUtils.randomInRange(fixedMin, 256)), 1001 r: Math.floor(NumberUtils.randomInRange(fixedMin, 256)) 1002 }; 1003 } 1004 1005 static getStyleFromRgb(color, opacity) { 1006 return `rgba(${color.r}, ${color.g}
1006, ${color.b}, ${opacity !== null && opacity !== void 0 ? opacity : 1})`; 1007 } 1008 1009 static getStyleFromHsl(color, opacity) { 1010 return `hsla(${color.h}, ${color.s}%, ${color.l}%, ${opacity !== null && opacity !== void 0 ? opacity : 1})`; 1011 } 1012 1013 static getStyleFromHsv(color, opacity) { 1014 return ColorUtils.getStyleFromHsl(ColorUtils.hsvToHsl(color), opacity); 1015 } 1016 1017 static mix(color1, color2, size1, size2) { 1018 let rgb1 = color1; 1019 let rgb2 = color2; 1020 1021 if (rgb1.r === undefined) { 1022 rgb1 = ColorUtils.hslToRgb(color1); 1023 } 1024 1025 if (rgb2.r === undefined) { 1026 rgb2 = ColorUtils.hslToRgb(color2); 1027 } 1028 1029 return { 1030 b: NumberUtils.mix(rgb1.b, rgb2.b, size1, size2), 1031 g: NumberUtils.mix(rgb1.g, rgb2.g, size1, size2), 1032 r: NumberUtils.mix(rgb1.r, rgb2.r, size1, size2) 1033 }; 1034 } 1035 1036 static replaceColorSvg(image, color, opacity) { 1037 if (!image.svgData) { 1038 return ""; 1039 } 1040 1041 const svgXml = image.svgData; 1042 const rgbHex = /#([0-9A-F]{3,6})/gi; 1043 return svgXml.replace(rgbHex, () => ColorUtils.getStyleFromHsl(color, opacity)); 1044 } 1045 1046 static getLinkColor(p1, p2, linkColor) { 1047 var _a, _b; 1048 1049 if (linkColor === Constants.randomColorValue) { 1050 return ColorUtils.getRandomRgbColor(); 1051 } else if (linkColor === "mid") { 1052 const sourceColor = (_a = p1.getFillColor()) !== null && _a !== void 0 ? _a : p1.getStrokeColor(); 1053 const destColor = (_b = p2 === null || p2 === void 0 ? void 0 : p2.getFillColor()) !== null && _b !== void 0 ? _b : p2 === null || p2 === void 0 ? void 0 : p2.getStrokeColor(); 1054 1055 if (sourceColor && destColor && p2) { 1056 return ColorUtils.mix(sourceColor, destColor, p1.getRadius(), p2.getRadius()); 1057 } else { 1058 const hslColor = sourceColor !== null && sourceColor !== void 0 ? sourceColor : destColor; 1059 1060 if (hslColor) { 1061 return ColorUtils.hslToRgb(hslColor); 1062 } 1063 } 1064 } else { 1065 return linkColor; 1066 } 1067 } 1068 1069 static getLinkRandomColor(optColor, blink, consent) { 1070 const color = typeof optColor === "string" ? optColor : optColor.value; 1071 1072 if (color === Constants.randomColorValue) { 1073 if (consent) { 1074 return ColorUtils.colorToRgb({ 1075 value: color 1076 }); 1077 } else if (blink) { 1078 return Constants.randomColorValue; 1079 } else { 1080 return Constants.midColorValue; 1081 } 1082 } else { 1083 return ColorUtils.colorToRgb({ 1084 value: color 1085 }); 1086 } 1087 } 1088 1089 } 1090 // CONCATENATED MODULE: ./dist/browser/Utils/CanvasUtils.js 1091 1092 function drawLine(context, begin, end) { 1093 context.beginPath(); 1094 context.moveTo(begin.x, begin.y); 1095 context.lineTo(end.x, end.y); 1096 context.closePath(); 1097 } 1098 1099 function drawTriangle(context, p1, p2, p3) { 1100 context.beginPath(); 1101 context.moveTo(p1.x, p1.y); 1102 context.lineTo(p2.x, p2.y); 1103 context.lineTo(p3.x, p3.y); 1104 context.closePath(); 1105 } 1106 1107 class CanvasUtils { 1108 static paintBase(context, dimension, baseColor) { 1109 context.save(); 1110 context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)"; 1111 context.fillRect(0, 0, dimension.width, dimension.height); 1112 context.restore(); 1113 } 1114 1115 static clear(context, dimension) { 1116 context.clearRect(0, 0, dimension.width, dimension.height); 1117 } 1118 1119 static drawLinkLine(context, width, begin, end, maxDistance, canvasSize, warp, backgroundMask, composite, colorLine, opacity, shadow) { 1120 let drawn = false; 1121 1122 if (NumberUtils.getDistance(begin, end) <= maxDistance) { 1123 drawLine(context, begin, end); 1124 drawn = true; 1125 } else if (warp) { 1126 let pi1; 1127 let pi2; 1128 const endNE = { 1129 x: end.x - canvasSize.width, 1130 y: end.y 1131 }; 1132 const d1 = NumberUtils.getDistances(begin, endNE); 1133 1134 if (d1.distance <= maxDistance) { 1135 const yi = begin.y - d1.dy / d1.dx * begin.x; 1136 pi1 = { 1137 x: 0, 1138 y: yi 1139 }; 1140 pi2 = { 1141 x: canvasSize.width, 1142 y: yi 1143 }; 1144 } else { 1145 const endSW = { 1146 x: end.x, 1147 y: end.y - canvasSize.height 1148 }; 1149 const d2 = NumberUtils.getDistances(begin, endSW); 1150 1151 if (d2.distance <= maxDistance) { 1152 const yi = begin.y - d2.dy / d2.dx * begin.x; 1153 const xi = -yi / (d2.dy / d2.dx); 1154 pi1 = { 1155 x: xi, 1156 y: 0 1157 }; 1158 pi2 = { 1159 x: xi, 1160 y: canvasSize.height 1161 }; 1162 } else { 1163 const endSE = { 1164 x: end.x - canvasSize.width, 1165 y: end.y - canvasSize.height 1166 }; 1167 const d3 = NumberUtils.getDistances(begin, endSE); 1168 1169 if (d3.distance <= maxDistance) { 1170 const yi = begin.y - d3.dy / d3.dx * begin.x; 1171 const xi = -yi / (d3.dy / d3.dx); 1172 pi1 = { 1173 x: xi, 1174 y: yi 1175 }; 1176 pi2 = { 1177 x: pi1.x + canvasSize.width, 1178 y: pi1.y + canvasSize.height 1179 }; 1180 } 1181 } 1182 } 1183 1184 if (pi1 && pi2) { 1185 drawLine(context, begin, pi1); 1186 drawLine(context, end, pi2); 1187 drawn = true; 1188 } 1189 } 1190 1191 if (!drawn) { 1192 return; 1193 } 1194 1195 context.lineWidth = width; 1196 1197 if (backgroundMask) { 1198 context.globalCompositeOperation = composite; 1199 } 1200 1201 context.strokeStyle = ColorUtils.getStyleFromRgb(colorLine, opacity); 1202 1203 if (shadow.enable) { 1204 const shadowColor = ColorUtils.colorToRgb(shadow.color); 1205 1206 if (shadowColor) { 1207 context.shadowBlur = shadow.blur; 1208 context.shadowColor = ColorUtils.getStyleFromRgb(shadowColor); 1209 } 1210 } 1211 1212 context.stroke(); 1213 } 1214 1215 static drawLinkTriangle(context, pos1, pos2, pos3, backgroundMask, composite, colorTriangle, opacityTriangle) { 1216 drawTriangle(context, pos1, pos2, pos3); 1217 1218 if (backgroundMask) { 1219 context.globalCompositeOperation = composite; 1220 } 1221 1222 context.fillStyle = ColorUtils.getStyleFromRgb(colorTriangle, opacityTriangle); 1223 context.fill(); 1224 } 1225 1226 static drawConnectLine(context, width, lineStyle, begin, end) { 1227 context.save(); 1228 drawLine(context, begin, end); 1229 context.lineWidth = width; 1230 context.strokeStyle = lineStyle; 1231 context.stroke();
1232 context.restore(); 1233 } 1234 1235 static gradient(context, p1, p2, opacity) { 1236 const gradStop = Math.floor(p2.getRadius() / p1.getRadius()); 1237 const color1 = p1.getFillColor(); 1238 const color2 = p2.getFillColor(); 1239 1240 if (!color1 || !color2) { 1241 return; 1242 } 1243 1244 const sourcePos = p1.getPosition(); 1245 const destPos = p2.getPosition(); 1246 const midRgb = ColorUtils.mix(color1, color2, p1.getRadius(), p2.getRadius()); 1247 const grad = context.createLinearGradient(sourcePos.x, sourcePos.y, destPos.x, destPos.y); 1248 grad.addColorStop(0, ColorUtils.getStyleFromHsl(color1, opacity)); 1249 grad.addColorStop(gradStop > 1 ? 1 : gradStop, ColorUtils.getStyleFromRgb(midRgb, opacity)); 1250 grad.addColorStop(1, ColorUtils.getStyleFromHsl(color2, opacity)); 1251 return grad; 1252 } 1253 1254 static drawGrabLine(context, width, begin, end, colorLine, opacity) { 1255 context.save(); 1256 drawLine(context, begin, end); 1257 context.strokeStyle = ColorUtils.getStyleFromRgb(colorLine, opacity); 1258 context.lineWidth = width; 1259 context.stroke(); 1260 context.restore(); 1261 } 1262 1263 static drawLight(container, context, mousePos) { 1264 const lightOptions = container.options.interactivity.modes.light.area; 1265 context.beginPath(); 1266 context.arc(mousePos.x, mousePos.y, lightOptions.radius, 0, 2 * Math.PI); 1267 const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y, 0, mousePos.x, mousePos.y, lightOptions.radius); 1268 const gradient = lightOptions.gradient; 1269 const gradientRgb = { 1270 start: ColorUtils.colorToRgb(gradient.start), 1271 stop: ColorUtils.colorToRgb(gradient.stop) 1272 }; 1273 1274 if (!gradientRgb.start || !gradientRgb.stop) { 1275 return; 1276 } 1277 1278 gradientAmbientLight.addColorStop(0, ColorUtils.getStyleFromRgb(gradientRgb.start)); 1279 gradientAmbientLight.addColorStop(1, ColorUtils.getStyleFromRgb(gradientRgb.stop)); 1280 context.fillStyle = gradientAmbientLight; 1281 context.fill(); 1282 } 1283 1284 static drawParticleShadow(container, context, particle, mousePos) { 1285 const pos = particle.getPosition(); 1286 const shadowOptions = container.options.interactivity.modes.light.shadow; 1287 context.save(); 1288 const radius = particle.getRadius(); 1289 const sides = particle.sides; 1290 const full = Math.PI * 2 / sides; 1291 const angle = -particle.rotate.value + Math.PI / 4; 1292 const factor = 1; 1293 const dots = []; 1294 1295 for (let i = 0; i < sides; i++) { 1296 dots.push({ 1297 x: pos.x + radius * Math.sin(angle + full * i) * factor, 1298 y: pos.y + radius * Math.cos(angle + full * i) * factor 1299 }); 1300 } 1301 1302 const points = []; 1303 const shadowLength = shadowOptions.length; 1304 1305 for (const dot of dots) { 1306 const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x); 1307 const endX = dot.x + shadowLength * Math.sin(-dotAngle - Math.PI / 2); 1308 const endY = dot.y + shadowLength * Math.cos(-dotAngle - Math.PI / 2); 1309 points.push({ 1310 endX: endX, 1311 endY: endY, 1312 startX: dot.x, 1313 startY: dot.y 1314 }); 1315 } 1316 1317 const shadowRgb = ColorUtils.colorToRgb(shadowOptions.color); 1318 1319 if (!shadowRgb) { 1320 return; 1321 } 1322 1323 const shadowColor = ColorUtils.getStyleFromRgb(shadowRgb); 1324 1325 for (let i = points.length - 1; i >= 0; i--) { 1326 const n = i == points.length - 1 ? 0 : i + 1; 1327 context.beginPath(); 1328 context.moveTo(points[i].startX, points[i].startY); 1329 context.lineTo(points[n].startX, points[n].startY); 1330 context.lineTo(points[n].endX, points[n].endY); 1331 context.lineTo(points[i].endX, points[i].endY); 1332 context.fillStyle = shadowColor; 1333 context.fill(); 1334 } 1335 1336 context.restore(); 1337 } 1338 1339 static drawParticle(container, context, particle, delta, fillColorValue, strokeColorValue, backgroundMask, composite, radius, opacity, shadow) { 1340 const pos = particle.getPosition(); 1341 context.save(); 1342 context.translate(pos.x, pos.y); 1343 context.beginPath(); 1344 const angle = particle.rotate.value + (particle.particlesOptions.rotate.path ? particle.pathAngle : 0); 1345 1346 if (angle !== 0) { 1347 context.rotate(angle); 1348 } 1349 1350 if (backgroundMask) { 1351 context.globalCompositeOperation = composite; 1352 } 1353 1354 const shadowColor = particle.shadowColor; 1355 1356 if (shadow.enable && shadowColor) { 1357 context.shadowBlur = shadow.blur; 1358 context.shadowColor = ColorUtils.getStyleFromRgb(shadowColor); 1359 context.shadowOffsetX = shadow.offset.x; 1360 context.shadowOffsetY = shadow.offset.y; 1361 } 1362 1363 if (fillColorValue) { 1364 context.fillStyle = fillColorValue; 1365 } 1366 1367 const stroke = particle.stroke; 1368 context.lineWidth = particle.strokeWidth; 1369 1370 if (strokeColorValue) { 1371 context.strokeStyle = strokeColorValue; 1372 } 1373 1374 CanvasUtils.drawShape(container, context, particle, radius, opacity, delta); 1375 1376 if (stroke.width > 0) { 1377 context.stroke(); 1378 } 1379 1380 if (particle.close) { 1381 context.closePath(); 1382 } 1383 1384 if (particle.fill) { 1385 context.fill(); 1386 } 1387
1388 context.restore(); 1389 context.save(); 1390 context.translate(pos.x, pos.y); 1391 1392 if (angle !== 0) { 1393 context.rotate(angle); 1394 } 1395 1396 if (backgroundMask) { 1397 context.globalCompositeOperation = composite; 1398 } 1399 1400 CanvasUtils.drawShapeAfterEffect(container, context, particle, radius, opacity, delta); 1401 context.restore(); 1402 } 1403 1404 static drawShape(container, context, particle, radius, opacity, delta) { 1405 if (!particle.shape) { 1406 return; 1407 } 1408 1409 const drawer = container.drawers.get(particle.shape); 1410 1411 if (!drawer) { 1412 return; 1413 } 1414 1415 drawer.draw(context, particle, radius, opacity, delta.value, container.retina.pixelRatio); 1416 } 1417 1418 static drawShapeAfterEffect(container, context, particle, radius, opacity, delta) { 1419 if (!particle.shape) { 1420 return; 1421 } 1422 1423 const drawer = container.drawers.get(particle.shape); 1424 1425 if (!(drawer === null || drawer === void 0 ? void 0 : drawer.afterEffect)) { 1426 return; 1427 } 1428 1429 drawer.afterEffect(context, particle, radius, opacity, delta.value, container.retina.pixelRatio); 1430 } 1431 1432 static drawPlugin(context, plugin, delta) { 1433 if (plugin.draw !== undefined) { 1434 context.save(); 1435 plugin.draw(context, delta); 1436 context.restore(); 1437 } 1438 } 1439 1440 } 1441 // CONCATENATED MODULE: ./dist/browser/Utils/Range.js 1442 class Range { 1443 constructor(x, y) { 1444 this.position = { 1445 x: x, 1446 y: y 1447 }; 1448 } 1449 1450 } 1451 // CONCATENATED MODULE: ./dist/browser/Utils/Circle.js 1452 1453 class Circle extends Range { 1454 constructor(x, y, radius) { 1455 super(x, y); 1456 this.radius = radius; 1457 } 1458 1459 contains(point) { 1460 const d = Math.pow(point.x - this.position.x, 2) + Math.pow(point.y - this.position.y, 2); 1461 return d <= this.radius * this.radius; 1462 } 1463 1464 intersects(range) { 1465 const rect = range; 1466 const circle = range; 1467 const pos1 = this.position; 1468 const pos2 = range.position; 1469 const xDist = Math.abs(pos2.x - pos1.x); 1470 const yDist = Math.abs(pos2.y - pos1.y); 1471 const r = this.radius; 1472 1473 if (circle.radius !== undefined) { 1474 const rSum = r + circle.radius; 1475 const dist = Math.sqrt(xDist * xDist + yDist + yDist); 1476 return rSum > dist; 1477 } else if (rect.size !== undefined) { 1478 const w = rect.size.width; 1479 const h = rect.size.height; 1480 const edges = Math.pow(xDist - w, 2) + Math.pow(yDist - h, 2); 1481 1482 if (xDist > r + w || yDist > r + h) { 1483 return false; 1484 } 1485 1486 if (xDist <= w || yDist <= h) { 1487 return true; 1488 } 1489 1490 return edges <= r * r; 1491 } 1492 1493 return false; 1494 } 1495 1496 } 1497 // CONCATENATED MODULE: ./dist/browser/Utils/Rectangle.js 1498 1499 class Rectangle extends Range { 1500 constructor(x, y, width, height) { 1501 super(x, y); 1502 this.size = { 1503 height: height, 1504 width: width 1505 }; 1506 } 1507 1508 contains(point) { 1509 const w = this.size.width; 1510 const h = this.size.height; 1511 const pos = this.position; 1512 return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h; 1513 } 1514 1515 intersects(range) { 1516 const rect = range; 1517 const circle = range; 1518 const w = this.size.width; 1519 const h = this.size.height; 1520 const pos1 = this.position; 1521 const pos2 = range.position; 1522 1523 if (circle.radius !== undefined) { 1524 return circle.intersects(this); 1525 } else if (rect.size !== undefined) { 1526 const size2 = rect.size; 1527 const w2 = size2.width; 1528 const h2 = size2.height; 1529 return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y; 1530 } 1531 1532 return false; 1533 } 1534 1535 } 1536 // CONCATENATED MODULE: ./dist/browser/Utils/CircleWarp.js 1537 1538 1539 class CircleWarp extends Circle { 1540 constructor(x, y, radius, canvasSize) { 1541 super(x, y, radius); 1542 this.canvasSize = canvasSize; 1543 this.canvasSize = { 1544 height: canvasSize.height, 1545 width: canvasSize.width 1546 }; 1547 } 1548 1549 contains(point) { 1550 if (super.contains(point)) { 1551 return true; 1552 } 1553 1554 const posNE = { 1555 x: point.x - this.canvasSize.width, 1556 y: point.y 1557 }; 1558 1559 if (super.contains(posNE)) { 1560 return true; 1561 } 1562 1563 const posSE = { 1564 x: point.x - this.canvasSize.width, 1565 y: point.y - this.canvasSize.height 1566 }; 1567 1568 if (super.contains(posSE)) { 1569 return true; 1570 } 1571 1572 const posSW = { 1573 x: point.x, 1574 y: point.y - this.canvasSize.height 1575 }; 1576 return super.contains(posSW); 1577 } 1578 1579 intersects(range) { 1580 if (super.intersects(range)) { 1581 return true; 1582 } 1583 1584 const rect = range; 1585 const circle = range; 1586 const newPos = { 1587 x: range.position.x - this.canvasSize.width, 1588 y: range.position.y - this.canvasSize.height 1589 }; 1590 1591 if (circle.radius !== undefined) { 1592 const biggerCircle = new Circle(newPos.x, newPos.y, circle.radius * 2); 1593 return super.intersects(biggerCircle); 1594 } else if (rect.size !== undefined) { 1595 const rectSW = new Rectangle(newPos.x, newPos.y, rect.size.width * 2, rect.size.height * 2); 1596 return super.intersects(rectSW); 1597 } 1598 1599 return false;
1600 } 1601 1602 } 1603 // CONCATENATED MODULE: ./dist/browser/Enums/Modes/ClickMode.js 1604 var ClickMode; 1605 1606 (function (ClickMode) { 1607 ClickMode["attract"] = "attract"; 1608 ClickMode["bubble"] = "bubble"; 1609 ClickMode["push"] = "push"; 1610 ClickMode["remove"] = "remove"; 1611 ClickMode["repulse"] = "repulse"; 1612 ClickMode["pause"] = "pause"; 1613 ClickMode["trail"] = "trail"; 1614 })(ClickMode || (ClickMode = {})); 1615 // CONCATENATED MODULE: ./dist/browser/Enums/Modes/DivMode.js 1616 var DivMode; 1617 1618 (function (DivMode) { 1619 DivMode["bounce"] = "bounce"; 1620 DivMode["bubble"] = "bubble"; 1621 DivMode["repulse"] = "repulse"; 1622 })(DivMode || (DivMode = {})); 1623 // CONCATENATED MODULE: ./dist/browser/Enums/Modes/HoverMode.js 1624 var HoverMode; 1625 1626 (function (HoverMode) { 1627 HoverMode["attract"] = "attract"; 1628 HoverMode["bounce"] = "bounce"; 1629 HoverMode["bubble"] = "bubble"; 1630 HoverMode["connect"] = "connect"; 1631 HoverMode["grab"] = "grab"; 1632 HoverMode["light"] = "light"; 1633 HoverMode["repulse"] = "repulse"; 1634 HoverMode["slow"] = "slow"; 1635 HoverMode["trail"] = "trail"; 1636 })(HoverMode || (HoverMode = {})); 1637 // CONCATENATED MODULE: ./dist/browser/Enums/Modes/CollisionMode.js 1638 var CollisionMode; 1639 1640 (function (CollisionMode) { 1641 CollisionMode["absorb"] = "absorb"; 1642 CollisionMode["bounce"] = "bounce"; 1643 CollisionMode["destroy"] = "destroy"; 1644 })(CollisionMode || (CollisionMode = {})); 1645 // CONCATENATED MODULE: ./dist/browser/Enums/Modes/OutMode.js 1646 var OutMode; 1647 1648 (function (OutMode) { 1649 OutMode["bounce"] = "bounce"; 1650 OutMode["bounceHorizontal"] = "bounce-horizontal"; 1651 OutMode["bounceVertical"] = "bounce-vertical"; 1652 OutMode["none"] = "none"; 1653 OutMode["out"] = "out"; 1654 OutMode["destroy"] = "destroy"; 1655 })(OutMode || (OutMode = {})); 1656 // CONCATENATED MODULE: ./dist/browser/Enums/Modes/SizeMode.js 1657 var SizeMode; 1658 1659 (function (SizeMode) { 1660 SizeMode["precise"] = "precise"; 1661 SizeMode["percent"] = "percent"; 1662 })(SizeMode || (SizeMode = {})); 1663 // CONCATENATED MODULE: ./dist/browser/Enums/Modes/ThemeMode.js 1664 var ThemeMode; 1665 1666 (function (ThemeMode) { 1667 ThemeMode["any"] = "any"; 1668 ThemeMode["dark"] = "dark"; 1669 ThemeMode["light"] = "light"; 1670 })(ThemeMode || (ThemeMode = {})); 1671 // CONCATENATED MODULE: ./dist/browser/Enums/Modes/index.js 1672 1673 1674 1675 1676 1677 1678 1679 // CONCATENATED MODULE: ./dist/browser/Enums/AnimationStatus.js 1680 var AnimationStatus; 1681 1682 (function (AnimationStatus) { 1683 AnimationStatus[AnimationStatus["increasing"] = 0] = "increasing"; 1684 AnimationStatus[AnimationStatus["decreasing"] = 1] = "decreasing"; 1685 })(AnimationStatus || (AnimationStatus = {})); 1686 // CONCATENATED MODULE: ./dist/browser/Enums/Types/DestroyType.js 1687 var DestroyType; 1688 1689 (function (DestroyType) { 1690 DestroyType["none"] = "none"; 1691 DestroyType["max"] = "max"; 1692 DestroyType["min"] = "min"; 1693 })(DestroyType || (DestroyType = {})); 1694 // CONCATENATED MODULE: ./dist/browser/Enums/Types/ProcessBubbleType.js 1695 var ProcessBubbleType; 1696 1697 (function (ProcessBubbleType) { 1698 ProcessBubbleType["color"] = "color"; 1699 ProcessBubbleType["opacity"] = "opacity"; 1700 ProcessBubbleType["size"] = "size"; 1701 })(ProcessBubbleType || (ProcessBubbleType = {})); 1702 // CONCATENATED MODULE: ./dist/browser/Enums/Types/ShapeType.js 1703 var ShapeType; 1704 1705 (function (ShapeType) { 1706 ShapeType["char"] = "char"; 1707 ShapeType["character"] = "character"; 1708 ShapeType["circle"] = "circle"; 1709 ShapeType["edge"] = "edge"; 1710 ShapeType["image"] = "image"; 1711 ShapeType["images"] = "images"; 1712 ShapeType["line"] = "line"; 1713 ShapeType["polygon"] = "polygon"; 1714 ShapeType["square"] = "square"; 1715 ShapeType["star"] = "star"; 1716 ShapeType["triangle"] = "triangle"; 1717 })(ShapeType || (ShapeType = {})); 1718 // CONCATENATED MODULE: ./dist/browser/Enums/Types/StartValueType.js 1719 var StartValueType; 1720 1721 (function (StartValueType) { 1722 StartValueType["max"] = "max"; 1723 StartValueType["min"] = "min"; 1724 StartValueType["random"] = "random"; 1725 })(StartValueType || (StartValueType = {})); 1726 // CONCATENATED MODULE: ./dist/browser/Enums/Types/DivType.js 1727 var DivType; 1728 1729 (function (DivType) { 1730 DivType["circle"] = "circle"; 1731 DivType["rectangle"] = "rectangle"; 1732 })(DivType || (DivType = {})); 1733 // CONCATENATED MODULE: ./dist/browser/Enums/Types/index.js 1734 1735 1736 1737 1738 1739 // CONCATENATED MODULE: ./dist/browser/Enums/InteractivityDetect.js 1740 var InteractivityDetect; 1741 1742 (function (InteractivityDetect) { 1743 InteractivityDetect["canvas"] = "canvas"; 1744 InteractivityDetect["parent"] = "parent"; 1745 InteractivityDetect["window"] = "window"; 1746 })(InteractivityDetect || (InteractivityDetect = {})); 1747 // CONCATENATED MODULE: ./dist/browser/Enums/index.js 1748 1749 1750 1751 1752 1753 // CONCATENATED MODULE: ./dist/browser/Utils/EventListeners.js 1754 1755 1756 1757 function manageListener(element, event, handler, add, options) { 1758 if (add) { 1759 let addOptions = { 1760 passive: true 1761 }; 1762 1763 if (typeof options === "boolean") { 1764 addOptions.capture = options; 1765 } else if (options !== undefined) { 1766 addOptions = options; 1767 } 1768 1769 element.addEventListener(event, handler, addOptions); 1770 } else { 1771 const removeOptions = options; 1772 element.removeEventListener(event, handler, removeOptions); 1773 } 1774 } 1775 1776 class EventListeners { 1777 constructor(container) { 1778 this.container = container; 1779 this.canPush = true; 1780 1781 this.mouseMoveHandler = e => this.mouseTouchMove(e); 1782 1783 this.touchStartHandler = e => this.mouseTouchMove(e); 1784 1785 this.touchMoveHandler = e => this.mouseTouchMove(e); 1786 1787 this.touchEndHandler = () => this.mouseTouchFinish(); 1788 1789 this.mouseLeaveHandler = () => this.mouseTouchFinish(); 1790 1791 this.touchCancelHandler = () => this.mouseTouchFinish(); 1792 1793 this.touchEndClickHandler = e => this.mouseTouchClick(e); 1794 1795 this.mouseUpHandler = e => this.mouseTouchClick(e); 1796 1797 this.mouseDownHandler = () => this.mouseDown(); 1798 1799 this.visibilityChangeHandler = () => this.handleVisibilityChange(); 1800 1801 this.resizeHandler = () => this.handleWindowResize(); 1802 } 1803 1804 addListeners() { 1805 this.manageListeners(true); 1806 } 1807 1808 removeListeners() { 1809 this.manageListeners(false); 1810 } 1811 1812 manageListeners(add) { 1813 var _a; 1814 1815 const container = this.container; 1816 const options = container.options; 1817 const detectType = options.interactivity.detectsOn; 1818 let mouseLeaveEvent = Constants.mouseLeaveEvent; 1819 1820 if (detectType === InteractivityDetect.window) { 1821 container.interactivity.element = window; 1822 mouseLeaveEvent = Constants.mouseOutEvent; 1823 } else if (detectType === InteractivityDetect.parent && container.canvas.element) { 1824 const canvasEl = container.canvas.element; 1825 container.interactivity.element = (_a = canvasEl.parentElement) !== null && _a !== void 0 ? _a : canvasEl.parentNode; 1826 } else { 1827 container.interactivity.element = container.canvas.element; 1828 } 1829 1830 const interactivityEl = container.interactivity.element; 1831 1832 if (!interactivityEl) { 1833 return; 1834 } 1835 1836 const html = interactivityEl; 1837 1838 if (options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable) { 1839 manageListener(interactivityEl, Constants.mouseMoveEvent, this.mouseMoveHandler, add); 1840 manageListener(interactivityEl, Constants.touchStartEvent, this.touchStartHandler, add); 1841 manageListener(interactivityEl, Constants.touchMoveEvent, this.touchMoveHandler, add); 1842 1843 if (!options.interactivity.events.onClick.enable) { 1844 manageListener(interactivityEl, Constants.touchEndEvent, this.touchEndHandler, add); 1845 } else { 1846 manageListener(interactivityEl, Constants.touchEndEvent, this.touchEndClickHandler, add); 1847 manageListener(interactivityEl, Constants.mouseUpEvent, this.mouseUpHandler, add); 1848 manageListener(interactivityEl, Constants.mouseDownEvent, this.mouseDownHandler, add); 1849 } 1850 1851 manageListener(interactivityEl, mouseLeaveEvent, this.mouseLeaveHandler, add); 1852 manageListener(interactivityEl, Constants.touchCancelEvent, this.touchCancelHandler, add); 1853 } 1854 1855 if (container.canvas.element) { 1856 container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none"; 1857 } 1858 1859 if (options.interactivity.events.resize) { 1860 manageListener(window, Constants.resizeEvent, this.resizeHandler, add); 1861 } 1862 1863 if (document) { 1864 manageListener(document, Constants.visibilityChangeEvent, this.visibilityChangeHandler, add, false); 1865 } 1866 } 1867 1868 handleWindowResize() { 1869 var _a; 1870 1871 (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize(); 1872 } 1873 1874 handleVisibilityChange() { 1875 const container = this.container; 1876 const options = container.options; 1877 this.mouseTouchFinish(); 1878 1879 if (!options.pauseOnBlur) { 1880 return; 1881 } 1882 1883 if (document === null || document === void 0 ? void 0 : document.hidden) { 1884 container.pageHidden = true; 1885 container.pause(); 1886 } else { 1887 container.pageHidden = false;
1888 1889 if (container.getAnimationStatus()) { 1890 container.play(true); 1891 } else { 1892 container.draw(); 1893 } 1894 } 1895 } 1896 1897 mouseDown() { 1898 const interactivity = this.container.interactivity; 1899 1900 if (interactivity) { 1901 const mouse = interactivity.mouse; 1902 mouse.clicking = true; 1903 mouse.downPosition = mouse.position; 1904 } 1905 } 1906 1907 mouseTouchMove(e) { 1908 var _a, _b, _c, _d, _e, _f, _g; 1909 1910 const container = this.container; 1911 const options = container.options; 1912 1913 if (((_a = container.interactivity) === null || _a === void 0 ? void 0 : _a.element) === undefined) { 1914 return; 1915 } 1916 1917 container.interactivity.mouse.inside = true; 1918 let pos; 1919 const canvas = container.canvas.element; 1920 1921 if (e.type.startsWith("mouse")) { 1922 this.canPush = true; 1923 const mouseEvent = e; 1924 1925 if (container.interactivity.element === window) { 1926 if (canvas) { 1927 const clientRect = canvas.getBoundingClientRect(); 1928 pos = { 1929 x: mouseEvent.clientX - clientRect.left, 1930 y: mouseEvent.clientY - clientRect.top 1931 }; 1932 } 1933 } else if (options.interactivity.detectsOn === InteractivityDetect.parent) { 1934 const source = mouseEvent.target; 1935 const target = mouseEvent.currentTarget; 1936 const canvasEl = container.canvas.element; 1937 1938 if (source && target && canvasEl) { 1939 const sourceRect = source.getBoundingClientRect(); 1940 const targetRect = target.getBoundingClientRect(); 1941 const canvasRect = canvasEl.getBoundingClientRect(); 1942 pos = { 1943 x: mouseEvent.offsetX + 2 * sourceRect.left - (targetRect.left + canvasRect.left), 1944 y: mouseEvent.offsetY + 2 * sourceRect.top - (targetRect.top + canvasRect.top) 1945 }; 1946 } else { 1947 pos = { 1948 x: (_b = mouseEvent.offsetX) !== null && _b !== void 0 ? _b : mouseEvent.clientX, 1949 y: (_c = mouseEvent.offsetY) !== null && _c !== void 0 ? _c : mouseEvent.clientY 1950 }; 1951 } 1952 } else { 1953 if (mouseEvent.target === container.canvas.element) { 1954 pos = { 1955 x: (_d = mouseEvent.offsetX) !== null && _d !== void 0 ? _d : mouseEvent.clientX, 1956 y: (_e = mouseEvent.offsetY) !== null && _e !== void 0 ? _e : mouseEvent.clientY 1957 }; 1958 } 1959 } 1960 } else { 1961 this.canPush = e.type !== "touchmove"; 1962 const touchEvent = e; 1963 const lastTouch = touchEvent.touches[touchEvent.touches.length - 1]; 1964 const canvasRect = canvas === null || canvas === void 0 ? void 0 : canvas.getBoundingClientRect(); 1965 pos = { 1966 x: lastTouch.clientX - ((_f = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) !== null && _f !== void 0 ? _f : 0), 1967 y: lastTouch.clientY - ((_g = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) !== null && _g !== void 0 ? _g : 0) 1968 }; 1969 } 1970 1971 const pxRatio = container.retina.pixelRatio; 1972 1973 if (pos) { 1974 pos.x *= pxRatio; 1975 pos.y *= pxRatio; 1976 } 1977 1978 container.interactivity.mouse.position = pos; 1979 container.interactivity.status = Constants.mouseMoveEvent; 1980 } 1981 1982 mouseTouchFinish() { 1983 const interactivity = this.container.interactivity; 1984 1985 if (interactivity === undefined) { 1986 return; 1987 } 1988 1989 const mouse = interactivity.mouse; 1990 delete mouse.position; 1991 delete mouse.clickPosition; 1992 delete mouse.downPosition; 1993 interactivity.status = Constants.mouseLeaveEvent; 1994 mouse.inside = false;
1995 mouse.clicking = false; 1996 } 1997 1998 mouseTouchClick(e) { 1999 const container = this.container; 2000 const options = container.options; 2001 const mouse = container.interactivity.mouse; 2002 mouse.inside = true; 2003 let handled = false; 2004 const mousePosition = mouse.position; 2005 2006 if (mousePosition === undefined || !options.interactivity.events.onClick.enable) { 2007 return; 2008 } 2009 2010 for (const [, plugin] of container.plugins) { 2011 if (plugin.clickPositionValid !== undefined) { 2012 handled = plugin.clickPositionValid(mousePosition); 2013 2014 if (handled) { 2015 break; 2016 } 2017 } 2018 } 2019 2020 if (!handled) { 2021 this.doMouseTouchClick(e); 2022 } 2023 2024 mouse.clicking = false; 2025 } 2026 2027 doMouseTouchClick(e) { 2028 const container = this.container; 2029 const options = container.options; 2030 2031 if (this.canPush) { 2032 const mousePos = container.interactivity.mouse.position; 2033 2034 if (mousePos) { 2035 container.interactivity.mouse.clickPosition = { 2036 x: mousePos.x, 2037 y: mousePos.y 2038 }; 2039 } else { 2040 return; 2041 } 2042 2043 container.interactivity.mouse.clickTime = new Date().getTime(); 2044 const onClick = options.interactivity.events.onClick; 2045 2046 if (onClick.mode instanceof Array) { 2047 for (const mode of onClick.mode) { 2048 this.handleClickMode(mode); 2049 } 2050 } else { 2051 this.handleClickMode(onClick.mode); 2052 } 2053 } 2054 2055 if (e.type === "touchend") { 2056 setTimeout(() => this.mouseTouchFinish(), 500); 2057 } 2058 } 2059 2060 handleClickMode(mode) { 2061 const container = this.container; 2062 const options = container.options; 2063 const pushNb = options.interactivity.modes.push.quantity; 2064 const removeNb = options.interactivity.modes.remove.quantity; 2065 2066 switch (mode) { 2067 case ClickMode.push: 2068 { 2069 if (pushNb > 0) { 2070 container.particles.push(pushNb, container.interactivity.mouse); 2071 } 2072 2073 break; 2074 } 2075 2076 case ClickMode.remove: 2077 container.particles.removeQuantity(removeNb); 2078 break; 2079 2080 case ClickMode.bubble: 2081 container.bubble.clicking = true; 2082 break; 2083 2084 case ClickMode.repulse: 2085 container.repulse.clicking = true; 2086 container.repulse.count = 0; 2087 2088 for (const particle of container.repulse.particles) { 2089 particle.velocity.horizontal = particle.initialVelocity.horizontal; 2090 particle.velocity.vertical = particle.initialVelocity.vertical; 2091 } 2092 2093 container.repulse.particles = []; 2094 container.repulse.finish = false; 2095 setTimeout(() => { 2096 if (!container.destroyed) { 2097 container.repulse.clicking = false; 2098 } 2099 }, options.interactivity.modes.repulse.duration * 1000); 2100 break; 2101 2102 case ClickMode.attract: 2103 container.attract.clicking = true; 2104 container.attract.count = 0; 2105 2106 for (const particle of container.attract.particles) { 2107 particle.velocity.horizontal = particle.initialVelocity.horizontal; 2108 particle.velocity.vertical = particle.initialVelocity.vertical; 2109 } 2110 2111 container.attract.particles = []; 2112 container.attract.finish = false; 2113 setTimeout(() => { 2114 if (!container.destroyed) { 2115 container.attract.clicking = false; 2116 } 2117 }, options.interactivity.modes.attract.duration * 1000); 2118 break; 2119 2120 case ClickMode.pause: 2121 if (container.getAnimationStatus()) { 2122 container.pause(); 2123 } else { 2124 container.play(); 2125 } 2126 2127 break; 2128 } 2129 2130 for (const [, plugin] of container.plugins) { 2131 if (plugin.handleClickMode) { 2132 plugin.handleClickMode(mode); 2133 } 2134 } 2135 } 2136 2137 } 2138 // CONCATENATED MODULE: ./dist/browser/Utils/Plugins.js 2139 const plugins = []; 2140 const presets = new Map(); 2141 const drawers = new Map(); 2142 class Plugins { 2143 static getPlugin(plugin) { 2144 return plugins.find(t => t.id === plugin); 2145 } 2146 2147 static addPlugin(plugin) { 2148 if (!Plugins.getPlugin(plugin.id)) { 2149 plugins.push(plugin); 2150 } 2151 } 2152 2153 static getAvailablePlugins(container) { 2154 const res = new Map(); 2155 2156 for (const plugin of plugins) { 2157 if (!plugin.needsPlugin(container.options)) { 2158 continue; 2159 } 2160 2161 res.set(plugin.id, plugin.getPlugin(container)); 2162 } 2163 2164 return res; 2165 } 2166 2167 static loadOptions(options, sourceOptions) { 2168 for (const plugin of plugins) { 2169 plugin.loadOptions(options, sourceOptions); 2170 } 2171 } 2172 2173 static getPreset(preset) { 2174 return presets.get(preset); 2175 } 2176 2177 static addPreset(presetKey, options) { 2178 if (!Plugins.getPreset(presetKey)) { 2179 presets.set(presetKey, options); 2180 } 2181 } 2182 2183 static addShapeDrawer(type, drawer) { 2184 if (!Plugins.getShapeDrawer(type)) { 2185 drawers.set(type, drawer); 2186 } 2187 } 2188 2189 static getShapeDrawer(type) { 2190 return drawers.get(type); 2191 } 2192
2193 static getSupportedShapes() { 2194 return drawers.keys(); 2195 } 2196 2197 } 2198 // CONCATENATED MODULE: ./dist/browser/Utils/Point.js 2199 class Point { 2200 constructor(position, particle) { 2201 this.position = position; 2202 this.particle = particle; 2203 } 2204 2205 } 2206 // CONCATENATED MODULE: ./dist/browser/Utils/QuadTree.js 2207 2208 2209 2210 class QuadTree { 2211 constructor(rectangle, capacity) { 2212 this.rectangle = rectangle; 2213 this.capacity = capacity; 2214 this.points = []; 2215 this.divided = false; 2216 } 2217 2218 subdivide() { 2219 const x = this.rectangle.position.x; 2220 const y = this.rectangle.position.y; 2221 const w = this.rectangle.size.width; 2222 const h = this.rectangle.size.height; 2223 const capacity = this.capacity; 2224 this.northEast = new QuadTree(new Rectangle(x, y, w / 2, h / 2), capacity); 2225 this.northWest = new QuadTree(new Rectangle(x + w / 2, y, w / 2, h / 2), capacity); 2226 this.southEast = new QuadTree(new Rectangle(x, y + h / 2, w / 2, h / 2), capacity); 2227 this.southWest = new QuadTree(new Rectangle(x + w / 2, y + h / 2, w / 2, h / 2), capacity); 2228 this.divided = true; 2229 } 2230 2231 insert(point) { 2232 var _a, _b, _c, _d, _e; 2233 2234 if (!this.rectangle.contains(point.position)) { 2235 return false; 2236 } 2237 2238 if (this.points.length < this.capacity) { 2239 this.points.push(point); 2240 return true; 2241 } 2242 2243 if (!this.divided) { 2244 this.subdivide(); 2245 } 2246 2247 return (_e = ((_a = this.northEast) === null || _a === void 0 ? void 0 : _a.insert(point)) || ((_b = this.northWest) === null || _b === void 0 ? void 0 : _b.insert(point)) || ((_c = this.southEast) === null || _c === void 0 ? void 0 : _c.insert(point)) || ((_d = this.southWest) === null || _d === void 0 ? void 0 : _d.insert(point))) !== null && _e !== void 0 ? _e : false; 2248 } 2249 2250 queryCircle(position, radius) { 2251 return this.query(new Circle(position.x, position.y, radius)); 2252 } 2253 2254 queryCircleWarp(position, radius, containerOrSize) { 2255 const container = containerOrSize; 2256 const size = containerOrSize; 2257 return this.query(new CircleWarp(position.x, position.y, radius, container.canvas !== undefined ? container.canvas.size : size)); 2258 } 2259 2260 queryRectangle(position, size) { 2261 return this.query(new Rectangle(position.x, position.y, size.width, size.height)); 2262 } 2263 2264 query(range, found) { 2265 var _a, _b, _c, _d; 2266 2267 const res = found !== null && found !== void 0 ? found : []; 2268 2269 if (!range.intersects(this.rectangle)) { 2270 return []; 2271 } else { 2272 for (const p of this.points) { 2273 if (!range.contains(p.position)) { 2274 continue; 2275 } 2276 2277 res.push(p.particle); 2278 } 2279 2280 if (this.divided) { 2281 (_a = this.northEast) === null || _a === void 0 ? void 0 : _a.query(range, res); 2282 (_b = this.northWest) === null || _b === void 0 ? void 0 : _b.query(range, res); 2283 (_c = this.southEast) === null || _c === void 0 ? void 0 : _c.query(range, res); 2284 (_d = this.southWest) === null || _d === void 0 ? void 0 : _d.query(range, res); 2285 } 2286 } 2287 2288 return res; 2289 } 2290 2291 } 2292 // CONCATENATED MODULE: ./dist/browser/Utils/index.js 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/TextDrawer.js 2307 var TextDrawer_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { 2308 function adopt(value) { 2309 return value instanceof P ? value : new P(function (resolve) { 2310 resolve(value); 2311 }); 2312 } 2313 2314 return new (P || (P = Promise))(function (resolve, reject) { 2315 function fulfilled(value) { 2316 try { 2317 step(generator.next(value)); 2318 } catch (e) { 2319 reject(e); 2320 } 2321 } 2322 2323 function rejected(value) { 2324 try { 2325 step(generator["throw"](value)); 2326 } catch (e) { 2327 reject(e); 2328 } 2329 } 2330 2331 function step(result) { 2332 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 2333 } 2334 2335 step((generator = generator.apply(thisArg, _arguments || [])).next()); 2336 }); 2337 }; 2338 2339 2340 2341 class TextDrawer { 2342 getSidesCount() { 2343 return 12; 2344 } 2345 2346 init(container) { 2347 var _a; 2348 2349 return TextDrawer_awaiter(this, void 0, void 0, function* () { 2350 const options = container.options; 2351 2352 if (Utils.isInArray(ShapeType.char, options.particles.shape.type) || Utils.isInArray(ShapeType.character, options.particles.shape.type)) { 2353 const shapeOptions = (_a = options.particles.shape.options[ShapeType.character]) !== null && _a !== void 0 ? _a : options.particles.shape.options[ShapeType.char]; 2354 2355 if (shapeOptions instanceof Array) { 2356 for (const character of shapeOptions) { 2357 yield Utils.loadFont(character); 2358 } 2359 } else { 2360 if (shapeOptions !== undefined) { 2361 yield Utils.loadFont(shapeOptions); 2362 } 2363 } 2364 } 2365 }); 2366 } 2367 2368 draw(context, particle, radius) { 2369 const character = particle.shapeData; 2370 2371 if (character === undefined) { 2372 return; 2373 } 2374 2375 const textData = character.value; 2376 2377 if (textData === undefined) { 2378 return; 2379 } 2380 2381 const textParticle = particle; 2382 2383 if (textParticle.text === undefined) { 2384 textParticle.text = textData instanceof Array ? Utils.itemFromArray(textData, particle.randomIndexData) : textData; 2385 } 2386 2387 const text = textParticle.text; 2388 const style = character.style; 2389 const weight = character.weight; 2390 const size = Math.round(radius) * 2; 2391 const font = character.font; 2392 const fill = particle.fill; 2393 const offsetX = text.length * radius / 2; 2394 context.font = `${style} ${weight} ${size}px "${font}"`; 2395 const pos = {
2396 x: -offsetX, 2397 y: radius / 2 2398 }; 2399 2400 if (fill) { 2401 context.fillText(text, pos.x, pos.y); 2402 } else { 2403 context.strokeText(text, pos.x, pos.y); 2404 } 2405 } 2406 2407 } 2408 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/ImageDrawer.js 2409 var ImageDrawer_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { 2410 function adopt(value) { 2411 return value instanceof P ? value : new P(function (resolve) { 2412 resolve(value); 2413 }); 2414 } 2415 2416 return new (P || (P = Promise))(function (resolve, reject) { 2417 function fulfilled(value) { 2418 try { 2419 step(generator.next(value)); 2420 } catch (e) { 2421 reject(e); 2422 } 2423 } 2424 2425 function rejected(value) { 2426 try { 2427 step(generator["throw"](value)); 2428 } catch (e) { 2429 reject(e); 2430 } 2431 } 2432 2433 function step(result) { 2434 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 2435 } 2436 2437 step((generator = generator.apply(thisArg, _arguments || [])).next()); 2438 }); 2439 }; 2440 2441 2442 2443 class ImageDrawer { 2444 constructor() { 2445 this.images = []; 2446 } 2447 2448 getSidesCount() { 2449 return 12; 2450 } 2451 2452 getImages(container) { 2453 const containerImages = this.images.filter(t => t.id === container.id); 2454 2455 if (!containerImages.length) { 2456 this.images.push({ 2457 id: container.id, 2458 images: [] 2459 }); 2460 return this.getImages(container); 2461 } else { 2462 return containerImages[0]; 2463 } 2464 } 2465 2466 addImage(container, image) { 2467 const containerImages = this.getImages(container); 2468 containerImages === null || containerImages === void 0 ? void 0 : containerImages.images.push(image); 2469 } 2470 2471 init(container) { 2472 var _a; 2473 2474 return ImageDrawer_awaiter(this, void 0, void 0, function* () { 2475 const options = container.options; 2476 const shapeOptions = options.particles.shape; 2477 2478 if (!Utils.isInArray(ShapeType.image, shapeOptions.type) && !Utils.isInArray(ShapeType.images, shapeOptions.type)) { 2479 return; 2480 } 2481 2482 const imageOptions = (_a = shapeOptions.options[ShapeType.images]) !== null && _a !== void 0 ? _a : shapeOptions.options[ShapeType.image]; 2483 2484 if (imageOptions instanceof Array) { 2485 for (const optionsImage of imageOptions) { 2486 yield this.loadImageShape(container, optionsImage); 2487 } 2488 } else { 2489 yield this.loadImageShape(container, imageOptions); 2490 } 2491 }); 2492 } 2493 2494 destroy() { 2495 this.images = []; 2496 } 2497 2498 loadImageShape(container, imageShape) { 2499 return ImageDrawer_awaiter(this, void 0, void 0, function* () { 2500 try { 2501 const image = imageShape.replaceColor ? yield Utils.downloadSvgImage(imageShape.src) : yield Utils.loadImage(imageShape.src); 2502 this.addImage(container, image); 2503 } catch (_a) { 2504 console.warn(`tsParticles error - ${imageShape.src} not found`); 2505 } 2506 }); 2507 } 2508 2509 draw(context, particle, radius, opacity) { 2510 var _a, _b; 2511 2512 if (!context) { 2513 return; 2514 } 2515 2516 const image = particle.image; 2517 const element = (_a = image === null || image === void 0 ? void 0 : image.data) === null || _a === void 0 ? void 0 : _a.element; 2518 2519 if (!element) { 2520 return; 2521 } 2522 2523 const ratio = (_b = image === null || image === void 0 ? void 0 : image.ratio) !== null && _b !== void 0 ? _b : 1; 2524 const pos = { 2525 x: -radius, 2526 y: -radius 2527 }; 2528 2529 if (!(image === null || image === void 0 ? void 0 : image.data.svgData) || !(image === null || image === void 0 ? void 0 : image.replaceColor)) { 2530 context.globalAlpha = opacity; 2531 } 2532 2533 context.drawImage(element, pos.x, pos.y, radius * 2, radius * 2 / ratio); 2534 2535 if (!(image === null || image === void 0 ? void 0 : image.data.svgData) || !(image === null || image === void 0 ? void 0 : image.replaceColor)) { 2536 context.globalAlpha = 1; 2537 } 2538 } 2539 2540 } 2541 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/LineDrawer.js 2542 class LineDrawer { 2543 getSidesCount() { 2544 return 1; 2545 } 2546 2547 draw(context, particle, radius) { 2548 context.moveTo(0, -radius / 2); 2549 context.lineTo(0, radius / 2); 2550 } 2551 2552 } 2553 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/CircleDrawer.js 2554 class CircleDrawer { 2555 getSidesCount() { 2556 return 12; 2557 } 2558 2559 draw(context, particle, radius) { 2560 context.arc(0, 0, radius, 0, Math.PI * 2, false); 2561 } 2562 2563 } 2564 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/PolygonDrawerBase.js 2565 class PolygonDrawerBase { 2566 getSidesCount(particle) { 2567 var _a, _b; 2568 2569 const polygon = particle.shapeData; 2570 return (_b = (_a = polygon === null || polygon === void 0 ? void 0 : polygon.sides) !== null && _a !== void 0 ? _a : polygon === null || polygon === void 0 ? void 0 : polygon.nb_sides) !== null && _b !== void 0 ? _b : 5; 2571 } 2572 2573 draw(context, particle, radius) { 2574 const start = this.getCenter(particle, radius);
2575 const side = this.getSidesData(particle, radius); 2576 const sideCount = side.count.numerator * side.count.denominator; 2577 const decimalSides = side.count.numerator / side.count.denominator; 2578 const interiorAngleDegrees = 180 * (decimalSides - 2) / decimalSides; 2579 const interiorAngle = Math.PI - Math.PI * interiorAngleDegrees / 180; 2580 2581 if (!context) { 2582 return; 2583 } 2584 2585 context.beginPath(); 2586 context.translate(start.x, start.y); 2587 context.moveTo(0, 0); 2588 2589 for (let i = 0; i < sideCount; i++) { 2590 context.lineTo(side.length, 0); 2591 context.translate(side.length, 0); 2592 context.rotate(interiorAngle); 2593 } 2594 } 2595 2596 } 2597 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/TriangleDrawer.js 2598 2599 class TriangleDrawer extends PolygonDrawerBase { 2600 getSidesCount() { 2601 return 3; 2602 } 2603 2604 getSidesData(particle, radius) { 2605 return { 2606 count: { 2607 denominator: 2, 2608 numerator: 3 2609 }, 2610 length: radius * 2 2611 }; 2612 } 2613 2614 getCenter(particle, radius) { 2615 return { 2616 x: -radius, 2617 y: radius / 1.66 2618 }; 2619 } 2620 2621 } 2622 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/StarDrawer.js 2623 class StarDrawer { 2624 getSidesCount(particle) { 2625 var _a, _b; 2626 2627 const star = particle.shapeData; 2628 return (_b = (_a = star === null || star === void 0 ? void 0 : star.sides) !== null && _a !== void 0 ? _a : star === null || star === void 0 ? void 0 : star.nb_sides) !== null && _b !== void 0 ? _b : 5; 2629 } 2630 2631 draw(context, particle, radius) { 2632 var _a; 2633 2634 const star = particle.shapeData; 2635 const sides = this.getSidesCount(particle); 2636 const inset = (_a = star === null || star === void 0 ? void 0 : star.inset) !== null && _a !== void 0 ? _a : 2; 2637 context.moveTo(0, 0 - radius); 2638 2639 for (let i = 0; i < sides; i++) { 2640 context.rotate(Math.PI / sides); 2641 context.lineTo(0, 0 - radius * inset); 2642 context.rotate(Math.PI / sides); 2643 context.lineTo(0, 0 - radius); 2644 } 2645 } 2646 2647 } 2648 // CONCATENATED MODULE: ./dist/browser/ShapeDrawers/PolygonDrawer.js 2649 2650 class PolygonDrawer extends PolygonDrawerBase { 2651 getSidesData(particle, radius) { 2652 var _a, _b; 2653 2654 const polygon = particle.shapeData; 2655 const sides = (_b = (_a = polygon === null || polygon === void 0 ? void 0 : polygon.sides) !== null && _a !== void 0 ? _a : polygon === null || polygon === void 0 ? void 0 : polygon.nb_sides) !== null && _b !== void 0 ? _b : 5; 2656 return { 2657 count: { 2658 denominator: 1, 2659 numerator: sides 2660 }, 2661 length: radius * 2.66 / (sides / 3) 2662 }; 2663 } 2664 2665 getCenter(particle, radius) { 2666 const sides = this.getSidesCount(particle); 2667 return { 2668 x: -radius / (sides / 3.5), 2669 y: -radius / (2.66 / 3.5) 2670 }; 2671 } 2672 2673 } 2674 // CONCATENATED MODULE: ./dist/browser/Core/Canvas.js 2675 2676 class Canvas { 2677 constructor(container) { 2678 this.container = container; 2679 this.size = { 2680 height: 0, 2681 width: 0 2682 }; 2683 this.context = null; 2684 this.generatedCanvas = false; 2685 } 2686 2687 init() { 2688 var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; 2689 2690 this.resize(); 2691 const options = this.container.options; 2692 const element = this.element; 2693 2694 if (element) { 2695 if (options.backgroundMode.enable) { 2696 this.originalStyle = Utils.deepExtend({}, element.style); 2697 element.style.position = "fixed"; 2698 element.style.zIndex = options.backgroundMode.zIndex.toString(10); 2699 element.style.top = "0"; 2700 element.style.left = "0"; 2701 element.style.width = "100%"; 2702 element.style.height = "100%"; 2703 } else { 2704 element.style.position = (_b = (_a = this.originalStyle) === null || _a === void 0 ? void 0 : _a.position) !== null && _b !== void 0 ? _b : ""; 2705 element.style.zIndex = (_d = (_c = this.originalStyle) === null || _c === void 0 ? void 0 : _c.zIndex) !== null && _d !== void 0 ? _d : ""; 2706 element.style.top = (_f = (_e = this.originalStyle) === null || _e === void 0 ? void 0 : _e.to
2706p) !== null && _f !== void 0 ? _f : ""; 2707 element.style.left = (_h = (_g = this.originalStyle) === null || _g === void 0 ? void 0 : _g.left) !== null && _h !== void 0 ? _h : ""; 2708 element.style.width = (_k = (_j = this.originalStyle) === null || _j === void 0 ? void 0 : _j.width) !== null && _k !== void 0 ? _k : ""; 2709 element.style.height = (_m = (_l = this.originalStyle) === null || _l === void 0 ? void 0 : _l.height) !== null && _m !== void 0 ? _m : ""; 2710 } 2711 } 2712 2713 const cover = options.backgroundMask.cover; 2714 const color = cover.color; 2715 const trail = options.particles.move.trail; 2716 const coverRgb = ColorUtils.colorToRgb(color); 2717 this.coverColor = coverRgb !== undefined ? { 2718 r: coverRgb.r, 2719 g: coverRgb.g, 2720 b: coverRgb.b, 2721 a: cover.opacity 2722 } : undefined; 2723 this.trailFillColor = ColorUtils.colorToRgb(trail.fillColor); 2724 this.initBackground(); 2725 this.paint(); 2726 } 2727 2728 loadCanvas(canvas, generatedCanvas) { 2729 var _a; 2730 2731 if (!canvas.className) { 2732 canvas.className = Constants.canvasClass; 2733 } 2734 2735 if (this.generatedCanvas) { 2736 (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove(); 2737 } 2738 2739 this.generatedCanvas = generatedCanvas !== null && generatedCanvas !== void 0 ? generatedCanvas : this.generatedCanvas; 2740 this.element = canvas; 2741 this.originalStyle = Utils.deepExtend({}, this.element.style); 2742 this.size.height = canvas.offsetHeight; 2743 this.size.width = canvas.offsetWidth; 2744 this.context = this.element.getContext("2d"); 2745 this.container.retina.init();
2746 this.initBackground(); 2747 } 2748 2749 destroy() { 2750 var _a; 2751 2752 if (this.generatedCanvas) { 2753 (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove(); 2754 } 2755 2756 if (this.context) { 2757 CanvasUtils.clear(this.context, this.size); 2758 } 2759 } 2760 2761 resize() { 2762 if (!this.element) { 2763 return; 2764 } 2765 2766 this.element.width = this.size.width; 2767 this.element.height = this.size.height; 2768 } 2769 2770 paint() { 2771 const options = this.container.options; 2772 2773 if (!this.context) { 2774 return; 2775 } 2776 2777 if (options.backgroundMask.enable && options.backgroundMask.cover && this.coverColor) { 2778 CanvasUtils.clear(this.context, this.size); 2779 this.paintBase(ColorUtils.getStyleFromRgb(this.coverColor, this.coverColor.a)); 2780 } else { 2781 this.paintBase(); 2782 } 2783 } 2784 2785 clear() { 2786 const options = this.container.options; 2787 const trail = options.particles.move.trail; 2788 2789 if (options.backgroundMask.enable) { 2790 this.paint(); 2791 } else if (trail.enable && trail.length > 0 && this.trailFillColor) { 2792 this.paintBase(ColorUtils.getStyleFromRgb(this.trailFillColor, 1 / trail.length)); 2793 } else if (this.context) { 2794 CanvasUtils.clear(this.context, this.size); 2795 } 2796 } 2797 2798 windowResize() { 2799 if (!this.element) { 2800 return; 2801 } 2802 2803 const container = this.container; 2804 container.canvas.initSize(); 2805 container.particles.setDensity(); 2806 2807 for (const [, plugin] of container.plugins) { 2808 if (plugin.resize !== undefined) { 2809 plugin.resize(); 2810 } 2811 } 2812 } 2813 2814 initSize() { 2815 if (!this.element) { 2816 return; 2817 } 2818 2819 const container = this.container; 2820 const pxRatio = container.retina.pixelRatio; 2821 container.canvas.size.width = this.element.offsetWidth * pxRatio; 2822 container.canvas.size.height = this.element.offsetHeight * pxRatio; 2823 this.element.width = container.canvas.size.width; 2824 this.element.height = container.canvas.size.height; 2825 } 2826 2827 drawConnectLine(p1, p2) { 2828 var _a; 2829 2830 const lineStyle = this.lineStyle(p1, p2); 2831 2832 if (!lineStyle) { 2833 return; 2834 } 2835 2836 const ctx = this.context; 2837 2838 if (!ctx) { 2839 return; 2840 } 2841 2842 const pos1 = p1.getPosition(); 2843 const pos2 = p2.getPosition(); 2844 CanvasUtils.drawConnectLine(ctx, (_a = p1.linksWidth) !== null && _a !== void 0 ? _a : this.container.retina.linksWidth, lineStyle, pos1, pos2); 2845 } 2846 2847 drawGrabLine(particle, lineColor, opacity, mousePos) { 2848 var _a; 2849 2850 const container = this.container; 2851 const ctx = container.canvas.context; 2852 2853 if (!ctx) { 2854 return; 2855 } 2856 2857 const beginPos = particle.getPosition(); 2858 CanvasUtils.drawGrabLine(ctx, (_a = particle.linksWidth) !== null && _a !== void 0 ? _a : container.retina.linksWidth, beginPos, mousePos, lineColor, opacity); 2859 } 2860 2861 drawParticleShadow(particle, mousePos) { 2862 if (!this.context) { 2863 return; 2864 } 2865 2866 CanvasUtils.drawParticleShadow(this.container, this.context, particle, mousePos); 2867 } 2868 2869 drawLinkTriangle(p1, link1, link2) { 2870 var _a; 2871 2872 const container = this.container; 2873 const options = container.options; 2874 const p2 = link1.destination; 2875 const p3 = link2.destination; 2876 const triangleOptions = p1.particlesOptions.links.triangles; 2877 const opacityTriangle = (_a = triangleOptions.opacity) !== null && _a !== void 0 ? _a : (link1.op
2877acity + link2.opacity) / 2; 2878 2879 if (opacityTriangle <= 0) { 2880 return; 2881 } 2882 2883 const pos1 = p1.getPosition(); 2884 const pos2 = p2.getPosition(); 2885 const pos3 = p3.getPosition(); 2886 const ctx = this.context; 2887 2888 if (!ctx) { 2889 return; 2890 } 2891 2892 if (NumberUtils.getDistance(pos1, pos2) > container.retina.linksDistance || NumberUtils.getDistance(pos3, pos2) > container.retina.linksDistance || NumberUtils.getDistance(pos3, pos1) > container.retina.linksDistance) { 2893 return; 2894 } 2895 2896 let colorTriangle = ColorUtils.colorToRgb(triangleOptions.color); 2897 2898 if (!colorTriangle) { 2899 const linksOptions = p1.particlesOptions.links; 2900 const linkColor = linksOptions.id !== undefined ? container.particles.linksColors.get(linksOptions.id) : container.particles.linksColor; 2901 colorTriangle = ColorUtils.getLinkColor(p1, p2, linkColor); 2902 } 2903 2904 if (!colorTriangle) { 2905 return; 2906 } 2907 2908 CanvasUtils.drawLinkTriangle(ctx, pos1, pos2, pos3, options.backgroundMask.enable, options.backgroundMask.composite, colorTriangle, opacityTriangle); 2909 } 2910 2911 drawLinkLine(p1, link) { 2912 var _a, _b; 2913 2914 const container = this.container; 2915 const options = container.options; 2916 const p2 = link.destination; 2917 let opacity = link.opacity; 2918 const pos1 = p1.getPosition(); 2919 const pos2 = p2.getPosition(); 2920 const ctx = this.context; 2921 2922 if (!ctx) { 2923 return; 2924 } 2925 2926 let colorLine; 2927 const twinkle = p1.particlesOptions.twinkle.lines; 2928 2929 if (twinkle.enable) { 2930 const twinkleFreq = twinkle.frequency; 2931 const twinkleRgb = ColorUtils.colorToRgb(twinkle.color); 2932 const twinkling = Math.random() < twinkleFreq; 2933 2934 if (twinkling && twinkleRgb !== undefined) { 2935 colorLine = twinkleRgb; 2936 opacity = twinkle.opacity; 2937 } 2938 } 2939 2940 if (!colorLine) { 2941 const linksOptions = p1.particlesOptions.links; 2942 const linkColor = linksOptions.id !== undefined ? container.particles.linksColors.get(linksOptions.id) : container.particles.linksColor; 2943 colorLine = ColorUtils.getLinkColor(p1, p2, linkColor); 2944 } 2945 2946 if (!colorLine) { 2947 return; 2948 } 2949 2950 const width = (_a = p1.linksWidth) !== null && _a !== void 0 ? _a : container.retina.linksWidth; 2951 const maxDistance = (_b = p1.linksDistance) !== null && _b !== void 0 ? _b : container.retina.linksDistance; 2952 CanvasUtils.drawLinkLine(ctx, width, pos1, pos2, maxDistance, container.canvas.size, p1.particlesOptions.links.warp, options.backgroundMask.enable, options.backgroundMask.composite, colorLine, opacity, p1.particlesOptions.links.shadow); 2953 } 2954 2955 drawParticle(particle, delta) { 2956 var _a, _b, _c, _d; 2957 2958 if (((_a = particle.image) === null || _a === void 0 ? void 0 : _a.loaded) === false || particle.spawning || particle.destroyed) { 2959 return; 2960 } 2961 2962 const pfColor = particle.getFillColor(); 2963 const psColor = (_b = particle.getStrokeColor()) !== null && _b !== void 0 ? _b : pfColor; 2964 2965 if (!pfColor && !psColor) { 2966 return; 2967 } 2968 2969 const options = this.container.options; 2970 const pOptions = particle.particlesOptions; 2971 const twinkle = pOptions.twinkle.particles; 2972 const twinkleFreq = twinkle.frequency; 2973 const twinkleRgb = ColorUtils.colorToRgb(twinkle.color); 2974 const twinkling = twinkle.enable && Math.random() < twinkleFreq; 2975 const radius = particle.getRadius(); 2976 const opacity = twinkling ? twinkle.opacity : (_c = particle.bubble.opacity) !== null && _c !== void 0 ? _c : particle.opacity.value; 2977 const infectionStage = particle.infecter.infectionStage; 2978 const infection = options.infection; 2979 const infectionStages = infection.stages; 2980 const infectionColor = infectionStage !== undefined ? infectionStages[infectionStage].color : undefined; 2981 const infectionRgb = ColorUtils.colorToRgb(infectionColor); 2982 const fColor = twinkling && twinkleRgb !== undefined ? twinkleRgb : infectionRgb !== null && infectionRgb !== void 0 ? infectionRgb : pfColor ? ColorUtils.hslToRgb(pfColor) : undefined; 2983 const sColor = twinkling && twinkleRgb !== undefined ? twinkleRgb : infectionRgb !== null && infectionRgb !== void 0 ? infectionRgb : psColor ? ColorUtils.hslToRgb(psColor) : undefined; 2984 const fillColorValue = fColor !== undefined ? ColorUtils.getStyleFromRgb(fColor, opacity) : undefined; 2985 2986 if (!this.context || !fillColorValue && !sColor) { 2987 return; 2988 } 2989 2990 const strokeColorValue = sColor !== undefined ? ColorUtils.getStyleFromRgb(sColor, (_d = particle.stroke.opacity) !== null && _d !== void 0 ? _d : opacity) : fillColorValue; 2991 this.drawParticleLinks(particle); 2992 2993 if (radius > 0) {
2994 CanvasUtils.drawParticle(this.container, this.context, particle, delta, fillColorValue, strokeColorValue, options.backgroundMask.enable, options.backgroundMask.composite, radius, opacity, particle.particlesOptions.shadow); 2995 } 2996 } 2997 2998 drawParticleLinks(particle) { 2999 if (!this.context) { 3000 return; 3001 } 3002 3003 const container = this.container; 3004 const particles = container.particles; 3005 const pOptions = particle.particlesOptions; 3006 3007 if (particle.links.length > 0) { 3008 this.context.save(); 3009 const p1Links = particle.links.filter(l => { 3010 const linkFreq = container.particles.getLinkFrequency(particle, l.destination); 3011 return linkFreq <= pOptions.links.frequency; 3012 }); 3013 3014 for (const link of p1Links) { 3015 const p2 = link.destination; 3016 3017 if (pOptions.links.triangles.enable) { 3018 const links = p1Links.map(l => l.destination); 3019 const vertices = p2.links.filter(t => { 3020 const linkFreq = container.particles.getLinkFrequency(p2, t.destination); 3021 return linkFreq <= p2.particlesOptions.links.frequency && links.indexOf(t.destination) >= 0; 3022 }); 3023 3024 if (vertices.length) { 3025 for (const vertex of vertices) { 3026 const p3 = vertex.destination; 3027 const triangleFreq = particles.getTriangleFrequency(particle, p2, p3); 3028 3029 if (triangleFreq > pOptions.links.triangles.frequency) { 3030 continue; 3031 } 3032 3033 this.drawLinkTriangle(particle, link, vertex); 3034 } 3035 } 3036 } 3037 3038 if (link.opacity > 0 && container.retina.linksWidth > 0) { 3039 this.drawLinkLine(particle, link); 3040 } 3041 } 3042 if ( this.context ) { 3043 this.context.restore(); 3044 } 3045 } 3046 } 3047 3048 drawPlugin(plugin, delta) { 3049 if (!this.context) { 3050 return; 3051 } 3052 3053 CanvasUtils.drawPlugin(this.context, plugin, delta); 3054 } 3055 3056 drawLight(mousePos) { 3057 if (!this.context) { 3058 return; 3059 } 3060 3061 CanvasUtils.drawLight(this.container, this.context, mousePos); 3062 } 3063 3064 paintBase(baseColor) { 3065 if (!this.context) { 3066 return; 3067 } 3068 3069 CanvasUtils.paintBase(this.context, this.size, baseColor); 3070 } 3071 3072 lineStyle(p1, p2) { 3073 const options = this.container.options; 3074 const connectOptions = options.interactivity.modes.connect; 3075 3076 if (this.context) { 3077 return CanvasUtils.gradient(this.context, p1, p2, connectOptions.links.opacity); 3078 } 3079 } 3080
3081 initBackground() { 3082 const options = this.container.options; 3083 const background = options.background; 3084 const element = this.element; 3085 3086 if (!element) { 3087 return; 3088 } 3089 3090 const elementStyle = element.style; 3091 3092 if (background.color) { 3093 const color = ColorUtils.colorToRgb(background.color); 3094 3095 if (color) { 3096 elementStyle.backgroundColor = ColorUtils.getStyleFromRgb(color, background.opacity); 3097 } 3098 } 3099 3100 if (background.image) { 3101 elementStyle.backgroundImage = background.image; 3102 } 3103 3104 if (background.position) { 3105 elementStyle.backgroundPosition = background.position; 3106 } 3107 3108 if (background.repeat) { 3109 elementStyle.backgroundRepeat = background.repeat; 3110 } 3111 3112 if (background.size) { 3113 elementStyle.backgroundSize = background.size; 3114 } 3115 } 3116 3117 } 3118 // CONCATENATED MODULE: ./dist/browser/Core/Particle/Updater.js 3119 3120 3121 3122 3123 function bounceHorizontal(data) { 3124 if (data.outMode === OutMode.bounce || data.outMode === OutMode.bounceHorizontal || data.outMode === "bounceHorizontal") { 3125 const velocity = data.particle.velocity.horizontal; 3126 let bounced = false; 3127 3128 if (data.direction === OutModeDirection.right && data.bounds.right >= data.canvasSize.width && velocity > 0 || data.direction === OutModeDirection.left && data.bounds.left <= 0 && velocity < 0) { 3129 const newVelocity = NumberUtils.getValue(data.particle.particlesOptions.bounce.horizontal); 3130 data.particle.velocity.horizontal *= -newVelocity; 3131 bounced = true; 3132 } 3133 3134 if (bounced) { 3135 const minPos = data.offset.x + data.size; 3136 3137 if (data.bounds.right >= data.canvasSize.width) { 3138 data.particle.position.x = data.canvasSize.width - minPos; 3139 } else if (data.bounds.left <= 0) { 3140 data.particle.position.x = minPos; 3141 } 3142 } 3143 } 3144 } 3145 3146 function bounceVertical(data) { 3147 if (data.outMode === OutMode.bounce || data.outMode === OutMode.bounceVertical || data.outMode === "bounceVertical") { 3148 const velocity = data.particle.velocity.vertical; 3149 let bounced = false; 3150 3151 if (data.direction === OutModeDirection.bottom && data.bounds.bottom >= data.canvasSize.height && velocity > 0 || data.direction === OutModeDirection.top && data.bounds.top <= 0 && velocity < 0) { 3152 const newVelocity = NumberUtils.getValue(data.particle.particlesOptions.bounce.vertical); 3153 data.particle.velocity.vertical *= -newVelocity; 3154 bounced = true; 3155 } 3156 3157 if (bounced) { 3158 const minPos = data.offset.y + data.size; 3159 3160 if (data.bounds.bottom >= data.canvasSize.height) { 3161 data.particle.position.y = data.canvasSize.height - minPos; 3162 } else if (data.bounds.top <= 0) { 3163 data.particle.position.y = minPos; 3164 } 3165 } 3166 } 3167 } 3168 3169 function checkDestroy(particle, destroy, value, minValue, maxValue) { 3170 switch (destroy) { 3171 case DestroyType.max: 3172 if (value >= maxValue) { 3173 particle.destroy(); 3174 } 3175 3176 break; 3177 3178 case DestroyType.min: 3179 if (value <= minValue) { 3180 particle.destroy(); 3181 } 3182 3183 break; 3184 } 3185 } 3186 3187 class Updater { 3188 constructor(container, particle) { 3189 this.container = container; 3190 this.particle = particle; 3191 } 3192 3193 update(delta) { 3194 if (this.particle.destroyed) { 3195 return; 3196 } 3197 3198 this.updateLife(delta); 3199 3200 if (this.particle.destroyed || this.particle.spawning) { 3201 return; 3202 } 3203 3204 this.updateOpacity(delta); 3205 this.updateSize(delta); 3206 this.updateAngle(delta); 3207 this.updateColor(delta); 3208 this.updateStrokeColor(delta); 3209 this.updateOutModes(delta); 3210 } 3211 3212 updateLife(delta) { 3213 const particle = this.particle; 3214 let justSpawned = false;
3215 3216 if (particle.spawning) { 3217 particle.lifeDelayTime += delta.value; 3218 3219 if (particle.lifeDelayTime >= particle.lifeDelay) { 3220 justSpawned = true; 3221 particle.spawning = false; 3222 particle.lifeDelayTime = 0; 3223 particle.lifeTime = 0; 3224 } 3225 } 3226 3227 if (particle.lifeDuration === -1) { 3228 return; 3229 } 3230 3231 if (!particle.spawning) { 3232 if (justSpawned) { 3233 particle.lifeTime = 0; 3234 } else { 3235 particle.lifeTime += delta.value; 3236 } 3237 3238 if (particle.lifeTime >= particle.lifeDuration) { 3239 particle.lifeTime = 0; 3240 3241 if (particle.livesRemaining > 0) { 3242 particle.livesRemaining--; 3243 } 3244 3245 if (particle.livesRemaining === 0) { 3246 particle.destroy(); 3247 return; 3248 } 3249 3250 const canvasSize = this.container.canvas.size; 3251 particle.position.x = NumberUtils.randomInRange(0, canvasSize.width); 3252 particle.position.y = NumberUtils.randomInRange(0, canvasSize.height); 3253 particle.spawning = true; 3254 particle.lifeDelayTime = 0; 3255 particle.lifeTime = 0; 3256 const lifeOptions = particle.particlesOptions.life; 3257 particle.lifeDelay = NumberUtils.getValue(lifeOptions.delay) * 1000; 3258 particle.lifeDuration = NumberUtils.getValue(lifeOptions.duration) * 1000; 3259 } 3260 } 3261 } 3262 3263 updateOpacity(delta) { 3264 var _a, _b; 3265 3266 const particle = this.particle; 3267 const opacityAnim = particle.particlesOptions.opacity.anim; 3268 const minValue = opacityAnim.minimumValue; 3269 const maxValue = particle.particlesOptions.opacity.value; 3270 3271 if (opacityAnim.enable) { 3272 switch (particle.opacity.status) { 3273 case AnimationStatus.increasing: 3274 if (particle.opacity.value >= maxValue) { 3275 particle.opacity.status = AnimationStatus.decreasing; 3276 } else { 3277 particle.opacity.value += ((_a = particle.opacity.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor; 3278 } 3279 3280 break; 3281 3282 case AnimationStatus.decreasing: 3283 if (particle.opacity.value <= minValue) { 3284 particle.opacity.status = AnimationStatus.increasing; 3285 } else { 3286 particle.opacity.value -= ((_b = particle.opacity.velocity) !== null && _b !== void 0 ? _b : 0) * delta.factor; 3287 } 3288 3289 break; 3290 } 3291 3292 checkDestroy(particle, opacityAnim.destroy, particle.opacity.value, minValue, maxValue); 3293 3294 if (!particle.destroyed) { 3295 particle.opacity.value = NumberUtils.clamp(particle.opacity.value, minValue, maxValue); 3296 } 3297 } 3298 } 3299 3300 updateSize(delta) { 3301 var _a, _b; 3302 3303 const container = this.container; 3304 const particle = this.particle; 3305 const sizeOpt = particle.particlesOptions.size; 3306 const sizeAnim = sizeOpt.animation; 3307 const sizeVelocity = ((_a = particle.size.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor; 3308 const maxValue = (_b = particle.sizeValue) !== null && _b !== void 0 ? _b : container.retina.sizeValue; 3309 const minValue = sizeAnim.minimumValue * container.retina.pixelRatio; 3310 3311 if (sizeAnim.enable) { 3312 switch (particle.size.status) { 3313 case AnimationStatus.increasing: 3314 if (particle.size.value >= maxValue) { 3315 particle.size.status = AnimationStatus.decreasing; 3316 } else { 3317 particle.size.value += sizeVelocity; 3318 } 3319 3320 break; 3321 3322 case AnimationStatus.decreasing: 3323 if (particle.size.value <= minValue) { 3324 particle.size.status = AnimationStatus.increasing; 3325 } else { 3326 particle.size.value -= sizeVelocity; 3327 } 3328 3329 } 3330 3331 checkDestroy(particle, sizeAnim.destroy, particle.size.value, minValue, maxValue); 3332 3333 if (!particle.destroyed) { 3334 particle.size.value = NumberUtils.clamp(particle.size.value, minValue, maxValue); 3335 } 3336 } 3337 } 3338 3339 updateAngle(delta) { 3340 var _a; 3341 3342 const particle = this.particle; 3343 const rotate = particle.particlesOptions.rotate; 3344 const rotateAnimation = rotate.animation; 3345 const speed = ((_a = particle.rotate.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor; 3346 const max = 2 * Math.PI; 3347 3348 if (rotate.path) { 3349 particle.pathAngle = Math.atan2(particle.velocity.vertical, particle.velocity.horizontal); 3350 } else if (rotateAnimation.enable) { 3351 switch (particle.rotate.status) { 3352 case AnimationStatus.increasing: 3353 particle.rotate.value += speed; 3354 3355 if (particle.rotate.value > max) { 3356 particle.rotate.value -= max; 3357 } 3358 3359 break; 3360 3361 case AnimationStatus.decreasing: 3362 default: 3363 particle.rotate.value -= speed; 3364 3365 if (particle.rotate.value < 0) { 3366 particle.rotate.value += max; 3367 } 3368 3369 break; 3370 } 3371 } 3372 } 3373 3374 updateColor(delta) { 3375 var _a; 3376 3377 const particle = this.particle; 3378 3379 if (particle.color.value === undefined) { 3380 return; 3381 } 3382 3383 if (particle.particlesOptions.color.animation.enable) { 3384 particle.color.value.h += ((_a = particle.color.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor; 3385 3386 if (particle.color.value.h > 360) { 3387 particle.color.value.h -= 360; 3388 } 3389 } 3390 } 3391 3392 updateStrokeColor(delta) { 3393 var _a, _b; 3394 3395 const particle = this.particle; 3396 const color = particle.stroke.color; 3397 3398 if (typeof color === "string" || color === undefined) { 3399 return; 3400 } 3401 3402 if (particle.strokeColor.value === undefined) { 3403 return; 3404 } 3405 3406 if (color.animation.enable) { 3407 particle.strokeColor.value.h += ((_b = (_a = particle.strokeColor.velocity) !== null && _a !== void 0 ? _a : particle.color.velocity) !== null && _b !== void 0 ? _b : 0) * delta.factor; 3408 3409 if (particle.strokeColor.value.h > 360) { 3410 particle.strokeColor.value.h -= 360; 3411 } 3412 } 3413 } 3414 3415 updateOutModes(delta) { 3416 var _a, _b, _c, _d; 3417 3418 const outModes = this.particle.particlesOptions.move.outModes; 3419 this.updateOutMode(delta, (_a = outModes.bottom) !== null && _a !== void 0 ? _a : outModes.default, OutModeDirection.bottom); 3420 this.updateOutMode(delta, (_b = outModes.left) !== null && _b !== void 0 ? _b : outModes.default, OutModeDirection.left); 3421 this.updateOutMode(delta, (_c = outModes.right) !== null && _c !== void 0 ? _c : outModes.default, OutModeDirection.r
3421ight); 3422 this.updateOutMode(delta, (_d = outModes.top) !== null && _d !== void 0 ? _d : outModes.default, OutModeDirection.top); 3423 } 3424 3425 updateOutMode(delta, outMode, direction) { 3426 const container = this.container; 3427 const particle = this.particle; 3428 3429 switch (outMode) { 3430 case OutMode.bounce: 3431 case OutMode.bounceVertical: 3432 case OutMode.bounceHorizontal: 3433 case "bounceVertical": 3434 case "bounceHorizontal": 3435 this.updateBounce(delta, direction, outMode); 3436 break; 3437 3438 case OutMode.destroy: 3439 if (!Utils.isPointInside(particle.position, container.canvas.size, particle.getRadius(), direction)) { 3440 container.particles.remove(particle); 3441 } 3442 3443 break; 3444 3445 case OutMode.out: 3446 if (!Utils.isPointInside(particle.position, container.canvas.size, particle.getRadius(), direction)) { 3447 this.fixOutOfCanvasPosition(direction); 3448 } 3449 3450 break; 3451 3452 case OutMode.none: 3453 this.bounceNone(direction); 3454 break; 3455 } 3456 } 3457 3458 fixOutOfCanvasPosition(direction) { 3459 const container = this.container; 3460 const particle = this.particle; 3461 const wrap = particle.particlesOptions.move.warp; 3462 const canvasSize = container.canvas.size; 3463 const newPos = { 3464 bottom: canvasSize.height + particle.getRadius() - particle.offset.y, 3465 left: -particle.getRadius() - particle.offset.x, 3466 right: canvasSize.width + particle.getRadius() + particle.offset.x, 3467 top: -particle.getRadius() - particle.offset.y 3468 }; 3469 const sizeValue = particle.getRadius(); 3470 const nextBounds = Utils.calculateBounds(particle.position, sizeValue); 3471 3472 if (direction === OutModeDirection.right && nextBounds.left > canvasSize.width - particle.offset.x) { 3473 particle.position.x = newPos.left; 3474 3475 if (!wrap) { 3476 particle.position.y = Math.random() * canvasSize.height; 3477 } 3478 } else if (direction === OutModeDirection.left && nextBounds.right < -particle.offset.x) { 3479 particle.position.x = newPos.right; 3480 3481 if (!wrap) { 3482 particle.position.y = Math.random() * canvasSize.height; 3483 } 3484 } 3485 3486 if (direction === OutModeDirection.bottom && nextBounds.top > canvasSize.height - particle.offset.y) { 3487 if (!wrap) { 3488 particle.position.x = Math.random() * canvasSize.width; 3489 } 3490 3491 particle.position.y = newPos.top; 3492 } else if (direction === OutModeDirection.top && nextBounds.bottom < -particle.offset.y) { 3493 if (!wrap) { 3494 particle.position.x = Math.random() * canvasSize.width; 3495 } 3496 3497 particle.position.y = newPos.bottom; 3498 } 3499 } 3500 3501 updateBounce(delta, direction, outMode) { 3502 const container = this.container; 3503 const particle = this.particle; 3504 let handled = false; 3505 3506 for (const [, plugin] of container.plugins) { 3507 if (plugin.particleBounce !== undefined) { 3508 handled = plugin.particleBounce(particle, delta, direction); 3509 } 3510 3511 if (handled) { 3512 break; 3513 } 3514 } 3515 3516 if (handled) { 3517 return; 3518 } 3519 3520 const pos = particle.getPosition(), 3521 offset = particle.offset, 3522 size = particle.getRadius(), 3523 bounds = Utils.calculateBounds(pos, size), 3524 canvasSize = container.canvas.size; 3525 bounceHorizontal({ 3526 particle, 3527 outMode, 3528 direction, 3529 bounds, 3530 canvasSize, 3531 offset, 3532 size 3533 }); 3534 bounceVertical({ 3535 particle, 3536 outMode, 3537 direction, 3538 bounds, 3539 canvasSize, 3540 offset, 3541 size 3542 }); 3543 } 3544 3545 bounceNone(direction) { 3546 const particle = this.particle; 3547 3548 if (particle.particlesOptions.move.distance) { 3549 return; 3550 } 3551 3552 const gravityOptions = particle.particlesOptions.move.gravity; 3553 const container = this.container; 3554 3555 if (!gravityOptions.enable) { 3556 if (!Utils.isPointInside(particle.position, container.canvas.size, particle.getRadius(), direction)) { 3557 container.particles.remove(particle); 3558 } 3559 } else { 3560 const position = particle.position; 3561 3562 if (gravityOptions.acceleration >= 0 && position.y > container.canvas.size.height && direction === OutModeDirection.bottom || gravityOptions.acceleration < 0 && position.y < 0 && direction === OutModeDirection.top) { 3563 container.particles.remove(particle); 3564 } 3565 } 3566 } 3567 3568 } 3569 // CONCATENATED MODULE: ./dist/browser/Options/Classes/OptionsColor.js 3570 class OptionsColor { 3571 constructor() { 3572 this.value = "#fff"; 3573 } 3574 3575 static create(source, data) { 3576 const color = source !== null && source !== void 0 ? source : new OptionsColor(); 3577 3578 if (data !== undefined) { 3579 color.load(typeof data === "string" ? { 3580 value: data 3581 } : data); 3582 } 3583 3584 return color; 3585 } 3586 3587 load(data) { 3588 if ((data === null || data === void 0 ? void 0 : data.value) === undefined) { 3589 return; 3590 } 3591 3592 this.value = data.value; 3593 } 3594 3595 } 3596 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Links/LinksShadow.js 3597 3598 class LinksShadow { 3599 constructor() { 3600 this.blur = 5; 3601 this.color = new OptionsColor(); 3602 this.enable = false;
3603 this.color.value = "#00ff00"; 3604 } 3605 3606 load(data) { 3607 if (data === undefined) { 3608 return; 3609 } 3610 3611 if (data.blur !== undefined) { 3612 this.blur = data.blur; 3613 } 3614 3615 this.color = OptionsColor.create(this.color, data.color); 3616 3617 if (data.enable !== undefined) { 3618 this.enable = data.enable; 3619 } 3620 } 3621 3622 } 3623 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Links/LinksTriangle.js 3624 3625 class LinksTriangle { 3626 constructor() { 3627 this.enable = false; 3628 this.frequency = 1; 3629 } 3630 3631 load(data) { 3632 if (data === undefined) { 3633 return; 3634 } 3635 3636 if (data.color !== undefined) { 3637 this.color = OptionsColor.create(this.color, data.color); 3638 } 3639 3640 if (data.enable !== undefined) { 3641 this.enable = data.enable; 3642 } 3643 3644 if (data.frequency !== undefined) { 3645 this.frequency = data.frequency; 3646 } 3647 3648 if (data.opacity !== undefined) { 3649 this.opacity = data.opacity; 3650 } 3651 } 3652 3653 } 3654 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Links/Links.js 3655 3656 3657 3658 class Links { 3659 constructor() { 3660 this.blink = false; 3661 this.color = new OptionsColor(); 3662 this.consent = false; 3663 this.distance = 100; 3664 this.enable = false; 3665 this.frequency = 1; 3666 this.opacity = 1; 3667 this.shadow = new LinksShadow(); 3668 this.triangles = new LinksTriangle(); 3669 this.width = 1; 3670 this.warp = false; 3671 } 3672 3673 load(data) { 3674 if (data === undefined) { 3675 return; 3676 } 3677 3678 if (data.id !== undefined) { 3679 this.id = data.id; 3680 } 3681 3682 if (data.blink !== undefined) { 3683 this.blink = data.blink; 3684 } 3685 3686 this.color = OptionsColor.create(this.color, data.color); 3687 3688 if (data.consent !== undefined) { 3689 this.consent = data.consent; 3690 } 3691 3692 if (data.distance !== undefined) { 3693 this.distance = data.distance; 3694 } 3695 3696 if (data.enable !== undefined) { 3697 this.enable = data.enable; 3698 } 3699 3700 if (data.frequency !== undefined) { 3701 this.frequency = data.frequency; 3702 } 3703 3704 if (data.opacity !== undefined) { 3705 this.opacity = data.opacity; 3706 } 3707 3708 this.shadow.load(data.shadow); 3709 this.triangles.load(data.triangles); 3710 3711 if (data.width !== undefined) { 3712 this.width = data.width; 3713 } 3714 3715 if (data.warp !== undefined) { 3716 this.warp = data.warp; 3717 } 3718 } 3719 3720 } 3721 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/Attract.js 3722 class Attract { 3723 constructor() { 3724 this.enable = false; 3725 this.rotate = { 3726 x: 3000, 3727 y: 3000 3728 }; 3729 } 3730 3731 get rotateX() { 3732 return this.rotate.x; 3733 } 3734 3735 set rotateX(value) { 3736 this.rotate.x = value; 3737 } 3738 3739 get rotateY() { 3740 return this.rotate.y; 3741 } 3742 3743 set rotateY(value) { 3744 this.rotate.y = value; 3745 } 3746 3747 load(data) { 3748 var _a, _b, _c, _d; 3749 3750 if (data === undefined) { 3751 return; 3752 } 3753 3754 if (data.enable !== undefined) { 3755 this.enable = data.enable; 3756 } 3757 3758 const rotateX = (_b = (_a = data.rotate) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : data.rotateX; 3759 3760 if (rotateX !== undefined) { 3761 this.rotate.x = rotateX; 3762 } 3763 3764 const rotateY = (_d = (_c = data.rotate) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : data.rotateY; 3765 3766 if (rotateY !== undefined) { 3767 this.rotate.y = rotateY; 3768 } 3769 } 3770 3771 } 3772 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/Trail.js 3773 3774 class Trail { 3775 constructor() { 3776 this.enable = false; 3777 this.length = 10; 3778 this.fillColor = new OptionsColor(); 3779 this.fillColor.value = "#000000"; 3780 } 3781 3782 load(data) { 3783 if (data === undefined) { 3784 return; 3785 } 3786 3787 if (data.enable !== undefined) { 3788 this.enable = data.enable; 3789 } 3790 3791 this.fillColor = OptionsColor.create(this.fillColor, data.fillColor); 3792 3793 if (data.length !== undefined) { 3794 this.length = data.length; 3795 } 3796 } 3797 3798 } 3799 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Random.js 3800 class Random { 3801 constructor() { 3802 this.enable = false;
3803 this.minimumValue = 0; 3804 } 3805 3806 load(data) { 3807 if (!data) { 3808 return; 3809 } 3810 3811 if (data.enable !== undefined) { 3812 this.enable = data.enable; 3813 } 3814 3815 if (data.minimumValue !== undefined) { 3816 this.minimumValue = data.minimumValue; 3817 } 3818 } 3819 3820 } 3821 // CONCATENATED MODULE: ./dist/browser/Options/Classes/ValueWithRandom.js 3822 3823 class ValueWithRandom { 3824 constructor() { 3825 this.random = new Random(); 3826 this.value = 0; 3827 } 3828 3829 load(data) { 3830 if (!data) { 3831 return; 3832 } 3833 3834 if (typeof data.random === "boolean") { 3835 this.random.enable = data.random; 3836 } else { 3837 this.random.load(data.random); 3838 } 3839 3840 if (data.value !== undefined) { 3841 this.value = data.value; 3842 } 3843 } 3844 3845 } 3846 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/Noise/NoiseDelay.js 3847 3848 class NoiseDelay extends ValueWithRandom { 3849 constructor() { 3850 super(); 3851 } 3852 3853 } 3854 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/Noise/Noise.js 3855 3856 class Noise { 3857 constructor() { 3858 this.delay = new NoiseDelay(); 3859 this.enable = false; 3860 } 3861 3862 load(data) { 3863 if (data === undefined) { 3864 return; 3865 } 3866 3867 this.delay.load(data.delay); 3868 3869 if (data.enable !== undefined) { 3870 this.enable = data.enable; 3871 } 3872 } 3873 3874 } 3875 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/MoveAngle.js 3876 class MoveAngle { 3877 constructor() { 3878 this.offset = 45; 3879 this.value = 90; 3880 } 3881 3882 load(data) { 3883 if (data === undefined) { 3884 return; 3885 } 3886 3887 if (data.offset !== undefined) { 3888 this.offset = data.offset; 3889 } 3890 3891 if (data.value !== undefined) { 3892 this.value = data.value; 3893 } 3894 } 3895 3896 } 3897 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/MoveGravity.js 3898 class MoveGravity { 3899 constructor() { 3900 this.acceleration = 9.81; 3901 this.enable = false; 3902 this.maxSpeed = 50; 3903 } 3904 3905 load(data) { 3906 if (!data) { 3907 return; 3908 } 3909 3910 if (data.acceleration !== undefined) { 3911 this.acceleration = data.acceleration; 3912 } 3913 3914 if (data.enable !== undefined) { 3915 this.enable = data.enable; 3916 } 3917 3918 if (data.maxSpeed !== undefined) { 3919 this.maxSpeed = data.maxSpeed; 3920 } 3921 } 3922 3923 } 3924 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/OutModes.js 3925 3926 class OutModes { 3927 constructor() { 3928 this.default = OutMode.out; 3929 } 3930 3931 load(data) { 3932 var _a, _b, _c, _d; 3933 3934 if (!data) { 3935 return; 3936 } 3937 3938 if (data.default !== undefined) { 3939 this.default = data.default; 3940 } 3941 3942 this.bottom = (_a = data.bottom) !== null && _a !== void 0 ? _a : data.default; 3943 this.left = (_b = data.left) !== null && _b !== void 0 ? _b : data.default; 3944 this.right = (_c = data.right) !== null && _c !== void 0 ? _c : data.default; 3945 this.top = (_d = data.top) !== null && _d !== void 0 ? _d : data.default; 3946 } 3947 3948 } 3949 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Move/Move.js 3950 3951 3952 3953 3954 3955 3956 3957 class Move { 3958 constructor() { 3959 this.angle = new MoveAngle(); 3960 this.attract = new Attract(); 3961 this.direction = MoveDirection.none; 3962 this.distance = 0; 3963 this.enable = false; 3964 this.gravity = new MoveGravity(); 3965 this.noise = new Noise(); 3966 this.outModes = new OutModes(); 3967 this.random = false;
3968 this.size = false; 3969 this.speed = 2; 3970 this.straight = false; 3971 this.trail = new Trail(); 3972 this.vibrate = false; 3973 this.warp = false; 3974 } 3975 3976 get collisions() { 3977 return false; 3978 } 3979 3980 set collisions(value) {} 3981 3982 get bounce() { 3983 return this.collisions; 3984 } 3985 3986 set bounce(value) { 3987 this.collisions = value; 3988 } 3989 3990 get out_mode() { 3991 return this.outMode; 3992 } 3993 3994 set out_mode(value) { 3995 this.outMode = value; 3996 } 3997 3998 get outMode() { 3999 return this.outModes.default; 4000 } 4001 4002 set outMode(value) { 4003 this.outModes.default = value; 4004 } 4005 4006 load(data) { 4007 var _a, _b; 4008 4009 if (data === undefined) { 4010 return; 4011 } 4012 4013 if (data.angle !== undefined) { 4014 if (typeof data.angle === "number") { 4015 this.angle.value = data.angle; 4016 } else { 4017 this.angle.load(data.angle); 4018 } 4019 } 4020 4021 this.attract.load(data.attract); 4022 4023 if (data.direction !== undefined) { 4024 this.direction = data.direction; 4025 } 4026 4027 if (data.distance !== undefined) { 4028 this.distance = data.distance; 4029 } 4030 4031 if (data.enable !== undefined) { 4032 this.enable = data.enable; 4033 } 4034 4035 this.gravity.load(data.gravity); 4036 this.noise.load(data.noise); 4037 const outMode = (_a = data.outMode) !== null && _a !== void 0 ? _a : data.out_mode; 4038 4039 if (data.outModes !== undefined || outMode !== undefined) { 4040 if (typeof data.outModes === "string" || data.outModes === undefined && outMode !== undefined) { 4041 this.outModes.load({ 4042 default: (_b = data.outModes) !== null && _b !== void 0 ? _b : outMode 4043 }); 4044 } else { 4045 this.outModes.load(data.outModes); 4046 } 4047 } 4048 4049 if (data.random !== undefined) { 4050 this.random = data.random; 4051 } 4052 4053 if (data.size !== undefined) { 4054 this.size = data.size; 4055 } 4056 4057 if (data.speed !== undefined) { 4058 this.speed = data.speed; 4059 } 4060 4061 if (data.straight !== undefined) { 4062 this.straight = data.straight; 4063 } 4064 4065 this.trail.load(data.trail); 4066 4067 if (data.vibrate !== undefined) { 4068 this.vibrate = data.vibrate; 4069 } 4070 4071 if (data.warp !== undefined) { 4072 this.warp = data.warp; 4073 } 4074 } 4075 4076 } 4077 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Number/Density.js 4078 class Density { 4079 constructor() { 4080 this.enable = false; 4081 this.area = 800; 4082 this.factor = 1000; 4083 } 4084 4085 get value_area() { 4086 return this.area; 4087 } 4088 4089 set value_area(value) { 4090 this.area = value; 4091 } 4092 4093 load(data) { 4094 var _a; 4095 4096 if (data === undefined) { 4097 return; 4098 } 4099 4100 if (data.enable !== undefined) { 4101 this.enable = data.enable; 4102 } 4103 4104 const area = (_a = data.area) !== null && _a !== void 0 ? _a : data.value_area; 4105 4106 if (area !== undefined) { 4107 this.area = area; 4108 } 4109 4110 if (data.factor !== undefined) { 4111 this.factor = data.factor; 4112 } 4113 } 4114 4115 } 4116 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Number/ParticlesNumber.js 4117 4118 class ParticlesNumber { 4119 constructor() { 4120 this.density = new Density(); 4121 this.limit = 0; 4122 this.value = 100; 4123 } 4124 4125 get max() { 4126 return this.limit; 4127 } 4128 4129 set max(value) { 4130 this.limit = value; 4131 } 4132 4133 load(data) { 4134 var _a; 4135 4136 if (data === undefined) { 4137 return; 4138 } 4139 4140 this.density.load(data.density); 4141 const limit = (_a = data.limit) !== null && _a !== void 0 ? _a : data.max; 4142 4143 if (limit !== undefined) { 4144 this.limit = limit; 4145 } 4146 4147 if (data.value !== undefined) { 4148 this.value = data.value; 4149 } 4150 } 4151 4152 } 4153 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js 4154 4155 class OpacityAnimation { 4156 constructor() { 4157 this.destroy = DestroyType.none; 4158 this.enable = false;
4159 this.minimumValue = 0; 4160 this.speed = 2; 4161 this.startValue = StartValueType.random; 4162 this.sync = false; 4163 } 4164 4165 get opacity_min() { 4166 return this.minimumValue; 4167 } 4168 4169 set opacity_min(value) { 4170 this.minimumValue = value; 4171 } 4172 4173 load(data) { 4174 var _a; 4175 4176 if (data === undefined) { 4177 return; 4178 } 4179 4180 if (data.destroy !== undefined) { 4181 this.destroy = data.destroy; 4182 } 4183 4184 if (data.enable !== undefined) { 4185 this.enable = data.enable; 4186 } 4187 4188 const minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.opacity_min; 4189 4190 if (minimumValue !== undefined) { 4191 this.minimumValue = minimumValue; 4192 } 4193 4194 if (data.speed !== undefined) { 4195 this.speed = data.speed; 4196 } 4197 4198 if (data.startValue !== undefined) { 4199 this.startValue = data.startValue; 4200 } 4201 4202 if (data.sync !== undefined) { 4203 this.sync = data.sync; 4204 } 4205 } 4206 4207 } 4208 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Opacity/Opacity.js 4209 4210 4211 class Opacity extends ValueWithRandom { 4212 constructor() { 4213 super(); 4214 this.animation = new OpacityAnimation(); 4215 this.random.minimumValue = 0.1; 4216 this.value = 1; 4217 } 4218 4219 get anim() { 4220 return this.animation; 4221 } 4222 4223 set anim(value) { 4224 this.animation = value; 4225 } 4226 4227 load(data) { 4228 var _a; 4229 4230 if (!data) { 4231 return; 4232 } 4233 4234 super.load(data); 4235 this.animation.load((_a = data.animation) !== null && _a !== void 0 ? _a : data.anim); 4236 } 4237 4238 } 4239 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Shape/Shape.js 4240 4241 4242 class Shape { 4243 constructor() { 4244 this.options = {}; 4245 this.type = ShapeType.circle; 4246 } 4247 4248 get image() { 4249 var _a; 4250 4251 return (_a = this.options[ShapeType.image]) !== null && _a !== void 0 ? _a : this.options[ShapeType.images]; 4252 } 4253 4254 set image(value) { 4255 this.options[ShapeType.image] = value; 4256 this.options[ShapeType.images] = value; 4257 } 4258 4259 get custom() { 4260 return this.options; 4261 } 4262 4263 set custom(value) { 4264 this.options = value; 4265 } 4266 4267 get images() { 4268 return this.image instanceof Array ? this.image : [this.image]; 4269 } 4270 4271 set images(value) { 4272 this.image = value; 4273 } 4274 4275 get stroke() { 4276 return []; 4277 } 4278 4279 set stroke(_value) {} 4280 4281 get character() { 4282 var _a; 4283 4284 return (_a = this.options[ShapeType.character]) !== null && _a !== void 0 ? _a : this.options[ShapeType.char]; 4285 } 4286 4287 set character(value) { 4288 this.options[ShapeType.character] = value; 4289 this.options[ShapeType.char] = value; 4290 } 4291 4292 get polygon() { 4293 var _a; 4294 4295 return (_a = this.options[ShapeType.polygon]) !== null && _a !== void 0 ? _a : this.options[ShapeType.star]; 4296 } 4297 4298 set polygon(value) { 4299 this.options[ShapeType.polygon] = value; 4300 this.options[ShapeType.star] = value; 4301 } 4302 4303 load(data) { 4304 var _a, _b, _c; 4305 4306 if (data === undefined) { 4307 return; 4308 } 4309 4310 const options = (_a = data.options) !== null && _a !== void 0 ? _a : data.custom; 4311 4312 if (options !== undefined) { 4313 for (const shape in options) { 4314 const item = options[shape]; 4315 4316 if (item !== undefined) { 4317 this.options[shape] = Utils.deepExtend((_b = this.options[shape]) !== null && _b !== void 0 ? _b : {}, item); 4318 } 4319 } 4320 } 4321 4322 this.loadShape(data.character, ShapeType.character, ShapeType.char, true); 4323 this.loadShape(data.polygon, ShapeType.polygon, ShapeType.star, false); 4324 this.loadShape((_c = data.image) !== null && _c !== void 0 ? _c : data.images, ShapeType.image, ShapeType.images, true); 4325 4326 if (data.type !== undefined) { 4327 this.type = data.type; 4328 } 4329 } 4330 4331 loadShape(item, mainKey, altKey, altOverride) { 4332 var _a, _b, _c, _d; 4333 4334 if (item === undefined) { 4335 return; 4336 } 4337 4338 if (item instanceof Array) { 4339 if (!(this.options[mainKey] instanceof Array)) { 4340 this.options[mainKey] = []; 4341 4342 if (!this.options[altKey] || altOverride) { 4343 this.options[altKey] = []; 4344 } 4345 } 4346 4347 this.options[mainKey] = Utils.deepExtend((_a = this.options[mainKey]) !== null && _a !== void 0 ? _a : [], item); 4348 4349 if (!this.options[altKey] || altOverride) { 4350 this.options[altKey] = Utils.deepExtend((_b = this.options[altKey]) !== null && _b !== void 0 ? _b : [], item); 4351 } 4352 } else { 4353 if (this.options[mainKey] instanceof Array) { 4354 this.options[mainKey] = {}; 4355 4356 if (!this.options[altKey] || altOverride) { 4357 this.options[altKey] = {}; 4358 } 4359 } 4360 4361 this.options[mainKey] = Utils.deepExtend((_c = this.options[mainKey]) !== null && _c !== void 0 ? _c : {}, item); 4362 4363 if (!this.options[altKey] || altOverride) { 4364 this.options[altKey] = Utils.deepExtend((_d = this.options[altKey]) !== null && _d !== void 0 ? _d : {}, item); 4365 } 4366 } 4367 } 4368 4369 } 4370 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Size/SizeAnimation.js 4371 4372 class SizeAnimation { 4373 constructor() { 4374 this.destroy = DestroyType.none; 4375 this.enable = false;
4376 this.minimumValue = 0; 4377 this.speed = 5; 4378 this.startValue = StartValueType.random; 4379 this.sync = false; 4380 } 4381 4382 get size_min() { 4383 return this.minimumValue; 4384 } 4385 4386 set size_min(value) { 4387 this.minimumValue = value; 4388 } 4389 4390 load(data) { 4391 var _a; 4392 4393 if (data === undefined) { 4394 return; 4395 } 4396 4397 if (data.destroy !== undefined) { 4398 this.destroy = data.destroy; 4399 } 4400 4401 if (data.enable !== undefined) { 4402 this.enable = data.enable; 4403 } 4404 4405 const minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.size_min; 4406 4407 if (minimumValue !== undefined) { 4408 this.minimumValue = minimumValue; 4409 } 4410 4411 if (data.speed !== undefined) { 4412 this.speed = data.speed; 4413 } 4414 4415 if (data.startValue !== undefined) { 4416 this.startValue = data.startValue; 4417 } 4418 4419 if (data.sync !== undefined) { 4420 this.sync = data.sync; 4421 } 4422 } 4423 4424 } 4425 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Size/Size.js 4426 4427 4428 class Size extends ValueWithRandom { 4429 constructor() { 4430 super(); 4431 this.animation = new SizeAnimation(); 4432 this.random.minimumValue = 1; 4433 this.value = 3; 4434 } 4435 4436 get anim() { 4437 return this.animation; 4438 } 4439 4440 set anim(value) { 4441 this.animation = value; 4442 } 4443 4444 load(data) { 4445 var _a; 4446 4447 if (!data) { 4448 return; 4449 } 4450 4451 super.load(data); 4452 const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim; 4453 4454 if (animation !== undefined) { 4455 this.animation.load(animation); 4456 } 4457 } 4458 4459 } 4460 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Rotate/RotateAnimation.js 4461 class RotateAnimation { 4462 constructor() { 4463 this.enable = false; 4464 this.speed = 0; 4465 this.sync = false; 4466 } 4467 4468 load(data) { 4469 if (data === undefined) { 4470 return; 4471 } 4472 4473 if (data.enable !== undefined) { 4474 this.enable = data.enable; 4475 } 4476 4477 if (data.speed !== undefined) { 4478 this.speed = data.speed; 4479 } 4480 4481 if (data.sync !== undefined) { 4482 this.sync = data.sync; 4483 } 4484 } 4485 4486 } 4487 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Rotate/Rotate.js 4488 4489 4490 4491 class Rotate extends ValueWithRandom { 4492 constructor() { 4493 super(); 4494 this.animation = new RotateAnimation(); 4495 this.direction = RotateDirection.clockwise; 4496 this.path = false; 4497 } 4498 4499 load(data) { 4500 if (!data) { 4501 return; 4502 } 4503 4504 super.load(data); 4505 4506 if (data.direction !== undefined) { 4507 this.direction = data.direction; 4508 } 4509 4510 this.animation.load(data.animation); 4511 4512 if (data.path !== undefined) { 4513 this.path = data.path; 4514 } 4515 } 4516 4517 } 4518 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Shadow.js 4519 4520 class Shadow { 4521 constructor() { 4522 this.blur = 0; 4523 this.color = new OptionsColor(); 4524 this.enable = false; 4525 this.offset = { 4526 x: 0, 4527 y: 0 4528 }; 4529 this.color.value = "#000000"; 4530 } 4531 4532 load(data) { 4533 if (data === undefined) { 4534 return; 4535 } 4536 4537 if (data.blur !== undefined) { 4538 this.blur = data.blur; 4539 } 4540 4541 this.color = OptionsColor.create(this.color, data.color); 4542 4543 if (data.enable !== undefined) { 4544 this.enable = data.enable; 4545 } 4546 4547 if (data.offset === undefined) { 4548 return; 4549 } 4550 4551 if (data.offset.x !== undefined) { 4552 this.offset.x = data.offset.x; 4553 } 4554 4555 if (data.offset.y !== undefined) { 4556 this.offset.y = data.offset.y; 4557 } 4558 } 4559 4560 } 4561 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/ColorAnimation.js 4562 class ColorAnimation { 4563 constructor() { 4564 this.enable = false;
4565 this.speed = 1; 4566 this.sync = true; 4567 } 4568 4569 load(data) { 4570 if (data === undefined) { 4571 return; 4572 } 4573 4574 if (data.enable !== undefined) { 4575 this.enable = data.enable; 4576 } 4577 4578 if (data.speed !== undefined) { 4579 this.speed = data.speed; 4580 } 4581 4582 if (data.sync !== undefined) { 4583 this.sync = data.sync; 4584 } 4585 } 4586 4587 } 4588 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/AnimatableColor.js 4589 4590 4591 class AnimatableColor extends OptionsColor { 4592 constructor() { 4593 super(); 4594 this.animation = new ColorAnimation(); 4595 } 4596 4597 static create(source, data) { 4598 const color = source !== null && source !== void 0 ? source : new AnimatableColor(); 4599 4600 if (data !== undefined) { 4601 color.load(typeof data === "string" ? { 4602 value: data 4603 } : data); 4604 } 4605 4606 return color; 4607 } 4608 4609 load(data) { 4610 super.load(data); 4611 this.animation.load(data === null || data === void 0 ? void 0 : data.animation); 4612 } 4613 4614 } 4615 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Stroke.js 4616 4617 class Stroke { 4618 constructor() { 4619 this.width = 0; 4620 } 4621 4622 load(data) { 4623 if (data === undefined) { 4624 return; 4625 } 4626 4627 if (data.color !== undefined) { 4628 this.color = AnimatableColor.create(this.color, data.color); 4629 } 4630 4631 if (data.width !== undefined) { 4632 this.width = data.width; 4633 } 4634 4635 if (data.opacity !== undefined) { 4636 this.opacity = data.opacity; 4637 } 4638 } 4639 4640 } 4641 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Bounce/BounceFactor.js 4642 4643 class BounceFactor extends ValueWithRandom { 4644 constructor() { 4645 super(); 4646 this.random.minimumValue = 0.1; 4647 this.value = 1; 4648 } 4649 4650 } 4651 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Bounce/Bounce.js 4652 4653 class Bounce { 4654 constructor() { 4655 this.horizontal = new BounceFactor(); 4656 this.vertical = new BounceFactor(); 4657 } 4658 4659 load(data) { 4660 if (!data) { 4661 return; 4662 } 4663 4664 this.horizontal.load(data.horizontal); 4665 this.vertical.load(data.vertical); 4666 } 4667 4668 } 4669 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Collisions.js 4670 4671 4672 class Collisions { 4673 constructor() { 4674 this.bounce = new Bounce(); 4675 this.enable = false; 4676 this.mode = CollisionMode.bounce; 4677 } 4678 4679 load(data) { 4680 if (data === undefined) { 4681 return; 4682 } 4683 4684 this.bounce.load(data.bounce); 4685 4686 if (data.enable !== undefined) { 4687 this.enable = data.enable; 4688 } 4689 4690 if (data.mode !== undefined) { 4691 this.mode = data.mode; 4692 } 4693 } 4694 4695 } 4696 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Twinkle/TwinkleValues.js 4697 4698 class TwinkleValues { 4699 constructor() { 4700 this.enable = false; 4701 this.frequency = 0.05; 4702 this.opacity = 1; 4703 } 4704 4705 load(data) { 4706 if (data === undefined) { 4707 return; 4708 } 4709 4710 if (data.color !== undefined) { 4711 this.color = OptionsColor.create(this.color, data.color); 4712 } 4713 4714 if (data.enable !== undefined) { 4715 this.enable = data.enable; 4716 } 4717 4718 if (data.frequency !== undefined) { 4719 this.frequency = data.frequency; 4720 } 4721 4722 if (data.opacity !== undefined) { 4723 this.opacity = data.opacity; 4724 } 4725 } 4726 4727 } 4728 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Twinkle/Twinkle.js 4729 4730 class Twinkle { 4731 constructor() { 4732 this.lines = new TwinkleValues(); 4733 this.particles = new TwinkleValues(); 4734 } 4735 4736 load(data) { 4737 if (data === undefined) { 4738 return; 4739 } 4740 4741 this.lines.load(data.lines); 4742 this.particles.load(data.particles); 4743 } 4744 4745 } 4746 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Life/LifeDelay.js 4747 4748 class LifeDelay extends ValueWithRandom { 4749 constructor() { 4750 super(); 4751 this.sync = false;
4752 } 4753 4754 load(data) { 4755 if (!data) { 4756 return; 4757 } 4758 4759 super.load(data); 4760 4761 if (data.sync !== undefined) { 4762 this.sync = data.sync; 4763 } 4764 } 4765 4766 } 4767 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Life/LifeDuration.js 4768 4769 class LifeDuration extends ValueWithRandom { 4770 constructor() { 4771 super(); 4772 this.random.minimumValue = 0.0001; 4773 this.sync = false; 4774 } 4775 4776 load(data) { 4777 if (data === undefined) { 4778 return; 4779 } 4780 4781 super.load(data); 4782 4783 if (data.sync !== undefined) { 4784 this.sync = data.sync; 4785 } 4786 } 4787 4788 } 4789 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Life/Life.js 4790 4791 4792 class Life { 4793 constructor() { 4794 this.count = 0; 4795 this.delay = new LifeDelay(); 4796 this.duration = new LifeDuration(); 4797 } 4798 4799 load(data) { 4800 if (data === undefined) { 4801 return; 4802 } 4803 4804 if (data.count !== undefined) { 4805 this.count = data.count; 4806 } 4807 4808 this.delay.load(data.delay); 4809 this.duration.load(data.duration); 4810 } 4811 4812 } 4813 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Particles/Particles.js 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 class Particles { 4829 constructor() { 4830 this.bounce = new Bounce(); 4831 this.collisions = new Collisions(); 4832 this.color = new AnimatableColor(); 4833 this.life = new Life(); 4834 this.links = new Links(); 4835 this.move = new Move(); 4836 this.number = new ParticlesNumber(); 4837 this.opacity = new Opacity(); 4838 this.reduceDuplicates = false; 4839 this.rotate = new Rotate(); 4840 this.shadow = new Shadow(); 4841 this.shape = new Shape(); 4842 this.size = new Size(); 4843 this.stroke = new Stroke(); 4844 this.twinkle = new Twinkle(); 4845 } 4846 4847 get line_linked() { 4848 return this.links; 4849 } 4850 4851 set line_linked(value) { 4852 this.links = value; 4853 } 4854 4855 get lineLinked() { 4856 return this.links; 4857 } 4858 4859 set lineLinked(value) { 4860 this.links = value; 4861 } 4862 4863 load(data) { 4864 var _a, _b, _c, _d, _e, _f, _g; 4865 4866 if (data === undefined) { 4867 return; 4868 } 4869 4870 this.bounce.load(data.bounce); 4871 this.color = AnimatableColor.create(this.color, data.color); 4872 this.life.load(data.life); 4873 const links = (_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked; 4874 4875 if (links !== undefined) { 4876 this.links.load(links); 4877 } 4878 4879 this.move.load(data.move); 4880 this.number.load(data.number); 4881 this.opacity.load(data.opacity); 4882 4883 if (data.reduceDuplicates !== undefined) { 4884 this.reduceDuplicates = data.reduceDuplicates; 4885 } 4886 4887 this.rotate.load(data.rotate); 4888 this.shape.load(data.shape); 4889 this.size.load(data.size); 4890 this.shadow.load(data.shadow); 4891 this.twinkle.load(data.twinkle); 4892 const collisions = (_d = (_c = data.move) === null || _c === void 0 ? void 0 : _c.collisions) !== null && _d !== void 0 ? _d : (_e = data.move) === null || _e === void 0 ? void 0 : _e.bounce; 4893 4894 if (collisions !== undefined) { 4895 this.collisions.enable = collisions; 4896 } 4897 4898 this.collisions.load(data.collisions); 4899 const strokeToLoad = (_f = data.stroke) !== null && _f !== void 0 ? _f : (_g = data.shape) === null || _g === void 0 ? void 0 : _g.stroke; 4900 4901 if (strokeToLoad === undefined) { 4902 return; 4903 } 4904 4905 if (strokeToLoad instanceof Array) { 4906 this.stroke = strokeToLoad.map(s => { 4907 const tmp = new Stroke(); 4908 tmp.load(s); 4909 return tmp; 4910 }); 4911 } else { 4912 if (this.stroke instanceof Array) { 4913 this.stroke = new Stroke(); 4914 } 4915 4916 this.stroke.load(strokeToLoad); 4917 } 4918 } 4919 4920 } 4921 // CONCATENATED MODULE: ./dist/browser/Core/Particle/Infecter.js 4922 class Infecter { 4923 constructor(container) { 4924 this.container = container; 4925 } 4926 4927 startInfection(stage) { 4928 const options = this.container.options; 4929 const stages = options.infection.stages; 4930 const stagesCount = stages.length; 4931 4932 if (stage > stagesCount || stage < 0) { 4933 return; 4934 } 4935 4936 this.infectionDelay = 0; 4937 this.infectionDelayStage = stage; 4938 } 4939 4940 updateInfectionStage(stage) { 4941 const options = this.container.options; 4942 const stagesCount = options.infection.stages.length; 4943 4944 if (stage > stagesCount || stage < 0 || this.infectionStage !== undefined && this.infectionStage > stage) { 4945 return; 4946 } 4947 4948 this.infectionStage = stage; 4949 this.infectionTime = 0; 4950 } 4951 4952 updateInfection(delta) { 4953 const options = this.container.options; 4954 const infection = options.infection; 4955 const stages = options.infection.stages; 4956 const stagesCount = stages.length; 4957 4958 if (this.infectionDelay !== undefined && this.infectionDelayStage !== undefined) { 4959 const stage = this.infectionDelayStage; 4960 4961 if (stage > stagesCount || stage < 0) { 4962 return; 4963 } 4964 4965 if (this.infectionDelay > infection.delay * 1000) { 4966 this.infectionStage = stage; 4967 this.infectionTime = 0; 4968 delete this.infectionDelay; 4969 delete this.infectionDelayStage; 4970 } else { 4971 this.infectionDelay += delta; 4972 } 4973 } else { 4974 delete this.infectionDelay; 4975 delete this.infectionDelayStage; 4976 } 4977 4978 if (this.infectionStage !== undefined && this.infectionTime !== undefined) { 4979 const infectionStage = stages[this.infectionStage]; 4980 4981 if (infectionStage.duration !== undefined && infectionStage.duration >= 0) { 4982 if (this.infectionTime > infectionStage.duration * 1000) { 4983 this.nextInfectionStage(); 4984 } else { 4985 this.infectionTime += delta; 4986 } 4987 } else { 4988 this.infectionTime += delta; 4989 } 4990 } else { 4991 delete this.infectionStage; 4992 delete this.infectionTime; 4993 } 4994 } 4995 4996 nextInfectionStage() { 4997 const options = this.container.options; 4998 const stagesCount = options.infection.stages.length; 4999 5000 if (stagesCount <= 0 || this.infectionStage === undefined) { 5001 return; 5002 } 5003 5004 this.infectionTime = 0; 5005 5006 if (stagesCount <= ++this.infectionStage) { 5007 if (options.infection.cure) { 5008 delete this.infectionStage; 5009 delete this.infectionTime; 5010 return; 5011 } else { 5012 this.infectionStage = 0; 5013 this.infectionTime = 0; 5014 } 5015 } 5016 } 5017 5018 } 5019 // CONCATENATED MODULE: ./dist/browser/Core/Particle/Mover.js 5020 5021 5022 class Mover { 5023 constructor(container, particle) { 5024 this.container = container; 5025 this.particle = particle; 5026 } 5027 5028 move(delta) { 5029 const particle = this.particle; 5030 particle.bubble.inRange = false;
5031 particle.links = []; 5032 5033 for (const [, plugin] of this.container.plugins) { 5034 if (particle.destroyed) { 5035 break; 5036 } 5037 5038 if (plugin.particleUpdate) { 5039 plugin.particleUpdate(particle, delta); 5040 } 5041 } 5042 5043 if (particle.destroyed) { 5044 return; 5045 } 5046 5047 this.moveParticle(delta); 5048 this.moveParallax(); 5049 } 5050 5051 moveParticle(delta) { 5052 var _a, _b; 5053 5054 const particle = this.particle; 5055 const particlesOptions = particle.particlesOptions; 5056 5057 if (!particlesOptions.move.enable) { 5058 return; 5059 } 5060 5061 const container = this.container; 5062 const slowFactor = this.getProximitySpeedFactor(); 5063 const baseSpeed = ((_a = particle.moveSpeed) !== null && _a !== void 0 ? _a : container.retina.moveSpeed) * container.retina.reduceFactor; 5064 const maxSize = (_b = particle.sizeValue) !== null && _b !== void 0 ? _b : container.retina.sizeValue; 5065 const sizeFactor = particlesOptions.move.size ? particle.getRadius() / maxSize : 1; 5066 const moveSpeed = baseSpeed / 2 * sizeFactor * slowFactor * delta.factor; 5067 this.applyNoise(delta); 5068 const gravityOptions = particlesOptions.move.gravity; 5069 5070 if (gravityOptions.enable) { 5071 particle.velocity.vertical += gravityOptions.acceleration * delta.factor / (60 * moveSpeed); 5072 } 5073 5074 const velocity = { 5075 horizontal: particle.velocity.horizontal * moveSpeed, 5076 vertical: particle.velocity.vertical * moveSpeed 5077 }; 5078 5079 if (gravityOptions.enable && velocity.vertical >= gravityOptions.maxSpeed && gravityOptions.maxSpeed > 0) { 5080 velocity.vertical = gravityOptions.maxSpeed; 5081 particle.velocity.vertical = velocity.vertical / moveSpeed; 5082 } 5083 5084 particle.position.x += velocity.horizontal; 5085 particle.position.y += velocity.vertical; 5086 5087 if (particlesOptions.move.vibrate) { 5088 particle.position.x += Math.sin(particle.position.x * Math.cos(particle.position.y)); 5089 particle.position.y += Math.cos(particle.position.y * Math.sin(particle.position.x)); 5090 } 5091 5092 const initialPosition = particle.initialPosition; 5093 const initialDistance = NumberUtils.getDistance(initialPosition, particle.position); 5094 5095 if (particle.maxDistance) { 5096 if (initialDistance >= particle.maxDistance && !particle.misplaced) { 5097 particle.misplaced = initialDistance > particle.maxDistance; 5098 particle.velocity.horizontal = particle.velocity.vertical / 2 - particle.velocity.horizontal; 5099 particle.velocity.vertical = particle.velocity.horizontal / 2 - particle.velocity.vertical; 5100 } else if (initialDistance < particle.maxDistance && particle.misplaced) { 5101 particle.misplaced = false; 5102 } else if (particle.misplaced) { 5103 if (particle.position.x < initialPosition.x && particle.velocity.horizontal < 0 || particle.position.x > initialPosition.x && particle.velocity.horizontal > 0) { 5104 particle.velocity.horizontal *= -Math.random(); 5105 } 5106 5107 if (particle.position.y < initialPosition.y && particle.velocity.vertical < 0 || particle.position.y > initialPosition.y && particle.velocity.vertical > 0) { 5108 particle.velocity.vertical *= -Math.random(); 5109 } 5110 } 5111 } 5112 } 5113 5114 applyNoise(delta) { 5115 const particle = this.particle; 5116 const particlesOptions = particle.particlesOptions; 5117 const noiseOptions = particlesOptions.move.noise; 5118 const noiseEnabled = noiseOptions.enable; 5119 5120 if (!noiseEnabled) { 5121 return; 5122 } 5123 5124 const container = this.container; 5125 5126 if (particle.lastNoiseTime <= particle.noiseDelay) { 5127 particle.lastNoiseTime += delta.value; 5128 return; 5129 } 5130 5131 const noise = container.noise.generate(particle); 5132 particle.velocity.horizontal += Math.cos(noise.angle) * noise.length; 5133 particle.velocity.horizontal = NumberUtils.clamp(particle.velocity.horizontal, -1, 1); 5134 particle.velocity.vertical += Math.sin(noise.angle) * noise.length; 5135 particle.velocity.vertical = NumberUtils.clamp(particle.velocity.vertical, -1, 1); 5136 particle.lastNoiseTime -= particle.noiseDelay; 5137 } 5138 5139 moveParallax() { 5140 const container = this.container; 5141 const options = container.options; 5142 5143 if (Utils.isSsr() || !options.interactivity.events.onHover.parallax.enable) { 5144 return; 5145 } 5146 5147 const particle = this.particle; 5148 const parallaxForce = options.interactivity.events.onHover.parallax.force; 5149 const mousePos = container.interactivity.mouse.position; 5150 5151 if (!mousePos) { 5152 return; 5153 } 5154 5155 const canvasCenter = { 5156 x: container.canvas.size.width / 2, 5157 y: container.canvas.size.height / 2 5158 }; 5159 const parallaxSmooth = options.interactivity.events.onHover.parallax.smooth; 5160 const factor = particle.getRadius() / parallaxForce; 5161 const tmp = { 5162 x: (mousePos.x - canvasCenter.x) * factor, 5163 y: (mousePos.y - canvasCenter.y) * factor 5164 }; 5165 particle.offset.x += (tmp.x - particle.offset.x) / parallaxSmooth; 5166 particle.offset.y += (tmp.y - particle.offset.y) / parallaxSmooth; 5167 } 5168 5169 getProximitySpeedFactor() { 5170 const container = this.container; 5171 const options = container.options; 5172 const active = Utils.isInArray(HoverMode.slow, options.interactivity.events.onHover.mode); 5173 5174 if (!active) { 5175 return 1; 5176 } 5177 5178 const mousePos = this.container.interactivity.mouse.position; 5179 5180 if (!mousePos) { 5181 return 1; 5182 } 5183 5184 const particlePos = this.particle.getPosition(); 5185 const dist = NumberUtils.getDistance(mousePos, particlePos); 5186 const radius = container.retina.slowModeRadius; 5187 5188 if (dist > radius) { 5189 return 1; 5190 } 5191 5192 const proximityFactor = dist / radius || 0; 5193 const slowFactor = options.interactivity.modes.slow.factor; 5194 return proximityFactor / slowFactor; 5195 } 5196 5197 } 5198 // CONCATENATED MODULE: ./dist/browser/Core/Particle.js 5199 5200 5201 5202 5203 5204 5205 5206 class Particle { 5207 constructor(id, container, position, overrideOptions) { 5208 var _a, _b, _c, _d, _e, _f, _g, _h, _j; 5209 5210 this.id = id; 5211 this.container = container; 5212 this.links = []; 5213 this.fill = true; 5214 this.close = true; 5215 this.lastNoiseTime = 0; 5216 this.destroyed = false;
5217 this.misplaced = false; 5218 const pxRatio = container.retina.pixelRatio; 5219 const options = container.options; 5220 const particlesOptions = new Particles(); 5221 particlesOptions.load(options.particles); 5222 const shapeType = particlesOptions.shape.type; 5223 const reduceDuplicates = particlesOptions.reduceDuplicates; 5224 this.shape = shapeType instanceof Array ? Utils.itemFromArray(shapeType, this.id, reduceDuplicates) : shapeType; 5225 5226 if (overrideOptions === null || overrideOptions === void 0 ? void 0 : overrideOptions.shape) { 5227 if (overrideOptions.shape.type) { 5228 const overrideShapeType = overrideOptions.shape.type; 5229 this.shape = overrideShapeType instanceof Array ? Utils.itemFromArray(overrideShapeType, this.id, reduceDuplicates) : overrideShapeType; 5230 } 5231 5232 const shapeOptions = new Shape(); 5233 shapeOptions.load(overrideOptions.shape); 5234 5235 if (this.shape) { 5236 const shapeData = shapeOptions.options[this.shape]; 5237 5238 if (shapeData) { 5239 this.shapeData = Utils.deepExtend({}, shapeData instanceof Array ? Utils.itemFromArray(shapeData, this.id, reduceDuplicates) : shapeData); 5240 } 5241 } 5242 } else { 5243 const shapeData = particlesOptions.shape.options[this.shape]; 5244 5245 if (shapeData) { 5246 this.shapeData = Utils.deepExtend({}, shapeData instanceof Array ? Utils.itemFromArray(shapeData, this.id, reduceDuplicates) : shapeData); 5247 } 5248 } 5249 5250 if (overrideOptions !== undefined) { 5251 particlesOptions.load(overrideOptions); 5252 } 5253 5254 if (((_a = this.shapeData) === null || _a === void 0 ? void 0 : _a.particles) !== undefined) { 5255 particlesOptions.load((_b = this.shapeData) === null || _b === void 0 ? void 0 : _b.particles); 5256 } 5257 5258 this.fill = (_d = (_c = this.shapeData) === null || _c === void 0 ? void 0 : _c.fill) !== null && _d !== void 0 ? _d : this.fill; 5259 this.close = (_f = (_e = this.shapeData) === null || _e === void 0 ? void 0 : _e.close) !== null && _f !== void 0 ? _f : this.close; 5260 this.particlesOptions = particlesOptions; 5261 this.noiseDelay = NumberUtils.getValue(this.particlesOptions.move.noise.delay) * 1000; 5262 container.retina.initParticle(this); 5263 const color = this.particlesOptions.color; 5264 const sizeOptions = this.particlesOptions.size; 5265 const sizeValue = NumberUtils.getValue(sizeOptions) * container.retina.pixelRatio; 5266 const randomSize = typeof sizeOptions.random === "boolean" ? sizeOptions.random : sizeOptions.random.enable; 5267 this.size = { 5268 value: sizeValue 5269 }; 5270 this.direction = this.particlesOptions.move.direction; 5271 this.bubble = { 5272 inRange: false 5273 }; 5274 this.initialVelocity = this.calculateVelocity(); 5275 this.velocity = { 5276 horizontal: this.initialVelocity.horizontal, 5277 vertical: this.initialVelocity.vertical 5278 }; 5279 this.pathAngle = Math.atan2(this.initialVelocity.vertical, this.initialVelocity.horizontal); 5280 const rotateOptions = this.particlesOptions.rotate; 5281 this.rotate = { 5282 value: (rotateOptions.random.enable ? Math.random() * 360 : rotateOptions.value) * Math.PI / 180 5283 }; 5284 let rotateDirection = rotateOptions.direction; 5285 5286 if (rotateDirection === RotateDirection.random) { 5287 const index = Math.floor(Math.random() * 2); 5288 rotateDirection = index > 0 ? RotateDirection.counterClockwise : RotateDirection.clockwise; 5289 } 5290 5291 switch (rotateDirection) { 5292 case RotateDirection.counterClockwise: 5293 case "counterClockwise": 5294 this.rotate.status = AnimationStatus.decreasing; 5295 break; 5296 5297 case RotateDirection.clockwise: 5298 this.rotate.status = AnimationStatus.increasing; 5299 break; 5300 } 5301 5302 const rotateAnimation = this.particlesOptions.rotate.animation; 5303 5304 if (rotateAnimation.enable) { 5305 this.rotate.velocity = rotateAnimation.speed / 360 * container.retina.reduceFactor; 5306 5307 if (!rotateAnimation.sync) { 5308 this.rotate.velocity *= Math.random(); 5309 } 5310 } 5311 5312 const sizeAnimation = this.particlesOptions.size.animation; 5313 5314 if (sizeAnimation.enable) { 5315 this.size.status = AnimationStatus.increasing; 5316 5317 if (!randomSize) { 5318 switch (sizeAnimation.startValue) { 5319 case StartValueType.min: 5320 this.size.value = sizeAnimation.minimumValue * pxRatio; 5321 break; 5322 5323 case StartValueType.random: 5324 this.size.value = NumberUtils.randomInRange(sizeAnimation.minimumValue * pxRatio, this.size.value); 5325 break; 5326 5327 case StartValueType.max: 5328 default: 5329 this.size.status = AnimationStatus.decreasing; 5330 break; 5331 } 5332 } 5333 5334 this.size.velocity = ((_g = this.sizeAnimationSpeed) !== null && _g !== void 0 ? _g : container.retina.sizeAnimationSpeed) / 100 * container.retina.reduceFactor; 5335 5336 if (!sizeAnimation.sync) { 5337 this.size.velocity *= Math.random(); 5338 } 5339 } 5340 5341 this.color = { 5342 value: ColorUtils.colorToHsl(color, this.id, reduceDuplicates) 5343 }; 5344 const colorAnimation = this.particlesOptions.color.animation; 5345 5346 if (colorAnimation.enable) { 5347 this.color.velocity = colorAnimation.speed / 100 * container.retina.reduceFactor; 5348 5349 if (!colorAnimation.sync) { 5350 this.color.velocity *= Math.random(); 5351 } 5352 } 5353 5354 this.position = this.calcPosition(this.container, position); 5355 this.initialPosition = { 5356 x: this.position.x, 5357 y: this.position.y 5358 }; 5359 this.offset = { 5360 x: 0, 5361 y: 0 5362 }; 5363 const opacityOptions = this.particlesOptions.opacity; 5364 const randomOpacity = typeof opacityOptions.random === "boolean" ? opacityOptions.random : opacityOptions.random.enable; 5365 this.opacity = { 5366 value: NumberUtils.getValue(opacityOptions) 5367 }; 5368 const opacityAnimation = opacityOptions.animation; 5369 5370 if (opacityAnimation.enable) { 5371 this.opacity.status = AnimationStatus.increasing; 5372 5373 if (!randomOpacity) { 5374 switch (opacityAnimation.startValue) { 5375 case StartValueType.min: 5376 this.opacity.value = opacityAnimation.minimumValue; 5377 break; 5378 5379 case StartValueType.random: 5380 this.opacity.value = NumberUtils.randomInRange(opacityAnimation.minimumValue, this.opacity.value); 5381 break; 5382 5383 case StartValueType.max: 5384 default: 5385 this.opacity.status = AnimationStatus.decreasing; 5386 break; 5387 } 5388 } 5389 5390 this.opacity.velocity = opacityAnimation.speed / 100 * container.retina.reduceFactor; 5391 5392 if (!opacityAnimation.sync) { 5393 this.opacity.velocity *= Math.random(); 5394 } 5395 } 5396 5397 this.sides = 24; 5398 let drawer = container.drawers.get(this.shape); 5399 5400 if (!drawer) { 5401 drawer = Plugins.getShapeDrawer(this.shape); 5402 5403 if (drawer) { 5404 container.drawers.set(this.shape, drawer); 5405 } 5406 } 5407 5408 const sideCountFunc = drawer === null || drawer === void 0 ? void 0 : drawer.getSidesCount; 5409 5410 if (sideCountFunc) { 5411 this.sides = sideCountFunc(this); 5412 } 5413 5414 const imageShape = this.loadImageShape(container, drawer); 5415 5416 if (imageShape) { 5417 this.image = imageShape.image; 5418 this.fill = imageShape.fill; 5419 this.close = imageShape.close; 5420 } 5421 5422 this.stroke = this.particlesOptions.stroke instanceof Array ? Utils.itemFromArray(this.particlesOptions.stroke, this.id, reduceDuplicates) : this.particlesOptions.stroke; 5423 this.strokeWidth = this.stroke.width * container.retina.pixelRatio; 5424 this.strokeColor = { 5425 value: (_h = ColorUtils.colorToHsl(this.stroke.color)) !== null && _h !== void 0 ? _h : this.color.value 5426 }; 5427 5428 if (typeof this.stroke.color !== "string") { 5429 const strokeColorAnimation = (_j = this.stroke.color) === null || _j === void 0 ? void 0 : _j.animation; 5430 5431 if (strokeColorAnimation && this.strokeColor) { 5432 if (strokeColorAnimation.enable) { 5433 this.strokeColor.velocity = strokeColorAnimation.speed / 100 * container.retina.reduceFactor; 5434 5435 if (!strokeColorAnimation.sync) { 5436 this.strokeColor.velocity = this.strokeColor.velocity * Math.random(); 5437 } 5438 } else { 5439 this.strokeColor.velocity = 0; 5440 } 5441 5442 if (strokeColorAnimation.enable && !strokeColorAnimation.sync && this.strokeColor.value) { 5443 this.strokeColor.value.h = Math.random() * 360; 5444 } 5445 } 5446 } 5447 5448 const lifeOptions = particlesOptions.life; 5449 this.lifeDelay = container.retina.reduceFactor ? NumberUtils.getValue(lifeOptions.delay) * (lifeOptions.delay.sync ? 1 : Math.random()) / container.retina.reduceFactor * 1000 : 0; 5450 this.lifeDelayTime = 0; 5451 this.lifeDuration = container.retina.reduceFactor ? NumberUtils.getValue(lifeOptions.duration) * (lifeOptions.duration.sync ? 1 : Math.random()) / container.retina.reduceFactor * 1000 : 0; 5452 this.lifeTime = 0; 5453 this.livesRemaining = particlesOptions.life.count; 5454 this.spawning = this.lifeDelay > 0; 5455 5456 if (this.lifeDuration <= 0) { 5457 this.lifeDuration = -1; 5458 } 5459 5460 if (this.livesRemaining <= 0) { 5461 this.livesRemaining = -1; 5462 } 5463 5464 this.shadowColor = ColorUtils.colorToRgb(this.particlesOptions.shadow.color); 5465 this.updater = new Updater(container, this); 5466 this.infecter = new Infecter(container); 5467 this.mover = new Mover(container, this); 5468 } 5469 5470 move(delta) { 5471 this.mover.move(delta); 5472 } 5473 5474 update(delta) { 5475 this.updater.update(delta); 5476 } 5477 5478 draw(delta) {
5479 this.container.canvas.drawParticle(this, delta); 5480 } 5481 5482 getPosition() { 5483 return { 5484 x: this.position.x + this.offset.x, 5485 y: this.position.y + this.offset.y 5486 }; 5487 } 5488 5489 getRadius() { 5490 return this.bubble.radius || this.size.value; 5491 } 5492 5493 getFillColor() { 5494 var _a; 5495 5496 return (_a = this.bubble.color) !== null && _a !== void 0 ? _a : this.color.value; 5497 } 5498 5499 getStrokeColor() { 5500 var _a, _b; 5501 5502 return (_b = (_a = this.bubble.color) !== null && _a !== void 0 ? _a : this.strokeColor.value) !== null && _b !== void 0 ? _b : this.color.value; 5503 } 5504 5505 destroy() { 5506 this.destroyed = true; 5507 this.bubble.inRange = false; 5508 this.links = []; 5509 } 5510 5511 calcPosition(container, position) { 5512 var _a, _b; 5513 5514 for (const [, plugin] of container.plugins) { 5515 const pluginPos = plugin.particlePosition !== undefined ? plugin.particlePosition(position, this) : undefined; 5516 5517 if (pluginPos !== undefined) { 5518 return Utils.deepExtend({}, pluginPos); 5519 } 5520 } 5521 5522 const pos = { 5523 x: (_a = position === null || position === void 0 ? void 0 : position.x) !== null && _a !== void 0 ? _a : Math.random() * container.canvas.size.width, 5524 y: (_b = position === null || position === void 0 ? void 0 : position.y) !== null && _b !== void 0 ? _b : Math.random() * container.canvas.size.height 5525 }; 5526 const outMode = this.particlesOptions.move.outMode; 5527 5528 if (Utils.isInArray(outMode, OutMode.bounce) || Utils.isInArray(outMode, OutMode.bounceHorizontal)) { 5529 if (pos.x > container.canvas.size.width - this.size.value * 2) { 5530 pos.x -= this.size.value; 5531 } else if (pos.x < this.size.value * 2) { 5532 pos.x += this.size.value; 5533 } 5534 } 5535 5536 if (Utils.isInArray(outMode, OutMode.bounce) || Utils.isInArray(outMode, OutMode.bounceVertical)) { 5537 if (pos.y > container.canvas.size.height - this.size.value * 2) { 5538 pos.y -= this.size.value; 5539 } else if (pos.y < this.size.value * 2) { 5540 pos.y += this.size.value; 5541 } 5542 } 5543 5544 return pos; 5545 } 5546 5547 calculateVelocity() { 5548 const baseVelocity = NumberUtils.getParticleBaseVelocity(this); 5549 const res = { 5550 horizontal: 0, 5551 vertical: 0 5552 }; 5553 const moveOptions = this.particlesOptions.move; 5554 let rad; 5555 let radOffset = Math.PI / 4; 5556 5557 if (typeof moveOptions.angle === "number") { 5558 rad = Math.PI / 180 * moveOptions.angle; 5559 } else { 5560 rad = Math.PI / 180 * moveOptions.angle.value; 5561 radOffset = Math.PI / 180 * moveOptions.angle.offset; 5562 } 5563 5564 const range = { 5565 left: Math.sin(radOffset + rad / 2) - Math.sin(radOffset - rad / 2), 5566 right: Math.cos(radOffset + rad / 2) - Math.cos(radOffset - rad / 2) 5567 }; 5568 5569 if (moveOptions.straight) { 5570 res.horizontal = baseVelocity.x; 5571 res.vertical = baseVelocity.y; 5572 5573 if (moveOptions.random) { 5574 res.horizontal += NumberUtils.randomInRange(range.left, range.right) / 2; 5575 res.vertical += NumberUtils.randomInRange(range.left, range.right) / 2; 5576 } 5577 } else { 5578 res.horizontal = baseVelocity.x + NumberUtils.randomInRange(range.left, range.right) / 2; 5579 res.vertical = baseVelocity.y + NumberUtils.randomInRange(range.left, range.right) / 2; 5580 } 5581 5582 return res; 5583 } 5584 5585 loadImageShape(container, drawer) { 5586 var _a, _b, _c, _d, _e; 5587 5588 if (!(this.shape === ShapeType.image || this.shape === ShapeType.images)) { 5589 return; 5590 } 5591 5592 const imageDrawer = drawer; 5593 const images = imageDrawer.getImages(container).images; 5594 const imageData = this.shapeData; 5595 const image = (_a = images.find(t => t.source === imageData.src)) !== null && _a !== void 0 ? _a : images[0]; 5596 const color = this.getFillColor(); 5597 let imageRes; 5598 5599 if (!image) { 5600 return; 5601 } 5602 5603 if (image.svgData !== undefined && imageData.replaceColor && color) { 5604 const svgColoredData = ColorUtils.replaceColorSvg(image, color, this.opacity.value); 5605 const svg = new Blob([svgColoredData], { 5606 type: "image/svg+xml" 5607 }); 5608 const domUrl = URL || window.URL || window.webkitURL || window; 5609 const url = domUrl.createObjectURL(svg); 5610 const img = new Image(); 5611 imageRes = { 5612 data: image, 5613 loaded: false, 5614 ratio: imageData.width / imageData.height, 5615 replaceColor: (_b = imageData.replaceColor) !== null && _b !== void 0 ? _b : imageData.replace_color, 5616 source: imageData.src 5617 }; 5618 img.addEventListener("load", () => { 5619 if (this.image) { 5620 this.image.loaded = true; 5621 image.element = img; 5622 } 5623 5624 domUrl.revokeObjectURL(url); 5625 }); 5626 img.addEventListener("error", () => { 5627 domUrl.revokeObjectURL(url); 5628 Utils.loadImage(imageData.src).then(img2 => { 5629 if (this.image) { 5630 image.element = img2.element; 5631 this.image.loaded = true; 5632 } 5633 }); 5634 }); 5635 img.src = url; 5636 } else { 5637 imageRes = { 5638 data: image, 5639 loaded: true, 5640 ratio: imageData.width / imageData.height, 5641 replaceColor: (_c = imageData.replaceColor) !== null && _c !== void 0 ? _c : imageData.replace_color, 5642 source: imageData.src 5643 }; 5644 } 5645 5646 if (!imageRes.ratio) { 5647 imageRes.ratio = 1; 5648 } 5649 5650 const fill = (_d = imageData.fill) !== null && _d !== void 0 ? _d : this.fill; 5651 const close = (_e = imageData.close) !== null && _e !== void 0 ? _e : this.close; 5652 return { 5653 image: imageRes, 5654 fill, 5655 close 5656 }; 5657 } 5658 5659 } 5660 // CONCATENATED MODULE: ./dist/browser/Interactions/External/Grabber.js 5661 5662 5663 class Grabber { 5664 constructor(container) { 5665 this.container = container; 5666 } 5667 5668 isEnabled() { 5669 const container = this.container; 5670 const mouse = container.interactivity.mouse;
5671 const events = container.options.interactivity.events; 5672 5673 if (!(events.onHover.enable && mouse.position)) { 5674 return false; 5675 } 5676 5677 const hoverMode = events.onHover.mode; 5678 return Utils.isInArray(HoverMode.grab, hoverMode); 5679 } 5680 5681 reset() {} 5682 5683 interact() { 5684 var _a; 5685 5686 const container = this.container; 5687 const options = container.options; 5688 const interactivity = options.interactivity; 5689 5690 if (interactivity.events.onHover.enable && container.interactivity.status === Constants.mouseMoveEvent) { 5691 const mousePos = container.interactivity.mouse.position; 5692 5693 if (mousePos === undefined) { 5694 return; 5695 } 5696 5697 const distance = container.retina.grabModeDistance; 5698 const query = container.particles.quadTree.queryCircle(mousePos, distance); 5699 5700 for (const particle of query) { 5701 const pos = particle.getPosition(); 5702 const pointDistance = NumberUtils.getDistance(pos, mousePos); 5703 5704 if (pointDistance <= distance) { 5705 const grabLineOptions = interactivity.modes.grab.links; 5706 const lineOpacity = grabLineOptions.opacity; 5707 const opacityLine = lineOpacity - pointDistance * lineOpacity / distance; 5708 5709 if (opacityLine > 0) { 5710 const optColor = (_a = grabLineOptions.color) !== null && _a !== void 0 ? _a : particle.particlesOptions.links.color; 5711 5712 if (!container.particles.grabLineColor) { 5713 const linksOptions = container.options.interactivity.modes.grab.links; 5714 container.particles.grabLineColor = ColorUtils.getLinkRandomColor(optColor, linksOptions.blink, linksOptions.consent); 5715 } 5716 5717 const colorLine = ColorUtils.getLinkColor(particle, undefined, container.particles.grabLineColor); 5718 5719 if (colorLine === undefined) { 5720 return; 5721 } 5722 5723 container.canvas.drawGrabLine(particle, colorLine, opacityLine, mousePos); 5724 } 5725 } 5726 } 5727 } 5728 } 5729 5730 } 5731 // CONCATENATED MODULE: ./dist/browser/Interactions/External/Repulser.js 5732 5733 5734 class Repulser { 5735 constructor(container) { 5736 this.container = container; 5737 } 5738 5739 isEnabled() { 5740 const container = this.container; 5741 const options = container.options; 5742 const mouse = container.interactivity.mouse; 5743 const events = options.interactivity.events; 5744 const divs = events.onDiv; 5745 const divRepulse = Utils.isDivModeEnabled(DivMode.repulse, divs); 5746 5747 if (!(divRepulse || events.onHover.enable && mouse.position || events.onClick.enable && mouse.clickPosition)) { 5748 return false; 5749 } 5750 5751 const hoverMode = events.onHover.mode; 5752 const clickMode = events.onClick.mode; 5753 return Utils.isInArray(HoverMode.repulse, hoverMode) || Utils.isInArray(ClickMode.repulse, clickMode) || divRepulse; 5754 } 5755 5756 reset() {} 5757 5758 interact() { 5759 const container = this.container; 5760 const options = container.options; 5761 const mouseMoveStatus = container.interactivity.status === Constants.mouseMoveEvent; 5762 const events = options.interactivity.events; 5763 const hoverEnabled = events.onHover.enable; 5764 const hoverMode = events.onHover.mode; 5765 const clickEnabled = events.onClick.enable; 5766 const clickMode = events.onClick.mode; 5767 const divs = events.onDiv; 5768 5769 if (mouseMoveStatus && hoverEnabled && Utils.isInArray(HoverMode.repulse, hoverMode)) { 5770 this.hoverRepulse(); 5771 } else if (clickEnabled && Utils.isInArray(ClickMode.repulse, clickMode)) { 5772 this.clickRepulse(); 5773 } else { 5774 Utils.divModeExecute(DivMode.repulse, divs, (selector, div) => this.singleSelectorRepulse(selector, div)); 5775 } 5776 } 5777 5778 singleSelectorRepulse(selector, div) { 5779 const container = this.container; 5780 const query = document.querySelectorAll(selector); 5781 5782 if (!query.length) { 5783 return; 5784 } 5785
5786 query.forEach(item => { 5787 const elem = item; 5788 const pxRatio = container.retina.pixelRatio; 5789 const pos = { 5790 x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio, 5791 y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio 5792 }; 5793 const repulseRadius = elem.offsetWidth / 2 * pxRatio; 5794 const area = div.type === DivType.circle ? new Circle(pos.x, pos.y, repulseRadius) : new Rectangle(elem.offsetLeft * pxRatio, elem.offsetTop * pxRatio, elem.offsetWidth * pxRatio, elem.offsetHeight * pxRatio); 5795 const divs = container.options.interactivity.modes.repulse.divs; 5796 const divRepulse = Utils.divMode(divs, elem); 5797 this.processRepulse(pos, repulseRadius, area, divRepulse); 5798 }); 5799 } 5800 5801 hoverRepulse() { 5802 const container = this.container; 5803 const mousePos = container.interactivity.mouse.position; 5804 5805 if (!mousePos) { 5806 return; 5807 } 5808 5809 const repulseRadius = container.retina.repulseModeDistance; 5810 this.processRepulse(mousePos, repulseRadius, new Circle(mousePos.x, mousePos.y, repulseRadius)); 5811 } 5812 5813 processRepulse(position, repulseRadius, area, divRepulse) { 5814 var _a; 5815 5816 const container = this.container; 5817 const query = container.particles.quadTree.query(area); 5818
5819 for (const particle of query) { 5820 const { 5821 dx, 5822 dy, 5823 distance 5824 } = NumberUtils.getDistances(particle.position, position); 5825 const normVec = { 5826 x: dx / distance, 5827 y: dy / distance 5828 }; 5829 const velocity = ((_a = divRepulse === null || divRepulse === void 0 ? void 0 : divRepulse.speed) !== null && _a !== void 0 ? _a : container.options.interactivity.modes.repulse.speed) * 100; 5830 const repulseFactor = NumberUtils.clamp((1 - Math.pow(distance / repulseRadius, 2)) * velocity, 0, 50); 5831 particle.position.x = particle.position.x + normVec.x * repulseFactor; 5832 particle.position.y = particle.position.y + normVec.y * repulseFactor; 5833 } 5834 } 5835 5836 clickRepulse() { 5837 const container = this.container; 5838 5839 if (!container.repulse.finish) { 5840 if (!container.repulse.count) { 5841 container.repulse.count = 0; 5842 } 5843 5844 container.repulse.count++; 5845 5846 if (container.repulse.count === container.particles.count) { 5847 container.repulse.finish = true; 5848 } 5849 } 5850 5851 if (container.repulse.clicking) { 5852 const repulseDistance = container.retina.repulseModeDistance; 5853 const repulseRadius = Math.pow(repulseDistance / 6, 3); 5854 const mouseClickPos = container.interactivity.mouse.clickPosition; 5855 5856 if (mouseClickPos === undefined) { 5857 return; 5858 } 5859 5860 const range = new Circle(mouseClickPos.x, mouseClickPos.y, repulseRadius); 5861 const query = container.particles.quadTree.query(range); 5862
5863 for (const particle of query) { 5864 const { 5865 dx, 5866 dy, 5867 distance 5868 } = NumberUtils.getDistances(mouseClickPos, particle.position); 5869 const d = distance * distance; 5870 const velocity = container.options.interactivity.modes.repulse.speed; 5871 const force = -repulseRadius * velocity / d; 5872 5873 if (d <= repulseRadius) { 5874 container.repulse.particles.push(particle); 5875 const angle = Math.atan2(dy, dx); 5876 particle.velocity.horizontal = force * Math.cos(angle); 5877 particle.velocity.vertical = force * Math.sin(angle); 5878 } 5879 } 5880 } else if (container.repulse.clicking === false) { 5881 for (const particle of container.repulse.particles) { 5882 particle.velocity.horizontal = particle.initialVelocity.horizontal; 5883 particle.velocity.vertical = particle.initialVelocity.vertical; 5884 } 5885 5886 container.repulse.particles = []; 5887 } 5888 } 5889 5890 } 5891 // CONCATENATED MODULE: ./dist/browser/Interactions/External/Bubbler.js 5892 5893 5894 5895 function calculateBubbleValue(particleValue, modeValue, optionsValue, ratio) { 5896 if (modeValue > optionsValue) { 5897 const size = particleValue + (modeValue - optionsValue) * ratio; 5898 return NumberUtils.clamp(size, particleValue, modeValue); 5899 } else if (modeValue < optionsValue) { 5900 const size = particleValue - (optionsValue - modeValue) * ratio; 5901 return NumberUtils.clamp(size, modeValue, particleValue); 5902 } 5903 } 5904 5905 class Bubbler { 5906 constructor(container) { 5907 this.container = container; 5908 } 5909 5910 isEnabled() { 5911 const container = this.container; 5912 const options = container.options; 5913 const mouse = container.interactivity.mouse; 5914 const events = options.interactivity.events; 5915 const divs = events.onDiv; 5916 const divBubble = Utils.isDivModeEnabled(DivMode.bubble, divs); 5917 5918 if (!(divBubble || events.onHover.enable && mouse.position || events.onClick.enable && mouse.clickPosition)) { 5919 return false; 5920 } 5921 5922 const hoverMode = events.onHover.mode; 5923 const clickMode = events.onClick.mode; 5924 return Utils.isInArray(HoverMode.bubble, hoverMode) || Utils.isInArray(ClickMode.bubble, clickMode) || divBubble; 5925 } 5926 5927 reset(particle, force) { 5928 if (!particle.bubble.inRange || force) { 5929 delete particle.bubble.div; 5930 delete particle.bubble.opacity; 5931 delete particle.bubble.radius; 5932 delete particle.bubble.color; 5933 } 5934 } 5935 5936 interact() { 5937 const options = this.container.options; 5938 const events = options.interactivity.events; 5939 const onHover = events.onHover; 5940 const onClick = events.onClick; 5941 const hoverEnabled = onHover.enable; 5942 const hoverMode = onHover.mode; 5943 const clickEnabled = onClick.enable; 5944 const clickMode = onClick.mode; 5945 const divs = events.onDiv; 5946 5947 if (hoverEnabled && Utils.isInArray(HoverMode.bubble, hoverMode)) { 5948 this.hoverBubble(); 5949 } else if (clickEnabled && Utils.isInArray(ClickMode.bubble, clickMode)) { 5950 this.clickBubble(); 5951 } else { 5952 Utils.divModeExecute(DivMode.bubble, divs, (selector, div) => this.singleSelectorHover(selector, div)); 5953 } 5954 } 5955 5956 singleSelectorHover(selector, div) { 5957 const container = this.container; 5958 const selectors = document.querySelectorAll(selector); 5959 5960 if (!selectors.length) { 5961 return; 5962 } 5963 5964 selectors.forEach(item => { 5965 const elem = item; 5966 const pxRatio = container.retina.pixelRatio; 5967 const pos = { 5968 x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio, 5969 y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio 5970 }; 5971 const repulseRadius = elem.offsetWidth / 2 * pxRatio; 5972 const area = div.type === DivType.circle ? new Circle(pos.x, pos.y, repulseRadius) : new Rectangle(elem.offsetLeft * pxRatio, elem.offsetTop * pxRatio, elem.offsetWidth * pxRatio, elem.offsetHeight * pxRatio); 5973 const query = container.particles.quadTree.query(area); 5974
5975 for (const particle of query) { 5976 if (!area.contains(particle.getPosition())) { 5977 continue; 5978 } 5979 5980 particle.bubble.inRange = true; 5981 const divs = container.options.interactivity.modes.bubble.divs; 5982 const divBubble = Utils.divMode(divs, elem); 5983 5984 if (!particle.bubble.div || particle.bubble.div !== elem) { 5985 this.reset(particle, true); 5986 particle.bubble.div = elem; 5987 } 5988 5989 this.hoverBubbleSize(particle, 1, divBubble); 5990 this.hoverBubbleOpacity(particle, 1, divBubble); 5991 this.hoverBubbleColor(particle, divBubble); 5992 } 5993 }); 5994 } 5995 5996 process(particle, distMouse, timeSpent, data) { 5997 const container = this.container; 5998 const bubbleParam = data.bubbleObj.optValue; 5999 6000 if (bubbleParam === undefined) { 6001 return; 6002 } 6003 6004 const options = container.options; 6005 const bubbleDuration = options.interactivity.modes.bubble.duration; 6006 const bubbleDistance = container.retina.bubbleModeDistance; 6007 const particlesParam = data.particlesObj.optValue; 6008 const pObjBubble = data.bubbleObj.value; 6009 const pObj = data.particlesObj.value || 0; 6010 const type = data.type; 6011 6012 if (bubbleParam !== particlesParam) { 6013 if (!container.bubble.durationEnd) { 6014 if (distMouse <= bubbleDistance) { 6015 const obj = pObjBubble !== null && pObjBubble !== void 0 ? pObjBubble : pObj; 6016 6017 if (obj !== bubbleParam) { 6018 const value = pObj - timeSpent * (pObj - bubbleParam) / bubbleDuration; 6019 6020 if (type === ProcessBubbleType.size) { 6021 particle.bubble.radius = value; 6022 } 6023 6024 if (type === ProcessBubbleType.opacity) { 6025 particle.bubble.opacity = value; 6026 } 6027 } 6028 } else { 6029 if (type === ProcessBubbleType.size) { 6030 delete particle.bubble.radius; 6031 } 6032 6033 if (type === ProcessBubbleType.opacity) { 6034 delete particle.bubble.opacity; 6035 } 6036 } 6037 } else if (pObjBubble) { 6038 if (type === ProcessBubbleType.size) { 6039 delete particle.bubble.radius; 6040 } 6041 6042 if (type === ProcessBubbleType.opacity) { 6043 delete particle.bubble.opacity; 6044 } 6045 } 6046 } 6047 } 6048 6049 clickBubble() { 6050 var _a; 6051 6052 const container = this.container; 6053 const options = container.options; 6054 const mouseClickPos = container.interactivity.mouse.clickPosition; 6055 6056 if (mouseClickPos === undefined) { 6057 return; 6058 } 6059 6060 const distance = container.retina.bubbleModeDistance; 6061 const query = container.particles.quadTree.queryCircle(mouseClickPos, distance); 6062
6063 for (const particle of query) { 6064 if (!container.bubble.clicking) { 6065 continue; 6066 } 6067 6068 particle.bubble.inRange = !container.bubble.durationEnd; 6069 const pos = particle.getPosition(); 6070 const distMouse = NumberUtils.getDistance(pos, mouseClickPos); 6071 const timeSpent = (new Date().getTime() - (container.interactivity.mouse.clickTime || 0)) / 1000; 6072 6073 if (timeSpent > options.interactivity.modes.bubble.duration) { 6074 container.bubble.durationEnd = true; 6075 } 6076 6077 if (timeSpent > options.interactivity.modes.bubble.duration * 2) { 6078 container.bubble.clicking = false; 6079 container.bubble.durationEnd = false; 6080 } 6081 6082 const sizeData = { 6083 bubbleObj: { 6084 optValue: container.retina.bubbleModeSize, 6085 value: particle.bubble.radius 6086 }, 6087 particlesObj: { 6088 optValue: (_a = particle.sizeValue) !== null && _a !== void 0 ? _a : container.retina.sizeValue, 6089 value: particle.size.value 6090 }, 6091 type: ProcessBubbleType.size 6092 }; 6093 this.process(particle, distMouse, timeSpent, sizeData); 6094 const opacityData = { 6095 bubbleObj: { 6096 optValue: options.interactivity.modes.bubble.opacity, 6097 value: particle.bubble.opacity 6098 }, 6099 particlesObj: { 6100 optValue: particle.particlesOptions.opacity.value, 6101 value: particle.opacity.value 6102 }, 6103 type: ProcessBubbleType.opacity 6104 }; 6105 this.process(particle, distMouse, timeSpent, opacityData); 6106 6107 if (!container.bubble.durationEnd) { 6108 if (distMouse <= container.retina.bubbleModeDistance) { 6109 this.hoverBubbleColor(particle); 6110 } else { 6111 delete particle.bubble.color; 6112 } 6113 } else { 6114 delete particle.bubble.color; 6115 } 6116 } 6117 } 6118 6119 hoverBubble() { 6120 const container = this.container; 6121 const mousePos = container.interactivity.mouse.position; 6122 6123 if (mousePos === undefined) { 6124 return; 6125 } 6126 6127 const distance = container.retina.bubbleModeDistance; 6128 const query = container.particles.quadTree.queryCircle(mousePos, distance); 6129
6130 for (const particle of query) { 6131 particle.bubble.inRange = true; 6132 const pos = particle.getPosition(); 6133 const pointDistance = NumberUtils.getDistance(pos, mousePos); 6134 const ratio = 1 - pointDistance / distance; 6135 6136 if (pointDistance <= distance) { 6137 if (ratio >= 0 && container.interactivity.status === Constants.mouseMoveEvent) { 6138 this.hoverBubbleSize(particle, ratio); 6139 this.hoverBubbleOpacity(particle, ratio); 6140 this.hoverBubbleColor(particle); 6141 } 6142 } else { 6143 this.reset(particle); 6144 } 6145 6146 if (container.interactivity.status === Constants.mouseLeaveEvent) { 6147 this.reset(particle); 6148 } 6149 } 6150 } 6151 6152 hoverBubbleSize(particle, ratio, divBubble) { 6153 var _a; 6154 6155 const container = this.container; 6156 const modeSize = (divBubble === null || divBubble === void 0 ? void 0 : divBubble.size) ? divBubble.size * container.retina.pixelRatio : container.retina.bubbleModeSize; 6157 6158 if (modeSize === undefined) { 6159 return; 6160 } 6161 6162 const optSize = (_a = particle.sizeValue) !== null && _a !== void 0 ? _a : container.retina.sizeValue; 6163 const pSize = particle.size.value; 6164 const size = calculateBubbleValue(pSize, modeSize, optSize, ratio); 6165 6166 if (size !== undefined) { 6167 particle.bubble.radius = size; 6168 } 6169 } 6170 6171 hoverBubbleOpacity(particle, ratio, divBubble) { 6172 var _a; 6173 6174 const options = this.container.options; 6175 const modeOpacity = (_a = divBubble === null || divBubble === void 0 ? void 0 : divBubble.opacity) !== null && _a !== void 0 ? _a : options.interactivity.modes.bubble.opacity; 6176 6177 if (modeOpacity === undefined) { 6178 return; 6179 } 6180 6181 const optOpacity = particle.particlesOptions.opacity.value; 6182 const pOpacity = particle.opacity.value; 6183 const opacity = calculateBubbleValue(pOpacity, modeOpacity, optOpacity, ratio); 6184 6185 if (opacity !== undefined) { 6186 particle.bubble.opacity = opacity; 6187 } 6188 } 6189 6190 hoverBubbleColor(particle, divBubble) { 6191 var _a; 6192 6193 const options = this.container.options; 6194 6195 if (particle.bubble.color === undefined) { 6196 const modeColor = (_a = divBubble === null || divBubble === void 0 ? void 0 : divBubble.color) !== null && _a !== void 0 ? _a : options.interactivity.modes.bubble.color; 6197 6198 if (modeColor === undefined) { 6199 return; 6200 } 6201 6202 const bubbleColor = modeColor instanceof Array ? Utils.itemFromArray(modeColor) : modeColor; 6203 particle.bubble.color = ColorUtils.colorToHsl(bubbleColor); 6204 } 6205 } 6206 6207 } 6208 // CONCATENATED MODULE: ./dist/browser/Interactions/External/Connector.js 6209 6210 6211 class Connector { 6212 constructor(container) { 6213 this.container = container; 6214 } 6215 6216 isEnabled() { 6217 const container = this.container; 6218 const mouse = container.interactivity.mouse; 6219 const events = container.options.interactivity.events; 6220 6221 if (!(events.onHover.enable && mouse.position)) { 6222 return false; 6223 } 6224 6225 const hoverMode = events.onHover.mode; 6226 return Utils.isInArray(HoverMode.connect, hoverMode); 6227 } 6228 6229 reset() {} 6230 6231 interact() { 6232 const container = this.container; 6233 const options = container.options; 6234 6235 if (options.interactivity.events.onHover.enable && container.interactivity.status === "mousemove") { 6236 const mousePos = container.interactivity.mouse.position; 6237 6238 if (!mousePos) { 6239 return; 6240 } 6241 6242 const distance = Math.abs(container.retina.connectModeRadius); 6243 const query = container.particles.quadTree.queryCircle(mousePos, distance); 6244 let i = 0; 6245 6246 for (const p1 of query) { 6247 const pos1 = p1.getPosition(); 6248 6249 for (const p2 of query.slice(i + 1)) { 6250 const pos2 = p2.getPosition();
6251 const distMax = Math.abs(container.retina.connectModeDistance); 6252 const xDiff = Math.abs(pos1.x - pos2.x); 6253 const yDiff = Math.abs(pos1.y - pos2.y); 6254 6255 if (xDiff < distMax && yDiff < distMax) { 6256 container.canvas.drawConnectLine(p1, p2); 6257 } 6258 } 6259 6260 ++i; 6261 } 6262 } 6263 } 6264 6265 } 6266 // CONCATENATED MODULE: ./dist/browser/Interactions/Particles/Linker.js 6267 6268 class Linker { 6269 constructor(container) { 6270 this.container = container; 6271 } 6272 6273 isEnabled(particle) { 6274 return particle.particlesOptions.links.enable; 6275 } 6276 6277 reset() {} 6278 6279 interact(p1) { 6280 var _a; 6281 6282 const container = this.container; 6283 const linkOpt1 = p1.particlesOptions.links; 6284 const optOpacity = linkOpt1.opacity; 6285 const optDistance = (_a = p1.linksDistance) !== null && _a !== void 0 ? _a : container.retina.linksDistance; 6286 const canvasSize = container.canvas.size; 6287 const warp = linkOpt1.warp; 6288 const pos1 = p1.getPosition(); 6289 const range = warp ? new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize) : new Circle(pos1.x, pos1.y, optDistance); 6290 const query = container.particles.quadTree.query(range); 6291 6292 for (const p2 of query) { 6293 const linkOpt2 = p2.particlesOptions.links; 6294 6295 if (p1 === p2 || !linkOpt2.enable || linkOpt1.id !== linkOpt2.id || p2.spawning || p2.destroyed) { 6296 continue; 6297 } 6298 6299 const pos2 = p2.getPosition(); 6300 let distance = NumberUtils.getDistance(pos1, pos2); 6301 6302 if (warp) { 6303 if (distance > optDistance) { 6304 const pos2NE = { 6305 x: pos2.x - canvasSize.width, 6306 y: pos2.y 6307 }; 6308 distance = NumberUtils.getDistance(pos1, pos2NE); 6309 6310 if (distance > optDistance) { 6311 const pos2SE = { 6312 x: pos2.x - canvasSize.width, 6313 y: pos2.y - canvasSize.height 6314 }; 6315 distance = NumberUtils.getDistance(pos1, pos2SE); 6316 6317 if (distance > optDistance) { 6318 const pos2SW = { 6319 x: pos2.x, 6320 y: pos2.y - canvasSize.height 6321 }; 6322 distance = NumberUtils.getDistance(pos1, pos2SW); 6323 } 6324 } 6325 } 6326 } 6327 6328 if (distance > optDistance) { 6329 return; 6330 } 6331 6332 const opacityLine = (1 - distance / optDistance) * optOpacity; 6333 const linksOptions = p1.particlesOptions.links; 6334 let linkColor = linksOptions.id !== undefined ? container.particles.linksColors.get(linksOptions.id) : container.particles.linksColor; 6335 6336 if (!linkColor) { 6337 const optColor = linksOptions.color; 6338 linkColor = ColorUtils.getLinkRandomColor(optColor, linksOptions.blink, linksOptions.consent); 6339 6340 if (linksOptions.id !== undefined) { 6341 container.particles.linksColors.set(linksOptions.id, linkColor); 6342 } else { 6343 container.particles.linksColor = linkColor; 6344 } 6345 } 6346 6347 if (p2.links.map(t => t.destination).indexOf(p1) === -1 && p1.links.map(t => t.destination).indexOf(p2) === -1) { 6348 p1.links.push({ 6349 destination: p2, 6350 opacity: opacityLine 6351 }); 6352 } 6353 } 6354 } 6355 6356 } 6357 // CONCATENATED MODULE: ./dist/browser/Interactions/Particles/Attractor.js 6358 6359 class Attractor { 6360 constructor(container) { 6361 this.container = container; 6362 } 6363 6364 interact(p1) { 6365 var _a; 6366 6367 const container = this.container; 6368 const distance = (_a = p1.linksDistance) !== null && _a !== void 0 ? _a : container.retina.linksDistance; 6369 const pos1 = p1.getPosition(); 6370 const query = container.particles.quadTree.queryCircle(pos1, distance); 6371
6372 for (const p2 of query) { 6373 if (p1 === p2 || !p2.particlesOptions.move.attract.enable || p2.destroyed || p2.spawning) { 6374 continue; 6375 } 6376 6377 const pos2 = p2.getPosition(); 6378 const { 6379 dx, 6380 dy 6381 } = NumberUtils.getDistances(pos1, pos2); 6382 const rotate = p1.particlesOptions.move.attract.rotate; 6383 const ax = dx / (rotate.x * 1000); 6384 const ay = dy / (rotate.y * 1000); 6385 p1.velocity.horizontal -= ax; 6386 p1.velocity.vertical -= ay; 6387 p2.velocity.horizontal += ax; 6388 p2.velocity.vertical += ay; 6389 } 6390 } 6391 6392 isEnabled(particle) { 6393 return particle.particlesOptions.move.attract.enable; 6394 } 6395 6396 reset() {} 6397 6398 } 6399 // CONCATENATED MODULE: ./dist/browser/Interactions/Particles/Collider.js 6400 6401 6402 6403 function bounce(p1, p2) { 6404 Utils.circleBounce(Utils.circleBounceDataFromParticle(p1), Utils.circleBounceDataFromParticle(p2)); 6405 } 6406 6407 function destroy(p1, p2) { 6408 if (p1.getRadius() === undefined && p2.getRadius() !== undefined) { 6409 p1.destroy(); 6410 } else if (p1.getRadius() !== undefined && p2.getRadius() === undefined) { 6411 p2.destroy(); 6412 } else if (p1.getRadius() !== undefined && p2.getRadius() !== undefined) { 6413 if (p1.getRadius() >= p2.getRadius()) { 6414 p2.destroy(); 6415 } else { 6416 p1.destroy(); 6417 } 6418 } 6419 } 6420 6421 class Collider { 6422 constructor(container) { 6423 this.container = container; 6424 } 6425 6426 isEnabled(particle) { 6427 return particle.particlesOptions.collisions.enable; 6428 } 6429 6430 reset() {} 6431 6432 interact(p1) { 6433 const container = this.container; 6434 const pos1 = p1.getPosition(); 6435 const query = container.particles.quadTree.queryCircle(pos1, p1.getRadius() * 2); 6436 6437 for (const p2 of query) { 6438 if (p1 === p2 || !p2.particlesOptions.collisions.enable || p1.particlesOptions.collisions.mode !== p2.particlesOptions.collisions.mode || p2.destroyed || p2.spawning) { 6439 continue; 6440 } 6441 6442 const pos2 = p2.getPosition(); 6443 const dist = NumberUtils.getDistance(pos1, pos2); 6444 const radius1 = p1.getRadius(); 6445 const radius2 = p2.getRadius(); 6446 const distP = radius1 + radius2; 6447 6448 if (dist <= distP) { 6449 this.resolveCollision(p1, p2); 6450 } 6451 } 6452 } 6453 6454 resolveCollision(p1, p2) { 6455 switch (p1.particlesOptions.collisions.mode) { 6456 case CollisionMode.absorb: 6457 { 6458 this.absorb(p1, p2); 6459 break; 6460 } 6461 6462 case CollisionMode.bounce: 6463 { 6464 bounce(p1, p2); 6465 break; 6466 } 6467 6468 case CollisionMode.destroy: 6469 { 6470 destroy(p1, p2); 6471 break; 6472 } 6473 } 6474 } 6475 6476 absorb(p1, p2) { 6477 const container = this.container; 6478 const fps = container.options.fpsLimit / 1000; 6479 6480 if (p1.getRadius() === undefined && p2.getRadius() !== undefined) { 6481 p1.destroy(); 6482 } else if (p1.getRadius() !== undefined && p2.getRadius() === undefined) { 6483 p2.destroy(); 6484 } else if (p1.getRadius() !== undefined && p2.getRadius() !== undefined) { 6485 if (p1.getRadius() >= p2.getRadius()) { 6486 const factor = NumberUtils.clamp(p1.getRadius() / p2.getRadius(), 0, p2.getRadius()) * fps; 6487 p1.size.value += factor; 6488 p2.size.value -= factor; 6489 6490 if (p2.getRadius() <= container.retina.pixelRatio) { 6491 p2.size.value = 0; 6492 p2.destroy(); 6493 } 6494 } else { 6495 const factor = NumberUtils.clamp(p2.getRadius() / p1.getRadius(), 0, p1.getRadius()) * fps; 6496 p1.size.value -= factor; 6497 p2.size.value += factor; 6498 6499 if (p1.getRadius() <= container.retina.pixelRatio) { 6500 p1.size.value = 0; 6501 p1.destroy(); 6502 } 6503 } 6504 } 6505 } 6506 6507 } 6508 // CONCATENATED MODULE: ./dist/browser/Interactions/Particles/Infecter.js 6509 class Infecter_Infecter { 6510 constructor(container) { 6511 this.container = container; 6512 } 6513 6514 isEnabled() { 6515 return this.container.options.infection.enable; 6516 } 6517 6518 reset() {} 6519 6520 interact(p1, delta) { 6521 var _a, _b; 6522 6523 const infecter1 = p1.infecter; 6524 infecter1.updateInfection(delta.value); 6525 6526 if (infecter1.infectionStage === undefined) { 6527 return; 6528 } 6529 6530 const container = this.container; 6531 const options = container.options; 6532 const infectionOptions = options.infection; 6533 6534 if (!infectionOptions.enable || infectionOptions.stages.length < 1) { 6535 return; 6536 } 6537 6538 const infectionStage1 = infectionOptions.stages[infecter1.infectionStage]; 6539 const pxRatio = container.retina.pixelRatio; 6540 const radius = p1.getRadius() * 2 + infectionStage1.radius * pxRatio; 6541 const pos = p1.getPosition(); 6542 const infectedStage1 = (_a = infectionStage1.infectedStage) !== null && _a !== void 0 ? _a : infecter1.infectionStage; 6543 const query = container.particles.quadTree.queryCircle(pos, radius); 6544 const infections = infectionStage1.rate; 6545 const neighbors = query.length; 6546
6547 for (const p2 of query) { 6548 if (p2 === p1 || p2.destroyed || p2.spawning || !(p2.infecter.infectionStage === undefined || p2.infecter.infectionStage !== infecter1.infectionStage)) { 6549 continue; 6550 } 6551 6552 const infecter2 = p2.infecter; 6553 6554 if (Math.random() < infections / neighbors) { 6555 if (infecter2.infectionStage === undefined) { 6556 infecter2.startInfection(infectedStage1); 6557 } else if (infecter2.infectionStage < infecter1.infectionStage) { 6558 infecter2.updateInfectionStage(infectedStage1); 6559 } else if (infecter2.infectionStage > infecter1.infectionStage) { 6560 const infectionStage2 = infectionOptions.stages[infecter2.infectionStage]; 6561 const infectedStage2 = (_b = infectionStage2 === null || infectionStage2 === void 0 ? void 0 : infectionStage2.infectedStage) !== null && _b !== void 0 ? _b : infecter2.infectionStage; 6562 infecter1.updateInfectionStage(infectedStage2); 6563 } 6564 } 6565 } 6566 } 6567 6568 } 6569 // CONCATENATED MODULE: ./dist/browser/Interactions/External/TrailMaker.js 6570 6571 6572 class TrailMaker { 6573 constructor(container) { 6574 this.container = container; 6575 this.delay = 0; 6576 } 6577 6578 interact(delta) { 6579 if (!this.container.retina.reduceFactor) { 6580 return; 6581 } 6582 6583 const container = this.container; 6584 const options = container.options; 6585 const trailOptions = options.interactivity.modes.trail; 6586 const optDelay = trailOptions.delay * 1000 / this.container.retina.reduceFactor; 6587 6588 if (this.delay < optDelay) { 6589 this.delay += delta.value; 6590 } 6591 6592 if (this.delay >= optDelay) { 6593 container.particles.push(trailOptions.quantity, container.interactivity.mouse, trailOptions.particles); 6594 this.delay -= optDelay; 6595 } 6596 } 6597 6598 isEnabled() { 6599 const container = this.container; 6600 const options = container.options; 6601 const mouse = container.interactivity.mouse; 6602 const events = options.interactivity.events; 6603 return mouse.clicking && mouse.inside && !!mouse.position && Utils.isInArray(ClickMode.trail, events.onClick.mode) || mouse.inside && !!mouse.position && Utils.isInArray(HoverMode.trail, events.onHover.mode); 6604 } 6605 6606 reset() {} 6607 6608 } 6609 // CONCATENATED MODULE: ./dist/browser/Interactions/External/Attractor.js 6610 6611 6612 class Attractor_Attractor { 6613 constructor(container) { 6614 this.container = container; 6615 } 6616 6617 isEnabled() { 6618 const container = this.container; 6619 const options = container.options; 6620 const mouse = container.interactivity.mouse; 6621 const events = options.interactivity.events; 6622 6623 if (!(events.onHover.enable && mouse.position || events.onClick.enable && mouse.clickPosition)) { 6624 return false; 6625 } 6626 6627 const hoverMode = events.onHover.mode; 6628 const clickMode = events.onClick.mode; 6629 return Utils.isInArray(HoverMode.attract, hoverMode) || Utils.isInArray(ClickMode.attract, clickMode); 6630 } 6631 6632 reset() {} 6633 6634 interact() { 6635 const container = this.container; 6636 const options = container.options; 6637 const mouseMoveStatus = container.interactivity.status === Constants.mouseMoveEvent; 6638 const events = options.interactivity.events; 6639 const hoverEnabled = events.onHover.enable; 6640 const hoverMode = events.onHover.mode; 6641 const clickEnabled = events.onClick.enable; 6642 const clickMode = events.onClick.mode; 6643 6644 if (mouseMoveStatus && hoverEnabled && Utils.isInArray(HoverMode.attract, hoverMode)) { 6645 this.hoverAttract(); 6646 } else if (clickEnabled && Utils.isInArray(ClickMode.attract, clickMode)) { 6647 this.clickAttract(); 6648 } 6649 } 6650 6651 hoverAttract() { 6652 const container = this.container; 6653 const mousePos = container.interactivity.mouse.position; 6654 6655 if (!mousePos) { 6656 return; 6657 } 6658 6659 const attractRadius = container.retina.attractModeDistance; 6660 this.processAttract(mousePos, attractRadius, new Circle(mousePos.x, mousePos.y, attractRadius)); 6661 } 6662 6663 processAttract(position, attractRadius, area) { 6664 const container = this.container; 6665 const query = container.particles.quadTree.query(area); 6666
6667 for (const particle of query) { 6668 const { 6669 dx, 6670 dy, 6671 distance 6672 } = NumberUtils.getDistances(particle.position, position); 6673 const normVec = { 6674 x: dx / distance, 6675 y: dy / distance 6676 }; 6677 const velocity = container.options.interactivity.modes.attract.speed; 6678 const attractFactor = NumberUtils.clamp((1 - Math.pow(distance / attractRadius, 2)) * velocity, 0, 50); 6679 particle.position.x = particle.position.x - normVec.x * attractFactor; 6680 particle.position.y = particle.position.y - normVec.y * attractFactor; 6681 } 6682 } 6683 6684 clickAttract() { 6685 const container = this.container; 6686 6687 if (!container.attract.finish) { 6688 if (!container.attract.count) { 6689 container.attract.count = 0; 6690 } 6691 6692 container.attract.count++; 6693 6694 if (container.attract.count === container.particles.count) { 6695 container.attract.finish = true; 6696 } 6697 } 6698 6699 if (container.attract.clicking) { 6700 const mousePos = container.interactivity.mouse.clickPosition; 6701 6702 if (!mousePos) { 6703 return; 6704 } 6705 6706 const attractRadius = container.retina.attractModeDistance; 6707 this.processAttract(mousePos, attractRadius, new Circle(mousePos.x, mousePos.y, attractRadius)); 6708 } else if (container.attract.clicking === false) { 6709 container.attract.particles = []; 6710 } 6711 6712 return; 6713 } 6714 6715 } 6716 // CONCATENATED MODULE: ./dist/browser/Interactions/Particles/Lighter.js 6717 6718 6719 class Lighter { 6720 constructor(container) { 6721 this.container = container; 6722 } 6723 6724 interact(particle) { 6725 const container = this.container; 6726 const options = container.options; 6727 6728 if (options.interactivity.events.onHover.enable && container.interactivity.status === "mousemove") { 6729 const mousePos = this.container.interactivity.mouse.position; 6730 6731 if (mousePos) { 6732 container.canvas.drawParticleShadow(particle, mousePos); 6733 } 6734 } 6735 } 6736 6737 isEnabled() { 6738 const container = this.container; 6739 const mouse = container.interactivity.mouse; 6740 const events = container.options.interactivity.events; 6741 6742 if (!(events.onHover.enable && mouse.position)) { 6743 return false; 6744 } 6745 6746 const hoverMode = events.onHover.mode; 6747 return Utils.isInArray(HoverMode.light, hoverMode); 6748 } 6749 6750 reset() {} 6751 6752 } 6753 // CONCATENATED MODULE: ./dist/browser/Interactions/External/Lighter.js 6754 6755 6756 class Lighter_Lighter { 6757 constructor(container) { 6758 this.container = container; 6759 } 6760 6761 interact() { 6762 const container = this.container; 6763 const options = container.options; 6764 6765 if (options.interactivity.events.onHover.enable && container.interactivity.status === "mousemove") { 6766 const mousePos = container.interactivity.mouse.position; 6767 6768 if (!mousePos) { 6769 return; 6770 } 6771 6772 container.canvas.drawLight(mousePos); 6773 } 6774 } 6775 6776 isEnabled() { 6777 const container = this.container; 6778 const mouse = container.interactivity.mouse; 6779 const events = container.options.interactivity.events; 6780 6781 if (!(events.onHover.enable && mouse.position)) { 6782 return false; 6783 } 6784 6785 const hoverMode = events.onHover.mode; 6786 return Utils.isInArray(HoverMode.light, hoverMode); 6787 } 6788 6789 reset() {} 6790 6791 } 6792 // CONCATENATED MODULE: ./dist/browser/Interactions/External/Bouncer.js 6793 6794 6795 6796 6797 6798 class Bouncer { 6799 constructor(container) { 6800 this.container = container; 6801 } 6802 6803 isEnabled() { 6804 const container = this.container; 6805 const options = container.options; 6806 const mouse = container.interactivity.mouse; 6807 const events = options.interactivity.events; 6808 const divs = events.onDiv; 6809 return mouse.position && events.onHover.enable && Utils.isInArray(HoverMode.bounce, events.onHover.mode) || Utils.isDivModeEnabled(DivMode.bounce, divs); 6810 } 6811 6812 interact() { 6813 const container = this.container; 6814 const options = container.options; 6815 const events = options.interactivity.events; 6816 const mouseMoveStatus = container.interactivity.status === Constants.mouseMoveEvent; 6817 const hoverEnabled = events.onHover.enable; 6818 const hoverMode = events.onHover.mode; 6819 const divs = events.onDiv; 6820 6821 if (mouseMoveStatus && hoverEnabled && Utils.isInArray(HoverMode.bounce, hoverMode)) { 6822 this.processMouseBounce(); 6823 } else { 6824 Utils.divModeExecute(DivMode.bounce, divs, (selector, div) => this.singleSelectorBounce(selector, div)); 6825 } 6826 } 6827 6828 reset() {} 6829 6830 processMouseBounce() { 6831 const container = this.container; 6832 const pxRatio = container.retina.pixelRatio; 6833 const tolerance = 10 * pxRatio; 6834 const mousePos = container.interactivity.mouse.position; 6835 const radius = container.retina.bounceModeDistance; 6836 6837 if (mousePos) { 6838 this.processBounce(mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance)); 6839 } 6840 } 6841 6842 singleSelectorBounce(selector, div) { 6843 const container = this.container; 6844 const query = document.querySelectorAll(selector); 6845 6846 if (!query.length) { 6847 return; 6848 } 6849
6850 query.forEach(item => { 6851 const elem = item; 6852 const pxRatio = container.retina.pixelRatio; 6853 const pos = { 6854 x: (elem.offsetLeft + elem.offsetWidth / 2) * pxRatio, 6855 y: (elem.offsetTop + elem.offsetHeight / 2) * pxRatio 6856 }; 6857 const radius = elem.offsetWidth / 2 * pxRatio; 6858 const tolerance = 10 * pxRatio; 6859 const area = div.type === DivType.circle ? new Circle(pos.x, pos.y, radius + tolerance) : new Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * 2, elem.offsetHeight * pxRatio + tolerance * 2); 6860 this.processBounce(pos, radius, area); 6861 }); 6862 } 6863 6864 processBounce(position, radius, area) { 6865 const query = this.container.particles.quadTree.query(area); 6866 6867 for (const particle of query) { 6868 if (area instanceof Circle) { 6869 Utils.circleBounce(Utils.circleBounceDataFromParticle(particle), { 6870 position, 6871 radius, 6872 velocity: { 6873 horizontal: 0, 6874 vertical: 0 6875 }, 6876 factor: { 6877 horizontal: 0, 6878 vertical: 0 6879 } 6880 }); 6881 } else if (area instanceof Rectangle) { 6882 Utils.rectBounce(particle, Utils.calculateBounds(position, radius)); 6883 } 6884 } 6885 } 6886 6887 } 6888 // CONCATENATED MODULE: ./dist/browser/Core/Particle/InteractionManager.js 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 class InteractionManager { 6903 constructor(container) { 6904 this.container = container; 6905 this.externalInteractors = [new Bouncer(container), new Bubbler(container), new Connector(container), new Grabber(container), new Lighter_Lighter(container), new Attractor_Attractor(container), new Repulser(container), new TrailMaker(container)]; 6906 this.particleInteractors = [new Attractor(container), new Lighter(container), new Collider(container), new Infecter_Infecter(container), new Linker(container)]; 6907 } 6908 6909 init() {} 6910 6911 externalInteract(delta) { 6912 for (const interactor of this.externalInteractors) { 6913 if (interactor.isEnabled()) { 6914 interactor.interact(delta); 6915 } 6916 } 6917 } 6918 6919 particlesInteract(particle, delta) { 6920 for (const interactor of this.externalInteractors) { 6921 interactor.reset(particle); 6922 } 6923 6924 for (const interactor of this.particleInteractors) { 6925 if (interactor.isEnabled(particle)) { 6926 interactor.interact(particle, delta); 6927 } 6928 } 6929 } 6930 6931 } 6932 // CONCATENATED MODULE: ./dist/browser/Core/Particles.js 6933 6934 6935 6936 class Particles_Particles { 6937 constructor(container) { 6938 this.container = container; 6939 this.nextId = 0; 6940 this.array = []; 6941 this.limit = 0; 6942 this.linksFreq = new Map(); 6943 this.trianglesFreq = new Map(); 6944 this.interactionManager = new InteractionManager(container); 6945 const canvasSize = this.container.canvas.size; 6946 this.linksColors = new Map(); 6947 this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4); 6948 } 6949 6950 get count() { 6951 return this.array.length; 6952 } 6953 6954 init() { 6955 const container = this.container; 6956 const options = container.options; 6957 this.linksFreq = new Map(); 6958 this.trianglesFreq = new Map(); 6959 let handled = false; 6960 6961 for (const particle of options.manualParticles) { 6962 const pos = particle.position ? { 6963 x: particle.position.x * container.canvas.size.width / 100, 6964 y: particle.position.y * container.canvas.size.height / 100 6965 } : undefined; 6966 this.addParticle(pos, particle.options); 6967 } 6968 6969 for (const [, plugin] of container.plugins) { 6970 if (plugin.particlesInitialization !== undefined) { 6971 handled = plugin.particlesInitialization(); 6972 } 6973 6974 if (handled) { 6975 break; 6976 } 6977 } 6978 6979 if (!handled) { 6980 for (let i = this.count; i < options.particles.number.value; i++) {
6981 this.addParticle(); 6982 } 6983 } 6984 6985 if (options.infection.enable) { 6986 for (let i = 0; i < options.infection.infections; i++) { 6987 const notInfected = this.array.filter(p => p.infecter.infectionStage === undefined); 6988 const infected = Utils.itemFromArray(notInfected); 6989 infected.infecter.startInfection(0); 6990 } 6991 } 6992 6993 this.interactionManager.init(); 6994 container.noise.init(); 6995 } 6996 6997 redraw() { 6998 this.clear(); 6999 this.init(); 7000 this.draw({ 7001 value: 0, 7002 factor: 0 7003 }); 7004 } 7005 7006 removeAt(index, quantity) { 7007 if (index >= 0 && index <= this.count) { 7008 for (const particle of this.array.splice(index, quantity !== null && quantity !== void 0 ? quantity : 1)) { 7009 particle.destroy(); 7010 } 7011 } 7012 } 7013 7014 remove(particle) { 7015 this.removeAt(this.array.indexOf(particle)); 7016 } 7017 7018 update(delta) { 7019 const container = this.container; 7020 const particlesToDelete = []; 7021 container.noise.update(); 7022 7023 for (const particle of this.array) { 7024 particle.move(delta); 7025 7026 if (particle.destroyed) { 7027 particlesToDelete.push(particle); 7028 continue; 7029 } 7030 7031 this.quadTree.insert(new Point(particle.getPosition(), particle)); 7032 } 7033 7034 for (const particle of particlesToDelete) { 7035 this.remove(particle); 7036 } 7037 7038 this.interactionManager.externalInteract(delta); 7039 7040 for (const particle of this.container.particles.array) { 7041 particle.update(delta); 7042 7043 if (!particle.destroyed && !particle.spawning) { 7044 this.interactionManager.particlesInteract(particle, delta); 7045 } 7046 } 7047 } 7048 7049 draw(delta) { 7050 const container = this.container; 7051 container.canvas.clear(); 7052 const canvasSize = this.container.canvas.size; 7053 this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4); 7054 this.update(delta); 7055 7056 for (const [, plugin] of container.plugins) { 7057 container.canvas.drawPlugin(plugin, delta); 7058 } 7059 7060 for (const p of this.array) { 7061 p.draw(delta); 7062 } 7063 } 7064 7065 clear() { 7066 this.array = []; 7067 } 7068 7069 push(nb, mouse, overrideOptions) { 7070 const container = this.container; 7071 const options = container.options; 7072 const limit = options.particles.number.limit * container.density; 7073 this.pushing = true; 7074 7075 if (limit > 0) { 7076 const countToRemove = this.count + nb - limit; 7077 7078 if (countToRemove > 0) { 7079 this.removeQuantity(countToRemove); 7080 } 7081 } 7082 7083 for (let i = 0; i < nb; i++) { 7084 this.addParticle(mouse === null || mouse === void 0 ? void 0 : mouse.position, overrideOptions); 7085 } 7086 7087 this.pushing = false; 7088 } 7089 7090 addParticle(position, overrideOptions) { 7091 try { 7092 const particle = new Particle(this.nextId, this.container, position, overrideOptions); 7093 this.array.push(particle); 7094 this.nextId++; 7095 return particle; 7096 } catch (_a) { 7097 console.warn("error adding particle"); 7098 return; 7099 } 7100 } 7101 7102 removeQuantity(quantity) { 7103 this.removeAt(0, quantity); 7104 } 7105 7106 getLinkFrequency(p1, p2) { 7107 const key = `${Math.min(p1.id, p2.id)}_${Math.max(p1.id, p2.id)}`; 7108 let res = this.linksFreq.get(key); 7109 7110 if (res === undefined) { 7111 res = Math.random(); 7112 this.linksFreq.set(key, res); 7113 } 7114 7115 return res; 7116 } 7117 7118 getTriangleFrequency(p1, p2, p3) { 7119 let [id1, id2, id3] = [p1.id, p2.id, p3.id]; 7120 7121 if (id1 > id2) { 7122 [id2, id1] = [id1, id2]; 7123 } 7124 7125 if (id2 > id3) { 7126 [id3, id2] = [id2, id3]; 7127 } 7128 7129 if (id1 > id3) {
7130 [id3, id1] = [id1, id3]; 7131 } 7132 7133 const key = `${id1}_${id2}_${id3}`; 7134 let res = this.trianglesFreq.get(key); 7135 7136 if (res === undefined) { 7137 res = Math.random(); 7138 this.trianglesFreq.set(key, res); 7139 } 7140 7141 return res; 7142 } 7143 7144 setDensity() { 7145 const options = this.container.options; 7146 this.applyDensity(options.particles); 7147 } 7148 7149 applyDensity(options) { 7150 var _a; 7151 7152 if (!((_a = options.number.density) === null || _a === void 0 ? void 0 : _a.enable)) { 7153 return; 7154 } 7155 7156 const numberOptions = options.number; 7157 const densityFactor = this.initDensityFactor(numberOptions.density); 7158 const optParticlesNumber = numberOptions.value; 7159 const optParticlesLimit = numberOptions.limit > 0 ? numberOptions.limit : optParticlesNumber; 7160 const particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor; 7161 const particlesCount = this.count; 7162 this.limit = numberOptions.limit * densityFactor; 7163 7164 if (particlesCount < particlesNumber) { 7165 this.push(Math.abs(particlesNumber - particlesCount), undefined, options); 7166 } else if (particlesCount > particlesNumber) { 7167 this.removeQuantity(particlesCount - particlesNumber); 7168 } 7169 } 7170 7171 initDensityFactor(densityOptions) { 7172 const container = this.container; 7173 7174 if (!container.canvas.element || !densityOptions.enable) { 7175 return 1; 7176 } 7177 7178 const canvas = container.canvas.element; 7179 const pxRatio = container.retina.pixelRatio; 7180 return canvas.width * canvas.height / (densityOptions.factor * pxRatio * pxRatio * densityOptions.area); 7181 } 7182 7183 } 7184 // CONCATENATED MODULE: ./dist/browser/Core/Retina.js 7185 7186 class Retina { 7187 constructor(container) { 7188 this.container = container; 7189 } 7190 7191 init() { 7192 const container = this.container; 7193 const options = container.options; 7194 7195 if (options.detectRetina) { 7196 this.pixelRatio = Utils.isSsr() ? 1 : window.devicePixelRatio; 7197 } else { 7198 this.pixelRatio = 1; 7199 } 7200 7201 const motionOptions = this.container.options.motion; 7202 7203 if (motionOptions && (motionOptions.disable || motionOptions.reduce.value)) { 7204 if (Utils.isSsr() || typeof matchMedia === "undefined" || !matchMedia) { 7205 this.reduceFactor = 1; 7206 } else { 7207 const mediaQuery = matchMedia("(prefers-reduced-motion: reduce)"); 7208 7209 if (mediaQuery) { 7210 this.handleMotionChange(mediaQuery); 7211 7212 const handleChange = () => { 7213 this.handleMotionChange(mediaQuery); 7214 container.refresh().catch(() => {}); 7215 }; 7216 7217 if (mediaQuery.addEventListener !== undefined) { 7218 mediaQuery.addEventListener("change", handleChange); 7219 } else if (mediaQuery.addListener !== undefined) { 7220 mediaQuery.addListener(handleChange); 7221 } 7222 } 7223 } 7224 } else { 7225 this.reduceFactor = 1; 7226 } 7227 7228 const ratio = this.pixelRatio; 7229 7230 if (container.canvas.element) { 7231 const element = container.canvas.element; 7232 container.canvas.size.width = element.offsetWidth * ratio; 7233 container.canvas.size.height = element.offsetHeight * ratio; 7234 } 7235 7236 const particles = options.particles; 7237 this.linksDistance = particles.links.distance * ratio; 7238 this.linksWidth = particles.links.width * ratio; 7239 this.moveSpeed = particles.move.speed * ratio; 7240 this.sizeValue = particles.size.value * ratio; 7241 this.sizeAnimationSpeed = particles.size.animation.speed * ratio; 7242 const modes = options.interactivity.modes; 7243 this.connectModeDistance = modes.connect.distance * ratio; 7244 this.connectModeRadius = modes.connect.radius * ratio; 7245 this.grabModeDistance = modes.grab.distance * ratio; 7246 this.repulseModeDistance = modes.repulse.distance * ratio; 7247 this.bounceModeDistance = modes.bounce.distance * ratio; 7248 this.attractModeDistance = modes.attract.distance * ratio; 7249 this.slowModeRadius = modes.slow.radius * ratio; 7250 this.bubbleModeDistance = modes.bubble.distance * ratio; 7251 7252 if (modes.bubble.size) { 7253 this.bubbleModeSize = modes.bubble.size * ratio; 7254 } 7255 } 7256 7257 initParticle(particle) { 7258 const particlesOptions = particle.particlesOptions; 7259 const ratio = this.pixelRatio; 7260 particle.linksDistance = particlesOptions.links.distance * ratio; 7261 particle.linksWidth = particlesOptions.links.width * ratio; 7262 particle.moveSpeed = particlesOptions.move.speed * ratio; 7263 particle.sizeValue = particlesOptions.size.value * ratio; 7264 particle.sizeAnimationSpeed = particlesOptions.size.animation.speed * ratio; 7265 particle.maxDistance = particlesOptions.move.distance * ratio; 7266 } 7267 7268 handleMotionChange(mediaQuery) { 7269 const options = this.container.options; 7270 7271 if (mediaQuery.matches) { 7272 const motion = options.motion; 7273 this.reduceFactor = motion.disable ? 0 : motion.reduce.value ? 1 / motion.reduce.factor : 1; 7274 } else { 7275 this.reduceFactor = 1; 7276 } 7277 } 7278 7279 } 7280 // CONCATENATED MODULE: ./dist/browser/Core/FrameManager.js 7281 class FrameManager { 7282 constructor(container) { 7283 this.container = container; 7284 } 7285 7286 nextFrame(timestamp) { 7287 try { 7288 const container = this.container; 7289 7290 if (container.lastFrameTime !== undefined && timestamp < container.lastFrameTime + 1000 / container.fpsLimit) { 7291 container.draw(); 7292 return; 7293 } 7294 7295 const deltaValue = timestamp - container.lastFrameTime; 7296 const delta = { 7297 value: deltaValue, 7298 factor: 60 * deltaValue / 1000 7299 }; 7300 container.lastFrameTime = timestamp; 7301 container.particles.draw(delta); 7302 7303 if (container.getAnimationStatus()) { 7304 container.draw(); 7305 } 7306 } catch (e) { 7307 console.error("tsParticles error in animation loop", e); 7308 } 7309 } 7310 7311 } 7312 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/ClickEvent.js 7313 class ClickEvent { 7314 constructor() { 7315 this.enable = false;
7316 this.mode = []; 7317 } 7318 7319 load(data) { 7320 if (data === undefined) { 7321 return; 7322 } 7323 7324 if (data.enable !== undefined) { 7325 this.enable = data.enable; 7326 } 7327 7328 if (data.mode !== undefined) { 7329 this.mode = data.mode; 7330 } 7331 } 7332 7333 } 7334 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/DivEvent.js 7335 7336 class DivEvent { 7337 constructor() { 7338 this.selectors = []; 7339 this.enable = false; 7340 this.mode = []; 7341 this.type = DivType.circle; 7342 } 7343 7344 get elementId() { 7345 return this.ids; 7346 } 7347 7348 set elementId(value) { 7349 this.ids = value; 7350 } 7351 7352 get el() { 7353 return this.elementId; 7354 } 7355 7356 set el(value) { 7357 this.elementId = value; 7358 } 7359 7360 get ids() { 7361 if (this.selectors instanceof Array) { 7362 return this.selectors.map(t => t.replace("#", "")); 7363 } else { 7364 return this.selectors.replace("#", ""); 7365 } 7366 } 7367 7368 set ids(value) { 7369 if (value instanceof Array) { 7370 this.selectors = value.map(t => `#${t}`); 7371 } else { 7372 this.selectors = `#${value}`; 7373 } 7374 } 7375 7376 load(data) { 7377 var _a, _b; 7378 7379 if (data === undefined) { 7380 return; 7381 } 7382 7383 const ids = (_b = (_a = data.ids) !== null && _a !== void 0 ? _a : data.elementId) !== null && _b !== void 0 ? _b : data.el; 7384 7385 if (ids !== undefined) { 7386 this.ids = ids; 7387 } 7388 7389 if (data.selectors !== undefined) { 7390 this.selectors = data.selectors; 7391 } 7392 7393 if (data.enable !== undefined) { 7394 this.enable = data.enable; 7395 } 7396 7397 if (data.mode !== undefined) { 7398 this.mode = data.mode; 7399 } 7400 7401 if (data.type !== undefined) { 7402 this.type = data.type; 7403 } 7404 } 7405 7406 } 7407 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/Parallax.js 7408 class Parallax { 7409 constructor() { 7410 this.enable = false; 7411 this.force = 2; 7412 this.smooth = 10; 7413 } 7414 7415 load(data) { 7416 if (data === undefined) { 7417 return; 7418 } 7419 7420 if (data.enable !== undefined) { 7421 this.enable = data.enable; 7422 } 7423 7424 if (data.force !== undefined) { 7425 this.force = data.force; 7426 } 7427 7428 if (data.smooth !== undefined) { 7429 this.smooth = data.smooth; 7430 } 7431 } 7432 7433 } 7434 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/HoverEvent.js 7435 7436 class HoverEvent { 7437 constructor() { 7438 this.enable = false; 7439 this.mode = []; 7440 this.parallax = new Parallax(); 7441 } 7442 7443 load(data) { 7444 if (data === undefined) { 7445 return; 7446 } 7447 7448 if (data.enable !== undefined) { 7449 this.enable = data.enable; 7450 } 7451 7452 if (data.mode !== undefined) { 7453 this.mode = data.mode; 7454 } 7455 7456 this.parallax.load(data.parallax); 7457 } 7458 7459 } 7460 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Events/Events.js 7461 7462 7463 7464 class Events { 7465 constructor() { 7466 this.onClick = new ClickEvent(); 7467 this.onDiv = new DivEvent(); 7468 this.onHover = new HoverEvent(); 7469 this.resize = true; 7470 } 7471 7472 get onclick() { 7473 return this.onClick; 7474 } 7475 7476 set onclick(value) { 7477 this.onClick = value; 7478 } 7479 7480 get ondiv() { 7481 return this.onDiv; 7482 } 7483 7484 set ondiv(value) { 7485 this.onDiv = value; 7486 } 7487 7488 get onhover() { 7489 return this.onHover; 7490 } 7491 7492 set onhover(value) { 7493 this.onHover = value; 7494 } 7495 7496 load(data) { 7497 var _a, _b, _c; 7498 7499 if (data === undefined) { 7500 return; 7501 } 7502 7503 this.onClick.load((_a = data.onClick) !== null && _a !== void 0 ? _a : data.onclick); 7504 const onDiv = (_b = data.onDiv) !== null && _b !== void 0 ? _b : data.ondiv; 7505 7506 if (onDiv !== undefined) { 7507 if (onDiv instanceof Array) { 7508 this.onDiv = onDiv.map(div => { 7509 const tmp = new DivEvent(); 7510 tmp.load(div); 7511 return tmp; 7512 }); 7513 } else { 7514 this.onDiv = new DivEvent(); 7515 this.onDiv.load(onDiv); 7516 } 7517 } 7518
7519 this.onHover.load((_c = data.onHover) !== null && _c !== void 0 ? _c : data.onhover); 7520 7521 if (data.resize !== undefined) { 7522 this.resize = data.resize; 7523 } 7524 } 7525 7526 } 7527 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/BubbleBase.js 7528 7529 class BubbleBase { 7530 constructor() { 7531 this.distance = 200; 7532 this.duration = 0.4; 7533 } 7534 7535 load(data) { 7536 if (data === undefined) { 7537 return; 7538 } 7539 7540 if (data.distance !== undefined) { 7541 this.distance = data.distance; 7542 } 7543 7544 if (data.duration !== undefined) { 7545 this.duration = data.duration; 7546 } 7547 7548 if (data.opacity !== undefined) { 7549 this.opacity = data.opacity; 7550 } 7551 7552 if (data.color !== undefined) { 7553 if (data.color instanceof Array) { 7554 this.color = data.color.map(s => OptionsColor.create(undefined, s)); 7555 } else { 7556 if (this.color instanceof Array) { 7557 this.color = new OptionsColor(); 7558 } 7559 7560 this.color = OptionsColor.create(this.color, data.color); 7561 } 7562 } 7563 7564 if (data.size !== undefined) { 7565 this.size = data.size; 7566 } 7567 } 7568 7569 } 7570 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/BubbleDiv.js 7571 7572 class BubbleDiv extends BubbleBase { 7573 constructor() { 7574 super(); 7575 this.selectors = []; 7576 } 7577 7578 get ids() { 7579 if (this.selectors instanceof Array) { 7580 return this.selectors.map(t => t.replace("#", "")); 7581 } else { 7582 return this.selectors.replace("#", ""); 7583 } 7584 } 7585 7586 set ids(value) { 7587 if (value instanceof Array) { 7588 this.selectors = value.map(t => `#${t}`); 7589 } else { 7590 this.selectors = `#${value}`; 7591 } 7592 } 7593 7594 load(data) { 7595 super.load(data); 7596 7597 if (data === undefined) { 7598 return; 7599 } 7600 7601 if (data.ids !== undefined) { 7602 this.ids = data.ids; 7603 } 7604 7605 if (data.selectors !== undefined) { 7606 this.selectors = data.selectors; 7607 } 7608 } 7609 7610 } 7611 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Bubble.js 7612 7613 7614 class Bubble extends BubbleBase { 7615 load(data) { 7616 super.load(data); 7617 7618 if (!(data !== undefined && data.divs !== undefined)) { 7619 return; 7620 } 7621 7622 if (data.divs instanceof Array) { 7623 this.divs = data.divs.map(s => { 7624 const tmp = new BubbleDiv(); 7625 tmp.load(s); 7626 return tmp; 7627 }); 7628 } else { 7629 if (this.divs instanceof Array || !this.divs) { 7630 this.divs = new BubbleDiv(); 7631 } 7632 7633 this.divs.load(data.divs); 7634 } 7635 } 7636 7637 } 7638 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/ConnectLinks.js 7639 class ConnectLinks { 7640 constructor() { 7641 this.opacity = 0.5; 7642 } 7643 7644 load(data) { 7645 if (!(data !== undefined && data.opacity !== undefined)) { 7646 return; 7647 } 7648 7649 this.opacity = data.opacity; 7650 } 7651 7652 } 7653 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Connect.js 7654 7655 class Connect { 7656 constructor() { 7657 this.distance = 80; 7658 this.links = new ConnectLinks(); 7659 this.radius = 60; 7660 } 7661 7662 get line_linked() { 7663 return this.links; 7664 } 7665 7666 set line_linked(value) { 7667 this.links = value; 7668 } 7669 7670 get lineLinked() { 7671 return this.links; 7672 } 7673 7674 set lineLinked(value) { 7675 this.links = value; 7676 } 7677 7678 load(data) { 7679 var _a, _b; 7680 7681 if (data === undefined) { 7682 return; 7683 } 7684 7685 if (data.distance !== undefined) { 7686 this.distance = data.distance; 7687 } 7688 7689 this.links.load((_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked); 7690 7691 if (data.radius !== undefined) { 7692 this.radius = data.radius; 7693 } 7694 } 7695 7696 } 7697 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/GrabLinks.js 7698 7699 class GrabLinks { 7700 constructor() { 7701 this.blink = false;
7702 this.consent = false; 7703 this.opacity = 1; 7704 } 7705 7706 load(data) { 7707 if (data === undefined) { 7708 return; 7709 } 7710 7711 if (data.blink !== undefined) { 7712 this.blink = data.blink; 7713 } 7714 7715 if (data.color !== undefined) { 7716 this.color = OptionsColor.create(this.color, data.color); 7717 } 7718 7719 if (data.consent !== undefined) { 7720 this.consent = data.consent; 7721 } 7722 7723 if (data.opacity !== undefined) { 7724 this.opacity = data.opacity; 7725 } 7726 } 7727 7728 } 7729 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Grab.js 7730 7731 class Grab { 7732 constructor() { 7733 this.distance = 100; 7734 this.links = new GrabLinks(); 7735 } 7736 7737 get line_linked() { 7738 return this.links; 7739 } 7740 7741 set line_linked(value) { 7742 this.links = value; 7743 } 7744 7745 get lineLinked() { 7746 return this.links; 7747 } 7748 7749 set lineLinked(value) { 7750 this.links = value; 7751 } 7752 7753 load(data) { 7754 var _a, _b; 7755 7756 if (data === undefined) { 7757 return; 7758 } 7759 7760 if (data.distance !== undefined) { 7761 this.distance = data.distance; 7762 } 7763 7764 this.links.load((_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked); 7765 } 7766 7767 } 7768 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Remove.js 7769 class Remove { 7770 constructor() { 7771 this.quantity = 2; 7772 } 7773 7774 get particles_nb() { 7775 return this.quantity; 7776 } 7777 7778 set particles_nb(value) { 7779 this.quantity = value; 7780 } 7781 7782 load(data) { 7783 var _a; 7784 7785 if (data === undefined) { 7786 return; 7787 } 7788 7789 const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb; 7790 7791 if (quantity !== undefined) { 7792 this.quantity = quantity; 7793 } 7794 } 7795 7796 } 7797 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Push.js 7798 class Push { 7799 constructor() { 7800 this.quantity = 4; 7801 } 7802 7803 get particles_nb() { 7804 return this.quantity; 7805 } 7806 7807 set particles_nb(value) { 7808 this.quantity = value; 7809 } 7810 7811 load(data) { 7812 var _a; 7813 7814 if (data === undefined) { 7815 return; 7816 } 7817 7818 const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb; 7819 7820 if (quantity !== undefined) { 7821 this.quantity = quantity; 7822 } 7823 } 7824 7825 } 7826 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/RepulseBase.js 7827 class RepulseBase { 7828 constructor() { 7829 this.distance = 200; 7830 this.duration = 0.4; 7831 this.speed = 1; 7832 } 7833 7834 load(data) { 7835 if (data === undefined) { 7836 return; 7837 } 7838 7839 if (data.distance !== undefined) { 7840 this.distance = data.distance; 7841 } 7842 7843 if (data.duration !== undefined) { 7844 this.duration = data.duration; 7845 } 7846 7847 if (data.speed !== undefined) { 7848 this.speed = data.speed; 7849 } 7850 } 7851 7852 } 7853 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/RepulseDiv.js 7854 7855 class RepulseDiv extends RepulseBase { 7856 constructor() { 7857 super(); 7858 this.selectors = []; 7859 } 7860 7861 get ids() { 7862 if (this.selectors instanceof Array) { 7863 return this.selectors.map(t => t.replace("#", "")); 7864 } else { 7865 return this.selectors.replace("#", ""); 7866 } 7867 } 7868 7869 set ids(value) { 7870 if (value instanceof Array) { 7871 this.selectors = value.map(() => `#${value}`); 7872 } else { 7873 this.selectors = `#${value}`; 7874 } 7875 } 7876 7877 load(data) { 7878 super.load(data); 7879 7880 if (data === undefined) { 7881 return; 7882 } 7883 7884 if (data.ids !== undefined) { 7885 this.ids = data.ids; 7886 } 7887 7888 if (data.selectors !== undefined) { 7889 this.selectors = data.selectors; 7890 } 7891 } 7892 7893 } 7894 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Repulse.js 7895 7896 7897 class Repulse extends RepulseBase { 7898 load(data) { 7899 super.load(data); 7900 7901 if ((data === null || data === void 0 ? void 0 : data.divs) === undefined) { 7902 return; 7903 } 7904 7905 if (data.divs instanceof Array) { 7906 this.divs = data.divs.map(s => { 7907 const tmp = new RepulseDiv(); 7908 tmp.load(s); 7909 return tmp; 7910 }); 7911 } else { 7912 if (this.divs instanceof Array || !this.divs) { 7913 this.divs = new RepulseDiv(); 7914 } 7915 7916 this.divs.load(data.divs); 7917 } 7918 } 7919 7920 } 7921 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Slow.js 7922 class Slow { 7923 constructor() { 7924 this.factor = 3; 7925 this.radius = 200; 7926 } 7927 7928 get active() { 7929 return false;
7930 } 7931 7932 set active(_value) {} 7933 7934 load(data) { 7935 if (data === undefined) { 7936 return; 7937 } 7938 7939 if (data.factor !== undefined) { 7940 this.factor = data.factor; 7941 } 7942 7943 if (data.radius !== undefined) { 7944 this.radius = data.radius; 7945 } 7946 } 7947 7948 } 7949 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Trail.js 7950 7951 class Trail_Trail { 7952 constructor() { 7953 this.delay = 1; 7954 this.quantity = 1; 7955 } 7956 7957 load(data) { 7958 if (data === undefined) { 7959 return; 7960 } 7961 7962 if (data.delay !== undefined) { 7963 this.delay = data.delay; 7964 } 7965 7966 if (data.quantity !== undefined) { 7967 this.quantity = data.quantity; 7968 } 7969 7970 if (data.particles !== undefined) { 7971 this.particles = Utils.deepExtend({}, data.particles); 7972 } 7973 } 7974 7975 } 7976 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Attract.js 7977 class Attract_Attract { 7978 constructor() { 7979 this.distance = 200; 7980 this.duration = 0.4; 7981 this.speed = 1; 7982 } 7983 7984 load(data) { 7985 if (data === undefined) { 7986 return; 7987 } 7988 7989 if (data.distance !== undefined) { 7990 this.distance = data.distance; 7991 } 7992 7993 if (data.duration !== undefined) { 7994 this.duration = data.duration; 7995 } 7996 7997 if (data.speed !== undefined) { 7998 this.speed = data.speed; 7999 } 8000 } 8001 8002 } 8003 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/LightGradient.js 8004 8005 class LightGradient { 8006 constructor() { 8007 this.start = new OptionsColor(); 8008 this.stop = new OptionsColor(); 8009 this.start.value = "#ffffff"; 8010 this.stop.value = "#000000"; 8011 } 8012 8013 load(data) { 8014 if (data === undefined) { 8015 return; 8016 } 8017 8018 this.start = OptionsColor.create(this.start, data.start); 8019 this.stop = OptionsColor.create(this.stop, data.stop); 8020 } 8021 8022 } 8023 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/LightArea.js 8024 8025 class LightArea { 8026 constructor() { 8027 this.gradient = new LightGradient(); 8028 this.radius = 1000; 8029 } 8030 8031 load(data) { 8032 if (data === undefined) { 8033 return; 8034 } 8035 8036 this.gradient.load(data.gradient); 8037 8038 if (data.radius !== undefined) { 8039 this.radius = data.radius; 8040 } 8041 } 8042 8043 } 8044 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/LightShadow.js 8045 8046 class LightShadow { 8047 constructor() { 8048 this.color = new OptionsColor(); 8049 this.color.value = "#000000"; 8050 this.length = 2000; 8051 } 8052 8053 load(data) { 8054 if (data === undefined) { 8055 return; 8056 } 8057 8058 this.color = OptionsColor.create(this.color, data.color); 8059 8060 if (data.length !== undefined) { 8061 this.length = data.length; 8062 } 8063 } 8064 8065 } 8066 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Light.js 8067 8068 8069 class Light { 8070 constructor() { 8071 this.area = new LightArea(); 8072 this.shadow = new LightShadow(); 8073 } 8074 8075 load(data) { 8076 if (data === undefined) { 8077 return; 8078 } 8079 8080 this.area.load(data.area); 8081 this.shadow.load(data.shadow); 8082 } 8083 8084 } 8085 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Bounce.js 8086 class Bounce_Bounce { 8087 constructor() { 8088 this.distance = 200; 8089 } 8090 8091 load(data) { 8092 if (!data) { 8093 return; 8094 } 8095 8096 if (data.distance !== undefined) { 8097 this.distance = data.distance; 8098 } 8099 } 8100 8101 } 8102 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Modes/Modes.js 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 class Modes { 8115 constructor() { 8116 this.attract = new Attract_Attract(); 8117 this.bounce = new Bounce_Bounce(); 8118 this.bubble = new Bubble(); 8119 this.connect = new Connect(); 8120 this.grab = new Grab(); 8121 this.light = new Light(); 8122 this.push = new Push(); 8123 this.remove = new Remove(); 8124 this.repulse = new Repulse(); 8125 this.slow = new Slow(); 8126 this.trail = new Trail_Trail(); 8127 } 8128 8129 load(data) { 8130 if (data === undefined) { 8131 return; 8132 } 8133 8134 this.attract.load(data.attract); 8135 this.bubble.load(data.bubble); 8136 this.connect.load(data.connect); 8137 this.grab.load(data.grab); 8138 this.light.load(data.light); 8139 this.push.load(data.push); 8140 this.remove.load(data.remove); 8141 this.repulse.load(data.repulse); 8142 this.slow.load(data.slow); 8143 this.trail.load(data.trail); 8144 } 8145 8146 } 8147 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Interactivity/Interactivity.js 8148 8149 8150 8151 class Interactivity { 8152 constructor() { 8153 this.detectsOn = InteractivityDetect.canvas; 8154 this.events = new Events(); 8155 this.modes = new Modes(); 8156 } 8157 8158 get detect_on() { 8159 return this.detectsOn; 8160 } 8161 8162 set detect_on(value) { 8163 this.detectsOn = value; 8164 } 8165 8166 load(data) { 8167 var _a, _b, _c; 8168 8169 if (data === undefined) { 8170 return; 8171 } 8172 8173 const detectsOn = (_a = data.detectsOn) !== null && _a !== void 0 ? _a : data.detect_on; 8174 8175 if (detectsOn !== undefined) { 8176 this.detectsOn = detectsOn; 8177 } 8178 8179 this.events.load(data.events); 8180 this.modes.load(data.modes); 8181 8182 if (((_c = (_b = data.modes) === null || _b === void 0 ? void 0 : _b.slow) === null || _c === void 0 ? void 0 : _c.active) === true) { 8183 if (this.events.onHover.mode instanceof Array) { 8184 if (this.events.onHover.mode.indexOf(HoverMode.slow) < 0) {
8185 this.events.onHover.mode.push(HoverMode.slow); 8186 } 8187 } else if (this.events.onHover.mode !== HoverMode.slow) { 8188 this.events.onHover.mode = [this.events.onHover.mode, HoverMode.slow]; 8189 } 8190 } 8191 } 8192 8193 } 8194 // CONCATENATED MODULE: ./dist/browser/Options/Classes/BackgroundMask/BackgroundMaskCover.js 8195 8196 class BackgroundMaskCover { 8197 constructor() { 8198 this.color = new OptionsColor(); 8199 this.opacity = 1; 8200 } 8201 8202 load(data) { 8203 if (data === undefined) { 8204 return; 8205 } 8206 8207 if (data.color !== undefined) { 8208 this.color = OptionsColor.create(this.color, data.color); 8209 } 8210 8211 if (data.opacity !== undefined) { 8212 this.opacity = data.opacity; 8213 } 8214 } 8215 8216 } 8217 // CONCATENATED MODULE: ./dist/browser/Options/Classes/BackgroundMask/BackgroundMask.js 8218 8219 class BackgroundMask { 8220 constructor() { 8221 this.composite = "destination-out"; 8222 this.cover = new BackgroundMaskCover(); 8223 this.enable = false; 8224 } 8225 8226 load(data) { 8227 if (data === undefined) { 8228 return; 8229 } 8230 8231 if (data.composite !== undefined) { 8232 this.composite = data.composite; 8233 } 8234 8235 if (data.cover !== undefined) { 8236 const cover = data.cover; 8237 const color = typeof data.cover === "string" ? { 8238 color: data.cover 8239 } : data.cover; 8240 this.cover.load(cover.color !== undefined ? cover : { 8241 color: color 8242 }); 8243 } 8244 8245 if (data.enable !== undefined) { 8246 this.enable = data.enable; 8247 } 8248 } 8249 8250 } 8251 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Background/Background.js 8252 8253 class Background { 8254 constructor() { 8255 this.color = new OptionsColor(); 8256 this.color.value = ""; 8257 this.image = ""; 8258 this.position = ""; 8259 this.repeat = ""; 8260 this.size = ""; 8261 this.opacity = 1; 8262 } 8263 8264 load(data) { 8265 if (data === undefined) { 8266 return; 8267 } 8268 8269 if (data.color !== undefined) { 8270 this.color = OptionsColor.create(this.color, data.color); 8271 } 8272 8273 if (data.image !== undefined) { 8274 this.image = data.image; 8275 } 8276 8277 if (data.position !== undefined) { 8278 this.position = data.position; 8279 } 8280 8281 if (data.repeat !== undefined) { 8282 this.repeat = data.repeat; 8283 } 8284 8285 if (data.size !== undefined) { 8286 this.size = data.size; 8287 } 8288 8289 if (data.opacity !== undefined) { 8290 this.opacity = data.opacity; 8291 } 8292 } 8293 8294 } 8295 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Infection/InfectionStage.js 8296 8297 class InfectionStage { 8298 constructor() { 8299 this.color = new OptionsColor(); 8300 this.color.value = "#ff0000"; 8301 this.radius = 0; 8302 this.rate = 1; 8303 } 8304 8305 load(data) { 8306 if (data === undefined) { 8307 return; 8308 } 8309 8310 if (data.color !== undefined) { 8311 this.color = OptionsColor.create(this.color, data.color); 8312 } 8313 8314 this.duration = data.duration; 8315 this.infectedStage = data.infectedStage; 8316 8317 if (data.radius !== undefined) { 8318 this.radius = data.radius; 8319 } 8320 8321 if (data.rate !== undefined) { 8322 this.rate = data.rate; 8323 } 8324 } 8325 8326 } 8327 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Infection/Infection.js 8328 8329 class Infection { 8330 constructor() { 8331 this.cure = false; 8332 this.delay = 0; 8333 this.enable = false; 8334 this.infections = 0; 8335 this.stages = []; 8336 } 8337 8338 load(data) { 8339 if (data === undefined) { 8340 return; 8341 } 8342 8343 if (data.cure !== undefined) { 8344 this.cure = data.cure; 8345 } 8346 8347 if (data.delay !== undefined) { 8348 this.delay = data.delay; 8349 } 8350 8351 if (data.enable !== undefined) { 8352 this.enable = data.enable; 8353 } 8354 8355 if (data.infections !== undefined) { 8356 this.infections = data.infections; 8357 } 8358 8359 if (data.stages === undefined) { 8360 return; 8361 } 8362 8363 this.stages = data.stages.map(t => { 8364 const s = new InfectionStage(); 8365 s.load(t); 8366 return s; 8367 }); 8368 } 8369 8370 } 8371 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Theme/ThemeDefault.js 8372 8373 class ThemeDefault { 8374 constructor() { 8375 this.mode = ThemeMode.any; 8376 this.value = false;
8377 } 8378 8379 load(data) { 8380 if (data === undefined) { 8381 return; 8382 } 8383 8384 if (data.mode !== undefined) { 8385 this.mode = data.mode; 8386 } 8387 8388 if (data.value !== undefined) { 8389 this.value = data.value; 8390 } 8391 } 8392 8393 } 8394 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Theme/Theme.js 8395 8396 8397 class Theme { 8398 constructor() { 8399 this.name = ""; 8400 this.default = new ThemeDefault(); 8401 } 8402 8403 load(data) { 8404 if (data === undefined) { 8405 return; 8406 } 8407 8408 if (data.name !== undefined) { 8409 this.name = data.name; 8410 } 8411 8412 this.default.load(data.default); 8413 8414 if (data.options !== undefined) { 8415 this.options = Utils.deepExtend({}, data.options); 8416 } 8417 } 8418 8419 } 8420 // CONCATENATED MODULE: ./dist/browser/Options/Classes/BackgroundMode/BackgroundMode.js 8421 class BackgroundMode { 8422 constructor() { 8423 this.enable = false; 8424 this.zIndex = -1; 8425 } 8426 8427 load(data) { 8428 if (!data) { 8429 return; 8430 } 8431 8432 if (data.enable !== undefined) { 8433 this.enable = data.enable; 8434 } 8435 8436 if (data.zIndex !== undefined) { 8437 this.zIndex = data.zIndex; 8438 } 8439 } 8440 8441 } 8442 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Motion/MotionReduce.js 8443 class MotionReduce { 8444 constructor() { 8445 this.factor = 4; 8446 this.value = false; 8447 } 8448 8449 load(data) { 8450 if (!data) { 8451 return; 8452 } 8453 8454 if (data.factor !== undefined) { 8455 this.factor = data.factor; 8456 } 8457 8458 if (data.value !== undefined) { 8459 this.value = data.value; 8460 } 8461 } 8462 8463 } 8464 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Motion/Motion.js 8465 8466 class Motion { 8467 constructor() { 8468 this.disable = false; 8469 this.reduce = new MotionReduce(); 8470 } 8471 8472 load(data) { 8473 if (!data) { 8474 return; 8475 } 8476 8477 if (data.disable !== undefined) { 8478 this.disable = data.disable; 8479 } 8480 8481 this.reduce.load(data.reduce); 8482 } 8483 8484 } 8485 // CONCATENATED MODULE: ./dist/browser/Options/Classes/ManualParticle.js 8486 8487 class ManualParticle { 8488 load(data) { 8489 var _a, _b; 8490 8491 if (!data) { 8492 return; 8493 } 8494 8495 if (data.position !== undefined) { 8496 this.position = { 8497 x: (_a = data.position.x) !== null && _a !== void 0 ? _a : 50, 8498 y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50 8499 }; 8500 } 8501 8502 if (data.options !== undefined) { 8503 this.options = Utils.deepExtend({}, data.options); 8504 } 8505 } 8506 8507 } 8508 // CONCATENATED MODULE: ./dist/browser/Options/Classes/Options.js 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 class Options { 8521 constructor() { 8522 this.autoPlay = true; 8523 this.background = new Background(); 8524 this.backgroundMask = new BackgroundMask(); 8525 this.backgroundMode = new BackgroundMode(); 8526 this.detectRetina = true; 8527 this.fpsLimit = 30; 8528 this.infection = new Infection(); 8529 this.interactivity = new Interactivity(); 8530 this.manualParticles = []; 8531 this.motion = new Motion(); 8532 this.particles = new Particles(); 8533 this.pauseOnBlur = true; 8534 this.pauseOnOutsideViewport = false; 8535 this.themes = []; 8536 } 8537 8538 get fps_limit() { 8539 return this.fpsLimit; 8540 } 8541 8542 set fps_limit(value) { 8543 this.fpsLimit = value; 8544 } 8545 8546 get retina_detect() { 8547 return this.detectRetina; 8548 } 8549 8550 set retina_detect(value) { 8551 this.detectRetina = value; 8552 } 8553 8554 load(data) { 8555 var _a, _b; 8556 8557 if (data === undefined) { 8558 return; 8559 } 8560 8561 if (data.preset !== undefined) { 8562 if (data.preset instanceof Array) { 8563 for (const preset of data.preset) { 8564 this.importPreset(preset); 8565 } 8566 } else { 8567 this.importPreset(data.preset); 8568 } 8569 } 8570 8571 if (data.autoPlay !== undefined) { 8572 this.autoPlay = data.autoPlay; 8573 } 8574 8575 const detectRetina = (_a = data.detectRetina) !== null && _a !== void 0 ? _a : data.retina_detect; 8576 8577 if (detectRetina !== undefined) { 8578 this.detectRetina = detectRetina; 8579 } 8580 8581 const fpsLimit = (_b = data.fpsLimit) !== null && _b !== void 0 ? _b : data.fps_limit; 8582 8583 if (fpsLimit !== undefined) { 8584 this.fpsLimit = fpsLimit; 8585 } 8586 8587 if (data.pauseOnBlur !== undefined) { 8588 this.pauseOnBlur = data.pauseOnBlur; 8589 } 8590 8591 if (data.pauseOnOutsideViewport !== undefined) { 8592 this.pauseOnOutsideViewport = data.pauseOnOutsideViewport; 8593 } 8594 8595 this.background.load(data.background); 8596 this.backgroundMode.load(data.backgroundMode); 8597 this.backgroundMask.load(data.backgroundMask); 8598 this.infection.load(data.infection); 8599 this.interactivity.load(data.interactivity); 8600 8601 if (data.manualParticles !== undefined) { 8602 this.manualParticles = data.manualParticles.map(t => { 8603 const tmp = new ManualParticle(); 8604 tmp.load(t); 8605 return tmp; 8606 }); 8607 } 8608 8609 this.motion.load(data.motion); 8610 this.particles.load(data.particles); 8611 Plugins.loadOptions(this, data); 8612 8613 if (data.themes !== undefined) { 8614 for (const theme of data.themes) { 8615 const optTheme = new Theme(); 8616 optTheme.load(theme); 8617 this.themes.push(optTheme); 8618 } 8619 } 8620 } 8621 8622 setTheme(name) { 8623 if (name) { 8624 const chosenTheme = this.themes.find(theme => theme.name === name); 8625 8626 if (chosenTheme) { 8627 this.load(chosenTheme.options); 8628 } 8629 } else { 8630 const clientDarkMode = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)").matches; 8631 let defaultTheme = this.themes.find(theme => theme.default.value && (theme.default.mode === ThemeMode.dark && clientDarkMode || theme.default.mode === ThemeMode.light && !clientDarkMode)); 8632 8633 if (!defaultTheme) { 8634 defaultTheme = this.themes.find(theme => theme.default.value && theme.default.mode === ThemeMode.any); 8635 } 8636 8637 if (defaultTheme) { 8638 this.load(defaultTheme.options); 8639 } 8640 } 8641 } 8642 8643 importPreset(preset) { 8644 this.load(Plugins.getPreset(preset)); 8645 } 8646 8647 } 8648 // CONCATENATED MODULE: ./dist/browser/Core/Container.js 8649 var Container_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { 8650 function adopt(value) { 8651 return value instanceof P ? value : new P(function (resolve) { 8652 resolve(value); 8653 }); 8654 } 8655 8656 return new (P || (P = Promise))(function (resolve, reject) { 8657 function fulfilled(value) { 8658 try { 8659 step(generator.next(value)); 8660 } catch (e) { 8661 reject(e); 8662 } 8663 } 8664 8665 function rejected(value) { 8666 try { 8667 step(generator["throw"](value)); 8668 } catch (e) { 8669 reject(e); 8670 } 8671 } 8672 8673 function step(result) { 8674 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 8675 } 8676 8677 step((generator = generator.apply(thisArg, _arguments || [])).next()); 8678 }); 8679 }; 8680 8681 8682 8683 8684 8685 8686 8687 class Container { 8688 constructor(id, sourceOptions, ...presets) { 8689 this.id = id; 8690 this.sourceOptions = sourceOptions; 8691 this.firstStart = true; 8692 this.started = false;
8693 this.destroyed = false; 8694 this.paused = true; 8695 this.lastFrameTime = 0; 8696 this.pageHidden = false; 8697 this.retina = new Retina(this); 8698 this.canvas = new Canvas(this); 8699 this.particles = new Particles_Particles(this); 8700 this.drawer = new FrameManager(this); 8701 this.noise = { 8702 generate: () => { 8703 return { 8704 angle: Math.random() * Math.PI * 2, 8705 length: Math.random() 8706 }; 8707 }, 8708 init: () => {}, 8709 update: () => {} 8710 }; 8711 this.interactivity = { 8712 mouse: { 8713 clicking: false, 8714 inside: false 8715 } 8716 }; 8717 this.bubble = {}; 8718 this.repulse = { 8719 particles: [] 8720 }; 8721 this.attract = { 8722 particles: [] 8723 }; 8724 this.plugins = new Map(); 8725 this.drawers = new Map(); 8726 this.density = 1; 8727 this.options = new Options(); 8728 8729 for (const preset of presets) { 8730 this.options.load(Plugins.getPreset(preset)); 8731 } 8732 8733 const shapes = Plugins.getSupportedShapes(); 8734 8735 for (const type of shapes) { 8736 const drawer = Plugins.getShapeDrawer(type); 8737 8738 if (drawer) { 8739 this.drawers.set(type, drawer); 8740 } 8741 } 8742 8743 if (this.sourceOptions) { 8744 this.options.load(this.sourceOptions); 8745 } 8746 8747 this.fpsLimit = this.options.fpsLimit > 0 ? this.options.fpsLimit : 60; 8748 this.options.setTheme(undefined); 8749 this.eventListeners = new EventListeners(this); 8750 8751 if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) { 8752 this.intersectionObserver = new IntersectionObserver(entries => this.intersectionManager(entries)); 8753 } 8754 } 8755 8756 play(force) { 8757 const needsUpdate = this.paused || force; 8758 8759 if (this.firstStart && !this.options.autoPlay) { 8760 this.firstStart = false;
8761 return; 8762 } 8763 8764 if (this.paused) { 8765 this.paused = false; 8766 } 8767 8768 if (needsUpdate) { 8769 for (const [, plugin] of this.plugins) { 8770 if (plugin.play) { 8771 plugin.play(); 8772 } 8773 } 8774 8775 this.lastFrameTime = performance.now(); 8776 } 8777 8778 this.draw(); 8779 } 8780 8781 pause() { 8782 if (this.drawAnimationFrame !== undefined) { 8783 Utils.cancelAnimation(this.drawAnimationFrame); 8784 delete this.drawAnimationFrame; 8785 } 8786 8787 if (this.paused) { 8788 return; 8789 } 8790 8791 for (const [, plugin] of this.plugins) { 8792 if (plugin.pause) { 8793 plugin.pause(); 8794 } 8795 } 8796 8797 if (!this.pageHidden) { 8798 this.paused = true; 8799 } 8800 } 8801 8802 draw() { 8803 this.drawAnimationFrame = Utils.animate(timestamp => this.drawer.nextFrame(timestamp)); 8804 } 8805 8806 getAnimationStatus() { 8807 return !this.paused; 8808 } 8809 8810 setNoise(noiseOrGenerator, init, update) { 8811 if (!noiseOrGenerator) { 8812 return; 8813 } 8814 8815 if (typeof noiseOrGenerator === "function") { 8816 this.noise.generate = noiseOrGenerator; 8817 8818 if (init) { 8819 this.noise.init = init; 8820 } 8821 8822 if (update) { 8823 this.noise.update = update; 8824 } 8825 } else { 8826 if (noiseOrGenerator.generate) { 8827 this.noise.generate = noiseOrGenerator.generate; 8828 } 8829 8830 if (noiseOrGenerator.init) { 8831 this.noise.init = noiseOrGenerator.init; 8832 } 8833 8834 if (noiseOrGenerator.update) { 8835 this.noise.update = noiseOrGenerator.update; 8836 } 8837 } 8838 } 8839 8840 destroy() { 8841 this.stop(); 8842 this.canvas.destroy(); 8843 8844 for (const [, drawer] of this.drawers) { 8845 if (drawer.destroy) { 8846 drawer.destroy(this); 8847 } 8848 } 8849 8850 for (const key of this.drawers.keys()) { 8851 this.drawers.delete(key); 8852 } 8853 8854 this.destroyed = true; 8855 } 8856 8857 exportImg(callback) { 8858 this.exportImage(callback); 8859 } 8860 8861 exportImage(callback, type, quality) { 8862 var _a; 8863 8864 return (_a = this.canvas.element) === null || _a === void 0 ? void 0 : _a.toBlob(callback, type !== null && type !== void 0 ? type : "image/png", quality); 8865 } 8866 8867 exportConfiguration() { 8868 return JSON.stringify(this.options, undefined, 2); 8869 } 8870 8871 refresh() { 8872 return Container_awaiter(this, void 0, void 0, function* () { 8873 this.stop(); 8874 yield this.start(); 8875 }); 8876 } 8877 8878 stop() { 8879 if (!this.started) { 8880 return; 8881 } 8882 8883 this.firstStart = true; 8884 this.started = false; 8885 this.eventListeners.removeListeners(); 8886 this.pause(); 8887 this.particles.clear(); 8888 this.canvas.clear(); 8889 8890 if (this.interactivity.element instanceof HTMLElement && this.intersectionObserver) { 8891 this.intersectionObserver.observe(this.interactivity.element); 8892 } 8893 8894 for (const [, plugin] of this.plugins) { 8895 if (plugin.stop) { 8896 plugin.stop(); 8897 } 8898 } 8899 8900 for (const key of this.plugins.keys()) { 8901 this.plugins.delete(key); 8902 } 8903 8904 this.particles.linksColors = new Map(); 8905 delete this.particles.grabLineColor; 8906 delete this.particles.linksColor; 8907 } 8908 8909 loadTheme(name) { 8910 return Container_awaiter(this, void 0, void 0, function* () { 8911 this.options.setTheme(name); 8912 yield this.refresh(); 8913 }); 8914 } 8915 8916 start() { 8917 return Container_awaiter(this, void 0, void 0, function* () { 8918 if (this.started) { 8919 return; 8920 } 8921 8922 yield this.init(); 8923 this.started = true; 8924 this.eventListeners.addListeners(); 8925 8926 if (this.interactivity.element instanceof HTMLElement && this.intersectionObserver) { 8927 this.intersectionObserver.observe(this.interactivity.element); 8928 } 8929 8930 for (const [, plugin] of this.plugins) { 8931 if (plugin.startAsync !== undefined) { 8932 yield plugin.startAsync(); 8933 } else if (plugin.start !== undefined) { 8934 plugin.start(); 8935 } 8936 } 8937 8938 this.play(); 8939 }); 8940 } 8941 8942 init() { 8943 return Container_awaiter(this, void 0, void 0, function* () { 8944 this.retina.init(); 8945 this.canvas.init(); 8946 this.fpsLimit = this.options.fpsLimit > 0 ? this.options.fpsLimit : 60; 8947 const availablePlugins = Plugins.getAvailablePlugins(this); 8948 8949 for (const [id, plugin] of availablePlugins) { 8950 this.plugins.set(id, plugin); 8951 } 8952 8953 for (const [, drawer] of this.drawers) { 8954 if (drawer.init) { 8955 yield drawer.init(this); 8956 } 8957 } 8958 8959 for (const [, plugin] of this.plugins) { 8960 if (plugin.init) { 8961 plugin.init(this.options); 8962 } else if (plugin.initAsync !== undefined) { 8963 yield plugin.initAsync(this.options); 8964 } 8965 } 8966 8967 this.canvas.initSize(); 8968 this.particles.init(); 8969 this.particles.setDensity(); 8970 }); 8971 } 8972 8973 intersectionManager(entries) { 8974 if (!this.options.pauseOnOutsideViewport) { 8975 return; 8976 } 8977
8978 for (const entry of entries) { 8979 if (entry.target !== this.interactivity.element) { 8980 continue; 8981 } 8982 8983 if (entry.isIntersecting) { 8984 this.play(); 8985 } else { 8986 this.pause(); 8987 } 8988 } 8989 } 8990 8991 } 8992 // CONCATENATED MODULE: ./dist/browser/Core/Loader.js 8993 var Loader_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { 8994 function adopt(value) { 8995 return value instanceof P ? value : new P(function (resolve) { 8996 resolve(value); 8997 }); 8998 } 8999 9000 return new (P || (P = Promise))(function (resolve, reject) { 9001 function fulfilled(value) { 9002 try { 9003 step(generator.next(value)); 9004 } catch (e) { 9005 reject(e); 9006 } 9007 } 9008 9009 function rejected(value) { 9010 try { 9011 step(generator["throw"](value)); 9012 } catch (e) { 9013 reject(e); 9014 } 9015 } 9016 9017 function step(result) { 9018 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 9019 } 9020 9021 step((generator = generator.apply(thisArg, _arguments || [])).next()); 9022 }); 9023 }; 9024 9025 9026 9027 const tsParticlesDom = []; 9028 9029 function fetchError(statusCode) { 9030 console.error(`Error tsParticles - fetch status: ${statusCode}`); 9031 console.error("Error tsParticles - File config not found"); 9032 } 9033 9034 class Loader { 9035 static dom() { 9036 return tsParticlesDom; 9037 } 9038 9039 static domItem(index) { 9040 const dom = Loader.dom(); 9041 const item = dom[index]; 9042 9043 if (item && !item.destroyed) { 9044 return item; 9045 } 9046 9047 dom.splice(index, 1); 9048 } 9049 9050 static load(tagId, options, index) { 9051 return Loader_awaiter(this, void 0, void 0, function* () { 9052 const domContainer = document.getElementById(tagId); 9053 9054 if (!domContainer) { 9055 return; 9056 } 9057 9058 return Loader.set(tagId, domContainer, options, index); 9059 }); 9060 } 9061 9062 static set(id, domContainer, options, index) { 9063 return Loader_awaiter(this, void 0, void 0, function* () { 9064 const currentOptions = options instanceof Array ? Utils.itemFromArray(options, index) : options; 9065 const dom = Loader.dom(); 9066 const oldIndex = dom.findIndex(v => v.id === id); 9067 9068 if (oldIndex >= 0) { 9069 const old = Loader.domItem(oldIndex); 9070 9071 if (old && !old.destroyed) { 9072 old.destroy(); 9073 dom.splice(oldIndex, 1); 9074 } 9075 } 9076 9077 let canvasEl; 9078 let generatedCanvas; 9079 9080 if (domContainer.tagName.toLowerCase() === "canvas") { 9081 canvasEl = domContainer; 9082 generatedCanvas = false; 9083 } else { 9084 const existingCanvases = domContainer.getElementsByTagName("canvas"); 9085 9086 if (existingCanvases.length) { 9087 canvasEl = existingCanvases[0]; 9088 9089 if (!canvasEl.className) { 9090 canvasEl.className = Constants.canvasClass; 9091 } 9092 9093 generatedCanvas = false; 9094 } else { 9095 generatedCanvas = true; 9096 canvasEl = document.createElement("canvas"); 9097 canvasEl.className = Constants.canvasClass; 9098 canvasEl.style.width = "100%"; 9099 canvasEl.style.height = "100%"; 9100 domContainer.appendChild(canvasEl); 9101 } 9102 } 9103 9104 const newItem = new Container(id, currentOptions); 9105 9106 if (oldIndex >= 0) { 9107 dom.splice(oldIndex, 0, newItem); 9108 } else { 9109 dom.push(newItem); 9110 } 9111 9112 newItem.canvas.loadCanvas(canvasEl, generatedCanvas); 9113 yield newItem.start(); 9114 return newItem; 9115 }); 9116 } 9117 9118 static loadJSON(tagId, jsonUrl, index) { 9119 return Loader_awaiter(this, void 0, void 0, function* () { 9120 const url = jsonUrl instanceof Array ? Utils.itemFromArray(jsonUrl, index) : jsonUrl; 9121 const response = yield fetch(url); 9122 9123 if (response.ok) { 9124 return Loader.load(tagId, yield response.json()); 9125 } else { 9126 fetchError(response.status); 9127 } 9128 }); 9129 } 9130 9131 static setJSON(id, domContainer, jsonUrl) { 9132 return Loader_awaiter(this, void 0, void 0, function* () { 9133 const response = yield fetch(jsonUrl); 9134 9135 if (response.ok) { 9136 const options = yield response.json(); 9137 return Loader.set(id, domContainer, options); 9138 } else { 9139 fetchError(response.status); 9140 } 9141 }); 9142 } 9143 9144 static setOnClickHandler(callback) { 9145 const dom = Loader.dom(); 9146 9147 if (dom.length === 0) { 9148 throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()"); 9149 } 9150 9151 for (const domItem of dom) { 9152 const el = domItem.interactivity.element; 9153 9154 if (!el) { 9155 continue; 9156 } 9157 9158 const clickOrTouchHandler = (e, pos) => { 9159 if (domItem.destroyed) { 9160 return; 9161 } 9162 9163 const pxRatio = domItem.retina.pixelRatio; 9164 const posRetina = { 9165 x: pos.x * pxRatio, 9166 y: pos.y * pxRatio 9167 }; 9168 const particles = domItem.particles.quadTree.queryCircle(posRetina, domItem.retina.sizeValue); 9169 callback(e, particles); 9170 }; 9171 9172 const clickHandler = e => { 9173 if (domItem.destroyed) { 9174 return; 9175 } 9176 9177 const mouseEvent = e; 9178 const pos = { 9179 x: mouseEvent.offsetX || mouseEvent.clientX, 9180 y: mouseEvent.offsetY || mouseEvent.clientY 9181 }; 9182 clickOrTouchHandler(e, pos); 9183 }; 9184 9185 const touchStartHandler = () => { 9186 if (domItem.destroyed) { 9187 return; 9188 } 9189 9190 touched = true; 9191 touchMoved = false;
9192 }; 9193 9194 const touchMoveHandler = () => { 9195 if (domItem.destroyed) { 9196 return; 9197 } 9198 9199 touchMoved = true; 9200 }; 9201 9202 const touchEndHandler = e => { 9203 var _a, _b, _c; 9204 9205 if (domItem.destroyed) { 9206 return; 9207 } 9208 9209 if (touched && !touchMoved) { 9210 const touchEvent = e; 9211 const lastTouch = touchEvent.touches[touchEvent.touches.length - 1]; 9212 const canvasRect = (_a = domItem.canvas.element) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(); 9213 const pos = { 9214 x: lastTouch.clientX - ((_b = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) !== null && _b !== void 0 ? _b : 0), 9215 y: lastTouch.clientY - ((_c = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) !== null && _c !== void 0 ? _c : 0) 9216 }; 9217 clickOrTouchHandler(e, pos); 9218 } 9219 9220 touched = false; 9221 touchMoved = false; 9222 }; 9223 9224 const touchCancelHandler = () => { 9225 if (domItem.destroyed) { 9226 return; 9227 } 9228 9229 touched = false; 9230 touchMoved = false; 9231 }; 9232 9233 let touched = false; 9234 let touchMoved = false; 9235 el.addEventListener("click", clickHandler); 9236 el.addEventListener("touchstart", touchStartHandler); 9237 el.addEventListener("touchmove", touchMoveHandler); 9238 el.addEventListener("touchend", touchEndHandler); 9239 el.addEventListener("touchcancel", touchCancelHandler); 9240 } 9241 } 9242 9243 } 9244 // CONCATENATED MODULE: ./dist/browser/main.slim.js 9245 var main_slim_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { 9246 function adopt(value) { 9247 return value instanceof P ? value : new P(function (resolve) { 9248 resolve(value); 9249 }); 9250 } 9251 9252 return new (P || (P = Promise))(function (resolve, reject) { 9253 function fulfilled(value) { 9254 try { 9255 step(generator.next(value)); 9256 } catch (e) { 9257 reject(e); 9258 } 9259 } 9260 9261 function rejected(value) { 9262 try { 9263 step(generator["throw"](value)); 9264 } catch (e) { 9265 reject(e); 9266 } 9267 } 9268 9269 function step(result) { 9270 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 9271 } 9272 9273 step((generator = generator.apply(thisArg, _arguments || [])).next()); 9274 }); 9275 }; 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 class MainSlim { 9289 constructor() { 9290 this.initialized = false; 9291 const squareDrawer = new SquareDrawer(); 9292 const textDrawer = new TextDrawer(); 9293 const imageDrawer = new ImageDrawer(); 9294 Plugins.addShapeDrawer(ShapeType.line, new LineDrawer()); 9295 Plugins.addShapeDrawer(ShapeType.circle, new CircleDrawer()); 9296 Plugins.addShapeDrawer(ShapeType.edge, squareDrawer); 9297 Plugins.addShapeDrawer(ShapeType.square, squareDrawer); 9298 Plugins.addShapeDrawer(ShapeType.triangle, new TriangleDrawer()); 9299 Plugins.addShapeDrawer(ShapeType.star, new StarDrawer()); 9300 Plugins.addShapeDrawer(ShapeType.polygon, new PolygonDrawer()); 9301 Plugins.addShapeDrawer(ShapeType.char, textDrawer); 9302 Plugins.addShapeDrawer(ShapeType.character, textDrawer); 9303 Plugins.addShapeDrawer(ShapeType.image, imageDrawer); 9304 Plugins.addShapeDrawer(ShapeType.images, imageDrawer); 9305 } 9306 9307 init() { 9308 if (!this.initialized) { 9309 this.initialized = true; 9310 } 9311 } 9312 9313 loadFromArray(tagId, options, index) { 9314 return main_slim_awaiter(this, void 0, void 0, function* () { 9315 return Loader.load(tagId, options, index); 9316 }); 9317 } 9318 9319 load(tagId, options) { 9320 return main_slim_awaiter(this, void 0, void 0, function* () { 9321 return Loader.load(tagId, options); 9322 }); 9323 } 9324 9325 set(id, element, options) { 9326 return main_slim_awaiter(this, void 0, void 0, function* () { 9327 return Loader.set(id, element, options); 9328 }); 9329 } 9330 9331 loadJSON(tagId, pathConfigJson, index) { 9332 return Loader.loadJSON(tagId, pathConfigJson, index); 9333 } 9334 9335 setOnClickHandler(callback) { 9336 Loader.setOnClickHandler(callback); 9337 } 9338 9339 dom() { 9340 return Loader.dom(); 9341 } 9342 9343 domItem(index) { 9344 return Loader.domItem(index); 9345 } 9346 9347 addShape(shape, drawer, init, afterEffect, destroy) { 9348 let customDrawer; 9349 9350 if (typeof drawer === "function") { 9351 customDrawer = { 9352 afterEffect: afterEffect, 9353 destroy: destroy, 9354 draw: drawer, 9355 init: init 9356 }; 9357 } else { 9358 customDrawer = drawer; 9359 } 9360 9361 Plugins.addShapeDrawer(shape, customDrawer); 9362 } 9363 9364 addPreset(preset, options) { 9365 Plugins.addPreset(preset, options); 9366 } 9367 9368 addPlugin(plugin) { 9369 Plugins.addPlugin(plugin); 9370 } 9371 9372 } 9373 // CONCATENATED MODULE: ./dist/browser/Plugins/Absorbers/AbsorberInstance.js 9374 9375 class AbsorberInstance { 9376 constructor(absorbers, container, options, position) { 9377 var _a, _b; 9378 9379 this.absorbers = absorbers; 9380 this.container = container; 9381 this.initialPosition = position; 9382 this.options = options; 9383 this.dragging = false;
9384 this.opacity = this.options.opacity; 9385 this.size = NumberUtils.getValue(options.size) * container.retina.pixelRatio; 9386 this.mass = this.size * options.size.density * container.retina.reduceFactor; 9387 const limit = options.size.limit; 9388 this.limit = limit !== undefined ? limit * container.retina.pixelRatio * container.retina.reduceFactor : limit; 9389 const color = typeof options.color === "string" ? { 9390 value: options.color 9391 } : options.color; 9392 this.color = (_a = ColorUtils.colorToRgb(color)) !== null && _a !== void 0 ? _a : { 9393 b: 0, 9394 g: 0, 9395 r: 0 9396 }; 9397 this.position = (_b = this.initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition(); 9398 } 9399 9400 attract(particle) { 9401 const options = this.options; 9402 9403 if (options.draggable) { 9404 const mouse = this.container.interactivity.mouse; 9405 9406 if (mouse.clicking && mouse.downPosition) { 9407 const mouseDist = NumberUtils.getDistance(this.position, mouse.downPosition); 9408 9409 if (mouseDist <= this.size) { 9410 this.dragging = true; 9411 } 9412 } else { 9413 this.dragging = false; 9414 } 9415 9416 if (this.dragging && mouse.position) { 9417 this.position.x = mouse.position.x; 9418 this.position.y = mouse.position.y; 9419 } 9420 } 9421 9422 const pos = particle.getPosition(); 9423 const { 9424 dx, 9425 dy, 9426 distance 9427 } = NumberUtils.getDistances(this.position, pos); 9428 const angle = Math.atan2(dx, dy); 9429 const acceleration = this.mass / Math.pow(distance, 2) * this.container.retina.reduceFactor; 9430 9431 if (distance < this.size + particle.getRadius()) { 9432 const sizeFactor = particle.getRadius() * 0.033 * this.container.retina.pixelRatio; 9433 9434 if (this.size > particle.getRadius() && distance < this.size - particle.getRadius()) { 9435 if (options.destroy) { 9436 particle.destroy(); 9437 } else { 9438 particle.needsNewPosition = true; 9439 this.updateParticlePosition(particle, angle, acceleration); 9440 } 9441 } else { 9442 if (options.destroy) { 9443 particle.size.value -= sizeFactor; 9444 } 9445 9446 this.updateParticlePosition(particle, angle, acceleration); 9447 } 9448 9449 if (this.limit === undefined || this.size < this.limit) { 9450 this.size += sizeFactor; 9451 } 9452 9453 this.mass += sizeFactor * this.options.size.density * this.container.retina.reduceFactor; 9454 } else { 9455 this.updateParticlePosition(particle, angle, acceleration); 9456 } 9457 } 9458 9459 resize() { 9460 const initialPosition = this.initialPosition; 9461 this.position = initialPosition && Utils.isPointInside(initialPosition, this.container.canvas.size) ? initialPosition : this.calcPosition(); 9462 } 9463 9464 draw(context) { 9465 context.translate(this.position.x, this.position.y); 9466 context.beginPath(); 9467 context.arc(0, 0, this.size, 0, Math.PI * 2, false); 9468 context.closePath(); 9469 context.fillStyle = ColorUtils.getStyleFromRgb(this.color, this.opacity); 9470 context.fill(); 9471 } 9472 9473 calcPosition() { 9474 var _a, _b; 9475 9476 const container = this.container; 9477 const percentPosition = this.options.position; 9478 return { 9479 x: ((_a = percentPosition === null || percentPosition === void 0 ? void 0 : percentPosition.x) !== null && _a !== void 0 ? _a : Math.random() * 100) / 100 * container.canvas.size.width, 9480 y: ((_b = percentPosition === null || percentPosition === void 0 ? void 0 : percentPosition.y) !== null && _b !== void 0 ? _b : Math.random() * 100) / 100 * container.canvas.size.height 9481 }; 9482 } 9483 9484 updateParticlePosition(particle, angle, acceleration) { 9485 var _a; 9486 9487 if (particle.destroyed) { 9488 return; 9489 } 9490 9491 const canvasSize = this.container.canvas.size; 9492 9493 if (particle.needsNewPosition) { 9494 const pSize = particle.getRadius(); 9495 particle.position.x = Math.random() * (canvasSize.width - pSize * 2) + pSize; 9496 particle.position.y = Math.random() * (canvasSize.height - pSize * 2) + pSize; 9497 particle.needsNewPosition = false;
9498 } 9499 9500 if (this.options.orbits) { 9501 if (particle.orbitRadius === undefined) { 9502 particle.orbitRadius = NumberUtils.getDistance(particle.getPosition(), this.position); 9503 } 9504 9505 if (particle.orbitRadius <= this.size && !this.options.destroy) { 9506 particle.orbitRadius = Math.random() * Math.max(canvasSize.width, canvasSize.height); 9507 } 9508 9509 if (particle.orbitAngle === undefined) { 9510 particle.orbitAngle = Math.random() * Math.PI * 2; 9511 } 9512 9513 const orbitRadius = particle.orbitRadius; 9514 const orbitAngle = particle.orbitAngle; 9515 particle.velocity.horizontal = 0; 9516 particle.velocity.vertical = 0; 9517 particle.position.x = this.position.x + orbitRadius * Math.cos(orbitAngle); 9518 particle.position.y = this.position.y + orbitRadius * Math.sin(orbitAngle); 9519 particle.orbitRadius -= acceleration; 9520 particle.orbitAngle += ((_a = particle.moveSpeed) !== null && _a !== void 0 ? _a : this.container.retina.moveSpeed) / 100 * this.container.retina.reduceFactor; 9521 } else { 9522 particle.velocity.horizontal += Math.sin(angle) * acceleration; 9523 particle.velocity.vertical += Math.cos(angle) * acceleration; 9524 } 9525 } 9526 9527 } 9528 // CONCATENATED MODULE: ./dist/browser/Plugins/Absorbers/Options/Classes/AbsorberSize.js 9529 9530 class AbsorberSize extends ValueWithRandom { 9531 constructor() { 9532 super(); 9533 this.density = 5; 9534 this.random.minimumValue = 1; 9535 this.value = 50; 9536 } 9537 9538 load(data) { 9539 if (!data) { 9540 return; 9541 } 9542 9543 super.load(data); 9544 9545 if (data.density !== undefined) { 9546 this.density = data.density; 9547 } 9548 9549 if (data.limit !== undefined) { 9550 this.limit = data.limit; 9551 } 9552 9553 if (data.limit !== undefined) { 9554 this.limit = data.limit; 9555 } 9556 } 9557 9558 } 9559 // CONCATENATED MODULE: ./dist/browser/Plugins/Absorbers/Options/Classes/Absorber.js 9560 9561 9562 class Absorber { 9563 constructor() { 9564 this.color = new OptionsColor(); 9565 this.color.value = "#000000"; 9566 this.draggable = false; 9567 this.opacity = 1; 9568 this.destroy = true; 9569 this.orbits = false; 9570 this.size = new AbsorberSize(); 9571 } 9572 9573 load(data) { 9574 if (data === undefined) { 9575 return; 9576 } 9577 9578 if (data.color !== undefined) { 9579 this.color = OptionsColor.create(this.color, data.color); 9580 } 9581 9582 if (data.draggable !== undefined) { 9583 this.draggable = data.draggable; 9584 } 9585 9586 if (data.opacity !== undefined) { 9587 this.opacity = data.opacity; 9588 } 9589 9590 if (data.position !== undefined) { 9591 this.position = { 9592 x: data.position.x, 9593 y: data.position.y 9594 }; 9595 } 9596 9597 if (data.size !== undefined) { 9598 this.size.load(data.size); 9599 } 9600 9601 if (data.destroy !== undefined) { 9602 this.destroy = data.destroy; 9603 } 9604 9605 if (data.orbits !== undefined) { 9606 this.orbits = data.orbits; 9607 } 9608 } 9609 9610 } 9611 // CONCATENATED MODULE: ./dist/browser/Plugins/Absorbers/Enums/AbsorberClickMode.js 9612 var AbsorberClickMode; 9613 9614 (function (AbsorberClickMode) { 9615 AbsorberClickMode["absorber"] = "absorber"; 9616 })(AbsorberClickMode || (AbsorberClickMode = {})); 9617 // CONCATENATED MODULE: ./dist/browser/Plugins/Absorbers/Enums/index.js 9618 9619 // CONCATENATED MODULE: ./dist/browser/Plugins/Absorbers/Absorbers.js 9620 9621 9622 9623 9624 class Absorbers { 9625 constructor(container) { 9626 this.container = container; 9627 this.array = []; 9628 this.absorbers = []; 9629 this.interactivityAbsorbers = []; 9630 const overridableContainer = container; 9631 9632 overridableContainer.addAbsorber = (options, position) => this.addAbsorber(options, position); 9633 } 9634 9635 init(options) { 9636 var _a, _b; 9637 9638 if (!options) { 9639 return; 9640 } 9641 9642 if (options.absorbers) { 9643 if (options.absorbers instanceof Array) { 9644 this.absorbers = options.absorbers.map(s => { 9645 const tmp = new Absorber(); 9646 tmp.load(s); 9647 return tmp; 9648 }); 9649 } else { 9650 if (this.absorbers instanceof Array) { 9651 this.absorbers = new Absorber(); 9652 } 9653 9654 this.absorbers.load(options.absorbers); 9655 } 9656 } 9657 9658 const interactivityAbsorbers = (_b = (_a = options.interactivity) === null || _a === void 0 ? void 0 : _a.modes) === null || _b === void 0 ? void 0 : _b.absorbers; 9659 9660 if (interactivityAbsorbers) { 9661 if (interactivityAbsorbers instanceof Array) { 9662 this.interactivityAbsorbers = interactivityAbsorbers.map(s => { 9663 const tmp = new Absorber(); 9664 tmp.load(s); 9665 return tmp; 9666 }); 9667 } else { 9668 if (this.interactivityAbsorbers instanceof Array) { 9669 this.interactivityAbsorbers = new Absorber(); 9670 } 9671 9672 this.interactivityAbsorbers.load(interactivityAbsorbers); 9673 } 9674 } 9675 9676 if (this.absorbers instanceof Array) { 9677 for (const absorberOptions of this.absorbers) { 9678 this.addAbsorber(absorberOptions); 9679 } 9680 } else { 9681 this.addAbsorber(this.absorbers); 9682 } 9683 } 9684 9685 particleUpdate(particle) { 9686 for (const absorber of this.array) { 9687 absorber.attract(particle); 9688 9689 if (particle.destroyed) { 9690 break; 9691 } 9692 } 9693 } 9694 9695 draw(context) { 9696 for (const absorber of this.array) { 9697 context.save(); 9698 absorber.draw(context);
9699 context.restore(); 9700 } 9701 } 9702 9703 stop() { 9704 this.array = []; 9705 } 9706 9707 resize() { 9708 for (const absorber of this.array) { 9709 absorber.resize(); 9710 } 9711 } 9712 9713 handleClickMode(mode) { 9714 const container = this.container; 9715 const absorberOptions = this.absorbers; 9716 const modeAbsorbers = this.interactivityAbsorbers; 9717 9718 if (mode === AbsorberClickMode.absorber) { 9719 let absorbersModeOptions; 9720 9721 if (modeAbsorbers instanceof Array) { 9722 if (modeAbsorbers.length > 0) { 9723 absorbersModeOptions = Utils.itemFromArray(modeAbsorbers); 9724 } 9725 } else { 9726 absorbersModeOptions = modeAbsorbers; 9727 } 9728 9729 const absorbersOptions = absorbersModeOptions !== null && absorbersModeOptions !== void 0 ? absorbersModeOptions : absorberOptions instanceof Array ? Utils.itemFromArray(absorberOptions) : absorberOptions; 9730 const aPosition = container.interactivity.mouse.clickPosition; 9731 this.addAbsorber(absorbersOptions, aPosition); 9732 } 9733 } 9734 9735 addAbsorber(options, position) { 9736 const absorber = new AbsorberInstance(this, this.container, options, position); 9737 this.array.push(absorber); 9738 return absorber; 9739 } 9740 9741 removeAbsorber(absorber) { 9742 const index = this.array.indexOf(absorber); 9743 9744 if (index >= 0) { 9745 this.array.splice(index, 1); 9746 } 9747 } 9748 9749 } 9750 // CONCATENATED MODULE: ./dist/browser/Plugins/Absorbers/AbsorbersPlugin.js 9751 9752 9753 9754 9755 9756 class AbsorbersPlugin { 9757 constructor() { 9758 this.id = "absorbers"; 9759 } 9760 9761 getPlugin(container) { 9762 return new Absorbers(container); 9763 } 9764 9765 needsPlugin(options) { 9766 var _a, _b, _c; 9767 9768 if (options === undefined) { 9769 return false; 9770 } 9771 9772 const absorbers = options.absorbers; 9773 let loadAbsorbers = false; 9774 9775 if (absorbers instanceof Array) { 9776 if (absorbers.length) { 9777 loadAbsorbers = true; 9778 } 9779 } else if (absorbers !== undefined) { 9780 loadAbsorbers = true; 9781 } else if (((_c = (_b = (_a = options.interactivity) === null || _a === void 0 ? void 0 : _a.events) === null || _b === void 0 ? void 0 : _b.onClick) === null || _c === void 0 ? void 0 : _c.mode) && Utils.isInArray(AbsorberClickMode.absorber, options.interactivity.events.onClick.mode)) { 9782 loadAbsorbers = true; 9783 } 9784 9785 return loadAbsorbers; 9786 } 9787 9788 loadOptions(options, source) { 9789 var _a, _b; 9790 9791 if (!this.needsPlugin(options) && !this.needsPlugin(source)) { 9792 return; 9793 } 9794 9795 const optionsCast = options; 9796 9797 if (source === null || source === void 0 ? void 0 : source.absorbers) { 9798 if ((source === null || source === void 0 ? void 0 : source.absorbers) instanceof Array) { 9799 optionsCast.absorbers = source === null || source === void 0 ? void 0 : source.absorbers.map(s => { 9800 const tmp = new Absorber(); 9801 tmp.load(s); 9802 return tmp; 9803 }); 9804 } else { 9805 let absorberOptions = optionsCast.absorbers; 9806 9807 if ((absorberOptions === null || absorberOptions === void 0 ? void 0 : absorberOptions.load) === undefined) { 9808 optionsCast.absorbers = absorberOptions = new Absorber(); 9809 } 9810 9811 absorberOptions.load(source === null || source === void 0 ? void 0 : source.absorbers); 9812 } 9813 } 9814 9815 const interactivityAbsorbers = (_b = (_a = source === null || source === void 0 ? void 0 : source.interactivity) === null || _a === void 0 ? void 0 : _a.modes) === null || _b === void 0 ? void 0 : _b.absorbers; 9816 9817 if (interactivityAbsorbers) { 9818 if (interactivityAbsorbers instanceof Array) { 9819 optionsCast.interactivity.modes.absorbers = interactivityAbsorbers.map(s => { 9820 const tmp = new Absorber(); 9821 tmp.load(s); 9822 return tmp; 9823 }); 9824 } else { 9825 let absorberOptions = optionsCast.interactivity.modes.absorbers; 9826 9827 if ((absorberOptions === null || absorberOptions === void 0 ? void 0 : absorberOptions.load) === undefined) { 9828 optionsCast.interactivity.modes.absorbers = absorberOptions = new Absorber(); 9829 } 9830 9831 absorberOptions.load(interactivityAbsorbers); 9832 } 9833 } 9834 } 9835 9836 } 9837 9838 const AbsorbersPlugin_plugin = new AbsorbersPlugin(); 9839 9840 9841 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/Options/Classes/EmitterSize.js 9842 9843 class EmitterSize { 9844 constructor() { 9845 this.mode = SizeMode.percent; 9846 this.height = 0; 9847 this.width = 0; 9848 } 9849 9850 load(data) { 9851 if (data === undefined) { 9852 return; 9853 } 9854 9855 if (data.mode !== undefined) { 9856 this.mode = data.mode; 9857 } 9858 9859 if (data.height !== undefined) { 9860 this.height = data.height; 9861 } 9862 9863 if (data.width !== undefined) { 9864 this.width = data.width; 9865 } 9866 } 9867 9868 } 9869 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/EmitterInstance.js 9870 9871 9872 9873 9874 function randomCoordinate(position, offset) { 9875 return position + offset * (Math.random() - 0.5); 9876 } 9877 9878 function randomPosition(position, offset) { 9879 return { 9880 x: randomCoordinate(position.x, offset.x), 9881 y: randomCoordinate(position.y, offset.y) 9882 }; 9883 } 9884 9885 class EmitterInstance { 9886 constructor(emitters, container, emitterOptions, position) { 9887 var _a, _b, _c; 9888 9889 this.emitters = emitters; 9890 this.container = container; 9891 this.initialPosition = position;
9892 this.emitterOptions = Utils.deepExtend({}, emitterOptions); 9893 this.position = (_a = this.initialPosition) !== null && _a !== void 0 ? _a : this.calcPosition(); 9894 let particlesOptions = Utils.deepExtend({}, this.emitterOptions.particles); 9895 9896 if (particlesOptions === undefined) { 9897 particlesOptions = {}; 9898 } 9899 9900 if (particlesOptions.move === undefined) { 9901 particlesOptions.move = {}; 9902 } 9903 9904 if (particlesOptions.move.direction === undefined) { 9905 particlesOptions.move.direction = this.emitterOptions.direction; 9906 } 9907 9908 this.particlesOptions = particlesOptions; 9909 this.size = (_b = this.emitterOptions.size) !== null && _b !== void 0 ? _b : (() => { 9910 const size = new EmitterSize(); 9911 size.load({ 9912 height: 0, 9913 mode: SizeMode.percent, 9914 width: 0 9915 }); 9916 return size; 9917 })(); 9918 this.lifeCount = (_c = this.emitterOptions.life.count) !== null && _c !== void 0 ? _c : -1; 9919 this.immortal = this.lifeCount <= 0; 9920 this.play(); 9921 } 9922 9923 play() { 9924 if (this.container.retina.reduceFactor && (this.lifeCount > 0 || this.immortal || !this.emitterOptions.life.count)) { 9925 if (this.startInterval === undefined) { 9926 const delay = 1000 * this.emitterOptions.rate.delay / this.container.retina.reduceFactor; 9927 this.startInterval = window.setInterval(() => { 9928 this.emit(); 9929 }, delay); 9930 } 9931 9932 if (this.lifeCount > 0 || this.immortal) { 9933 this.prepareToDie(); 9934 } 9935 } 9936 } 9937 9938 pause() { 9939 const interval = this.startInterval; 9940 9941 if (interval !== undefined) { 9942 clearInterval(interval); 9943 delete this.startInterval; 9944 } 9945 } 9946 9947 resize() { 9948 const initialPosition = this.initialPosition; 9949 this.position = initialPosition && Utils.isPointInside(initialPosition, this.container.canvas.size) ? initialPosition : this.calcPosition(); 9950 } 9951 9952 prepareToDie() { 9953 var _a; 9954 9955 const duration = (_a = this.emitterOptions.life) === null || _a === void 0 ? void 0 : _a.duration; 9956 9957 if (this.container.retina.reduceFactor && (this.lifeCount > 0 || this.immortal) && duration !== undefined && duration > 0) { 9958 setTimeout(() => { 9959 var _a; 9960 9961 this.pause(); 9962 9963 if (!this.immortal) { 9964 this.lifeCount--; 9965 } 9966 9967 if (this.lifeCount > 0 || this.immortal) { 9968 this.position = this.calcPosition(); 9969 setTimeout(() => { 9970 this.play(); 9971 }, ((_a = this.emitterOptions.life.delay) !== null && _a !== void 0 ? _a : 0) * 1000 / this.container.retina.reduceFactor); 9972 } else { 9973 this.destroy(); 9974 } 9975 }, duration * 1000); 9976 } 9977 } 9978 9979 destroy() { 9980 this.emitters.removeEmitter(this); 9981 } 9982 9983 calcPosition() { 9984 var _a, _b; 9985 9986 const container = this.container; 9987 const percentPosition = this.emitterOptions.position; 9988 return { 9989 x: ((_a = percentPosition === null || percentPosition === void 0 ? void 0 : percentPosition.x) !== null && _a !== void 0 ? _a : Math.random() * 100) / 100 * container.canvas.size.width, 9990 y: ((_b = percentPosition === null || percentPosition === void 0 ? void 0 : percentPosition.y) !== null && _b !== void 0 ? _b : Math.random() * 100) / 100 * container.canvas.size.height 9991 }; 9992 } 9993 9994 emit() { 9995 const container = this.container; 9996 const position = this.position; 9997 const offset = { 9998 x: this.size.mode === SizeMode.percent ? container.canvas.size.width * this.size.width / 100 : this.size.width, 9999 y: this.size.mode === SizeMode.percent ? container.canvas.size.height * this.size.height / 100 : this.size.height 10000 }; 10001 10002 for (let i = 0; i < this.emitterOptions.rate.quantity; i++) {
10003 container.particles.addParticle(randomPosition(position, offset), this.particlesOptions); 10004 } 10005 } 10006 10007 } 10008 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/Options/Classes/EmitterRate.js 10009 class EmitterRate { 10010 constructor() { 10011 this.quantity = 1; 10012 this.delay = 0.1; 10013 } 10014 10015 load(data) { 10016 if (data === undefined) { 10017 return; 10018 } 10019 10020 if (data.quantity !== undefined) { 10021 this.quantity = data.quantity; 10022 } 10023 10024 if (data.delay !== undefined) { 10025 this.delay = data.delay; 10026 } 10027 } 10028 10029 } 10030 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/Options/Classes/EmitterLife.js 10031 class EmitterLife { 10032 load(data) { 10033 if (data === undefined) { 10034 return; 10035 } 10036 10037 if (data.count !== undefined) { 10038 this.count = data.count; 10039 } 10040 10041 if (data.delay !== undefined) { 10042 this.delay = data.delay; 10043 } 10044 10045 if (data.duration !== undefined) { 10046 this.duration = data.duration; 10047 } 10048 } 10049 10050 } 10051 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/Options/Classes/Emitter.js 10052 10053 10054 10055 10056 10057 class Emitter { 10058 constructor() { 10059 this.direction = MoveDirection.none; 10060 this.life = new EmitterLife(); 10061 this.rate = new EmitterRate(); 10062 } 10063 10064 load(data) { 10065 if (data === undefined) { 10066 return; 10067 } 10068 10069 if (data.size !== undefined) { 10070 if (this.size === undefined) { 10071 this.size = new EmitterSize(); 10072 } 10073 10074 this.size.load(data.size); 10075 } 10076 10077 if (data.direction !== undefined) { 10078 this.direction = data.direction; 10079 } 10080 10081 this.life.load(data.life); 10082 10083 if (data.particles !== undefined) { 10084 this.particles = Utils.deepExtend({}, data.particles); 10085 } 10086 10087 this.rate.load(data.rate); 10088 10089 if (data.position !== undefined) { 10090 this.position = { 10091 x: data.position.x, 10092 y: data.position.y 10093 }; 10094 } 10095 } 10096 10097 } 10098 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/Enums/EmitterClickMode.js 10099 var EmitterClickMode; 10100 10101 (function (EmitterClickMode) { 10102 EmitterClickMode["emitter"] = "emitter"; 10103 })(EmitterClickMode || (EmitterClickMode = {})); 10104 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/Enums/index.js 10105 10106 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/Emitters.js 10107 10108 10109 10110 10111 class Emitters { 10112 constructor(container) { 10113 this.container = container; 10114 this.array = []; 10115 this.emitters = []; 10116 this.interactivityEmitters = []; 10117 const overridableContainer = container; 10118 10119 overridableContainer.addEmitter = (options, position) => this.addEmitter(options, position); 10120 } 10121 10122 init(options) { 10123 var _a, _b; 10124 10125 if (!options) { 10126 return; 10127 } 10128 10129 if (options.emitters) { 10130 if (options.emitters instanceof Array) { 10131 this.emitters = options.emitters.map(s => { 10132 const tmp = new Emitter(); 10133 tmp.load(s); 10134 return tmp; 10135 }); 10136 } else { 10137 if (this.emitters instanceof Array) { 10138 this.emitters = new Emitter(); 10139 } 10140 10141 this.emitters.load(options.emitters); 10142 } 10143 } 10144 10145 const interactivityEmitters = (_b = (_a = options.interactivity) === null || _a === void 0 ? void 0 : _a.modes) === null || _b === void 0 ? void 0 : _b.emitters; 10146 10147 if (interactivityEmitters) { 10148 if (interactivityEmitters instanceof Array) { 10149 this.interactivityEmitters = interactivityEmitters.map(s => { 10150 const tmp = new Emitter(); 10151 tmp.load(s); 10152 return tmp; 10153 }); 10154 } else { 10155 if (this.interactivityEmitters instanceof Array) { 10156 this.interactivityEmitters = new Emitter(); 10157 } 10158 10159 this.interactivityEmitters.load(interactivityEmitters); 10160 } 10161 } 10162 10163 if (this.emitters instanceof Array) { 10164 for (const emitterOptions of this.emitters) { 10165 this.addEmitter(emitterOptions); 10166 } 10167 } else { 10168 this.addEmitter(this.emitters); 10169 } 10170 } 10171 10172 play() { 10173 for (const emitter of this.array) { 10174 emitter.play(); 10175 } 10176 } 10177 10178 pause() { 10179 for (const emitter of this.array) { 10180 emitter.pause(); 10181 } 10182 } 10183 10184 stop() { 10185 this.array = []; 10186 } 10187 10188 handleClickMode(mode) { 10189 const container = this.container; 10190 const emitterOptions = this.emitters; 10191 const modeEmitters = this.interactivityEmitters; 10192 10193 if (mode === EmitterClickMode.emitter) { 10194 let emitterModeOptions; 10195 10196 if (modeEmitters instanceof Array) { 10197 if (modeEmitters.length > 0) {
10198 emitterModeOptions = Utils.itemFromArray(modeEmitters); 10199 } 10200 } else { 10201 emitterModeOptions = modeEmitters; 10202 } 10203 10204 const emittersOptions = emitterModeOptions !== null && emitterModeOptions !== void 0 ? emitterModeOptions : emitterOptions instanceof Array ? Utils.itemFromArray(emitterOptions) : emitterOptions; 10205 const ePosition = container.interactivity.mouse.clickPosition; 10206 this.addEmitter(Utils.deepExtend({}, emittersOptions), ePosition); 10207 } 10208 } 10209 10210 resize() { 10211 for (const emitter of this.array) { 10212 emitter.resize(); 10213 } 10214 } 10215 10216 addEmitter(options, position) { 10217 const emitter = new EmitterInstance(this, this.container, options, position); 10218 this.array.push(emitter); 10219 return emitter; 10220 } 10221 10222 removeEmitter(emitter) { 10223 const index = this.array.indexOf(emitter); 10224 10225 if (index >= 0) { 10226 this.array.splice(index, 1); 10227 } 10228 } 10229 10230 } 10231 // CONCATENATED MODULE: ./dist/browser/Plugins/Emitters/EmittersPlugin.js 10232 10233 10234 10235 10236 10237 class EmittersPlugin { 10238 constructor() { 10239 this.id = "emitters"; 10240 } 10241 10242 getPlugin(container) { 10243 return new Emitters(container); 10244 } 10245 10246 needsPlugin(options) { 10247 var _a, _b, _c; 10248 10249 if (options === undefined) { 10250 return false; 10251 } 10252 10253 const emitters = options.emitters; 10254 let loadEmitters = false; 10255 10256 if (emitters instanceof Array) { 10257 if (emitters.length) { 10258 loadEmitters = true; 10259 } 10260 } else if (emitters !== undefined) { 10261 loadEmitters = true; 10262 } else if (((_c = (_b = (_a = options.interactivity) === null || _a === void 0 ? void 0 : _a.events) === null || _b === void 0 ? void 0 : _b.onClick) === null || _c === void 0 ? void 0 : _c.mode) && Utils.isInArray(EmitterClickMode.emitter, options.interactivity.events.onClick.mode)) { 10263 loadEmitters = true; 10264 } 10265 10266 return loadEmitters; 10267 } 10268 10269 loadOptions(options, source) { 10270 var _a, _b; 10271 10272 if (!this.needsPlugin(options) && !this.needsPlugin(source)) { 10273 return; 10274 } 10275 10276 const optionsCast = options; 10277 10278 if (source === null || source === void 0 ? void 0 : source.emitters) { 10279 if ((source === null || source === void 0 ? void 0 : source.emitters) instanceof Array) { 10280 optionsCast.emitters = source === null || source === void 0 ? void 0 : source.emitters.map(s => { 10281 const tmp = new Emitter(); 10282 tmp.load(s); 10283 return tmp; 10284 }); 10285 } else { 10286 let emitterOptions = optionsCast.emitters; 10287 10288 if ((emitterOptions === null || emitterOptions === void 0 ? void 0 : emitterOptions.load) === undefined) { 10289 optionsCast.emitters = emitterOptions = new Emitter(); 10290 } 10291 10292 emitterOptions.load(source === null || source === void 0 ? void 0 : source.emitters); 10293 } 10294 } 10295 10296 const interactivityEmitters = (_b = (_a = source === null || source === void 0 ? void 0 : source.interactivity) === null || _a === void 0 ? void 0 : _a.modes) === null || _b === void 0 ? void 0 : _b.emitters; 10297 10298 if (interactivityEmitters) { 10299 if (interactivityEmitters instanceof Array) { 10300 optionsCast.interactivity.modes.emitters = interactivityEmitters.map(s => { 10301 const tmp = new Emitter(); 10302 tmp.load(s); 10303 return tmp; 10304 }); 10305 } else { 10306 let emitterOptions = optionsCast.interactivity.modes.emitters; 10307 10308 if ((emitterOptions === null || emitterOptions === void 0 ? void 0 : emitterOptions.load) === undefined) { 10309 optionsCast.interactivity.modes.emitters = emitterOptions = new Emitter(); 10310 } 10311 10312 emitterOptions.load(interactivityEmitters); 10313 } 10314 } 10315 } 10316 10317 } 10318 10319 const EmittersPlugin_plugin = new EmittersPlugin(); 10320 10321 10322 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Enums/InlineArrangement.js 10323 var InlineArrangement; 10324 10325 (function (InlineArrangement) { 10326 InlineArrangement["equidistant"] = "equidistant"; 10327 InlineArrangement["onePerPoint"] = "one-per-point"; 10328 InlineArrangement["perPoint"] = "per-point"; 10329 InlineArrangement["randomLength"] = "random-length"; 10330 InlineArrangement["randomPoint"] = "random-point"; 10331 })(InlineArrangement || (InlineArrangement = {})); 10332 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Enums/MoveType.js 10333 var MoveType; 10334 10335 (function (MoveType) {
10336 MoveType["path"] = "path"; 10337 MoveType["radius"] = "radius"; 10338 })(MoveType || (MoveType = {})); 10339 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Enums/Type.js 10340 var Type; 10341 10342 (function (Type) { 10343 Type["inline"] = "inline"; 10344 Type["inside"] = "inside"; 10345 Type["outside"] = "outside"; 10346 Type["none"] = "none"; 10347 })(Type || (Type = {})); 10348 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Enums/index.js 10349 10350 10351 10352 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Options/Classes/DrawStroke.js 10353 10354 10355 class DrawStroke { 10356 constructor() { 10357 this.color = new OptionsColor(); 10358 this.width = 0.5; 10359 this.opacity = 1; 10360 } 10361 10362 load(data) { 10363 var _a; 10364 10365 if (data !== undefined) { 10366 this.color = OptionsColor.create(this.color, data.color); 10367 10368 if (typeof this.color.value === "string") { 10369 this.opacity = (_a = ColorUtils.stringToAlpha(this.color.value)) !== null && _a !== void 0 ? _a : this.opacity; 10370 } 10371 10372 if (data.opacity !== undefined) { 10373 this.opacity = data.opacity; 10374 } 10375 10376 if (data.width !== undefined) { 10377 this.width = data.width; 10378 } 10379 } 10380 } 10381 10382 } 10383 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Options/Classes/Draw.js 10384 10385 10386 class Draw { 10387 constructor() { 10388 this.enable = false; 10389 this.stroke = new DrawStroke(); 10390 } 10391 10392 get lineWidth() { 10393 return this.stroke.width; 10394 } 10395 10396 set lineWidth(value) { 10397 this.stroke.width = value; 10398 } 10399 10400 get lineColor() { 10401 return this.stroke.color; 10402 } 10403 10404 set lineColor(value) { 10405 this.stroke.color = OptionsColor.create(this.stroke.color, value); 10406 } 10407 10408 load(data) { 10409 var _a; 10410 10411 if (data !== undefined) { 10412 if (data.enable !== undefined) { 10413 this.enable = data.enable; 10414 } 10415 10416 const stroke = (_a = data.stroke) !== null && _a !== void 0 ? _a : { 10417 color: data.lineColor, 10418 width: data.lineWidth 10419 }; 10420 this.stroke.load(stroke); 10421 } 10422 } 10423 10424 } 10425 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Options/Classes/Move.js 10426 10427 class Move_Move { 10428 constructor() { 10429 this.radius = 10; 10430 this.type = MoveType.path; 10431 } 10432 10433 load(data) { 10434 if (data !== undefined) { 10435 if (data.radius !== undefined) { 10436 this.radius = data.radius; 10437 } 10438 10439 if (data.type !== undefined) { 10440 this.type = data.type; 10441 } 10442 } 10443 } 10444 10445 } 10446 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Options/Classes/Inline.js 10447 10448 class Inline { 10449 constructor() { 10450 this.arrangement = InlineArrangement.onePerPoint; 10451 } 10452 10453 load(data) { 10454 if (data !== undefined) { 10455 if (data.arrangement !== undefined) { 10456 this.arrangement = data.arrangement; 10457 } 10458 } 10459 } 10460 10461 } 10462 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Options/Classes/LocalSvg.js 10463 class LocalSvg { 10464 constructor() { 10465 this.path = []; 10466 this.size = { 10467 height: 0, 10468 width: 0 10469 }; 10470 } 10471 10472 load(data) { 10473 if (data !== undefined) { 10474 if (data.path !== undefined) { 10475 this.path = data.path; 10476 } 10477 10478 if (data.size !== undefined) { 10479 if (data.size.width !== undefined) { 10480 this.size.width = data.size.width; 10481 } 10482 10483 if (data.size.height !== undefined) { 10484 this.size.height = data.size.height; 10485 } 10486 } 10487 } 10488 } 10489 10490 } 10491 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/Options/Classes/PolygonMask.js 10492 10493 10494 10495 10496 10497 class PolygonMask { 10498 constructor() { 10499 this.draw = new Draw(); 10500 this.enable = false; 10501 this.inline = new Inline(); 10502 this.move = new Move_Move(); 10503 this.scale = 1; 10504 this.type = Type.none; 10505 } 10506
10507 get inlineArrangement() { 10508 return this.inline.arrangement; 10509 } 10510 10511 set inlineArrangement(value) { 10512 this.inline.arrangement = value; 10513 } 10514 10515 load(data) { 10516 var _a; 10517 10518 if (data !== undefined) { 10519 this.draw.load(data.draw); 10520 const inline = (_a = data.inline) !== null && _a !== void 0 ? _a : { 10521 arrangement: data.inlineArrangement 10522 }; 10523 10524 if (inline !== undefined) { 10525 this.inline.load(inline); 10526 } 10527 10528 this.move.load(data.move); 10529 10530 if (data.scale !== undefined) { 10531 this.scale = data.scale; 10532 } 10533 10534 if (data.type !== undefined) { 10535 this.type = data.type; 10536 } 10537 10538 if (data.enable !== undefined) { 10539 this.enable = data.enable; 10540 } else { 10541 this.enable = this.type !== Type.none; 10542 } 10543 10544 if (data.url !== undefined) { 10545 this.url = data.url; 10546 } 10547 10548 if (data.data !== undefined) { 10549 if (typeof data.data === "string") { 10550 this.data = data.data; 10551 } else { 10552 this.data = new LocalSvg(); 10553 this.data.load(data.data); 10554 } 10555 } 10556 10557 if (data.position !== undefined) { 10558 this.position = { 10559 x: data.position.x, 10560 y: data.position.y 10561 }; 10562 } 10563 } 10564 } 10565 10566 } 10567 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/PolygonMaskInstance.js 10568 var PolygonMaskInstance_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { 10569 function adopt(value) { 10570 return value instanceof P ? value : new P(function (resolve) { 10571 resolve(value); 10572 }); 10573 } 10574 10575 return new (P || (P = Promise))(function (resolve, reject) { 10576 function fulfilled(value) { 10577 try { 10578 step(generator.next(value)); 10579 } catch (e) { 10580 reject(e); 10581 } 10582 } 10583 10584 function rejected(value) { 10585 try { 10586 step(generator["throw"](value)); 10587 } catch (e) { 10588 reject(e); 10589 } 10590 } 10591 10592 function step(result) { 10593 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 10594 } 10595 10596 step((generator = generator.apply(thisArg, _arguments || [])).next()); 10597 }); 10598 }; 10599 10600 10601 10602 10603 10604 function polygonBounce(particle) { 10605 particle.velocity.horizontal = particle.velocity.vertical / 2 - particle.velocity.horizontal; 10606 particle.velocity.vertical = particle.velocity.horizontal / 2 - particle.velocity.vertical; 10607 } 10608 10609 function drawPolygonMask(context, rawData, stroke) { 10610 const color = ColorUtils.colorToRgb(stroke.color); 10611 10612 if (!color) { 10613 return; 10614 } 10615 10616 context.beginPath(); 10617 context.moveTo(rawData[0].x, rawData[0].y); 10618 10619 for (const item of rawData) { 10620 context.lineTo(item.x, item.y); 10621 } 10622 10623 context.closePath(); 10624 context.strokeStyle = ColorUtils.getStyleFromRgb(color); 10625 context.lineWidth = stroke.width; 10626 context.stroke(); 10627 } 10628 10629 function drawPolygonMaskPath(context, path, stroke, position) { 10630 context.translate(position.x, position.y); 10631 const color = ColorUtils.colorToRgb(stroke.color); 10632 10633 if (!color) { 10634 return; 10635 } 10636 10637 context.strokeStyle = ColorUtils.getStyleFromRgb(color, stroke.opacity); 10638 context.lineWidth = stroke.width; 10639 context.stroke(path); 10640 } 10641 10642 function parsePaths(paths, scale, offset) { 10643 const res = []; 10644 10645 for (const path of paths) { 10646 const segments = path.element.pathSegList; 10647 const len = segments.numberOfItems; 10648 const p = { 10649 x: 0, 10650 y: 0 10651 }; 10652 10653 for (let i = 0; i < len; i++) { 10654 const segment = segments.getItem(i); 10655 const svgPathSeg = window.SVGPathSeg; 10656 10657 switch (segment.pathSegType) { 10658 case svgPathSeg.PATHSEG_MOVETO_ABS: 10659 case svgPathSeg.PATHSEG_LINETO_ABS: 10660 case svgPathSeg.PATHSEG_CURVETO_CUBIC_ABS: 10661 case svgPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: 10662 case svgPathSeg.PATHSEG_ARC_ABS: 10663 case svgPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: 10664 case svgPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: 10665 { 10666 const absSeg = segment; 10667 p.x = absSeg.x; 10668 p.y = absSeg.y; 10669 break; 10670 } 10671 10672 case svgPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: 10673 p.x = segment.x; 10674 break; 10675 10676 case svgPathSeg.PATHSEG_LINETO_VERTICAL_ABS: 10677 p.y = segment.y; 10678 break; 10679 10680 case svgPathSeg.PATHSEG_LINETO_REL: 10681 case svgPathSeg.PATHSEG_MOVETO_REL: 10682 case svgPathSeg.PATHSEG_CURVETO_CUBIC_REL: 10683 case svgPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: 10684 case svgPathSeg.PATHSEG_ARC_REL: 10685 case svgPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: 10686 case svgPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: 10687 { 10688 const relSeg = segment; 10689 p.x += relSeg.x; 10690 p.y += relSeg.y; 10691 break; 10692 } 10693 10694 case svgPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: 10695 p.x += segment.x; 10696 break; 10697 10698 case svgPathSeg.PATHSEG_LINETO_VERTICAL_REL: 10699 p.y += segment.y; 10700 break; 10701 10702 case svgPathSeg.PATHSEG_UNKNOWN: 10703 case svgPathSeg.PATHSEG_CLOSEPATH: 10704 continue; 10705 } 10706 10707 res.push({ 10708 x: p.x * scale + offset.x, 10709 y: p.y * scale + offset.y 10710 }); 10711 } 10712 } 10713 10714 return res; 10715 } 10716 10717 class PolygonMaskInstance { 10718 constructor(container) { 10719 this.container = container; 10720 this.dimension = { 10721 height: 0, 10722 width: 0 10723 }; 10724 this.path2DSupported = !!window.Path2D; 10725 this.options = new PolygonMask(); 10726 this.polygonMaskMoveRadius = this.options.move.radius * container.retina.pixelRatio; 10727 } 10728 10729 initAsync(options) { 10730 return PolygonMaskInstance_awaiter(this, void 0, void 0, function* () { 10731 this.options.load(options === null || options === void 0 ? void 0 : options.polygon); 10732 const polygonMaskOptions = this.options; 10733 this.polygonMaskMoveRadius = polygonMaskOptions.move.radius * this.container.retina.pixelRatio; 10734 10735 if (polygonMaskOptions.enable) { 10736 yield this.initRawData(); 10737 } 10738 }); 10739 } 10740 10741 resize() { 10742 const container = this.container; 10743 const options = this.options; 10744 10745 if (!(options.enable && options.type !== Type.none)) { 10746 return; 10747 } 10748 10749 if (this.redrawTimeout) { 10750 clearTimeout(this.redrawTimeout); 10751 } 10752 10753 this.redrawTimeout = window.setTimeout(() => PolygonMaskInstance_awaiter(this, void 0, void 0, function* () { 10754 yield this.initRawData(true); 10755 container.particles.redraw(); 10756 }), 250); 10757 } 10758 10759 stop() { 10760 delete this.raw; 10761 delete this.paths; 10762 } 10763 10764 particlesInitialization() { 10765 const options = this.options; 10766 10767 if (options.enable && options.type === Type.inline && (options.inline.arrangement === InlineArrangement.onePerPoint || options.inline.arrangement === InlineArrangement.perPoint)) { 10768 this.drawPoints(); 10769 return true; 10770 } 10771 10772 return false;
10773 } 10774 10775 particlePosition(position) { 10776 var _a, _b; 10777 10778 const options = this.options; 10779 10780 if (!(options.enable && ((_b = (_a = this.raw) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0)) { 10781 return; 10782 } 10783 10784 return Utils.deepExtend({}, position ? position : this.randomPoint()); 10785 } 10786 10787 particleBounce(particle) { 10788 const options = this.options; 10789 10790 if (options.enable && options.type !== Type.none && options.type !== Type.inline) { 10791 if (!this.checkInsidePolygon(particle.getPosition())) { 10792 polygonBounce(particle); 10793 return true; 10794 } 10795 } else if (options.enable && options.type === Type.inline && particle.initialPosition) { 10796 const dist = NumberUtils.getDistance(particle.initialPosition, particle.getPosition()); 10797 10798 if (dist > this.polygonMaskMoveRadius) { 10799 polygonBounce(particle); 10800 return true; 10801 } 10802 } 10803 10804 return false; 10805 } 10806 10807 clickPositionValid(position) { 10808 const options = this.options; 10809 return options.enable && options.type !== Type.none && options.type !== Type.inline && this.checkInsidePolygon(position); 10810 } 10811 10812 draw(context) { 10813 var _a; 10814 10815 if (!((_a = this.paths) === null || _a === void 0 ? void 0 : _a.length)) { 10816 return; 10817 } 10818 10819 const options = this.options; 10820 const polygonDraw = options.draw; 10821 10822 if (!(options.enable && polygonDraw.enable)) { 10823 return; 10824 } 10825 10826 const rawData = this.raw; 10827 10828 for (const path of this.paths) { 10829 const path2d = path.path2d; 10830 const path2dSupported = this.path2DSupported; 10831 10832 if (!context) { 10833 continue; 10834 } 10835 10836 if (path2dSupported && path2d && this.offset) { 10837 drawPolygonMaskPath(context, path2d, polygonDraw.stroke, this.offset); 10838 } else if (rawData) { 10839 drawPolygonMask(context, rawData, polygonDraw.stroke); 10840 } 10841 } 10842 } 10843 10844 checkInsidePolygon(position) { 10845 var _a, _b; 10846 10847 const container = this.container; 10848 const options = this.options; 10849 10850 if (!options.enable || options.type === Type.none || options.type === Type.inline) { 10851 return true; 10852 } 10853 10854 if (!this.raw) { 10855 throw new Error(Constants.noPolygonFound); 10856 } 10857 10858 const canvasSize = container.canvas.size; 10859 const x = (_a = position === null || position === void 0 ? void 0 : position.x) !== null && _a !== void 0 ? _a : Math.random() * canvasSize.width; 10860 const y = (_b = position === null || position === void 0 ? void 0 : position.y) !== null && _b !== void 0 ? _b : Math.random() * canvasSize.height; 10861 let inside = false;
10862 10863 for (let i = 0, j = this.raw.length - 1; i < this.raw.length; j = i++) { 10864 const pi = this.raw[i]; 10865 const pj = this.raw[j]; 10866 const intersect = pi.y > y !== pj.y > y && x < (pj.x - pi.x) * (y - pi.y) / (pj.y - pi.y) + pi.x; 10867 10868 if (intersect) { 10869 inside = !inside; 10870 } 10871 } 10872 10873 return options.type === Type.inside ? inside : options.type === Type.outside ? !inside : false; 10874 } 10875 10876 parseSvgPath(xml, force) { 10877 var _a, _b, _c; 10878 10879 const forceDownload = force !== null && force !== void 0 ? force : false; 10880 10881 if (this.paths !== undefined && !forceDownload) { 10882 return this.raw; 10883 } 10884 10885 const container = this.container; 10886 const options = this.options; 10887 const parser = new DOMParser(); 10888 const doc = parser.parseFromString(xml, "image/svg+xml"); 10889 const svg = doc.getElementsByTagName("svg")[0]; 10890 let svgPaths = svg.getElementsByTagName("path"); 10891 10892 if (!svgPaths.length) { 10893 svgPaths = doc.getElementsByTagName("path"); 10894 } 10895 10896 this.paths = []; 10897 10898 for (let i = 0; i < svgPaths.length; i++) { 10899 const path = svgPaths.item(i); 10900 10901 if (path) { 10902 this.paths.push({ 10903 element: path, 10904 length: path.getTotalLength() 10905 }); 10906 } 10907 } 10908 10909 const pxRatio = container.retina.pixelRatio; 10910 const scale = options.scale / pxRatio;
10911 this.dimension.width = parseFloat((_a = svg.getAttribute("width")) !== null && _a !== void 0 ? _a : "0") * scale; 10912 this.dimension.height = parseFloat((_b = svg.getAttribute("height")) !== null && _b !== void 0 ? _b : "0") * scale; 10913 const position = (_c = options.position) !== null && _c !== void 0 ? _c : { 10914 x: 50, 10915 y: 50 10916 }; 10917 this.offset = { 10918 x: container.canvas.size.width * position.x / (100 * pxRatio) - this.dimension.width / 2, 10919 y: container.canvas.size.height * position.y / (100 * pxRatio) - this.dimension.height / 2 10920 }; 10921 return parsePaths(this.paths, scale, this.offset); 10922 } 10923 10924 downloadSvgPath(svgUrl, force) { 10925 return PolygonMaskInstance_awaiter(this, void 0, void 0, function* () { 10926 const options = this.options; 10927 const url = svgUrl || options.url; 10928 const forceDownload = force !== null && force !== void 0 ? force : false; 10929 10930 if (!url || this.paths !== undefined && !forceDownload) { 10931 return this.raw; 10932 } 10933 10934 const req = yield fetch(url); 10935 10936 if (!req.ok) { 10937 throw new Error("tsParticles Error - Error occurred during polygon mask download"); 10938 } 10939 10940 return this.parseSvgPath(yield req.text(), force); 10941 }); 10942 } 10943 10944 drawPoints() { 10945 if (!this.raw) { 10946 return; 10947 } 10948 10949 for (const item of this.raw) { 10950 this.container.particles.addParticle({ 10951 x: item.x, 10952 y: item.y 10953 }); 10954 } 10955 } 10956 10957 randomPoint() { 10958 const container = this.container; 10959 const options = this.options; 10960 let position; 10961 10962 if (options.type === Type.inline) { 10963 switch (options.inline.arrangement) { 10964 case InlineArrangement.randomPoint: 10965 position = this.getRandomPoint(); 10966 break; 10967 10968 case InlineArrangement.randomLength: 10969 position = this.getRandomPointByLength(); 10970 break; 10971 10972 case InlineArrangement.equidistant: 10973 position = this.getEquidistantPointByIndex(container.particles.count); 10974 break; 10975 10976 case InlineArrangement.onePerPoint: 10977 case InlineArrangement.perPoint: 10978 default: 10979 position = this.getPointByIndex(container.particles.count); 10980 } 10981 } else { 10982 position = { 10983 x: Math.random() * container.canvas.size.width, 10984 y: Math.random() * container.canvas.size.height 10985 }; 10986 } 10987 10988 if (this.checkInsidePolygon(position)) { 10989 return position; 10990 } else { 10991 return this.randomPoint(); 10992 } 10993 } 10994 10995 getRandomPoint() { 10996 if (!this.raw || !this.raw.length) { 10997 throw new Error(Constants.noPolygonDataLoaded); 10998 } 10999 11000 const coords = Utils.itemFromArray(this.raw); 11001 return { 11002 x: coords.x, 11003 y: coords.y 11004 }; 11005 } 11006 11007 getRandomPointByLength() { 11008 var _a, _b, _c; 11009 11010 const options = this.options; 11011 11012 if (!this.raw || !this.raw.length || !((_a = this.paths) === null || _a === void 0 ? void 0 : _a.length)) { 11013 throw new Error(Constants.noPolygonDataLoaded); 11014 } 11015 11016 const path = Utils.itemFromArray(this.paths); 11017 const distance = Math.floor(Math.random() * path.length) + 1; 11018 const point = path.element.getPointAtLength(distance); 11019 return { 11020 x: point.x * options.scale + (((_b = this.offset) === null || _b === void 0 ? void 0 : _b.x) || 0), 11021 y: point.y * options.scale + (((_c = this.offset) === null || _c === void 0 ? void 0 : _c.y) || 0) 11022 }; 11023 } 11024 11025 getEquidistantPointByIndex(index) { 11026 var _a, _b, _c, _d, _e, _f, _g; 11027 11028 const options = this.container.options; 11029 const polygonMaskOptions = this.options; 11030 if (!this.raw || !this.raw.length || !((_a = this.paths) === null || _a === void 0 ? void 0 : _a.length)) throw new Error(Constants.noPolygonDataLoaded); 11031 let offset = 0; 11032 let point; 11033 const totalLength = this.paths.reduce((tot, path) => tot + path.length, 0); 11034 const distance = totalLength / options.particles.number.value; 11035 11036 for (const path of this.paths) { 11037 const pathDistance = distance * index - offset; 11038 11039 if (pathDistance <= path.length) { 11040 point = path.element.getPointAtLength(pathDistance); 11041 break; 11042 } else { 11043 offset += path.length; 11044 } 11045 } 11046 11047 return { 11048 x: ((_b = point === null || point === void 0 ? void 0 : point.x) !== null && _b !== void 0 ? _b : 0) * polygonMaskOptions.scale + ((_d = (_c = this.offset) === null || _c === void 0 ? void 0 : _c.x) !== null && _d !== void 0 ? _d : 0), 11049 y: ((_e = point === null || point === void 0 ? void 0 : point.y) !== null && _e !== void 0 ? _e : 0) * polygonMaskOptions.scale + ((_g = (_f = this.offset) === null || _f === void 0 ? void 0 : _f.y) !== null && _g !== void 0 ? _g : 0) 11050 }; 11051 } 11052 11053 getPointByIndex(index) { 11054 if (!this.raw || !this.raw.length) { 11055 throw new Error(Constants.noPolygonDataLoaded); 11056 } 11057 11058 const coords = this.raw[index % this.raw.length]; 11059 return { 11060 x: coords.x, 11061 y: coords.y 11062 }; 11063 } 11064 11065 createPath2D() { 11066 var _a, _b; 11067 11068 const options = this.options; 11069 11070 if (!this.path2DSupported || !((_a = this.paths) === null || _a === void 0 ? void 0 : _a.length)) { 11071 return; 11072 } 11073 11074 for (const path of this.paths) { 11075 const pathData = (_b = path.element) === null || _b === void 0 ? void 0 : _b.getAttribute("d"); 11076 11077 if (pathData) { 11078 const path2d = new Path2D(pathData); 11079 const matrix = document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGMatrix(); 11080 const finalPath = new Path2D(); 11081 const transform = matrix.scale(options.scale); 11082 11083 if (finalPath.addPath) { 11084 finalPath.addPath(path2d, transform); 11085 path.path2d = finalPath; 11086 } else { 11087 delete path.path2d; 11088 } 11089 } else { 11090 delete path.path2d; 11091 } 11092 11093 if (path.path2d || !this.raw) { 11094 continue; 11095 } 11096 11097 path.path2d = new Path2D(); 11098 path.path2d.moveTo(this.raw[0].x, this.raw[0].y); 11099 this.raw.forEach((pos, i) => { 11100 var _a; 11101 11102 if (i > 0) { 11103 (_a = path.path2d) === null || _a === void 0 ? void 0 : _a.lineTo(pos.x, pos.y); 11104 } 11105 }); 11106 path.path2d.closePath(); 11107 } 11108 } 11109 11110 initRawData(force) { 11111 return PolygonMaskInstance_awaiter(this, void 0, void 0, function* () { 11112 const options = this.options; 11113 11114 if (options.url) { 11115 this.raw = yield this.downloadSvgPath(options.url, force); 11116 } else if (options.data) { 11117 const data = options.data; 11118 let svg; 11119 11120 if (typeof data !== "string") { 11121 const path = data.path instanceof Array ? data.path.map(t => `<path d="${t}" />`).join("") : `<path d="${data.path}" />`; 11122 const namespaces = 'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"';
11123 svg = `<svg ${namespaces} width="${data.size.width}" height="${data.size.height}">${path}</svg>`; 11124 } else { 11125 svg = data; 11126 } 11127 11128 this.raw = this.parseSvgPath(svg, force); 11129 } 11130 11131 this.createPath2D(); 11132 }); 11133 } 11134 11135 } 11136 // CONCATENATED MODULE: ./dist/browser/Plugins/PolygonMask/PolygonMaskPlugin.js 11137 11138 11139 11140 11141 class PolygonMaskPlugin { 11142 constructor() { 11143 this.id = "polygonMask"; 11144 } 11145 11146 getPlugin(container) { 11147 return new PolygonMaskInstance(container); 11148 } 11149 11150 needsPlugin(options) { 11151 var _a, _b, _c; 11152 11153 return (_b = (_a = options === null || options === void 0 ? void 0 : options.polygon) === null || _a === void 0 ? void 0 : _a.enable) !== null && _b !== void 0 ? _b : ((_c = options === null || options === void 0 ? void 0 : options.polygon) === null || _c === void 0 ? void 0 : _c.type) !== undefined && options.polygon.type !== Type.none; 11154 } 11155 11156 loadOptions(options, source) { 11157 if (!this.needsPlugin(source)) { 11158 return; 11159 } 11160 11161 const optionsCast = options; 11162 let polygonOptions = optionsCast.polygon; 11163 11164 if ((polygonOptions === null || polygonOptions === void 0 ? void 0 : polygonOptions.load) === undefined) { 11165 optionsCast.polygon = polygonOptions = new PolygonMask(); 11166 } 11167 11168 polygonOptions.load(source === null || source === void 0 ? void 0 : source.polygon); 11169 } 11170 11171 } 11172 11173 const PolygonMaskPlugin_plugin = new PolygonMaskPlugin(); 11174 11175 11176 // CONCATENATED MODULE: ./dist/browser/main.js 11177 11178 11179 11180 11181 class Main extends MainSlim { 11182 constructor() { 11183 super(); 11184 this.addPlugin(AbsorbersPlugin_plugin); 11185 this.addPlugin(EmittersPlugin_plugin); 11186 this.addPlugin(PolygonMaskPlugin_plugin); 11187 } 11188 11189 } 11190 // CONCATENATED MODULE: ./dist/browser/Types/index.js 11191 11192 11193 11194 11195 // CONCATENATED MODULE: ./dist/browser/index.js 11196 11197 11198 11199 const tsParticles = new Main(); 11200 tsParticles.init(); 11201 const { 11202 particlesJS, 11203 pJSDom 11204 } = initPjs(tsParticles); 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 /***/ }) 11215 11216 /******/ }); 11217 /************************************************************************/ 11218 /******/ // The module cache 11219 /******/ var __webpack_module_cache__ = {}; 11220 /******/ 11221 /******/ // The require function 11222 /******/ function __webpack_require__(moduleId) { 11223 /******/ // Check if module is in cache 11224 /******/ if(__webpack_module_cache__[moduleId]) { 11225 /******/ return __webpack_module_cache__[moduleId].exports; 11226 /******/ } 11227 /******/ // Create a new module (and put it into the cache) 11228 /******/ var module = __webpack_module_cache__[moduleId] = { 11229 /******/ // no module.id needed 11230 /******/ // no module.loaded needed 11231 /******/ exports: {} 11232 /******/ }; 11233 /******/ 11234 /******/ // Execute the module function 11235 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 11236 /******/ 11237 /******/ // Return the exports of the module 11238 /******/ return module.exports; 11239 /******/ } 11240 /******/ 11241 /************************************************************************/ 11242 /******/ /* webpack/runtime/define property getters */ 11243 /******/ (() => { 11244 /******/ // define getter functions for harmony exports 11245 /******/ __webpack_require__.d = (exports, definition) => { 11246 /******/ for(var key in definition) { 11247 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 11248 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 11249 /******/ } 11250 /******/ } 11251 /******/ }; 11252 /******/ })(); 11253 /******/ 11254 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 11255 /******/ (() => { 11256 /******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop) 11257 /******/ })(); 11258 /******/
11259 /******/ /* webpack/runtime/make namespace object */ 11260 /******/ (() => { 11261 /******/ // define __esModule on exports 11262 /******/ __webpack_require__.r = (exports) => { 11263 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 11264 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 11265 /******/ } 11266 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 11267 /******/ }; 11268 /******/ })(); 11269 /******/ 11270 /************************************************************************/ 11271 /******/ // module exports must be returned from runtime so entry inlining is disabled 11272 /******/ // startup 11273 /******/ // Load entry module and return exports 11274 /******/ return __webpack_require__(714); 11275 /******/ })() 11276 ; 11277 }); 11278 11279 } )( jQuery ); 11280
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.