@tsparticles/path-curves 4.0.0-alpha.0 → 4.0.0-alpha.14

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.0
7
+ * v4.0.0-alpha.14
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
34
34
  \*******************************/
35
35
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
36
36
 
37
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ curvesPathName: () => (/* binding */ curvesPathName),\n/* harmony export */ loadCurvesPath: () => (/* binding */ loadCurvesPath)\n/* harmony export */ });\nconst curvesPathName = \"curvesPathGenerator\";\nfunction loadCurvesPath(engine) {\n engine.checkVersion(\"4.0.0-alpha.0\");\n engine.register(async e => {\n const {\n CurvesPathGenerator\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_CurvesPathGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./CurvesPathGenerator.js */ \"./dist/browser/CurvesPathGenerator.js\"));\n e.addPathGenerator(curvesPathName, new CurvesPathGenerator());\n });\n}\n\n//# sourceURL=webpack://@tsparticles/path-curves/./dist/browser/index.js?\n}");
37
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ curvesPathName: () => (/* binding */ curvesPathName),\n/* harmony export */ loadCurvesPath: () => (/* binding */ loadCurvesPath)\n/* harmony export */ });\nconst curvesPathName = \"curvesPathGenerator\";\nasync function loadCurvesPath(engine) {\n engine.checkVersion(\"4.0.0-alpha.14\");\n await engine.register((e)=>{\n e.addPathGenerator(curvesPathName, async (container)=>{\n const { CurvesPathGenerator } = await __webpack_require__.e(/*! import() */ \"dist_browser_CurvesPathGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./CurvesPathGenerator.js */ \"./dist/browser/CurvesPathGenerator.js\"));\n return new CurvesPathGenerator(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-curves/./dist/browser/index.js?\n}");
38
38
 
39
39
  /***/ },
40
40
 
@@ -1,2 +1,2 @@
1
- /*! For license information please see tsparticles.path.curves.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-curves:",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"),u=0;u<p.length;u++){var l=p[u];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")==r+n){s=l;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={944: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_curves=this.webpackChunk_tsparticles_path_curves||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};a.r(i),a.d(i,{curvesPathName:()=>s,loadCurvesPath:()=>c});const s="curvesPathGenerator";function c(e){e.checkVersion("4.0.0-alpha.0"),e.register((async e=>{const{CurvesPathGenerator:t}=await a.e(298).then(a.bind(a,298));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 u=c[p];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")=="@tsparticles/path-curves:"+r){n=u;break}}n||(a=!0,(n=document.createElement("script")).charset="utf-8",i.nc&&n.setAttribute("nonce",i.nc),n.setAttribute("data-webpack","@tsparticles/path-curves:"+r),n.src=e),s[e]=[t];var l=(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(l.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=l.bind(null,n.onerror),n.onload=l.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 u=p.getElementsByTagName("script");if(u.length)for(var l=u.length-1;l>-1&&(!c||!/^http(s?):/.test(c));)c=u[l--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");i.p=c=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={944: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_curves=this.webpackChunk_tsparticles_path_curves||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};i.r(d),i.d(d,{curvesPathName:()=>f,loadCurvesPath:()=>h});let f="curvesPathGenerator";async function h(e){e.checkVersion("4.0.0-alpha.14"),await e.register(e=>{e.addPathGenerator(f,async e=>{let{CurvesPathGenerator:t}=await i.e(406).then(i.bind(i,406));return new t(e)})})}return d})());
@@ -3,9 +3,10 @@ import type { CurvesPathParticle } from "./CurvesPathParticle.js";
3
3
  import type { ICurvesOptions } from "./ICurvesOptions.js";
4
4
  export declare class CurvesPathGenerator implements IMovePathGenerator {
5
5
  readonly options: ICurvesOptions;
6
- constructor();
7
- generate(p: CurvesPathParticle): Vector;
8
- init(container: Container): void;
6
+ private readonly _container;
7
+ constructor(container: Container);
8
+ generate(particle: CurvesPathParticle): Vector;
9
+ init(): void;
9
10
  reset(particle: CurvesPathParticle): void;
10
11
  update(): void;
11
12
  }
package/types/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { type Engine } from "@tsparticles/engine";
2
2
  export declare const curvesPathName = "curvesPathGenerator";
3
- export declare function loadCurvesPath(engine: Engine): void;
3
+ export declare function loadCurvesPath(engine: Engine): Promise<void>;
@@ -12,53 +12,59 @@
12
12
  exports.CurvesPathGenerator = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const Curves_js_1 = require("./Curves.js");
15
+ const defaultOptions = {
16
+ rndFunc: null,
17
+ period: 100,
18
+ nbHarmonics: 2,
19
+ attenHarmonics: 0.8,
20
+ lowValue: -0.03,
21
+ highValue: 0.03,
22
+ };
15
23
  function randomVelocity() {
16
24
  const offset = 0.8, factor = 0.6;
17
25
  return (0, engine_1.getRandom)() * factor + offset;
18
26
  }
19
27
  class CurvesPathGenerator {
20
- constructor() {
21
- this.options = {
22
- rndFunc: null,
23
- period: 100,
24
- nbHarmonics: 2,
25
- attenHarmonics: 0.8,
26
- lowValue: -0.03,
27
- highValue: 0.03,
28
- };
28
+ options;
29
+ _container;
30
+ constructor(container) {
31
+ this._container = container;
32
+ this.options = (0, engine_1.deepExtend)({}, defaultOptions);
29
33
  }
30
- generate(p) {
31
- if (!p.pathGen) {
32
- const options = this.options;
33
- p.pathGen = (0, Curves_js_1.CurvesPathGen)(options.rndFunc, options.period, options.nbHarmonics, options.attenHarmonics, options.lowValue, options.highValue);
34
+ generate(particle) {
35
+ if (!particle.pathGen) {
36
+ const { options } = this;
37
+ particle.pathGen = (0, Curves_js_1.CurvesPathGen)(options.rndFunc, options.period, options.nbHarmonics, options.attenHarmonics, options.lowValue, options.highValue);
34
38
  }
35
- if (!p.curveVelocity) {
36
- p.curveVelocity = engine_1.Vector.origin;
37
- p.curveVelocity.length = randomVelocity();
38
- p.curveVelocity.angle = (0, engine_1.getRandom)() * engine_1.doublePI;
39
+ if (particle.curveVelocity) {
40
+ particle.curveVelocity.length += 0.01;
41
+ particle.curveVelocity.angle = (particle.curveVelocity.angle + particle.pathGen()) % engine_1.doublePI;
39
42
  }
40
43
  else {
41
- p.curveVelocity.length += 0.01;
42
- p.curveVelocity.angle = (p.curveVelocity.angle + p.pathGen()) % engine_1.doublePI;
44
+ particle.curveVelocity = engine_1.Vector.origin;
45
+ particle.curveVelocity.length = randomVelocity();
46
+ particle.curveVelocity.angle = (0, engine_1.getRandom)() * engine_1.doublePI;
43
47
  }
44
- p.velocity.x = 0;
45
- p.velocity.y = 0;
46
- return p.curveVelocity;
48
+ particle.velocity.x = 0;
49
+ particle.velocity.y = 0;
50
+ return particle.curveVelocity;
47
51
  }
48
- init(container) {
49
- const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
52
+ init() {
53
+ const sourceOptions = this._container.actualOptions.particles.move.path.options;
50
54
  if ((0, engine_1.isFunction)(sourceOptions["rndFunc"])) {
51
- options.rndFunc = sourceOptions["rndFunc"];
55
+ this.options.rndFunc = sourceOptions["rndFunc"];
52
56
  }
53
57
  else if ((0, engine_1.isString)(sourceOptions["rndFunc"])) {
54
- options.rndFunc =
55
- globalThis[sourceOptions["rndFunc"]] ?? this.options.rndFunc;
58
+ this.options.rndFunc =
59
+ globalThis[sourceOptions["rndFunc"]] ??
60
+ this.options.rndFunc;
56
61
  }
57
- options.period = sourceOptions["period"] ?? options.period;
58
- options.nbHarmonics = sourceOptions["nbHarmonics"] ?? options.nbHarmonics;
59
- options.attenHarmonics = sourceOptions["attenHarmonics"] ?? options.attenHarmonics;
60
- options.lowValue = sourceOptions["lowValue"] ?? options.lowValue;
61
- options.highValue = sourceOptions["highValue"] ?? options.highValue;
62
+ this.options.period = sourceOptions["period"] ?? this.options.period;
63
+ this.options.nbHarmonics = sourceOptions["nbHarmonics"] ?? this.options.nbHarmonics;
64
+ this.options.attenHarmonics =
65
+ sourceOptions["attenHarmonics"] ?? this.options.attenHarmonics;
66
+ this.options.lowValue = sourceOptions["lowValue"] ?? this.options.lowValue;
67
+ this.options.highValue = sourceOptions["highValue"] ?? this.options.highValue;
62
68
  }
63
69
  reset(particle) {
64
70
  delete particle.pathGen;
package/umd/index.js CHANGED
@@ -46,11 +46,13 @@ var __importStar = (this && this.__importStar) || (function () {
46
46
  exports.curvesPathName = void 0;
47
47
  exports.loadCurvesPath = loadCurvesPath;
48
48
  exports.curvesPathName = "curvesPathGenerator";
49
- function loadCurvesPath(engine) {
50
- engine.checkVersion("4.0.0-alpha.0");
51
- engine.register(async (e) => {
52
- const { CurvesPathGenerator } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./CurvesPathGenerator.js"))) : new Promise((resolve_1, reject_1) => { require(["./CurvesPathGenerator.js"], resolve_1, reject_1); }).then(__importStar));
53
- e.addPathGenerator(exports.curvesPathName, new CurvesPathGenerator());
49
+ async function loadCurvesPath(engine) {
50
+ engine.checkVersion("4.0.0-alpha.14");
51
+ await engine.register(e => {
52
+ e.addPathGenerator(exports.curvesPathName, async (container) => {
53
+ const { CurvesPathGenerator } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./CurvesPathGenerator.js"))) : new Promise((resolve_1, reject_1) => { require(["./CurvesPathGenerator.js"], resolve_1, reject_1); }).then(__importStar));
54
+ return new CurvesPathGenerator(container);
55
+ });
54
56
  });
55
57
  }
56
58
  });
package/298.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 298.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_path_curves=this.webpackChunk_tsparticles_path_curves||[]).push([[298],{298(e,n,t){t.d(n,{CurvesPathGenerator:()=>r});var o=t(303);class r{constructor(){this.options={rndFunc:null,period:100,nbHarmonics:2,attenHarmonics:.8,lowValue:-.03,highValue:.03}}generate(e){if(!e.pathGen){const n=this.options;e.pathGen=function(e,n,t,r,c=0,i=1){const a=[],l=[],u=[],s=[],h=[],p=e??o.getRandom;let d=0;t<1&&(t=1);for(let e=1;e<=t;++e)a[e]=p(),l[e]=p(),u[e]=1===e?1:u[e-1]*r,d+=u[e],s[e]=e/n,h[e]=p();return u.forEach(((e,n)=>u[n]=e/d*(i-c))),()=>{let e,n,o=0;for(let r=t;r>=1;--r)e=h[r]+=s[r],h[r]>=1&&(e=h[r]-=1,a[r]=l[r],l[r]=p()),n=e**2*(3-2*e),o+=(a[r]*(1-n)+l[r]*n)*u[r];return o+c}}(n.rndFunc,n.period,n.nbHarmonics,n.attenHarmonics,n.lowValue,n.highValue)}return e.curveVelocity?(e.curveVelocity.length+=.01,e.curveVelocity.angle=(e.curveVelocity.angle+e.pathGen())%o.doublePI):(e.curveVelocity=o.Vector.origin,e.curveVelocity.length=.6*(0,o.getRandom)()+.8,e.curveVelocity.angle=(0,o.getRandom)()*o.doublePI),e.velocity.x=0,e.velocity.y=0,e.curveVelocity}init(e){const n=e.actualOptions.particles.move.path.options,{options:t}=this;(0,o.isFunction)(n.rndFunc)?t.rndFunc=n.rndFunc:(0,o.isString)(n.rndFunc)&&(t.rndFunc=globalThis[n.rndFunc]??this.options.rndFunc),t.period=n.period??t.period,t.nbHarmonics=n.nbHarmonics??t.nbHarmonics,t.attenHarmonics=n.attenHarmonics??t.attenHarmonics,t.lowValue=n.lowValue??t.lowValue,t.highValue=n.highValue??t.highValue}reset(e){delete e.pathGen,delete e.curveVelocity}update(){}}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Curves Path v4.0.0-alpha.0 by Matteo Bruni */
@@ -1 +0,0 @@
1
- /*! tsParticles Curves Path v4.0.0-alpha.0 by Matteo Bruni */