@tsparticles/path-zig-zag 4.0.0-alpha.5 → 4.0.0-beta.0

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/38.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_path_zig_zag=this.webpackChunk_tsparticles_path_zig_zag||[]).push([[38],{38(t,e,i){i.d(e,{ZigZagPathGenerator:()=>h});var a=i(303);let n=Math.PI*a.half,s={waveHeight:{min:0,max:3},waveLength:{min:0,max:5}};class h{options;_container;_res;constructor(t){this._container=t,this._res=a.Vector.origin,this.options=(0,a.deepExtend)({},s)}generate(t,e){let{options:i}=this;t.zigzag??={counter:(0,a.getRandom)(),waveHeight:(0,a.getRangeValue)(i.waveHeight),waveLength:(0,a.getRangeValue)(i.waveLength)};let s=.5/t.zigzag.waveLength*e.factor;t.zigzag.counter+=s;let h=t.zigzag.waveHeight*Math.sin(t.zigzag.counter);return t.position.x+=h*Math.cos(t.velocity.angle+n),t.position.y+=h*Math.sin(t.velocity.angle+n),this._res.x=0,this._res.y=0,this._res}init(){let t=this._container.actualOptions.particles.move.path.options;this.options.waveLength=t.waveLength??this.options.waveLength,this.options.waveHeight=t.waveHeight??this.options.waveHeight}reset(){}update(){}}}}]);
@@ -1,29 +1,38 @@
1
- import { Vector, getRandom, getRangeValue, half, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, getRandom, getRangeValue, half, } from "@tsparticles/engine";
2
2
  const angularFrequencyFactor = 0.5, halfPI = Math.PI * half;
3
+ const defaultOptions = {
4
+ waveHeight: { min: 0, max: 3 },
5
+ waveLength: { min: 0, max: 5 },
6
+ };
3
7
  export class ZigZagPathGenerator {
4
- constructor() {
5
- this.options = {
6
- waveHeight: { min: 0, max: 3 },
7
- waveLength: { min: 0, max: 5 },
8
- };
8
+ options;
9
+ _container;
10
+ _res;
11
+ constructor(container) {
12
+ this._container = container;
13
+ this._res = Vector.origin;
14
+ this.options = deepExtend({}, defaultOptions);
9
15
  }
10
16
  generate(particle, delta) {
17
+ const { options } = this;
11
18
  particle.zigzag ??= {
12
19
  counter: getRandom(),
13
- waveHeight: getRangeValue(this.options.waveHeight),
14
- waveLength: getRangeValue(this.options.waveLength),
20
+ waveHeight: getRangeValue(options.waveHeight),
21
+ waveLength: getRangeValue(options.waveLength),
15
22
  };
16
23
  const angularFrequency = (angularFrequencyFactor / particle.zigzag.waveLength) * delta.factor;
17
24
  particle.zigzag.counter += angularFrequency;
18
25
  const zigzagAngle = particle.zigzag.waveHeight * Math.sin(particle.zigzag.counter);
19
26
  particle.position.x += zigzagAngle * Math.cos(particle.velocity.angle + halfPI);
20
27
  particle.position.y += zigzagAngle * Math.sin(particle.velocity.angle + halfPI);
21
- return Vector.origin;
28
+ this._res.x = 0;
29
+ this._res.y = 0;
30
+ return this._res;
22
31
  }
23
- init(container) {
24
- const options = container.actualOptions.particles.move.path.options;
25
- this.options.waveLength = options["waveLength"] ?? this.options.waveLength;
26
- this.options.waveHeight = options["waveHeight"] ?? this.options.waveHeight;
32
+ init() {
33
+ const sourceOptions = this._container.actualOptions.particles.move.path.options;
34
+ this.options.waveLength = sourceOptions["waveLength"] ?? this.options.waveLength;
35
+ this.options.waveHeight = sourceOptions["waveHeight"] ?? this.options.waveHeight;
27
36
  }
28
37
  reset() {
29
38
  }
package/browser/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  export const zigZagPathName = "zigZagPathGenerator";
2
2
  export async function loadZigZagPath(engine) {
3
- engine.checkVersion("4.0.0-alpha.5");
3
+ engine.checkVersion("4.0.0-beta.0");
4
4
  await engine.register(async (e) => {
5
- const { ZigZagPathGenerator } = await import("./ZigZagPathGenerator.js");
6
- e.addPathGenerator(zigZagPathName, new ZigZagPathGenerator());
5
+ const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
+ ensureBaseMoverLoaded(e);
7
+ e.addPathGenerator?.(zigZagPathName, async (container) => {
8
+ const { ZigZagPathGenerator } = await import("./ZigZagPathGenerator.js");
9
+ return new ZigZagPathGenerator(container);
10
+ });
7
11
  });
8
12
  }
@@ -1,29 +1,38 @@
1
- import { Vector, getRandom, getRangeValue, half, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, getRandom, getRangeValue, half, } from "@tsparticles/engine";
2
2
  const angularFrequencyFactor = 0.5, halfPI = Math.PI * half;
3
+ const defaultOptions = {
4
+ waveHeight: { min: 0, max: 3 },
5
+ waveLength: { min: 0, max: 5 },
6
+ };
3
7
  export class ZigZagPathGenerator {
4
- constructor() {
5
- this.options = {
6
- waveHeight: { min: 0, max: 3 },
7
- waveLength: { min: 0, max: 5 },
8
- };
8
+ options;
9
+ _container;
10
+ _res;
11
+ constructor(container) {
12
+ this._container = container;
13
+ this._res = Vector.origin;
14
+ this.options = deepExtend({}, defaultOptions);
9
15
  }
10
16
  generate(particle, delta) {
17
+ const { options } = this;
11
18
  particle.zigzag ??= {
12
19
  counter: getRandom(),
13
- waveHeight: getRangeValue(this.options.waveHeight),
14
- waveLength: getRangeValue(this.options.waveLength),
20
+ waveHeight: getRangeValue(options.waveHeight),
21
+ waveLength: getRangeValue(options.waveLength),
15
22
  };
16
23
  const angularFrequency = (angularFrequencyFactor / particle.zigzag.waveLength) * delta.factor;
17
24
  particle.zigzag.counter += angularFrequency;
18
25
  const zigzagAngle = particle.zigzag.waveHeight * Math.sin(particle.zigzag.counter);
19
26
  particle.position.x += zigzagAngle * Math.cos(particle.velocity.angle + halfPI);
20
27
  particle.position.y += zigzagAngle * Math.sin(particle.velocity.angle + halfPI);
21
- return Vector.origin;
28
+ this._res.x = 0;
29
+ this._res.y = 0;
30
+ return this._res;
22
31
  }
23
- init(container) {
24
- const options = container.actualOptions.particles.move.path.options;
25
- this.options.waveLength = options["waveLength"] ?? this.options.waveLength;
26
- this.options.waveHeight = options["waveHeight"] ?? this.options.waveHeight;
32
+ init() {
33
+ const sourceOptions = this._container.actualOptions.particles.move.path.options;
34
+ this.options.waveLength = sourceOptions["waveLength"] ?? this.options.waveLength;
35
+ this.options.waveHeight = sourceOptions["waveHeight"] ?? this.options.waveHeight;
27
36
  }
28
37
  reset() {
29
38
  }
package/cjs/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  export const zigZagPathName = "zigZagPathGenerator";
2
2
  export async function loadZigZagPath(engine) {
3
- engine.checkVersion("4.0.0-alpha.5");
3
+ engine.checkVersion("4.0.0-beta.0");
4
4
  await engine.register(async (e) => {
5
- const { ZigZagPathGenerator } = await import("./ZigZagPathGenerator.js");
6
- e.addPathGenerator(zigZagPathName, new ZigZagPathGenerator());
5
+ const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
+ ensureBaseMoverLoaded(e);
7
+ e.addPathGenerator?.(zigZagPathName, async (container) => {
8
+ const { ZigZagPathGenerator } = await import("./ZigZagPathGenerator.js");
9
+ return new ZigZagPathGenerator(container);
10
+ });
7
11
  });
8
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-alpha.5
7
+ * v4.0.0-beta.0
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 */ ZigZagPathGenerator: () => (/* binding */ ZigZagPathGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst angularFrequencyFactor = 0.5,\n halfPI = Math.PI * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half;\nclass ZigZagPathGenerator {\n constructor() {\n this.options = {\n waveHeight: {\n min: 0,\n max: 3\n },\n waveLength: {\n min: 0,\n max: 5\n }\n };\n }\n generate(particle, delta) {\n particle.zigzag ??= {\n counter: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)(),\n waveHeight: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(this.options.waveHeight),\n waveLength: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(this.options.waveLength)\n };\n const angularFrequency = angularFrequencyFactor / particle.zigzag.waveLength * delta.factor;\n particle.zigzag.counter += angularFrequency;\n const zigzagAngle = particle.zigzag.waveHeight * Math.sin(particle.zigzag.counter);\n particle.position.x += zigzagAngle * Math.cos(particle.velocity.angle + halfPI);\n particle.position.y += zigzagAngle * Math.sin(particle.velocity.angle + halfPI);\n return _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n }\n init(container) {\n const options = container.actualOptions.particles.move.path.options;\n this.options.waveLength = options[\"waveLength\"] ?? this.options.waveLength;\n this.options.waveHeight = options[\"waveHeight\"] ?? this.options.waveHeight;\n }\n reset() {}\n update() {}\n}\n\n//# sourceURL=webpack://@tsparticles/path-zig-zag/./dist/browser/ZigZagPathGenerator.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ZigZagPathGenerator: () => (/* binding */ ZigZagPathGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst angularFrequencyFactor = 0.5, halfPI = Math.PI * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half;\nconst defaultOptions = {\n waveHeight: {\n min: 0,\n max: 3\n },\n waveLength: {\n min: 0,\n max: 5\n }\n};\nclass ZigZagPathGenerator {\n options;\n _container;\n _res;\n constructor(container){\n this._container = container;\n this._res = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle, delta) {\n const { options } = this;\n particle.zigzag ??= {\n counter: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)(),\n waveHeight: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(options.waveHeight),\n waveLength: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(options.waveLength)\n };\n const angularFrequency = angularFrequencyFactor / particle.zigzag.waveLength * delta.factor;\n particle.zigzag.counter += angularFrequency;\n const zigzagAngle = particle.zigzag.waveHeight * Math.sin(particle.zigzag.counter);\n particle.position.x += zigzagAngle * Math.cos(particle.velocity.angle + halfPI);\n particle.position.y += zigzagAngle * Math.sin(particle.velocity.angle + halfPI);\n this._res.x = 0;\n this._res.y = 0;\n return this._res;\n }\n init() {\n const sourceOptions = this._container.actualOptions.particles.move.path.options;\n this.options.waveLength = sourceOptions[\"waveLength\"] ?? this.options.waveLength;\n this.options.waveHeight = sourceOptions[\"waveHeight\"] ?? this.options.waveHeight;\n }\n reset() {}\n update() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-zig-zag/./dist/browser/ZigZagPathGenerator.js?\n}");
27
27
 
28
28
  /***/ }
29
29
 
@@ -1,29 +1,38 @@
1
- import { Vector, getRandom, getRangeValue, half, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, getRandom, getRangeValue, half, } from "@tsparticles/engine";
2
2
  const angularFrequencyFactor = 0.5, halfPI = Math.PI * half;
3
+ const defaultOptions = {
4
+ waveHeight: { min: 0, max: 3 },
5
+ waveLength: { min: 0, max: 5 },
6
+ };
3
7
  export class ZigZagPathGenerator {
4
- constructor() {
5
- this.options = {
6
- waveHeight: { min: 0, max: 3 },
7
- waveLength: { min: 0, max: 5 },
8
- };
8
+ options;
9
+ _container;
10
+ _res;
11
+ constructor(container) {
12
+ this._container = container;
13
+ this._res = Vector.origin;
14
+ this.options = deepExtend({}, defaultOptions);
9
15
  }
10
16
  generate(particle, delta) {
17
+ const { options } = this;
11
18
  particle.zigzag ??= {
12
19
  counter: getRandom(),
13
- waveHeight: getRangeValue(this.options.waveHeight),
14
- waveLength: getRangeValue(this.options.waveLength),
20
+ waveHeight: getRangeValue(options.waveHeight),
21
+ waveLength: getRangeValue(options.waveLength),
15
22
  };
16
23
  const angularFrequency = (angularFrequencyFactor / particle.zigzag.waveLength) * delta.factor;
17
24
  particle.zigzag.counter += angularFrequency;
18
25
  const zigzagAngle = particle.zigzag.waveHeight * Math.sin(particle.zigzag.counter);
19
26
  particle.position.x += zigzagAngle * Math.cos(particle.velocity.angle + halfPI);
20
27
  particle.position.y += zigzagAngle * Math.sin(particle.velocity.angle + halfPI);
21
- return Vector.origin;
28
+ this._res.x = 0;
29
+ this._res.y = 0;
30
+ return this._res;
22
31
  }
23
- init(container) {
24
- const options = container.actualOptions.particles.move.path.options;
25
- this.options.waveLength = options["waveLength"] ?? this.options.waveLength;
26
- this.options.waveHeight = options["waveHeight"] ?? this.options.waveHeight;
32
+ init() {
33
+ const sourceOptions = this._container.actualOptions.particles.move.path.options;
34
+ this.options.waveLength = sourceOptions["waveLength"] ?? this.options.waveLength;
35
+ this.options.waveHeight = sourceOptions["waveHeight"] ?? this.options.waveHeight;
27
36
  }
28
37
  reset() {
29
38
  }
package/esm/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  export const zigZagPathName = "zigZagPathGenerator";
2
2
  export async function loadZigZagPath(engine) {
3
- engine.checkVersion("4.0.0-alpha.5");
3
+ engine.checkVersion("4.0.0-beta.0");
4
4
  await engine.register(async (e) => {
5
- const { ZigZagPathGenerator } = await import("./ZigZagPathGenerator.js");
6
- e.addPathGenerator(zigZagPathName, new ZigZagPathGenerator());
5
+ const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
+ ensureBaseMoverLoaded(e);
7
+ e.addPathGenerator?.(zigZagPathName, async (container) => {
8
+ const { ZigZagPathGenerator } = await import("./ZigZagPathGenerator.js");
9
+ return new ZigZagPathGenerator(container);
10
+ });
7
11
  });
8
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/path-zig-zag",
3
- "version": "4.0.0-alpha.5",
3
+ "version": "4.0.0-beta.0",
4
4
  "description": "tsParticles zig zag path",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -101,7 +101,8 @@
101
101
  "./package.json": "./package.json"
102
102
  },
103
103
  "dependencies": {
104
- "@tsparticles/engine": "4.0.0-alpha.5"
104
+ "@tsparticles/engine": "4.0.0-beta.0",
105
+ "@tsparticles/plugin-move": "4.0.0-beta.0"
105
106
  },
106
107
  "publishConfig": {
107
108
  "access": "public"