@tsparticles/shape-polygon 3.9.1 → 4.0.0-alpha.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/106.min.js +2 -0
- package/106.min.js.LICENSE.txt +1 -0
- package/144.min.js +2 -0
- package/144.min.js.LICENSE.txt +1 -0
- package/browser/TriangleDrawer.js +2 -2
- package/browser/Utils.js +0 -3
- package/browser/index.js +18 -12
- package/cjs/IPolygonShape.js +1 -2
- package/cjs/ISide.js +1 -2
- package/cjs/ISideCount.js +1 -2
- package/cjs/PolygonDrawer.js +2 -6
- package/cjs/PolygonDrawerBase.js +5 -9
- package/cjs/TriangleDrawer.js +4 -8
- package/cjs/Utils.js +3 -9
- package/cjs/index.js +18 -17
- package/dist_browser_PolygonDrawer_js.js +50 -0
- package/dist_browser_TriangleDrawer_js.js +50 -0
- package/esm/TriangleDrawer.js +2 -2
- package/esm/Utils.js +0 -3
- package/esm/index.js +18 -12
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.shape.polygon.js +209 -60
- package/tsparticles.shape.polygon.min.js +1 -1
- package/tsparticles.shape.polygon.min.js.LICENSE.txt +1 -1
- package/types/TriangleDrawer.d.ts +2 -2
- package/types/index.d.ts +3 -3
- package/umd/TriangleDrawer.js +2 -2
- package/umd/Utils.js +0 -3
- package/umd/index.js +53 -13
package/106.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 106.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_shape_polygon=this.webpackChunk_tsparticles_shape_polygon||[]).push([[106],{106(t,e,n){n.d(e,{PolygonDrawer:()=>o});var a=n(461);class o extends a.L{constructor(){super(...arguments),this.validTypes=["polygon"]}getCenter(t,e){return{x:-e/(t.sides/3.5),y:-e/.76}}getSidesData(t,e){const n=t.sides;return{count:{denominator:1,numerator:n},length:2.66*e/(n/3)}}}},461(t,e,n){n.d(e,{L:()=>r});var a=n(303);const o=0,s=0;class r{draw(t){const{particle:e,radius:n}=t;!function(t,e,n){const{context:r}=t,i=n.count.numerator*n.count.denominator,c=n.count.numerator/n.count.denominator,u=180*(c-2)/c,d=Math.PI-(0,a.degToRad)(u);r.beginPath(),r.translate(e.x,e.y),r.moveTo(o,s);for(let t=0;t<i;t++)r.lineTo(n.length,s),r.translate(n.length,s),r.rotate(d)}(t,this.getCenter(e,n),this.getSidesData(e,n))}getSidesCount(t){const e=t.shapeData;return Math.round((0,a.getRangeValue)(e?.sides??5))}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Polygon Shape v4.0.0-alpha.1 by Matteo Bruni */
|
package/144.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 144.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_shape_polygon=this.webpackChunk_tsparticles_shape_polygon||[]).push([[144],{144(t,e,n){n.d(e,{TriangleDrawer:()=>r});var a=n(461);class r extends a.L{constructor(){super(...arguments),this.validTypes=["triangle"]}getCenter(t,e){return{x:-e,y:e/1.66}}getSidesCount(){return 3}getSidesData(t,e){return{count:{denominator:2,numerator:3},length:2*e}}}},461(t,e,n){n.d(e,{L:()=>s});var a=n(303);const r=0,o=0;class s{draw(t){const{particle:e,radius:n}=t;!function(t,e,n){const{context:s}=t,i=n.count.numerator*n.count.denominator,u=n.count.numerator/n.count.denominator,c=180*(u-2)/u,l=Math.PI-(0,a.degToRad)(c);s.beginPath(),s.translate(e.x,e.y),s.moveTo(r,o);for(let t=0;t<i;t++)s.lineTo(n.length,o),s.translate(n.length,o),s.rotate(l)}(t,this.getCenter(e,n),this.getSidesData(e,n))}getSidesCount(t){const e=t.shapeData;return Math.round((0,a.getRangeValue)(e?.sides??5))}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Polygon Shape v4.0.0-alpha.1 by Matteo Bruni */
|
|
@@ -5,7 +5,7 @@ export class TriangleDrawer extends PolygonDrawerBase {
|
|
|
5
5
|
super(...arguments);
|
|
6
6
|
this.validTypes = ["triangle"];
|
|
7
7
|
}
|
|
8
|
-
getCenter(
|
|
8
|
+
getCenter(_particle, radius) {
|
|
9
9
|
return {
|
|
10
10
|
x: -radius,
|
|
11
11
|
y: radius / yFactor,
|
|
@@ -14,7 +14,7 @@ export class TriangleDrawer extends PolygonDrawerBase {
|
|
|
14
14
|
getSidesCount() {
|
|
15
15
|
return sides;
|
|
16
16
|
}
|
|
17
|
-
getSidesData(
|
|
17
|
+
getSidesData(_particle, radius) {
|
|
18
18
|
const diameter = radius * double;
|
|
19
19
|
return {
|
|
20
20
|
count: {
|
package/browser/Utils.js
CHANGED
|
@@ -2,9 +2,6 @@ import { degToRad } from "@tsparticles/engine";
|
|
|
2
2
|
const piDeg = 180, origin = { x: 0, y: 0 }, sidesOffset = 2;
|
|
3
3
|
export function drawPolygon(data, start, side) {
|
|
4
4
|
const { context } = data, sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (piDeg * (decimalSides - sidesOffset)) / decimalSides, interiorAngle = Math.PI - degToRad(interiorAngleDegrees);
|
|
5
|
-
if (!context) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
5
|
context.beginPath();
|
|
9
6
|
context.translate(start.x, start.y);
|
|
10
7
|
context.moveTo(origin.x, origin.y);
|
package/browser/index.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export function loadGenericPolygonShape(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { PolygonDrawer } = await import("./PolygonDrawer.js");
|
|
5
|
+
e.addShape(new PolygonDrawer());
|
|
6
|
+
});
|
|
6
7
|
}
|
|
7
|
-
export
|
|
8
|
-
engine.checkVersion("
|
|
9
|
-
|
|
8
|
+
export function loadTriangleShape(engine) {
|
|
9
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
10
|
+
engine.register(async (e) => {
|
|
11
|
+
const { TriangleDrawer } = await import("./TriangleDrawer.js");
|
|
12
|
+
e.addShape(new TriangleDrawer());
|
|
13
|
+
});
|
|
10
14
|
}
|
|
11
|
-
export
|
|
12
|
-
engine.checkVersion("
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
export function loadPolygonShape(engine) {
|
|
16
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
17
|
+
engine.register(e => {
|
|
18
|
+
loadGenericPolygonShape(e);
|
|
19
|
+
loadTriangleShape(e);
|
|
20
|
+
});
|
|
15
21
|
}
|
package/cjs/IPolygonShape.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/ISide.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/ISideCount.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/PolygonDrawer.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PolygonDrawer = void 0;
|
|
4
|
-
const PolygonDrawerBase_js_1 = require("./PolygonDrawerBase.js");
|
|
1
|
+
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
5
2
|
const sidesCenterFactor = 3.5, yFactor = 2.66, sidesFactor = 3;
|
|
6
|
-
class PolygonDrawer extends
|
|
3
|
+
export class PolygonDrawer extends PolygonDrawerBase {
|
|
7
4
|
constructor() {
|
|
8
5
|
super(...arguments);
|
|
9
6
|
this.validTypes = ["polygon"];
|
|
@@ -25,4 +22,3 @@ class PolygonDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
|
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
exports.PolygonDrawer = PolygonDrawer;
|
package/cjs/PolygonDrawerBase.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.PolygonDrawerBase = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const Utils_js_1 = require("./Utils.js");
|
|
1
|
+
import { getRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
import { drawPolygon } from "./Utils.js";
|
|
6
3
|
const defaultSides = 5;
|
|
7
|
-
class PolygonDrawerBase {
|
|
4
|
+
export class PolygonDrawerBase {
|
|
8
5
|
draw(data) {
|
|
9
6
|
const { particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius);
|
|
10
|
-
|
|
7
|
+
drawPolygon(data, start, side);
|
|
11
8
|
}
|
|
12
9
|
getSidesCount(particle) {
|
|
13
10
|
const polygon = particle.shapeData;
|
|
14
|
-
return Math.round(
|
|
11
|
+
return Math.round(getRangeValue(polygon?.sides ?? defaultSides));
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.PolygonDrawerBase = PolygonDrawerBase;
|
package/cjs/TriangleDrawer.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TriangleDrawer = void 0;
|
|
4
|
-
const PolygonDrawerBase_js_1 = require("./PolygonDrawerBase.js");
|
|
1
|
+
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
5
2
|
const yFactor = 1.66, sides = 3, double = 2;
|
|
6
|
-
class TriangleDrawer extends
|
|
3
|
+
export class TriangleDrawer extends PolygonDrawerBase {
|
|
7
4
|
constructor() {
|
|
8
5
|
super(...arguments);
|
|
9
6
|
this.validTypes = ["triangle"];
|
|
10
7
|
}
|
|
11
|
-
getCenter(
|
|
8
|
+
getCenter(_particle, radius) {
|
|
12
9
|
return {
|
|
13
10
|
x: -radius,
|
|
14
11
|
y: radius / yFactor,
|
|
@@ -17,7 +14,7 @@ class TriangleDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
|
|
|
17
14
|
getSidesCount() {
|
|
18
15
|
return sides;
|
|
19
16
|
}
|
|
20
|
-
getSidesData(
|
|
17
|
+
getSidesData(_particle, radius) {
|
|
21
18
|
const diameter = radius * double;
|
|
22
19
|
return {
|
|
23
20
|
count: {
|
|
@@ -28,4 +25,3 @@ class TriangleDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
|
|
|
28
25
|
};
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
exports.TriangleDrawer = TriangleDrawer;
|
package/cjs/Utils.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.drawPolygon = drawPolygon;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
1
|
+
import { degToRad } from "@tsparticles/engine";
|
|
5
2
|
const piDeg = 180, origin = { x: 0, y: 0 }, sidesOffset = 2;
|
|
6
|
-
function drawPolygon(data, start, side) {
|
|
7
|
-
const { context } = data, sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (piDeg * (decimalSides - sidesOffset)) / decimalSides, interiorAngle = Math.PI -
|
|
8
|
-
if (!context) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
3
|
+
export function drawPolygon(data, start, side) {
|
|
4
|
+
const { context } = data, sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (piDeg * (decimalSides - sidesOffset)) / decimalSides, interiorAngle = Math.PI - degToRad(interiorAngleDegrees);
|
|
11
5
|
context.beginPath();
|
|
12
6
|
context.translate(start.x, start.y);
|
|
13
7
|
context.moveTo(origin.x, origin.y);
|
package/cjs/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const TriangleDrawer_js_1 = require("./TriangleDrawer.js");
|
|
8
|
-
async function loadGenericPolygonShape(engine, refresh = true) {
|
|
9
|
-
engine.checkVersion("3.9.1");
|
|
10
|
-
await engine.addShape(new PolygonDrawer_js_1.PolygonDrawer(), refresh);
|
|
1
|
+
export function loadGenericPolygonShape(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { PolygonDrawer } = await import("./PolygonDrawer.js");
|
|
5
|
+
e.addShape(new PolygonDrawer());
|
|
6
|
+
});
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
engine.checkVersion("
|
|
14
|
-
|
|
8
|
+
export function loadTriangleShape(engine) {
|
|
9
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
10
|
+
engine.register(async (e) => {
|
|
11
|
+
const { TriangleDrawer } = await import("./TriangleDrawer.js");
|
|
12
|
+
e.addShape(new TriangleDrawer());
|
|
13
|
+
});
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
engine.checkVersion("
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export function loadPolygonShape(engine) {
|
|
16
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
17
|
+
engine.register(e => {
|
|
18
|
+
loadGenericPolygonShape(e);
|
|
19
|
+
loadTriangleShape(e);
|
|
20
|
+
});
|
|
20
21
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.1
|
|
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_shape_polygon"] = this["webpackChunk_tsparticles_shape_polygon"] || []).push([["dist_browser_PolygonDrawer_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/PolygonDrawer.js"
|
|
21
|
+
/*!***************************************!*\
|
|
22
|
+
!*** ./dist/browser/PolygonDrawer.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 */ PolygonDrawer: () => (/* binding */ PolygonDrawer)\n/* harmony export */ });\n/* harmony import */ var _PolygonDrawerBase_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PolygonDrawerBase.js */ \"./dist/browser/PolygonDrawerBase.js\");\n\nconst sidesCenterFactor = 3.5,\n yFactor = 2.66,\n sidesFactor = 3;\nclass PolygonDrawer extends _PolygonDrawerBase_js__WEBPACK_IMPORTED_MODULE_0__.PolygonDrawerBase {\n constructor() {\n super(...arguments);\n this.validTypes = [\"polygon\"];\n }\n getCenter(particle, radius) {\n return {\n x: -radius / (particle.sides / sidesCenterFactor),\n y: -radius / (yFactor / sidesCenterFactor)\n };\n }\n getSidesData(particle, radius) {\n const sides = particle.sides;\n return {\n count: {\n denominator: 1,\n numerator: sides\n },\n length: radius * yFactor / (sides / sidesFactor)\n };\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/PolygonDrawer.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/PolygonDrawerBase.js"
|
|
31
|
+
/*!*******************************************!*\
|
|
32
|
+
!*** ./dist/browser/PolygonDrawerBase.js ***!
|
|
33
|
+
\*******************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PolygonDrawerBase: () => (/* binding */ PolygonDrawerBase)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst defaultSides = 5;\nclass PolygonDrawerBase {\n draw(data) {\n const {\n particle,\n radius\n } = data,\n start = this.getCenter(particle, radius),\n side = this.getSidesData(particle, radius);\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawPolygon)(data, start, side);\n }\n getSidesCount(particle) {\n const polygon = particle.shapeData;\n return Math.round((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(polygon?.sides ?? defaultSides));\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/PolygonDrawerBase.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ },
|
|
39
|
+
|
|
40
|
+
/***/ "./dist/browser/Utils.js"
|
|
41
|
+
/*!*******************************!*\
|
|
42
|
+
!*** ./dist/browser/Utils.js ***!
|
|
43
|
+
\*******************************/
|
|
44
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
+
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawPolygon: () => (/* binding */ drawPolygon)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst piDeg = 180,\n origin = {\n x: 0,\n y: 0\n },\n sidesOffset = 2;\nfunction drawPolygon(data, start, side) {\n const {\n context\n } = data,\n sideCount = side.count.numerator * side.count.denominator,\n decimalSides = side.count.numerator / side.count.denominator,\n interiorAngleDegrees = piDeg * (decimalSides - sidesOffset) / decimalSides,\n interiorAngle = Math.PI - (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.degToRad)(interiorAngleDegrees);\n context.beginPath();\n context.translate(start.x, start.y);\n context.moveTo(origin.x, origin.y);\n for (let i = 0; i < sideCount; i++) {\n context.lineTo(side.length, origin.y);\n context.translate(side.length, origin.y);\n context.rotate(interiorAngle);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/Utils.js?\n}");
|
|
47
|
+
|
|
48
|
+
/***/ }
|
|
49
|
+
|
|
50
|
+
}]);
|
|
@@ -0,0 +1,50 @@
|
|
|
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.1
|
|
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_shape_polygon"] = this["webpackChunk_tsparticles_shape_polygon"] || []).push([["dist_browser_TriangleDrawer_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/PolygonDrawerBase.js"
|
|
21
|
+
/*!*******************************************!*\
|
|
22
|
+
!*** ./dist/browser/PolygonDrawerBase.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 */ PolygonDrawerBase: () => (/* binding */ PolygonDrawerBase)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst defaultSides = 5;\nclass PolygonDrawerBase {\n draw(data) {\n const {\n particle,\n radius\n } = data,\n start = this.getCenter(particle, radius),\n side = this.getSidesData(particle, radius);\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawPolygon)(data, start, side);\n }\n getSidesCount(particle) {\n const polygon = particle.shapeData;\n return Math.round((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(polygon?.sides ?? defaultSides));\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/PolygonDrawerBase.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/TriangleDrawer.js"
|
|
31
|
+
/*!****************************************!*\
|
|
32
|
+
!*** ./dist/browser/TriangleDrawer.js ***!
|
|
33
|
+
\****************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TriangleDrawer: () => (/* binding */ TriangleDrawer)\n/* harmony export */ });\n/* harmony import */ var _PolygonDrawerBase_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PolygonDrawerBase.js */ \"./dist/browser/PolygonDrawerBase.js\");\n\nconst yFactor = 1.66,\n sides = 3,\n double = 2;\nclass TriangleDrawer extends _PolygonDrawerBase_js__WEBPACK_IMPORTED_MODULE_0__.PolygonDrawerBase {\n constructor() {\n super(...arguments);\n this.validTypes = [\"triangle\"];\n }\n getCenter(_particle, radius) {\n return {\n x: -radius,\n y: radius / yFactor\n };\n }\n getSidesCount() {\n return sides;\n }\n getSidesData(_particle, radius) {\n const diameter = radius * double;\n return {\n count: {\n denominator: 2,\n numerator: 3\n },\n length: diameter\n };\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/TriangleDrawer.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ },
|
|
39
|
+
|
|
40
|
+
/***/ "./dist/browser/Utils.js"
|
|
41
|
+
/*!*******************************!*\
|
|
42
|
+
!*** ./dist/browser/Utils.js ***!
|
|
43
|
+
\*******************************/
|
|
44
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
+
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawPolygon: () => (/* binding */ drawPolygon)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst piDeg = 180,\n origin = {\n x: 0,\n y: 0\n },\n sidesOffset = 2;\nfunction drawPolygon(data, start, side) {\n const {\n context\n } = data,\n sideCount = side.count.numerator * side.count.denominator,\n decimalSides = side.count.numerator / side.count.denominator,\n interiorAngleDegrees = piDeg * (decimalSides - sidesOffset) / decimalSides,\n interiorAngle = Math.PI - (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.degToRad)(interiorAngleDegrees);\n context.beginPath();\n context.translate(start.x, start.y);\n context.moveTo(origin.x, origin.y);\n for (let i = 0; i < sideCount; i++) {\n context.lineTo(side.length, origin.y);\n context.translate(side.length, origin.y);\n context.rotate(interiorAngle);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/Utils.js?\n}");
|
|
47
|
+
|
|
48
|
+
/***/ }
|
|
49
|
+
|
|
50
|
+
}]);
|
package/esm/TriangleDrawer.js
CHANGED
|
@@ -5,7 +5,7 @@ export class TriangleDrawer extends PolygonDrawerBase {
|
|
|
5
5
|
super(...arguments);
|
|
6
6
|
this.validTypes = ["triangle"];
|
|
7
7
|
}
|
|
8
|
-
getCenter(
|
|
8
|
+
getCenter(_particle, radius) {
|
|
9
9
|
return {
|
|
10
10
|
x: -radius,
|
|
11
11
|
y: radius / yFactor,
|
|
@@ -14,7 +14,7 @@ export class TriangleDrawer extends PolygonDrawerBase {
|
|
|
14
14
|
getSidesCount() {
|
|
15
15
|
return sides;
|
|
16
16
|
}
|
|
17
|
-
getSidesData(
|
|
17
|
+
getSidesData(_particle, radius) {
|
|
18
18
|
const diameter = radius * double;
|
|
19
19
|
return {
|
|
20
20
|
count: {
|
package/esm/Utils.js
CHANGED
|
@@ -2,9 +2,6 @@ import { degToRad } from "@tsparticles/engine";
|
|
|
2
2
|
const piDeg = 180, origin = { x: 0, y: 0 }, sidesOffset = 2;
|
|
3
3
|
export function drawPolygon(data, start, side) {
|
|
4
4
|
const { context } = data, sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (piDeg * (decimalSides - sidesOffset)) / decimalSides, interiorAngle = Math.PI - degToRad(interiorAngleDegrees);
|
|
5
|
-
if (!context) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
5
|
context.beginPath();
|
|
9
6
|
context.translate(start.x, start.y);
|
|
10
7
|
context.moveTo(origin.x, origin.y);
|
package/esm/index.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export function loadGenericPolygonShape(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { PolygonDrawer } = await import("./PolygonDrawer.js");
|
|
5
|
+
e.addShape(new PolygonDrawer());
|
|
6
|
+
});
|
|
6
7
|
}
|
|
7
|
-
export
|
|
8
|
-
engine.checkVersion("
|
|
9
|
-
|
|
8
|
+
export function loadTriangleShape(engine) {
|
|
9
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
10
|
+
engine.register(async (e) => {
|
|
11
|
+
const { TriangleDrawer } = await import("./TriangleDrawer.js");
|
|
12
|
+
e.addShape(new TriangleDrawer());
|
|
13
|
+
});
|
|
10
14
|
}
|
|
11
|
-
export
|
|
12
|
-
engine.checkVersion("
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
export function loadPolygonShape(engine) {
|
|
16
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
17
|
+
engine.register(e => {
|
|
18
|
+
loadGenericPolygonShape(e);
|
|
19
|
+
loadTriangleShape(e);
|
|
20
|
+
});
|
|
15
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-polygon",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "tsParticles polygon shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -59,9 +59,10 @@
|
|
|
59
59
|
"./package.json": "./package.json"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@tsparticles/engine": "
|
|
62
|
+
"@tsparticles/engine": "4.0.0-alpha.1"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
|
+
"type": "module"
|
|
67
68
|
}
|