@tsparticles/path-svg 4.0.0-beta.12 → 4.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/browser.js +5 -0
- package/browser/index.js +6 -6
- package/browser/index.lazy.js +12 -0
- package/cjs/browser.js +5 -0
- package/cjs/index.js +6 -6
- package/cjs/index.lazy.js +12 -0
- package/esm/browser.js +5 -0
- package/esm/index.js +6 -6
- package/esm/index.lazy.js +12 -0
- package/package.json +10 -3
- package/report.html +4949 -94
- package/tsparticles.path.svg.js +172 -350
- package/tsparticles.path.svg.min.js +1 -2
- package/types/browser.d.ts +1 -0
- package/types/index.lazy.d.ts +3 -0
- package/844.min.js +0 -1
- package/dist_browser_SVGPathGenerator_js.js +0 -50
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Author : Matteo Bruni
|
|
3
|
-
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
-
* Demo / Generator : https://particles.js.org/
|
|
5
|
-
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
-
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-beta.12
|
|
8
|
-
*/
|
|
9
|
-
"use strict";
|
|
10
|
-
/*
|
|
11
|
-
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
-
* This devtool is neither made for production nor for readable output files.
|
|
13
|
-
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
-
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
-
* or disable the default devtool with "devtool: false".
|
|
16
|
-
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
-
*/
|
|
18
|
-
(this["webpackChunk_tsparticles_path_svg"] = this["webpackChunk_tsparticles_path_svg"] || []).push([["dist_browser_SVGPathGenerator_js"],{
|
|
19
|
-
|
|
20
|
-
/***/ "./dist/browser/SVGPathGenerator.js"
|
|
21
|
-
/*!******************************************!*\
|
|
22
|
-
!*** ./dist/browser/SVGPathGenerator.js ***!
|
|
23
|
-
\******************************************/
|
|
24
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
-
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SVGPathGenerator: () => (/* binding */ SVGPathGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _createSVGPaths_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./createSVGPaths.js */ \"./dist/browser/createSVGPaths.js\");\n/* harmony import */ var _loadSVGFromString_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./loadSVGFromString.js */ \"./dist/browser/loadSVGFromString.js\");\n\n\n\nvar SVGPathDirection;\n(function(SVGPathDirection) {\n SVGPathDirection[SVGPathDirection[\"normal\"] = 0] = \"normal\";\n SVGPathDirection[SVGPathDirection[\"reverse\"] = 1] = \"reverse\";\n})(SVGPathDirection || (SVGPathDirection = {}));\nconst minStep = 0, minIndex = 0, minWidth = 0, minScale = 1;\nclass SVGPathGenerator {\n _container;\n _offset;\n _paths;\n _res;\n _reverse;\n _scale;\n _size;\n _width;\n constructor(container){\n this._container = container;\n this._paths = [];\n this._reverse = false;\n this._size = {\n width: 0,\n height: 0\n };\n this._scale = 1;\n this._offset = {\n x: 0,\n y: 0,\n mode: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.PixelMode.percent\n };\n this._width = 0;\n this._res = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n }\n generate(particle, delta) {\n const container = this._container, pxRatio = container.retina.pixelRatio;\n particle.svgDirection ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() > _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half ? SVGPathDirection.normal : SVGPathDirection.reverse;\n particle.svgPathIndex ??= Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * this._paths.length);\n particle.svgSpeed ??= particle.velocity.mult(particle.retina.moveSpeed * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half).length;\n particle.svgStep ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)({\n min: 0,\n max: this._paths[particle.svgPathIndex].length\n }) * pxRatio;\n particle.svgOffset ??= {\n width: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)({\n min: -this._width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half,\n max: this._width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half\n }) * pxRatio,\n height: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)({\n min: -this._width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half,\n max: this._width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half\n }) * pxRatio\n };\n particle.svgInitialPosition ??= particle.position.copy();\n particle.velocity.x = 0;\n particle.velocity.y = 0;\n if (particle.svgDirection === SVGPathDirection.normal) {\n particle.svgStep += particle.svgSpeed * delta.factor;\n } else {\n particle.svgStep -= particle.svgSpeed * delta.factor;\n }\n let path = this._paths[particle.svgPathIndex];\n const pathLength = path.length, indexOffset = 1;\n if (particle.svgStep >= pathLength) {\n particle.svgPathIndex = particle.svgPathIndex + indexOffset;\n if (particle.svgPathIndex >= this._paths.length) {\n if (this._reverse) {\n particle.svgPathIndex = this._paths.length - indexOffset;\n particle.svgDirection = SVGPathDirection.reverse;\n } else {\n particle.svgPathIndex = 0;\n particle.svgStep = 0;\n }\n }\n } else if (particle.svgStep <= minStep) {\n particle.svgPathIndex = particle.svgPathIndex - indexOffset;\n if (particle.svgPathIndex < minIndex) {\n if (this._reverse) {\n particle.svgPathIndex = 0;\n particle.svgDirection = SVGPathDirection.normal;\n } else {\n particle.svgPathIndex = this._paths.length - indexOffset;\n path = this._paths[particle.svgPathIndex];\n particle.svgStep = path.length;\n }\n }\n }\n path = this._paths[particle.svgPathIndex];\n const pathElement = path.element, pos = pathElement.getPointAtLength(particle.svgStep), canvasSize = this._container.canvas.size, offset = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getPosition)(this._offset, canvasSize), scale = this._scale * pxRatio;\n particle.position.x = (pos.x - this._size.width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half) * scale + particle.svgInitialPosition.x + offset.x + particle.svgOffset.width;\n particle.position.y = (pos.y - this._size.height * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half) * scale + particle.svgInitialPosition.y + offset.y + particle.svgOffset.height;\n this._res.x = 0;\n this._res.y = 0;\n return this._res;\n }\n init() {\n const options = this._container.actualOptions.particles.move.path.options, position = options.position ?? this._offset;\n this._reverse = options.reverse ?? this._reverse;\n this._scale = options.scale ?? minScale;\n this._offset.x = position.x;\n this._offset.y = position.y;\n this._offset.mode = position.mode;\n this._width = options.width ?? minWidth;\n if (options.url && !options.path) {\n const url = options.url;\n void (async ()=>{\n const response = await fetch(url), data = await response.text(), { paths, size } = (0,_loadSVGFromString_js__WEBPACK_IMPORTED_MODULE_2__.loadSVGFromString)(data);\n this._paths = paths;\n this._size.width = size.width;\n this._size.height = size.height;\n })();\n } else if (options.path) {\n const path = options.path;\n this._paths = (0,_createSVGPaths_js__WEBPACK_IMPORTED_MODULE_1__.createSVGPaths)(options.path.data);\n this._size.height = path.size.height;\n this._size.width = path.size.width;\n }\n }\n reset() {}\n update() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-svg/./dist/browser/SVGPathGenerator.js?\n}");
|
|
27
|
-
|
|
28
|
-
/***/ },
|
|
29
|
-
|
|
30
|
-
/***/ "./dist/browser/createSVGPaths.js"
|
|
31
|
-
/*!****************************************!*\
|
|
32
|
-
!*** ./dist/browser/createSVGPaths.js ***!
|
|
33
|
-
\****************************************/
|
|
34
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
-
|
|
36
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createSVGPaths: () => (/* binding */ createSVGPaths)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nfunction createSVGPaths(data) {\n const doc = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)();\n return data.map((d)=>{\n const element = doc.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n element.setAttribute(\"d\", d);\n return {\n element,\n length: element.getTotalLength()\n };\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-svg/./dist/browser/createSVGPaths.js?\n}");
|
|
37
|
-
|
|
38
|
-
/***/ },
|
|
39
|
-
|
|
40
|
-
/***/ "./dist/browser/loadSVGFromString.js"
|
|
41
|
-
/*!*******************************************!*\
|
|
42
|
-
!*** ./dist/browser/loadSVGFromString.js ***!
|
|
43
|
-
\*******************************************/
|
|
44
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
-
|
|
46
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadSVGFromString: () => (/* binding */ loadSVGFromString)\n/* harmony export */ });\nfunction loadSVGFromString(svgText) {\n const parser = new DOMParser(), doc = parser.parseFromString(svgText, \"image/svg+xml\"), svg = doc.querySelector(\"svg\");\n if (!svg) {\n return {\n paths: [],\n size: {\n width: 0,\n height: 0\n }\n };\n }\n const pathElements = svg.querySelectorAll(\"path\"), paths = [];\n for (const node of pathElements){\n if (!(node instanceof SVGPathElement)) {\n continue;\n }\n paths.push({\n element: node,\n length: node.getTotalLength()\n });\n }\n const size = {\n width: Number.parseFloat(svg.getAttribute(\"width\") ?? \"0\"),\n height: Number.parseFloat(svg.getAttribute(\"height\") ?? \"0\")\n };\n return {\n paths,\n size\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-svg/./dist/browser/loadSVGFromString.js?\n}");
|
|
47
|
-
|
|
48
|
-
/***/ }
|
|
49
|
-
|
|
50
|
-
}]);
|