tsparticles 2.8.0 → 3.0.0-alpha.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 +6 -3
- package/browser/bundle.js +3 -3
- package/browser/index.js +9 -9
- package/cjs/bundle.js +4 -4
- package/cjs/index.js +18 -18
- package/esm/bundle.js +3 -3
- package/esm/index.js +9 -9
- package/package.json +14 -11
- package/report.html +2 -2
- package/tsparticles.bundle.js +450 -593
- package/tsparticles.bundle.min.js +1 -1
- package/tsparticles.bundle.min.js.LICENSE.txt +1 -1
- package/tsparticles.js +50 -50
- package/tsparticles.min.js +1 -1
- package/tsparticles.min.js.LICENSE.txt +1 -1
- package/types/bundle.d.ts +2 -2
- package/types/index.d.ts +1 -1
- package/umd/bundle.js +5 -5
- package/umd/index.js +19 -19
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
|
-
*
|
|
7
|
+
* v3.0.0-alpha.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -59,6 +59,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
59
59
|
__webpack_require__.d(__webpack_exports__, {
|
|
60
60
|
"AnimatableColor": () => (/* reexport */ AnimatableColor),
|
|
61
61
|
"AnimationOptions": () => (/* reexport */ AnimationOptions),
|
|
62
|
+
"AnimationValueWithRandom": () => (/* reexport */ AnimationValueWithRandom),
|
|
62
63
|
"Background": () => (/* reexport */ Background),
|
|
63
64
|
"BackgroundMask": () => (/* reexport */ BackgroundMask),
|
|
64
65
|
"BackgroundMaskCover": () => (/* reexport */ BackgroundMaskCover),
|
|
@@ -85,6 +86,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
85
86
|
"MoveGravity": () => (/* reexport */ MoveGravity),
|
|
86
87
|
"MovePath": () => (/* reexport */ MovePath),
|
|
87
88
|
"MoveTrail": () => (/* reexport */ MoveTrail),
|
|
89
|
+
"MoveTrailFill": () => (/* reexport */ MoveTrailFill),
|
|
88
90
|
"Opacity": () => (/* reexport */ Opacity),
|
|
89
91
|
"OpacityAnimation": () => (/* reexport */ OpacityAnimation),
|
|
90
92
|
"Options": () => (/* reexport */ Options),
|
|
@@ -99,6 +101,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
99
101
|
"ParticlesOptions": () => (/* reexport */ ParticlesOptions),
|
|
100
102
|
"Point": () => (/* reexport */ Point),
|
|
101
103
|
"Range": () => (/* reexport */ Range),
|
|
104
|
+
"RangedAnimationOptions": () => (/* reexport */ RangedAnimationOptions),
|
|
105
|
+
"RangedAnimationValueWithRandom": () => (/* reexport */ RangedAnimationValueWithRandom),
|
|
102
106
|
"Rectangle": () => (/* reexport */ Rectangle),
|
|
103
107
|
"ResizeEvent": () => (/* reexport */ ResizeEvent),
|
|
104
108
|
"Responsive": () => (/* reexport */ Responsive),
|
|
@@ -132,6 +136,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
132
136
|
"circleBounceDataFromParticle": () => (/* reexport */ circleBounceDataFromParticle),
|
|
133
137
|
"clamp": () => (/* reexport */ clamp),
|
|
134
138
|
"clear": () => (/* reexport */ clear),
|
|
139
|
+
"clearCanvas": () => (/* reexport */ clearCanvas),
|
|
135
140
|
"collisionVelocity": () => (/* reexport */ collisionVelocity),
|
|
136
141
|
"colorMix": () => (/* reexport */ colorMix),
|
|
137
142
|
"colorToHsl": () => (/* reexport */ colorToHsl),
|
|
@@ -149,6 +154,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
149
154
|
"executeOnSingleOrMultiple": () => (/* reexport */ executeOnSingleOrMultiple),
|
|
150
155
|
"findItemFromSingleOrMultiple": () => (/* reexport */ findItemFromSingleOrMultiple),
|
|
151
156
|
"generatedAttribute": () => (/* reexport */ generatedAttribute),
|
|
157
|
+
"getContext": () => (/* reexport */ getContext),
|
|
152
158
|
"getDistance": () => (/* reexport */ getDistance),
|
|
153
159
|
"getDistances": () => (/* reexport */ getDistances),
|
|
154
160
|
"getEasing": () => (/* reexport */ getEasing),
|
|
@@ -169,6 +175,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
169
175
|
"hasMatchMedia": () => (/* reexport */ hasMatchMedia),
|
|
170
176
|
"hslToRgb": () => (/* reexport */ hslToRgb),
|
|
171
177
|
"hslaToRgba": () => (/* reexport */ hslaToRgba),
|
|
178
|
+
"initParticleNumericAnimationValue": () => (/* reexport */ initParticleNumericAnimationValue),
|
|
172
179
|
"isDivModeEnabled": () => (/* reexport */ isDivModeEnabled),
|
|
173
180
|
"isInArray": () => (/* reexport */ isInArray),
|
|
174
181
|
"isPointInside": () => (/* reexport */ isPointInside),
|
|
@@ -186,8 +193,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
186
193
|
"mouseMoveEvent": () => (/* reexport */ mouseMoveEvent),
|
|
187
194
|
"mouseOutEvent": () => (/* reexport */ mouseOutEvent),
|
|
188
195
|
"mouseUpEvent": () => (/* reexport */ mouseUpEvent),
|
|
189
|
-
"
|
|
190
|
-
"paintImage": () => (/* reexport */ paintImage),
|
|
196
|
+
"paintCanvas": () => (/* reexport */ paintCanvas),
|
|
191
197
|
"parseAlpha": () => (/* reexport */ parseAlpha),
|
|
192
198
|
"randomInRange": () => (/* reexport */ randomInRange),
|
|
193
199
|
"rangeColorToHsl": () => (/* reexport */ rangeColorToHsl),
|
|
@@ -209,50 +215,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
209
215
|
"visibilityChangeEvent": () => (/* reexport */ visibilityChangeEvent)
|
|
210
216
|
});
|
|
211
217
|
|
|
212
|
-
;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/EventDispatcher.js
|
|
213
|
-
class EventDispatcher {
|
|
214
|
-
constructor() {
|
|
215
|
-
this._listeners = new Map();
|
|
216
|
-
}
|
|
217
|
-
addEventListener(type, listener) {
|
|
218
|
-
var _a;
|
|
219
|
-
this.removeEventListener(type, listener);
|
|
220
|
-
if (!this._listeners.get(type)) {
|
|
221
|
-
this._listeners.set(type, []);
|
|
222
|
-
}
|
|
223
|
-
(_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.push(listener);
|
|
224
|
-
}
|
|
225
|
-
dispatchEvent(type, args) {
|
|
226
|
-
var _a;
|
|
227
|
-
(_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(handler => handler(args));
|
|
228
|
-
}
|
|
229
|
-
hasEventListener(type) {
|
|
230
|
-
return !!this._listeners.get(type);
|
|
231
|
-
}
|
|
232
|
-
removeAllEventListeners(type) {
|
|
233
|
-
if (!type) {
|
|
234
|
-
this._listeners = new Map();
|
|
235
|
-
} else {
|
|
236
|
-
this._listeners.delete(type);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
removeEventListener(type, listener) {
|
|
240
|
-
const arr = this._listeners.get(type);
|
|
241
|
-
if (!arr) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
const length = arr.length,
|
|
245
|
-
idx = arr.indexOf(listener);
|
|
246
|
-
if (idx < 0) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
if (length === 1) {
|
|
250
|
-
this._listeners.delete(type);
|
|
251
|
-
} else {
|
|
252
|
-
arr.splice(idx, 1);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
218
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Vector3d.js
|
|
257
219
|
class Vector3d {
|
|
258
220
|
constructor(xOrCoords, y, z) {
|
|
@@ -750,6 +712,39 @@ function itemFromSingleOrMultiple(obj, index, useIndex) {
|
|
|
750
712
|
function findItemFromSingleOrMultiple(obj, callback) {
|
|
751
713
|
return obj instanceof Array ? obj.find((t, index) => callback(t, index)) : callback(obj, 0) ? obj : undefined;
|
|
752
714
|
}
|
|
715
|
+
function initParticleNumericAnimationValue(options, pxRatio) {
|
|
716
|
+
const valueRange = options.value,
|
|
717
|
+
animationOptions = options.animation;
|
|
718
|
+
const res = {
|
|
719
|
+
enable: options.animation.enable,
|
|
720
|
+
value: getRangeValue(options.value) * pxRatio,
|
|
721
|
+
max: getRangeMax(valueRange) * pxRatio,
|
|
722
|
+
min: getRangeMin(valueRange) * pxRatio,
|
|
723
|
+
loops: 0,
|
|
724
|
+
maxLoops: getRangeValue(options.animation.count)
|
|
725
|
+
};
|
|
726
|
+
if (animationOptions.enable) {
|
|
727
|
+
res.status = "increasing";
|
|
728
|
+
res.decay = 1 - getRangeValue(animationOptions.decay);
|
|
729
|
+
switch (animationOptions.startValue) {
|
|
730
|
+
case "min":
|
|
731
|
+
res.value = res.min;
|
|
732
|
+
res.status = "increasing";
|
|
733
|
+
break;
|
|
734
|
+
case "random":
|
|
735
|
+
res.value = randomInRange(res);
|
|
736
|
+
res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
737
|
+
break;
|
|
738
|
+
case "max":
|
|
739
|
+
default:
|
|
740
|
+
res.value = res.max;
|
|
741
|
+
res.status = "decreasing";
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
res.initialValue = res.value;
|
|
746
|
+
return res;
|
|
747
|
+
}
|
|
753
748
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/ColorUtils.js
|
|
754
749
|
|
|
755
750
|
|
|
@@ -1033,6 +1028,49 @@ function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
|
|
|
1033
1028
|
}
|
|
1034
1029
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/CanvasUtils.js
|
|
1035
1030
|
|
|
1031
|
+
function paintBase(context, dimension, baseColor) {
|
|
1032
|
+
context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)";
|
|
1033
|
+
context.fillRect(0, 0, dimension.width, dimension.height);
|
|
1034
|
+
}
|
|
1035
|
+
function paintImage(context, dimension, image, opacity) {
|
|
1036
|
+
if (!image) {
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
context.globalAlpha = opacity;
|
|
1040
|
+
context.drawImage(image, 0, 0, dimension.width, dimension.height);
|
|
1041
|
+
context.globalAlpha = 1;
|
|
1042
|
+
}
|
|
1043
|
+
function getContext(canvas) {
|
|
1044
|
+
const context = canvas.getContext("2d");
|
|
1045
|
+
if (!context) {
|
|
1046
|
+
throw new Error("Error tsParticles - No canvas context found");
|
|
1047
|
+
}
|
|
1048
|
+
return context;
|
|
1049
|
+
}
|
|
1050
|
+
function clearCanvas(context, size, options, trailFill, coverColorStyle) {
|
|
1051
|
+
if (options.backgroundMask.enable) {
|
|
1052
|
+
paintCanvas(context, size, options, coverColorStyle);
|
|
1053
|
+
} else {
|
|
1054
|
+
const trail = options.particles.move.trail;
|
|
1055
|
+
if (trail.enable && trail.length > 0 && trailFill) {
|
|
1056
|
+
if (trailFill.color) {
|
|
1057
|
+
paintBase(context, size, getStyleFromRgb(trailFill.color, trailFill.opacity));
|
|
1058
|
+
} else if (trailFill.image) {
|
|
1059
|
+
paintImage(context, size, trailFill.image, trailFill.opacity);
|
|
1060
|
+
}
|
|
1061
|
+
} else {
|
|
1062
|
+
clear(context, size);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
function paintCanvas(context, size, options, coverColorStyle) {
|
|
1067
|
+
if (options.backgroundMask.enable && coverColorStyle) {
|
|
1068
|
+
clear(context, size);
|
|
1069
|
+
paintBase(context, size, coverColorStyle);
|
|
1070
|
+
} else {
|
|
1071
|
+
paintBase(context, size);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1036
1074
|
function drawLine(context, begin, end) {
|
|
1037
1075
|
context.beginPath();
|
|
1038
1076
|
context.moveTo(begin.x, begin.y);
|
|
@@ -1046,18 +1084,6 @@ function drawTriangle(context, p1, p2, p3) {
|
|
|
1046
1084
|
context.lineTo(p3.x, p3.y);
|
|
1047
1085
|
context.closePath();
|
|
1048
1086
|
}
|
|
1049
|
-
function paintBase(context, dimension, baseColor) {
|
|
1050
|
-
context.fillStyle = baseColor !== null && baseColor !== void 0 ? baseColor : "rgba(0,0,0,0)";
|
|
1051
|
-
context.fillRect(0, 0, dimension.width, dimension.height);
|
|
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
|
-
}
|
|
1061
1087
|
function clear(context, dimension) {
|
|
1062
1088
|
context.clearRect(0, 0, dimension.width, dimension.height);
|
|
1063
1089
|
}
|
|
@@ -1211,22 +1237,9 @@ class Canvas {
|
|
|
1211
1237
|
return this.container.actualOptions.fullScreen.enable;
|
|
1212
1238
|
}
|
|
1213
1239
|
clear() {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
if (options.backgroundMask.enable) {
|
|
1218
|
-
this.paint();
|
|
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
|
-
}
|
|
1225
|
-
} else {
|
|
1226
|
-
this.draw(ctx => {
|
|
1227
|
-
clear(ctx, this.size);
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1240
|
+
this.draw(ctx => {
|
|
1241
|
+
clearCanvas(ctx, this.size, this.container.actualOptions, this._trailFill, this._coverColorStyle);
|
|
1242
|
+
});
|
|
1230
1243
|
}
|
|
1231
1244
|
destroy() {
|
|
1232
1245
|
var _a, _b;
|
|
@@ -1314,7 +1327,7 @@ class Canvas {
|
|
|
1314
1327
|
}
|
|
1315
1328
|
async init() {
|
|
1316
1329
|
var _a;
|
|
1317
|
-
this.
|
|
1330
|
+
this._resize();
|
|
1318
1331
|
this._initStyle();
|
|
1319
1332
|
this._initCover();
|
|
1320
1333
|
try {
|
|
@@ -1322,57 +1335,18 @@ class Canvas {
|
|
|
1322
1335
|
} catch (e) {
|
|
1323
1336
|
console.error(e);
|
|
1324
1337
|
}
|
|
1325
|
-
this.
|
|
1338
|
+
this._initBackground();
|
|
1326
1339
|
if (this.element) {
|
|
1327
1340
|
(_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.element, {
|
|
1328
1341
|
attributes: true
|
|
1329
1342
|
});
|
|
1330
1343
|
}
|
|
1331
|
-
this.
|
|
1332
|
-
this.
|
|
1333
|
-
this.
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
background = options.background,
|
|
1338
|
-
element = this.element,
|
|
1339
|
-
elementStyle = element === null || element === void 0 ? void 0 : element.style;
|
|
1340
|
-
if (!elementStyle) {
|
|
1341
|
-
return;
|
|
1342
|
-
}
|
|
1343
|
-
if (background.color) {
|
|
1344
|
-
const color = rangeColorToRgb(background.color);
|
|
1345
|
-
elementStyle.backgroundColor = color ? getStyleFromRgb(color, background.opacity) : "";
|
|
1346
|
-
} else {
|
|
1347
|
-
elementStyle.backgroundColor = "";
|
|
1348
|
-
}
|
|
1349
|
-
elementStyle.backgroundImage = background.image || "";
|
|
1350
|
-
elementStyle.backgroundPosition = background.position || "";
|
|
1351
|
-
elementStyle.backgroundRepeat = background.repeat || "";
|
|
1352
|
-
elementStyle.backgroundSize = background.size || "";
|
|
1353
|
-
}
|
|
1354
|
-
initPlugins() {
|
|
1355
|
-
this._resizePlugins = [];
|
|
1356
|
-
for (const [, plugin] of this.container.plugins) {
|
|
1357
|
-
if (plugin.resize) {
|
|
1358
|
-
this._resizePlugins.push(plugin);
|
|
1359
|
-
}
|
|
1360
|
-
if (plugin.particleFillColor || plugin.particleStrokeColor) {
|
|
1361
|
-
this._colorPlugins.push(plugin);
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
initUpdaters() {
|
|
1366
|
-
this._preDrawUpdaters = [];
|
|
1367
|
-
this._postDrawUpdaters = [];
|
|
1368
|
-
for (const updater of this.container.particles.updaters) {
|
|
1369
|
-
if (updater.afterDraw) {
|
|
1370
|
-
this._postDrawUpdaters.push(updater);
|
|
1371
|
-
}
|
|
1372
|
-
if (updater.getColorStyles || updater.getTransformValues || updater.beforeDraw) {
|
|
1373
|
-
this._preDrawUpdaters.push(updater);
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1344
|
+
this._initUpdaters();
|
|
1345
|
+
this._initPlugins();
|
|
1346
|
+
this._paint();
|
|
1347
|
+
this.container.updateActualOptions();
|
|
1348
|
+
this._resize();
|
|
1349
|
+
this._initBackground();
|
|
1376
1350
|
}
|
|
1377
1351
|
loadCanvas(canvas) {
|
|
1378
1352
|
var _a, _b;
|
|
@@ -1385,53 +1359,18 @@ class Canvas {
|
|
|
1385
1359
|
this._originalStyle = deepExtend({}, this.element.style);
|
|
1386
1360
|
this.size.height = canvas.offsetHeight;
|
|
1387
1361
|
this.size.width = canvas.offsetWidth;
|
|
1388
|
-
this._context =
|
|
1362
|
+
this._context = getContext(canvas);
|
|
1389
1363
|
(_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(this.element, {
|
|
1390
1364
|
attributes: true
|
|
1391
1365
|
});
|
|
1392
1366
|
this.container.retina.init();
|
|
1393
|
-
this.
|
|
1394
|
-
}
|
|
1395
|
-
paint() {
|
|
1396
|
-
const options = this.container.actualOptions;
|
|
1397
|
-
this.draw(ctx => {
|
|
1398
|
-
if (options.backgroundMask.enable && options.backgroundMask.cover) {
|
|
1399
|
-
clear(ctx, this.size);
|
|
1400
|
-
this._paintBase(this._coverColorStyle);
|
|
1401
|
-
} else {
|
|
1402
|
-
this._paintBase();
|
|
1403
|
-
}
|
|
1404
|
-
});
|
|
1405
|
-
}
|
|
1406
|
-
resize() {
|
|
1407
|
-
if (!this.element) {
|
|
1408
|
-
return;
|
|
1409
|
-
}
|
|
1410
|
-
const container = this.container,
|
|
1411
|
-
pxRatio = container.retina.pixelRatio,
|
|
1412
|
-
size = container.canvas.size,
|
|
1413
|
-
newSize = {
|
|
1414
|
-
width: this.element.offsetWidth * pxRatio,
|
|
1415
|
-
height: this.element.offsetHeight * pxRatio
|
|
1416
|
-
};
|
|
1417
|
-
if (newSize.height === size.height && newSize.width === size.width && newSize.height === this.element.height && newSize.width === this.element.width) {
|
|
1418
|
-
return;
|
|
1419
|
-
}
|
|
1420
|
-
const oldSize = Object.assign({}, size);
|
|
1421
|
-
this.element.width = size.width = this.element.offsetWidth * pxRatio;
|
|
1422
|
-
this.element.height = size.height = this.element.offsetHeight * pxRatio;
|
|
1423
|
-
if (this.container.started) {
|
|
1424
|
-
this.resizeFactor = {
|
|
1425
|
-
width: size.width / oldSize.width,
|
|
1426
|
-
height: size.height / oldSize.height
|
|
1427
|
-
};
|
|
1428
|
-
}
|
|
1367
|
+
this._initBackground();
|
|
1429
1368
|
}
|
|
1430
1369
|
async windowResize() {
|
|
1431
1370
|
if (!this.element) {
|
|
1432
1371
|
return;
|
|
1433
1372
|
}
|
|
1434
|
-
this.
|
|
1373
|
+
this._resize();
|
|
1435
1374
|
const container = this.container,
|
|
1436
1375
|
needsRefresh = container.updateActualOptions();
|
|
1437
1376
|
container.particles.setDensity();
|
|
@@ -1492,6 +1431,25 @@ class Canvas {
|
|
|
1492
1431
|
}
|
|
1493
1432
|
return [fColor, sColor];
|
|
1494
1433
|
}
|
|
1434
|
+
_initBackground() {
|
|
1435
|
+
const options = this.container.actualOptions,
|
|
1436
|
+
background = options.background,
|
|
1437
|
+
element = this.element,
|
|
1438
|
+
elementStyle = element === null || element === void 0 ? void 0 : element.style;
|
|
1439
|
+
if (!elementStyle) {
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
if (background.color) {
|
|
1443
|
+
const color = rangeColorToRgb(background.color);
|
|
1444
|
+
elementStyle.backgroundColor = color ? getStyleFromRgb(color, background.opacity) : "";
|
|
1445
|
+
} else {
|
|
1446
|
+
elementStyle.backgroundColor = "";
|
|
1447
|
+
}
|
|
1448
|
+
elementStyle.backgroundImage = background.image || "";
|
|
1449
|
+
elementStyle.backgroundPosition = background.position || "";
|
|
1450
|
+
elementStyle.backgroundRepeat = background.repeat || "";
|
|
1451
|
+
elementStyle.backgroundSize = background.size || "";
|
|
1452
|
+
}
|
|
1495
1453
|
_initCover() {
|
|
1496
1454
|
const options = this.container.actualOptions,
|
|
1497
1455
|
cover = options.backgroundMask.cover,
|
|
@@ -1507,6 +1465,17 @@ class Canvas {
|
|
|
1507
1465
|
this._coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
|
|
1508
1466
|
}
|
|
1509
1467
|
}
|
|
1468
|
+
_initPlugins() {
|
|
1469
|
+
this._resizePlugins = [];
|
|
1470
|
+
for (const [, plugin] of this.container.plugins) {
|
|
1471
|
+
if (plugin.resize) {
|
|
1472
|
+
this._resizePlugins.push(plugin);
|
|
1473
|
+
}
|
|
1474
|
+
if (plugin.particleFillColor || plugin.particleStrokeColor) {
|
|
1475
|
+
this._colorPlugins.push(plugin);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1510
1479
|
_initStyle() {
|
|
1511
1480
|
const element = this.element,
|
|
1512
1481
|
options = this.container.actualOptions;
|
|
@@ -1567,14 +1536,21 @@ class Canvas {
|
|
|
1567
1536
|
});
|
|
1568
1537
|
}
|
|
1569
1538
|
}
|
|
1570
|
-
|
|
1571
|
-
this.
|
|
1572
|
-
|
|
1573
|
-
|
|
1539
|
+
_initUpdaters() {
|
|
1540
|
+
this._preDrawUpdaters = [];
|
|
1541
|
+
this._postDrawUpdaters = [];
|
|
1542
|
+
for (const updater of this.container.particles.updaters) {
|
|
1543
|
+
if (updater.afterDraw) {
|
|
1544
|
+
this._postDrawUpdaters.push(updater);
|
|
1545
|
+
}
|
|
1546
|
+
if (updater.getColorStyles || updater.getTransformValues || updater.beforeDraw) {
|
|
1547
|
+
this._preDrawUpdaters.push(updater);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1574
1550
|
}
|
|
1575
|
-
|
|
1551
|
+
_paint() {
|
|
1576
1552
|
this.draw(ctx => {
|
|
1577
|
-
|
|
1553
|
+
paintCanvas(ctx, this.size, this.container.actualOptions, this._coverColorStyle);
|
|
1578
1554
|
});
|
|
1579
1555
|
}
|
|
1580
1556
|
_repairStyle() {
|
|
@@ -1585,7 +1561,7 @@ class Canvas {
|
|
|
1585
1561
|
}
|
|
1586
1562
|
(_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
1587
1563
|
this._initStyle();
|
|
1588
|
-
this.
|
|
1564
|
+
this._initBackground();
|
|
1589
1565
|
(_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(element, {
|
|
1590
1566
|
attributes: true
|
|
1591
1567
|
});
|
|
@@ -1603,6 +1579,30 @@ class Canvas {
|
|
|
1603
1579
|
element.style.width = originalStyle.width;
|
|
1604
1580
|
element.style.height = originalStyle.height;
|
|
1605
1581
|
}
|
|
1582
|
+
_resize() {
|
|
1583
|
+
if (!this.element) {
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
const container = this.container,
|
|
1587
|
+
pxRatio = container.retina.pixelRatio,
|
|
1588
|
+
size = container.canvas.size,
|
|
1589
|
+
newSize = {
|
|
1590
|
+
width: this.element.offsetWidth * pxRatio,
|
|
1591
|
+
height: this.element.offsetHeight * pxRatio
|
|
1592
|
+
};
|
|
1593
|
+
if (newSize.height === size.height && newSize.width === size.width && newSize.height === this.element.height && newSize.width === this.element.width) {
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
const oldSize = Object.assign({}, size);
|
|
1597
|
+
this.element.width = size.width = this.element.offsetWidth * pxRatio;
|
|
1598
|
+
this.element.height = size.height = this.element.offsetHeight * pxRatio;
|
|
1599
|
+
if (this.container.started) {
|
|
1600
|
+
this.resizeFactor = {
|
|
1601
|
+
width: size.width / oldSize.width,
|
|
1602
|
+
height: size.height / oldSize.height
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
1606
|
_setFullScreenStyle() {
|
|
1607
1607
|
const element = this.element;
|
|
1608
1608
|
if (!element) {
|
|
@@ -2519,6 +2519,55 @@ class CollisionsOverlap {
|
|
|
2519
2519
|
}
|
|
2520
2520
|
}
|
|
2521
2521
|
}
|
|
2522
|
+
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/AnimationOptions.js
|
|
2523
|
+
|
|
2524
|
+
class AnimationOptions {
|
|
2525
|
+
constructor() {
|
|
2526
|
+
this.count = 0;
|
|
2527
|
+
this.enable = false;
|
|
2528
|
+
this.speed = 1;
|
|
2529
|
+
this.decay = 0;
|
|
2530
|
+
this.sync = false;
|
|
2531
|
+
}
|
|
2532
|
+
load(data) {
|
|
2533
|
+
if (!data) {
|
|
2534
|
+
return;
|
|
2535
|
+
}
|
|
2536
|
+
if (data.count !== undefined) {
|
|
2537
|
+
this.count = setRangeValue(data.count);
|
|
2538
|
+
}
|
|
2539
|
+
if (data.enable !== undefined) {
|
|
2540
|
+
this.enable = data.enable;
|
|
2541
|
+
}
|
|
2542
|
+
if (data.speed !== undefined) {
|
|
2543
|
+
this.speed = setRangeValue(data.speed);
|
|
2544
|
+
}
|
|
2545
|
+
if (data.decay !== undefined) {
|
|
2546
|
+
this.decay = setRangeValue(data.decay);
|
|
2547
|
+
}
|
|
2548
|
+
if (data.sync !== undefined) {
|
|
2549
|
+
this.sync = data.sync;
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
class RangedAnimationOptions extends AnimationOptions {
|
|
2554
|
+
constructor() {
|
|
2555
|
+
super();
|
|
2556
|
+
this.startValue = "random";
|
|
2557
|
+
}
|
|
2558
|
+
load(data) {
|
|
2559
|
+
super.load(data);
|
|
2560
|
+
if (!data) {
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
if (data.minimumValue !== undefined) {
|
|
2564
|
+
this.minimumValue = data.minimumValue;
|
|
2565
|
+
}
|
|
2566
|
+
if (data.startValue !== undefined) {
|
|
2567
|
+
this.startValue = data.startValue;
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2522
2571
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Random.js
|
|
2523
2572
|
class Random {
|
|
2524
2573
|
constructor() {
|
|
@@ -2540,6 +2589,8 @@ class Random {
|
|
|
2540
2589
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/ValueWithRandom.js
|
|
2541
2590
|
|
|
2542
2591
|
|
|
2592
|
+
|
|
2593
|
+
|
|
2543
2594
|
class ValueWithRandom {
|
|
2544
2595
|
constructor() {
|
|
2545
2596
|
this.random = new Random();
|
|
@@ -2559,6 +2610,44 @@ class ValueWithRandom {
|
|
|
2559
2610
|
}
|
|
2560
2611
|
}
|
|
2561
2612
|
}
|
|
2613
|
+
class AnimationValueWithRandom extends ValueWithRandom {
|
|
2614
|
+
constructor() {
|
|
2615
|
+
super();
|
|
2616
|
+
this.animation = new AnimationOptions();
|
|
2617
|
+
}
|
|
2618
|
+
get anim() {
|
|
2619
|
+
return this.animation;
|
|
2620
|
+
}
|
|
2621
|
+
set anim(value) {
|
|
2622
|
+
this.animation = value;
|
|
2623
|
+
}
|
|
2624
|
+
load(data) {
|
|
2625
|
+
var _a;
|
|
2626
|
+
super.load(data);
|
|
2627
|
+
if (!data) {
|
|
2628
|
+
return;
|
|
2629
|
+
}
|
|
2630
|
+
const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
|
|
2631
|
+
if (animation !== undefined) {
|
|
2632
|
+
this.animation.load(animation);
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
class RangedAnimationValueWithRandom extends AnimationValueWithRandom {
|
|
2637
|
+
constructor() {
|
|
2638
|
+
super();
|
|
2639
|
+
this.animation = new RangedAnimationOptions();
|
|
2640
|
+
}
|
|
2641
|
+
load(data) {
|
|
2642
|
+
super.load(data);
|
|
2643
|
+
if (!data) {
|
|
2644
|
+
return;
|
|
2645
|
+
}
|
|
2646
|
+
if (data.animation !== undefined) {
|
|
2647
|
+
this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2562
2651
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js
|
|
2563
2652
|
|
|
2564
2653
|
class ParticlesBounceFactor extends ValueWithRandom {
|
|
@@ -2963,47 +3052,13 @@ class Move {
|
|
|
2963
3052
|
}
|
|
2964
3053
|
}
|
|
2965
3054
|
}
|
|
2966
|
-
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/AnimationOptions.js
|
|
2967
|
-
|
|
2968
|
-
class AnimationOptions {
|
|
2969
|
-
constructor() {
|
|
2970
|
-
this.count = 0;
|
|
2971
|
-
this.enable = false;
|
|
2972
|
-
this.speed = 1;
|
|
2973
|
-
this.decay = 0;
|
|
2974
|
-
this.sync = false;
|
|
2975
|
-
}
|
|
2976
|
-
load(data) {
|
|
2977
|
-
if (!data) {
|
|
2978
|
-
return;
|
|
2979
|
-
}
|
|
2980
|
-
if (data.count !== undefined) {
|
|
2981
|
-
this.count = setRangeValue(data.count);
|
|
2982
|
-
}
|
|
2983
|
-
if (data.enable !== undefined) {
|
|
2984
|
-
this.enable = data.enable;
|
|
2985
|
-
}
|
|
2986
|
-
if (data.speed !== undefined) {
|
|
2987
|
-
this.speed = setRangeValue(data.speed);
|
|
2988
|
-
}
|
|
2989
|
-
if (data.decay !== undefined) {
|
|
2990
|
-
this.decay = setRangeValue(data.decay);
|
|
2991
|
-
}
|
|
2992
|
-
if (data.sync !== undefined) {
|
|
2993
|
-
this.sync = data.sync;
|
|
2994
|
-
}
|
|
2995
|
-
}
|
|
2996
|
-
}
|
|
2997
3055
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js
|
|
2998
3056
|
|
|
2999
|
-
class OpacityAnimation extends
|
|
3057
|
+
class OpacityAnimation extends RangedAnimationOptions {
|
|
3000
3058
|
constructor() {
|
|
3001
3059
|
super();
|
|
3002
3060
|
this.destroy = "none";
|
|
3003
|
-
this.enable = false;
|
|
3004
3061
|
this.speed = 2;
|
|
3005
|
-
this.startValue = "random";
|
|
3006
|
-
this.sync = false;
|
|
3007
3062
|
}
|
|
3008
3063
|
get opacity_min() {
|
|
3009
3064
|
return this.minimumValue;
|
|
@@ -3012,34 +3067,22 @@ class OpacityAnimation extends AnimationOptions {
|
|
|
3012
3067
|
this.minimumValue = value;
|
|
3013
3068
|
}
|
|
3014
3069
|
load(data) {
|
|
3015
|
-
|
|
3070
|
+
if ((data === null || data === void 0 ? void 0 : data.opacity_min) !== undefined && data.minimumValue === undefined) {
|
|
3071
|
+
data.minimumValue = data.opacity_min;
|
|
3072
|
+
}
|
|
3073
|
+
super.load(data);
|
|
3016
3074
|
if (!data) {
|
|
3017
3075
|
return;
|
|
3018
3076
|
}
|
|
3019
|
-
super.load(data);
|
|
3020
3077
|
if (data.destroy !== undefined) {
|
|
3021
3078
|
this.destroy = data.destroy;
|
|
3022
3079
|
}
|
|
3023
|
-
if (data.enable !== undefined) {
|
|
3024
|
-
this.enable = data.enable;
|
|
3025
|
-
}
|
|
3026
|
-
this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.opacity_min;
|
|
3027
|
-
if (data.speed !== undefined) {
|
|
3028
|
-
this.speed = data.speed;
|
|
3029
|
-
}
|
|
3030
|
-
if (data.startValue !== undefined) {
|
|
3031
|
-
this.startValue = data.startValue;
|
|
3032
|
-
}
|
|
3033
|
-
if (data.sync !== undefined) {
|
|
3034
|
-
this.sync = data.sync;
|
|
3035
|
-
}
|
|
3036
3080
|
}
|
|
3037
3081
|
}
|
|
3038
3082
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Opacity/Opacity.js
|
|
3039
3083
|
|
|
3040
3084
|
|
|
3041
|
-
|
|
3042
|
-
class Opacity extends ValueWithRandom {
|
|
3085
|
+
class Opacity extends RangedAnimationValueWithRandom {
|
|
3043
3086
|
constructor() {
|
|
3044
3087
|
super();
|
|
3045
3088
|
this.animation = new OpacityAnimation();
|
|
@@ -3052,18 +3095,6 @@ class Opacity extends ValueWithRandom {
|
|
|
3052
3095
|
set anim(value) {
|
|
3053
3096
|
this.animation = value;
|
|
3054
3097
|
}
|
|
3055
|
-
load(data) {
|
|
3056
|
-
var _a;
|
|
3057
|
-
if (!data) {
|
|
3058
|
-
return;
|
|
3059
|
-
}
|
|
3060
|
-
super.load(data);
|
|
3061
|
-
const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
|
|
3062
|
-
if (animation !== undefined) {
|
|
3063
|
-
this.animation.load(animation);
|
|
3064
|
-
this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
3098
|
}
|
|
3068
3099
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Number/ParticlesDensity.js
|
|
3069
3100
|
class ParticlesDensity {
|
|
@@ -3174,106 +3205,37 @@ class Shadow {
|
|
|
3174
3205
|
}
|
|
3175
3206
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Shape/Shape.js
|
|
3176
3207
|
|
|
3177
|
-
const charKey = "character",
|
|
3178
|
-
charAltKey = "char",
|
|
3179
|
-
imageKey = "image",
|
|
3180
|
-
imageAltKey = "images",
|
|
3181
|
-
polygonKey = "polygon",
|
|
3182
|
-
polygonAltKey = "star";
|
|
3183
3208
|
class Shape {
|
|
3184
3209
|
constructor() {
|
|
3185
3210
|
this.options = {};
|
|
3186
3211
|
this.type = "circle";
|
|
3187
3212
|
}
|
|
3188
|
-
get character() {
|
|
3189
|
-
var _a;
|
|
3190
|
-
return (_a = this.options[charKey]) !== null && _a !== void 0 ? _a : this.options[charAltKey];
|
|
3191
|
-
}
|
|
3192
|
-
set character(value) {
|
|
3193
|
-
this.options[charAltKey] = this.options[charKey] = value;
|
|
3194
|
-
}
|
|
3195
|
-
get custom() {
|
|
3196
|
-
return this.options;
|
|
3197
|
-
}
|
|
3198
|
-
set custom(value) {
|
|
3199
|
-
this.options = value;
|
|
3200
|
-
}
|
|
3201
|
-
get image() {
|
|
3202
|
-
var _a;
|
|
3203
|
-
return (_a = this.options[imageKey]) !== null && _a !== void 0 ? _a : this.options[imageAltKey];
|
|
3204
|
-
}
|
|
3205
|
-
set image(value) {
|
|
3206
|
-
this.options[imageAltKey] = this.options[imageKey] = value;
|
|
3207
|
-
}
|
|
3208
|
-
get images() {
|
|
3209
|
-
return this.image;
|
|
3210
|
-
}
|
|
3211
|
-
set images(value) {
|
|
3212
|
-
this.image = value;
|
|
3213
|
-
}
|
|
3214
|
-
get polygon() {
|
|
3215
|
-
var _a;
|
|
3216
|
-
return (_a = this.options[polygonKey]) !== null && _a !== void 0 ? _a : this.options[polygonAltKey];
|
|
3217
|
-
}
|
|
3218
|
-
set polygon(value) {
|
|
3219
|
-
this.options[polygonAltKey] = this.options[polygonKey] = value;
|
|
3220
|
-
}
|
|
3221
|
-
get stroke() {
|
|
3222
|
-
return [];
|
|
3223
|
-
}
|
|
3224
|
-
set stroke(_value) {}
|
|
3225
3213
|
load(data) {
|
|
3226
|
-
var _a
|
|
3214
|
+
var _a;
|
|
3227
3215
|
if (!data) {
|
|
3228
3216
|
return;
|
|
3229
3217
|
}
|
|
3230
|
-
const options =
|
|
3218
|
+
const options = data.options;
|
|
3231
3219
|
if (options !== undefined) {
|
|
3232
3220
|
for (const shape in options) {
|
|
3233
3221
|
const item = options[shape];
|
|
3234
3222
|
if (item) {
|
|
3235
|
-
this.options[shape] = deepExtend((
|
|
3223
|
+
this.options[shape] = deepExtend((_a = this.options[shape]) !== null && _a !== void 0 ? _a : {}, item);
|
|
3236
3224
|
}
|
|
3237
3225
|
}
|
|
3238
3226
|
}
|
|
3239
|
-
this.loadShape(data.character, charKey, charAltKey, true);
|
|
3240
|
-
this.loadShape(data.polygon, polygonKey, polygonAltKey, false);
|
|
3241
|
-
this.loadShape((_c = data.image) !== null && _c !== void 0 ? _c : data.images, imageKey, imageAltKey, true);
|
|
3242
3227
|
if (data.type !== undefined) {
|
|
3243
3228
|
this.type = data.type;
|
|
3244
3229
|
}
|
|
3245
3230
|
}
|
|
3246
|
-
loadShape(item, mainKey, altKey, altOverride) {
|
|
3247
|
-
var _a, _b;
|
|
3248
|
-
if (!item) {
|
|
3249
|
-
return;
|
|
3250
|
-
}
|
|
3251
|
-
const isArray = item instanceof Array;
|
|
3252
|
-
const emptyValue = isArray ? [] : {},
|
|
3253
|
-
mainDifferentValues = isArray !== this.options[mainKey] instanceof Array,
|
|
3254
|
-
altDifferentValues = isArray !== this.options[altKey] instanceof Array;
|
|
3255
|
-
if (mainDifferentValues) {
|
|
3256
|
-
this.options[mainKey] = emptyValue;
|
|
3257
|
-
}
|
|
3258
|
-
if (altDifferentValues && altOverride) {
|
|
3259
|
-
this.options[altKey] = emptyValue;
|
|
3260
|
-
}
|
|
3261
|
-
this.options[mainKey] = deepExtend((_a = this.options[mainKey]) !== null && _a !== void 0 ? _a : emptyValue, item);
|
|
3262
|
-
if (!this.options[altKey] || altOverride) {
|
|
3263
|
-
this.options[altKey] = deepExtend((_b = this.options[altKey]) !== null && _b !== void 0 ? _b : emptyValue, item);
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
3231
|
}
|
|
3267
3232
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Size/SizeAnimation.js
|
|
3268
3233
|
|
|
3269
|
-
class SizeAnimation extends
|
|
3234
|
+
class SizeAnimation extends RangedAnimationOptions {
|
|
3270
3235
|
constructor() {
|
|
3271
3236
|
super();
|
|
3272
3237
|
this.destroy = "none";
|
|
3273
|
-
this.enable = false;
|
|
3274
3238
|
this.speed = 5;
|
|
3275
|
-
this.startValue = "random";
|
|
3276
|
-
this.sync = false;
|
|
3277
3239
|
}
|
|
3278
3240
|
get size_min() {
|
|
3279
3241
|
return this.minimumValue;
|
|
@@ -3282,34 +3244,22 @@ class SizeAnimation extends AnimationOptions {
|
|
|
3282
3244
|
this.minimumValue = value;
|
|
3283
3245
|
}
|
|
3284
3246
|
load(data) {
|
|
3285
|
-
|
|
3247
|
+
if ((data === null || data === void 0 ? void 0 : data.size_min) !== undefined && data.minimumValue === undefined) {
|
|
3248
|
+
data.minimumValue = data.size_min;
|
|
3249
|
+
}
|
|
3286
3250
|
super.load(data);
|
|
3287
3251
|
if (!data) {
|
|
3288
3252
|
return;
|
|
3289
3253
|
}
|
|
3290
|
-
if (data.destroy !== undefined) {
|
|
3291
|
-
this.destroy = data.destroy;
|
|
3292
|
-
}
|
|
3293
|
-
if (data.enable !== undefined) {
|
|
3294
|
-
this.enable = data.enable;
|
|
3295
|
-
}
|
|
3296
|
-
this.minimumValue = (_a = data.minimumValue) !== null && _a !== void 0 ? _a : data.size_min;
|
|
3297
|
-
if (data.speed !== undefined) {
|
|
3298
|
-
this.speed = data.speed;
|
|
3299
|
-
}
|
|
3300
|
-
if (data.startValue !== undefined) {
|
|
3301
|
-
this.startValue = data.startValue;
|
|
3302
|
-
}
|
|
3303
|
-
if (data.sync !== undefined) {
|
|
3304
|
-
this.sync = data.sync;
|
|
3254
|
+
if (data.destroy !== undefined) {
|
|
3255
|
+
this.destroy = data.destroy;
|
|
3305
3256
|
}
|
|
3306
3257
|
}
|
|
3307
3258
|
}
|
|
3308
3259
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Size/Size.js
|
|
3309
3260
|
|
|
3310
3261
|
|
|
3311
|
-
|
|
3312
|
-
class Size extends ValueWithRandom {
|
|
3262
|
+
class Size extends RangedAnimationValueWithRandom {
|
|
3313
3263
|
constructor() {
|
|
3314
3264
|
super();
|
|
3315
3265
|
this.animation = new SizeAnimation();
|
|
@@ -3322,18 +3272,6 @@ class Size extends ValueWithRandom {
|
|
|
3322
3272
|
set anim(value) {
|
|
3323
3273
|
this.animation = value;
|
|
3324
3274
|
}
|
|
3325
|
-
load(data) {
|
|
3326
|
-
var _a;
|
|
3327
|
-
super.load(data);
|
|
3328
|
-
if (!data) {
|
|
3329
|
-
return;
|
|
3330
|
-
}
|
|
3331
|
-
const animation = (_a = data.animation) !== null && _a !== void 0 ? _a : data.anim;
|
|
3332
|
-
if (animation !== undefined) {
|
|
3333
|
-
this.animation.load(animation);
|
|
3334
|
-
this.value = setRangeValue(this.value, this.animation.enable ? this.animation.minimumValue : undefined);
|
|
3335
|
-
}
|
|
3336
|
-
}
|
|
3337
3275
|
}
|
|
3338
3276
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Stroke.js
|
|
3339
3277
|
|
|
@@ -3415,7 +3353,7 @@ class ParticlesOptions {
|
|
|
3415
3353
|
this.zIndex = new ZIndex();
|
|
3416
3354
|
}
|
|
3417
3355
|
load(data) {
|
|
3418
|
-
var _a, _b, _c, _d
|
|
3356
|
+
var _a, _b, _c, _d;
|
|
3419
3357
|
if (!data) {
|
|
3420
3358
|
return;
|
|
3421
3359
|
}
|
|
@@ -3447,9 +3385,9 @@ class ParticlesOptions {
|
|
|
3447
3385
|
if (data.interactivity !== undefined) {
|
|
3448
3386
|
this.interactivity = deepExtend({}, data.interactivity);
|
|
3449
3387
|
}
|
|
3450
|
-
const
|
|
3451
|
-
if (
|
|
3452
|
-
this.stroke = executeOnSingleOrMultiple(
|
|
3388
|
+
const stroke = data.stroke;
|
|
3389
|
+
if (stroke) {
|
|
3390
|
+
this.stroke = executeOnSingleOrMultiple(stroke, t => {
|
|
3453
3391
|
const tmp = new Stroke();
|
|
3454
3392
|
tmp.load(t);
|
|
3455
3393
|
return tmp;
|
|
@@ -3513,6 +3451,7 @@ class Options {
|
|
|
3513
3451
|
this.fpsLimit = 120;
|
|
3514
3452
|
this.interactivity = new Interactivity(engine, container);
|
|
3515
3453
|
this.manualParticles = [];
|
|
3454
|
+
this.name = "default";
|
|
3516
3455
|
this.particles = loadParticlesOptions(this._engine, this._container);
|
|
3517
3456
|
this.pauseOnBlur = true;
|
|
3518
3457
|
this.pauseOnOutsideViewport = true;
|
|
@@ -3792,7 +3731,7 @@ class Particle {
|
|
|
3792
3731
|
return this._getRollColor((_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.strokeColor));
|
|
3793
3732
|
}
|
|
3794
3733
|
init(id, position, overrideOptions, group) {
|
|
3795
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
3734
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3796
3735
|
const container = this.container,
|
|
3797
3736
|
engine = this._engine;
|
|
3798
3737
|
this.id = id;
|
|
@@ -3844,39 +3783,8 @@ class Particle {
|
|
|
3844
3783
|
this.pathGenerator.init(container);
|
|
3845
3784
|
}
|
|
3846
3785
|
}
|
|
3847
|
-
const zIndexValue = getRangeValue(this.options.zIndex.value);
|
|
3848
3786
|
container.retina.initParticle(this);
|
|
3849
|
-
|
|
3850
|
-
sizeRange = sizeOptions.value,
|
|
3851
|
-
sizeAnimation = sizeOptions.animation;
|
|
3852
|
-
this.size = {
|
|
3853
|
-
enable: sizeOptions.animation.enable,
|
|
3854
|
-
value: getRangeValue(sizeOptions.value) * container.retina.pixelRatio,
|
|
3855
|
-
max: getRangeMax(sizeRange) * pxRatio,
|
|
3856
|
-
min: getRangeMin(sizeRange) * pxRatio,
|
|
3857
|
-
loops: 0,
|
|
3858
|
-
maxLoops: getRangeValue(sizeOptions.animation.count)
|
|
3859
|
-
};
|
|
3860
|
-
if (sizeAnimation.enable) {
|
|
3861
|
-
this.size.status = "increasing";
|
|
3862
|
-
this.size.decay = 1 - getRangeValue(sizeAnimation.decay);
|
|
3863
|
-
switch (sizeAnimation.startValue) {
|
|
3864
|
-
case "min":
|
|
3865
|
-
this.size.value = this.size.min;
|
|
3866
|
-
this.size.status = "increasing";
|
|
3867
|
-
break;
|
|
3868
|
-
case "random":
|
|
3869
|
-
this.size.value = randomInRange(this.size);
|
|
3870
|
-
this.size.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
3871
|
-
break;
|
|
3872
|
-
case "max":
|
|
3873
|
-
default:
|
|
3874
|
-
this.size.value = this.size.max;
|
|
3875
|
-
this.size.status = "decreasing";
|
|
3876
|
-
break;
|
|
3877
|
-
}
|
|
3878
|
-
}
|
|
3879
|
-
this.size.initialValue = this.size.value;
|
|
3787
|
+
this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
|
|
3880
3788
|
this.bubble = {
|
|
3881
3789
|
inRange: false
|
|
3882
3790
|
};
|
|
@@ -3884,30 +3792,10 @@ class Particle {
|
|
|
3884
3792
|
inRange: false,
|
|
3885
3793
|
factor: 1
|
|
3886
3794
|
};
|
|
3887
|
-
this.
|
|
3888
|
-
this.initialPosition = this.position.copy();
|
|
3889
|
-
const canvasSize = container.canvas.size,
|
|
3890
|
-
moveCenter = Object.assign({}, this.options.move.center),
|
|
3891
|
-
isCenterPercent = moveCenter.mode === "percent";
|
|
3892
|
-
this.moveCenter = {
|
|
3893
|
-
x: moveCenter.x * (isCenterPercent ? canvasSize.width / 100 : 1),
|
|
3894
|
-
y: moveCenter.y * (isCenterPercent ? canvasSize.height / 100 : 1),
|
|
3895
|
-
radius: (_f = this.options.move.center.radius) !== null && _f !== void 0 ? _f : 0,
|
|
3896
|
-
mode: (_g = this.options.move.center.mode) !== null && _g !== void 0 ? _g : "percent"
|
|
3897
|
-
};
|
|
3898
|
-
this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
|
|
3899
|
-
switch (this.options.move.direction) {
|
|
3900
|
-
case "inside":
|
|
3901
|
-
this.outType = "inside";
|
|
3902
|
-
break;
|
|
3903
|
-
case "outside":
|
|
3904
|
-
this.outType = "outside";
|
|
3905
|
-
break;
|
|
3906
|
-
}
|
|
3795
|
+
this._initPosition(position);
|
|
3907
3796
|
this.initialVelocity = this._calculateVelocity();
|
|
3908
3797
|
this.velocity = this.initialVelocity.copy();
|
|
3909
3798
|
this.moveDecay = 1 - getRangeValue(this.options.move.decay);
|
|
3910
|
-
this.offset = Vector.origin;
|
|
3911
3799
|
const particles = container.particles;
|
|
3912
3800
|
particles.needsSort = particles.needsSort || particles.lastZIndex < this.position.z;
|
|
3913
3801
|
particles.lastZIndex = this.position.z;
|
|
@@ -3933,13 +3821,13 @@ class Particle {
|
|
|
3933
3821
|
updater.init(this);
|
|
3934
3822
|
}
|
|
3935
3823
|
for (const mover of container.particles.movers) {
|
|
3936
|
-
(
|
|
3824
|
+
(_f = mover.init) === null || _f === void 0 ? void 0 : _f.call(mover, this);
|
|
3937
3825
|
}
|
|
3938
3826
|
if (drawer === null || drawer === void 0 ? void 0 : drawer.particleInit) {
|
|
3939
3827
|
drawer.particleInit(container, this);
|
|
3940
3828
|
}
|
|
3941
3829
|
for (const [, plugin] of container.plugins) {
|
|
3942
|
-
(
|
|
3830
|
+
(_g = plugin.particleCreated) === null || _g === void 0 ? void 0 : _g.call(plugin, this);
|
|
3943
3831
|
}
|
|
3944
3832
|
}
|
|
3945
3833
|
isInsideCanvas() {
|
|
@@ -4064,6 +3952,32 @@ class Particle {
|
|
|
4064
3952
|
}
|
|
4065
3953
|
return color;
|
|
4066
3954
|
}
|
|
3955
|
+
_initPosition(position) {
|
|
3956
|
+
var _a, _b;
|
|
3957
|
+
const container = this.container,
|
|
3958
|
+
zIndexValue = getRangeValue(this.options.zIndex.value);
|
|
3959
|
+
this.position = this._calcPosition(container, position, clamp(zIndexValue, 0, container.zLayers));
|
|
3960
|
+
this.initialPosition = this.position.copy();
|
|
3961
|
+
const canvasSize = container.canvas.size,
|
|
3962
|
+
moveCenter = Object.assign({}, this.options.move.center),
|
|
3963
|
+
isCenterPercent = moveCenter.mode === "percent";
|
|
3964
|
+
this.moveCenter = {
|
|
3965
|
+
x: moveCenter.x * (isCenterPercent ? canvasSize.width / 100 : 1),
|
|
3966
|
+
y: moveCenter.y * (isCenterPercent ? canvasSize.height / 100 : 1),
|
|
3967
|
+
radius: (_a = this.options.move.center.radius) !== null && _a !== void 0 ? _a : 0,
|
|
3968
|
+
mode: (_b = this.options.move.center.mode) !== null && _b !== void 0 ? _b : "percent"
|
|
3969
|
+
};
|
|
3970
|
+
this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
|
|
3971
|
+
switch (this.options.move.direction) {
|
|
3972
|
+
case "inside":
|
|
3973
|
+
this.outType = "inside";
|
|
3974
|
+
break;
|
|
3975
|
+
case "outside":
|
|
3976
|
+
this.outType = "outside";
|
|
3977
|
+
break;
|
|
3978
|
+
}
|
|
3979
|
+
this.offset = Vector.origin;
|
|
3980
|
+
}
|
|
4067
3981
|
_loadShapeData(shapeOptions, reduceDuplicates) {
|
|
4068
3982
|
const shapeData = shapeOptions.options[this.shape];
|
|
4069
3983
|
if (shapeData) {
|
|
@@ -4363,8 +4277,8 @@ class Particles {
|
|
|
4363
4277
|
}
|
|
4364
4278
|
particle.destroy(override);
|
|
4365
4279
|
this.array.splice(i--, 1);
|
|
4366
|
-
const
|
|
4367
|
-
this.zArray.splice(
|
|
4280
|
+
const idx = this.zArray.indexOf(particle);
|
|
4281
|
+
this.zArray.splice(idx, 1);
|
|
4368
4282
|
this.pool.push(particle);
|
|
4369
4283
|
deleted++;
|
|
4370
4284
|
this._engine.dispatchEvent("particleRemoved", {
|
|
@@ -4787,9 +4701,6 @@ class Container {
|
|
|
4787
4701
|
}
|
|
4788
4702
|
this.retina.init();
|
|
4789
4703
|
await this.canvas.init();
|
|
4790
|
-
this.updateActualOptions();
|
|
4791
|
-
this.canvas.initBackground();
|
|
4792
|
-
this.canvas.resize();
|
|
4793
4704
|
this.zLayers = this.actualOptions.zLayers;
|
|
4794
4705
|
this.duration = getRangeValue(this.actualOptions.duration) * 1000;
|
|
4795
4706
|
this._delay = getRangeValue(this.actualOptions.delay) * 1000;
|
|
@@ -4992,158 +4903,48 @@ class Container {
|
|
|
4992
4903
|
}
|
|
4993
4904
|
}
|
|
4994
4905
|
}
|
|
4995
|
-
;// CONCATENATED MODULE: ../../engine/dist/esm/
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
async function getDataFromUrl(jsonUrl, index) {
|
|
5001
|
-
const url = itemFromSingleOrMultiple(jsonUrl, index);
|
|
5002
|
-
if (!url) {
|
|
5003
|
-
return;
|
|
5004
|
-
}
|
|
5005
|
-
const response = await fetch(url);
|
|
5006
|
-
if (response.ok) {
|
|
5007
|
-
return response.json();
|
|
5008
|
-
}
|
|
5009
|
-
console.error(`tsParticles - Error ${response.status} while retrieving config file`);
|
|
5010
|
-
}
|
|
5011
|
-
class Loader {
|
|
5012
|
-
constructor(engine) {
|
|
5013
|
-
this._engine = engine;
|
|
4906
|
+
;// CONCATENATED MODULE: ../../engine/dist/esm/Utils/EventDispatcher.js
|
|
4907
|
+
class EventDispatcher {
|
|
4908
|
+
constructor() {
|
|
4909
|
+
this._listeners = new Map();
|
|
5014
4910
|
}
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
if (typeof tagId === "string") {
|
|
5021
|
-
params.tagId = tagId;
|
|
5022
|
-
} else {
|
|
5023
|
-
params.options = tagId;
|
|
5024
|
-
}
|
|
5025
|
-
if (typeof options === "number") {
|
|
5026
|
-
params.index = options;
|
|
5027
|
-
} else {
|
|
5028
|
-
params.options = options !== null && options !== void 0 ? options : params.options;
|
|
4911
|
+
addEventListener(type, listener) {
|
|
4912
|
+
var _a;
|
|
4913
|
+
this.removeEventListener(type, listener);
|
|
4914
|
+
if (!this._listeners.get(type)) {
|
|
4915
|
+
this._listeners.set(type, []);
|
|
5029
4916
|
}
|
|
5030
|
-
|
|
4917
|
+
(_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.push(listener);
|
|
5031
4918
|
}
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
url = tagId;
|
|
5036
|
-
} else {
|
|
5037
|
-
id = tagId;
|
|
5038
|
-
url = jsonUrl;
|
|
5039
|
-
}
|
|
5040
|
-
return this.loadRemoteOptions({
|
|
5041
|
-
tagId: id,
|
|
5042
|
-
url,
|
|
5043
|
-
index,
|
|
5044
|
-
remote: true
|
|
5045
|
-
});
|
|
4919
|
+
dispatchEvent(type, args) {
|
|
4920
|
+
var _a;
|
|
4921
|
+
(_a = this._listeners.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(handler => handler(args));
|
|
5046
4922
|
}
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
remote
|
|
5054
|
-
} = params,
|
|
5055
|
-
options = remote ? await getDataFromUrl(jsonUrl, index) : params.options;
|
|
5056
|
-
let domContainer = (_b = params.element) !== null && _b !== void 0 ? _b : document.getElementById(tagId);
|
|
5057
|
-
if (!domContainer) {
|
|
5058
|
-
domContainer = document.createElement("div");
|
|
5059
|
-
domContainer.id = tagId;
|
|
5060
|
-
(_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
|
|
5061
|
-
}
|
|
5062
|
-
const currentOptions = itemFromSingleOrMultiple(options, index),
|
|
5063
|
-
dom = this._engine.dom(),
|
|
5064
|
-
oldIndex = dom.findIndex(v => v.id === tagId);
|
|
5065
|
-
if (oldIndex >= 0) {
|
|
5066
|
-
const old = this._engine.domItem(oldIndex);
|
|
5067
|
-
if (old && !old.destroyed) {
|
|
5068
|
-
old.destroy();
|
|
5069
|
-
dom.splice(oldIndex, 1);
|
|
5070
|
-
}
|
|
5071
|
-
}
|
|
5072
|
-
let canvasEl;
|
|
5073
|
-
if (domContainer.tagName.toLowerCase() === "canvas") {
|
|
5074
|
-
canvasEl = domContainer;
|
|
5075
|
-
canvasEl.dataset[generatedAttribute] = "false";
|
|
5076
|
-
} else {
|
|
5077
|
-
const existingCanvases = domContainer.getElementsByTagName("canvas");
|
|
5078
|
-
if (existingCanvases.length) {
|
|
5079
|
-
canvasEl = existingCanvases[0];
|
|
5080
|
-
canvasEl.dataset[generatedAttribute] = "false";
|
|
5081
|
-
} else {
|
|
5082
|
-
canvasEl = document.createElement("canvas");
|
|
5083
|
-
canvasEl.dataset[generatedAttribute] = "true";
|
|
5084
|
-
domContainer.appendChild(canvasEl);
|
|
5085
|
-
}
|
|
5086
|
-
}
|
|
5087
|
-
if (!canvasEl.style.width) {
|
|
5088
|
-
canvasEl.style.width = "100%";
|
|
5089
|
-
}
|
|
5090
|
-
if (!canvasEl.style.height) {
|
|
5091
|
-
canvasEl.style.height = "100%";
|
|
5092
|
-
}
|
|
5093
|
-
const newItem = new Container(this._engine, tagId, currentOptions);
|
|
5094
|
-
if (oldIndex >= 0) {
|
|
5095
|
-
dom.splice(oldIndex, 0, newItem);
|
|
4923
|
+
hasEventListener(type) {
|
|
4924
|
+
return !!this._listeners.get(type);
|
|
4925
|
+
}
|
|
4926
|
+
removeAllEventListeners(type) {
|
|
4927
|
+
if (!type) {
|
|
4928
|
+
this._listeners = new Map();
|
|
5096
4929
|
} else {
|
|
5097
|
-
|
|
4930
|
+
this._listeners.delete(type);
|
|
5098
4931
|
}
|
|
5099
|
-
newItem.canvas.loadCanvas(canvasEl);
|
|
5100
|
-
await newItem.start();
|
|
5101
|
-
return newItem;
|
|
5102
4932
|
}
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
const params = {
|
|
5108
|
-
index,
|
|
5109
|
-
remote: false
|
|
5110
|
-
};
|
|
5111
|
-
if (typeof id === "string") {
|
|
5112
|
-
params.tagId = id;
|
|
5113
|
-
} else {
|
|
5114
|
-
params.element = id;
|
|
4933
|
+
removeEventListener(type, listener) {
|
|
4934
|
+
const arr = this._listeners.get(type);
|
|
4935
|
+
if (!arr) {
|
|
4936
|
+
return;
|
|
5115
4937
|
}
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
4938
|
+
const length = arr.length,
|
|
4939
|
+
idx = arr.indexOf(listener);
|
|
4940
|
+
if (idx < 0) {
|
|
4941
|
+
return;
|
|
5120
4942
|
}
|
|
5121
|
-
if (
|
|
5122
|
-
|
|
4943
|
+
if (length === 1) {
|
|
4944
|
+
this._listeners.delete(type);
|
|
5123
4945
|
} else {
|
|
5124
|
-
|
|
4946
|
+
arr.splice(idx, 1);
|
|
5125
4947
|
}
|
|
5126
|
-
return this.loadOptions(params);
|
|
5127
|
-
}
|
|
5128
|
-
async setJSON(id, domContainer, jsonUrl, index) {
|
|
5129
|
-
let url, newId, newIndex, element;
|
|
5130
|
-
if (id instanceof HTMLElement) {
|
|
5131
|
-
element = id;
|
|
5132
|
-
url = domContainer;
|
|
5133
|
-
newIndex = jsonUrl;
|
|
5134
|
-
} else {
|
|
5135
|
-
newId = id;
|
|
5136
|
-
element = domContainer;
|
|
5137
|
-
url = jsonUrl;
|
|
5138
|
-
newIndex = index;
|
|
5139
|
-
}
|
|
5140
|
-
return this.loadRemoteOptions({
|
|
5141
|
-
tagId: newId,
|
|
5142
|
-
url,
|
|
5143
|
-
index: newIndex,
|
|
5144
|
-
element,
|
|
5145
|
-
remote: true
|
|
5146
|
-
});
|
|
5147
4948
|
}
|
|
5148
4949
|
}
|
|
5149
4950
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Plugins.js
|
|
@@ -5263,14 +5064,46 @@ class Plugins {
|
|
|
5263
5064
|
|
|
5264
5065
|
|
|
5265
5066
|
|
|
5067
|
+
|
|
5068
|
+
|
|
5069
|
+
|
|
5070
|
+
async function getDataFromUrl(data) {
|
|
5071
|
+
const url = itemFromSingleOrMultiple(data.url, data.index);
|
|
5072
|
+
if (!url) {
|
|
5073
|
+
return data.fallback;
|
|
5074
|
+
}
|
|
5075
|
+
const response = await fetch(url);
|
|
5076
|
+
if (response.ok) {
|
|
5077
|
+
return response.json();
|
|
5078
|
+
}
|
|
5079
|
+
console.error(`tsParticles - Error ${response.status} while retrieving config file`);
|
|
5080
|
+
return data.fallback;
|
|
5081
|
+
}
|
|
5266
5082
|
class Engine {
|
|
5267
5083
|
constructor() {
|
|
5084
|
+
this._configs = new Map();
|
|
5268
5085
|
this._domArray = [];
|
|
5269
5086
|
this._eventDispatcher = new EventDispatcher();
|
|
5270
|
-
this._initialized = false;
|
|
5271
|
-
this._loader = new Loader(this);
|
|
5272
5087
|
this.plugins = new Plugins(this);
|
|
5273
5088
|
}
|
|
5089
|
+
get configs() {
|
|
5090
|
+
const res = {};
|
|
5091
|
+
for (const [name, config] of this._configs) {
|
|
5092
|
+
res[name] = config;
|
|
5093
|
+
}
|
|
5094
|
+
return res;
|
|
5095
|
+
}
|
|
5096
|
+
addConfig(nameOrConfig, config) {
|
|
5097
|
+
var _a;
|
|
5098
|
+
if (typeof nameOrConfig === "string") {
|
|
5099
|
+
if (config) {
|
|
5100
|
+
config.name = nameOrConfig;
|
|
5101
|
+
this._configs.set(nameOrConfig, config);
|
|
5102
|
+
}
|
|
5103
|
+
} else {
|
|
5104
|
+
this._configs.set((_a = nameOrConfig.name) !== null && _a !== void 0 ? _a : "default", nameOrConfig);
|
|
5105
|
+
}
|
|
5106
|
+
}
|
|
5274
5107
|
addEventListener(type, listener) {
|
|
5275
5108
|
this._eventDispatcher.addEventListener(type, listener);
|
|
5276
5109
|
}
|
|
@@ -5327,19 +5160,64 @@ class Engine {
|
|
|
5327
5160
|
}
|
|
5328
5161
|
dom.splice(index, 1);
|
|
5329
5162
|
}
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5163
|
+
async load(params) {
|
|
5164
|
+
var _a, _b, _c;
|
|
5165
|
+
const id = (_a = params.id) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(getRandom() * 10000)}`,
|
|
5166
|
+
{
|
|
5167
|
+
index,
|
|
5168
|
+
url
|
|
5169
|
+
} = params,
|
|
5170
|
+
options = url ? await getDataFromUrl({
|
|
5171
|
+
fallback: params.options,
|
|
5172
|
+
index,
|
|
5173
|
+
url: url
|
|
5174
|
+
}) : params.options;
|
|
5175
|
+
let domContainer = (_b = params.element) !== null && _b !== void 0 ? _b : document.getElementById(id);
|
|
5176
|
+
if (!domContainer) {
|
|
5177
|
+
domContainer = document.createElement("div");
|
|
5178
|
+
domContainer.id = id;
|
|
5179
|
+
(_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
|
|
5333
5180
|
}
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5181
|
+
const currentOptions = itemFromSingleOrMultiple(options, index),
|
|
5182
|
+
dom = this.dom(),
|
|
5183
|
+
oldIndex = dom.findIndex(v => v.id === id);
|
|
5184
|
+
if (oldIndex >= 0) {
|
|
5185
|
+
const old = this.domItem(oldIndex);
|
|
5186
|
+
if (old && !old.destroyed) {
|
|
5187
|
+
old.destroy();
|
|
5188
|
+
dom.splice(oldIndex, 1);
|
|
5189
|
+
}
|
|
5190
|
+
}
|
|
5191
|
+
let canvasEl;
|
|
5192
|
+
if (domContainer.tagName.toLowerCase() === "canvas") {
|
|
5193
|
+
canvasEl = domContainer;
|
|
5194
|
+
canvasEl.dataset[generatedAttribute] = "false";
|
|
5195
|
+
} else {
|
|
5196
|
+
const existingCanvases = domContainer.getElementsByTagName("canvas");
|
|
5197
|
+
if (existingCanvases.length) {
|
|
5198
|
+
canvasEl = existingCanvases[0];
|
|
5199
|
+
canvasEl.dataset[generatedAttribute] = "false";
|
|
5200
|
+
} else {
|
|
5201
|
+
canvasEl = document.createElement("canvas");
|
|
5202
|
+
canvasEl.dataset[generatedAttribute] = "true";
|
|
5203
|
+
domContainer.appendChild(canvasEl);
|
|
5204
|
+
}
|
|
5205
|
+
}
|
|
5206
|
+
if (!canvasEl.style.width) {
|
|
5207
|
+
canvasEl.style.width = "100%";
|
|
5208
|
+
}
|
|
5209
|
+
if (!canvasEl.style.height) {
|
|
5210
|
+
canvasEl.style.height = "100%";
|
|
5211
|
+
}
|
|
5212
|
+
const newItem = new Container(this, id, currentOptions);
|
|
5213
|
+
if (oldIndex >= 0) {
|
|
5214
|
+
dom.splice(oldIndex, 0, newItem);
|
|
5215
|
+
} else {
|
|
5216
|
+
dom.push(newItem);
|
|
5217
|
+
}
|
|
5218
|
+
newItem.canvas.loadCanvas(canvasEl);
|
|
5219
|
+
await newItem.start();
|
|
5220
|
+
return newItem;
|
|
5343
5221
|
}
|
|
5344
5222
|
async refresh() {
|
|
5345
5223
|
for (const instance of this.dom()) {
|
|
@@ -5349,16 +5227,10 @@ class Engine {
|
|
|
5349
5227
|
removeEventListener(type, listener) {
|
|
5350
5228
|
this._eventDispatcher.removeEventListener(type, listener);
|
|
5351
5229
|
}
|
|
5352
|
-
async set(id, element, options) {
|
|
5353
|
-
return this._loader.set(id, element, options);
|
|
5354
|
-
}
|
|
5355
|
-
async setJSON(id, element, pathConfigJson, index) {
|
|
5356
|
-
return this._loader.setJSON(id, element, pathConfigJson, index);
|
|
5357
|
-
}
|
|
5358
5230
|
setOnClickHandler(callback) {
|
|
5359
5231
|
const dom = this.dom();
|
|
5360
5232
|
if (!dom.length) {
|
|
5361
|
-
throw new Error("Can only set click handlers after calling tsParticles.load()
|
|
5233
|
+
throw new Error("Can only set click handlers after calling tsParticles.load()");
|
|
5362
5234
|
}
|
|
5363
5235
|
for (const domItem of dom) {
|
|
5364
5236
|
domItem.addClickHandler(callback);
|
|
@@ -5472,7 +5344,14 @@ const rgbColorManager = new RgbColorManager(),
|
|
|
5472
5344
|
addColorManager(rgbColorManager);
|
|
5473
5345
|
addColorManager(hslColorManager);
|
|
5474
5346
|
const tsParticles = new Engine();
|
|
5475
|
-
|
|
5347
|
+
|
|
5348
|
+
|
|
5349
|
+
|
|
5350
|
+
|
|
5351
|
+
|
|
5352
|
+
|
|
5353
|
+
|
|
5354
|
+
|
|
5476
5355
|
|
|
5477
5356
|
|
|
5478
5357
|
|
|
@@ -7163,10 +7042,16 @@ async function loadRollUpdater(engine) {
|
|
|
7163
7042
|
;// CONCATENATED MODULE: ../pjs/dist/esm/index.js
|
|
7164
7043
|
const initPjs = engine => {
|
|
7165
7044
|
const particlesJS = (tagId, options) => {
|
|
7166
|
-
return engine.load(
|
|
7045
|
+
return engine.load({
|
|
7046
|
+
id: tagId,
|
|
7047
|
+
options: options
|
|
7048
|
+
});
|
|
7167
7049
|
};
|
|
7168
7050
|
particlesJS.load = (tagId, pathConfigJson, callback) => {
|
|
7169
|
-
engine.
|
|
7051
|
+
engine.load({
|
|
7052
|
+
id: tagId,
|
|
7053
|
+
url: pathConfigJson
|
|
7054
|
+
}).then(container => {
|
|
7170
7055
|
if (container) {
|
|
7171
7056
|
callback(container);
|
|
7172
7057
|
}
|
|
@@ -9683,42 +9568,14 @@ class OpacityUpdater {
|
|
|
9683
9568
|
}
|
|
9684
9569
|
init(particle) {
|
|
9685
9570
|
const opacityOptions = particle.options.opacity;
|
|
9686
|
-
particle.opacity =
|
|
9687
|
-
enable: opacityOptions.animation.enable,
|
|
9688
|
-
max: getRangeMax(opacityOptions.value),
|
|
9689
|
-
min: getRangeMin(opacityOptions.value),
|
|
9690
|
-
value: getRangeValue(opacityOptions.value),
|
|
9691
|
-
loops: 0,
|
|
9692
|
-
maxLoops: getRangeValue(opacityOptions.animation.count)
|
|
9693
|
-
};
|
|
9571
|
+
particle.opacity = initParticleNumericAnimationValue(opacityOptions, 1);
|
|
9694
9572
|
const opacityAnimation = opacityOptions.animation;
|
|
9695
9573
|
if (opacityAnimation.enable) {
|
|
9696
|
-
particle.opacity.decay = 1 - getRangeValue(opacityAnimation.decay);
|
|
9697
|
-
particle.opacity.status = "increasing";
|
|
9698
|
-
const opacityRange = opacityOptions.value;
|
|
9699
|
-
particle.opacity.min = getRangeMin(opacityRange);
|
|
9700
|
-
particle.opacity.max = getRangeMax(opacityRange);
|
|
9701
|
-
switch (opacityAnimation.startValue) {
|
|
9702
|
-
case "min":
|
|
9703
|
-
particle.opacity.value = particle.opacity.min;
|
|
9704
|
-
particle.opacity.status = "increasing";
|
|
9705
|
-
break;
|
|
9706
|
-
case "random":
|
|
9707
|
-
particle.opacity.value = randomInRange(particle.opacity);
|
|
9708
|
-
particle.opacity.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
9709
|
-
break;
|
|
9710
|
-
case "max":
|
|
9711
|
-
default:
|
|
9712
|
-
particle.opacity.value = particle.opacity.max;
|
|
9713
|
-
particle.opacity.status = "decreasing";
|
|
9714
|
-
break;
|
|
9715
|
-
}
|
|
9716
9574
|
particle.opacity.velocity = getRangeValue(opacityAnimation.speed) / 100 * this.container.retina.reduceFactor;
|
|
9717
9575
|
if (!opacityAnimation.sync) {
|
|
9718
9576
|
particle.opacity.velocity *= getRandom();
|
|
9719
9577
|
}
|
|
9720
9578
|
}
|
|
9721
|
-
particle.opacity.initialValue = particle.opacity.value;
|
|
9722
9579
|
}
|
|
9723
9580
|
isEnabled(particle) {
|
|
9724
9581
|
var _a, _b, _c, _d;
|