@tsparticles/plugin-polygon-mask 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.
Files changed (41) hide show
  1. package/README.md +15 -11
  2. package/browser/Options/Classes/PolygonMask.js +2 -8
  3. package/browser/Options/Classes/PolygonMaskDraw.js +1 -18
  4. package/browser/Options/Classes/PolygonMaskDrawStroke.js +3 -4
  5. package/browser/PolygonMaskInstance.js +297 -305
  6. package/browser/index.js +7 -8
  7. package/browser/pathseg.js +1 -1
  8. package/browser/utils.js +3 -5
  9. package/cjs/Options/Classes/PolygonMask.js +2 -8
  10. package/cjs/Options/Classes/PolygonMaskDraw.js +1 -18
  11. package/cjs/Options/Classes/PolygonMaskDrawStroke.js +2 -3
  12. package/cjs/PolygonMaskInstance.js +309 -332
  13. package/cjs/index.js +7 -19
  14. package/cjs/pathseg.js +1 -1
  15. package/cjs/utils.js +4 -6
  16. package/esm/Options/Classes/PolygonMask.js +2 -8
  17. package/esm/Options/Classes/PolygonMaskDraw.js +1 -18
  18. package/esm/Options/Classes/PolygonMaskDrawStroke.js +3 -4
  19. package/esm/PolygonMaskInstance.js +297 -305
  20. package/esm/index.js +7 -8
  21. package/esm/pathseg.js +1 -1
  22. package/esm/utils.js +3 -5
  23. package/package.json +8 -5
  24. package/report.html +4 -4
  25. package/tsparticles.plugin.polygon-mask.js +336 -362
  26. package/tsparticles.plugin.polygon-mask.min.js +1 -1
  27. package/tsparticles.plugin.polygon-mask.min.js.LICENSE.txt +1 -8
  28. package/types/Options/Classes/PolygonMask.d.ts +1 -4
  29. package/types/Options/Classes/PolygonMaskDraw.d.ts +1 -6
  30. package/types/Options/Classes/PolygonMaskDrawStroke.d.ts +1 -2
  31. package/types/Options/Interfaces/IPolygonMaskDraw.d.ts +0 -3
  32. package/types/PolygonMaskInstance.d.ts +13 -15
  33. package/types/index.d.ts +1 -1
  34. package/types/utils.d.ts +1 -2
  35. package/umd/Options/Classes/PolygonMask.js +3 -9
  36. package/umd/Options/Classes/PolygonMaskDraw.js +2 -19
  37. package/umd/Options/Classes/PolygonMaskDrawStroke.js +2 -3
  38. package/umd/PolygonMaskInstance.js +298 -306
  39. package/umd/index.js +7 -8
  40. package/umd/pathseg.js +1 -1
  41. 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
- [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-plugin-polygon-mask/badge)](https://www.jsdelivr.com/package/npm/tsparticles-plugin-polygon-mask)
6
- [![npmjs](https://badge.fury.io/js/tsparticles-plugin-polygon-mask.svg)](https://www.npmjs.com/package/tsparticles-plugin-polygon-mask)
7
- [![npmjs](https://img.shields.io/npm/dt/tsparticles-plugin-polygon-mask)](https://www.npmjs.com/package/tsparticles-plugin-polygon-mask) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/plugin-polygon-mask/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-polygon-mask)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/plugin-polygon-mask.svg)](https://www.npmjs.com/package/@tsparticles/plugin-polygon-mask)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/plugin-polygon-mask)](https://www.npmjs.com/package/@tsparticles/plugin-polygon-mask) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](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-plugin-polygon-mask
45
+ $ npm install @tsparticles/plugin-polygon-mask
46
46
  ```
47
47
 
48
48
  or
49
49
 
50
50
  ```shell
51
- $ yarn add tsparticles-plugin-polygon-mask
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-engine");
58
- const { loadPolygonMaskPlugin } = require("tsparticles-plugin-polygon-mask");
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadPolygonMaskPlugin } = require("@tsparticles/plugin-polygon-mask");
59
59
 
60
- loadPolygonMaskPlugin(tsParticles); // awaitable
60
+ (async () => {
61
+ await loadPolygonMaskPlugin(tsParticles);
62
+ })();
61
63
  ```
62
64
 
63
65
  or
64
66
 
65
67
  ```javascript
66
- import { tsParticles } from "tsparticles-engine";
67
- import { loadPolygonMaskPlugin } from "tsparticles-plugin-polygon-mask";
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadPolygonMaskPlugin } from "@tsparticles/plugin-polygon-mask";
68
70
 
69
- loadPolygonMaskPlugin(tsParticles); // awaitable
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 (typeof data.data === "string") {
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 = (_a = data.stroke) !== null && _a !== void 0 ? _a : {
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 (typeof this.color.value === "string") {
15
- this.opacity = (_a = stringToAlpha(this.color.value)) !== null && _a !== void 0 ? _a : 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;