@tsparticles/path-curves 3.0.0-alpha.1 → 3.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/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # tsParticles Curves Path
4
4
 
5
- [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-path-curves/badge)](https://www.jsdelivr.com/package/npm/tsparticles-path-curves)
6
- [![npmjs](https://badge.fury.io/js/tsparticles-path-curves.svg)](https://www.npmjs.com/package/tsparticles-path-curves)
7
- [![npmjs](https://img.shields.io/npm/dt/tsparticles-path-curves)](https://www.npmjs.com/package/tsparticles-path-curves) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/path-curves/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/path-curves)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/path-curves.svg)](https://www.npmjs.com/package/@tsparticles/path-curves)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/path-curves)](https://www.npmjs.com/package/@tsparticles/path-curves) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
8
 
9
9
  [tsParticles](https://github.com/matteobruni/tsparticles) path plugin for curves movement.
10
10
 
@@ -42,29 +42,33 @@ Once the scripts are loaded you can set up `tsParticles` and the path plugin lik
42
42
  This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
43
 
44
44
  ```shell
45
- $ npm install tsparticles-path-curves
45
+ $ npm install @tsparticles/path-curves
46
46
  ```
47
47
 
48
48
  or
49
49
 
50
50
  ```shell
51
- $ yarn add tsparticles-path-curves
51
+ $ yarn add @tsparticles/path-curves
52
52
  ```
53
53
 
54
54
  Then you need to import it in the app, like this:
55
55
 
56
56
  ```javascript
57
- const { tsParticles } = require("tsparticles-engine");
58
- const { loadCurvesPath } = require("tsparticles-path-curves");
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadCurvesPath } = require("@tsparticles/path-curves");
59
59
 
60
- loadCurvesPath(tsParticles);
60
+ (async () => {
61
+ await loadCurvesPath(tsParticles);
62
+ })();
61
63
  ```
62
64
 
63
65
  or
64
66
 
65
67
  ```javascript
66
- import { tsParticles } from "tsparticles-engine";
67
- import { loadCurvesPath } from "tsparticles-path-curves";
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadCurvesPath } from "@tsparticles/path-curves";
68
70
 
69
- loadCurvesPath(tsParticles);
71
+ (async () => {
72
+ await loadCurvesPath(tsParticles);
73
+ })();
70
74
  ```
package/browser/Curves.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getRandom } from "@tsparticles/engine";
2
2
  export function CurvesPathGen(rndFunc, period, nbHarmonics, attenHarmonics, lowValue = 0, highValue = 1) {
3
- const arP0 = [], arP1 = [], amplitudes = [], increments = [], phases = [], randomFunc = rndFunc !== null && rndFunc !== void 0 ? rndFunc : getRandom;
3
+ const arP0 = [], arP1 = [], amplitudes = [], increments = [], phases = [], randomFunc = rndFunc ?? getRandom;
4
4
  let globAmplitude = 0;
5
5
  if (nbHarmonics < 1)
6
6
  nbHarmonics = 1;
@@ -1,6 +1,5 @@
1
+ import { Vector, getRandom, isFunction, isString } from "@tsparticles/engine";
1
2
  import { CurvesPathGen } from "./Curves";
2
- import { Vector } from "@tsparticles/engine";
3
- import { getRandom } from "@tsparticles/engine";
4
3
  export class CurvesPathGenerator {
5
4
  constructor() {
6
5
  this.options = {
@@ -13,11 +12,11 @@ export class CurvesPathGenerator {
13
12
  };
14
13
  }
15
14
  generate(p) {
16
- if (p.pathGen === undefined) {
15
+ if (!p.pathGen) {
17
16
  const options = this.options;
18
17
  p.pathGen = CurvesPathGen(options.rndFunc, options.period, options.nbHarmonics, options.attenHarmonics, options.lowValue, options.highValue);
19
18
  }
20
- if (p.curveVelocity === undefined) {
19
+ if (!p.curveVelocity) {
21
20
  p.curveVelocity = Vector.origin;
22
21
  p.curveVelocity.length = getRandom() * 0.6 + 0.8;
23
22
  p.curveVelocity.angle = getRandom() * Math.PI * 2;
@@ -31,20 +30,19 @@ export class CurvesPathGenerator {
31
30
  return p.curveVelocity;
32
31
  }
33
32
  init(container) {
34
- var _a, _b, _c, _d, _e;
35
- const sourceOptions = container.actualOptions.particles.move.path.options;
36
- if (typeof sourceOptions.rndFunc === "function") {
37
- this.options.rndFunc = sourceOptions.rndFunc;
33
+ const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
34
+ if (isFunction(sourceOptions.rndFunc)) {
35
+ options.rndFunc = sourceOptions.rndFunc;
38
36
  }
39
- else if (typeof sourceOptions.rndFunc === "string") {
40
- this.options.rndFunc =
37
+ else if (isString(sourceOptions.rndFunc)) {
38
+ options.rndFunc =
41
39
  window[sourceOptions.rndFunc] || this.options.rndFunc;
42
40
  }
43
- this.options.period = (_a = sourceOptions.period) !== null && _a !== void 0 ? _a : this.options.period;
44
- this.options.nbHarmonics = (_b = sourceOptions.nbHarmonics) !== null && _b !== void 0 ? _b : this.options.nbHarmonics;
45
- this.options.attenHarmonics = (_c = sourceOptions.attenHarmonics) !== null && _c !== void 0 ? _c : this.options.attenHarmonics;
46
- this.options.lowValue = (_d = sourceOptions.lowValue) !== null && _d !== void 0 ? _d : this.options.lowValue;
47
- this.options.highValue = (_e = sourceOptions.highValue) !== null && _e !== void 0 ? _e : this.options.highValue;
41
+ options.period = sourceOptions.period ?? options.period;
42
+ options.nbHarmonics = sourceOptions.nbHarmonics ?? options.nbHarmonics;
43
+ options.attenHarmonics = sourceOptions.attenHarmonics ?? options.attenHarmonics;
44
+ options.lowValue = sourceOptions.lowValue ?? options.lowValue;
45
+ options.highValue = sourceOptions.highValue ?? options.highValue;
48
46
  }
49
47
  reset(particle) {
50
48
  delete particle.pathGen;
package/browser/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CurvesPathGenerator } from "./CurvesPathGenerator";
2
2
  export const curvesPathName = "curvesPathGenerator";
3
- export function loadCurvesPath(engine) {
4
- engine.addPathGenerator(curvesPathName, new CurvesPathGenerator());
3
+ export async function loadCurvesPath(engine, refresh = true) {
4
+ await engine.addPathGenerator(curvesPathName, new CurvesPathGenerator(), refresh);
5
5
  }
package/cjs/Curves.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CurvesPathGen = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
5
  function CurvesPathGen(rndFunc, period, nbHarmonics, attenHarmonics, lowValue = 0, highValue = 1) {
6
- const arP0 = [], arP1 = [], amplitudes = [], increments = [], phases = [], randomFunc = rndFunc !== null && rndFunc !== void 0 ? rndFunc : engine_1.getRandom;
6
+ const arP0 = [], arP1 = [], amplitudes = [], increments = [], phases = [], randomFunc = rndFunc ?? engine_1.getRandom;
7
7
  let globAmplitude = 0;
8
8
  if (nbHarmonics < 1)
9
9
  nbHarmonics = 1;
@@ -25,7 +25,7 @@ function CurvesPathGen(rndFunc, period, nbHarmonics, attenHarmonics, lowValue =
25
25
  arP0[kh] = arP1[kh];
26
26
  arP1[kh] = randomFunc();
27
27
  }
28
- pfl = Math.pow(pf, 2) * (3 - 2 * pf);
28
+ pfl = pf ** 2 * (3 - 2 * pf);
29
29
  signal += (arP0[kh] * (1 - pfl) + arP1[kh] * pfl) * amplitudes[kh];
30
30
  }
31
31
  return signal + lowValue;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CurvesPathGenerator = void 0;
4
- const Curves_1 = require("./Curves");
5
4
  const engine_1 = require("@tsparticles/engine");
6
- const engine_2 = require("@tsparticles/engine");
5
+ const Curves_1 = require("./Curves");
7
6
  class CurvesPathGenerator {
8
7
  constructor() {
9
8
  this.options = {
@@ -16,14 +15,14 @@ class CurvesPathGenerator {
16
15
  };
17
16
  }
18
17
  generate(p) {
19
- if (p.pathGen === undefined) {
18
+ if (!p.pathGen) {
20
19
  const options = this.options;
21
20
  p.pathGen = (0, Curves_1.CurvesPathGen)(options.rndFunc, options.period, options.nbHarmonics, options.attenHarmonics, options.lowValue, options.highValue);
22
21
  }
23
- if (p.curveVelocity === undefined) {
22
+ if (!p.curveVelocity) {
24
23
  p.curveVelocity = engine_1.Vector.origin;
25
- p.curveVelocity.length = (0, engine_2.getRandom)() * 0.6 + 0.8;
26
- p.curveVelocity.angle = (0, engine_2.getRandom)() * Math.PI * 2;
24
+ p.curveVelocity.length = (0, engine_1.getRandom)() * 0.6 + 0.8;
25
+ p.curveVelocity.angle = (0, engine_1.getRandom)() * Math.PI * 2;
27
26
  }
28
27
  else {
29
28
  p.curveVelocity.length += 0.01;
@@ -34,20 +33,19 @@ class CurvesPathGenerator {
34
33
  return p.curveVelocity;
35
34
  }
36
35
  init(container) {
37
- var _a, _b, _c, _d, _e;
38
- const sourceOptions = container.actualOptions.particles.move.path.options;
39
- if (typeof sourceOptions.rndFunc === "function") {
40
- this.options.rndFunc = sourceOptions.rndFunc;
36
+ const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
37
+ if ((0, engine_1.isFunction)(sourceOptions.rndFunc)) {
38
+ options.rndFunc = sourceOptions.rndFunc;
41
39
  }
42
- else if (typeof sourceOptions.rndFunc === "string") {
43
- this.options.rndFunc =
40
+ else if ((0, engine_1.isString)(sourceOptions.rndFunc)) {
41
+ options.rndFunc =
44
42
  window[sourceOptions.rndFunc] || this.options.rndFunc;
45
43
  }
46
- this.options.period = (_a = sourceOptions.period) !== null && _a !== void 0 ? _a : this.options.period;
47
- this.options.nbHarmonics = (_b = sourceOptions.nbHarmonics) !== null && _b !== void 0 ? _b : this.options.nbHarmonics;
48
- this.options.attenHarmonics = (_c = sourceOptions.attenHarmonics) !== null && _c !== void 0 ? _c : this.options.attenHarmonics;
49
- this.options.lowValue = (_d = sourceOptions.lowValue) !== null && _d !== void 0 ? _d : this.options.lowValue;
50
- this.options.highValue = (_e = sourceOptions.highValue) !== null && _e !== void 0 ? _e : this.options.highValue;
44
+ options.period = sourceOptions.period ?? options.period;
45
+ options.nbHarmonics = sourceOptions.nbHarmonics ?? options.nbHarmonics;
46
+ options.attenHarmonics = sourceOptions.attenHarmonics ?? options.attenHarmonics;
47
+ options.lowValue = sourceOptions.lowValue ?? options.lowValue;
48
+ options.highValue = sourceOptions.highValue ?? options.highValue;
51
49
  }
52
50
  reset(particle) {
53
51
  delete particle.pathGen;
package/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadCurvesPath = exports.curvesPathName = void 0;
4
4
  const CurvesPathGenerator_1 = require("./CurvesPathGenerator");
5
5
  exports.curvesPathName = "curvesPathGenerator";
6
- function loadCurvesPath(engine) {
7
- engine.addPathGenerator(exports.curvesPathName, new CurvesPathGenerator_1.CurvesPathGenerator());
6
+ async function loadCurvesPath(engine, refresh = true) {
7
+ await engine.addPathGenerator(exports.curvesPathName, new CurvesPathGenerator_1.CurvesPathGenerator(), refresh);
8
8
  }
9
9
  exports.loadCurvesPath = loadCurvesPath;
package/esm/Curves.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getRandom } from "@tsparticles/engine";
2
2
  export function CurvesPathGen(rndFunc, period, nbHarmonics, attenHarmonics, lowValue = 0, highValue = 1) {
3
- const arP0 = [], arP1 = [], amplitudes = [], increments = [], phases = [], randomFunc = rndFunc !== null && rndFunc !== void 0 ? rndFunc : getRandom;
3
+ const arP0 = [], arP1 = [], amplitudes = [], increments = [], phases = [], randomFunc = rndFunc ?? getRandom;
4
4
  let globAmplitude = 0;
5
5
  if (nbHarmonics < 1)
6
6
  nbHarmonics = 1;
@@ -1,6 +1,5 @@
1
+ import { Vector, getRandom, isFunction, isString } from "@tsparticles/engine";
1
2
  import { CurvesPathGen } from "./Curves";
2
- import { Vector } from "@tsparticles/engine";
3
- import { getRandom } from "@tsparticles/engine";
4
3
  export class CurvesPathGenerator {
5
4
  constructor() {
6
5
  this.options = {
@@ -13,11 +12,11 @@ export class CurvesPathGenerator {
13
12
  };
14
13
  }
15
14
  generate(p) {
16
- if (p.pathGen === undefined) {
15
+ if (!p.pathGen) {
17
16
  const options = this.options;
18
17
  p.pathGen = CurvesPathGen(options.rndFunc, options.period, options.nbHarmonics, options.attenHarmonics, options.lowValue, options.highValue);
19
18
  }
20
- if (p.curveVelocity === undefined) {
19
+ if (!p.curveVelocity) {
21
20
  p.curveVelocity = Vector.origin;
22
21
  p.curveVelocity.length = getRandom() * 0.6 + 0.8;
23
22
  p.curveVelocity.angle = getRandom() * Math.PI * 2;
@@ -31,20 +30,19 @@ export class CurvesPathGenerator {
31
30
  return p.curveVelocity;
32
31
  }
33
32
  init(container) {
34
- var _a, _b, _c, _d, _e;
35
- const sourceOptions = container.actualOptions.particles.move.path.options;
36
- if (typeof sourceOptions.rndFunc === "function") {
37
- this.options.rndFunc = sourceOptions.rndFunc;
33
+ const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
34
+ if (isFunction(sourceOptions.rndFunc)) {
35
+ options.rndFunc = sourceOptions.rndFunc;
38
36
  }
39
- else if (typeof sourceOptions.rndFunc === "string") {
40
- this.options.rndFunc =
37
+ else if (isString(sourceOptions.rndFunc)) {
38
+ options.rndFunc =
41
39
  window[sourceOptions.rndFunc] || this.options.rndFunc;
42
40
  }
43
- this.options.period = (_a = sourceOptions.period) !== null && _a !== void 0 ? _a : this.options.period;
44
- this.options.nbHarmonics = (_b = sourceOptions.nbHarmonics) !== null && _b !== void 0 ? _b : this.options.nbHarmonics;
45
- this.options.attenHarmonics = (_c = sourceOptions.attenHarmonics) !== null && _c !== void 0 ? _c : this.options.attenHarmonics;
46
- this.options.lowValue = (_d = sourceOptions.lowValue) !== null && _d !== void 0 ? _d : this.options.lowValue;
47
- this.options.highValue = (_e = sourceOptions.highValue) !== null && _e !== void 0 ? _e : this.options.highValue;
41
+ options.period = sourceOptions.period ?? options.period;
42
+ options.nbHarmonics = sourceOptions.nbHarmonics ?? options.nbHarmonics;
43
+ options.attenHarmonics = sourceOptions.attenHarmonics ?? options.attenHarmonics;
44
+ options.lowValue = sourceOptions.lowValue ?? options.lowValue;
45
+ options.highValue = sourceOptions.highValue ?? options.highValue;
48
46
  }
49
47
  reset(particle) {
50
48
  delete particle.pathGen;
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CurvesPathGenerator } from "./CurvesPathGenerator";
2
2
  export const curvesPathName = "curvesPathGenerator";
3
- export function loadCurvesPath(engine) {
4
- engine.addPathGenerator(curvesPathName, new CurvesPathGenerator());
3
+ export async function loadCurvesPath(engine, refresh = true) {
4
+ await engine.addPathGenerator(curvesPathName, new CurvesPathGenerator(), refresh);
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/path-curves",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-beta.0",
4
4
  "description": "tsParticles curves path",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -63,6 +63,9 @@
63
63
  "@tsparticles/plugin",
64
64
  "@tsparticles/path"
65
65
  ],
66
+ "publishConfig": {
67
+ "access": "public"
68
+ },
66
69
  "author": "Matteo Bruni <matteo.bruni@me.com>",
67
70
  "license": "MIT",
68
71
  "bugs": {
@@ -73,6 +76,10 @@
73
76
  "type": "github",
74
77
  "url": "https://github.com/sponsors/matteobruni"
75
78
  },
79
+ {
80
+ "type": "github",
81
+ "url": "https://github.com/sponsors/tsparticles"
82
+ },
76
83
  {
77
84
  "type": "buymeacoffee",
78
85
  "url": "https://www.buymeacoffee.com/matteobruni"
@@ -83,10 +90,8 @@
83
90
  "unpkg": "tsparticles.path.curves.min.js",
84
91
  "module": "esm/index.js",
85
92
  "types": "types/index.d.ts",
86
- "publishConfig": {
87
- "access": "public"
88
- },
93
+ "sideEffects": false,
89
94
  "dependencies": {
90
- "@tsparticles/engine": "^3.0.0-alpha.1"
95
+ "@tsparticles/engine": "^3.0.0-beta.0"
91
96
  }
92
- }
97
+ }