@tsparticles/path-svg 4.0.0-beta.0 → 4.0.0-beta.2

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/291.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_path_svg=this.webpackChunk_tsparticles_path_svg||[]).push([[291],{291(t,e,s){s.d(e,{SVGPathGenerator:()=>n});var i,h,a=s(303);s(400),(i=h||(h={}))[i.normal=0]="normal",i[i.reverse=1]="reverse";class n{_container;_offset;_paths;_res;_reverse;_scale;_size;_width;constructor(t){this._container=t,this._paths=[],this._reverse=!1,this._size={width:0,height:0},this._scale=1,this._offset={x:0,y:0,mode:a.PixelMode.percent},this._width=0,this._res=a.Vector.origin}generate(t,e){let s=this._container.retina.pixelRatio;t.svgDirection??=(0,a.getRandom)()>a.half?h.normal:h.reverse,t.svgPathIndex??=Math.floor((0,a.getRandom)()*this._paths.length),t.svgSpeed??=t.velocity.mult(t.retina.moveSpeed*a.half).length,t.svgStep??=(0,a.randomInRangeValue)({min:0,max:this._paths[t.svgPathIndex].length})*s,t.svgOffset??={width:(0,a.randomInRangeValue)({min:-this._width*a.half,max:this._width*a.half})*s,height:(0,a.randomInRangeValue)({min:-this._width*a.half,max:this._width*a.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 i=this._paths[t.svgPathIndex],n=i.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,i=this._paths[t.svgPathIndex],t.svgStep=i.length)));let r=(i=this._paths[t.svgPathIndex]).element.getPointAtLength(t.svgStep),g=this._container.canvas.size,o=(0,a.getPosition)(this._offset,g),l=this._scale*s;return t.position.x=(r.x-this._size.width*a.half)*l+t.svgInitialPosition.x+o.x+t.svgOffset.width,t.position.y=(r.y-this._size.height*a.half)*l+t.svgInitialPosition.y+o.y+t.svgOffset.height,this._res.x=0,this._res.y=0,this._res}init(){let t=this._container.actualOptions.particles.move.path.options,e=t.position??this._offset;if(this._reverse=t.reverse??this._reverse,this._scale=t.scale??1,this._offset.x=e.x,this._offset.y=e.y,this._offset.mode=e.mode,this._width=t.width??0,t.url&&!t.path){let e=t.url;(async()=>{let t=await fetch(e),{paths:s,size:i}=function(t){let e=new DOMParser().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)return{paths:[],size:{width:0,height:0}};let s=e.querySelectorAll("path"),i=[];for(let t of s)t instanceof SVGPathElement&&i.push({element:t,length:t.getTotalLength()});return{paths:i,size:{width:Number.parseFloat(e.getAttribute("width")??"0"),height:Number.parseFloat(e.getAttribute("height")??"0")}}}(await t.text());this._paths=s,this._size.width=i.width,this._size.height=i.height})()}else if(t.path){var s;let e,i=t.path;this._paths=(s=t.path.data,e=(0,a.safeDocument)(),s.map(t=>{let s=e.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("d",t),{element:s,length:s.getTotalLength()}})),this._size.height=i.size.height,this._size.width=i.size.width}}reset(){}update(){}}}}]);
@@ -1,4 +1,5 @@
1
1
  import { PixelMode, Vector, getPosition, getRandom, half, randomInRangeValue, } from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
2
3
  import { createSVGPaths } from "./createSVGPaths.js";
3
4
  import { loadSVGFromString } from "./loadSVGFromString.js";
4
5
  var SVGPathDirection;
@@ -6,7 +7,7 @@ var SVGPathDirection;
6
7
  SVGPathDirection[SVGPathDirection["normal"] = 0] = "normal";
7
8
  SVGPathDirection[SVGPathDirection["reverse"] = 1] = "reverse";
8
9
  })(SVGPathDirection || (SVGPathDirection = {}));
9
- const defaultSpeed = 1, minStep = 0, minIndex = 0, minWidth = 0, minScale = 1;
10
+ const minStep = 0, minIndex = 0, minWidth = 0, minScale = 1;
10
11
  export class SVGPathGenerator {
11
12
  _container;
12
13
  _offset;
@@ -30,7 +31,7 @@ export class SVGPathGenerator {
30
31
  const container = this._container, pxRatio = container.retina.pixelRatio;
31
32
  particle.svgDirection ??= getRandom() > half ? SVGPathDirection.normal : SVGPathDirection.reverse;
32
33
  particle.svgPathIndex ??= Math.floor(getRandom() * this._paths.length);
33
- particle.svgSpeed ??= particle.velocity.mult((particle.retina.moveSpeed ?? defaultSpeed) * half).length;
34
+ particle.svgSpeed ??= particle.velocity.mult(particle.retina.moveSpeed * half).length;
34
35
  particle.svgStep ??= randomInRangeValue({ min: 0, max: this._paths[particle.svgPathIndex].length }) * pxRatio;
35
36
  particle.svgOffset ??= {
36
37
  width: randomInRangeValue({ min: -this._width * half, max: this._width * half }) * pxRatio,
package/browser/index.js CHANGED
@@ -1,10 +1,12 @@
1
+ import {} from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
1
3
  export const svgPathName = "svgPathGenerator";
2
4
  export async function loadSVGPath(engine) {
3
- engine.checkVersion("4.0.0-beta.0");
4
- await engine.register(async (e) => {
5
+ engine.checkVersion("4.0.0-beta.2");
6
+ await engine.pluginManager.register(async (e) => {
5
7
  const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
8
  ensureBaseMoverLoaded(e);
7
- e.addPathGenerator?.(svgPathName, async (container) => {
9
+ e.pluginManager.addPathGenerator?.(svgPathName, async (container) => {
8
10
  const { SVGPathGenerator } = await import("./SVGPathGenerator.js");
9
11
  return new SVGPathGenerator(container);
10
12
  });
@@ -1,4 +1,5 @@
1
1
  import { PixelMode, Vector, getPosition, getRandom, half, randomInRangeValue, } from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
2
3
  import { createSVGPaths } from "./createSVGPaths.js";
3
4
  import { loadSVGFromString } from "./loadSVGFromString.js";
4
5
  var SVGPathDirection;
@@ -6,7 +7,7 @@ var SVGPathDirection;
6
7
  SVGPathDirection[SVGPathDirection["normal"] = 0] = "normal";
7
8
  SVGPathDirection[SVGPathDirection["reverse"] = 1] = "reverse";
8
9
  })(SVGPathDirection || (SVGPathDirection = {}));
9
- const defaultSpeed = 1, minStep = 0, minIndex = 0, minWidth = 0, minScale = 1;
10
+ const minStep = 0, minIndex = 0, minWidth = 0, minScale = 1;
10
11
  export class SVGPathGenerator {
11
12
  _container;
12
13
  _offset;
@@ -30,7 +31,7 @@ export class SVGPathGenerator {
30
31
  const container = this._container, pxRatio = container.retina.pixelRatio;
31
32
  particle.svgDirection ??= getRandom() > half ? SVGPathDirection.normal : SVGPathDirection.reverse;
32
33
  particle.svgPathIndex ??= Math.floor(getRandom() * this._paths.length);
33
- particle.svgSpeed ??= particle.velocity.mult((particle.retina.moveSpeed ?? defaultSpeed) * half).length;
34
+ particle.svgSpeed ??= particle.velocity.mult(particle.retina.moveSpeed * half).length;
34
35
  particle.svgStep ??= randomInRangeValue({ min: 0, max: this._paths[particle.svgPathIndex].length }) * pxRatio;
35
36
  particle.svgOffset ??= {
36
37
  width: randomInRangeValue({ min: -this._width * half, max: this._width * half }) * pxRatio,
package/cjs/index.js CHANGED
@@ -1,10 +1,12 @@
1
+ import {} from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
1
3
  export const svgPathName = "svgPathGenerator";
2
4
  export async function loadSVGPath(engine) {
3
- engine.checkVersion("4.0.0-beta.0");
4
- await engine.register(async (e) => {
5
+ engine.checkVersion("4.0.0-beta.2");
6
+ await engine.pluginManager.register(async (e) => {
5
7
  const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
8
  ensureBaseMoverLoaded(e);
7
- e.addPathGenerator?.(svgPathName, async (container) => {
9
+ e.pluginManager.addPathGenerator?.(svgPathName, async (container) => {
8
10
  const { SVGPathGenerator } = await import("./SVGPathGenerator.js");
9
11
  return new SVGPathGenerator(container);
10
12
  });
@@ -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-beta.0
7
+ * v4.0.0-beta.2
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -23,7 +23,7 @@
23
23
  \******************************************/
24
24
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
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 defaultSpeed = 1, 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 ?? defaultSpeed) * _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}");
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 _tsparticles_plugin_move__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-move */ \"@tsparticles/plugin-move\");\n/* harmony import */ var _createSVGPaths_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./createSVGPaths.js */ \"./dist/browser/createSVGPaths.js\");\n/* harmony import */ var _loadSVGFromString_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./loadSVGFromString.js */ \"./dist/browser/loadSVGFromString.js\");\n\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_3__.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_2__.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
27
 
28
28
  /***/ },
29
29
 
@@ -1,4 +1,5 @@
1
1
  import { PixelMode, Vector, getPosition, getRandom, half, randomInRangeValue, } from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
2
3
  import { createSVGPaths } from "./createSVGPaths.js";
3
4
  import { loadSVGFromString } from "./loadSVGFromString.js";
4
5
  var SVGPathDirection;
@@ -6,7 +7,7 @@ var SVGPathDirection;
6
7
  SVGPathDirection[SVGPathDirection["normal"] = 0] = "normal";
7
8
  SVGPathDirection[SVGPathDirection["reverse"] = 1] = "reverse";
8
9
  })(SVGPathDirection || (SVGPathDirection = {}));
9
- const defaultSpeed = 1, minStep = 0, minIndex = 0, minWidth = 0, minScale = 1;
10
+ const minStep = 0, minIndex = 0, minWidth = 0, minScale = 1;
10
11
  export class SVGPathGenerator {
11
12
  _container;
12
13
  _offset;
@@ -30,7 +31,7 @@ export class SVGPathGenerator {
30
31
  const container = this._container, pxRatio = container.retina.pixelRatio;
31
32
  particle.svgDirection ??= getRandom() > half ? SVGPathDirection.normal : SVGPathDirection.reverse;
32
33
  particle.svgPathIndex ??= Math.floor(getRandom() * this._paths.length);
33
- particle.svgSpeed ??= particle.velocity.mult((particle.retina.moveSpeed ?? defaultSpeed) * half).length;
34
+ particle.svgSpeed ??= particle.velocity.mult(particle.retina.moveSpeed * half).length;
34
35
  particle.svgStep ??= randomInRangeValue({ min: 0, max: this._paths[particle.svgPathIndex].length }) * pxRatio;
35
36
  particle.svgOffset ??= {
36
37
  width: randomInRangeValue({ min: -this._width * half, max: this._width * half }) * pxRatio,
package/esm/index.js CHANGED
@@ -1,10 +1,12 @@
1
+ import {} from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
1
3
  export const svgPathName = "svgPathGenerator";
2
4
  export async function loadSVGPath(engine) {
3
- engine.checkVersion("4.0.0-beta.0");
4
- await engine.register(async (e) => {
5
+ engine.checkVersion("4.0.0-beta.2");
6
+ await engine.pluginManager.register(async (e) => {
5
7
  const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
8
  ensureBaseMoverLoaded(e);
7
- e.addPathGenerator?.(svgPathName, async (container) => {
9
+ e.pluginManager.addPathGenerator?.(svgPathName, async (container) => {
8
10
  const { SVGPathGenerator } = await import("./SVGPathGenerator.js");
9
11
  return new SVGPathGenerator(container);
10
12
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/path-svg",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.2",
4
4
  "description": "tsParticles svg path",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -95,14 +95,13 @@
95
95
  "browser": "./browser/index.js",
96
96
  "import": "./esm/index.js",
97
97
  "require": "./cjs/index.js",
98
- "umd": "./umd/index.js",
99
- "default": "./cjs/index.js"
98
+ "default": "./esm/index.js"
100
99
  },
101
100
  "./package.json": "./package.json"
102
101
  },
103
- "dependencies": {
104
- "@tsparticles/engine": "4.0.0-beta.0",
105
- "@tsparticles/plugin-move": "4.0.0-beta.0"
102
+ "peerDependencies": {
103
+ "@tsparticles/engine": "4.0.0-beta.1",
104
+ "@tsparticles/plugin-move": "4.0.0-beta.1"
106
105
  },
107
106
  "publishConfig": {
108
107
  "access": "public"