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