@tsparticles/effect-trail 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/browser/TrailDrawer.js +21 -23
- package/browser/index.js +1 -1
- package/cjs/TrailDrawer.js +21 -23
- package/cjs/index.js +2 -2
- package/esm/TrailDrawer.js +21 -23
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.effect.trail.js +12 -200
- package/tsparticles.effect.trail.min.js +1 -1
- package/tsparticles.effect.trail.min.js.LICENSE.txt +1 -1
- package/types/TrailDrawer.d.ts +7 -0
- package/umd/TrailDrawer.js +21 -23
- package/umd/index.js +3 -27
- package/892.min.js +0 -2
- package/892.min.js.LICENSE.txt +0 -1
- package/dist_browser_TrailDrawer_js.js +0 -30
package/browser/TrailDrawer.js
CHANGED
@@ -1,44 +1,42 @@
|
|
1
1
|
import { getRangeValue, } from "@tsparticles/engine";
|
2
|
-
const double = 2, minTrailLength = 2, trailLengthOffset = 1, noItems = 0, half = 0.5, minWidth = -1, defaultLength = 10, defaultAlpha = 1;
|
2
|
+
const double = 2, minTrailLength = 2, trailLengthOffset = 1, noItems = 0, half = 0.5, minWidth = -1, defaultLength = 10, defaultAlpha = 1, origin = { x: 0, y: 0 };
|
3
|
+
const defaultTransform = {
|
4
|
+
a: 1,
|
5
|
+
b: 0,
|
6
|
+
c: 0,
|
7
|
+
d: 1,
|
8
|
+
};
|
3
9
|
export class TrailDrawer {
|
4
10
|
draw(data) {
|
5
|
-
const { context, radius, particle } = data, diameter = radius * double, pxRatio = particle.container.retina.pixelRatio, currentPos = particle.getPosition();
|
6
|
-
if (!
|
11
|
+
const { context, radius, particle, transformData } = data, diameter = radius * double, pxRatio = particle.container.retina.pixelRatio, currentPos = particle.getPosition(), trail = particle.trail;
|
12
|
+
if (!trail || !particle.trailLength) {
|
7
13
|
return;
|
8
14
|
}
|
9
15
|
const pathLength = particle.trailLength + radius;
|
10
|
-
|
16
|
+
trail.push({
|
11
17
|
color: context.fillStyle ?? context.strokeStyle,
|
12
18
|
position: {
|
13
19
|
x: currentPos.x,
|
14
20
|
y: currentPos.y,
|
15
21
|
},
|
22
|
+
transformData: { ...data.transformData },
|
16
23
|
});
|
17
|
-
if (
|
24
|
+
if (trail.length < minTrailLength) {
|
18
25
|
return;
|
19
26
|
}
|
20
|
-
while (
|
21
|
-
|
27
|
+
while (trail.length > pathLength) {
|
28
|
+
trail.shift();
|
22
29
|
}
|
23
|
-
const trailLength = Math.min(
|
24
|
-
x: currentPos.x,
|
25
|
-
y: currentPos.y,
|
26
|
-
}, canvasSize = {
|
30
|
+
const trailLength = Math.min(trail.length, pathLength), canvasSize = {
|
27
31
|
width: particle.container.canvas.size.width + diameter,
|
28
32
|
height: particle.container.canvas.size.height + diameter,
|
29
33
|
};
|
30
|
-
let lastPos =
|
31
|
-
const defaultTransform = {
|
32
|
-
a: 1,
|
33
|
-
b: 0,
|
34
|
-
c: 0,
|
35
|
-
d: 1,
|
36
|
-
};
|
37
|
-
context.setTransform(defaultTransform.a, defaultTransform.b, defaultTransform.c, defaultTransform.d, currentPos.x, currentPos.y);
|
34
|
+
let lastPos = trail[trailLength - trailLengthOffset].position;
|
38
35
|
for (let i = trailLength; i > noItems; i--) {
|
39
|
-
const step =
|
36
|
+
const step = trail[i - trailLengthOffset], position = step.position, stepTransformData = particle.trailTransform ? step.transformData ?? defaultTransform : defaultTransform;
|
37
|
+
context.setTransform(stepTransformData.a, stepTransformData.b, stepTransformData.c, stepTransformData.d, position.x, position.y);
|
40
38
|
context.beginPath();
|
41
|
-
context.moveTo(lastPos.x -
|
39
|
+
context.moveTo(lastPos.x - position.x, lastPos.y - position.y);
|
42
40
|
const warp = {
|
43
41
|
x: (lastPos.x + canvasSize.width) % canvasSize.width,
|
44
42
|
y: (lastPos.y + canvasSize.height) % canvasSize.height,
|
@@ -48,7 +46,7 @@ export class TrailDrawer {
|
|
48
46
|
lastPos = position;
|
49
47
|
continue;
|
50
48
|
}
|
51
|
-
context.lineTo(
|
49
|
+
context.lineTo(Math.abs(lastPos.x - position.x) > canvasSize.width * half ? warp.x : origin.x, Math.abs(lastPos.y - position.y) > canvasSize.height * half ? warp.y : origin.y);
|
52
50
|
const width = Math.max((i / trailLength) * diameter, pxRatio, particle.trailMinWidth ?? minWidth), oldAlpha = context.globalAlpha;
|
53
51
|
context.globalAlpha = particle.trailFade ? i / trailLength : defaultAlpha;
|
54
52
|
context.lineWidth = particle.trailMaxWidth ? Math.min(width, particle.trailMaxWidth) : width;
|
@@ -57,7 +55,6 @@ export class TrailDrawer {
|
|
57
55
|
context.globalAlpha = oldAlpha;
|
58
56
|
lastPos = position;
|
59
57
|
}
|
60
|
-
const { transformData } = data;
|
61
58
|
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, currentPos.x, currentPos.y);
|
62
59
|
}
|
63
60
|
particleInit(container, particle) {
|
@@ -71,5 +68,6 @@ export class TrailDrawer {
|
|
71
68
|
particle.trailMinWidth = effectData?.minWidth
|
72
69
|
? getRangeValue(effectData.minWidth) * container.retina.pixelRatio
|
73
70
|
: undefined;
|
71
|
+
particle.trailTransform = effectData?.transform ?? false;
|
74
72
|
}
|
75
73
|
}
|
package/browser/index.js
CHANGED
package/cjs/TrailDrawer.js
CHANGED
@@ -2,46 +2,44 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.TrailDrawer = void 0;
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
5
|
-
const double = 2, minTrailLength = 2, trailLengthOffset = 1, noItems = 0, half = 0.5, minWidth = -1, defaultLength = 10, defaultAlpha = 1;
|
5
|
+
const double = 2, minTrailLength = 2, trailLengthOffset = 1, noItems = 0, half = 0.5, minWidth = -1, defaultLength = 10, defaultAlpha = 1, origin = { x: 0, y: 0 };
|
6
|
+
const defaultTransform = {
|
7
|
+
a: 1,
|
8
|
+
b: 0,
|
9
|
+
c: 0,
|
10
|
+
d: 1,
|
11
|
+
};
|
6
12
|
class TrailDrawer {
|
7
13
|
draw(data) {
|
8
|
-
const { context, radius, particle } = data, diameter = radius * double, pxRatio = particle.container.retina.pixelRatio, currentPos = particle.getPosition();
|
9
|
-
if (!
|
14
|
+
const { context, radius, particle, transformData } = data, diameter = radius * double, pxRatio = particle.container.retina.pixelRatio, currentPos = particle.getPosition(), trail = particle.trail;
|
15
|
+
if (!trail || !particle.trailLength) {
|
10
16
|
return;
|
11
17
|
}
|
12
18
|
const pathLength = particle.trailLength + radius;
|
13
|
-
|
19
|
+
trail.push({
|
14
20
|
color: context.fillStyle ?? context.strokeStyle,
|
15
21
|
position: {
|
16
22
|
x: currentPos.x,
|
17
23
|
y: currentPos.y,
|
18
24
|
},
|
25
|
+
transformData: { ...data.transformData },
|
19
26
|
});
|
20
|
-
if (
|
27
|
+
if (trail.length < minTrailLength) {
|
21
28
|
return;
|
22
29
|
}
|
23
|
-
while (
|
24
|
-
|
30
|
+
while (trail.length > pathLength) {
|
31
|
+
trail.shift();
|
25
32
|
}
|
26
|
-
const trailLength = Math.min(
|
27
|
-
x: currentPos.x,
|
28
|
-
y: currentPos.y,
|
29
|
-
}, canvasSize = {
|
33
|
+
const trailLength = Math.min(trail.length, pathLength), canvasSize = {
|
30
34
|
width: particle.container.canvas.size.width + diameter,
|
31
35
|
height: particle.container.canvas.size.height + diameter,
|
32
36
|
};
|
33
|
-
let lastPos =
|
34
|
-
const defaultTransform = {
|
35
|
-
a: 1,
|
36
|
-
b: 0,
|
37
|
-
c: 0,
|
38
|
-
d: 1,
|
39
|
-
};
|
40
|
-
context.setTransform(defaultTransform.a, defaultTransform.b, defaultTransform.c, defaultTransform.d, currentPos.x, currentPos.y);
|
37
|
+
let lastPos = trail[trailLength - trailLengthOffset].position;
|
41
38
|
for (let i = trailLength; i > noItems; i--) {
|
42
|
-
const step =
|
39
|
+
const step = trail[i - trailLengthOffset], position = step.position, stepTransformData = particle.trailTransform ? step.transformData ?? defaultTransform : defaultTransform;
|
40
|
+
context.setTransform(stepTransformData.a, stepTransformData.b, stepTransformData.c, stepTransformData.d, position.x, position.y);
|
43
41
|
context.beginPath();
|
44
|
-
context.moveTo(lastPos.x -
|
42
|
+
context.moveTo(lastPos.x - position.x, lastPos.y - position.y);
|
45
43
|
const warp = {
|
46
44
|
x: (lastPos.x + canvasSize.width) % canvasSize.width,
|
47
45
|
y: (lastPos.y + canvasSize.height) % canvasSize.height,
|
@@ -51,7 +49,7 @@ class TrailDrawer {
|
|
51
49
|
lastPos = position;
|
52
50
|
continue;
|
53
51
|
}
|
54
|
-
context.lineTo(
|
52
|
+
context.lineTo(Math.abs(lastPos.x - position.x) > canvasSize.width * half ? warp.x : origin.x, Math.abs(lastPos.y - position.y) > canvasSize.height * half ? warp.y : origin.y);
|
55
53
|
const width = Math.max((i / trailLength) * diameter, pxRatio, particle.trailMinWidth ?? minWidth), oldAlpha = context.globalAlpha;
|
56
54
|
context.globalAlpha = particle.trailFade ? i / trailLength : defaultAlpha;
|
57
55
|
context.lineWidth = particle.trailMaxWidth ? Math.min(width, particle.trailMaxWidth) : width;
|
@@ -60,7 +58,6 @@ class TrailDrawer {
|
|
60
58
|
context.globalAlpha = oldAlpha;
|
61
59
|
lastPos = position;
|
62
60
|
}
|
63
|
-
const { transformData } = data;
|
64
61
|
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, currentPos.x, currentPos.y);
|
65
62
|
}
|
66
63
|
particleInit(container, particle) {
|
@@ -74,6 +71,7 @@ class TrailDrawer {
|
|
74
71
|
particle.trailMinWidth = effectData?.minWidth
|
75
72
|
? (0, engine_1.getRangeValue)(effectData.minWidth) * container.retina.pixelRatio
|
76
73
|
: undefined;
|
74
|
+
particle.trailTransform = effectData?.transform ?? false;
|
77
75
|
}
|
78
76
|
}
|
79
77
|
exports.TrailDrawer = TrailDrawer;
|
package/cjs/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.loadTrailEffect = void 0;
|
4
|
+
const TrailDrawer_js_1 = require("./TrailDrawer.js");
|
4
5
|
async function loadTrailEffect(engine, refresh = true) {
|
5
|
-
|
6
|
-
await engine.addEffect("trail", new TrailDrawer(), refresh);
|
6
|
+
await engine.addEffect("trail", new TrailDrawer_js_1.TrailDrawer(), refresh);
|
7
7
|
}
|
8
8
|
exports.loadTrailEffect = loadTrailEffect;
|
package/esm/TrailDrawer.js
CHANGED
@@ -1,44 +1,42 @@
|
|
1
1
|
import { getRangeValue, } from "@tsparticles/engine";
|
2
|
-
const double = 2, minTrailLength = 2, trailLengthOffset = 1, noItems = 0, half = 0.5, minWidth = -1, defaultLength = 10, defaultAlpha = 1;
|
2
|
+
const double = 2, minTrailLength = 2, trailLengthOffset = 1, noItems = 0, half = 0.5, minWidth = -1, defaultLength = 10, defaultAlpha = 1, origin = { x: 0, y: 0 };
|
3
|
+
const defaultTransform = {
|
4
|
+
a: 1,
|
5
|
+
b: 0,
|
6
|
+
c: 0,
|
7
|
+
d: 1,
|
8
|
+
};
|
3
9
|
export class TrailDrawer {
|
4
10
|
draw(data) {
|
5
|
-
const { context, radius, particle } = data, diameter = radius * double, pxRatio = particle.container.retina.pixelRatio, currentPos = particle.getPosition();
|
6
|
-
if (!
|
11
|
+
const { context, radius, particle, transformData } = data, diameter = radius * double, pxRatio = particle.container.retina.pixelRatio, currentPos = particle.getPosition(), trail = particle.trail;
|
12
|
+
if (!trail || !particle.trailLength) {
|
7
13
|
return;
|
8
14
|
}
|
9
15
|
const pathLength = particle.trailLength + radius;
|
10
|
-
|
16
|
+
trail.push({
|
11
17
|
color: context.fillStyle ?? context.strokeStyle,
|
12
18
|
position: {
|
13
19
|
x: currentPos.x,
|
14
20
|
y: currentPos.y,
|
15
21
|
},
|
22
|
+
transformData: { ...data.transformData },
|
16
23
|
});
|
17
|
-
if (
|
24
|
+
if (trail.length < minTrailLength) {
|
18
25
|
return;
|
19
26
|
}
|
20
|
-
while (
|
21
|
-
|
27
|
+
while (trail.length > pathLength) {
|
28
|
+
trail.shift();
|
22
29
|
}
|
23
|
-
const trailLength = Math.min(
|
24
|
-
x: currentPos.x,
|
25
|
-
y: currentPos.y,
|
26
|
-
}, canvasSize = {
|
30
|
+
const trailLength = Math.min(trail.length, pathLength), canvasSize = {
|
27
31
|
width: particle.container.canvas.size.width + diameter,
|
28
32
|
height: particle.container.canvas.size.height + diameter,
|
29
33
|
};
|
30
|
-
let lastPos =
|
31
|
-
const defaultTransform = {
|
32
|
-
a: 1,
|
33
|
-
b: 0,
|
34
|
-
c: 0,
|
35
|
-
d: 1,
|
36
|
-
};
|
37
|
-
context.setTransform(defaultTransform.a, defaultTransform.b, defaultTransform.c, defaultTransform.d, currentPos.x, currentPos.y);
|
34
|
+
let lastPos = trail[trailLength - trailLengthOffset].position;
|
38
35
|
for (let i = trailLength; i > noItems; i--) {
|
39
|
-
const step =
|
36
|
+
const step = trail[i - trailLengthOffset], position = step.position, stepTransformData = particle.trailTransform ? step.transformData ?? defaultTransform : defaultTransform;
|
37
|
+
context.setTransform(stepTransformData.a, stepTransformData.b, stepTransformData.c, stepTransformData.d, position.x, position.y);
|
40
38
|
context.beginPath();
|
41
|
-
context.moveTo(lastPos.x -
|
39
|
+
context.moveTo(lastPos.x - position.x, lastPos.y - position.y);
|
42
40
|
const warp = {
|
43
41
|
x: (lastPos.x + canvasSize.width) % canvasSize.width,
|
44
42
|
y: (lastPos.y + canvasSize.height) % canvasSize.height,
|
@@ -48,7 +46,7 @@ export class TrailDrawer {
|
|
48
46
|
lastPos = position;
|
49
47
|
continue;
|
50
48
|
}
|
51
|
-
context.lineTo(
|
49
|
+
context.lineTo(Math.abs(lastPos.x - position.x) > canvasSize.width * half ? warp.x : origin.x, Math.abs(lastPos.y - position.y) > canvasSize.height * half ? warp.y : origin.y);
|
52
50
|
const width = Math.max((i / trailLength) * diameter, pxRatio, particle.trailMinWidth ?? minWidth), oldAlpha = context.globalAlpha;
|
53
51
|
context.globalAlpha = particle.trailFade ? i / trailLength : defaultAlpha;
|
54
52
|
context.lineWidth = particle.trailMaxWidth ? Math.min(width, particle.trailMaxWidth) : width;
|
@@ -57,7 +55,6 @@ export class TrailDrawer {
|
|
57
55
|
context.globalAlpha = oldAlpha;
|
58
56
|
lastPos = position;
|
59
57
|
}
|
60
|
-
const { transformData } = data;
|
61
58
|
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, currentPos.x, currentPos.y);
|
62
59
|
}
|
63
60
|
particleInit(container, particle) {
|
@@ -71,5 +68,6 @@ export class TrailDrawer {
|
|
71
68
|
particle.trailMinWidth = effectData?.minWidth
|
72
69
|
? getRangeValue(effectData.minWidth) * container.retina.pixelRatio
|
73
70
|
: undefined;
|
71
|
+
particle.trailTransform = effectData?.transform ?? false;
|
74
72
|
}
|
75
73
|
}
|
package/esm/index.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tsparticles/effect-trail",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.4.0",
|
4
4
|
"description": "tsParticles trail effect",
|
5
5
|
"homepage": "https://particles.js.org",
|
6
6
|
"repository": {
|
@@ -100,7 +100,7 @@
|
|
100
100
|
"./package.json": "./package.json"
|
101
101
|
},
|
102
102
|
"dependencies": {
|
103
|
-
"@tsparticles/engine": "^3.
|
103
|
+
"@tsparticles/engine": "^3.4.0"
|
104
104
|
},
|
105
105
|
"publishConfig": {
|
106
106
|
"access": "public"
|
package/report.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="UTF-8"/>
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
6
|
-
<title>@tsparticles/effect-trail [
|
6
|
+
<title>@tsparticles/effect-trail [13 May 2024 at 00:06]</title>
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
8
8
|
|
9
9
|
<script>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
6
6
|
* How to use? : Check the GitHub README
|
7
|
-
* v3.
|
7
|
+
* v3.4.0
|
8
8
|
*/
|
9
9
|
/*
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
@@ -28,13 +28,23 @@ return /******/ (() => { // webpackBootstrap
|
|
28
28
|
/******/ "use strict";
|
29
29
|
/******/ var __webpack_modules__ = ({
|
30
30
|
|
31
|
+
/***/ "./dist/browser/TrailDrawer.js":
|
32
|
+
/*!*************************************!*\
|
33
|
+
!*** ./dist/browser/TrailDrawer.js ***!
|
34
|
+
\*************************************/
|
35
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
36
|
+
|
37
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TrailDrawer: () => (/* binding */ TrailDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst double = 2,\n minTrailLength = 2,\n trailLengthOffset = 1,\n noItems = 0,\n half = 0.5,\n minWidth = -1,\n defaultLength = 10,\n defaultAlpha = 1,\n origin = {\n x: 0,\n y: 0\n };\nconst defaultTransform = {\n a: 1,\n b: 0,\n c: 0,\n d: 1\n};\nclass TrailDrawer {\n draw(data) {\n const {\n context,\n radius,\n particle,\n transformData\n } = data,\n diameter = radius * double,\n pxRatio = particle.container.retina.pixelRatio,\n currentPos = particle.getPosition(),\n trail = particle.trail;\n if (!trail || !particle.trailLength) {\n return;\n }\n const pathLength = particle.trailLength + radius;\n trail.push({\n color: context.fillStyle ?? context.strokeStyle,\n position: {\n x: currentPos.x,\n y: currentPos.y\n },\n transformData: {\n ...data.transformData\n }\n });\n if (trail.length < minTrailLength) {\n return;\n }\n while (trail.length > pathLength) {\n trail.shift();\n }\n const trailLength = Math.min(trail.length, pathLength),\n canvasSize = {\n width: particle.container.canvas.size.width + diameter,\n height: particle.container.canvas.size.height + diameter\n };\n let lastPos = trail[trailLength - trailLengthOffset].position;\n for (let i = trailLength; i > noItems; i--) {\n const step = trail[i - trailLengthOffset],\n position = step.position,\n stepTransformData = particle.trailTransform ? step.transformData ?? defaultTransform : defaultTransform;\n context.setTransform(stepTransformData.a, stepTransformData.b, stepTransformData.c, stepTransformData.d, position.x, position.y);\n context.beginPath();\n context.moveTo(lastPos.x - position.x, lastPos.y - position.y);\n const warp = {\n x: (lastPos.x + canvasSize.width) % canvasSize.width,\n y: (lastPos.y + canvasSize.height) % canvasSize.height\n };\n if (Math.abs(lastPos.x - position.x) > canvasSize.width * half || Math.abs(lastPos.y - position.y) > canvasSize.height * half) {\n lastPos = position;\n continue;\n }\n context.lineTo(Math.abs(lastPos.x - position.x) > canvasSize.width * half ? warp.x : origin.x, Math.abs(lastPos.y - position.y) > canvasSize.height * half ? warp.y : origin.y);\n const width = Math.max(i / trailLength * diameter, pxRatio, particle.trailMinWidth ?? minWidth),\n oldAlpha = context.globalAlpha;\n context.globalAlpha = particle.trailFade ? i / trailLength : defaultAlpha;\n context.lineWidth = particle.trailMaxWidth ? Math.min(width, particle.trailMaxWidth) : width;\n context.strokeStyle = step.color;\n context.stroke();\n context.globalAlpha = oldAlpha;\n lastPos = position;\n }\n context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, currentPos.x, currentPos.y);\n }\n particleInit(container, particle) {\n particle.trail = [];\n const effectData = particle.effectData;\n particle.trailFade = effectData?.fade ?? true;\n particle.trailLength = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(effectData?.length ?? defaultLength) * container.retina.pixelRatio;\n particle.trailMaxWidth = effectData?.maxWidth ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(effectData.maxWidth) * container.retina.pixelRatio : undefined;\n particle.trailMinWidth = effectData?.minWidth ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(effectData.minWidth) * container.retina.pixelRatio : undefined;\n particle.trailTransform = effectData?.transform ?? false;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/effect-trail/./dist/browser/TrailDrawer.js?");
|
38
|
+
|
39
|
+
/***/ }),
|
40
|
+
|
31
41
|
/***/ "./dist/browser/index.js":
|
32
42
|
/*!*******************************!*\
|
33
43
|
!*** ./dist/browser/index.js ***!
|
34
44
|
\*******************************/
|
35
45
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
36
46
|
|
37
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTrailEffect: () => (/* binding */ loadTrailEffect)\n/* harmony export */ });\
|
47
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTrailEffect: () => (/* binding */ loadTrailEffect)\n/* harmony export */ });\n/* harmony import */ var _TrailDrawer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TrailDrawer.js */ \"./dist/browser/TrailDrawer.js\");\n\nasync function loadTrailEffect(engine, refresh = true) {\n await engine.addEffect(\"trail\", new _TrailDrawer_js__WEBPACK_IMPORTED_MODULE_0__.TrailDrawer(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/effect-trail/./dist/browser/index.js?");
|
38
48
|
|
39
49
|
/***/ }),
|
40
50
|
|
@@ -74,9 +84,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
74
84
|
/******/ return module.exports;
|
75
85
|
/******/ }
|
76
86
|
/******/
|
77
|
-
/******/ // expose the modules object (__webpack_modules__)
|
78
|
-
/******/ __webpack_require__.m = __webpack_modules__;
|
79
|
-
/******/
|
80
87
|
/************************************************************************/
|
81
88
|
/******/ /* webpack/runtime/compat get default export */
|
82
89
|
/******/ (() => {
|
@@ -102,91 +109,11 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
102
109
|
/******/ };
|
103
110
|
/******/ })();
|
104
111
|
/******/
|
105
|
-
/******/ /* webpack/runtime/ensure chunk */
|
106
|
-
/******/ (() => {
|
107
|
-
/******/ __webpack_require__.f = {};
|
108
|
-
/******/ // This file contains only the entry chunk.
|
109
|
-
/******/ // The chunk loading function for additional chunks
|
110
|
-
/******/ __webpack_require__.e = (chunkId) => {
|
111
|
-
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
|
112
|
-
/******/ __webpack_require__.f[key](chunkId, promises);
|
113
|
-
/******/ return promises;
|
114
|
-
/******/ }, []));
|
115
|
-
/******/ };
|
116
|
-
/******/ })();
|
117
|
-
/******/
|
118
|
-
/******/ /* webpack/runtime/get javascript chunk filename */
|
119
|
-
/******/ (() => {
|
120
|
-
/******/ // This function allow to reference async chunks
|
121
|
-
/******/ __webpack_require__.u = (chunkId) => {
|
122
|
-
/******/ // return url for filenames based on template
|
123
|
-
/******/ return "" + chunkId + ".js";
|
124
|
-
/******/ };
|
125
|
-
/******/ })();
|
126
|
-
/******/
|
127
|
-
/******/ /* webpack/runtime/global */
|
128
|
-
/******/ (() => {
|
129
|
-
/******/ __webpack_require__.g = (function() {
|
130
|
-
/******/ if (typeof globalThis === 'object') return globalThis;
|
131
|
-
/******/ try {
|
132
|
-
/******/ return this || new Function('return this')();
|
133
|
-
/******/ } catch (e) {
|
134
|
-
/******/ if (typeof window === 'object') return window;
|
135
|
-
/******/ }
|
136
|
-
/******/ })();
|
137
|
-
/******/ })();
|
138
|
-
/******/
|
139
112
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
140
113
|
/******/ (() => {
|
141
114
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
142
115
|
/******/ })();
|
143
116
|
/******/
|
144
|
-
/******/ /* webpack/runtime/load script */
|
145
|
-
/******/ (() => {
|
146
|
-
/******/ var inProgress = {};
|
147
|
-
/******/ var dataWebpackPrefix = "@tsparticles/effect-trail:";
|
148
|
-
/******/ // loadScript function to load a script via script tag
|
149
|
-
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
|
150
|
-
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
|
151
|
-
/******/ var script, needAttach;
|
152
|
-
/******/ if(key !== undefined) {
|
153
|
-
/******/ var scripts = document.getElementsByTagName("script");
|
154
|
-
/******/ for(var i = 0; i < scripts.length; i++) {
|
155
|
-
/******/ var s = scripts[i];
|
156
|
-
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
|
157
|
-
/******/ }
|
158
|
-
/******/ }
|
159
|
-
/******/ if(!script) {
|
160
|
-
/******/ needAttach = true;
|
161
|
-
/******/ script = document.createElement('script');
|
162
|
-
/******/
|
163
|
-
/******/ script.charset = 'utf-8';
|
164
|
-
/******/ script.timeout = 120;
|
165
|
-
/******/ if (__webpack_require__.nc) {
|
166
|
-
/******/ script.setAttribute("nonce", __webpack_require__.nc);
|
167
|
-
/******/ }
|
168
|
-
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
|
169
|
-
/******/
|
170
|
-
/******/ script.src = url;
|
171
|
-
/******/ }
|
172
|
-
/******/ inProgress[url] = [done];
|
173
|
-
/******/ var onScriptComplete = (prev, event) => {
|
174
|
-
/******/ // avoid mem leaks in IE.
|
175
|
-
/******/ script.onerror = script.onload = null;
|
176
|
-
/******/ clearTimeout(timeout);
|
177
|
-
/******/ var doneFns = inProgress[url];
|
178
|
-
/******/ delete inProgress[url];
|
179
|
-
/******/ script.parentNode && script.parentNode.removeChild(script);
|
180
|
-
/******/ doneFns && doneFns.forEach((fn) => (fn(event)));
|
181
|
-
/******/ if(prev) return prev(event);
|
182
|
-
/******/ }
|
183
|
-
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
|
184
|
-
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
|
185
|
-
/******/ script.onload = onScriptComplete.bind(null, script.onload);
|
186
|
-
/******/ needAttach && document.head.appendChild(script);
|
187
|
-
/******/ };
|
188
|
-
/******/ })();
|
189
|
-
/******/
|
190
117
|
/******/ /* webpack/runtime/make namespace object */
|
191
118
|
/******/ (() => {
|
192
119
|
/******/ // define __esModule on exports
|
@@ -198,121 +125,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
198
125
|
/******/ };
|
199
126
|
/******/ })();
|
200
127
|
/******/
|
201
|
-
/******/ /* webpack/runtime/publicPath */
|
202
|
-
/******/ (() => {
|
203
|
-
/******/ var scriptUrl;
|
204
|
-
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
205
|
-
/******/ var document = __webpack_require__.g.document;
|
206
|
-
/******/ if (!scriptUrl && document) {
|
207
|
-
/******/ if (document.currentScript)
|
208
|
-
/******/ scriptUrl = document.currentScript.src;
|
209
|
-
/******/ if (!scriptUrl) {
|
210
|
-
/******/ var scripts = document.getElementsByTagName("script");
|
211
|
-
/******/ if(scripts.length) {
|
212
|
-
/******/ var i = scripts.length - 1;
|
213
|
-
/******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
|
214
|
-
/******/ }
|
215
|
-
/******/ }
|
216
|
-
/******/ }
|
217
|
-
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
218
|
-
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
219
|
-
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
220
|
-
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
221
|
-
/******/ __webpack_require__.p = scriptUrl;
|
222
|
-
/******/ })();
|
223
|
-
/******/
|
224
|
-
/******/ /* webpack/runtime/jsonp chunk loading */
|
225
|
-
/******/ (() => {
|
226
|
-
/******/ // no baseURI
|
227
|
-
/******/
|
228
|
-
/******/ // object to store loaded and loading chunks
|
229
|
-
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
230
|
-
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
231
|
-
/******/ var installedChunks = {
|
232
|
-
/******/ "tsparticles.effect.trail": 0
|
233
|
-
/******/ };
|
234
|
-
/******/
|
235
|
-
/******/ __webpack_require__.f.j = (chunkId, promises) => {
|
236
|
-
/******/ // JSONP chunk loading for javascript
|
237
|
-
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
|
238
|
-
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
|
239
|
-
/******/
|
240
|
-
/******/ // a Promise means "currently loading".
|
241
|
-
/******/ if(installedChunkData) {
|
242
|
-
/******/ promises.push(installedChunkData[2]);
|
243
|
-
/******/ } else {
|
244
|
-
/******/ if(true) { // all chunks have JS
|
245
|
-
/******/ // setup Promise in chunk cache
|
246
|
-
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
|
247
|
-
/******/ promises.push(installedChunkData[2] = promise);
|
248
|
-
/******/
|
249
|
-
/******/ // start chunk loading
|
250
|
-
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
|
251
|
-
/******/ // create error before stack unwound to get useful stacktrace later
|
252
|
-
/******/ var error = new Error();
|
253
|
-
/******/ var loadingEnded = (event) => {
|
254
|
-
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
|
255
|
-
/******/ installedChunkData = installedChunks[chunkId];
|
256
|
-
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
|
257
|
-
/******/ if(installedChunkData) {
|
258
|
-
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
259
|
-
/******/ var realSrc = event && event.target && event.target.src;
|
260
|
-
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
|
261
|
-
/******/ error.name = 'ChunkLoadError';
|
262
|
-
/******/ error.type = errorType;
|
263
|
-
/******/ error.request = realSrc;
|
264
|
-
/******/ installedChunkData[1](error);
|
265
|
-
/******/ }
|
266
|
-
/******/ }
|
267
|
-
/******/ };
|
268
|
-
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
|
269
|
-
/******/ }
|
270
|
-
/******/ }
|
271
|
-
/******/ }
|
272
|
-
/******/ };
|
273
|
-
/******/
|
274
|
-
/******/ // no prefetching
|
275
|
-
/******/
|
276
|
-
/******/ // no preloaded
|
277
|
-
/******/
|
278
|
-
/******/ // no HMR
|
279
|
-
/******/
|
280
|
-
/******/ // no HMR manifest
|
281
|
-
/******/
|
282
|
-
/******/ // no on chunks loaded
|
283
|
-
/******/
|
284
|
-
/******/ // install a JSONP callback for chunk loading
|
285
|
-
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
286
|
-
/******/ var chunkIds = data[0];
|
287
|
-
/******/ var moreModules = data[1];
|
288
|
-
/******/ var runtime = data[2];
|
289
|
-
/******/ // add "moreModules" to the modules object,
|
290
|
-
/******/ // then flag all "chunkIds" as loaded and fire callback
|
291
|
-
/******/ var moduleId, chunkId, i = 0;
|
292
|
-
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
293
|
-
/******/ for(moduleId in moreModules) {
|
294
|
-
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
295
|
-
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
296
|
-
/******/ }
|
297
|
-
/******/ }
|
298
|
-
/******/ if(runtime) var result = runtime(__webpack_require__);
|
299
|
-
/******/ }
|
300
|
-
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
301
|
-
/******/ for(;i < chunkIds.length; i++) {
|
302
|
-
/******/ chunkId = chunkIds[i];
|
303
|
-
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
304
|
-
/******/ installedChunks[chunkId][0]();
|
305
|
-
/******/ }
|
306
|
-
/******/ installedChunks[chunkId] = 0;
|
307
|
-
/******/ }
|
308
|
-
/******/
|
309
|
-
/******/ }
|
310
|
-
/******/
|
311
|
-
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_effect_trail"] = this["webpackChunk_tsparticles_effect_trail"] || [];
|
312
|
-
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
313
|
-
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
314
|
-
/******/ })();
|
315
|
-
/******/
|
316
128
|
/************************************************************************/
|
317
129
|
/******/
|
318
130
|
/******/ // startup
|
@@ -1,2 +1,2 @@
|
|
1
1
|
/*! For license information please see tsparticles.effect.trail.min.js.LICENSE.txt */
|
2
|
-
!function(e
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var a="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in a)("object"==typeof exports?exports:t)[i]=a[i]}}(this,(t=>(()=>{var e={303:e=>{e.exports=t}},a={};function i(t){var r=a[t];if(void 0!==r)return r.exports;var o=a[t]={exports:{}};return e[t](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var a in e)i.o(e,a)&&!i.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{i.r(r),i.d(r,{loadTrailEffect:()=>s});var t=i(303);const e=.5,a=0,o=0,n={a:1,b:0,c:0,d:1};class l{draw(t){const{context:i,radius:r,particle:l,transformData:s}=t,f=2*r,c=l.container.retina.pixelRatio,d=l.getPosition(),p=l.trail;if(!p||!l.trailLength)return;const h=l.trailLength+r;if(p.push({color:i.fillStyle??i.strokeStyle,position:{x:d.x,y:d.y},transformData:{...t.transformData}}),p.length<2)return;for(;p.length>h;)p.shift();const x=Math.min(p.length,h),y=l.container.canvas.size.width+f,g=l.container.canvas.size.height+f;let u=p[x-1].position;for(let t=x;t>0;t--){const r=p[t-1],s=r.position,d=l.trailTransform?r.transformData??n:n;i.setTransform(d.a,d.b,d.c,d.d,s.x,s.y),i.beginPath(),i.moveTo(u.x-s.x,u.y-s.y);const h={x:(u.x+y)%y,y:(u.y+g)%g};if(Math.abs(u.x-s.x)>y*e||Math.abs(u.y-s.y)>g*e){u=s;continue}i.lineTo(Math.abs(u.x-s.x)>y*e?h.x:a,Math.abs(u.y-s.y)>g*e?h.y:o);const m=Math.max(t/x*f,c,l.trailMinWidth??-1),b=i.globalAlpha;i.globalAlpha=l.trailFade?t/x:1,i.lineWidth=l.trailMaxWidth?Math.min(m,l.trailMaxWidth):m,i.strokeStyle=r.color,i.stroke(),i.globalAlpha=b,u=s}i.setTransform(s.a,s.b,s.c,s.d,d.x,d.y)}particleInit(e,a){a.trail=[];const i=a.effectData;a.trailFade=i?.fade??!0,a.trailLength=(0,t.getRangeValue)(i?.length??10)*e.retina.pixelRatio,a.trailMaxWidth=i?.maxWidth?(0,t.getRangeValue)(i.maxWidth)*e.retina.pixelRatio:void 0,a.trailMinWidth=i?.minWidth?(0,t.getRangeValue)(i.minWidth)*e.retina.pixelRatio:void 0,a.trailTransform=i?.transform??!1}}async function s(t,e=!0){await t.addEffect("trail",new l,e)}})(),r})()));
|
@@ -1 +1 @@
|
|
1
|
-
/*! tsParticles Trail Shape v3.
|
1
|
+
/*! tsParticles Trail Shape v3.4.0 by Matteo Bruni */
|
package/types/TrailDrawer.d.ts
CHANGED
@@ -2,6 +2,12 @@ import { type Container, type ICoordinates, type IEffectDrawer, type IShapeDrawD
|
|
2
2
|
interface TrailStep {
|
3
3
|
color: string | CanvasGradient | CanvasPattern;
|
4
4
|
position: ICoordinates;
|
5
|
+
transformData?: {
|
6
|
+
a: number;
|
7
|
+
b: number;
|
8
|
+
c: number;
|
9
|
+
d: number;
|
10
|
+
};
|
5
11
|
}
|
6
12
|
type TrailParticle = Particle & {
|
7
13
|
trail?: TrailStep[];
|
@@ -9,6 +15,7 @@ type TrailParticle = Particle & {
|
|
9
15
|
trailLength?: number;
|
10
16
|
trailMaxWidth?: number;
|
11
17
|
trailMinWidth?: number;
|
18
|
+
trailTransform?: boolean;
|
12
19
|
};
|
13
20
|
export declare class TrailDrawer implements IEffectDrawer<TrailParticle> {
|
14
21
|
draw(data: IShapeDrawData<TrailParticle>): void;
|
package/umd/TrailDrawer.js
CHANGED
@@ -11,46 +11,44 @@
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.TrailDrawer = void 0;
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
14
|
-
const double = 2, minTrailLength = 2, trailLengthOffset = 1, noItems = 0, half = 0.5, minWidth = -1, defaultLength = 10, defaultAlpha = 1;
|
14
|
+
const double = 2, minTrailLength = 2, trailLengthOffset = 1, noItems = 0, half = 0.5, minWidth = -1, defaultLength = 10, defaultAlpha = 1, origin = { x: 0, y: 0 };
|
15
|
+
const defaultTransform = {
|
16
|
+
a: 1,
|
17
|
+
b: 0,
|
18
|
+
c: 0,
|
19
|
+
d: 1,
|
20
|
+
};
|
15
21
|
class TrailDrawer {
|
16
22
|
draw(data) {
|
17
|
-
const { context, radius, particle } = data, diameter = radius * double, pxRatio = particle.container.retina.pixelRatio, currentPos = particle.getPosition();
|
18
|
-
if (!
|
23
|
+
const { context, radius, particle, transformData } = data, diameter = radius * double, pxRatio = particle.container.retina.pixelRatio, currentPos = particle.getPosition(), trail = particle.trail;
|
24
|
+
if (!trail || !particle.trailLength) {
|
19
25
|
return;
|
20
26
|
}
|
21
27
|
const pathLength = particle.trailLength + radius;
|
22
|
-
|
28
|
+
trail.push({
|
23
29
|
color: context.fillStyle ?? context.strokeStyle,
|
24
30
|
position: {
|
25
31
|
x: currentPos.x,
|
26
32
|
y: currentPos.y,
|
27
33
|
},
|
34
|
+
transformData: { ...data.transformData },
|
28
35
|
});
|
29
|
-
if (
|
36
|
+
if (trail.length < minTrailLength) {
|
30
37
|
return;
|
31
38
|
}
|
32
|
-
while (
|
33
|
-
|
39
|
+
while (trail.length > pathLength) {
|
40
|
+
trail.shift();
|
34
41
|
}
|
35
|
-
const trailLength = Math.min(
|
36
|
-
x: currentPos.x,
|
37
|
-
y: currentPos.y,
|
38
|
-
}, canvasSize = {
|
42
|
+
const trailLength = Math.min(trail.length, pathLength), canvasSize = {
|
39
43
|
width: particle.container.canvas.size.width + diameter,
|
40
44
|
height: particle.container.canvas.size.height + diameter,
|
41
45
|
};
|
42
|
-
let lastPos =
|
43
|
-
const defaultTransform = {
|
44
|
-
a: 1,
|
45
|
-
b: 0,
|
46
|
-
c: 0,
|
47
|
-
d: 1,
|
48
|
-
};
|
49
|
-
context.setTransform(defaultTransform.a, defaultTransform.b, defaultTransform.c, defaultTransform.d, currentPos.x, currentPos.y);
|
46
|
+
let lastPos = trail[trailLength - trailLengthOffset].position;
|
50
47
|
for (let i = trailLength; i > noItems; i--) {
|
51
|
-
const step =
|
48
|
+
const step = trail[i - trailLengthOffset], position = step.position, stepTransformData = particle.trailTransform ? step.transformData ?? defaultTransform : defaultTransform;
|
49
|
+
context.setTransform(stepTransformData.a, stepTransformData.b, stepTransformData.c, stepTransformData.d, position.x, position.y);
|
52
50
|
context.beginPath();
|
53
|
-
context.moveTo(lastPos.x -
|
51
|
+
context.moveTo(lastPos.x - position.x, lastPos.y - position.y);
|
54
52
|
const warp = {
|
55
53
|
x: (lastPos.x + canvasSize.width) % canvasSize.width,
|
56
54
|
y: (lastPos.y + canvasSize.height) % canvasSize.height,
|
@@ -60,7 +58,7 @@
|
|
60
58
|
lastPos = position;
|
61
59
|
continue;
|
62
60
|
}
|
63
|
-
context.lineTo(
|
61
|
+
context.lineTo(Math.abs(lastPos.x - position.x) > canvasSize.width * half ? warp.x : origin.x, Math.abs(lastPos.y - position.y) > canvasSize.height * half ? warp.y : origin.y);
|
64
62
|
const width = Math.max((i / trailLength) * diameter, pxRatio, particle.trailMinWidth ?? minWidth), oldAlpha = context.globalAlpha;
|
65
63
|
context.globalAlpha = particle.trailFade ? i / trailLength : defaultAlpha;
|
66
64
|
context.lineWidth = particle.trailMaxWidth ? Math.min(width, particle.trailMaxWidth) : width;
|
@@ -69,7 +67,6 @@
|
|
69
67
|
context.globalAlpha = oldAlpha;
|
70
68
|
lastPos = position;
|
71
69
|
}
|
72
|
-
const { transformData } = data;
|
73
70
|
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, currentPos.x, currentPos.y);
|
74
71
|
}
|
75
72
|
particleInit(container, particle) {
|
@@ -83,6 +80,7 @@
|
|
83
80
|
particle.trailMinWidth = effectData?.minWidth
|
84
81
|
? (0, engine_1.getRangeValue)(effectData.minWidth) * container.retina.pixelRatio
|
85
82
|
: undefined;
|
83
|
+
particle.trailTransform = effectData?.transform ?? false;
|
86
84
|
}
|
87
85
|
}
|
88
86
|
exports.TrailDrawer = TrailDrawer;
|
package/umd/index.js
CHANGED
@@ -1,42 +1,18 @@
|
|
1
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
2
|
-
if (k2 === undefined) k2 = k;
|
3
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
4
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
5
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
6
|
-
}
|
7
|
-
Object.defineProperty(o, k2, desc);
|
8
|
-
}) : (function(o, m, k, k2) {
|
9
|
-
if (k2 === undefined) k2 = k;
|
10
|
-
o[k2] = m[k];
|
11
|
-
}));
|
12
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
13
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
14
|
-
}) : function(o, v) {
|
15
|
-
o["default"] = v;
|
16
|
-
});
|
17
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
18
|
-
if (mod && mod.__esModule) return mod;
|
19
|
-
var result = {};
|
20
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
21
|
-
__setModuleDefault(result, mod);
|
22
|
-
return result;
|
23
|
-
};
|
24
1
|
(function (factory) {
|
25
2
|
if (typeof module === "object" && typeof module.exports === "object") {
|
26
3
|
var v = factory(require, exports);
|
27
4
|
if (v !== undefined) module.exports = v;
|
28
5
|
}
|
29
6
|
else if (typeof define === "function" && define.amd) {
|
30
|
-
define(["require", "exports"], factory);
|
7
|
+
define(["require", "exports", "./TrailDrawer.js"], factory);
|
31
8
|
}
|
32
9
|
})(function (require, exports) {
|
33
10
|
"use strict";
|
34
|
-
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
35
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
36
12
|
exports.loadTrailEffect = void 0;
|
13
|
+
const TrailDrawer_js_1 = require("./TrailDrawer.js");
|
37
14
|
async function loadTrailEffect(engine, refresh = true) {
|
38
|
-
|
39
|
-
await engine.addEffect("trail", new TrailDrawer(), refresh);
|
15
|
+
await engine.addEffect("trail", new TrailDrawer_js_1.TrailDrawer(), refresh);
|
40
16
|
}
|
41
17
|
exports.loadTrailEffect = loadTrailEffect;
|
42
18
|
});
|
package/892.min.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
/*! For license information please see 892.min.js.LICENSE.txt */
|
2
|
-
(this.webpackChunk_tsparticles_effect_trail=this.webpackChunk_tsparticles_effect_trail||[]).push([[892],{892:(t,a,i)=>{i.d(a,{TrailDrawer:()=>n});var e=i(303);const l=.5;class n{draw(t){const{context:a,radius:i,particle:e}=t,n=2*i,r=e.container.retina.pixelRatio,o=e.getPosition();if(!e.trail||!e.trailLength)return;const s=e.trailLength+i;if(e.trail.push({color:a.fillStyle??a.strokeStyle,position:{x:o.x,y:o.y}}),e.trail.length<2)return;for(;e.trail.length>s;)e.trail.shift();const h=Math.min(e.trail.length,s),c=o.x,x=o.y,d=e.container.canvas.size.width+n,g=e.container.canvas.size.height+n;let p=e.trail[h-1].position;const f=1,y=0,M=0,b=1;a.setTransform(f,y,M,b,o.x,o.y);for(let t=h;t>0;t--){const i=e.trail[t-1],o=i.position;a.beginPath(),a.moveTo(p.x-c,p.y-x);const s={x:(p.x+d)%d,y:(p.y+g)%g};if(Math.abs(p.x-o.x)>d*l||Math.abs(p.y-o.y)>g*l){p=o;continue}a.lineTo((Math.abs(p.x-o.x)>d*l?s.x:o.x)-c,(Math.abs(p.y-o.y)>g*l?s.y:o.y)-x);const f=Math.max(t/h*n,r,e.trailMinWidth??-1),y=a.globalAlpha;a.globalAlpha=e.trailFade?t/h:1,a.lineWidth=e.trailMaxWidth?Math.min(f,e.trailMaxWidth):f,a.strokeStyle=i.color,a.stroke(),a.globalAlpha=y,p=o}const{transformData:m}=t;a.setTransform(m.a,m.b,m.c,m.d,o.x,o.y)}particleInit(t,a){a.trail=[];const i=a.effectData;a.trailFade=i?.fade??!0,a.trailLength=(0,e.getRangeValue)(i?.length??10)*t.retina.pixelRatio,a.trailMaxWidth=i?.maxWidth?(0,e.getRangeValue)(i.maxWidth)*t.retina.pixelRatio:void 0,a.trailMinWidth=i?.minWidth?(0,e.getRangeValue)(i.minWidth)*t.retina.pixelRatio:void 0}}}}]);
|
package/892.min.js.LICENSE.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
/*! tsParticles Trail Shape v3.3.0 by Matteo Bruni */
|
@@ -1,30 +0,0 @@
|
|
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
|
-
* v3.3.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_effect_trail"] = this["webpackChunk_tsparticles_effect_trail"] || []).push([["dist_browser_TrailDrawer_js"],{
|
19
|
-
|
20
|
-
/***/ "./dist/browser/TrailDrawer.js":
|
21
|
-
/*!*************************************!*\
|
22
|
-
!*** ./dist/browser/TrailDrawer.js ***!
|
23
|
-
\*************************************/
|
24
|
-
/***/ ((__unused_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 */ TrailDrawer: () => (/* binding */ TrailDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst double = 2,\n minTrailLength = 2,\n trailLengthOffset = 1,\n noItems = 0,\n half = 0.5,\n minWidth = -1,\n defaultLength = 10,\n defaultAlpha = 1;\nclass TrailDrawer {\n draw(data) {\n const {\n context,\n radius,\n particle\n } = data,\n diameter = radius * double,\n pxRatio = particle.container.retina.pixelRatio,\n currentPos = particle.getPosition();\n if (!particle.trail || !particle.trailLength) {\n return;\n }\n const pathLength = particle.trailLength + radius;\n particle.trail.push({\n color: context.fillStyle ?? context.strokeStyle,\n position: {\n x: currentPos.x,\n y: currentPos.y\n }\n });\n if (particle.trail.length < minTrailLength) {\n return;\n }\n while (particle.trail.length > pathLength) {\n particle.trail.shift();\n }\n const trailLength = Math.min(particle.trail.length, pathLength),\n offsetPos = {\n x: currentPos.x,\n y: currentPos.y\n },\n canvasSize = {\n width: particle.container.canvas.size.width + diameter,\n height: particle.container.canvas.size.height + diameter\n };\n let lastPos = particle.trail[trailLength - trailLengthOffset].position;\n const defaultTransform = {\n a: 1,\n b: 0,\n c: 0,\n d: 1\n };\n context.setTransform(defaultTransform.a, defaultTransform.b, defaultTransform.c, defaultTransform.d, currentPos.x, currentPos.y);\n for (let i = trailLength; i > noItems; i--) {\n const step = particle.trail[i - trailLengthOffset],\n position = step.position;\n context.beginPath();\n context.moveTo(lastPos.x - offsetPos.x, lastPos.y - offsetPos.y);\n const warp = {\n x: (lastPos.x + canvasSize.width) % canvasSize.width,\n y: (lastPos.y + canvasSize.height) % canvasSize.height\n };\n if (Math.abs(lastPos.x - position.x) > canvasSize.width * half || Math.abs(lastPos.y - position.y) > canvasSize.height * half) {\n lastPos = position;\n continue;\n }\n context.lineTo((Math.abs(lastPos.x - position.x) > canvasSize.width * half ? warp.x : position.x) - offsetPos.x, (Math.abs(lastPos.y - position.y) > canvasSize.height * half ? warp.y : position.y) - offsetPos.y);\n const width = Math.max(i / trailLength * diameter, pxRatio, particle.trailMinWidth ?? minWidth),\n oldAlpha = context.globalAlpha;\n context.globalAlpha = particle.trailFade ? i / trailLength : defaultAlpha;\n context.lineWidth = particle.trailMaxWidth ? Math.min(width, particle.trailMaxWidth) : width;\n context.strokeStyle = step.color;\n context.stroke();\n context.globalAlpha = oldAlpha;\n lastPos = position;\n }\n const {\n transformData\n } = data;\n context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, currentPos.x, currentPos.y);\n }\n particleInit(container, particle) {\n particle.trail = [];\n const effectData = particle.effectData;\n particle.trailFade = effectData?.fade ?? true;\n particle.trailLength = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(effectData?.length ?? defaultLength) * container.retina.pixelRatio;\n particle.trailMaxWidth = effectData?.maxWidth ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(effectData.maxWidth) * container.retina.pixelRatio : undefined;\n particle.trailMinWidth = effectData?.minWidth ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(effectData.minWidth) * container.retina.pixelRatio : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/effect-trail/./dist/browser/TrailDrawer.js?");
|
27
|
-
|
28
|
-
/***/ })
|
29
|
-
|
30
|
-
}]);
|