tsparticles 2.7.0 → 2.8.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/package.json +11 -11
- package/report.html +2 -2
- package/tsparticles.bundle.js +90 -16
- package/tsparticles.bundle.min.js +1 -1
- package/tsparticles.bundle.min.js.LICENSE.txt +1 -1
- package/tsparticles.js +1 -1
- package/tsparticles.min.js.LICENSE.txt +1 -1
package/tsparticles.bundle.js
CHANGED
|
@@ -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
|
-
* v2.
|
|
7
|
+
* v2.8.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -187,6 +187,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
187
187
|
"mouseOutEvent": () => (/* reexport */ mouseOutEvent),
|
|
188
188
|
"mouseUpEvent": () => (/* reexport */ mouseUpEvent),
|
|
189
189
|
"paintBase": () => (/* reexport */ paintBase),
|
|
190
|
+
"paintImage": () => (/* reexport */ paintImage),
|
|
190
191
|
"parseAlpha": () => (/* reexport */ parseAlpha),
|
|
191
192
|
"randomInRange": () => (/* reexport */ randomInRange),
|
|
192
193
|
"rangeColorToHsl": () => (/* reexport */ rangeColorToHsl),
|
|
@@ -1049,6 +1050,14 @@ function paintBase(context, dimension, baseColor) {
|
|
|
1049
1050
|
context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)";
|
|
1050
1051
|
context.fillRect(0, 0, dimension.width, dimension.height);
|
|
1051
1052
|
}
|
|
1053
|
+
function paintImage(context, dimension, image, opacity) {
|
|
1054
|
+
if (!image) {
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
context.globalAlpha = opacity;
|
|
1058
|
+
context.drawImage(image, 0, 0, dimension.width, dimension.height);
|
|
1059
|
+
context.globalAlpha = 1;
|
|
1060
|
+
}
|
|
1052
1061
|
function clear(context, dimension) {
|
|
1053
1062
|
context.clearRect(0, 0, dimension.width, dimension.height);
|
|
1054
1063
|
}
|
|
@@ -1203,11 +1212,16 @@ class Canvas {
|
|
|
1203
1212
|
}
|
|
1204
1213
|
clear() {
|
|
1205
1214
|
const options = this.container.actualOptions,
|
|
1206
|
-
trail = options.particles.move.trail
|
|
1215
|
+
trail = options.particles.move.trail,
|
|
1216
|
+
trailFill = this._trailFill;
|
|
1207
1217
|
if (options.backgroundMask.enable) {
|
|
1208
1218
|
this.paint();
|
|
1209
|
-
} else if (trail.enable && trail.length > 0 &&
|
|
1210
|
-
|
|
1219
|
+
} else if (trail.enable && trail.length > 0 && trailFill) {
|
|
1220
|
+
if (trailFill.color) {
|
|
1221
|
+
this._paintBase(getStyleFromRgb(trailFill.color, trailFill.opacity));
|
|
1222
|
+
} else if (trailFill.image) {
|
|
1223
|
+
this._paintImage(trailFill.image, trailFill.opacity);
|
|
1224
|
+
}
|
|
1211
1225
|
} else {
|
|
1212
1226
|
this.draw(ctx => {
|
|
1213
1227
|
clear(ctx, this.size);
|
|
@@ -1298,12 +1312,16 @@ class Canvas {
|
|
|
1298
1312
|
drawPlugin(ctx, plugin, delta);
|
|
1299
1313
|
});
|
|
1300
1314
|
}
|
|
1301
|
-
init() {
|
|
1315
|
+
async init() {
|
|
1302
1316
|
var _a;
|
|
1303
1317
|
this.resize();
|
|
1304
1318
|
this._initStyle();
|
|
1305
1319
|
this._initCover();
|
|
1306
|
-
|
|
1320
|
+
try {
|
|
1321
|
+
await this._initTrail();
|
|
1322
|
+
} catch (e) {
|
|
1323
|
+
console.error(e);
|
|
1324
|
+
}
|
|
1307
1325
|
this.initBackground();
|
|
1308
1326
|
if (this.element) {
|
|
1309
1327
|
(_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.element, {
|
|
@@ -1512,14 +1530,40 @@ class Canvas {
|
|
|
1512
1530
|
element.style.setProperty(key, value, "important");
|
|
1513
1531
|
}
|
|
1514
1532
|
}
|
|
1515
|
-
_initTrail() {
|
|
1533
|
+
async _initTrail() {
|
|
1516
1534
|
const options = this.container.actualOptions,
|
|
1517
1535
|
trail = options.particles.move.trail,
|
|
1518
|
-
|
|
1519
|
-
if (
|
|
1536
|
+
trailFill = trail.fill;
|
|
1537
|
+
if (!trail.enable) {
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
if (trailFill.color) {
|
|
1541
|
+
const fillColor = rangeColorToRgb(trailFill.color);
|
|
1542
|
+
if (!fillColor) {
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1520
1545
|
const trail = options.particles.move.trail;
|
|
1521
|
-
this.
|
|
1522
|
-
|
|
1546
|
+
this._trailFill = {
|
|
1547
|
+
color: Object.assign({}, fillColor),
|
|
1548
|
+
opacity: 1 / trail.length
|
|
1549
|
+
};
|
|
1550
|
+
} else {
|
|
1551
|
+
await new Promise((resolve, reject) => {
|
|
1552
|
+
if (!trailFill.image) {
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
const img = document.createElement("img");
|
|
1556
|
+
img.addEventListener("load", () => {
|
|
1557
|
+
this._trailFill = {
|
|
1558
|
+
image: img,
|
|
1559
|
+
opacity: 1 / trail.length
|
|
1560
|
+
};
|
|
1561
|
+
resolve();
|
|
1562
|
+
});
|
|
1563
|
+
img.addEventListener("error", evt => {
|
|
1564
|
+
reject(evt.error);
|
|
1565
|
+
});
|
|
1566
|
+
img.src = trailFill.image;
|
|
1523
1567
|
});
|
|
1524
1568
|
}
|
|
1525
1569
|
}
|
|
@@ -1528,6 +1572,11 @@ class Canvas {
|
|
|
1528
1572
|
paintBase(ctx, this.size, baseColor);
|
|
1529
1573
|
});
|
|
1530
1574
|
}
|
|
1575
|
+
_paintImage(image, opacity) {
|
|
1576
|
+
this.draw(ctx => {
|
|
1577
|
+
paintImage(ctx, this.size, image, opacity);
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1531
1580
|
_repairStyle() {
|
|
1532
1581
|
var _a, _b;
|
|
1533
1582
|
const element = this.element;
|
|
@@ -2704,14 +2753,36 @@ class MovePath {
|
|
|
2704
2753
|
}
|
|
2705
2754
|
}
|
|
2706
2755
|
}
|
|
2756
|
+
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/MoveTrailFill.js
|
|
2757
|
+
|
|
2758
|
+
class MoveTrailFill {
|
|
2759
|
+
load(data) {
|
|
2760
|
+
if (!data) {
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
if (data.color !== undefined) {
|
|
2764
|
+
this.color = OptionsColor.create(this.color, data.color);
|
|
2765
|
+
}
|
|
2766
|
+
if (data.image !== undefined) {
|
|
2767
|
+
this.image = data.image;
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2707
2771
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Move/MoveTrail.js
|
|
2708
2772
|
|
|
2709
2773
|
class MoveTrail {
|
|
2710
2774
|
constructor() {
|
|
2711
2775
|
this.enable = false;
|
|
2712
2776
|
this.length = 10;
|
|
2713
|
-
this.
|
|
2714
|
-
|
|
2777
|
+
this.fill = new MoveTrailFill();
|
|
2778
|
+
}
|
|
2779
|
+
get fillColor() {
|
|
2780
|
+
return this.fill.color;
|
|
2781
|
+
}
|
|
2782
|
+
set fillColor(value) {
|
|
2783
|
+
this.fill.load({
|
|
2784
|
+
color: value
|
|
2785
|
+
});
|
|
2715
2786
|
}
|
|
2716
2787
|
load(data) {
|
|
2717
2788
|
if (!data) {
|
|
@@ -2720,7 +2791,11 @@ class MoveTrail {
|
|
|
2720
2791
|
if (data.enable !== undefined) {
|
|
2721
2792
|
this.enable = data.enable;
|
|
2722
2793
|
}
|
|
2723
|
-
|
|
2794
|
+
if (data.fill !== undefined || data.fillColor !== undefined) {
|
|
2795
|
+
this.fill.load(data.fill || {
|
|
2796
|
+
color: data.fillColor
|
|
2797
|
+
});
|
|
2798
|
+
}
|
|
2724
2799
|
if (data.length !== undefined) {
|
|
2725
2800
|
this.length = data.length;
|
|
2726
2801
|
}
|
|
@@ -4711,7 +4786,7 @@ class Container {
|
|
|
4711
4786
|
this.plugins.set(id, plugin);
|
|
4712
4787
|
}
|
|
4713
4788
|
this.retina.init();
|
|
4714
|
-
this.canvas.init();
|
|
4789
|
+
await this.canvas.init();
|
|
4715
4790
|
this.updateActualOptions();
|
|
4716
4791
|
this.canvas.initBackground();
|
|
4717
4792
|
this.canvas.resize();
|
|
@@ -5579,7 +5654,6 @@ tsParticles.init();
|
|
|
5579
5654
|
|
|
5580
5655
|
|
|
5581
5656
|
|
|
5582
|
-
|
|
5583
5657
|
|
|
5584
5658
|
|
|
5585
5659
|
;// CONCATENATED MODULE: ../../plugins/absorbers/dist/esm/Options/Classes/AbsorberSizeLimit.js
|