@tsparticles/shape-polygon 4.0.0-alpha.23 → 4.0.0-alpha.24
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/118.min.js +1 -1
- package/144.min.js +1 -1
- package/browser/PolygonDrawer.js +2 -8
- package/browser/PolygonDrawerBase.js +3 -3
- package/browser/TriangleDrawer.js +2 -9
- package/browser/Utils.js +33 -10
- package/browser/index.js +3 -3
- package/cjs/PolygonDrawer.js +2 -8
- package/cjs/PolygonDrawerBase.js +3 -3
- package/cjs/TriangleDrawer.js +2 -9
- package/cjs/Utils.js +33 -10
- package/cjs/index.js +3 -3
- package/dist_browser_PolygonDrawer_js.js +4 -4
- package/dist_browser_TriangleDrawer_js.js +4 -4
- package/esm/PolygonDrawer.js +2 -8
- package/esm/PolygonDrawerBase.js +3 -3
- package/esm/TriangleDrawer.js +2 -9
- package/esm/Utils.js +33 -10
- package/esm/index.js +3 -3
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.shape.polygon.js +2 -2
- package/tsparticles.shape.polygon.min.js +1 -1
- package/types/PolygonDrawer.d.ts +1 -2
- package/types/PolygonDrawerBase.d.ts +1 -2
- package/types/TriangleDrawer.d.ts +1 -2
- package/types/Utils.d.ts +2 -2
- package/umd/PolygonDrawer.js +2 -8
- package/umd/PolygonDrawerBase.js +2 -2
- package/umd/TriangleDrawer.js +2 -9
- package/umd/Utils.js +32 -9
- package/umd/index.js +3 -3
package/118.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_shape_polygon=this.webpackChunk_tsparticles_shape_polygon||[]).push([[118],{415(t,
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_shape_polygon=this.webpackChunk_tsparticles_shape_polygon||[]).push([[118],{415(e,t,n){n.d(t,{L:()=>r});var a=n(303);let o=new Map;class r{draw(e){let{particle:t,radius:n}=e;!function(e,t){let{context:n,radius:r}=e,s=function(e){let t=o.get(e);if(t)return t;let n=a.doublePI/e,r=(-Math.PI+(e%a.double?0:n))*a.half,s=[];for(let t=0;t<e;t++){let e=r+t*n;s[t]={x:Math.cos(e),y:Math.sin(e)}}return o.set(e,s),s}(t.count.numerator/t.count.denominator);n.beginPath();for(let e=0;e<s.length;e++){let t=s[e];if(!t)continue;let a=t.x*r,o=t.y*r;e?n.lineTo(a,o):n.moveTo(a,o)}n.closePath()}(e,this.getSidesData(t,n))}getSidesCount(e){let t=e.shapeData;return Math.round((0,a.getRangeValue)(t?.sides??5))}}},118(e,t,n){n.d(t,{TriangleDrawer:()=>r});var a=n(303),o=n(415);class r extends o.L{getSidesCount(){return 3}getSidesData(e,t){return{count:{denominator:2,numerator:3},length:t*a.double}}}}}]);
|
package/144.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_shape_polygon=this.webpackChunk_tsparticles_shape_polygon||[]).push([[144],{144(t,e,n){n.d(e,{PolygonDrawer:()=>
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_shape_polygon=this.webpackChunk_tsparticles_shape_polygon||[]).push([[144],{144(t,e,n){n.d(e,{PolygonDrawer:()=>o});var a=n(415);class o extends a.L{getSidesData(t,e){let{sides:n}=t;return{count:{denominator:1,numerator:n},length:2.66*e/(n/3)}}}},415(t,e,n){n.d(e,{L:()=>l});var a=n(303);let o=new Map;class l{draw(t){let{particle:e,radius:n}=t;!function(t,e){let{context:n,radius:l}=t,s=function(t){let e=o.get(t);if(e)return e;let n=a.doublePI/t,l=(-Math.PI+(t%a.double?0:n))*a.half,s=[];for(let e=0;e<t;e++){let t=l+e*n;s[e]={x:Math.cos(t),y:Math.sin(t)}}return o.set(t,s),s}(e.count.numerator/e.count.denominator);n.beginPath();for(let t=0;t<s.length;t++){let e=s[t];if(!e)continue;let a=e.x*l,o=e.y*l;t?n.lineTo(a,o):n.moveTo(a,o)}n.closePath()}(t,this.getSidesData(e,n))}getSidesCount(t){let e=t.shapeData;return Math.round((0,a.getRangeValue)(e?.sides??5))}}}}]);
|
package/browser/PolygonDrawer.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
2
|
-
const
|
|
2
|
+
const yFactor = 2.66, sidesFactor = 3;
|
|
3
3
|
export class PolygonDrawer extends PolygonDrawerBase {
|
|
4
|
-
getCenter(particle, radius) {
|
|
5
|
-
return {
|
|
6
|
-
x: -radius / (particle.sides / sidesCenterFactor),
|
|
7
|
-
y: -radius / (yFactor / sidesCenterFactor),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
4
|
getSidesData(particle, radius) {
|
|
11
|
-
const sides = particle
|
|
5
|
+
const { sides } = particle;
|
|
12
6
|
return {
|
|
13
7
|
count: {
|
|
14
8
|
denominator: 1,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getRangeValue
|
|
1
|
+
import { getRangeValue } from "@tsparticles/engine";
|
|
2
2
|
import { drawPolygon } from "./Utils.js";
|
|
3
3
|
const defaultSides = 5;
|
|
4
4
|
export class PolygonDrawerBase {
|
|
5
5
|
draw(data) {
|
|
6
|
-
const { particle, radius } = data,
|
|
7
|
-
drawPolygon(data,
|
|
6
|
+
const { particle, radius } = data, side = this.getSidesData(particle, radius);
|
|
7
|
+
drawPolygon(data, side);
|
|
8
8
|
}
|
|
9
9
|
getSidesCount(particle) {
|
|
10
10
|
const polygon = particle.shapeData;
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { double } from "@tsparticles/engine";
|
|
2
2
|
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
3
|
-
const
|
|
3
|
+
const sides = 3;
|
|
4
4
|
export class TriangleDrawer extends PolygonDrawerBase {
|
|
5
|
-
getCenter(_particle, radius) {
|
|
6
|
-
return {
|
|
7
|
-
x: -radius,
|
|
8
|
-
y: radius / yFactor,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
5
|
getSidesCount() {
|
|
12
6
|
return sides;
|
|
13
7
|
}
|
|
14
8
|
getSidesData(_particle, radius) {
|
|
15
|
-
const diameter = radius * double;
|
|
16
9
|
return {
|
|
17
10
|
count: {
|
|
18
11
|
denominator: 2,
|
|
19
12
|
numerator: 3,
|
|
20
13
|
},
|
|
21
|
-
length:
|
|
14
|
+
length: radius * double,
|
|
22
15
|
};
|
|
23
16
|
}
|
|
24
17
|
}
|
package/browser/Utils.js
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
1
|
+
import { double, doublePI, half } from "@tsparticles/engine";
|
|
2
|
+
const polygonCache = new Map(), noOffset = 0;
|
|
3
|
+
function getUnitPolygon(sides) {
|
|
4
|
+
const cached = polygonCache.get(sides);
|
|
5
|
+
if (cached) {
|
|
6
|
+
return cached;
|
|
7
|
+
}
|
|
8
|
+
const step = doublePI / sides, isOdd = !!(sides % double), baseAngle = (-Math.PI + (isOdd ? noOffset : step)) * half, verts = [];
|
|
9
|
+
for (let i = 0; i < sides; i++) {
|
|
10
|
+
const angle = baseAngle + i * step;
|
|
11
|
+
verts[i] = {
|
|
12
|
+
x: Math.cos(angle),
|
|
13
|
+
y: Math.sin(angle),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
polygonCache.set(sides, verts);
|
|
17
|
+
return verts;
|
|
18
|
+
}
|
|
19
|
+
export function drawPolygon(data, side) {
|
|
20
|
+
const { context, radius } = data, sides = side.count.numerator / side.count.denominator, verts = getUnitPolygon(sides);
|
|
5
21
|
context.beginPath();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
for (let i = 0; i < verts.length; i++) {
|
|
23
|
+
const vert = verts[i];
|
|
24
|
+
if (!vert) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const x = vert.x * radius, y = vert.y * radius;
|
|
28
|
+
if (i) {
|
|
29
|
+
context.lineTo(x, y);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
context.moveTo(x, y);
|
|
33
|
+
}
|
|
12
34
|
}
|
|
35
|
+
context.closePath();
|
|
13
36
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadGenericPolygonShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
3
3
|
await engine.register(e => {
|
|
4
4
|
e.addShape(["polygon"], async () => {
|
|
5
5
|
const { PolygonDrawer } = await import("./PolygonDrawer.js");
|
|
@@ -8,7 +8,7 @@ export async function loadGenericPolygonShape(engine) {
|
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
export async function loadTriangleShape(engine) {
|
|
11
|
-
engine.checkVersion("4.0.0-alpha.
|
|
11
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
12
12
|
await engine.register(e => {
|
|
13
13
|
e.addShape(["triangle"], async () => {
|
|
14
14
|
const { TriangleDrawer } = await import("./TriangleDrawer.js");
|
|
@@ -17,7 +17,7 @@ export async function loadTriangleShape(engine) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
export async function loadPolygonShape(engine) {
|
|
20
|
-
engine.checkVersion("4.0.0-alpha.
|
|
20
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
21
21
|
await Promise.all([
|
|
22
22
|
loadGenericPolygonShape(engine),
|
|
23
23
|
loadTriangleShape(engine),
|
package/cjs/PolygonDrawer.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
2
|
-
const
|
|
2
|
+
const yFactor = 2.66, sidesFactor = 3;
|
|
3
3
|
export class PolygonDrawer extends PolygonDrawerBase {
|
|
4
|
-
getCenter(particle, radius) {
|
|
5
|
-
return {
|
|
6
|
-
x: -radius / (particle.sides / sidesCenterFactor),
|
|
7
|
-
y: -radius / (yFactor / sidesCenterFactor),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
4
|
getSidesData(particle, radius) {
|
|
11
|
-
const sides = particle
|
|
5
|
+
const { sides } = particle;
|
|
12
6
|
return {
|
|
13
7
|
count: {
|
|
14
8
|
denominator: 1,
|
package/cjs/PolygonDrawerBase.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getRangeValue
|
|
1
|
+
import { getRangeValue } from "@tsparticles/engine";
|
|
2
2
|
import { drawPolygon } from "./Utils.js";
|
|
3
3
|
const defaultSides = 5;
|
|
4
4
|
export class PolygonDrawerBase {
|
|
5
5
|
draw(data) {
|
|
6
|
-
const { particle, radius } = data,
|
|
7
|
-
drawPolygon(data,
|
|
6
|
+
const { particle, radius } = data, side = this.getSidesData(particle, radius);
|
|
7
|
+
drawPolygon(data, side);
|
|
8
8
|
}
|
|
9
9
|
getSidesCount(particle) {
|
|
10
10
|
const polygon = particle.shapeData;
|
package/cjs/TriangleDrawer.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { double } from "@tsparticles/engine";
|
|
2
2
|
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
3
|
-
const
|
|
3
|
+
const sides = 3;
|
|
4
4
|
export class TriangleDrawer extends PolygonDrawerBase {
|
|
5
|
-
getCenter(_particle, radius) {
|
|
6
|
-
return {
|
|
7
|
-
x: -radius,
|
|
8
|
-
y: radius / yFactor,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
5
|
getSidesCount() {
|
|
12
6
|
return sides;
|
|
13
7
|
}
|
|
14
8
|
getSidesData(_particle, radius) {
|
|
15
|
-
const diameter = radius * double;
|
|
16
9
|
return {
|
|
17
10
|
count: {
|
|
18
11
|
denominator: 2,
|
|
19
12
|
numerator: 3,
|
|
20
13
|
},
|
|
21
|
-
length:
|
|
14
|
+
length: radius * double,
|
|
22
15
|
};
|
|
23
16
|
}
|
|
24
17
|
}
|
package/cjs/Utils.js
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
1
|
+
import { double, doublePI, half } from "@tsparticles/engine";
|
|
2
|
+
const polygonCache = new Map(), noOffset = 0;
|
|
3
|
+
function getUnitPolygon(sides) {
|
|
4
|
+
const cached = polygonCache.get(sides);
|
|
5
|
+
if (cached) {
|
|
6
|
+
return cached;
|
|
7
|
+
}
|
|
8
|
+
const step = doublePI / sides, isOdd = !!(sides % double), baseAngle = (-Math.PI + (isOdd ? noOffset : step)) * half, verts = [];
|
|
9
|
+
for (let i = 0; i < sides; i++) {
|
|
10
|
+
const angle = baseAngle + i * step;
|
|
11
|
+
verts[i] = {
|
|
12
|
+
x: Math.cos(angle),
|
|
13
|
+
y: Math.sin(angle),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
polygonCache.set(sides, verts);
|
|
17
|
+
return verts;
|
|
18
|
+
}
|
|
19
|
+
export function drawPolygon(data, side) {
|
|
20
|
+
const { context, radius } = data, sides = side.count.numerator / side.count.denominator, verts = getUnitPolygon(sides);
|
|
5
21
|
context.beginPath();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
for (let i = 0; i < verts.length; i++) {
|
|
23
|
+
const vert = verts[i];
|
|
24
|
+
if (!vert) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const x = vert.x * radius, y = vert.y * radius;
|
|
28
|
+
if (i) {
|
|
29
|
+
context.lineTo(x, y);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
context.moveTo(x, y);
|
|
33
|
+
}
|
|
12
34
|
}
|
|
35
|
+
context.closePath();
|
|
13
36
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadGenericPolygonShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
3
3
|
await engine.register(e => {
|
|
4
4
|
e.addShape(["polygon"], async () => {
|
|
5
5
|
const { PolygonDrawer } = await import("./PolygonDrawer.js");
|
|
@@ -8,7 +8,7 @@ export async function loadGenericPolygonShape(engine) {
|
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
export async function loadTriangleShape(engine) {
|
|
11
|
-
engine.checkVersion("4.0.0-alpha.
|
|
11
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
12
12
|
await engine.register(e => {
|
|
13
13
|
e.addShape(["triangle"], async () => {
|
|
14
14
|
const { TriangleDrawer } = await import("./TriangleDrawer.js");
|
|
@@ -17,7 +17,7 @@ export async function loadTriangleShape(engine) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
export async function loadPolygonShape(engine) {
|
|
20
|
-
engine.checkVersion("4.0.0-alpha.
|
|
20
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
21
21
|
await Promise.all([
|
|
22
22
|
loadGenericPolygonShape(engine),
|
|
23
23
|
loadTriangleShape(engine),
|
|
@@ -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
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.24
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\***************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
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
|
|
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 yFactor = 2.66, sidesFactor = 3;\nclass PolygonDrawer extends _PolygonDrawerBase_js__WEBPACK_IMPORTED_MODULE_0__.PolygonDrawerBase {\n getSidesData(particle, radius) {\n const { sides } = particle;\n return {\n count: {\n denominator: 1,\n numerator: sides\n },\n length: radius * yFactor / (sides / sidesFactor)\n };\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/PolygonDrawer.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
33
33
|
\*******************************************/
|
|
34
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
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 { particle, radius } = data,
|
|
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 { particle, radius } = data, side = this.getSidesData(particle, radius);\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawPolygon)(data, 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\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/PolygonDrawerBase.js?\n}");
|
|
37
37
|
|
|
38
38
|
/***/ },
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
43
43
|
\*******************************/
|
|
44
44
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
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
|
|
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 polygonCache = new Map(), noOffset = 0;\nfunction getUnitPolygon(sides) {\n const cached = polygonCache.get(sides);\n if (cached) {\n return cached;\n }\n const step = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI / sides, isOdd = !!(sides % _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double), baseAngle = (-Math.PI + (isOdd ? noOffset : step)) * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half, verts = [];\n for(let i = 0; i < sides; i++){\n const angle = baseAngle + i * step;\n verts[i] = {\n x: Math.cos(angle),\n y: Math.sin(angle)\n };\n }\n polygonCache.set(sides, verts);\n return verts;\n}\nfunction drawPolygon(data, side) {\n const { context, radius } = data, sides = side.count.numerator / side.count.denominator, verts = getUnitPolygon(sides);\n context.beginPath();\n for(let i = 0; i < verts.length; i++){\n const vert = verts[i];\n if (!vert) {\n continue;\n }\n const x = vert.x * radius, y = vert.y * radius;\n if (i) {\n context.lineTo(x, y);\n } else {\n context.moveTo(x, y);\n }\n }\n context.closePath();\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/Utils.js?\n}");
|
|
47
47
|
|
|
48
48
|
/***/ }
|
|
49
49
|
|
|
@@ -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
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.24
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\*******************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
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 { particle, radius } = data,
|
|
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 { particle, radius } = data, side = this.getSidesData(particle, radius);\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawPolygon)(data, 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\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/PolygonDrawerBase.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
33
33
|
\****************************************/
|
|
34
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
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 _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _PolygonDrawerBase_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PolygonDrawerBase.js */ \"./dist/browser/PolygonDrawerBase.js\");\n\n\nconst
|
|
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 _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _PolygonDrawerBase_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PolygonDrawerBase.js */ \"./dist/browser/PolygonDrawerBase.js\");\n\n\nconst sides = 3;\nclass TriangleDrawer extends _PolygonDrawerBase_js__WEBPACK_IMPORTED_MODULE_1__.PolygonDrawerBase {\n getSidesCount() {\n return sides;\n }\n getSidesData(_particle, radius) {\n return {\n count: {\n denominator: 2,\n numerator: 3\n },\n length: radius * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double\n };\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/TriangleDrawer.js?\n}");
|
|
37
37
|
|
|
38
38
|
/***/ },
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
43
43
|
\*******************************/
|
|
44
44
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
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
|
|
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 polygonCache = new Map(), noOffset = 0;\nfunction getUnitPolygon(sides) {\n const cached = polygonCache.get(sides);\n if (cached) {\n return cached;\n }\n const step = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI / sides, isOdd = !!(sides % _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double), baseAngle = (-Math.PI + (isOdd ? noOffset : step)) * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half, verts = [];\n for(let i = 0; i < sides; i++){\n const angle = baseAngle + i * step;\n verts[i] = {\n x: Math.cos(angle),\n y: Math.sin(angle)\n };\n }\n polygonCache.set(sides, verts);\n return verts;\n}\nfunction drawPolygon(data, side) {\n const { context, radius } = data, sides = side.count.numerator / side.count.denominator, verts = getUnitPolygon(sides);\n context.beginPath();\n for(let i = 0; i < verts.length; i++){\n const vert = verts[i];\n if (!vert) {\n continue;\n }\n const x = vert.x * radius, y = vert.y * radius;\n if (i) {\n context.lineTo(x, y);\n } else {\n context.moveTo(x, y);\n }\n }\n context.closePath();\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/Utils.js?\n}");
|
|
47
47
|
|
|
48
48
|
/***/ }
|
|
49
49
|
|
package/esm/PolygonDrawer.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
2
|
-
const
|
|
2
|
+
const yFactor = 2.66, sidesFactor = 3;
|
|
3
3
|
export class PolygonDrawer extends PolygonDrawerBase {
|
|
4
|
-
getCenter(particle, radius) {
|
|
5
|
-
return {
|
|
6
|
-
x: -radius / (particle.sides / sidesCenterFactor),
|
|
7
|
-
y: -radius / (yFactor / sidesCenterFactor),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
4
|
getSidesData(particle, radius) {
|
|
11
|
-
const sides = particle
|
|
5
|
+
const { sides } = particle;
|
|
12
6
|
return {
|
|
13
7
|
count: {
|
|
14
8
|
denominator: 1,
|
package/esm/PolygonDrawerBase.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getRangeValue
|
|
1
|
+
import { getRangeValue } from "@tsparticles/engine";
|
|
2
2
|
import { drawPolygon } from "./Utils.js";
|
|
3
3
|
const defaultSides = 5;
|
|
4
4
|
export class PolygonDrawerBase {
|
|
5
5
|
draw(data) {
|
|
6
|
-
const { particle, radius } = data,
|
|
7
|
-
drawPolygon(data,
|
|
6
|
+
const { particle, radius } = data, side = this.getSidesData(particle, radius);
|
|
7
|
+
drawPolygon(data, side);
|
|
8
8
|
}
|
|
9
9
|
getSidesCount(particle) {
|
|
10
10
|
const polygon = particle.shapeData;
|
package/esm/TriangleDrawer.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { double } from "@tsparticles/engine";
|
|
2
2
|
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
3
|
-
const
|
|
3
|
+
const sides = 3;
|
|
4
4
|
export class TriangleDrawer extends PolygonDrawerBase {
|
|
5
|
-
getCenter(_particle, radius) {
|
|
6
|
-
return {
|
|
7
|
-
x: -radius,
|
|
8
|
-
y: radius / yFactor,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
5
|
getSidesCount() {
|
|
12
6
|
return sides;
|
|
13
7
|
}
|
|
14
8
|
getSidesData(_particle, radius) {
|
|
15
|
-
const diameter = radius * double;
|
|
16
9
|
return {
|
|
17
10
|
count: {
|
|
18
11
|
denominator: 2,
|
|
19
12
|
numerator: 3,
|
|
20
13
|
},
|
|
21
|
-
length:
|
|
14
|
+
length: radius * double,
|
|
22
15
|
};
|
|
23
16
|
}
|
|
24
17
|
}
|
package/esm/Utils.js
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
1
|
+
import { double, doublePI, half } from "@tsparticles/engine";
|
|
2
|
+
const polygonCache = new Map(), noOffset = 0;
|
|
3
|
+
function getUnitPolygon(sides) {
|
|
4
|
+
const cached = polygonCache.get(sides);
|
|
5
|
+
if (cached) {
|
|
6
|
+
return cached;
|
|
7
|
+
}
|
|
8
|
+
const step = doublePI / sides, isOdd = !!(sides % double), baseAngle = (-Math.PI + (isOdd ? noOffset : step)) * half, verts = [];
|
|
9
|
+
for (let i = 0; i < sides; i++) {
|
|
10
|
+
const angle = baseAngle + i * step;
|
|
11
|
+
verts[i] = {
|
|
12
|
+
x: Math.cos(angle),
|
|
13
|
+
y: Math.sin(angle),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
polygonCache.set(sides, verts);
|
|
17
|
+
return verts;
|
|
18
|
+
}
|
|
19
|
+
export function drawPolygon(data, side) {
|
|
20
|
+
const { context, radius } = data, sides = side.count.numerator / side.count.denominator, verts = getUnitPolygon(sides);
|
|
5
21
|
context.beginPath();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
for (let i = 0; i < verts.length; i++) {
|
|
23
|
+
const vert = verts[i];
|
|
24
|
+
if (!vert) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const x = vert.x * radius, y = vert.y * radius;
|
|
28
|
+
if (i) {
|
|
29
|
+
context.lineTo(x, y);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
context.moveTo(x, y);
|
|
33
|
+
}
|
|
12
34
|
}
|
|
35
|
+
context.closePath();
|
|
13
36
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadGenericPolygonShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
3
3
|
await engine.register(e => {
|
|
4
4
|
e.addShape(["polygon"], async () => {
|
|
5
5
|
const { PolygonDrawer } = await import("./PolygonDrawer.js");
|
|
@@ -8,7 +8,7 @@ export async function loadGenericPolygonShape(engine) {
|
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
export async function loadTriangleShape(engine) {
|
|
11
|
-
engine.checkVersion("4.0.0-alpha.
|
|
11
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
12
12
|
await engine.register(e => {
|
|
13
13
|
e.addShape(["triangle"], async () => {
|
|
14
14
|
const { TriangleDrawer } = await import("./TriangleDrawer.js");
|
|
@@ -17,7 +17,7 @@ export async function loadTriangleShape(engine) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
export async function loadPolygonShape(engine) {
|
|
20
|
-
engine.checkVersion("4.0.0-alpha.
|
|
20
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
21
21
|
await Promise.all([
|
|
22
22
|
loadGenericPolygonShape(engine),
|
|
23
23
|
loadTriangleShape(engine),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-polygon",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.24",
|
|
4
4
|
"description": "tsParticles polygon shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"./package.json": "./package.json"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@tsparticles/engine": "4.0.0-alpha.
|
|
62
|
+
"@tsparticles/engine": "4.0.0-alpha.24"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/shape-polygon [
|
|
6
|
+
<title>@tsparticles/shape-polygon [12 Feb 2026 at 18:49]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -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
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.24
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -44,7 +44,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
44
44
|
\*******************************/
|
|
45
45
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
46
46
|
|
|
47
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadGenericPolygonShape: () => (/* binding */ loadGenericPolygonShape),\n/* harmony export */ loadPolygonShape: () => (/* binding */ loadPolygonShape),\n/* harmony export */ loadTriangleShape: () => (/* binding */ loadTriangleShape)\n/* harmony export */ });\nasync function loadGenericPolygonShape(engine) {\n engine.checkVersion(\"4.0.0-alpha.
|
|
47
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadGenericPolygonShape: () => (/* binding */ loadGenericPolygonShape),\n/* harmony export */ loadPolygonShape: () => (/* binding */ loadPolygonShape),\n/* harmony export */ loadTriangleShape: () => (/* binding */ loadTriangleShape)\n/* harmony export */ });\nasync function loadGenericPolygonShape(engine) {\n engine.checkVersion(\"4.0.0-alpha.24\");\n await engine.register((e)=>{\n e.addShape([\n \"polygon\"\n ], async ()=>{\n const { PolygonDrawer } = await __webpack_require__.e(/*! import() */ \"dist_browser_PolygonDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./PolygonDrawer.js */ \"./dist/browser/PolygonDrawer.js\"));\n return new PolygonDrawer();\n });\n });\n}\nasync function loadTriangleShape(engine) {\n engine.checkVersion(\"4.0.0-alpha.24\");\n await engine.register((e)=>{\n e.addShape([\n \"triangle\"\n ], async ()=>{\n const { TriangleDrawer } = await __webpack_require__.e(/*! import() */ \"dist_browser_TriangleDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./TriangleDrawer.js */ \"./dist/browser/TriangleDrawer.js\"));\n return new TriangleDrawer();\n });\n });\n}\nasync function loadPolygonShape(engine) {\n engine.checkVersion(\"4.0.0-alpha.24\");\n await Promise.all([\n loadGenericPolygonShape(engine),\n loadTriangleShape(engine)\n ]);\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-polygon/./dist/browser/index.js?\n}");
|
|
48
48
|
|
|
49
49
|
/***/ }
|
|
50
50
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
!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 r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,e=>(()=>{"use strict";var t,r,o,n={303(t){t.exports=e}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>""+e+".min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s={},i.l=(e,t,r,o)=>{if(s[e])return void s[e].push(t);if(void 0!==r)for(var n,a,p=document.getElementsByTagName("script"),l=0;l<p.length;l++){var c=p[l];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="@tsparticles/shape-polygon:"+r){n=c;break}}n||(a=!0,(n=document.createElement("script")).charset="utf-8",i.nc&&n.setAttribute("nonce",i.nc),n.setAttribute("data-webpack","@tsparticles/shape-polygon:"+r),n.src=e),s[e]=[t];var u=(t,r)=>{n.onerror=n.onload=null,clearTimeout(d);var o=s[e];if(delete s[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),a&&document.head.appendChild(n)},i.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.g.importScripts&&(p=i.g.location+"");var s,p,l=i.g.document;if(!p&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(p=l.currentScript.src),!p)){var c=l.getElementsByTagName("script");if(c.length)for(var u=c.length-1;u>-1&&(!p||!/^http(s?):/.test(p));)p=c[u--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");i.p=p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={974:0},i.f.j=(e,r)=>{var o=i.o(t,e)?t[e]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=t[e]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(e),s=Error();i.l(a,r=>{if(i.o(t,e)&&(0!==(o=t[e])&&(t[e]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+e+` failed.
|
|
2
|
-
(`+n+": "+a+")",s.name="ChunkLoadError",s.type=n,s.request=a,o[1](s)}},"chunk-"+e,e)}},r=(e,r)=>{var o,n,[a,s,p]=r,l=0;if(a.some(e=>0!==t[e])){for(o in s)i.o(s,o)&&(i.m[o]=s[o]);p&&p(i)}for(e&&e(r);l<a.length;l++)n=a[l],i.o(t,n)&&t[n]&&t[n][0](),t[n]=0},(o=this.webpackChunk_tsparticles_shape_polygon=this.webpackChunk_tsparticles_shape_polygon||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};async function f(e){e.checkVersion("4.0.0-alpha.
|
|
2
|
+
(`+n+": "+a+")",s.name="ChunkLoadError",s.type=n,s.request=a,o[1](s)}},"chunk-"+e,e)}},r=(e,r)=>{var o,n,[a,s,p]=r,l=0;if(a.some(e=>0!==t[e])){for(o in s)i.o(s,o)&&(i.m[o]=s[o]);p&&p(i)}for(e&&e(r);l<a.length;l++)n=a[l],i.o(t,n)&&t[n]&&t[n][0](),t[n]=0},(o=this.webpackChunk_tsparticles_shape_polygon=this.webpackChunk_tsparticles_shape_polygon||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};async function f(e){e.checkVersion("4.0.0-alpha.24"),await e.register(e=>{e.addShape(["polygon"],async()=>{let{PolygonDrawer:e}=await i.e(144).then(i.bind(i,144));return new e})})}async function h(e){e.checkVersion("4.0.0-alpha.24"),await e.register(e=>{e.addShape(["triangle"],async()=>{let{TriangleDrawer:e}=await i.e(118).then(i.bind(i,118));return new e})})}async function g(e){e.checkVersion("4.0.0-alpha.24"),await Promise.all([f(e),h(e)])}return i.r(d),i.d(d,{loadGenericPolygonShape:()=>f,loadPolygonShape:()=>g,loadTriangleShape:()=>h}),d})());
|
package/types/PolygonDrawer.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { ICoordinates, Particle } from "@tsparticles/engine";
|
|
2
1
|
import type { ISide } from "./ISide.js";
|
|
2
|
+
import type { Particle } from "@tsparticles/engine";
|
|
3
3
|
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
4
4
|
export declare class PolygonDrawer extends PolygonDrawerBase {
|
|
5
|
-
getCenter(particle: Particle, radius: number): ICoordinates;
|
|
6
5
|
getSidesData(particle: Particle, radius: number): ISide;
|
|
7
6
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type IShapeDrawData, type IShapeDrawer, type Particle } from "@tsparticles/engine";
|
|
2
2
|
import type { ISide } from "./ISide.js";
|
|
3
3
|
export declare abstract class PolygonDrawerBase implements IShapeDrawer {
|
|
4
4
|
draw(data: IShapeDrawData): void;
|
|
5
5
|
getSidesCount(particle: Particle): number;
|
|
6
|
-
abstract getCenter(particle: Particle, radius: number): ICoordinates;
|
|
7
6
|
abstract getSidesData(particle: Particle, radius: number): ISide;
|
|
8
7
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Particle } from "@tsparticles/engine";
|
|
2
2
|
import type { ISide } from "./ISide.js";
|
|
3
3
|
import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
|
|
4
4
|
export declare class TriangleDrawer extends PolygonDrawerBase {
|
|
5
|
-
getCenter(_particle: Particle, radius: number): ICoordinates;
|
|
6
5
|
getSidesCount(): number;
|
|
7
6
|
getSidesData(_particle: Particle, radius: number): ISide;
|
|
8
7
|
}
|
package/types/Utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type IShapeDrawData } from "@tsparticles/engine";
|
|
2
2
|
import type { ISide } from "./ISide.js";
|
|
3
|
-
export declare function drawPolygon(data: IShapeDrawData,
|
|
3
|
+
export declare function drawPolygon(data: IShapeDrawData, side: ISide): void;
|
package/umd/PolygonDrawer.js
CHANGED
|
@@ -11,16 +11,10 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PolygonDrawer = void 0;
|
|
13
13
|
const PolygonDrawerBase_js_1 = require("./PolygonDrawerBase.js");
|
|
14
|
-
const
|
|
14
|
+
const yFactor = 2.66, sidesFactor = 3;
|
|
15
15
|
class PolygonDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
|
|
16
|
-
getCenter(particle, radius) {
|
|
17
|
-
return {
|
|
18
|
-
x: -radius / (particle.sides / sidesCenterFactor),
|
|
19
|
-
y: -radius / (yFactor / sidesCenterFactor),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
16
|
getSidesData(particle, radius) {
|
|
23
|
-
const sides = particle
|
|
17
|
+
const { sides } = particle;
|
|
24
18
|
return {
|
|
25
19
|
count: {
|
|
26
20
|
denominator: 1,
|
package/umd/PolygonDrawerBase.js
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
const defaultSides = 5;
|
|
16
16
|
class PolygonDrawerBase {
|
|
17
17
|
draw(data) {
|
|
18
|
-
const { particle, radius } = data,
|
|
19
|
-
(0, Utils_js_1.drawPolygon)(data,
|
|
18
|
+
const { particle, radius } = data, side = this.getSidesData(particle, radius);
|
|
19
|
+
(0, Utils_js_1.drawPolygon)(data, side);
|
|
20
20
|
}
|
|
21
21
|
getSidesCount(particle) {
|
|
22
22
|
const polygon = particle.shapeData;
|
package/umd/TriangleDrawer.js
CHANGED
|
@@ -12,25 +12,18 @@
|
|
|
12
12
|
exports.TriangleDrawer = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const PolygonDrawerBase_js_1 = require("./PolygonDrawerBase.js");
|
|
15
|
-
const
|
|
15
|
+
const sides = 3;
|
|
16
16
|
class TriangleDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
|
|
17
|
-
getCenter(_particle, radius) {
|
|
18
|
-
return {
|
|
19
|
-
x: -radius,
|
|
20
|
-
y: radius / yFactor,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
17
|
getSidesCount() {
|
|
24
18
|
return sides;
|
|
25
19
|
}
|
|
26
20
|
getSidesData(_particle, radius) {
|
|
27
|
-
const diameter = radius * engine_1.double;
|
|
28
21
|
return {
|
|
29
22
|
count: {
|
|
30
23
|
denominator: 2,
|
|
31
24
|
numerator: 3,
|
|
32
25
|
},
|
|
33
|
-
length:
|
|
26
|
+
length: radius * engine_1.double,
|
|
34
27
|
};
|
|
35
28
|
}
|
|
36
29
|
}
|
package/umd/Utils.js
CHANGED
|
@@ -11,16 +11,39 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.drawPolygon = drawPolygon;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const
|
|
15
|
-
function
|
|
16
|
-
const
|
|
14
|
+
const polygonCache = new Map(), noOffset = 0;
|
|
15
|
+
function getUnitPolygon(sides) {
|
|
16
|
+
const cached = polygonCache.get(sides);
|
|
17
|
+
if (cached) {
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
const step = engine_1.doublePI / sides, isOdd = !!(sides % engine_1.double), baseAngle = (-Math.PI + (isOdd ? noOffset : step)) * engine_1.half, verts = [];
|
|
21
|
+
for (let i = 0; i < sides; i++) {
|
|
22
|
+
const angle = baseAngle + i * step;
|
|
23
|
+
verts[i] = {
|
|
24
|
+
x: Math.cos(angle),
|
|
25
|
+
y: Math.sin(angle),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
polygonCache.set(sides, verts);
|
|
29
|
+
return verts;
|
|
30
|
+
}
|
|
31
|
+
function drawPolygon(data, side) {
|
|
32
|
+
const { context, radius } = data, sides = side.count.numerator / side.count.denominator, verts = getUnitPolygon(sides);
|
|
17
33
|
context.beginPath();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
for (let i = 0; i < verts.length; i++) {
|
|
35
|
+
const vert = verts[i];
|
|
36
|
+
if (!vert) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const x = vert.x * radius, y = vert.y * radius;
|
|
40
|
+
if (i) {
|
|
41
|
+
context.lineTo(x, y);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
context.moveTo(x, y);
|
|
45
|
+
}
|
|
24
46
|
}
|
|
47
|
+
context.closePath();
|
|
25
48
|
}
|
|
26
49
|
});
|
package/umd/index.js
CHANGED
|
@@ -47,7 +47,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
47
47
|
exports.loadTriangleShape = loadTriangleShape;
|
|
48
48
|
exports.loadPolygonShape = loadPolygonShape;
|
|
49
49
|
async function loadGenericPolygonShape(engine) {
|
|
50
|
-
engine.checkVersion("4.0.0-alpha.
|
|
50
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
51
51
|
await engine.register(e => {
|
|
52
52
|
e.addShape(["polygon"], async () => {
|
|
53
53
|
const { PolygonDrawer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./PolygonDrawer.js"))) : new Promise((resolve_1, reject_1) => { require(["./PolygonDrawer.js"], resolve_1, reject_1); }).then(__importStar));
|
|
@@ -56,7 +56,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
async function loadTriangleShape(engine) {
|
|
59
|
-
engine.checkVersion("4.0.0-alpha.
|
|
59
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
60
60
|
await engine.register(e => {
|
|
61
61
|
e.addShape(["triangle"], async () => {
|
|
62
62
|
const { TriangleDrawer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./TriangleDrawer.js"))) : new Promise((resolve_2, reject_2) => { require(["./TriangleDrawer.js"], resolve_2, reject_2); }).then(__importStar));
|
|
@@ -65,7 +65,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
async function loadPolygonShape(engine) {
|
|
68
|
-
engine.checkVersion("4.0.0-alpha.
|
|
68
|
+
engine.checkVersion("4.0.0-alpha.24");
|
|
69
69
|
await Promise.all([
|
|
70
70
|
loadGenericPolygonShape(engine),
|
|
71
71
|
loadTriangleShape(engine),
|