@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
|
@@ -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
|
-
* v3.0.0-
|
|
7
|
+
* v3.0.0-beta.1
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -91,8 +91,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
curvesPathName: () => (/* binding */ curvesPathName),
|
|
95
|
+
loadCurvesPath: () => (/* binding */ loadCurvesPath)
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
@@ -105,7 +105,7 @@ function CurvesPathGen(rndFunc, period, nbHarmonics, attenHarmonics, lowValue =
|
|
|
105
105
|
amplitudes = [],
|
|
106
106
|
increments = [],
|
|
107
107
|
phases = [],
|
|
108
|
-
randomFunc = rndFunc
|
|
108
|
+
randomFunc = rndFunc ?? engine_root_window_.getRandom;
|
|
109
109
|
let globAmplitude = 0;
|
|
110
110
|
if (nbHarmonics < 1) nbHarmonics = 1;
|
|
111
111
|
for (let kh = 1; kh <= nbHarmonics; ++kh) {
|
|
@@ -137,7 +137,6 @@ function CurvesPathGen(rndFunc, period, nbHarmonics, attenHarmonics, lowValue =
|
|
|
137
137
|
;// CONCATENATED MODULE: ./dist/browser/CurvesPathGenerator.js
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
|
|
141
140
|
class CurvesPathGenerator {
|
|
142
141
|
constructor() {
|
|
143
142
|
this.options = {
|
|
@@ -150,11 +149,11 @@ class CurvesPathGenerator {
|
|
|
150
149
|
};
|
|
151
150
|
}
|
|
152
151
|
generate(p) {
|
|
153
|
-
if (p.pathGen
|
|
152
|
+
if (!p.pathGen) {
|
|
154
153
|
const options = this.options;
|
|
155
154
|
p.pathGen = CurvesPathGen(options.rndFunc, options.period, options.nbHarmonics, options.attenHarmonics, options.lowValue, options.highValue);
|
|
156
155
|
}
|
|
157
|
-
if (p.curveVelocity
|
|
156
|
+
if (!p.curveVelocity) {
|
|
158
157
|
p.curveVelocity = engine_root_window_.Vector.origin;
|
|
159
158
|
p.curveVelocity.length = (0,engine_root_window_.getRandom)() * 0.6 + 0.8;
|
|
160
159
|
p.curveVelocity.angle = (0,engine_root_window_.getRandom)() * Math.PI * 2;
|
|
@@ -167,18 +166,20 @@ class CurvesPathGenerator {
|
|
|
167
166
|
return p.curveVelocity;
|
|
168
167
|
}
|
|
169
168
|
init(container) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
169
|
+
const sourceOptions = container.actualOptions.particles.move.path.options,
|
|
170
|
+
{
|
|
171
|
+
options
|
|
172
|
+
} = this;
|
|
173
|
+
if ((0,engine_root_window_.isFunction)(sourceOptions.rndFunc)) {
|
|
174
|
+
options.rndFunc = sourceOptions.rndFunc;
|
|
175
|
+
} else if ((0,engine_root_window_.isString)(sourceOptions.rndFunc)) {
|
|
176
|
+
options.rndFunc = window[sourceOptions.rndFunc] || this.options.rndFunc;
|
|
176
177
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
options.period = sourceOptions.period ?? options.period;
|
|
179
|
+
options.nbHarmonics = sourceOptions.nbHarmonics ?? options.nbHarmonics;
|
|
180
|
+
options.attenHarmonics = sourceOptions.attenHarmonics ?? options.attenHarmonics;
|
|
181
|
+
options.lowValue = sourceOptions.lowValue ?? options.lowValue;
|
|
182
|
+
options.highValue = sourceOptions.highValue ?? options.highValue;
|
|
182
183
|
}
|
|
183
184
|
reset(particle) {
|
|
184
185
|
delete particle.pathGen;
|
|
@@ -189,8 +190,8 @@ class CurvesPathGenerator {
|
|
|
189
190
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
190
191
|
|
|
191
192
|
const curvesPathName = "curvesPathGenerator";
|
|
192
|
-
function loadCurvesPath(engine) {
|
|
193
|
-
engine.addPathGenerator(curvesPathName, new CurvesPathGenerator());
|
|
193
|
+
async function loadCurvesPath(engine, refresh = true) {
|
|
194
|
+
await engine.addPathGenerator(curvesPathName, new CurvesPathGenerator(), refresh);
|
|
194
195
|
}
|
|
195
196
|
})();
|
|
196
197
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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
|
|
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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{curvesPathName:()=>n,loadCurvesPath:()=>i});var e=o(533);class t{constructor(){this.options={rndFunc:null,period:100,nbHarmonics:2,attenHarmonics:.8,lowValue:-.03,highValue:.03}}generate(t){if(!t.pathGen){const n=this.options;t.pathGen=function(t,n,o,r,i=0,a=1){const c=[],l=[],s=[],u=[],p=[],d=t??e.getRandom;let h=0;o<1&&(o=1);for(let e=1;e<=o;++e)c[e]=d(),l[e]=d(),s[e]=1===e?1:s[e-1]*r,h+=s[e],u[e]=e/n,p[e]=d();return s.forEach(((e,t)=>s[t]=e/h*(a-i))),()=>{let e,t,n=0;for(let r=o;r>=1;--r)e=p[r]+=u[r],p[r]>=1&&(e=p[r]-=1,c[r]=l[r],l[r]=d()),t=e**2*(3-2*e),n+=(c[r]*(1-t)+l[r]*t)*s[r];return n+i}}(n.rndFunc,n.period,n.nbHarmonics,n.attenHarmonics,n.lowValue,n.highValue)}return t.curveVelocity?(t.curveVelocity.length+=.01,t.curveVelocity.angle=(t.curveVelocity.angle+t.pathGen())%(2*Math.PI)):(t.curveVelocity=e.Vector.origin,t.curveVelocity.length=.6*(0,e.getRandom)()+.8,t.curveVelocity.angle=(0,e.getRandom)()*Math.PI*2),t.velocity.x=0,t.velocity.y=0,t.curveVelocity}init(t){const n=t.actualOptions.particles.move.path.options,{options:o}=this;(0,e.isFunction)(n.rndFunc)?o.rndFunc=n.rndFunc:(0,e.isString)(n.rndFunc)&&(o.rndFunc=window[n.rndFunc]||this.options.rndFunc),o.period=n.period??o.period,o.nbHarmonics=n.nbHarmonics??o.nbHarmonics,o.attenHarmonics=n.attenHarmonics??o.attenHarmonics,o.lowValue=n.lowValue??o.lowValue,o.highValue=n.highValue??o.highValue}reset(e){delete e.pathGen,delete e.curveVelocity}update(){}}const n="curvesPathGenerator";async function i(e,o=!0){await e.addPathGenerator(n,new t,o)}})(),r})()));
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Author : Matteo Bruni
|
|
3
|
-
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
-
* Demo / Generator : https://particles.js.org/
|
|
5
|
-
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
-
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0.0-alpha.1
|
|
8
|
-
*/
|
|
1
|
+
/*! tsParticles Curves Path v3.0.0-beta.1 by Matteo Bruni */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { CurvesPathParticle } from "./CurvesPathParticle";
|
|
3
|
-
import type { ICurvesOptions } from "./ICurvesOptions";
|
|
4
|
-
import { Vector } from "@tsparticles/engine";
|
|
1
|
+
import { type Container, type IMovePathGenerator, Vector } from "@tsparticles/engine";
|
|
2
|
+
import type { CurvesPathParticle } from "./CurvesPathParticle.js";
|
|
3
|
+
import type { ICurvesOptions } from "./ICurvesOptions.js";
|
|
5
4
|
declare global {
|
|
6
5
|
interface Window {
|
|
7
6
|
[key: string]: unknown;
|
package/types/index.d.ts
CHANGED
package/umd/Curves.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
exports.CurvesPathGen = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
function CurvesPathGen(rndFunc, period, nbHarmonics, attenHarmonics, lowValue = 0, highValue = 1) {
|
|
15
|
-
const arP0 = [], arP1 = [], amplitudes = [], increments = [], phases = [], randomFunc = rndFunc
|
|
15
|
+
const arP0 = [], arP1 = [], amplitudes = [], increments = [], phases = [], randomFunc = rndFunc ?? engine_1.getRandom;
|
|
16
16
|
let globAmplitude = 0;
|
|
17
17
|
if (nbHarmonics < 1)
|
|
18
18
|
nbHarmonics = 1;
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Curves.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CurvesPathGenerator = void 0;
|
|
13
|
-
const Curves_1 = require("./Curves");
|
|
14
13
|
const engine_1 = require("@tsparticles/engine");
|
|
15
|
-
const
|
|
14
|
+
const Curves_js_1 = require("./Curves.js");
|
|
16
15
|
class CurvesPathGenerator {
|
|
17
16
|
constructor() {
|
|
18
17
|
this.options = {
|
|
@@ -25,14 +24,14 @@
|
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
26
|
generate(p) {
|
|
28
|
-
if (p.pathGen
|
|
27
|
+
if (!p.pathGen) {
|
|
29
28
|
const options = this.options;
|
|
30
|
-
p.pathGen = (0,
|
|
29
|
+
p.pathGen = (0, Curves_js_1.CurvesPathGen)(options.rndFunc, options.period, options.nbHarmonics, options.attenHarmonics, options.lowValue, options.highValue);
|
|
31
30
|
}
|
|
32
|
-
if (p.curveVelocity
|
|
31
|
+
if (!p.curveVelocity) {
|
|
33
32
|
p.curveVelocity = engine_1.Vector.origin;
|
|
34
|
-
p.curveVelocity.length = (0,
|
|
35
|
-
p.curveVelocity.angle = (0,
|
|
33
|
+
p.curveVelocity.length = (0, engine_1.getRandom)() * 0.6 + 0.8;
|
|
34
|
+
p.curveVelocity.angle = (0, engine_1.getRandom)() * Math.PI * 2;
|
|
36
35
|
}
|
|
37
36
|
else {
|
|
38
37
|
p.curveVelocity.length += 0.01;
|
|
@@ -43,20 +42,19 @@
|
|
|
43
42
|
return p.curveVelocity;
|
|
44
43
|
}
|
|
45
44
|
init(container) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.options.rndFunc = sourceOptions.rndFunc;
|
|
45
|
+
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
46
|
+
if ((0, engine_1.isFunction)(sourceOptions.rndFunc)) {
|
|
47
|
+
options.rndFunc = sourceOptions.rndFunc;
|
|
50
48
|
}
|
|
51
|
-
else if (
|
|
52
|
-
|
|
49
|
+
else if ((0, engine_1.isString)(sourceOptions.rndFunc)) {
|
|
50
|
+
options.rndFunc =
|
|
53
51
|
window[sourceOptions.rndFunc] || this.options.rndFunc;
|
|
54
52
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
options.period = sourceOptions.period ?? options.period;
|
|
54
|
+
options.nbHarmonics = sourceOptions.nbHarmonics ?? options.nbHarmonics;
|
|
55
|
+
options.attenHarmonics = sourceOptions.attenHarmonics ?? options.attenHarmonics;
|
|
56
|
+
options.lowValue = sourceOptions.lowValue ?? options.lowValue;
|
|
57
|
+
options.highValue = sourceOptions.highValue ?? options.highValue;
|
|
60
58
|
}
|
|
61
59
|
reset(particle) {
|
|
62
60
|
delete particle.pathGen;
|
package/umd/index.js
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./CurvesPathGenerator"], factory);
|
|
7
|
+
define(["require", "exports", "./CurvesPathGenerator.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.loadCurvesPath = exports.curvesPathName = void 0;
|
|
13
|
-
const
|
|
13
|
+
const CurvesPathGenerator_js_1 = require("./CurvesPathGenerator.js");
|
|
14
14
|
exports.curvesPathName = "curvesPathGenerator";
|
|
15
|
-
function loadCurvesPath(engine) {
|
|
16
|
-
engine.addPathGenerator(exports.curvesPathName, new
|
|
15
|
+
async function loadCurvesPath(engine, refresh = true) {
|
|
16
|
+
await engine.addPathGenerator(exports.curvesPathName, new CurvesPathGenerator_js_1.CurvesPathGenerator(), refresh);
|
|
17
17
|
}
|
|
18
18
|
exports.loadCurvesPath = loadCurvesPath;
|
|
19
19
|
});
|