@tsparticles/shape-polygon 3.0.0-alpha.1 → 3.0.0-beta.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/README.md +17 -12
- package/browser/PolygonDrawerBase.js +2 -3
- package/browser/index.js +7 -7
- package/cjs/PolygonDrawerBase.js +2 -3
- package/cjs/index.js +7 -22
- package/esm/PolygonDrawerBase.js +2 -3
- package/esm/index.js +7 -7
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.shape.polygon.js +13 -15
- package/tsparticles.shape.polygon.min.js +1 -1
- package/tsparticles.shape.polygon.min.js.LICENSE.txt +1 -8
- package/types/PolygonDrawerBase.d.ts +1 -1
- package/types/index.d.ts +3 -3
- package/umd/PolygonDrawerBase.js +2 -3
- package/umd/index.js +7 -7
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# tsParticles Polygon Shape
|
|
4
4
|
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/@tsparticles/shape-polygon)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/shape-polygon)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/shape-polygon) [](https://github.com/sponsors/matteobruni)
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/matteobruni/tsparticles) additional polygon shape.
|
|
10
10
|
|
|
@@ -26,13 +26,14 @@ Once the scripts are loaded you can set up `tsParticles` and the shape like this
|
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
28
|
(async () => {
|
|
29
|
-
await loadPolygonShape();
|
|
29
|
+
await loadPolygonShape(tsParticles);
|
|
30
30
|
|
|
31
31
|
await tsParticles.load({
|
|
32
32
|
id: "tsparticles",
|
|
33
33
|
options: {
|
|
34
34
|
/* options */
|
|
35
35
|
/* here you can use particles.shape.type: "polygon" */
|
|
36
|
+
/* or you can use particles.shape.type: "triangle" */
|
|
36
37
|
},
|
|
37
38
|
});
|
|
38
39
|
})();
|
|
@@ -43,29 +44,33 @@ Once the scripts are loaded you can set up `tsParticles` and the shape like this
|
|
|
43
44
|
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
|
|
44
45
|
|
|
45
46
|
```shell
|
|
46
|
-
$ npm install tsparticles
|
|
47
|
+
$ npm install @tsparticles/shape-polygon
|
|
47
48
|
```
|
|
48
49
|
|
|
49
50
|
or
|
|
50
51
|
|
|
51
52
|
```shell
|
|
52
|
-
$ yarn add tsparticles
|
|
53
|
+
$ yarn add @tsparticles/shape-polygon
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
Then you need to import it in the app, like this:
|
|
56
57
|
|
|
57
58
|
```javascript
|
|
58
|
-
const { tsParticles } = require("tsparticles
|
|
59
|
-
const { loadPolygonShape } = require("tsparticles
|
|
59
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
60
|
+
const { loadPolygonShape } = require("@tsparticles/shape-polygon");
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
(async () => {
|
|
63
|
+
await loadPolygonShape(tsParticles);
|
|
64
|
+
})();
|
|
62
65
|
```
|
|
63
66
|
|
|
64
67
|
or
|
|
65
68
|
|
|
66
69
|
```javascript
|
|
67
|
-
import { tsParticles } from "tsparticles
|
|
68
|
-
import { loadPolygonShape } from "tsparticles
|
|
70
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
71
|
+
import { loadPolygonShape } from "@tsparticles/shape-polygon";
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
(async () => {
|
|
74
|
+
await loadPolygonShape(tsParticles);
|
|
75
|
+
})();
|
|
71
76
|
```
|
|
@@ -15,8 +15,7 @@ export class PolygonDrawerBase {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
getSidesCount(particle) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return sides;
|
|
18
|
+
const polygon = particle.shapeData;
|
|
19
|
+
return Math.round(getRangeValue(polygon?.sides ?? 5));
|
|
21
20
|
}
|
|
22
21
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { PolygonDrawer } from "./PolygonDrawer";
|
|
2
2
|
import { TriangleDrawer } from "./TriangleDrawer";
|
|
3
|
-
export async function loadGenericPolygonShape(engine) {
|
|
4
|
-
await engine.addShape("polygon", new PolygonDrawer());
|
|
3
|
+
export async function loadGenericPolygonShape(engine, refresh = true) {
|
|
4
|
+
await engine.addShape("polygon", new PolygonDrawer(), refresh);
|
|
5
5
|
}
|
|
6
|
-
export async function loadTriangleShape(engine) {
|
|
7
|
-
await engine.addShape("triangle", new TriangleDrawer());
|
|
6
|
+
export async function loadTriangleShape(engine, refresh = true) {
|
|
7
|
+
await engine.addShape("triangle", new TriangleDrawer(), refresh);
|
|
8
8
|
}
|
|
9
|
-
export async function loadPolygonShape(engine) {
|
|
10
|
-
await loadGenericPolygonShape(engine);
|
|
11
|
-
await loadTriangleShape(engine);
|
|
9
|
+
export async function loadPolygonShape(engine, refresh = true) {
|
|
10
|
+
await loadGenericPolygonShape(engine, refresh);
|
|
11
|
+
await loadTriangleShape(engine, refresh);
|
|
12
12
|
}
|
package/cjs/PolygonDrawerBase.js
CHANGED
|
@@ -18,9 +18,8 @@ class PolygonDrawerBase {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
getSidesCount(particle) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return sides;
|
|
21
|
+
const polygon = particle.shapeData;
|
|
22
|
+
return Math.round((0, engine_1.getRangeValue)(polygon?.sides ?? 5));
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
exports.PolygonDrawerBase = PolygonDrawerBase;
|
package/cjs/index.js
CHANGED
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.loadPolygonShape = exports.loadTriangleShape = exports.loadGenericPolygonShape = void 0;
|
|
13
4
|
const PolygonDrawer_1 = require("./PolygonDrawer");
|
|
14
5
|
const TriangleDrawer_1 = require("./TriangleDrawer");
|
|
15
|
-
function loadGenericPolygonShape(engine) {
|
|
16
|
-
|
|
17
|
-
yield engine.addShape("polygon", new PolygonDrawer_1.PolygonDrawer());
|
|
18
|
-
});
|
|
6
|
+
async function loadGenericPolygonShape(engine, refresh = true) {
|
|
7
|
+
await engine.addShape("polygon", new PolygonDrawer_1.PolygonDrawer(), refresh);
|
|
19
8
|
}
|
|
20
9
|
exports.loadGenericPolygonShape = loadGenericPolygonShape;
|
|
21
|
-
function loadTriangleShape(engine) {
|
|
22
|
-
|
|
23
|
-
yield engine.addShape("triangle", new TriangleDrawer_1.TriangleDrawer());
|
|
24
|
-
});
|
|
10
|
+
async function loadTriangleShape(engine, refresh = true) {
|
|
11
|
+
await engine.addShape("triangle", new TriangleDrawer_1.TriangleDrawer(), refresh);
|
|
25
12
|
}
|
|
26
13
|
exports.loadTriangleShape = loadTriangleShape;
|
|
27
|
-
function loadPolygonShape(engine) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
yield loadTriangleShape(engine);
|
|
31
|
-
});
|
|
14
|
+
async function loadPolygonShape(engine, refresh = true) {
|
|
15
|
+
await loadGenericPolygonShape(engine, refresh);
|
|
16
|
+
await loadTriangleShape(engine, refresh);
|
|
32
17
|
}
|
|
33
18
|
exports.loadPolygonShape = loadPolygonShape;
|
package/esm/PolygonDrawerBase.js
CHANGED
|
@@ -15,8 +15,7 @@ export class PolygonDrawerBase {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
getSidesCount(particle) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return sides;
|
|
18
|
+
const polygon = particle.shapeData;
|
|
19
|
+
return Math.round(getRangeValue(polygon?.sides ?? 5));
|
|
21
20
|
}
|
|
22
21
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { PolygonDrawer } from "./PolygonDrawer";
|
|
2
2
|
import { TriangleDrawer } from "./TriangleDrawer";
|
|
3
|
-
export async function loadGenericPolygonShape(engine) {
|
|
4
|
-
await engine.addShape("polygon", new PolygonDrawer());
|
|
3
|
+
export async function loadGenericPolygonShape(engine, refresh = true) {
|
|
4
|
+
await engine.addShape("polygon", new PolygonDrawer(), refresh);
|
|
5
5
|
}
|
|
6
|
-
export async function loadTriangleShape(engine) {
|
|
7
|
-
await engine.addShape("triangle", new TriangleDrawer());
|
|
6
|
+
export async function loadTriangleShape(engine, refresh = true) {
|
|
7
|
+
await engine.addShape("triangle", new TriangleDrawer(), refresh);
|
|
8
8
|
}
|
|
9
|
-
export async function loadPolygonShape(engine) {
|
|
10
|
-
await loadGenericPolygonShape(engine);
|
|
11
|
-
await loadTriangleShape(engine);
|
|
9
|
+
export async function loadPolygonShape(engine, refresh = true) {
|
|
10
|
+
await loadGenericPolygonShape(engine, refresh);
|
|
11
|
+
await loadTriangleShape(engine, refresh);
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-polygon",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles polygon shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -45,10 +45,11 @@
|
|
|
45
45
|
"unpkg": "tsparticles.shape.polygon.min.js",
|
|
46
46
|
"module": "esm/index.js",
|
|
47
47
|
"types": "types/index.d.ts",
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@tsparticles/engine": "^3.0.0-beta.0"
|
|
51
|
+
},
|
|
48
52
|
"publishConfig": {
|
|
49
53
|
"access": "public"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@tsparticles/engine": "^3.0.0-alpha.1"
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|