@tsparticles/plugin-polygon-mask 4.0.0-beta.0 → 4.0.0-beta.10
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/{319.min.js → 225.min.js} +2 -2
- package/780.min.js +1 -0
- package/README.md +27 -0
- package/browser/Options/Classes/PolygonMask.js +2 -2
- package/browser/Options/Classes/PolygonMaskDraw.js +2 -2
- package/browser/Options/Classes/PolygonMaskDrawStroke.js +4 -4
- package/browser/PolygonMaskInstance.js +6 -8
- package/browser/PolygonMaskPlugin.js +5 -5
- package/browser/index.js +3 -3
- package/browser/utils.js +4 -4
- package/cjs/Options/Classes/PolygonMask.js +2 -2
- package/cjs/Options/Classes/PolygonMaskDraw.js +2 -2
- package/cjs/Options/Classes/PolygonMaskDrawStroke.js +4 -4
- package/cjs/PolygonMaskInstance.js +6 -8
- package/cjs/PolygonMaskPlugin.js +5 -5
- package/cjs/index.js +3 -3
- package/cjs/utils.js +4 -4
- package/dist_browser_PolygonMaskInstance_js.js +3 -3
- package/dist_browser_PolygonMaskPlugin_js.js +5 -5
- package/esm/Options/Classes/PolygonMask.js +2 -2
- package/esm/Options/Classes/PolygonMaskDraw.js +2 -2
- package/esm/Options/Classes/PolygonMaskDrawStroke.js +4 -4
- package/esm/PolygonMaskInstance.js +6 -8
- package/esm/PolygonMaskPlugin.js +5 -5
- package/esm/index.js +3 -3
- package/esm/utils.js +4 -4
- package/package.json +4 -5
- package/report.html +84 -29
- package/tsparticles.plugin.polygon-mask.js +2 -2
- package/tsparticles.plugin.polygon-mask.min.js +2 -2
- package/types/Options/Classes/PolygonMask.d.ts +2 -2
- package/types/Options/Classes/PolygonMaskDraw.d.ts +2 -2
- package/types/Options/Classes/PolygonMaskDrawStroke.d.ts +3 -3
- package/types/PolygonMaskInstance.d.ts +5 -5
- package/types/PolygonMaskPlugin.d.ts +3 -3
- package/types/utils.d.ts +3 -3
- package/99.min.js +0 -1
- package/umd/Enums/PolygonMaskInlineArrangement.js +0 -21
- package/umd/Enums/PolygonMaskMoveType.js +0 -18
- package/umd/Enums/PolygonMaskType.js +0 -20
- package/umd/Interfaces/ISvgPath.js +0 -12
- package/umd/Options/Classes/PolygonMask.js +0 -74
- package/umd/Options/Classes/PolygonMaskDraw.js +0 -34
- package/umd/Options/Classes/PolygonMaskDrawStroke.js +0 -42
- package/umd/Options/Classes/PolygonMaskInline.js +0 -30
- package/umd/Options/Classes/PolygonMaskLocalSvg.js +0 -42
- package/umd/Options/Classes/PolygonMaskMove.js +0 -35
- package/umd/Options/Interfaces/IPolygonMask.js +0 -12
- package/umd/Options/Interfaces/IPolygonMaskDraw.js +0 -12
- package/umd/Options/Interfaces/IPolygonMaskDrawStroke.js +0 -12
- package/umd/Options/Interfaces/IPolygonMaskInline.js +0 -12
- package/umd/Options/Interfaces/IPolygonMaskLocalSvg.js +0 -12
- package/umd/Options/Interfaces/IPolygonMaskMove.js +0 -12
- package/umd/PolygonMaskInstance.js +0 -425
- package/umd/PolygonMaskPlugin.js +0 -75
- package/umd/index.js +0 -60
- package/umd/pathseg.js +0 -1486
- package/umd/types.js +0 -12
- package/umd/utils.js +0 -139
package/umd/types.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|
package/umd/utils.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.drawPolygonMask = drawPolygonMask;
|
|
13
|
-
exports.drawPolygonMaskPath = drawPolygonMaskPath;
|
|
14
|
-
exports.parsePaths = parsePaths;
|
|
15
|
-
exports.calcClosestPointOnSegment = calcClosestPointOnSegment;
|
|
16
|
-
exports.segmentBounce = segmentBounce;
|
|
17
|
-
const engine_1 = require("@tsparticles/engine");
|
|
18
|
-
const squareExp = 2, inSegmentRange = {
|
|
19
|
-
min: 0,
|
|
20
|
-
max: 1,
|
|
21
|
-
};
|
|
22
|
-
function drawPolygonMask(engine, context, rawData, stroke, hdr = false) {
|
|
23
|
-
const color = (0, engine_1.rangeColorToRgb)(engine, stroke.color);
|
|
24
|
-
if (!color) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const firstIndex = 0, firstItem = rawData[firstIndex];
|
|
28
|
-
if (!firstItem) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
context.beginPath();
|
|
32
|
-
context.moveTo(firstItem.x, firstItem.y);
|
|
33
|
-
for (const item of rawData) {
|
|
34
|
-
context.lineTo(item.x, item.y);
|
|
35
|
-
}
|
|
36
|
-
context.closePath();
|
|
37
|
-
context.strokeStyle = (0, engine_1.getStyleFromRgb)(color, hdr);
|
|
38
|
-
context.lineWidth = stroke.width;
|
|
39
|
-
context.stroke();
|
|
40
|
-
}
|
|
41
|
-
function drawPolygonMaskPath(engine, context, path, stroke, position, hdr = false) {
|
|
42
|
-
const defaultTransform = {
|
|
43
|
-
a: 1,
|
|
44
|
-
b: 0,
|
|
45
|
-
c: 0,
|
|
46
|
-
d: 1,
|
|
47
|
-
};
|
|
48
|
-
context.setTransform(defaultTransform.a, defaultTransform.b, defaultTransform.c, defaultTransform.d, position.x, position.y);
|
|
49
|
-
const color = (0, engine_1.rangeColorToRgb)(engine, stroke.color);
|
|
50
|
-
if (!color) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
context.strokeStyle = (0, engine_1.getStyleFromRgb)(color, hdr, stroke.opacity);
|
|
54
|
-
context.lineWidth = stroke.width;
|
|
55
|
-
context.stroke(path);
|
|
56
|
-
context.resetTransform();
|
|
57
|
-
}
|
|
58
|
-
function parsePaths(paths, scale, offset) {
|
|
59
|
-
const res = [], defaultCount = 0;
|
|
60
|
-
for (const path of paths) {
|
|
61
|
-
const segments = path.element.pathSegList, len = segments?.numberOfItems ?? defaultCount, p = {
|
|
62
|
-
x: 0,
|
|
63
|
-
y: 0,
|
|
64
|
-
};
|
|
65
|
-
for (let i = 0; i < len; i++) {
|
|
66
|
-
const segment = segments?.getItem(i), svgPathSeg = globalThis.SVGPathSeg;
|
|
67
|
-
switch (segment?.pathSegType) {
|
|
68
|
-
case svgPathSeg.PATHSEG_MOVETO_ABS:
|
|
69
|
-
case svgPathSeg.PATHSEG_LINETO_ABS:
|
|
70
|
-
case svgPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
|
|
71
|
-
case svgPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
|
|
72
|
-
case svgPathSeg.PATHSEG_ARC_ABS:
|
|
73
|
-
case svgPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
|
|
74
|
-
case svgPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: {
|
|
75
|
-
const absSeg = segment;
|
|
76
|
-
p.x = absSeg.x;
|
|
77
|
-
p.y = absSeg.y;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case svgPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:
|
|
81
|
-
p.x = segment.x;
|
|
82
|
-
break;
|
|
83
|
-
case svgPathSeg.PATHSEG_LINETO_VERTICAL_ABS:
|
|
84
|
-
p.y = segment.y;
|
|
85
|
-
break;
|
|
86
|
-
case svgPathSeg.PATHSEG_LINETO_REL:
|
|
87
|
-
case svgPathSeg.PATHSEG_MOVETO_REL:
|
|
88
|
-
case svgPathSeg.PATHSEG_CURVETO_CUBIC_REL:
|
|
89
|
-
case svgPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:
|
|
90
|
-
case svgPathSeg.PATHSEG_ARC_REL:
|
|
91
|
-
case svgPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
|
|
92
|
-
case svgPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: {
|
|
93
|
-
const relSeg = segment;
|
|
94
|
-
p.x += relSeg.x;
|
|
95
|
-
p.y += relSeg.y;
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case svgPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:
|
|
99
|
-
p.x += segment.x;
|
|
100
|
-
break;
|
|
101
|
-
case svgPathSeg.PATHSEG_LINETO_VERTICAL_REL:
|
|
102
|
-
p.y += segment.y;
|
|
103
|
-
break;
|
|
104
|
-
case svgPathSeg.PATHSEG_UNKNOWN:
|
|
105
|
-
case svgPathSeg.PATHSEG_CLOSEPATH:
|
|
106
|
-
continue;
|
|
107
|
-
default:
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
res.push({
|
|
111
|
-
x: p.x * scale + offset.x,
|
|
112
|
-
y: p.y * scale + offset.y,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return res;
|
|
117
|
-
}
|
|
118
|
-
function calcClosestPointOnSegment(s1, s2, pos) {
|
|
119
|
-
const { dx: dx1, dy: dy1 } = (0, engine_1.getDistances)(pos, s1), { dx: dx2, dy: dy2 } = (0, engine_1.getDistances)(s2, s1), t = (dx1 * dx2 + dy1 * dy2) / (dx2 ** squareExp + dy2 ** squareExp), res = {
|
|
120
|
-
x: s1.x + dx2 * t,
|
|
121
|
-
y: s1.y + dy2 * t,
|
|
122
|
-
isOnSegment: t >= inSegmentRange.min && t <= inSegmentRange.max,
|
|
123
|
-
};
|
|
124
|
-
if (t < inSegmentRange.min) {
|
|
125
|
-
res.x = s1.x;
|
|
126
|
-
res.y = s1.y;
|
|
127
|
-
}
|
|
128
|
-
else if (t > inSegmentRange.max) {
|
|
129
|
-
res.x = s2.x;
|
|
130
|
-
res.y = s2.y;
|
|
131
|
-
}
|
|
132
|
-
return res;
|
|
133
|
-
}
|
|
134
|
-
function segmentBounce(start, stop, velocity) {
|
|
135
|
-
const { dx, dy } = (0, engine_1.getDistances)(start, stop), wallAngle = Math.atan2(dy, dx), wallNormal = engine_1.Vector.create(Math.sin(wallAngle), -Math.cos(wallAngle)), d = engine_1.double * (velocity.x * wallNormal.x + velocity.y * wallNormal.y);
|
|
136
|
-
wallNormal.multTo(d);
|
|
137
|
-
velocity.subFrom(wallNormal);
|
|
138
|
-
}
|
|
139
|
-
});
|