@tsparticles/path-polygon 3.9.0 → 4.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/399.min.js +2 -0
- package/399.min.js.LICENSE.txt +1 -0
- package/browser/PolygonPathGenerator.js +6 -12
- package/browser/index.js +6 -4
- package/cjs/IPolygonPathOptions.js +1 -2
- package/cjs/PolygonPathGenerator.js +11 -21
- package/cjs/PolygonPathParticle.js +1 -2
- package/cjs/index.js +7 -9
- package/dist_browser_PolygonPathGenerator_js.js +30 -0
- package/esm/PolygonPathGenerator.js +6 -12
- package/esm/index.js +6 -4
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.path.polygon.js +209 -30
- package/tsparticles.path.polygon.min.js +1 -1
- package/tsparticles.path.polygon.min.js.LICENSE.txt +1 -1
- package/types/index.d.ts +1 -1
- package/umd/PolygonPathGenerator.js +6 -12
- package/umd/index.js +41 -5
package/399.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 399.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_path_polygon=this.webpackChunk_tsparticles_path_polygon||[]).push([[399],{399(t,e,s){s.d(e,{PolygonPathGenerator:()=>o});var i=s(303);class o{constructor(){this._createDirs=()=>{this.dirsList=[];for(let t=0;t<360;t+=360/this.options.sides){const e=this.options.angle+t;this.dirsList.push(i.Vector.create(Math.cos(e*Math.PI/180),Math.sin(e*Math.PI/180)))}},this.dirsList=[],this.options={sides:6,turnSteps:20,angle:30}}generate(t){const{sides:e}=this.options;t.hexStep??=0,t.hexDirection??=6===e?2*(3*(0,i.getRandom)()|0):(0,i.getRandom)()*e|0,t.hexSpeed??=t.velocity.length,t.hexStep%this.options.turnSteps==0&&(t.hexDirection=(0,i.getRandom)()>.5?(t.hexDirection+1)%e:(t.hexDirection+e-1)%e),t.velocity.x=0,t.velocity.y=0,t.hexStep++;const s=this.dirsList[t.hexDirection];return i.Vector.create(s.x*t.hexSpeed,s.y*t.hexSpeed)}init(t){const e=t.actualOptions.particles.move.path.options;this.options.sides=e.sides>0?e.sides:6,this.options.angle=e.angle??30,this.options.turnSteps=e.turnSteps>=0?e.turnSteps:20,this._createDirs()}reset(t){delete t.hexStep,delete t.hexDirection,delete t.hexSpeed}update(){}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Polygon Path v4.0.0-alpha.0 by Matteo Bruni */
|
|
@@ -17,15 +17,9 @@ export class PolygonPathGenerator {
|
|
|
17
17
|
}
|
|
18
18
|
generate(p) {
|
|
19
19
|
const { sides } = this.options;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (p.hexDirection === undefined) {
|
|
24
|
-
p.hexDirection = sides === 6 ? ((getRandom() * 3) | 0) * 2 : (getRandom() * sides) | 0;
|
|
25
|
-
}
|
|
26
|
-
if (p.hexSpeed === undefined) {
|
|
27
|
-
p.hexSpeed = p.velocity.length;
|
|
28
|
-
}
|
|
20
|
+
p.hexStep ??= 0;
|
|
21
|
+
p.hexDirection ??= sides === 6 ? ((getRandom() * 3) | 0) * 2 : (getRandom() * sides) | 0;
|
|
22
|
+
p.hexSpeed ??= p.velocity.length;
|
|
29
23
|
if (p.hexStep % this.options.turnSteps === 0) {
|
|
30
24
|
p.hexDirection = getRandom() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;
|
|
31
25
|
}
|
|
@@ -37,9 +31,9 @@ export class PolygonPathGenerator {
|
|
|
37
31
|
}
|
|
38
32
|
init(container) {
|
|
39
33
|
const options = container.actualOptions.particles.move.path.options;
|
|
40
|
-
this.options.sides = options
|
|
41
|
-
this.options.angle = options
|
|
42
|
-
this.options.turnSteps = options
|
|
34
|
+
this.options.sides = options["sides"] > 0 ? options["sides"] : 6;
|
|
35
|
+
this.options.angle = options["angle"] ?? 30;
|
|
36
|
+
this.options.turnSteps = options["turnSteps"] >= 0 ? options["turnSteps"] : 20;
|
|
43
37
|
this._createDirs();
|
|
44
38
|
}
|
|
45
39
|
reset(particle) {
|
package/browser/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { PolygonPathGenerator } from "./PolygonPathGenerator.js";
|
|
2
1
|
export const polygonPathName = "polygonPathGenerator";
|
|
3
|
-
export
|
|
4
|
-
engine.checkVersion("
|
|
5
|
-
|
|
2
|
+
export function loadPolygonPath(engine) {
|
|
3
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
4
|
+
engine.register(async (e) => {
|
|
5
|
+
const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
|
|
6
|
+
e.addPathGenerator(polygonPathName, new PolygonPathGenerator());
|
|
7
|
+
});
|
|
6
8
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.PolygonPathGenerator = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
class PolygonPathGenerator {
|
|
1
|
+
import { Vector, getRandom } from "@tsparticles/engine";
|
|
2
|
+
export class PolygonPathGenerator {
|
|
6
3
|
constructor() {
|
|
7
4
|
this._createDirs = () => {
|
|
8
5
|
this.dirsList = [];
|
|
9
6
|
for (let i = 0; i < 360; i += 360 / this.options.sides) {
|
|
10
7
|
const angle = this.options.angle + i;
|
|
11
|
-
this.dirsList.push(
|
|
8
|
+
this.dirsList.push(Vector.create(Math.cos((angle * Math.PI) / 180), Math.sin((angle * Math.PI) / 180)));
|
|
12
9
|
}
|
|
13
10
|
};
|
|
14
11
|
this.dirsList = [];
|
|
@@ -20,29 +17,23 @@ class PolygonPathGenerator {
|
|
|
20
17
|
}
|
|
21
18
|
generate(p) {
|
|
22
19
|
const { sides } = this.options;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (p.hexDirection === undefined) {
|
|
27
|
-
p.hexDirection = sides === 6 ? (((0, engine_1.getRandom)() * 3) | 0) * 2 : ((0, engine_1.getRandom)() * sides) | 0;
|
|
28
|
-
}
|
|
29
|
-
if (p.hexSpeed === undefined) {
|
|
30
|
-
p.hexSpeed = p.velocity.length;
|
|
31
|
-
}
|
|
20
|
+
p.hexStep ??= 0;
|
|
21
|
+
p.hexDirection ??= sides === 6 ? ((getRandom() * 3) | 0) * 2 : (getRandom() * sides) | 0;
|
|
22
|
+
p.hexSpeed ??= p.velocity.length;
|
|
32
23
|
if (p.hexStep % this.options.turnSteps === 0) {
|
|
33
|
-
p.hexDirection =
|
|
24
|
+
p.hexDirection = getRandom() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;
|
|
34
25
|
}
|
|
35
26
|
p.velocity.x = 0;
|
|
36
27
|
p.velocity.y = 0;
|
|
37
28
|
p.hexStep++;
|
|
38
29
|
const direction = this.dirsList[p.hexDirection];
|
|
39
|
-
return
|
|
30
|
+
return Vector.create(direction.x * p.hexSpeed, direction.y * p.hexSpeed);
|
|
40
31
|
}
|
|
41
32
|
init(container) {
|
|
42
33
|
const options = container.actualOptions.particles.move.path.options;
|
|
43
|
-
this.options.sides = options
|
|
44
|
-
this.options.angle = options
|
|
45
|
-
this.options.turnSteps = options
|
|
34
|
+
this.options.sides = options["sides"] > 0 ? options["sides"] : 6;
|
|
35
|
+
this.options.angle = options["angle"] ?? 30;
|
|
36
|
+
this.options.turnSteps = options["turnSteps"] >= 0 ? options["turnSteps"] : 20;
|
|
46
37
|
this._createDirs();
|
|
47
38
|
}
|
|
48
39
|
reset(particle) {
|
|
@@ -53,4 +44,3 @@ class PolygonPathGenerator {
|
|
|
53
44
|
update() {
|
|
54
45
|
}
|
|
55
46
|
}
|
|
56
|
-
exports.PolygonPathGenerator = PolygonPathGenerator;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
engine.checkVersion("3.9.0");
|
|
9
|
-
await engine.addPathGenerator(exports.polygonPathName, new PolygonPathGenerator_js_1.PolygonPathGenerator(), refresh);
|
|
1
|
+
export const polygonPathName = "polygonPathGenerator";
|
|
2
|
+
export function loadPolygonPath(engine) {
|
|
3
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
4
|
+
engine.register(async (e) => {
|
|
5
|
+
const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
|
|
6
|
+
e.addPathGenerator(polygonPathName, new PolygonPathGenerator());
|
|
7
|
+
});
|
|
10
8
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_path_polygon"] = this["webpackChunk_tsparticles_path_polygon"] || []).push([["dist_browser_PolygonPathGenerator_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/PolygonPathGenerator.js"
|
|
21
|
+
/*!**********************************************!*\
|
|
22
|
+
!*** ./dist/browser/PolygonPathGenerator.js ***!
|
|
23
|
+
\**********************************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PolygonPathGenerator: () => (/* binding */ PolygonPathGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass PolygonPathGenerator {\n constructor() {\n this._createDirs = () => {\n this.dirsList = [];\n for (let i = 0; i < 360; i += 360 / this.options.sides) {\n const angle = this.options.angle + i;\n this.dirsList.push(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(Math.cos(angle * Math.PI / 180), Math.sin(angle * Math.PI / 180)));\n }\n };\n this.dirsList = [];\n this.options = {\n sides: 6,\n turnSteps: 20,\n angle: 30\n };\n }\n generate(p) {\n const {\n sides\n } = this.options;\n p.hexStep ??= 0;\n p.hexDirection ??= sides === 6 ? ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * 3 | 0) * 2 : (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * sides | 0;\n p.hexSpeed ??= p.velocity.length;\n if (p.hexStep % this.options.turnSteps === 0) {\n p.hexDirection = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;\n }\n p.velocity.x = 0;\n p.velocity.y = 0;\n p.hexStep++;\n const direction = this.dirsList[p.hexDirection];\n return _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(direction.x * p.hexSpeed, direction.y * p.hexSpeed);\n }\n init(container) {\n const options = container.actualOptions.particles.move.path.options;\n this.options.sides = options[\"sides\"] > 0 ? options[\"sides\"] : 6;\n this.options.angle = options[\"angle\"] ?? 30;\n this.options.turnSteps = options[\"turnSteps\"] >= 0 ? options[\"turnSteps\"] : 20;\n this._createDirs();\n }\n reset(particle) {\n delete particle.hexStep;\n delete particle.hexDirection;\n delete particle.hexSpeed;\n }\n update() {}\n}\n\n//# sourceURL=webpack://@tsparticles/path-polygon/./dist/browser/PolygonPathGenerator.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ }
|
|
29
|
+
|
|
30
|
+
}]);
|
|
@@ -17,15 +17,9 @@ export class PolygonPathGenerator {
|
|
|
17
17
|
}
|
|
18
18
|
generate(p) {
|
|
19
19
|
const { sides } = this.options;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (p.hexDirection === undefined) {
|
|
24
|
-
p.hexDirection = sides === 6 ? ((getRandom() * 3) | 0) * 2 : (getRandom() * sides) | 0;
|
|
25
|
-
}
|
|
26
|
-
if (p.hexSpeed === undefined) {
|
|
27
|
-
p.hexSpeed = p.velocity.length;
|
|
28
|
-
}
|
|
20
|
+
p.hexStep ??= 0;
|
|
21
|
+
p.hexDirection ??= sides === 6 ? ((getRandom() * 3) | 0) * 2 : (getRandom() * sides) | 0;
|
|
22
|
+
p.hexSpeed ??= p.velocity.length;
|
|
29
23
|
if (p.hexStep % this.options.turnSteps === 0) {
|
|
30
24
|
p.hexDirection = getRandom() > 0.5 ? (p.hexDirection + 1) % sides : (p.hexDirection + sides - 1) % sides;
|
|
31
25
|
}
|
|
@@ -37,9 +31,9 @@ export class PolygonPathGenerator {
|
|
|
37
31
|
}
|
|
38
32
|
init(container) {
|
|
39
33
|
const options = container.actualOptions.particles.move.path.options;
|
|
40
|
-
this.options.sides = options
|
|
41
|
-
this.options.angle = options
|
|
42
|
-
this.options.turnSteps = options
|
|
34
|
+
this.options.sides = options["sides"] > 0 ? options["sides"] : 6;
|
|
35
|
+
this.options.angle = options["angle"] ?? 30;
|
|
36
|
+
this.options.turnSteps = options["turnSteps"] >= 0 ? options["turnSteps"] : 20;
|
|
43
37
|
this._createDirs();
|
|
44
38
|
}
|
|
45
39
|
reset(particle) {
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { PolygonPathGenerator } from "./PolygonPathGenerator.js";
|
|
2
1
|
export const polygonPathName = "polygonPathGenerator";
|
|
3
|
-
export
|
|
4
|
-
engine.checkVersion("
|
|
5
|
-
|
|
2
|
+
export function loadPolygonPath(engine) {
|
|
3
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
4
|
+
engine.register(async (e) => {
|
|
5
|
+
const { PolygonPathGenerator } = await import("./PolygonPathGenerator.js");
|
|
6
|
+
e.addPathGenerator(polygonPathName, new PolygonPathGenerator());
|
|
7
|
+
});
|
|
6
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/path-polygon",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles polygon path",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"./package.json": "./package.json"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@tsparticles/engine": "
|
|
108
|
-
}
|
|
107
|
+
"@tsparticles/engine": "4.0.0-alpha.0"
|
|
108
|
+
},
|
|
109
|
+
"type": "module"
|
|
109
110
|
}
|