@tsparticles/shape-rounded-polygon 3.9.1 → 4.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/38.min.js +2 -0
- package/38.min.js.LICENSE.txt +1 -0
- package/browser/Utils.js +6 -0
- package/browser/index.js +6 -4
- package/cjs/IRoundedPolygonShape.js +1 -2
- package/cjs/RoundedParticle.js +1 -2
- package/cjs/RoundedPolygonDrawer.js +6 -10
- package/cjs/Utils.js +8 -6
- package/cjs/index.js +6 -7
- package/dist_browser_RoundedPolygonDrawer_js.js +40 -0
- package/esm/Utils.js +6 -0
- package/esm/index.js +6 -4
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.shape.rounded-polygon.js +209 -40
- package/tsparticles.shape.rounded-polygon.min.js +1 -1
- package/tsparticles.shape.rounded-polygon.min.js.LICENSE.txt +1 -1
- package/types/index.d.ts +1 -1
- package/umd/Utils.js +6 -0
- package/umd/index.js +41 -5
package/38.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 38.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_shape_rounded_polygon=this.webpackChunk_tsparticles_shape_rounded_polygon||[]).push([[38],{38(t,e,a){a.d(e,{RoundedPolygonDrawer:()=>r});var o=a(303);const n=2*Math.PI,s=.5;class r{constructor(){this.validTypes=["rounded-polygon"]}draw(t){const{context:e,particle:a,radius:o}=t;!function(t,e,a){let o=e[0],n=e[1];if(!o||!n)return;const r=e.length;t.moveTo((o.x+n.x)*s,(o.y+n.y)*s);for(let i=1;i<=r;i++)o=n,n=e[(i+1)%r],o&&n&&t.arcTo(o.x,o.y,(o.x+n.x)*s,(o.y+n.y)*s,a)}(e,function(t,e,a=0){const o=n/t,s=[];for(let n=0;n<t;n++)s.push({x:Math.cos(n*o+a)*e,y:Math.sin(n*o+a)*e});return s}(a.sides,o),a.borderRadius??5)}getSidesCount(t){const e=t.shapeData;return Math.round((0,o.getRangeValue)(e?.sides??5))}particleInit(t,e){const a=e.shapeData;e.borderRadius=Math.round((0,o.getRangeValue)(a?.radius??5))*t.retina.pixelRatio}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles RoundedPolygon Shape v4.0.0-alpha.0 by Matteo Bruni */
|
package/browser/Utils.js
CHANGED
|
@@ -9,11 +9,17 @@ export function polygon(sides, radius, rot = defaultRotation) {
|
|
|
9
9
|
export function roundedPath(context, path, radius) {
|
|
10
10
|
const index1 = 0, index2 = 1, increment = 1;
|
|
11
11
|
let p1 = path[index1], p2 = path[index2];
|
|
12
|
+
if (!p1 || !p2) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
12
15
|
const len = path.length;
|
|
13
16
|
context.moveTo((p1.x + p2.x) * half, (p1.y + p2.y) * half);
|
|
14
17
|
for (let i = 1; i <= len; i++) {
|
|
15
18
|
p1 = p2;
|
|
16
19
|
p2 = path[(i + increment) % len];
|
|
20
|
+
if (!p1 || !p2) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
17
23
|
context.arcTo(p1.x, p1.y, (p1.x + p2.x) * half, (p1.y + p2.y) * half, radius);
|
|
18
24
|
}
|
|
19
25
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
1
|
+
export function loadRoundedPolygonShape(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { RoundedPolygonDrawer } = await import("./RoundedPolygonDrawer.js");
|
|
5
|
+
e.addShape(new RoundedPolygonDrawer());
|
|
6
|
+
});
|
|
5
7
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/RoundedParticle.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.RoundedPolygonDrawer = 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 { polygon, roundedPath } from "./Utils.js";
|
|
6
3
|
const defaultSides = 5, defaultRadius = 5;
|
|
7
|
-
class RoundedPolygonDrawer {
|
|
4
|
+
export class RoundedPolygonDrawer {
|
|
8
5
|
constructor() {
|
|
9
6
|
this.validTypes = ["rounded-polygon"];
|
|
10
7
|
}
|
|
11
8
|
draw(data) {
|
|
12
9
|
const { context, particle, radius } = data;
|
|
13
|
-
|
|
10
|
+
roundedPath(context, polygon(particle.sides, radius), particle.borderRadius ?? defaultRadius);
|
|
14
11
|
}
|
|
15
12
|
getSidesCount(particle) {
|
|
16
13
|
const roundedPolygon = particle.shapeData;
|
|
17
|
-
return Math.round(
|
|
14
|
+
return Math.round(getRangeValue(roundedPolygon?.sides ?? defaultSides));
|
|
18
15
|
}
|
|
19
16
|
particleInit(container, particle) {
|
|
20
17
|
const shapeData = particle.shapeData;
|
|
21
18
|
particle.borderRadius =
|
|
22
|
-
Math.round(
|
|
19
|
+
Math.round(getRangeValue(shapeData?.radius ?? defaultSides)) * container.retina.pixelRatio;
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.RoundedPolygonDrawer = RoundedPolygonDrawer;
|
package/cjs/Utils.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.polygon = polygon;
|
|
4
|
-
exports.roundedPath = roundedPath;
|
|
5
1
|
const double = 2, doublePI = Math.PI * double, half = 0.5, defaultRotation = 0;
|
|
6
|
-
function polygon(sides, radius, rot = defaultRotation) {
|
|
2
|
+
export function polygon(sides, radius, rot = defaultRotation) {
|
|
7
3
|
const step = doublePI / sides, path = [];
|
|
8
4
|
for (let i = 0; i < sides; i++) {
|
|
9
5
|
path.push({ x: Math.cos(i * step + rot) * radius, y: Math.sin(i * step + rot) * radius });
|
|
10
6
|
}
|
|
11
7
|
return path;
|
|
12
8
|
}
|
|
13
|
-
function roundedPath(context, path, radius) {
|
|
9
|
+
export function roundedPath(context, path, radius) {
|
|
14
10
|
const index1 = 0, index2 = 1, increment = 1;
|
|
15
11
|
let p1 = path[index1], p2 = path[index2];
|
|
12
|
+
if (!p1 || !p2) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
16
15
|
const len = path.length;
|
|
17
16
|
context.moveTo((p1.x + p2.x) * half, (p1.y + p2.y) * half);
|
|
18
17
|
for (let i = 1; i <= len; i++) {
|
|
19
18
|
p1 = p2;
|
|
20
19
|
p2 = path[(i + increment) % len];
|
|
20
|
+
if (!p1 || !p2) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
21
23
|
context.arcTo(p1.x, p1.y, (p1.x + p2.x) * half, (p1.y + p2.y) * half, radius);
|
|
22
24
|
}
|
|
23
25
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
await engine.addShape(new RoundedPolygonDrawer_js_1.RoundedPolygonDrawer(), refresh);
|
|
1
|
+
export function loadRoundedPolygonShape(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { RoundedPolygonDrawer } = await import("./RoundedPolygonDrawer.js");
|
|
5
|
+
e.addShape(new RoundedPolygonDrawer());
|
|
6
|
+
});
|
|
8
7
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_shape_rounded_polygon"] = this["webpackChunk_tsparticles_shape_rounded_polygon"] || []).push([["dist_browser_RoundedPolygonDrawer_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/RoundedPolygonDrawer.js"
|
|
21
|
+
/*!**********************************************!*\
|
|
22
|
+
!*** ./dist/browser/RoundedPolygonDrawer.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 */ RoundedPolygonDrawer: () => (/* binding */ RoundedPolygonDrawer)\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,\n defaultRadius = 5;\nclass RoundedPolygonDrawer {\n constructor() {\n this.validTypes = [\"rounded-polygon\"];\n }\n draw(data) {\n const {\n context,\n particle,\n radius\n } = data;\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.roundedPath)(context, (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.polygon)(particle.sides, radius), particle.borderRadius ?? defaultRadius);\n }\n getSidesCount(particle) {\n const roundedPolygon = particle.shapeData;\n return Math.round((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(roundedPolygon?.sides ?? defaultSides));\n }\n particleInit(container, particle) {\n const shapeData = particle.shapeData;\n particle.borderRadius = Math.round((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(shapeData?.radius ?? defaultSides)) * container.retina.pixelRatio;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-rounded-polygon/./dist/browser/RoundedPolygonDrawer.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Utils.js"
|
|
31
|
+
/*!*******************************!*\
|
|
32
|
+
!*** ./dist/browser/Utils.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 */ polygon: () => (/* binding */ polygon),\n/* harmony export */ roundedPath: () => (/* binding */ roundedPath)\n/* harmony export */ });\nconst double = 2,\n doublePI = Math.PI * double,\n half = 0.5,\n defaultRotation = 0;\nfunction polygon(sides, radius, rot = defaultRotation) {\n const step = doublePI / sides,\n path = [];\n for (let i = 0; i < sides; i++) {\n path.push({\n x: Math.cos(i * step + rot) * radius,\n y: Math.sin(i * step + rot) * radius\n });\n }\n return path;\n}\nfunction roundedPath(context, path, radius) {\n const index1 = 0,\n index2 = 1,\n increment = 1;\n let p1 = path[index1],\n p2 = path[index2];\n if (!p1 || !p2) {\n return;\n }\n const len = path.length;\n context.moveTo((p1.x + p2.x) * half, (p1.y + p2.y) * half);\n for (let i = 1; i <= len; i++) {\n p1 = p2;\n p2 = path[(i + increment) % len];\n if (!p1 || !p2) {\n continue;\n }\n context.arcTo(p1.x, p1.y, (p1.x + p2.x) * half, (p1.y + p2.y) * half, radius);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-rounded-polygon/./dist/browser/Utils.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ }
|
|
39
|
+
|
|
40
|
+
}]);
|
package/esm/Utils.js
CHANGED
|
@@ -9,11 +9,17 @@ export function polygon(sides, radius, rot = defaultRotation) {
|
|
|
9
9
|
export function roundedPath(context, path, radius) {
|
|
10
10
|
const index1 = 0, index2 = 1, increment = 1;
|
|
11
11
|
let p1 = path[index1], p2 = path[index2];
|
|
12
|
+
if (!p1 || !p2) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
12
15
|
const len = path.length;
|
|
13
16
|
context.moveTo((p1.x + p2.x) * half, (p1.y + p2.y) * half);
|
|
14
17
|
for (let i = 1; i <= len; i++) {
|
|
15
18
|
p1 = p2;
|
|
16
19
|
p2 = path[(i + increment) % len];
|
|
20
|
+
if (!p1 || !p2) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
17
23
|
context.arcTo(p1.x, p1.y, (p1.x + p2.x) * half, (p1.y + p2.y) * half, radius);
|
|
18
24
|
}
|
|
19
25
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
1
|
+
export function loadRoundedPolygonShape(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { RoundedPolygonDrawer } = await import("./RoundedPolygonDrawer.js");
|
|
5
|
+
e.addShape(new RoundedPolygonDrawer());
|
|
6
|
+
});
|
|
5
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-rounded-polygon",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles rounded 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.0"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
|
+
"type": "module"
|
|
67
68
|
}
|