@tsparticles/shape-polygon 3.0.3 → 3.1.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.
@@ -1,9 +1,10 @@
1
1
  import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
2
+ const sidesCenterFactor = 3.5, yFactor = 2.66, sidesFactor = 3;
2
3
  export class PolygonDrawer extends PolygonDrawerBase {
3
4
  getCenter(particle, radius) {
4
5
  return {
5
- x: -radius / (particle.sides / 3.5),
6
- y: -radius / (2.66 / 3.5),
6
+ x: -radius / (particle.sides / sidesCenterFactor),
7
+ y: -radius / (yFactor / sidesCenterFactor),
7
8
  };
8
9
  }
9
10
  getSidesData(particle, radius) {
@@ -13,7 +14,7 @@ export class PolygonDrawer extends PolygonDrawerBase {
13
14
  denominator: 1,
14
15
  numerator: sides,
15
16
  },
16
- length: (radius * 2.66) / (sides / 3),
17
+ length: (radius * yFactor) / (sides / sidesFactor),
17
18
  };
18
19
  }
19
20
  }
@@ -1,21 +1,22 @@
1
- import { getRangeValue, } from "@tsparticles/engine";
1
+ import { degToRad, getRangeValue, } from "@tsparticles/engine";
2
+ const piDeg = 180, origin = { x: 0, y: 0 }, defaultSides = 5, sidesOffset = 2;
2
3
  export class PolygonDrawerBase {
3
4
  draw(data) {
4
- const { context, particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius), sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (180 * (decimalSides - 2)) / decimalSides, interiorAngle = Math.PI - (Math.PI * interiorAngleDegrees) / 180;
5
+ const { context, particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius), 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
6
  if (!context) {
6
7
  return;
7
8
  }
8
9
  context.beginPath();
9
10
  context.translate(start.x, start.y);
10
- context.moveTo(0, 0);
11
+ context.moveTo(origin.x, origin.y);
11
12
  for (let i = 0; i < sideCount; i++) {
12
- context.lineTo(side.length, 0);
13
- context.translate(side.length, 0);
13
+ context.lineTo(side.length, origin.y);
14
+ context.translate(side.length, origin.y);
14
15
  context.rotate(interiorAngle);
15
16
  }
16
17
  }
17
18
  getSidesCount(particle) {
18
19
  const polygon = particle.shapeData;
19
- return Math.round(getRangeValue(polygon?.sides ?? 5));
20
+ return Math.round(getRangeValue(polygon?.sides ?? defaultSides));
20
21
  }
21
22
  }
@@ -1,21 +1,23 @@
1
1
  import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
2
+ const yFactor = 1.66, sides = 3, double = 2;
2
3
  export class TriangleDrawer extends PolygonDrawerBase {
3
4
  getCenter(particle, radius) {
4
5
  return {
5
6
  x: -radius,
6
- y: radius / 1.66,
7
+ y: radius / yFactor,
7
8
  };
8
9
  }
9
10
  getSidesCount() {
10
- return 3;
11
+ return sides;
11
12
  }
12
13
  getSidesData(particle, radius) {
14
+ const diameter = radius * double;
13
15
  return {
14
16
  count: {
15
17
  denominator: 2,
16
18
  numerator: 3,
17
19
  },
18
- length: radius * 2,
20
+ length: diameter,
19
21
  };
20
22
  }
21
23
  }
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PolygonDrawer = void 0;
4
4
  const PolygonDrawerBase_js_1 = require("./PolygonDrawerBase.js");
5
+ const sidesCenterFactor = 3.5, yFactor = 2.66, sidesFactor = 3;
5
6
  class PolygonDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
6
7
  getCenter(particle, radius) {
7
8
  return {
8
- x: -radius / (particle.sides / 3.5),
9
- y: -radius / (2.66 / 3.5),
9
+ x: -radius / (particle.sides / sidesCenterFactor),
10
+ y: -radius / (yFactor / sidesCenterFactor),
10
11
  };
11
12
  }
12
13
  getSidesData(particle, radius) {
@@ -16,7 +17,7 @@ class PolygonDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
16
17
  denominator: 1,
17
18
  numerator: sides,
18
19
  },
19
- length: (radius * 2.66) / (sides / 3),
20
+ length: (radius * yFactor) / (sides / sidesFactor),
20
21
  };
21
22
  }
22
23
  }
@@ -2,24 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PolygonDrawerBase = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
+ const piDeg = 180, origin = { x: 0, y: 0 }, defaultSides = 5, sidesOffset = 2;
5
6
  class PolygonDrawerBase {
6
7
  draw(data) {
7
- const { context, particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius), sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (180 * (decimalSides - 2)) / decimalSides, interiorAngle = Math.PI - (Math.PI * interiorAngleDegrees) / 180;
8
+ const { context, particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius), sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (piDeg * (decimalSides - sidesOffset)) / decimalSides, interiorAngle = Math.PI - (0, engine_1.degToRad)(interiorAngleDegrees);
8
9
  if (!context) {
9
10
  return;
10
11
  }
11
12
  context.beginPath();
12
13
  context.translate(start.x, start.y);
13
- context.moveTo(0, 0);
14
+ context.moveTo(origin.x, origin.y);
14
15
  for (let i = 0; i < sideCount; i++) {
15
- context.lineTo(side.length, 0);
16
- context.translate(side.length, 0);
16
+ context.lineTo(side.length, origin.y);
17
+ context.translate(side.length, origin.y);
17
18
  context.rotate(interiorAngle);
18
19
  }
19
20
  }
20
21
  getSidesCount(particle) {
21
22
  const polygon = particle.shapeData;
22
- return Math.round((0, engine_1.getRangeValue)(polygon?.sides ?? 5));
23
+ return Math.round((0, engine_1.getRangeValue)(polygon?.sides ?? defaultSides));
23
24
  }
24
25
  }
25
26
  exports.PolygonDrawerBase = PolygonDrawerBase;
@@ -2,23 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TriangleDrawer = void 0;
4
4
  const PolygonDrawerBase_js_1 = require("./PolygonDrawerBase.js");
5
+ const yFactor = 1.66, sides = 3, double = 2;
5
6
  class TriangleDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
6
7
  getCenter(particle, radius) {
7
8
  return {
8
9
  x: -radius,
9
- y: radius / 1.66,
10
+ y: radius / yFactor,
10
11
  };
11
12
  }
12
13
  getSidesCount() {
13
- return 3;
14
+ return sides;
14
15
  }
15
16
  getSidesData(particle, radius) {
17
+ const diameter = radius * double;
16
18
  return {
17
19
  count: {
18
20
  denominator: 2,
19
21
  numerator: 3,
20
22
  },
21
- length: radius * 2,
23
+ length: diameter,
22
24
  };
23
25
  }
24
26
  }
@@ -1,9 +1,10 @@
1
1
  import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
2
+ const sidesCenterFactor = 3.5, yFactor = 2.66, sidesFactor = 3;
2
3
  export class PolygonDrawer extends PolygonDrawerBase {
3
4
  getCenter(particle, radius) {
4
5
  return {
5
- x: -radius / (particle.sides / 3.5),
6
- y: -radius / (2.66 / 3.5),
6
+ x: -radius / (particle.sides / sidesCenterFactor),
7
+ y: -radius / (yFactor / sidesCenterFactor),
7
8
  };
8
9
  }
9
10
  getSidesData(particle, radius) {
@@ -13,7 +14,7 @@ export class PolygonDrawer extends PolygonDrawerBase {
13
14
  denominator: 1,
14
15
  numerator: sides,
15
16
  },
16
- length: (radius * 2.66) / (sides / 3),
17
+ length: (radius * yFactor) / (sides / sidesFactor),
17
18
  };
18
19
  }
19
20
  }
@@ -1,21 +1,22 @@
1
- import { getRangeValue, } from "@tsparticles/engine";
1
+ import { degToRad, getRangeValue, } from "@tsparticles/engine";
2
+ const piDeg = 180, origin = { x: 0, y: 0 }, defaultSides = 5, sidesOffset = 2;
2
3
  export class PolygonDrawerBase {
3
4
  draw(data) {
4
- const { context, particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius), sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (180 * (decimalSides - 2)) / decimalSides, interiorAngle = Math.PI - (Math.PI * interiorAngleDegrees) / 180;
5
+ const { context, particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius), 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
6
  if (!context) {
6
7
  return;
7
8
  }
8
9
  context.beginPath();
9
10
  context.translate(start.x, start.y);
10
- context.moveTo(0, 0);
11
+ context.moveTo(origin.x, origin.y);
11
12
  for (let i = 0; i < sideCount; i++) {
12
- context.lineTo(side.length, 0);
13
- context.translate(side.length, 0);
13
+ context.lineTo(side.length, origin.y);
14
+ context.translate(side.length, origin.y);
14
15
  context.rotate(interiorAngle);
15
16
  }
16
17
  }
17
18
  getSidesCount(particle) {
18
19
  const polygon = particle.shapeData;
19
- return Math.round(getRangeValue(polygon?.sides ?? 5));
20
+ return Math.round(getRangeValue(polygon?.sides ?? defaultSides));
20
21
  }
21
22
  }
@@ -1,21 +1,23 @@
1
1
  import { PolygonDrawerBase } from "./PolygonDrawerBase.js";
2
+ const yFactor = 1.66, sides = 3, double = 2;
2
3
  export class TriangleDrawer extends PolygonDrawerBase {
3
4
  getCenter(particle, radius) {
4
5
  return {
5
6
  x: -radius,
6
- y: radius / 1.66,
7
+ y: radius / yFactor,
7
8
  };
8
9
  }
9
10
  getSidesCount() {
10
- return 3;
11
+ return sides;
11
12
  }
12
13
  getSidesData(particle, radius) {
14
+ const diameter = radius * double;
13
15
  return {
14
16
  count: {
15
17
  denominator: 2,
16
18
  numerator: 3,
17
19
  },
18
- length: radius * 2,
20
+ length: diameter,
19
21
  };
20
22
  }
21
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/shape-polygon",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
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": "^3.0.3"
62
+ "@tsparticles/engine": "^3.1.0"
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 [26 Dec 2023 at 19:31]</title>
6
+ <title>@tsparticles/shape-polygon [13 Jan 2024 at 23:07]</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>
@@ -31,7 +31,7 @@
31
31
  <body>
32
32
  <div id="app"></div>
33
33
  <script>
34
- window.chartData = [{"label":"tsparticles.shape.polygon.js","isAsset":true,"statSize":2426,"parsedSize":6282,"gzipSize":1915,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":2384,"groups":[{"id":680,"label":"index.js + 3 modules (concatenated)","path":"./dist/browser/index.js + 3 modules (concatenated)","statSize":2384,"parsedSize":6282,"gzipSize":1915,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser","statSize":2384,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/index.js","statSize":542,"parsedSize":1428,"gzipSize":435,"inaccurateSizes":true},{"id":null,"label":"PolygonDrawer.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/PolygonDrawer.js","statSize":455,"parsedSize":1198,"gzipSize":365,"inaccurateSizes":true},{"id":null,"label":"TriangleDrawer.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/TriangleDrawer.js","statSize":405,"parsedSize":1067,"gzipSize":325,"inaccurateSizes":true},{"id":null,"label":"PolygonDrawerBase.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/PolygonDrawerBase.js","statSize":982,"parsedSize":2587,"gzipSize":788,"inaccurateSizes":true}],"parsedSize":6282,"gzipSize":1915,"inaccurateSizes":true}]}],"parsedSize":6282,"gzipSize":1915},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.shape.polygon":true}}];
34
+ window.chartData = [{"label":"tsparticles.shape.polygon.js","isAsset":true,"statSize":2780,"parsedSize":6710,"gzipSize":2043,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":2738,"groups":[{"id":502,"label":"index.js + 3 modules (concatenated)","path":"./dist/browser/index.js + 3 modules (concatenated)","statSize":2738,"parsedSize":6710,"gzipSize":2043,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser","statSize":2738,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/index.js","statSize":542,"parsedSize":1328,"gzipSize":404,"inaccurateSizes":true},{"id":null,"label":"PolygonDrawer.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/PolygonDrawer.js","statSize":567,"parsedSize":1389,"gzipSize":423,"inaccurateSizes":true},{"id":null,"label":"TriangleDrawer.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/TriangleDrawer.js","statSize":497,"parsedSize":1217,"gzipSize":370,"inaccurateSizes":true},{"id":null,"label":"PolygonDrawerBase.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/PolygonDrawerBase.js","statSize":1132,"parsedSize":2774,"gzipSize":844,"inaccurateSizes":true}],"parsedSize":6710,"gzipSize":2043,"inaccurateSizes":true}]}],"parsedSize":6710,"gzipSize":2043},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.shape.polygon":true}}];
35
35
  window.entrypoints = ["tsparticles.shape.polygon","tsparticles.shape.polygon.min"];
36
36
  window.defaultSizes = "parsed";
37
37
  </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
- * v3.0.3
7
+ * v3.1.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -100,6 +100,13 @@ __webpack_require__.d(__webpack_exports__, {
100
100
  var engine_root_window_ = __webpack_require__(533);
101
101
  ;// CONCATENATED MODULE: ./dist/browser/PolygonDrawerBase.js
102
102
 
103
+ const piDeg = 180,
104
+ origin = {
105
+ x: 0,
106
+ y: 0
107
+ },
108
+ defaultSides = 5,
109
+ sidesOffset = 2;
103
110
  class PolygonDrawerBase {
104
111
  draw(data) {
105
112
  const {
@@ -111,32 +118,35 @@ class PolygonDrawerBase {
111
118
  side = this.getSidesData(particle, radius),
112
119
  sideCount = side.count.numerator * side.count.denominator,
113
120
  decimalSides = side.count.numerator / side.count.denominator,
114
- interiorAngleDegrees = 180 * (decimalSides - 2) / decimalSides,
115
- interiorAngle = Math.PI - Math.PI * interiorAngleDegrees / 180;
121
+ interiorAngleDegrees = piDeg * (decimalSides - sidesOffset) / decimalSides,
122
+ interiorAngle = Math.PI - (0,engine_root_window_.degToRad)(interiorAngleDegrees);
116
123
  if (!context) {
117
124
  return;
118
125
  }
119
126
  context.beginPath();
120
127
  context.translate(start.x, start.y);
121
- context.moveTo(0, 0);
128
+ context.moveTo(origin.x, origin.y);
122
129
  for (let i = 0; i < sideCount; i++) {
123
- context.lineTo(side.length, 0);
124
- context.translate(side.length, 0);
130
+ context.lineTo(side.length, origin.y);
131
+ context.translate(side.length, origin.y);
125
132
  context.rotate(interiorAngle);
126
133
  }
127
134
  }
128
135
  getSidesCount(particle) {
129
136
  const polygon = particle.shapeData;
130
- return Math.round((0,engine_root_window_.getRangeValue)(polygon?.sides ?? 5));
137
+ return Math.round((0,engine_root_window_.getRangeValue)(polygon?.sides ?? defaultSides));
131
138
  }
132
139
  }
133
140
  ;// CONCATENATED MODULE: ./dist/browser/PolygonDrawer.js
134
141
 
142
+ const sidesCenterFactor = 3.5,
143
+ yFactor = 2.66,
144
+ sidesFactor = 3;
135
145
  class PolygonDrawer extends PolygonDrawerBase {
136
146
  getCenter(particle, radius) {
137
147
  return {
138
- x: -radius / (particle.sides / 3.5),
139
- y: -radius / (2.66 / 3.5)
148
+ x: -radius / (particle.sides / sidesCenterFactor),
149
+ y: -radius / (yFactor / sidesCenterFactor)
140
150
  };
141
151
  }
142
152
  getSidesData(particle, radius) {
@@ -146,29 +156,33 @@ class PolygonDrawer extends PolygonDrawerBase {
146
156
  denominator: 1,
147
157
  numerator: sides
148
158
  },
149
- length: radius * 2.66 / (sides / 3)
159
+ length: radius * yFactor / (sides / sidesFactor)
150
160
  };
151
161
  }
152
162
  }
153
163
  ;// CONCATENATED MODULE: ./dist/browser/TriangleDrawer.js
154
164
 
165
+ const TriangleDrawer_yFactor = 1.66,
166
+ sides = 3,
167
+ TriangleDrawer_double = 2;
155
168
  class TriangleDrawer extends PolygonDrawerBase {
156
169
  getCenter(particle, radius) {
157
170
  return {
158
171
  x: -radius,
159
- y: radius / 1.66
172
+ y: radius / TriangleDrawer_yFactor
160
173
  };
161
174
  }
162
175
  getSidesCount() {
163
- return 3;
176
+ return sides;
164
177
  }
165
178
  getSidesData(particle, radius) {
179
+ const diameter = radius * TriangleDrawer_double;
166
180
  return {
167
181
  count: {
168
182
  denominator: 2,
169
183
  numerator: 3
170
184
  },
171
- length: radius * 2
185
+ length: diameter
172
186
  };
173
187
  }
174
188
  }
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.shape.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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,o),a.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{loadGenericPolygonShape:()=>i,loadPolygonShape:()=>d,loadTriangleShape:()=>s});var e=o(533);class t{draw(e){const{context:t,particle:n,radius:o}=e,r=this.getCenter(n,o),a=this.getSidesData(n,o),i=a.count.numerator*a.count.denominator,s=a.count.numerator/a.count.denominator,d=180*(s-2)/s,u=Math.PI-Math.PI*d/180;if(t){t.beginPath(),t.translate(r.x,r.y),t.moveTo(0,0);for(let e=0;e<i;e++)t.lineTo(a.length,0),t.translate(a.length,0),t.rotate(u)}}getSidesCount(t){const n=t.shapeData;return Math.round((0,e.getRangeValue)(n?.sides??5))}}class n extends t{getCenter(e,t){return{x:-t/(e.sides/3.5),y:-t/.76}}getSidesData(e,t){const n=e.sides;return{count:{denominator:1,numerator:n},length:2.66*t/(n/3)}}}class a extends t{getCenter(e,t){return{x:-t,y:t/1.66}}getSidesCount(){return 3}getSidesData(e,t){return{count:{denominator:2,numerator:3},length:2*t}}}async function i(e,t=!0){await e.addShape("polygon",new n,t)}async function s(e,t=!0){await e.addShape("triangle",new a,t)}async function d(e,t=!0){await i(e,t),await s(e,t)}})(),r})()));
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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,o),a.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{loadGenericPolygonShape:()=>d,loadPolygonShape:()=>c,loadTriangleShape:()=>u});var e=o(533);const t=0,n=0;class a{draw(o){const{context:r,particle:a,radius:i}=o,s=this.getCenter(a,i),d=this.getSidesData(a,i),u=d.count.numerator*d.count.denominator,c=d.count.numerator/d.count.denominator,l=180*(c-2)/c,p=Math.PI-(0,e.degToRad)(l);if(r){r.beginPath(),r.translate(s.x,s.y),r.moveTo(t,n);for(let e=0;e<u;e++)r.lineTo(d.length,n),r.translate(d.length,n),r.rotate(p)}}getSidesCount(t){const n=t.shapeData;return Math.round((0,e.getRangeValue)(n?.sides??5))}}class i extends a{getCenter(e,t){return{x:-t/(e.sides/3.5),y:-t/.76}}getSidesData(e,t){const n=e.sides;return{count:{denominator:1,numerator:n},length:2.66*t/(n/3)}}}class s extends a{getCenter(e,t){return{x:-t,y:t/1.66}}getSidesCount(){return 3}getSidesData(e,t){return{count:{denominator:2,numerator:3},length:2*t}}}async function d(e,t=!0){await e.addShape("polygon",new i,t)}async function u(e,t=!0){await e.addShape("triangle",new s,t)}async function c(e,t=!0){await d(e,t),await u(e,t)}})(),r})()));
@@ -1 +1 @@
1
- /*! tsParticles Polygon Shape v3.0.3 by Matteo Bruni */
1
+ /*! tsParticles Polygon Shape v3.1.0 by Matteo Bruni */
@@ -11,11 +11,12 @@
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 sidesCenterFactor = 3.5, yFactor = 2.66, sidesFactor = 3;
14
15
  class PolygonDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
15
16
  getCenter(particle, radius) {
16
17
  return {
17
- x: -radius / (particle.sides / 3.5),
18
- y: -radius / (2.66 / 3.5),
18
+ x: -radius / (particle.sides / sidesCenterFactor),
19
+ y: -radius / (yFactor / sidesCenterFactor),
19
20
  };
20
21
  }
21
22
  getSidesData(particle, radius) {
@@ -25,7 +26,7 @@
25
26
  denominator: 1,
26
27
  numerator: sides,
27
28
  },
28
- length: (radius * 2.66) / (sides / 3),
29
+ length: (radius * yFactor) / (sides / sidesFactor),
29
30
  };
30
31
  }
31
32
  }
@@ -11,24 +11,25 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PolygonDrawerBase = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
+ const piDeg = 180, origin = { x: 0, y: 0 }, defaultSides = 5, sidesOffset = 2;
14
15
  class PolygonDrawerBase {
15
16
  draw(data) {
16
- const { context, particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius), sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (180 * (decimalSides - 2)) / decimalSides, interiorAngle = Math.PI - (Math.PI * interiorAngleDegrees) / 180;
17
+ const { context, particle, radius } = data, start = this.getCenter(particle, radius), side = this.getSidesData(particle, radius), sideCount = side.count.numerator * side.count.denominator, decimalSides = side.count.numerator / side.count.denominator, interiorAngleDegrees = (piDeg * (decimalSides - sidesOffset)) / decimalSides, interiorAngle = Math.PI - (0, engine_1.degToRad)(interiorAngleDegrees);
17
18
  if (!context) {
18
19
  return;
19
20
  }
20
21
  context.beginPath();
21
22
  context.translate(start.x, start.y);
22
- context.moveTo(0, 0);
23
+ context.moveTo(origin.x, origin.y);
23
24
  for (let i = 0; i < sideCount; i++) {
24
- context.lineTo(side.length, 0);
25
- context.translate(side.length, 0);
25
+ context.lineTo(side.length, origin.y);
26
+ context.translate(side.length, origin.y);
26
27
  context.rotate(interiorAngle);
27
28
  }
28
29
  }
29
30
  getSidesCount(particle) {
30
31
  const polygon = particle.shapeData;
31
- return Math.round((0, engine_1.getRangeValue)(polygon?.sides ?? 5));
32
+ return Math.round((0, engine_1.getRangeValue)(polygon?.sides ?? defaultSides));
32
33
  }
33
34
  }
34
35
  exports.PolygonDrawerBase = PolygonDrawerBase;
@@ -11,23 +11,25 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TriangleDrawer = void 0;
13
13
  const PolygonDrawerBase_js_1 = require("./PolygonDrawerBase.js");
14
+ const yFactor = 1.66, sides = 3, double = 2;
14
15
  class TriangleDrawer extends PolygonDrawerBase_js_1.PolygonDrawerBase {
15
16
  getCenter(particle, radius) {
16
17
  return {
17
18
  x: -radius,
18
- y: radius / 1.66,
19
+ y: radius / yFactor,
19
20
  };
20
21
  }
21
22
  getSidesCount() {
22
- return 3;
23
+ return sides;
23
24
  }
24
25
  getSidesData(particle, radius) {
26
+ const diameter = radius * double;
25
27
  return {
26
28
  count: {
27
29
  denominator: 2,
28
30
  numerator: 3,
29
31
  },
30
- length: radius * 2,
32
+ length: diameter,
31
33
  };
32
34
  }
33
35
  }