@tsparticles/path-polygon 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.
package/425.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_path_polygon=this.webpackChunk_tsparticles_path_polygon||[]).push([[425],{425(t,e,s){s.d(e,{PolygonPathGenerator:()=>n});var i=s(303);let o={sides:6,turnSteps:20,angle:30};class n{dirsList;options;_container;constructor(t){this._container=t,this.dirsList=[],this.options=(0,i.deepExtend)({},o)}generate(t){let{sides:e,turnSteps:s}=this.options;t.hexStep??=0,t.hexDirection??=6===e?(3*(0,i.getRandom)()|0)*2:(0,i.getRandom)()*e|0,t.hexSpeed??=t.velocity.length,t.hexStep%s==0&&(t.hexDirection=(0,i.getRandom)()>.5?(t.hexDirection+1)%e:(t.hexDirection+e-1)%e),t.velocity.x=0,t.velocity.y=0,t.hexStep++;let o=this.dirsList[t.hexDirection];return i.Vector.create(o.x*t.hexSpeed,o.y*t.hexSpeed)}init(){let t=this._container.actualOptions.particles.move.path.options;this.options.sides=t.sides>0?t.sides:this.options.sides,this.options.angle=t.angle??this.options.angle,this.options.turnSteps=t.turnSteps>=0?t.turnSteps:this.options.turnSteps,this._createDirs()}reset(t){delete t.hexStep,delete t.hexDirection,delete t.hexSpeed}update(){}_createDirs=()=>{let{options:t}=this;this.dirsList=[];for(let e=0;e<360;e+=360/t.sides){let s=t.angle+e;this.dirsList.push(i.Vector.create(Math.cos(s*Math.PI/180),Math.sin(s*Math.PI/180)))}}}}}]);
@@ -1,26 +1,24 @@
1
- import { Vector, getRandom } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
2
+ const defaultOptions = {
3
+ sides: 6,
4
+ turnSteps: 20,
5
+ angle: 30,
6
+ };
2
7
  export class PolygonPathGenerator {
3
- constructor() {
4
- this._createDirs = () => {
5
- this.dirsList = [];
6
- for (let i = 0; i < 360; i += 360 / this.options.sides) {
7
- const angle = this.options.angle + i;
8
- this.dirsList.push(Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
9
- }
10
- };
8
+ dirsList;
9
+ options;
10
+ _container;
11
+ constructor(container) {
12
+ this._container = container;
11
13
  this.dirsList = [];
12
- this.options = {
13
- sides: 6,
14
- turnSteps: 20,
15
- angle: 30,
16
- };
14
+ this.options = deepExtend({}, defaultOptions);
17
15
  }
18
16
  generate(p) {
19
- const { sides } = this.options;
17
+ const { sides, turnSteps } = this.options;
20
18
  p.hexStep ??= 0;
21
19
  p.hexDirection ??= sides === 6 ? ((getRandom() * 3) | 0) * 2 : (getRandom() * sides) | 0;
22
20
  p.hexSpeed ??= p.velocity.length;
23
- if (p.hexStep % this.options.turnSteps === 0) {
21
+ if (p.hexStep % turnSteps === 0) {
24
22
  p.hexDirection = getRandom() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;
25
23
  }
26
24
  p.velocity.x = 0;
@@ -29,11 +27,13 @@ export class PolygonPathGenerator {
29
27
  const direction = this.dirsList[p.hexDirection];
30
28
  return Vector.create(direction.x * p.hexSpeed, direction.y * p.hexSpeed);
31
29
  }
32
- init(container) {
33
- const options = container.actualOptions.particles.move.path.options;
34
- this.options.sides = options["sides"] > 0 ? options["sides"] : 6;
35
- this.options.angle = options["angle"] ?? 30;
36
- this.options.turnSteps = options["turnSteps"] >= 0 ? options["turnSteps"] : 20;
30
+ init() {
31
+ const container = this._container, sourceOptions = container.actualOptions.particles.move.path.options;
32
+ this.options.sides =
33
+ sourceOptions["sides"] > 0 ? sourceOptions["sides"] : this.options.sides;
34
+ this.options.angle = sourceOptions["angle"] ?? this.options.angle;
35
+ this.options.turnSteps =
36
+ sourceOptions["turnSteps"] >= 0 ? sourceOptions["turnSteps"] : this.options.turnSteps;
37
37
  this._createDirs();
38
38
  }
39
39
  reset(particle) {
@@ -43,4 +43,12 @@ export class PolygonPathGenerator {
43
43
  }
44
44
  update() {
45
45
  }
46
+ _createDirs = () => {
47
+ const { options } = this;
48
+ this.dirsList = [];
49
+ for (let i = 0; i < 360; i += 360 / options.sides) {
50
+ const angle = options.angle + i;
51
+ this.dirsList.push(Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
52
+ }
53
+ };
46
54
  }
package/browser/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export const polygonPathName = "polygonPathGenerator";
2
- export function loadPolygonPath(engine) {
3
- engine.checkVersion("4.0.0-alpha.2");
4
- engine.register(async (e) => {
5
- const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
6
- e.addPathGenerator(polygonPathName, new PolygonPathGenerator());
2
+ export async function loadPolygonPath(engine) {
3
+ engine.checkVersion("4.0.0-alpha.20");
4
+ await engine.register(e => {
5
+ e.addPathGenerator(polygonPathName, async (container) => {
6
+ const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
7
+ return new PolygonPathGenerator(container);
8
+ });
7
9
  });
8
10
  }
@@ -1,26 +1,24 @@
1
- import { Vector, getRandom } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
2
+ const defaultOptions = {
3
+ sides: 6,
4
+ turnSteps: 20,
5
+ angle: 30,
6
+ };
2
7
  export class PolygonPathGenerator {
3
- constructor() {
4
- this._createDirs = () => {
5
- this.dirsList = [];
6
- for (let i = 0; i < 360; i += 360 / this.options.sides) {
7
- const angle = this.options.angle + i;
8
- this.dirsList.push(Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
9
- }
10
- };
8
+ dirsList;
9
+ options;
10
+ _container;
11
+ constructor(container) {
12
+ this._container = container;
11
13
  this.dirsList = [];
12
- this.options = {
13
- sides: 6,
14
- turnSteps: 20,
15
- angle: 30,
16
- };
14
+ this.options = deepExtend({}, defaultOptions);
17
15
  }
18
16
  generate(p) {
19
- const { sides } = this.options;
17
+ const { sides, turnSteps } = this.options;
20
18
  p.hexStep ??= 0;
21
19
  p.hexDirection ??= sides === 6 ? ((getRandom() * 3) | 0) * 2 : (getRandom() * sides) | 0;
22
20
  p.hexSpeed ??= p.velocity.length;
23
- if (p.hexStep % this.options.turnSteps === 0) {
21
+ if (p.hexStep % turnSteps === 0) {
24
22
  p.hexDirection = getRandom() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;
25
23
  }
26
24
  p.velocity.x = 0;
@@ -29,11 +27,13 @@ export class PolygonPathGenerator {
29
27
  const direction = this.dirsList[p.hexDirection];
30
28
  return Vector.create(direction.x * p.hexSpeed, direction.y * p.hexSpeed);
31
29
  }
32
- init(container) {
33
- const options = container.actualOptions.particles.move.path.options;
34
- this.options.sides = options["sides"] > 0 ? options["sides"] : 6;
35
- this.options.angle = options["angle"] ?? 30;
36
- this.options.turnSteps = options["turnSteps"] >= 0 ? options["turnSteps"] : 20;
30
+ init() {
31
+ const container = this._container, sourceOptions = container.actualOptions.particles.move.path.options;
32
+ this.options.sides =
33
+ sourceOptions["sides"] > 0 ? sourceOptions["sides"] : this.options.sides;
34
+ this.options.angle = sourceOptions["angle"] ?? this.options.angle;
35
+ this.options.turnSteps =
36
+ sourceOptions["turnSteps"] >= 0 ? sourceOptions["turnSteps"] : this.options.turnSteps;
37
37
  this._createDirs();
38
38
  }
39
39
  reset(particle) {
@@ -43,4 +43,12 @@ export class PolygonPathGenerator {
43
43
  }
44
44
  update() {
45
45
  }
46
+ _createDirs = () => {
47
+ const { options } = this;
48
+ this.dirsList = [];
49
+ for (let i = 0; i < 360; i += 360 / options.sides) {
50
+ const angle = options.angle + i;
51
+ this.dirsList.push(Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
52
+ }
53
+ };
46
54
  }
package/cjs/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export const polygonPathName = "polygonPathGenerator";
2
- export function loadPolygonPath(engine) {
3
- engine.checkVersion("4.0.0-alpha.2");
4
- engine.register(async (e) => {
5
- const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
6
- e.addPathGenerator(polygonPathName, new PolygonPathGenerator());
2
+ export async function loadPolygonPath(engine) {
3
+ engine.checkVersion("4.0.0-alpha.20");
4
+ await engine.register(e => {
5
+ e.addPathGenerator(polygonPathName, async (container) => {
6
+ const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
7
+ return new PolygonPathGenerator(container);
8
+ });
7
9
  });
8
10
  }
@@ -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
  "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 */ PolygonPathGenerator: () => (/* binding */ PolygonPathGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass PolygonPathGenerator {\n constructor() {\n this._createDirs = () => {\n this.dirsList = [];\n for (let i = 0; i < 360; i += 360 / this.options.sides) {\n const angle = this.options.angle + i;\n this.dirsList.push(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(Math.cos(angle * Math.PI / 180), Math.sin(angle * Math.PI / 180)));\n }\n };\n this.dirsList = [];\n this.options = {\n sides: 6,\n turnSteps: 20,\n angle: 30\n };\n }\n generate(p) {\n const {\n sides\n } = this.options;\n p.hexStep ??= 0;\n p.hexDirection ??= sides === 6 ? ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * 3 | 0) * 2 : (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * sides | 0;\n p.hexSpeed ??= p.velocity.length;\n if (p.hexStep % this.options.turnSteps === 0) {\n p.hexDirection = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;\n }\n p.velocity.x = 0;\n p.velocity.y = 0;\n p.hexStep++;\n const direction = this.dirsList[p.hexDirection];\n return _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(direction.x * p.hexSpeed, direction.y * p.hexSpeed);\n }\n init(container) {\n const options = container.actualOptions.particles.move.path.options;\n this.options.sides = options[\"sides\"] > 0 ? options[\"sides\"] : 6;\n this.options.angle = options[\"angle\"] ?? 30;\n this.options.turnSteps = options[\"turnSteps\"] >= 0 ? options[\"turnSteps\"] : 20;\n this._createDirs();\n }\n reset(particle) {\n delete particle.hexStep;\n delete particle.hexDirection;\n delete particle.hexSpeed;\n }\n update() {}\n}\n\n//# sourceURL=webpack://@tsparticles/path-polygon/./dist/browser/PolygonPathGenerator.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PolygonPathGenerator: () => (/* binding */ PolygonPathGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultOptions = {\n sides: 6,\n turnSteps: 20,\n angle: 30\n};\nclass PolygonPathGenerator {\n dirsList;\n options;\n _container;\n constructor(container){\n this._container = container;\n this.dirsList = [];\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(p) {\n const { sides, turnSteps } = this.options;\n p.hexStep ??= 0;\n p.hexDirection ??= sides === 6 ? ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * 3 | 0) * 2 : (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * sides | 0;\n p.hexSpeed ??= p.velocity.length;\n if (p.hexStep % turnSteps === 0) {\n p.hexDirection = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;\n }\n p.velocity.x = 0;\n p.velocity.y = 0;\n p.hexStep++;\n const direction = this.dirsList[p.hexDirection];\n return _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(direction.x * p.hexSpeed, direction.y * p.hexSpeed);\n }\n init() {\n const container = this._container, sourceOptions = container.actualOptions.particles.move.path.options;\n this.options.sides = sourceOptions[\"sides\"] > 0 ? sourceOptions[\"sides\"] : this.options.sides;\n this.options.angle = sourceOptions[\"angle\"] ?? this.options.angle;\n this.options.turnSteps = sourceOptions[\"turnSteps\"] >= 0 ? sourceOptions[\"turnSteps\"] : this.options.turnSteps;\n this._createDirs();\n }\n reset(particle) {\n delete particle.hexStep;\n delete particle.hexDirection;\n delete particle.hexSpeed;\n }\n update() {}\n _createDirs = ()=>{\n const { options } = this;\n this.dirsList = [];\n for(let i = 0; i < 360; i += 360 / options.sides){\n const angle = options.angle + i;\n this.dirsList.push(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(Math.cos(angle * Math.PI / 180), Math.sin(angle * Math.PI / 180)));\n }\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-polygon/./dist/browser/PolygonPathGenerator.js?\n}");
27
27
 
28
28
  /***/ }
29
29
 
@@ -1,26 +1,24 @@
1
- import { Vector, getRandom } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
2
+ const defaultOptions = {
3
+ sides: 6,
4
+ turnSteps: 20,
5
+ angle: 30,
6
+ };
2
7
  export class PolygonPathGenerator {
3
- constructor() {
4
- this._createDirs = () => {
5
- this.dirsList = [];
6
- for (let i = 0; i < 360; i += 360 / this.options.sides) {
7
- const angle = this.options.angle + i;
8
- this.dirsList.push(Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
9
- }
10
- };
8
+ dirsList;
9
+ options;
10
+ _container;
11
+ constructor(container) {
12
+ this._container = container;
11
13
  this.dirsList = [];
12
- this.options = {
13
- sides: 6,
14
- turnSteps: 20,
15
- angle: 30,
16
- };
14
+ this.options = deepExtend({}, defaultOptions);
17
15
  }
18
16
  generate(p) {
19
- const { sides } = this.options;
17
+ const { sides, turnSteps } = this.options;
20
18
  p.hexStep ??= 0;
21
19
  p.hexDirection ??= sides === 6 ? ((getRandom() * 3) | 0) * 2 : (getRandom() * sides) | 0;
22
20
  p.hexSpeed ??= p.velocity.length;
23
- if (p.hexStep % this.options.turnSteps === 0) {
21
+ if (p.hexStep % turnSteps === 0) {
24
22
  p.hexDirection = getRandom() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;
25
23
  }
26
24
  p.velocity.x = 0;
@@ -29,11 +27,13 @@ export class PolygonPathGenerator {
29
27
  const direction = this.dirsList[p.hexDirection];
30
28
  return Vector.create(direction.x * p.hexSpeed, direction.y * p.hexSpeed);
31
29
  }
32
- init(container) {
33
- const options = container.actualOptions.particles.move.path.options;
34
- this.options.sides = options["sides"] > 0 ? options["sides"] : 6;
35
- this.options.angle = options["angle"] ?? 30;
36
- this.options.turnSteps = options["turnSteps"] >= 0 ? options["turnSteps"] : 20;
30
+ init() {
31
+ const container = this._container, sourceOptions = container.actualOptions.particles.move.path.options;
32
+ this.options.sides =
33
+ sourceOptions["sides"] > 0 ? sourceOptions["sides"] : this.options.sides;
34
+ this.options.angle = sourceOptions["angle"] ?? this.options.angle;
35
+ this.options.turnSteps =
36
+ sourceOptions["turnSteps"] >= 0 ? sourceOptions["turnSteps"] : this.options.turnSteps;
37
37
  this._createDirs();
38
38
  }
39
39
  reset(particle) {
@@ -43,4 +43,12 @@ export class PolygonPathGenerator {
43
43
  }
44
44
  update() {
45
45
  }
46
+ _createDirs = () => {
47
+ const { options } = this;
48
+ this.dirsList = [];
49
+ for (let i = 0; i < 360; i += 360 / options.sides) {
50
+ const angle = options.angle + i;
51
+ this.dirsList.push(Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
52
+ }
53
+ };
46
54
  }
package/esm/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export const polygonPathName = "polygonPathGenerator";
2
- export function loadPolygonPath(engine) {
3
- engine.checkVersion("4.0.0-alpha.2");
4
- engine.register(async (e) => {
5
- const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
6
- e.addPathGenerator(polygonPathName, new PolygonPathGenerator());
2
+ export async function loadPolygonPath(engine) {
3
+ engine.checkVersion("4.0.0-alpha.20");
4
+ await engine.register(e => {
5
+ e.addPathGenerator(polygonPathName, async (container) => {
6
+ const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
7
+ return new PolygonPathGenerator(container);
8
+ });
7
9
  });
8
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/path-polygon",
3
- "version": "4.0.0-alpha.2",
3
+ "version": "4.0.0-alpha.20",
4
4
  "description": "tsParticles polygon path",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -104,7 +104,7 @@
104
104
  "./package.json": "./package.json"
105
105
  },
106
106
  "dependencies": {
107
- "@tsparticles/engine": "4.0.0-alpha.2"
107
+ "@tsparticles/engine": "4.0.0-alpha.20"
108
108
  },
109
109
  "type": "module"
110
110
  }