@tsparticles/path-svg 4.0.0-alpha.2 → 4.0.0-alpha.20

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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-alpha.2
7
+ * v4.0.0-alpha.20
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -28,16 +28,6 @@ return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
30
30
 
31
- /***/ "./dist/browser/index.js"
32
- /*!*******************************!*\
33
- !*** ./dist/browser/index.js ***!
34
- \*******************************/
35
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
36
-
37
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadSVGPath: () => (/* binding */ loadSVGPath),\n/* harmony export */ svgPathName: () => (/* binding */ svgPathName)\n/* harmony export */ });\nconst svgPathName = \"svgPathGenerator\";\nfunction loadSVGPath(engine) {\n engine.checkVersion(\"4.0.0-alpha.2\");\n engine.register(async e => {\n const {\n SVGPathGenerator\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_SVGPathGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./SVGPathGenerator.js */ \"./dist/browser/SVGPathGenerator.js\"));\n e.addPathGenerator(svgPathName, new SVGPathGenerator());\n });\n}\n\n//# sourceURL=webpack://@tsparticles/path-svg/./dist/browser/index.js?\n}");
38
-
39
- /***/ },
40
-
41
31
  /***/ "@tsparticles/engine"
42
32
  /*!*********************************************************************************************************************************!*\
43
33
  !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
@@ -46,6 +36,16 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
46
36
 
47
37
  module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
48
38
 
39
+ /***/ },
40
+
41
+ /***/ "./dist/browser/index.js"
42
+ /*!*******************************!*\
43
+ !*** ./dist/browser/index.js ***!
44
+ \*******************************/
45
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
46
+
47
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadSVGPath: () => (/* binding */ loadSVGPath),\n/* harmony export */ svgPathName: () => (/* binding */ svgPathName)\n/* harmony export */ });\nconst svgPathName = \"svgPathGenerator\";\nasync function loadSVGPath(engine) {\n engine.checkVersion(\"4.0.0-alpha.20\");\n await engine.register((e)=>{\n e.addPathGenerator(svgPathName, async (container)=>{\n const { SVGPathGenerator } = await __webpack_require__.e(/*! import() */ \"dist_browser_SVGPathGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./SVGPathGenerator.js */ \"./dist/browser/SVGPathGenerator.js\"));\n return new SVGPathGenerator(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-svg/./dist/browser/index.js?\n}");
48
+
49
49
  /***/ }
50
50
 
51
51
  /******/ });
@@ -1,2 +1,2 @@
1
- /*! For license information please see tsparticles.path.svg.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={303(t){t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/path-svg:",a.l=(e,o,n,i)=>{if(t[e])t[e].push(o);else{var s,c;if(void 0!==n)for(var p=document.getElementsByTagName("script"),l=0;l<p.length;l++){var u=p[l];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==r+n){s=u;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",a.nc&&s.setAttribute("nonce",a.nc),s.setAttribute("data-webpack",r+n),s.src=e),t[e]=[o];var d=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var n=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),n&&n.forEach((e=>e(o))),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),c&&document.head.appendChild(s)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={258:0};a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise(((r,n)=>o=e[t]=[r,n]));r.push(o[2]=n);var i=a.p+a.u(t),s=new Error;a.l(i,(r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+i+")",s.name="ChunkLoadError",s.type=n,s.request=i,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,n,[i,s,c]=r,p=0;if(i.some((t=>0!==e[t]))){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);if(c)c(a)}for(t&&t(r);p<i.length;p++)n=i[p],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_path_svg=this.webpackChunk_tsparticles_path_svg||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};a.r(i),a.d(i,{loadSVGPath:()=>c,svgPathName:()=>s});const s="svgPathGenerator";function c(e){e.checkVersion("4.0.0-alpha.2"),e.register((async e=>{const{SVGPathGenerator:t}=await a.e(747).then(a.bind(a,747));e.addPathGenerator(s,new t)}))}return i})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,e=>(()=>{"use strict";var t,r,o,n={303(t){t.exports=e}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>""+e+".min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s={},i.l=(e,t,r,o)=>{if(s[e])return void s[e].push(t);if(void 0!==r)for(var n,a,c=document.getElementsByTagName("script"),p=0;p<c.length;p++){var l=c[p];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")=="@tsparticles/path-svg:"+r){n=l;break}}n||(a=!0,(n=document.createElement("script")).charset="utf-8",i.nc&&n.setAttribute("nonce",i.nc),n.setAttribute("data-webpack","@tsparticles/path-svg:"+r),n.src=e),s[e]=[t];var u=(t,r)=>{n.onerror=n.onload=null,clearTimeout(d);var o=s[e];if(delete s[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),a&&document.head.appendChild(n)},i.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.g.importScripts&&(c=i.g.location+"");var s,c,p=i.g.document;if(!c&&p&&(p.currentScript&&"SCRIPT"===p.currentScript.tagName.toUpperCase()&&(c=p.currentScript.src),!c)){var l=p.getElementsByTagName("script");if(l.length)for(var u=l.length-1;u>-1&&(!c||!/^http(s?):/.test(c));)c=l[u--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");i.p=c=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={258:0},i.f.j=(e,r)=>{var o=i.o(t,e)?t[e]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=t[e]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(e),s=Error();i.l(a,r=>{if(i.o(t,e)&&(0!==(o=t[e])&&(t[e]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+e+` failed.
2
+ (`+n+": "+a+")",s.name="ChunkLoadError",s.type=n,s.request=a,o[1](s)}},"chunk-"+e,e)}},r=(e,r)=>{var o,n,[a,s,c]=r,p=0;if(a.some(e=>0!==t[e])){for(o in s)i.o(s,o)&&(i.m[o]=s[o]);c&&c(i)}for(e&&e(r);p<a.length;p++)n=a[p],i.o(t,n)&&t[n]&&t[n][0](),t[n]=0},(o=this.webpackChunk_tsparticles_path_svg=this.webpackChunk_tsparticles_path_svg||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};i.r(d),i.d(d,{loadSVGPath:()=>h,svgPathName:()=>f});let f="svgPathGenerator";async function h(e){e.checkVersion("4.0.0-alpha.20"),await e.register(e=>{e.addPathGenerator(f,async e=>{let{SVGPathGenerator:t}=await i.e(905).then(i.bind(i,905));return new t(e)})})}return d})());
@@ -12,15 +12,16 @@ type SVGPathParticle = Particle & {
12
12
  svgStep?: number;
13
13
  };
14
14
  export declare class SVGPathGenerator implements IMovePathGenerator {
15
+ private readonly _container;
15
16
  private readonly _offset;
16
17
  private _paths;
17
18
  private _reverse;
18
19
  private _scale;
19
20
  private readonly _size;
20
21
  private _width;
21
- constructor();
22
+ constructor(container: Container);
22
23
  generate(particle: SVGPathParticle, delta: IDelta): Vector;
23
- init(container: Container): void;
24
+ init(): void;
24
25
  reset(): void;
25
26
  update(): void;
26
27
  }
@@ -0,0 +1,2 @@
1
+ import type { SVGPathData } from "./types.js";
2
+ export declare function createSVGPaths(data: string[]): SVGPathData[];
package/types/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { type Engine } from "@tsparticles/engine";
2
2
  export declare const svgPathName = "svgPathGenerator";
3
- export declare function loadSVGPath(engine: Engine): void;
3
+ export declare function loadSVGPath(engine: Engine): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import type { SVGPathData } from "./types.js";
2
+ export interface LoadedSVGPaths {
3
+ paths: SVGPathData[];
4
+ size: {
5
+ height: number;
6
+ width: number;
7
+ };
8
+ }
9
+ export declare function loadSVGFromString(svgText: string): LoadedSVGPaths;
@@ -0,0 +1,4 @@
1
+ export interface SVGPathData {
2
+ element: SVGPathElement;
3
+ length: number;
4
+ }
@@ -4,13 +4,15 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "./createSVGPaths.js", "./loadSVGFromString.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SVGPathGenerator = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
+ const createSVGPaths_js_1 = require("./createSVGPaths.js");
15
+ const loadSVGFromString_js_1 = require("./loadSVGFromString.js");
14
16
  var SVGPathDirection;
15
17
  (function (SVGPathDirection) {
16
18
  SVGPathDirection[SVGPathDirection["normal"] = 0] = "normal";
@@ -18,7 +20,15 @@
18
20
  })(SVGPathDirection || (SVGPathDirection = {}));
19
21
  const defaultSpeed = 1, minStep = 0, minIndex = 0, minWidth = 0, minScale = 1;
20
22
  class SVGPathGenerator {
21
- constructor() {
23
+ _container;
24
+ _offset;
25
+ _paths;
26
+ _reverse;
27
+ _scale;
28
+ _size;
29
+ _width;
30
+ constructor(container) {
31
+ this._container = container;
22
32
  this._paths = [];
23
33
  this._reverse = false;
24
34
  this._size = { width: 0, height: 0 };
@@ -27,7 +37,7 @@
27
37
  this._width = 0;
28
38
  }
29
39
  generate(particle, delta) {
30
- const container = particle.container, pxRatio = container.retina.pixelRatio;
40
+ const container = this._container, pxRatio = container.retina.pixelRatio;
31
41
  particle.svgDirection ??= (0, engine_1.getRandom)() > engine_1.half ? SVGPathDirection.normal : SVGPathDirection.reverse;
32
42
  particle.svgPathIndex ??= Math.floor((0, engine_1.getRandom)() * this._paths.length);
33
43
  particle.svgSpeed ??= particle.velocity.mult((particle.retina.moveSpeed ?? defaultSpeed) * engine_1.half).length;
@@ -75,21 +85,15 @@
75
85
  }
76
86
  }
77
87
  path = this._paths[particle.svgPathIndex];
78
- const pathElement = path.element, pos = pathElement.getPointAtLength(particle.svgStep), canvasSize = particle.container.canvas.size, offset = (0, engine_1.getPosition)(this._offset, canvasSize), scale = this._scale * pxRatio;
88
+ const pathElement = path.element, pos = pathElement.getPointAtLength(particle.svgStep), canvasSize = this._container.canvas.size, offset = (0, engine_1.getPosition)(this._offset, canvasSize), scale = this._scale * pxRatio;
79
89
  particle.position.x =
80
- (pos.x - this._size.width * engine_1.half) * scale +
81
- particle.svgInitialPosition.x +
82
- offset.x +
83
- particle.svgOffset.width;
90
+ (pos.x - this._size.width * engine_1.half) * scale + particle.svgInitialPosition.x + offset.x + particle.svgOffset.width;
84
91
  particle.position.y =
85
- (pos.y - this._size.height * engine_1.half) * scale +
86
- particle.svgInitialPosition.y +
87
- offset.y +
88
- particle.svgOffset.height;
92
+ (pos.y - this._size.height * engine_1.half) * scale + particle.svgInitialPosition.y + offset.y + particle.svgOffset.height;
89
93
  return engine_1.Vector.origin;
90
94
  }
91
- init(container) {
92
- const options = container.actualOptions.particles.move.path.options, position = options.position ?? this._offset;
95
+ init() {
96
+ const options = this._container.actualOptions.particles.move.path.options, position = options.position ?? this._offset;
93
97
  this._reverse = options.reverse ?? this._reverse;
94
98
  this._scale = options.scale ?? minScale;
95
99
  this._offset.x = position.x;
@@ -99,37 +103,15 @@
99
103
  if (options.url && !options.path) {
100
104
  const url = options.url;
101
105
  void (async () => {
102
- const response = await fetch(url), data = await response.text();
103
- const parser = new DOMParser(), doc = parser.parseFromString(data, "image/svg+xml"), firstIndex = 0, svg = doc.getElementsByTagName("svg")[firstIndex];
104
- let svgPaths = svg.getElementsByTagName("path");
105
- if (!svgPaths.length) {
106
- svgPaths = doc.getElementsByTagName("path");
107
- }
108
- this._paths = [];
109
- for (let i = 0; i < svgPaths.length; i++) {
110
- const path = svgPaths.item(i);
111
- if (path) {
112
- this._paths.push({
113
- element: path,
114
- length: path.getTotalLength(),
115
- });
116
- }
117
- }
118
- this._size.height = Number.parseFloat(svg.getAttribute("height") ?? "0");
119
- this._size.width = Number.parseFloat(svg.getAttribute("width") ?? "0");
106
+ const response = await fetch(url), data = await response.text(), { paths, size } = (0, loadSVGFromString_js_1.loadSVGFromString)(data);
107
+ this._paths = paths;
108
+ this._size.width = size.width;
109
+ this._size.height = size.height;
120
110
  })();
121
111
  }
122
112
  else if (options.path) {
123
113
  const path = options.path;
124
- this._paths = [];
125
- for (const item of path.data) {
126
- const element = (0, engine_1.safeDocument)().createElementNS("http://www.w3.org/2000/svg", "path");
127
- element.setAttribute("d", item);
128
- this._paths.push({
129
- element,
130
- length: element.getTotalLength(),
131
- });
132
- }
114
+ this._paths = (0, createSVGPaths_js_1.createSVGPaths)(options.path.data);
133
115
  this._size.height = path.size.height;
134
116
  this._size.width = path.size.width;
135
117
  }
@@ -0,0 +1,25 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.createSVGPaths = createSVGPaths;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ function createSVGPaths(data) {
15
+ const doc = (0, engine_1.safeDocument)();
16
+ return data.map(d => {
17
+ const element = doc.createElementNS("http://www.w3.org/2000/svg", "path");
18
+ element.setAttribute("d", d);
19
+ return {
20
+ element,
21
+ length: element.getTotalLength(),
22
+ };
23
+ });
24
+ }
25
+ });
package/umd/index.js CHANGED
@@ -46,11 +46,13 @@ var __importStar = (this && this.__importStar) || (function () {
46
46
  exports.svgPathName = void 0;
47
47
  exports.loadSVGPath = loadSVGPath;
48
48
  exports.svgPathName = "svgPathGenerator";
49
- function loadSVGPath(engine) {
50
- engine.checkVersion("4.0.0-alpha.2");
51
- engine.register(async (e) => {
52
- const { SVGPathGenerator } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./SVGPathGenerator.js"))) : new Promise((resolve_1, reject_1) => { require(["./SVGPathGenerator.js"], resolve_1, reject_1); }).then(__importStar));
53
- e.addPathGenerator(exports.svgPathName, new SVGPathGenerator());
49
+ async function loadSVGPath(engine) {
50
+ engine.checkVersion("4.0.0-alpha.20");
51
+ await engine.register(e => {
52
+ e.addPathGenerator(exports.svgPathName, async (container) => {
53
+ const { SVGPathGenerator } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./SVGPathGenerator.js"))) : new Promise((resolve_1, reject_1) => { require(["./SVGPathGenerator.js"], resolve_1, reject_1); }).then(__importStar));
54
+ return new SVGPathGenerator(container);
55
+ });
54
56
  });
55
57
  }
56
58
  });
@@ -0,0 +1,37 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.loadSVGFromString = loadSVGFromString;
13
+ function loadSVGFromString(svgText) {
14
+ const parser = new DOMParser(), doc = parser.parseFromString(svgText, "image/svg+xml"), svg = doc.querySelector("svg");
15
+ if (!svg) {
16
+ return { paths: [], size: { width: 0, height: 0 } };
17
+ }
18
+ const pathElements = svg.querySelectorAll("path"), paths = [];
19
+ for (const node of pathElements) {
20
+ if (!(node instanceof SVGPathElement)) {
21
+ continue;
22
+ }
23
+ paths.push({
24
+ element: node,
25
+ length: node.getTotalLength(),
26
+ });
27
+ }
28
+ const size = {
29
+ width: Number.parseFloat(svg.getAttribute("width") ?? "0"),
30
+ height: Number.parseFloat(svg.getAttribute("height") ?? "0"),
31
+ };
32
+ return {
33
+ paths,
34
+ size,
35
+ };
36
+ }
37
+ });
package/umd/types.js ADDED
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
package/747.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 747.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_path_svg=this.webpackChunk_tsparticles_path_svg||[]).push([[747],{747(t,e,s){s.d(e,{SVGPathGenerator:()=>a});var h,i=s(303);!function(t){t[t.normal=0]="normal",t[t.reverse=1]="reverse"}(h||(h={}));class a{constructor(){this._paths=[],this._reverse=!1,this._size={width:0,height:0},this._scale=1,this._offset={x:0,y:0,mode:i.PixelMode.percent},this._width=0}generate(t,e){const s=t.container.retina.pixelRatio;t.svgDirection??=(0,i.getRandom)()>i.half?h.normal:h.reverse,t.svgPathIndex??=Math.floor((0,i.getRandom)()*this._paths.length),t.svgSpeed??=t.velocity.mult((t.retina.moveSpeed??1)*i.half).length,t.svgStep??=(0,i.randomInRangeValue)({min:0,max:this._paths[t.svgPathIndex].length})*s,t.svgOffset??={width:(0,i.randomInRangeValue)({min:-this._width*i.half,max:this._width*i.half})*s,height:(0,i.randomInRangeValue)({min:-this._width*i.half,max:this._width*i.half})*s},t.svgInitialPosition??=t.position.copy(),t.velocity.x=0,t.velocity.y=0,t.svgDirection===h.normal?t.svgStep+=t.svgSpeed*e.factor:t.svgStep-=t.svgSpeed*e.factor;let a=this._paths[t.svgPathIndex];const n=a.length;t.svgStep>=n?(t.svgPathIndex=t.svgPathIndex+1,t.svgPathIndex>=this._paths.length&&(this._reverse?(t.svgPathIndex=this._paths.length-1,t.svgDirection=h.reverse):(t.svgPathIndex=0,t.svgStep=0))):t.svgStep<=0&&(t.svgPathIndex=t.svgPathIndex-1,t.svgPathIndex<0&&(this._reverse?(t.svgPathIndex=0,t.svgDirection=h.normal):(t.svgPathIndex=this._paths.length-1,a=this._paths[t.svgPathIndex],t.svgStep=a.length))),a=this._paths[t.svgPathIndex];const g=a.element.getPointAtLength(t.svgStep),o=t.container.canvas.size,r=(0,i.getPosition)(this._offset,o),l=this._scale*s;return t.position.x=(g.x-this._size.width*i.half)*l+t.svgInitialPosition.x+r.x+t.svgOffset.width,t.position.y=(g.y-this._size.height*i.half)*l+t.svgInitialPosition.y+r.y+t.svgOffset.height,i.Vector.origin}init(t){const e=t.actualOptions.particles.move.path.options,s=e.position??this._offset;if(this._reverse=e.reverse??this._reverse,this._scale=e.scale??1,this._offset.x=s.x,this._offset.y=s.y,this._offset.mode=s.mode,this._width=e.width??0,e.url&&!e.path){const t=e.url;(async()=>{const e=await fetch(t),s=await e.text(),h=(new DOMParser).parseFromString(s,"image/svg+xml"),i=h.getElementsByTagName("svg")[0];let a=i.getElementsByTagName("path");a.length||(a=h.getElementsByTagName("path")),this._paths=[];for(let t=0;t<a.length;t++){const e=a.item(t);e&&this._paths.push({element:e,length:e.getTotalLength()})}this._size.height=Number.parseFloat(i.getAttribute("height")??"0"),this._size.width=Number.parseFloat(i.getAttribute("width")??"0")})()}else if(e.path){const t=e.path;this._paths=[];for(const e of t.data){const t=(0,i.safeDocument)().createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",e),this._paths.push({element:t,length:t.getTotalLength()})}this._size.height=t.size.height,this._size.width=t.size.width}}reset(){}update(){}}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles SVG Path v4.0.0-alpha.2 by Matteo Bruni */
@@ -1 +0,0 @@
1
- /*! tsParticles SVG Path v4.0.0-alpha.2 by Matteo Bruni */