@tsparticles/path-polygon 3.0.0-alpha.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 +70 -0
- package/browser/IPolygonPathOptions.js +1 -0
- package/browser/PolygonPathGenerator.js +55 -0
- package/browser/PolygonPathParticle.js +1 -0
- package/browser/index.js +5 -0
- package/cjs/IPolygonPathOptions.js +2 -0
- package/cjs/PolygonPathGenerator.js +59 -0
- package/cjs/PolygonPathParticle.js +2 -0
- package/cjs/index.js +9 -0
- package/esm/IPolygonPathOptions.js +1 -0
- package/esm/PolygonPathGenerator.js +55 -0
- package/esm/PolygonPathParticle.js +1 -0
- package/esm/index.js +5 -0
- package/package.json +92 -0
- package/report.html +39 -0
- package/tsparticles.path.polygon.js +162 -0
- package/tsparticles.path.polygon.min.js +2 -0
- package/tsparticles.path.polygon.min.js.LICENSE.txt +8 -0
- package/types/IPolygonPathOptions.d.ts +5 -0
- package/types/PolygonPathGenerator.d.ts +14 -0
- package/types/PolygonPathParticle.d.ts +6 -0
- package/types/index.d.ts +3 -0
- package/umd/IPolygonPathOptions.js +12 -0
- package/umd/PolygonPathGenerator.js +69 -0
- package/umd/PolygonPathParticle.js +12 -0
- package/umd/index.js +19 -0
|
@@ -0,0 +1,162 @@
|
|
|
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.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
|
+
"loadPolygonPath": () => (/* binding */ loadPolygonPath),
|
|
95
|
+
"polygonPathName": () => (/* binding */ polygonPathName)
|
|
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/PolygonPathGenerator.js
|
|
101
|
+
|
|
102
|
+
class PolygonPathGenerator {
|
|
103
|
+
constructor() {
|
|
104
|
+
this.dirsList = [];
|
|
105
|
+
this.options = {
|
|
106
|
+
sides: 6,
|
|
107
|
+
turnSteps: 20,
|
|
108
|
+
angle: 30
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
generate(p) {
|
|
112
|
+
if (p.hexStep === undefined) {
|
|
113
|
+
p.hexStep = 0;
|
|
114
|
+
}
|
|
115
|
+
if (p.hexDirection === undefined) {
|
|
116
|
+
p.hexDirection = this.options.sides === 6 ? ((0,engine_root_window_.getRandom)() * 3 | 0) * 2 : (0,engine_root_window_.getRandom)() * this.options.sides | 0;
|
|
117
|
+
}
|
|
118
|
+
if (p.hexSpeed === undefined) {
|
|
119
|
+
p.hexSpeed = p.velocity.length;
|
|
120
|
+
}
|
|
121
|
+
if (p.hexStep % this.options.turnSteps === 0) {
|
|
122
|
+
p.hexDirection = (0,engine_root_window_.getRandom)() > 0.5 ? (p.hexDirection + 1) % this.options.sides : (p.hexDirection + this.options.sides - 1) % this.options.sides;
|
|
123
|
+
}
|
|
124
|
+
p.velocity.x = 0;
|
|
125
|
+
p.velocity.y = 0;
|
|
126
|
+
p.hexStep++;
|
|
127
|
+
return engine_root_window_.Vector.create(this.dirsList[p.hexDirection].x * p.hexSpeed, this.dirsList[p.hexDirection].y * p.hexSpeed);
|
|
128
|
+
}
|
|
129
|
+
init(container) {
|
|
130
|
+
var _a;
|
|
131
|
+
const options = container.actualOptions.particles.move.path.options;
|
|
132
|
+
this.options.sides = options.sides > 0 ? options.sides : 6;
|
|
133
|
+
this.options.angle = (_a = options.angle) !== null && _a !== void 0 ? _a : 30;
|
|
134
|
+
this.options.turnSteps = options.turnSteps >= 0 ? options.turnSteps : 20;
|
|
135
|
+
this.createDirs();
|
|
136
|
+
}
|
|
137
|
+
reset(particle) {
|
|
138
|
+
delete particle.hexStep;
|
|
139
|
+
delete particle.hexDirection;
|
|
140
|
+
delete particle.hexSpeed;
|
|
141
|
+
}
|
|
142
|
+
update() {}
|
|
143
|
+
createDirs() {
|
|
144
|
+
this.dirsList = [];
|
|
145
|
+
for (let i = 0; i < 360; i += 360 / this.options.sides) {
|
|
146
|
+
const angle = this.options.angle + i;
|
|
147
|
+
this.dirsList.push(engine_root_window_.Vector.create(Math.cos(angle * Math.PI / 180), Math.sin(angle * Math.PI / 180)));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
152
|
+
|
|
153
|
+
const polygonPathName = "polygonPathGenerator";
|
|
154
|
+
function loadPolygonPath(engine) {
|
|
155
|
+
engine.addPathGenerator(polygonPathName, new PolygonPathGenerator());
|
|
156
|
+
}
|
|
157
|
+
})();
|
|
158
|
+
|
|
159
|
+
/******/ return __webpack_exports__;
|
|
160
|
+
/******/ })()
|
|
161
|
+
;
|
|
162
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.path.polygon.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 i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},i={};function o(e){var s=i[e];if(void 0!==s)return s.exports;var r=i[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},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 s={};return(()=>{o.r(s),o.d(s,{loadPolygonPath:()=>r,polygonPathName:()=>i});var e=o(533);class t{constructor(){this.dirsList=[],this.options={sides:6,turnSteps:20,angle:30}}generate(t){return void 0===t.hexStep&&(t.hexStep=0),void 0===t.hexDirection&&(t.hexDirection=6===this.options.sides?2*(3*(0,e.getRandom)()|0):(0,e.getRandom)()*this.options.sides|0),void 0===t.hexSpeed&&(t.hexSpeed=t.velocity.length),t.hexStep%this.options.turnSteps==0&&(t.hexDirection=(0,e.getRandom)()>.5?(t.hexDirection+1)%this.options.sides:(t.hexDirection+this.options.sides-1)%this.options.sides),t.velocity.x=0,t.velocity.y=0,t.hexStep++,e.Vector.create(this.dirsList[t.hexDirection].x*t.hexSpeed,this.dirsList[t.hexDirection].y*t.hexSpeed)}init(e){var t;const i=e.actualOptions.particles.move.path.options;this.options.sides=i.sides>0?i.sides:6,this.options.angle=null!==(t=i.angle)&&void 0!==t?t:30,this.options.turnSteps=i.turnSteps>=0?i.turnSteps:20,this.createDirs()}reset(e){delete e.hexStep,delete e.hexDirection,delete e.hexSpeed}update(){}createDirs(){this.dirsList=[];for(let t=0;t<360;t+=360/this.options.sides){const i=this.options.angle+t;this.dirsList.push(e.Vector.create(Math.cos(i*Math.PI/180),Math.sin(i*Math.PI/180)))}}}const i="polygonPathGenerator";function r(e){e.addPathGenerator(i,new t)}})(),s})()));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Container, ICoordinates, IMovePathGenerator } from "@tsparticles/engine";
|
|
2
|
+
import { Vector } from "@tsparticles/engine";
|
|
3
|
+
import type { IPolygonPathOptions } from "./IPolygonPathOptions";
|
|
4
|
+
import type { PolygonPathParticle } from "./PolygonPathParticle";
|
|
5
|
+
export declare class PolygonPathGenerator implements IMovePathGenerator {
|
|
6
|
+
dirsList: ICoordinates[];
|
|
7
|
+
readonly options: IPolygonPathOptions;
|
|
8
|
+
constructor();
|
|
9
|
+
generate(p: PolygonPathParticle): Vector;
|
|
10
|
+
init(container: Container): void;
|
|
11
|
+
reset(particle: PolygonPathParticle): void;
|
|
12
|
+
update(): void;
|
|
13
|
+
private createDirs;
|
|
14
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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.PolygonPathGenerator = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class PolygonPathGenerator {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.dirsList = [];
|
|
17
|
+
this.options = {
|
|
18
|
+
sides: 6,
|
|
19
|
+
turnSteps: 20,
|
|
20
|
+
angle: 30,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
generate(p) {
|
|
24
|
+
if (p.hexStep === undefined) {
|
|
25
|
+
p.hexStep = 0;
|
|
26
|
+
}
|
|
27
|
+
if (p.hexDirection === undefined) {
|
|
28
|
+
p.hexDirection =
|
|
29
|
+
this.options.sides === 6 ? (((0, engine_1.getRandom)() * 3) | 0) * 2 : ((0, engine_1.getRandom)() * this.options.sides) | 0;
|
|
30
|
+
}
|
|
31
|
+
if (p.hexSpeed === undefined) {
|
|
32
|
+
p.hexSpeed = p.velocity.length;
|
|
33
|
+
}
|
|
34
|
+
if (p.hexStep % this.options.turnSteps === 0) {
|
|
35
|
+
p.hexDirection =
|
|
36
|
+
(0, engine_1.getRandom)() > 0.5
|
|
37
|
+
? (p.hexDirection + 1) % this.options.sides
|
|
38
|
+
: (p.hexDirection + this.options.sides - 1) % this.options.sides;
|
|
39
|
+
}
|
|
40
|
+
p.velocity.x = 0;
|
|
41
|
+
p.velocity.y = 0;
|
|
42
|
+
p.hexStep++;
|
|
43
|
+
return engine_1.Vector.create(this.dirsList[p.hexDirection].x * p.hexSpeed, this.dirsList[p.hexDirection].y * p.hexSpeed);
|
|
44
|
+
}
|
|
45
|
+
init(container) {
|
|
46
|
+
var _a;
|
|
47
|
+
const options = container.actualOptions.particles.move.path.options;
|
|
48
|
+
this.options.sides = options.sides > 0 ? options.sides : 6;
|
|
49
|
+
this.options.angle = (_a = options.angle) !== null && _a !== void 0 ? _a : 30;
|
|
50
|
+
this.options.turnSteps = options.turnSteps >= 0 ? options.turnSteps : 20;
|
|
51
|
+
this.createDirs();
|
|
52
|
+
}
|
|
53
|
+
reset(particle) {
|
|
54
|
+
delete particle.hexStep;
|
|
55
|
+
delete particle.hexDirection;
|
|
56
|
+
delete particle.hexSpeed;
|
|
57
|
+
}
|
|
58
|
+
update() {
|
|
59
|
+
}
|
|
60
|
+
createDirs() {
|
|
61
|
+
this.dirsList = [];
|
|
62
|
+
for (let i = 0; i < 360; i += 360 / this.options.sides) {
|
|
63
|
+
const angle = this.options.angle + i;
|
|
64
|
+
this.dirsList.push(engine_1.Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.PolygonPathGenerator = PolygonPathGenerator;
|
|
69
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
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", "./PolygonPathGenerator"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadPolygonPath = exports.polygonPathName = void 0;
|
|
13
|
+
const PolygonPathGenerator_1 = require("./PolygonPathGenerator");
|
|
14
|
+
exports.polygonPathName = "polygonPathGenerator";
|
|
15
|
+
function loadPolygonPath(engine) {
|
|
16
|
+
engine.addPathGenerator(exports.polygonPathName, new PolygonPathGenerator_1.PolygonPathGenerator());
|
|
17
|
+
}
|
|
18
|
+
exports.loadPolygonPath = loadPolygonPath;
|
|
19
|
+
});
|