@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.
@@ -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 */ loadPolygonPath: () => (/* binding */ loadPolygonPath),\n/* harmony export */ polygonPathName: () => (/* binding */ polygonPathName)\n/* harmony export */ });\nconst polygonPathName = \"polygonPathGenerator\";\nfunction loadPolygonPath(engine) {\n engine.checkVersion(\"4.0.0-alpha.2\");\n engine.register(async e => {\n const {\n PolygonPathGenerator\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_PolygonPathGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./PolygonPathGenerator.js */ \"./dist/browser/PolygonPathGenerator.js\"));\n e.addPathGenerator(polygonPathName, new PolygonPathGenerator());\n });\n}\n\n//# sourceURL=webpack://@tsparticles/path-polygon/./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 */ loadPolygonPath: () => (/* binding */ loadPolygonPath),\n/* harmony export */ polygonPathName: () => (/* binding */ polygonPathName)\n/* harmony export */ });\nconst polygonPathName = \"polygonPathGenerator\";\nasync function loadPolygonPath(engine) {\n engine.checkVersion(\"4.0.0-alpha.20\");\n await engine.register((e)=>{\n e.addPathGenerator(polygonPathName, async (container)=>{\n const { PolygonPathGenerator } = await __webpack_require__.e(/*! import() */ \"dist_browser_PolygonPathGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./PolygonPathGenerator.js */ \"./dist/browser/PolygonPathGenerator.js\"));\n return new PolygonPathGenerator(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-polygon/./dist/browser/index.js?\n}");
48
+
49
49
  /***/ }
50
50
 
51
51
  /******/ });
@@ -1,2 +1,2 @@
1
- /*! For license information please see tsparticles.path.polygon.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-polygon:",a.l=(e,o,n,i)=>{if(t[e])t[e].push(o);else{var s,p;if(void 0!==n)for(var l=document.getElementsByTagName("script"),c=0;c<l.length;c++){var u=l[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==r+n){s=u;break}}s||(p=!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),p&&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={334: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,p]=r,l=0;if(i.some((t=>0!==e[t]))){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);if(p)p(a)}for(t&&t(r);l<i.length;l++)n=i[l],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_path_polygon=this.webpackChunk_tsparticles_path_polygon||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};a.r(i),a.d(i,{loadPolygonPath:()=>p,polygonPathName:()=>s});const s="polygonPathGenerator";function p(e){e.checkVersion("4.0.0-alpha.2"),e.register((async e=>{const{PolygonPathGenerator:t}=await a.e(399).then(a.bind(a,399));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),p={},i.l=(e,t,r,o)=>{if(p[e])return void p[e].push(t);if(void 0!==r)for(var n,a,s=document.getElementsByTagName("script"),l=0;l<s.length;l++){var c=s[l];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="@tsparticles/path-polygon:"+r){n=c;break}}n||(a=!0,(n=document.createElement("script")).charset="utf-8",i.nc&&n.setAttribute("nonce",i.nc),n.setAttribute("data-webpack","@tsparticles/path-polygon:"+r),n.src=e),p[e]=[t];var u=(t,r)=>{n.onerror=n.onload=null,clearTimeout(d);var o=p[e];if(delete p[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&&(s=i.g.location+"");var p,s,l=i.g.document;if(!s&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(s=l.currentScript.src),!s)){var c=l.getElementsByTagName("script");if(c.length)for(var u=c.length-1;u>-1&&(!s||!/^http(s?):/.test(s));)s=c[u--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");i.p=s=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={334: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),p=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;p.message="Loading chunk "+e+` failed.
2
+ (`+n+": "+a+")",p.name="ChunkLoadError",p.type=n,p.request=a,o[1](p)}},"chunk-"+e,e)}},r=(e,r)=>{var o,n,[a,p,s]=r,l=0;if(a.some(e=>0!==t[e])){for(o in p)i.o(p,o)&&(i.m[o]=p[o]);s&&s(i)}for(e&&e(r);l<a.length;l++)n=a[l],i.o(t,n)&&t[n]&&t[n][0](),t[n]=0},(o=this.webpackChunk_tsparticles_path_polygon=this.webpackChunk_tsparticles_path_polygon||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};i.r(d),i.d(d,{loadPolygonPath:()=>h,polygonPathName:()=>f});let f="polygonPathGenerator";async function h(e){e.checkVersion("4.0.0-alpha.20"),await e.register(e=>{e.addPathGenerator(f,async e=>{let{PolygonPathGenerator:t}=await i.e(425).then(i.bind(i,425));return new t(e)})})}return d})());
@@ -4,9 +4,10 @@ import type { PolygonPathParticle } from "./PolygonPathParticle.js";
4
4
  export declare class PolygonPathGenerator implements IMovePathGenerator {
5
5
  dirsList: ICoordinates[];
6
6
  readonly options: IPolygonPathOptions;
7
- constructor();
7
+ private readonly _container;
8
+ constructor(container: Container);
8
9
  generate(p: PolygonPathParticle): Vector;
9
- init(container: Container): void;
10
+ init(): void;
10
11
  reset(particle: PolygonPathParticle): void;
11
12
  update(): void;
12
13
  private readonly _createDirs;
package/types/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { type Engine } from "@tsparticles/engine";
2
2
  export declare const polygonPathName = "polygonPathGenerator";
3
- export declare function loadPolygonPath(engine: Engine): void;
3
+ export declare function loadPolygonPath(engine: Engine): Promise<void>;
@@ -11,28 +11,26 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PolygonPathGenerator = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
+ const defaultOptions = {
15
+ sides: 6,
16
+ turnSteps: 20,
17
+ angle: 30,
18
+ };
14
19
  class PolygonPathGenerator {
15
- constructor() {
16
- this._createDirs = () => {
17
- this.dirsList = [];
18
- for (let i = 0; i < 360; i += 360 / this.options.sides) {
19
- const angle = this.options.angle + i;
20
- this.dirsList.push(engine_1.Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
21
- }
22
- };
20
+ dirsList;
21
+ options;
22
+ _container;
23
+ constructor(container) {
24
+ this._container = container;
23
25
  this.dirsList = [];
24
- this.options = {
25
- sides: 6,
26
- turnSteps: 20,
27
- angle: 30,
28
- };
26
+ this.options = (0, engine_1.deepExtend)({}, defaultOptions);
29
27
  }
30
28
  generate(p) {
31
- const { sides } = this.options;
29
+ const { sides, turnSteps } = this.options;
32
30
  p.hexStep ??= 0;
33
31
  p.hexDirection ??= sides === 6 ? (((0, engine_1.getRandom)() * 3) | 0) * 2 : ((0, engine_1.getRandom)() * sides) | 0;
34
32
  p.hexSpeed ??= p.velocity.length;
35
- if (p.hexStep % this.options.turnSteps === 0) {
33
+ if (p.hexStep % turnSteps === 0) {
36
34
  p.hexDirection = (0, engine_1.getRandom)() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;
37
35
  }
38
36
  p.velocity.x = 0;
@@ -41,11 +39,13 @@
41
39
  const direction = this.dirsList[p.hexDirection];
42
40
  return engine_1.Vector.create(direction.x * p.hexSpeed, direction.y * p.hexSpeed);
43
41
  }
44
- init(container) {
45
- const options = container.actualOptions.particles.move.path.options;
46
- this.options.sides = options["sides"] > 0 ? options["sides"] : 6;
47
- this.options.angle = options["angle"] ?? 30;
48
- this.options.turnSteps = options["turnSteps"] >= 0 ? options["turnSteps"] : 20;
42
+ init() {
43
+ const container = this._container, sourceOptions = container.actualOptions.particles.move.path.options;
44
+ this.options.sides =
45
+ sourceOptions["sides"] > 0 ? sourceOptions["sides"] : this.options.sides;
46
+ this.options.angle = sourceOptions["angle"] ?? this.options.angle;
47
+ this.options.turnSteps =
48
+ sourceOptions["turnSteps"] >= 0 ? sourceOptions["turnSteps"] : this.options.turnSteps;
49
49
  this._createDirs();
50
50
  }
51
51
  reset(particle) {
@@ -55,6 +55,14 @@
55
55
  }
56
56
  update() {
57
57
  }
58
+ _createDirs = () => {
59
+ const { options } = this;
60
+ this.dirsList = [];
61
+ for (let i = 0; i < 360; i += 360 / options.sides) {
62
+ const angle = options.angle + i;
63
+ this.dirsList.push(engine_1.Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
64
+ }
65
+ };
58
66
  }
59
67
  exports.PolygonPathGenerator = PolygonPathGenerator;
60
68
  });
package/umd/index.js CHANGED
@@ -46,11 +46,13 @@ var __importStar = (this && this.__importStar) || (function () {
46
46
  exports.polygonPathName = void 0;
47
47
  exports.loadPolygonPath = loadPolygonPath;
48
48
  exports.polygonPathName = "polygonPathGenerator";
49
- function loadPolygonPath(engine) {
50
- engine.checkVersion("4.0.0-alpha.2");
51
- engine.register(async (e) => {
52
- const { PolygonPathGenerator } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./PolygonPathGenerator.js"))) : new Promise((resolve_1, reject_1) => { require(["./PolygonPathGenerator.js"], resolve_1, reject_1); }).then(__importStar));
53
- e.addPathGenerator(exports.polygonPathName, new PolygonPathGenerator());
49
+ async function loadPolygonPath(engine) {
50
+ engine.checkVersion("4.0.0-alpha.20");
51
+ await engine.register(e => {
52
+ e.addPathGenerator(exports.polygonPathName, async (container) => {
53
+ const { PolygonPathGenerator } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./PolygonPathGenerator.js"))) : new Promise((resolve_1, reject_1) => { require(["./PolygonPathGenerator.js"], resolve_1, reject_1); }).then(__importStar));
54
+ return new PolygonPathGenerator(container);
55
+ });
54
56
  });
55
57
  }
56
58
  });
package/399.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 399.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_path_polygon=this.webpackChunk_tsparticles_path_polygon||[]).push([[399],{399(t,e,s){s.d(e,{PolygonPathGenerator:()=>o});var i=s(303);class o{constructor(){this._createDirs=()=>{this.dirsList=[];for(let t=0;t<360;t+=360/this.options.sides){const e=this.options.angle+t;this.dirsList.push(i.Vector.create(Math.cos(e*Math.PI/180),Math.sin(e*Math.PI/180)))}},this.dirsList=[],this.options={sides:6,turnSteps:20,angle:30}}generate(t){const{sides:e}=this.options;t.hexStep??=0,t.hexDirection??=6===e?2*(3*(0,i.getRandom)()|0):(0,i.getRandom)()*e|0,t.hexSpeed??=t.velocity.length,t.hexStep%this.options.turnSteps==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++;const s=this.dirsList[t.hexDirection];return i.Vector.create(s.x*t.hexSpeed,s.y*t.hexSpeed)}init(t){const e=t.actualOptions.particles.move.path.options;this.options.sides=e.sides>0?e.sides:6,this.options.angle=e.angle??30,this.options.turnSteps=e.turnSteps>=0?e.turnSteps:20,this._createDirs()}reset(t){delete t.hexStep,delete t.hexDirection,delete t.hexSpeed}update(){}}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Polygon Path v4.0.0-alpha.2 by Matteo Bruni */
@@ -1 +0,0 @@
1
- /*! tsParticles Polygon Path v4.0.0-alpha.2 by Matteo Bruni */