@tsparticles/path-curves 3.0.0-alpha.1 → 3.0.0-beta.1
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 +15 -11
- package/browser/Curves.js +1 -1
- package/browser/CurvesPathGenerator.js +14 -16
- package/browser/index.js +3 -3
- package/browser/package.json +1 -0
- package/cjs/Curves.js +2 -2
- package/cjs/CurvesPathGenerator.js +16 -18
- package/cjs/index.js +3 -3
- package/cjs/package.json +1 -0
- package/esm/Curves.js +1 -1
- package/esm/CurvesPathGenerator.js +14 -16
- package/esm/index.js +3 -3
- package/esm/package.json +1 -0
- package/package.json +23 -6
- package/report.html +4 -4
- package/tsparticles.path.curves.js +21 -20
- package/tsparticles.path.curves.min.js +1 -1
- package/tsparticles.path.curves.min.js.LICENSE.txt +1 -8
- package/types/CurvesPathGenerator.d.ts +3 -4
- package/types/index.d.ts +1 -1
- package/umd/Curves.js +1 -1
- package/umd/CurvesPathGenerator.js +17 -19
- package/umd/index.js +4 -4
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# tsParticles Curves Path
|
|
4
4
|
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/@tsparticles/path-curves)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/path-curves)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/path-curves) [](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
|
|
45
|
+
$ npm install @tsparticles/path-curves
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
or
|
|
49
49
|
|
|
50
50
|
```shell
|
|
51
|
-
$ yarn add tsparticles
|
|
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
|
|
58
|
-
const { loadCurvesPath } = require("tsparticles
|
|
57
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
58
|
+
const { loadCurvesPath } = require("@tsparticles/path-curves");
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
(async () => {
|
|
61
|
+
await loadCurvesPath(tsParticles);
|
|
62
|
+
})();
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
or
|
|
64
66
|
|
|
65
67
|
```javascript
|
|
66
|
-
import { tsParticles } from "tsparticles
|
|
67
|
-
import { loadCurvesPath } from "tsparticles
|
|
68
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
69
|
+
import { loadCurvesPath } from "@tsparticles/path-curves";
|
|
68
70
|
|
|
69
|
-
|
|
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
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import { getRandom } from "@tsparticles/engine";
|
|
1
|
+
import { Vector, getRandom, isFunction, isString } from "@tsparticles/engine";
|
|
2
|
+
import { CurvesPathGen } from "./Curves.js";
|
|
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
|
|
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
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 (
|
|
40
|
-
|
|
37
|
+
else if (isString(sourceOptions.rndFunc)) {
|
|
38
|
+
options.rndFunc =
|
|
41
39
|
window[sourceOptions.rndFunc] || this.options.rndFunc;
|
|
42
40
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
import { CurvesPathGenerator } from "./CurvesPathGenerator";
|
|
1
|
+
import { CurvesPathGenerator } from "./CurvesPathGenerator.js";
|
|
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
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
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
|
|
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 =
|
|
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
|
|
5
|
+
const Curves_js_1 = require("./Curves.js");
|
|
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
|
|
18
|
+
if (!p.pathGen) {
|
|
20
19
|
const options = this.options;
|
|
21
|
-
p.pathGen = (0,
|
|
20
|
+
p.pathGen = (0, Curves_js_1.CurvesPathGen)(options.rndFunc, options.period, options.nbHarmonics, options.attenHarmonics, options.lowValue, options.highValue);
|
|
22
21
|
}
|
|
23
|
-
if (p.curveVelocity
|
|
22
|
+
if (!p.curveVelocity) {
|
|
24
23
|
p.curveVelocity = engine_1.Vector.origin;
|
|
25
|
-
p.curveVelocity.length = (0,
|
|
26
|
-
p.curveVelocity.angle = (0,
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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 (
|
|
43
|
-
|
|
40
|
+
else if ((0, engine_1.isString)(sourceOptions.rndFunc)) {
|
|
41
|
+
options.rndFunc =
|
|
44
42
|
window[sourceOptions.rndFunc] || this.options.rndFunc;
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadCurvesPath = exports.curvesPathName = void 0;
|
|
4
|
-
const
|
|
4
|
+
const CurvesPathGenerator_js_1 = require("./CurvesPathGenerator.js");
|
|
5
5
|
exports.curvesPathName = "curvesPathGenerator";
|
|
6
|
-
function loadCurvesPath(engine) {
|
|
7
|
-
engine.addPathGenerator(exports.curvesPathName, new
|
|
6
|
+
async function loadCurvesPath(engine, refresh = true) {
|
|
7
|
+
await engine.addPathGenerator(exports.curvesPathName, new CurvesPathGenerator_js_1.CurvesPathGenerator(), refresh);
|
|
8
8
|
}
|
|
9
9
|
exports.loadCurvesPath = loadCurvesPath;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
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
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import { getRandom } from "@tsparticles/engine";
|
|
1
|
+
import { Vector, getRandom, isFunction, isString } from "@tsparticles/engine";
|
|
2
|
+
import { CurvesPathGen } from "./Curves.js";
|
|
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
|
|
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
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 (
|
|
40
|
-
|
|
37
|
+
else if (isString(sourceOptions.rndFunc)) {
|
|
38
|
+
options.rndFunc =
|
|
41
39
|
window[sourceOptions.rndFunc] || this.options.rndFunc;
|
|
42
40
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
import { CurvesPathGenerator } from "./CurvesPathGenerator";
|
|
1
|
+
import { CurvesPathGenerator } from "./CurvesPathGenerator.js";
|
|
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/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/path-curves",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
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,20 +76,34 @@
|
|
|
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"
|
|
79
86
|
}
|
|
80
87
|
],
|
|
81
|
-
"
|
|
88
|
+
"sideEffects": false,
|
|
82
89
|
"jsdelivr": "tsparticles.path.curves.min.js",
|
|
83
90
|
"unpkg": "tsparticles.path.curves.min.js",
|
|
91
|
+
"browser": "browser/index.js",
|
|
92
|
+
"main": "cjs/index.js",
|
|
84
93
|
"module": "esm/index.js",
|
|
85
94
|
"types": "types/index.d.ts",
|
|
86
|
-
"
|
|
87
|
-
"
|
|
95
|
+
"exports": {
|
|
96
|
+
".": {
|
|
97
|
+
"types": "./types/index.d.ts",
|
|
98
|
+
"browser": "./browser/index.js",
|
|
99
|
+
"import": "./esm/index.js",
|
|
100
|
+
"require": "./cjs/index.js",
|
|
101
|
+
"umd": "./umd/index.js",
|
|
102
|
+
"default": "./cjs/index.js"
|
|
103
|
+
},
|
|
104
|
+
"./package.json": "./package.json"
|
|
88
105
|
},
|
|
89
106
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "^3.0.0-
|
|
107
|
+
"@tsparticles/engine": "^3.0.0-beta.1"
|
|
91
108
|
}
|
|
92
|
-
}
|
|
109
|
+
}
|