@tsparticles/plugin-polygon-mask 3.0.0-alpha.0 → 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 +15 -11
- package/browser/Options/Classes/PolygonMask.js +2 -8
- package/browser/Options/Classes/PolygonMaskDraw.js +1 -18
- package/browser/Options/Classes/PolygonMaskDrawStroke.js +3 -4
- package/browser/PolygonMaskInstance.js +297 -305
- package/browser/index.js +7 -8
- package/browser/pathseg.js +1 -1
- package/browser/utils.js +3 -5
- package/cjs/Options/Classes/PolygonMask.js +2 -8
- package/cjs/Options/Classes/PolygonMaskDraw.js +1 -18
- package/cjs/Options/Classes/PolygonMaskDrawStroke.js +2 -3
- package/cjs/PolygonMaskInstance.js +309 -332
- package/cjs/index.js +7 -19
- package/cjs/pathseg.js +1 -1
- package/cjs/utils.js +4 -6
- package/esm/Options/Classes/PolygonMask.js +2 -8
- package/esm/Options/Classes/PolygonMaskDraw.js +1 -18
- package/esm/Options/Classes/PolygonMaskDrawStroke.js +3 -4
- package/esm/PolygonMaskInstance.js +297 -305
- package/esm/index.js +7 -8
- package/esm/pathseg.js +1 -1
- package/esm/utils.js +3 -5
- package/package.json +8 -5
- package/report.html +4 -4
- package/tsparticles.plugin.polygon-mask.js +336 -362
- package/tsparticles.plugin.polygon-mask.min.js +1 -1
- package/tsparticles.plugin.polygon-mask.min.js.LICENSE.txt +1 -8
- package/types/Options/Classes/PolygonMask.d.ts +1 -4
- package/types/Options/Classes/PolygonMaskDraw.d.ts +1 -6
- package/types/Options/Classes/PolygonMaskDrawStroke.d.ts +1 -2
- package/types/Options/Interfaces/IPolygonMaskDraw.d.ts +0 -3
- package/types/PolygonMaskInstance.d.ts +13 -15
- package/types/index.d.ts +1 -1
- package/types/utils.d.ts +1 -2
- package/umd/Options/Classes/PolygonMask.js +3 -9
- package/umd/Options/Classes/PolygonMaskDraw.js +2 -19
- package/umd/Options/Classes/PolygonMaskDrawStroke.js +2 -3
- package/umd/PolygonMaskInstance.js +298 -306
- package/umd/index.js +7 -8
- package/umd/pathseg.js +1 -1
- package/umd/utils.js +3 -5
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# tsParticles Polygon Mask Plugin
|
|
4
4
|
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-polygon-mask)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/plugin-polygon-mask)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/plugin-polygon-mask) [](https://github.com/sponsors/matteobruni)
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/matteobruni/tsparticles) plugin for particles polygon mask effect.
|
|
10
10
|
|
|
@@ -42,29 +42,33 @@ Once the scripts are loaded you can set up `tsParticles` and the plugin like thi
|
|
|
42
42
|
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
|
|
43
43
|
|
|
44
44
|
```shell
|
|
45
|
-
$ npm install tsparticles
|
|
45
|
+
$ npm install @tsparticles/plugin-polygon-mask
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
or
|
|
49
49
|
|
|
50
50
|
```shell
|
|
51
|
-
$ yarn add tsparticles
|
|
51
|
+
$ yarn add @tsparticles/plugin-polygon-mask
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Then you need to import it in the app, like this:
|
|
55
55
|
|
|
56
56
|
```javascript
|
|
57
|
-
const { tsParticles } = require("tsparticles
|
|
58
|
-
const { loadPolygonMaskPlugin } = require("tsparticles
|
|
57
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
58
|
+
const { loadPolygonMaskPlugin } = require("@tsparticles/plugin-polygon-mask");
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
(async () => {
|
|
61
|
+
await loadPolygonMaskPlugin(tsParticles);
|
|
62
|
+
})();
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
or
|
|
64
66
|
|
|
65
67
|
```javascript
|
|
66
|
-
import { tsParticles } from "tsparticles
|
|
67
|
-
import { loadPolygonMaskPlugin } from "tsparticles
|
|
68
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
69
|
+
import { loadPolygonMaskPlugin } from "@tsparticles/plugin-polygon-mask";
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
(async () => {
|
|
72
|
+
await loadPolygonMaskPlugin(tsParticles);
|
|
73
|
+
})();
|
|
70
74
|
```
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { deepExtend, isString, } from "@tsparticles/engine";
|
|
1
2
|
import { PolygonMaskDraw } from "./PolygonMaskDraw";
|
|
2
3
|
import { PolygonMaskInline } from "./PolygonMaskInline";
|
|
3
4
|
import { PolygonMaskLocalSvg } from "./PolygonMaskLocalSvg";
|
|
4
5
|
import { PolygonMaskMove } from "./PolygonMaskMove";
|
|
5
|
-
import { deepExtend } from "@tsparticles/engine";
|
|
6
6
|
export class PolygonMask {
|
|
7
7
|
constructor() {
|
|
8
8
|
this.draw = new PolygonMaskDraw();
|
|
@@ -12,12 +12,6 @@ export class PolygonMask {
|
|
|
12
12
|
this.scale = 1;
|
|
13
13
|
this.type = "none";
|
|
14
14
|
}
|
|
15
|
-
get inlineArrangement() {
|
|
16
|
-
return this.inline.arrangement;
|
|
17
|
-
}
|
|
18
|
-
set inlineArrangement(value) {
|
|
19
|
-
this.inline.arrangement = value;
|
|
20
|
-
}
|
|
21
15
|
load(data) {
|
|
22
16
|
if (!data) {
|
|
23
17
|
return;
|
|
@@ -41,7 +35,7 @@ export class PolygonMask {
|
|
|
41
35
|
this.url = data.url;
|
|
42
36
|
}
|
|
43
37
|
if (data.data !== undefined) {
|
|
44
|
-
if (
|
|
38
|
+
if (isString(data.data)) {
|
|
45
39
|
this.data = data.data;
|
|
46
40
|
}
|
|
47
41
|
else {
|
|
@@ -1,34 +1,17 @@
|
|
|
1
|
-
import { OptionsColor } from "@tsparticles/engine";
|
|
2
1
|
import { PolygonMaskDrawStroke } from "./PolygonMaskDrawStroke";
|
|
3
2
|
export class PolygonMaskDraw {
|
|
4
3
|
constructor() {
|
|
5
4
|
this.enable = false;
|
|
6
5
|
this.stroke = new PolygonMaskDrawStroke();
|
|
7
6
|
}
|
|
8
|
-
get lineColor() {
|
|
9
|
-
return this.stroke.color;
|
|
10
|
-
}
|
|
11
|
-
set lineColor(value) {
|
|
12
|
-
this.stroke.color = OptionsColor.create(this.stroke.color, value);
|
|
13
|
-
}
|
|
14
|
-
get lineWidth() {
|
|
15
|
-
return this.stroke.width;
|
|
16
|
-
}
|
|
17
|
-
set lineWidth(value) {
|
|
18
|
-
this.stroke.width = value;
|
|
19
|
-
}
|
|
20
7
|
load(data) {
|
|
21
|
-
var _a;
|
|
22
8
|
if (!data) {
|
|
23
9
|
return;
|
|
24
10
|
}
|
|
25
11
|
if (data.enable !== undefined) {
|
|
26
12
|
this.enable = data.enable;
|
|
27
13
|
}
|
|
28
|
-
const stroke =
|
|
29
|
-
color: data.lineColor,
|
|
30
|
-
width: data.lineWidth,
|
|
31
|
-
};
|
|
14
|
+
const stroke = data.stroke;
|
|
32
15
|
this.stroke.load(stroke);
|
|
33
16
|
}
|
|
34
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OptionsColor, stringToAlpha } from "@tsparticles/engine";
|
|
1
|
+
import { OptionsColor, isString, stringToAlpha } from "@tsparticles/engine";
|
|
2
2
|
export class PolygonMaskDrawStroke {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.color = new OptionsColor();
|
|
@@ -6,13 +6,12 @@ export class PolygonMaskDrawStroke {
|
|
|
6
6
|
this.opacity = 1;
|
|
7
7
|
}
|
|
8
8
|
load(data) {
|
|
9
|
-
var _a;
|
|
10
9
|
if (!data) {
|
|
11
10
|
return;
|
|
12
11
|
}
|
|
13
12
|
this.color = OptionsColor.create(this.color, data.color);
|
|
14
|
-
if (
|
|
15
|
-
this.opacity =
|
|
13
|
+
if (isString(this.color.value)) {
|
|
14
|
+
this.opacity = stringToAlpha(this.color.value) ?? this.opacity;
|
|
16
15
|
}
|
|
17
16
|
if (data.opacity !== undefined) {
|
|
18
17
|
this.opacity = data.opacity;
|