@tsparticles/path-zig-zag 3.1.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/LICENSE +21 -0
- package/README.md +74 -0
- package/browser/ZigZagPathGenerator.js +34 -0
- package/browser/index.js +5 -0
- package/browser/package.json +1 -0
- package/cjs/ZigZagPathGenerator.js +38 -0
- package/cjs/index.js +9 -0
- package/cjs/package.json +1 -0
- package/esm/ZigZagPathGenerator.js +34 -0
- package/esm/index.js +5 -0
- package/esm/package.json +1 -0
- package/package.json +109 -0
- package/report.html +39 -0
- package/tsparticles.path.zigzag.js +152 -0
- package/tsparticles.path.zigzag.min.js +2 -0
- package/tsparticles.path.zigzag.min.js.LICENSE.txt +1 -0
- package/types/ZigZagPathGenerator.d.ts +22 -0
- package/types/index.d.ts +3 -0
- package/umd/ZigZagPathGenerator.js +48 -0
- package/umd/index.js +19 -0
|
@@ -0,0 +1,152 @@
|
|
|
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.1.0
|
|
8
|
+
*/
|
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
11
|
+
module.exports = factory(require("@tsparticles/engine"));
|
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
|
13
|
+
define(["@tsparticles/engine"], factory);
|
|
14
|
+
else {
|
|
15
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
|
+
}
|
|
18
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
|
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
|
20
|
+
/******/ "use strict";
|
|
21
|
+
/******/ var __webpack_modules__ = ({
|
|
22
|
+
|
|
23
|
+
/***/ 533:
|
|
24
|
+
/***/ ((module) => {
|
|
25
|
+
|
|
26
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
/******/ });
|
|
31
|
+
/************************************************************************/
|
|
32
|
+
/******/ // The module cache
|
|
33
|
+
/******/ var __webpack_module_cache__ = {};
|
|
34
|
+
/******/
|
|
35
|
+
/******/ // The require function
|
|
36
|
+
/******/ function __webpack_require__(moduleId) {
|
|
37
|
+
/******/ // Check if module is in cache
|
|
38
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
39
|
+
/******/ if (cachedModule !== undefined) {
|
|
40
|
+
/******/ return cachedModule.exports;
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ // Create a new module (and put it into the cache)
|
|
43
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
44
|
+
/******/ // no module.id needed
|
|
45
|
+
/******/ // no module.loaded needed
|
|
46
|
+
/******/ exports: {}
|
|
47
|
+
/******/ };
|
|
48
|
+
/******/
|
|
49
|
+
/******/ // Execute the module function
|
|
50
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // Return the exports of the module
|
|
53
|
+
/******/ return module.exports;
|
|
54
|
+
/******/ }
|
|
55
|
+
/******/
|
|
56
|
+
/************************************************************************/
|
|
57
|
+
/******/ /* webpack/runtime/define property getters */
|
|
58
|
+
/******/ (() => {
|
|
59
|
+
/******/ // define getter functions for harmony exports
|
|
60
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
61
|
+
/******/ for(var key in definition) {
|
|
62
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
63
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
64
|
+
/******/ }
|
|
65
|
+
/******/ }
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/ })();
|
|
68
|
+
/******/
|
|
69
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
|
+
/******/ (() => {
|
|
71
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
|
+
/******/ })();
|
|
73
|
+
/******/
|
|
74
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
75
|
+
/******/ (() => {
|
|
76
|
+
/******/ // define __esModule on exports
|
|
77
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
78
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
79
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
80
|
+
/******/ }
|
|
81
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
82
|
+
/******/ };
|
|
83
|
+
/******/ })();
|
|
84
|
+
/******/
|
|
85
|
+
/************************************************************************/
|
|
86
|
+
var __webpack_exports__ = {};
|
|
87
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
88
|
+
(() => {
|
|
89
|
+
// ESM COMPAT FLAG
|
|
90
|
+
__webpack_require__.r(__webpack_exports__);
|
|
91
|
+
|
|
92
|
+
// EXPORTS
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
+
loadZigZagPath: () => (/* binding */ loadZigZagPath),
|
|
95
|
+
zigZagPathName: () => (/* binding */ zigZagPathName)
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
99
|
+
var engine_root_window_ = __webpack_require__(533);
|
|
100
|
+
;// CONCATENATED MODULE: ./dist/browser/ZigZagPathGenerator.js
|
|
101
|
+
|
|
102
|
+
const angularFrequencyFactor = 0.5,
|
|
103
|
+
half = 0.5,
|
|
104
|
+
halfPI = Math.PI * half;
|
|
105
|
+
class ZigZagPathGenerator {
|
|
106
|
+
constructor() {
|
|
107
|
+
this.options = {
|
|
108
|
+
waveHeight: {
|
|
109
|
+
min: 0,
|
|
110
|
+
max: 3
|
|
111
|
+
},
|
|
112
|
+
waveLength: {
|
|
113
|
+
min: 0,
|
|
114
|
+
max: 5
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
generate(particle, delta) {
|
|
119
|
+
if (particle.zigzag === undefined) {
|
|
120
|
+
particle.zigzag = {
|
|
121
|
+
counter: (0,engine_root_window_.getRandom)(),
|
|
122
|
+
waveHeight: (0,engine_root_window_.getRangeValue)(this.options.waveHeight),
|
|
123
|
+
waveLength: (0,engine_root_window_.getRangeValue)(this.options.waveLength)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const angularFrequency = angularFrequencyFactor / particle.zigzag.waveLength * delta.factor;
|
|
127
|
+
particle.zigzag.counter += angularFrequency;
|
|
128
|
+
const zigzagAngle = particle.zigzag.waveHeight * Math.sin(particle.zigzag.counter);
|
|
129
|
+
particle.position.x += zigzagAngle * Math.cos(particle.velocity.angle + halfPI);
|
|
130
|
+
particle.position.y += zigzagAngle * Math.sin(particle.velocity.angle + halfPI);
|
|
131
|
+
return engine_root_window_.Vector.origin;
|
|
132
|
+
}
|
|
133
|
+
init(container) {
|
|
134
|
+
const options = container.actualOptions.particles.move.path.options;
|
|
135
|
+
this.options.waveLength = options.waveLength ?? this.options.waveLength;
|
|
136
|
+
this.options.waveHeight = options.waveHeight ?? this.options.waveHeight;
|
|
137
|
+
}
|
|
138
|
+
reset() {}
|
|
139
|
+
update() {}
|
|
140
|
+
}
|
|
141
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
142
|
+
|
|
143
|
+
const zigZagPathName = "zigZagPathGenerator";
|
|
144
|
+
async function loadZigZagPath(engine, refresh = true) {
|
|
145
|
+
await engine.addPathGenerator(zigZagPathName, new ZigZagPathGenerator(), refresh);
|
|
146
|
+
}
|
|
147
|
+
})();
|
|
148
|
+
|
|
149
|
+
/******/ return __webpack_exports__;
|
|
150
|
+
/******/ })()
|
|
151
|
+
;
|
|
152
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.path.zigzag.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 o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function i(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{loadZigZagPath:()=>r,zigZagPathName:()=>a});var e=i(533);const t=.5*Math.PI;class o{constructor(){this.options={waveHeight:{min:0,max:3},waveLength:{min:0,max:5}}}generate(o,i){void 0===o.zigzag&&(o.zigzag={counter:(0,e.getRandom)(),waveHeight:(0,e.getRangeValue)(this.options.waveHeight),waveLength:(0,e.getRangeValue)(this.options.waveLength)});const n=.5/o.zigzag.waveLength*i.factor;o.zigzag.counter+=n;const a=o.zigzag.waveHeight*Math.sin(o.zigzag.counter);return o.position.x+=a*Math.cos(o.velocity.angle+t),o.position.y+=a*Math.sin(o.velocity.angle+t),e.Vector.origin}init(e){const t=e.actualOptions.particles.move.path.options;this.options.waveLength=t.waveLength??this.options.waveLength,this.options.waveHeight=t.waveHeight??this.options.waveHeight}reset(){}update(){}}const a="zigZagPathGenerator";async function r(e,t=!0){await e.addPathGenerator(a,new o,t)}})(),n})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Zig Zag Path v3.1.0 by Matteo Bruni */
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Container, type IDelta, type IMovePathGenerator, type Particle, type RangeValue, Vector } from "@tsparticles/engine";
|
|
2
|
+
interface ZigZagParticle extends Particle {
|
|
3
|
+
zigzag?: ZigZagData;
|
|
4
|
+
}
|
|
5
|
+
interface ZigZagData {
|
|
6
|
+
counter: number;
|
|
7
|
+
waveHeight: number;
|
|
8
|
+
waveLength: number;
|
|
9
|
+
}
|
|
10
|
+
interface IZigZagOptions {
|
|
11
|
+
waveHeight: RangeValue;
|
|
12
|
+
waveLength: RangeValue;
|
|
13
|
+
}
|
|
14
|
+
export declare class ZigZagPathGenerator implements IMovePathGenerator {
|
|
15
|
+
options: IZigZagOptions;
|
|
16
|
+
constructor();
|
|
17
|
+
generate(particle: ZigZagParticle, delta: IDelta): Vector;
|
|
18
|
+
init(container: Container): void;
|
|
19
|
+
reset(): void;
|
|
20
|
+
update(): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ZigZagPathGenerator = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const angularFrequencyFactor = 0.5, half = 0.5, halfPI = Math.PI * half;
|
|
15
|
+
class ZigZagPathGenerator {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.options = {
|
|
18
|
+
waveHeight: { min: 0, max: 3 },
|
|
19
|
+
waveLength: { min: 0, max: 5 },
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
generate(particle, delta) {
|
|
23
|
+
if (particle.zigzag === undefined) {
|
|
24
|
+
particle.zigzag = {
|
|
25
|
+
counter: (0, engine_1.getRandom)(),
|
|
26
|
+
waveHeight: (0, engine_1.getRangeValue)(this.options.waveHeight),
|
|
27
|
+
waveLength: (0, engine_1.getRangeValue)(this.options.waveLength),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const angularFrequency = (angularFrequencyFactor / particle.zigzag.waveLength) * delta.factor;
|
|
31
|
+
particle.zigzag.counter += angularFrequency;
|
|
32
|
+
const zigzagAngle = particle.zigzag.waveHeight * Math.sin(particle.zigzag.counter);
|
|
33
|
+
particle.position.x += zigzagAngle * Math.cos(particle.velocity.angle + halfPI);
|
|
34
|
+
particle.position.y += zigzagAngle * Math.sin(particle.velocity.angle + halfPI);
|
|
35
|
+
return engine_1.Vector.origin;
|
|
36
|
+
}
|
|
37
|
+
init(container) {
|
|
38
|
+
const options = container.actualOptions.particles.move.path.options;
|
|
39
|
+
this.options.waveLength = options.waveLength ?? this.options.waveLength;
|
|
40
|
+
this.options.waveHeight = options.waveHeight ?? this.options.waveHeight;
|
|
41
|
+
}
|
|
42
|
+
reset() {
|
|
43
|
+
}
|
|
44
|
+
update() {
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.ZigZagPathGenerator = ZigZagPathGenerator;
|
|
48
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./ZigZagPathGenerator.js"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadZigZagPath = exports.zigZagPathName = void 0;
|
|
13
|
+
const ZigZagPathGenerator_js_1 = require("./ZigZagPathGenerator.js");
|
|
14
|
+
exports.zigZagPathName = "zigZagPathGenerator";
|
|
15
|
+
async function loadZigZagPath(engine, refresh = true) {
|
|
16
|
+
await engine.addPathGenerator(exports.zigZagPathName, new ZigZagPathGenerator_js_1.ZigZagPathGenerator(), refresh);
|
|
17
|
+
}
|
|
18
|
+
exports.loadZigZagPath = loadZigZagPath;
|
|
19
|
+
});
|