@tsparticles/slim 3.0.0-beta.2 → 3.0.0-beta.4
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/browser/index.js +1 -1
- package/cjs/index.js +2 -2
- package/esm/index.js +1 -1
- package/package.json +34 -34
- package/report.html +4 -22
- package/tsparticles.slim.bundle.js +617 -425
- package/tsparticles.slim.bundle.min.js +1 -1
- package/tsparticles.slim.bundle.min.js.LICENSE.txt +1 -1
- package/tsparticles.slim.js +106 -438
- package/tsparticles.slim.min.js +1 -1
- package/tsparticles.slim.min.js.LICENSE.txt +1 -1
- package/umd/index.js +3 -3
|
@@ -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.0.0-beta.
|
|
7
|
+
* v3.0.0-beta.4
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -97,6 +97,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
97
97
|
ParticlesDensity: () => (/* reexport */ ParticlesDensity),
|
|
98
98
|
ParticlesInteractorBase: () => (/* reexport */ ParticlesInteractorBase),
|
|
99
99
|
ParticlesNumber: () => (/* reexport */ ParticlesNumber),
|
|
100
|
+
ParticlesNumberLimit: () => (/* reexport */ ParticlesNumberLimit),
|
|
100
101
|
ParticlesOptions: () => (/* reexport */ ParticlesOptions),
|
|
101
102
|
Point: () => (/* reexport */ Point),
|
|
102
103
|
Range: () => (/* reexport */ Range),
|
|
@@ -140,13 +141,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
140
141
|
deepExtend: () => (/* reexport */ deepExtend),
|
|
141
142
|
divMode: () => (/* reexport */ divMode),
|
|
142
143
|
divModeExecute: () => (/* reexport */ divModeExecute),
|
|
144
|
+
drawEffect: () => (/* reexport */ drawEffect),
|
|
143
145
|
drawLine: () => (/* reexport */ drawLine),
|
|
144
146
|
drawParticle: () => (/* reexport */ drawParticle),
|
|
145
147
|
drawParticlePlugin: () => (/* reexport */ drawParticlePlugin),
|
|
146
148
|
drawPlugin: () => (/* reexport */ drawPlugin),
|
|
147
149
|
drawShape: () => (/* reexport */ drawShape),
|
|
148
|
-
|
|
149
|
-
drawTriangle: () => (/* reexport */ drawTriangle),
|
|
150
|
+
drawShapeAfterDraw: () => (/* reexport */ drawShapeAfterDraw),
|
|
150
151
|
errorPrefix: () => (/* reexport */ errorPrefix),
|
|
151
152
|
executeOnSingleOrMultiple: () => (/* reexport */ executeOnSingleOrMultiple),
|
|
152
153
|
findItemFromSingleOrMultiple: () => (/* reexport */ findItemFromSingleOrMultiple),
|
|
@@ -170,7 +171,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
170
171
|
getSize: () => (/* reexport */ getSize),
|
|
171
172
|
getStyleFromHsl: () => (/* reexport */ getStyleFromHsl),
|
|
172
173
|
getStyleFromRgb: () => (/* reexport */ getStyleFromRgb),
|
|
173
|
-
getValue: () => (/* reexport */ getValue),
|
|
174
174
|
hasMatchMedia: () => (/* reexport */ hasMatchMedia),
|
|
175
175
|
hslToRgb: () => (/* reexport */ hslToRgb),
|
|
176
176
|
hslaToRgba: () => (/* reexport */ hslaToRgba),
|
|
@@ -206,6 +206,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
206
206
|
rectBounce: () => (/* reexport */ rectBounce),
|
|
207
207
|
resizeEvent: () => (/* reexport */ resizeEvent),
|
|
208
208
|
rgbToHsl: () => (/* reexport */ rgbToHsl),
|
|
209
|
+
safeIntersectionObserver: () => (/* reexport */ safeIntersectionObserver),
|
|
209
210
|
safeMatchMedia: () => (/* reexport */ safeMatchMedia),
|
|
210
211
|
safeMutationObserver: () => (/* reexport */ safeMutationObserver),
|
|
211
212
|
setLogger: () => (/* reexport */ setLogger),
|
|
@@ -409,17 +410,6 @@ function setRangeValue(source, value) {
|
|
|
409
410
|
max: Math.max(max, value)
|
|
410
411
|
} : setRangeValue(min, max);
|
|
411
412
|
}
|
|
412
|
-
function getValue(options) {
|
|
413
|
-
const random = options.random,
|
|
414
|
-
{
|
|
415
|
-
enable,
|
|
416
|
-
minimumValue
|
|
417
|
-
} = isBoolean(random) ? {
|
|
418
|
-
enable: random,
|
|
419
|
-
minimumValue: 0
|
|
420
|
-
} : random;
|
|
421
|
-
return enable ? getRangeValue(setRangeValue(options.value, minimumValue)) : getRangeValue(options.value);
|
|
422
|
-
}
|
|
423
413
|
function getDistances(pointA, pointB) {
|
|
424
414
|
const dx = pointA.x - pointB.x,
|
|
425
415
|
dy = pointA.y - pointB.y;
|
|
@@ -438,21 +428,21 @@ function getParticleDirectionAngle(direction, position, center) {
|
|
|
438
428
|
}
|
|
439
429
|
switch (direction) {
|
|
440
430
|
case "top":
|
|
441
|
-
return -Math.PI
|
|
431
|
+
return -Math.PI * 0.5;
|
|
442
432
|
case "top-right":
|
|
443
|
-
return -Math.PI
|
|
433
|
+
return -Math.PI * 0.25;
|
|
444
434
|
case "right":
|
|
445
435
|
return 0;
|
|
446
436
|
case "bottom-right":
|
|
447
|
-
return Math.PI
|
|
437
|
+
return Math.PI * 0.25;
|
|
448
438
|
case "bottom":
|
|
449
|
-
return Math.PI
|
|
439
|
+
return Math.PI * 0.5;
|
|
450
440
|
case "bottom-left":
|
|
451
|
-
return
|
|
441
|
+
return Math.PI * 0.75;
|
|
452
442
|
case "left":
|
|
453
443
|
return Math.PI;
|
|
454
444
|
case "top-left":
|
|
455
|
-
return -
|
|
445
|
+
return -Math.PI * 0.75;
|
|
456
446
|
case "inside":
|
|
457
447
|
return Math.atan2(center.y - position.y, center.x - position.x);
|
|
458
448
|
case "outside":
|
|
@@ -548,7 +538,7 @@ function rectSideBounce(data) {
|
|
|
548
538
|
if (pOtherSide.min < rectOtherSide.min || pOtherSide.min > rectOtherSide.max || pOtherSide.max < rectOtherSide.min || pOtherSide.max > rectOtherSide.max) {
|
|
549
539
|
return res;
|
|
550
540
|
}
|
|
551
|
-
if (pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min)
|
|
541
|
+
if (pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * 0.5 && velocity > 0 || pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * 0.5 && velocity < 0) {
|
|
552
542
|
res.velocity = velocity * -factor;
|
|
553
543
|
res.bounced = true;
|
|
554
544
|
}
|
|
@@ -572,6 +562,12 @@ function safeMatchMedia(query) {
|
|
|
572
562
|
}
|
|
573
563
|
return matchMedia(query);
|
|
574
564
|
}
|
|
565
|
+
function safeIntersectionObserver(callback) {
|
|
566
|
+
if (isSsr() || typeof IntersectionObserver === "undefined") {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
return new IntersectionObserver(callback);
|
|
570
|
+
}
|
|
575
571
|
function safeMutationObserver(callback) {
|
|
576
572
|
if (isSsr() || typeof MutationObserver === "undefined") {
|
|
577
573
|
return;
|
|
@@ -678,7 +674,7 @@ function circleBounceDataFromParticle(p) {
|
|
|
678
674
|
radius: p.getRadius(),
|
|
679
675
|
mass: p.getMass(),
|
|
680
676
|
velocity: p.velocity,
|
|
681
|
-
factor: Vector.create(
|
|
677
|
+
factor: Vector.create(getRangeValue(p.options.bounce.horizontal.value), getRangeValue(p.options.bounce.vertical.value))
|
|
682
678
|
};
|
|
683
679
|
}
|
|
684
680
|
function circleBounce(p1, p2) {
|
|
@@ -712,6 +708,7 @@ function rectBounce(particle, divBounds) {
|
|
|
712
708
|
const pPos = particle.getPosition(),
|
|
713
709
|
size = particle.getRadius(),
|
|
714
710
|
bounds = calculateBounds(pPos, size),
|
|
711
|
+
bounceOptions = particle.options.bounce,
|
|
715
712
|
resH = rectSideBounce({
|
|
716
713
|
pSide: {
|
|
717
714
|
min: bounds.left,
|
|
@@ -730,7 +727,7 @@ function rectBounce(particle, divBounds) {
|
|
|
730
727
|
max: divBounds.bottom
|
|
731
728
|
},
|
|
732
729
|
velocity: particle.velocity.x,
|
|
733
|
-
factor:
|
|
730
|
+
factor: getRangeValue(bounceOptions.horizontal.value)
|
|
734
731
|
});
|
|
735
732
|
if (resH.bounced) {
|
|
736
733
|
if (resH.velocity !== undefined) {
|
|
@@ -758,7 +755,7 @@ function rectBounce(particle, divBounds) {
|
|
|
758
755
|
max: divBounds.right
|
|
759
756
|
},
|
|
760
757
|
velocity: particle.velocity.y,
|
|
761
|
-
factor:
|
|
758
|
+
factor: getRangeValue(bounceOptions.vertical.value)
|
|
762
759
|
});
|
|
763
760
|
if (resV.bounced) {
|
|
764
761
|
if (resV.velocity !== undefined) {
|
|
@@ -885,24 +882,6 @@ const randomColorValue = "random",
|
|
|
885
882
|
function addColorManager(manager) {
|
|
886
883
|
colorManagers.set(manager.key, manager);
|
|
887
884
|
}
|
|
888
|
-
function hue2rgb(p, q, t) {
|
|
889
|
-
if (t < 0) {
|
|
890
|
-
t += 1;
|
|
891
|
-
}
|
|
892
|
-
if (t > 1) {
|
|
893
|
-
t -= 1;
|
|
894
|
-
}
|
|
895
|
-
if (t < 1 / 6) {
|
|
896
|
-
return p + (q - p) * 6 * t;
|
|
897
|
-
}
|
|
898
|
-
if (t < 1 / 2) {
|
|
899
|
-
return q;
|
|
900
|
-
}
|
|
901
|
-
if (t < 2 / 3) {
|
|
902
|
-
return p + (q - p) * (2 / 3 - t) * 6;
|
|
903
|
-
}
|
|
904
|
-
return p;
|
|
905
|
-
}
|
|
906
885
|
function stringToRgba(input) {
|
|
907
886
|
for (const [, manager] of colorManagers) {
|
|
908
887
|
if (input.startsWith(manager.stringPrefix)) {
|
|
@@ -982,7 +961,7 @@ function rgbToHsl(color) {
|
|
|
982
961
|
min = Math.min(r1, g1, b1),
|
|
983
962
|
res = {
|
|
984
963
|
h: 0,
|
|
985
|
-
l: (max + min)
|
|
964
|
+
l: (max + min) * 0.5,
|
|
986
965
|
s: 0
|
|
987
966
|
};
|
|
988
967
|
if (max !== min) {
|
|
@@ -1007,29 +986,48 @@ function stringToRgb(input) {
|
|
|
1007
986
|
return stringToRgba(input);
|
|
1008
987
|
}
|
|
1009
988
|
function hslToRgb(hsl) {
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
989
|
+
const h = (hsl.h % 360 + 360) % 360,
|
|
990
|
+
s = Math.max(0, Math.min(100, hsl.s)),
|
|
991
|
+
l = Math.max(0, Math.min(100, hsl.l)),
|
|
992
|
+
hNormalized = h / 360,
|
|
993
|
+
sNormalized = s / 100,
|
|
994
|
+
lNormalized = l / 100;
|
|
995
|
+
if (s === 0) {
|
|
996
|
+
const grayscaleValue = Math.round(lNormalized * 255);
|
|
997
|
+
return {
|
|
998
|
+
r: grayscaleValue,
|
|
999
|
+
g: grayscaleValue,
|
|
1000
|
+
b: grayscaleValue
|
|
1019
1001
|
};
|
|
1020
|
-
if (!hslPercent.s) {
|
|
1021
|
-
result.r = result.g = result.b = hslPercent.l;
|
|
1022
|
-
} else {
|
|
1023
|
-
const q = hslPercent.l < 0.5 ? hslPercent.l * (1 + hslPercent.s) : hslPercent.l + hslPercent.s - hslPercent.l * hslPercent.s,
|
|
1024
|
-
p = 2 * hslPercent.l - q;
|
|
1025
|
-
result.r = hue2rgb(p, q, hslPercent.h + 1 / 3);
|
|
1026
|
-
result.g = hue2rgb(p, q, hslPercent.h);
|
|
1027
|
-
result.b = hue2rgb(p, q, hslPercent.h - 1 / 3);
|
|
1028
1002
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1003
|
+
const channel = (temp1, temp2, temp3) => {
|
|
1004
|
+
if (temp3 < 0) {
|
|
1005
|
+
temp3 += 1;
|
|
1006
|
+
}
|
|
1007
|
+
if (temp3 > 1) {
|
|
1008
|
+
temp3 -= 1;
|
|
1009
|
+
}
|
|
1010
|
+
if (temp3 * 6 < 1) {
|
|
1011
|
+
return temp1 + (temp2 - temp1) * 6 * temp3;
|
|
1012
|
+
}
|
|
1013
|
+
if (temp3 * 2 < 1) {
|
|
1014
|
+
return temp2;
|
|
1015
|
+
}
|
|
1016
|
+
if (temp3 * 3 < 2) {
|
|
1017
|
+
return temp1 + (temp2 - temp1) * (2 / 3 - temp3) * 6;
|
|
1018
|
+
}
|
|
1019
|
+
return temp1;
|
|
1020
|
+
},
|
|
1021
|
+
temp1 = lNormalized < 0.5 ? lNormalized * (1 + sNormalized) : lNormalized + sNormalized - lNormalized * sNormalized,
|
|
1022
|
+
temp2 = 2 * lNormalized - temp1,
|
|
1023
|
+
red = Math.min(255, 255 * channel(temp2, temp1, hNormalized + 1 / 3)),
|
|
1024
|
+
green = Math.min(255, 255 * channel(temp2, temp1, hNormalized)),
|
|
1025
|
+
blue = Math.min(255, 255 * channel(temp2, temp1, hNormalized - 1 / 3));
|
|
1026
|
+
return {
|
|
1027
|
+
r: Math.round(red),
|
|
1028
|
+
g: Math.round(green),
|
|
1029
|
+
b: Math.round(blue)
|
|
1030
|
+
};
|
|
1033
1031
|
}
|
|
1034
1032
|
function hslaToRgba(hsla) {
|
|
1035
1033
|
const rgbResult = hslToRgb(hsla);
|
|
@@ -1163,13 +1161,6 @@ function drawLine(context, begin, end) {
|
|
|
1163
1161
|
context.lineTo(end.x, end.y);
|
|
1164
1162
|
context.closePath();
|
|
1165
1163
|
}
|
|
1166
|
-
function drawTriangle(context, p1, p2, p3) {
|
|
1167
|
-
context.beginPath();
|
|
1168
|
-
context.moveTo(p1.x, p1.y);
|
|
1169
|
-
context.lineTo(p2.x, p2.y);
|
|
1170
|
-
context.lineTo(p3.x, p3.y);
|
|
1171
|
-
context.closePath();
|
|
1172
|
-
}
|
|
1173
1164
|
function paintBase(context, dimension, baseColor) {
|
|
1174
1165
|
context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|
|
1175
1166
|
context.fillRect(0, 0, dimension.width, dimension.height);
|
|
@@ -1212,7 +1203,6 @@ function drawParticle(data) {
|
|
|
1212
1203
|
d: rotateData.cos * (transform.d ?? 1)
|
|
1213
1204
|
};
|
|
1214
1205
|
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
1215
|
-
context.beginPath();
|
|
1216
1206
|
if (backgroundMask) {
|
|
1217
1207
|
context.globalCompositeOperation = composite;
|
|
1218
1208
|
}
|
|
@@ -1231,39 +1221,104 @@ function drawParticle(data) {
|
|
|
1231
1221
|
if (colorStyles.stroke) {
|
|
1232
1222
|
context.strokeStyle = colorStyles.stroke;
|
|
1233
1223
|
}
|
|
1234
|
-
|
|
1224
|
+
const drawData = {
|
|
1225
|
+
container,
|
|
1226
|
+
context,
|
|
1227
|
+
particle,
|
|
1228
|
+
radius,
|
|
1229
|
+
opacity,
|
|
1230
|
+
delta
|
|
1231
|
+
};
|
|
1232
|
+
context.beginPath();
|
|
1233
|
+
drawShape(drawData);
|
|
1234
|
+
if (particle.shapeClose) {
|
|
1235
|
+
context.closePath();
|
|
1236
|
+
}
|
|
1235
1237
|
if (strokeWidth > 0) {
|
|
1236
1238
|
context.stroke();
|
|
1237
1239
|
}
|
|
1238
|
-
if (particle.
|
|
1239
|
-
context.closePath();
|
|
1240
|
-
}
|
|
1241
|
-
if (particle.fill) {
|
|
1240
|
+
if (particle.shapeFill) {
|
|
1242
1241
|
context.fill();
|
|
1243
1242
|
}
|
|
1244
|
-
|
|
1243
|
+
drawShapeAfterDraw(drawData);
|
|
1244
|
+
drawEffect(drawData);
|
|
1245
1245
|
context.globalCompositeOperation = "source-over";
|
|
1246
1246
|
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
1247
1247
|
}
|
|
1248
|
-
function
|
|
1248
|
+
function drawEffect(data) {
|
|
1249
|
+
const {
|
|
1250
|
+
container,
|
|
1251
|
+
context,
|
|
1252
|
+
particle,
|
|
1253
|
+
radius,
|
|
1254
|
+
opacity,
|
|
1255
|
+
delta
|
|
1256
|
+
} = data;
|
|
1257
|
+
if (!particle.effect) {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
const drawer = container.effectDrawers.get(particle.effect);
|
|
1261
|
+
if (!drawer) {
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
drawer.draw({
|
|
1265
|
+
context,
|
|
1266
|
+
particle,
|
|
1267
|
+
radius,
|
|
1268
|
+
opacity,
|
|
1269
|
+
delta,
|
|
1270
|
+
pixelRatio: container.retina.pixelRatio
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
function drawShape(data) {
|
|
1274
|
+
const {
|
|
1275
|
+
container,
|
|
1276
|
+
context,
|
|
1277
|
+
particle,
|
|
1278
|
+
radius,
|
|
1279
|
+
opacity,
|
|
1280
|
+
delta
|
|
1281
|
+
} = data;
|
|
1249
1282
|
if (!particle.shape) {
|
|
1250
1283
|
return;
|
|
1251
1284
|
}
|
|
1252
|
-
const drawer = container.
|
|
1285
|
+
const drawer = container.shapeDrawers.get(particle.shape);
|
|
1253
1286
|
if (!drawer) {
|
|
1254
1287
|
return;
|
|
1255
1288
|
}
|
|
1256
|
-
drawer.draw(
|
|
1289
|
+
drawer.draw({
|
|
1290
|
+
context,
|
|
1291
|
+
particle,
|
|
1292
|
+
radius,
|
|
1293
|
+
opacity,
|
|
1294
|
+
delta,
|
|
1295
|
+
pixelRatio: container.retina.pixelRatio
|
|
1296
|
+
});
|
|
1257
1297
|
}
|
|
1258
|
-
function
|
|
1298
|
+
function drawShapeAfterDraw(data) {
|
|
1299
|
+
const {
|
|
1300
|
+
container,
|
|
1301
|
+
context,
|
|
1302
|
+
particle,
|
|
1303
|
+
radius,
|
|
1304
|
+
opacity,
|
|
1305
|
+
delta
|
|
1306
|
+
} = data;
|
|
1259
1307
|
if (!particle.shape) {
|
|
1260
1308
|
return;
|
|
1261
1309
|
}
|
|
1262
|
-
const drawer = container.
|
|
1263
|
-
if (!drawer || !drawer.
|
|
1310
|
+
const drawer = container.shapeDrawers.get(particle.shape);
|
|
1311
|
+
if (!drawer || !drawer.afterDraw) {
|
|
1264
1312
|
return;
|
|
1265
1313
|
}
|
|
1266
|
-
drawer.
|
|
1314
|
+
drawer.afterDraw({
|
|
1315
|
+
context,
|
|
1316
|
+
particle,
|
|
1317
|
+
radius,
|
|
1318
|
+
opacity,
|
|
1319
|
+
delta,
|
|
1320
|
+
pixelRatio: container.retina.pixelRatio
|
|
1321
|
+
});
|
|
1267
1322
|
}
|
|
1268
1323
|
function drawPlugin(context, plugin, delta) {
|
|
1269
1324
|
if (!plugin.draw) {
|
|
@@ -1710,10 +1765,10 @@ class Canvas {
|
|
|
1710
1765
|
this.element.width = size.width = this.element.offsetWidth * pxRatio;
|
|
1711
1766
|
this.element.height = size.height = this.element.offsetHeight * pxRatio;
|
|
1712
1767
|
if (this.container.started) {
|
|
1713
|
-
|
|
1768
|
+
container.particles.setResizeFactor({
|
|
1714
1769
|
width: size.width / oldSize.width,
|
|
1715
1770
|
height: size.height / oldSize.height
|
|
1716
|
-
};
|
|
1771
|
+
});
|
|
1717
1772
|
}
|
|
1718
1773
|
return true;
|
|
1719
1774
|
}
|
|
@@ -2183,10 +2238,10 @@ class BackgroundMask {
|
|
|
2183
2238
|
this.composite = data.composite;
|
|
2184
2239
|
}
|
|
2185
2240
|
if (data.cover !== undefined) {
|
|
2186
|
-
const cover = data.cover
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2241
|
+
const cover = data.cover,
|
|
2242
|
+
color = isString(data.cover) ? {
|
|
2243
|
+
color: data.cover
|
|
2244
|
+
} : data.cover;
|
|
2190
2245
|
this.cover.load(cover.color !== undefined ? cover : {
|
|
2191
2246
|
color: color
|
|
2192
2247
|
});
|
|
@@ -2488,17 +2543,16 @@ class Theme {
|
|
|
2488
2543
|
}
|
|
2489
2544
|
}
|
|
2490
2545
|
}
|
|
2491
|
-
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/
|
|
2546
|
+
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/AnimationOptions.js
|
|
2492
2547
|
|
|
2493
|
-
class
|
|
2548
|
+
class AnimationOptions {
|
|
2494
2549
|
constructor() {
|
|
2495
2550
|
this.count = 0;
|
|
2496
2551
|
this.enable = false;
|
|
2497
|
-
this.offset = 0;
|
|
2498
2552
|
this.speed = 1;
|
|
2499
|
-
this.delay = 0;
|
|
2500
2553
|
this.decay = 0;
|
|
2501
|
-
this.
|
|
2554
|
+
this.delay = 0;
|
|
2555
|
+
this.sync = false;
|
|
2502
2556
|
}
|
|
2503
2557
|
load(data) {
|
|
2504
2558
|
if (!data) {
|
|
@@ -2510,9 +2564,6 @@ class ColorAnimation {
|
|
|
2510
2564
|
if (data.enable !== undefined) {
|
|
2511
2565
|
this.enable = data.enable;
|
|
2512
2566
|
}
|
|
2513
|
-
if (data.offset !== undefined) {
|
|
2514
|
-
this.offset = setRangeValue(data.offset);
|
|
2515
|
-
}
|
|
2516
2567
|
if (data.speed !== undefined) {
|
|
2517
2568
|
this.speed = setRangeValue(data.speed);
|
|
2518
2569
|
}
|
|
@@ -2527,6 +2578,44 @@ class ColorAnimation {
|
|
|
2527
2578
|
}
|
|
2528
2579
|
}
|
|
2529
2580
|
}
|
|
2581
|
+
class RangedAnimationOptions extends AnimationOptions {
|
|
2582
|
+
constructor() {
|
|
2583
|
+
super();
|
|
2584
|
+
this.mode = "auto";
|
|
2585
|
+
this.startValue = "random";
|
|
2586
|
+
}
|
|
2587
|
+
load(data) {
|
|
2588
|
+
super.load(data);
|
|
2589
|
+
if (!data) {
|
|
2590
|
+
return;
|
|
2591
|
+
}
|
|
2592
|
+
if (data.mode !== undefined) {
|
|
2593
|
+
this.mode = data.mode;
|
|
2594
|
+
}
|
|
2595
|
+
if (data.startValue !== undefined) {
|
|
2596
|
+
this.startValue = data.startValue;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/ColorAnimation.js
|
|
2601
|
+
|
|
2602
|
+
|
|
2603
|
+
class ColorAnimation extends AnimationOptions {
|
|
2604
|
+
constructor() {
|
|
2605
|
+
super();
|
|
2606
|
+
this.offset = 0;
|
|
2607
|
+
this.sync = true;
|
|
2608
|
+
}
|
|
2609
|
+
load(data) {
|
|
2610
|
+
super.load(data);
|
|
2611
|
+
if (!data) {
|
|
2612
|
+
return;
|
|
2613
|
+
}
|
|
2614
|
+
if (data.offset !== undefined) {
|
|
2615
|
+
this.offset = setRangeValue(data.offset);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2530
2619
|
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/HslAnimation.js
|
|
2531
2620
|
|
|
2532
2621
|
class HslAnimation {
|
|
@@ -2614,99 +2703,19 @@ class CollisionsOverlap {
|
|
|
2614
2703
|
}
|
|
2615
2704
|
}
|
|
2616
2705
|
}
|
|
2617
|
-
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/AnimationOptions.js
|
|
2618
|
-
|
|
2619
|
-
class AnimationOptions {
|
|
2620
|
-
constructor() {
|
|
2621
|
-
this.count = 0;
|
|
2622
|
-
this.enable = false;
|
|
2623
|
-
this.speed = 1;
|
|
2624
|
-
this.decay = 0;
|
|
2625
|
-
this.delay = 0;
|
|
2626
|
-
this.sync = false;
|
|
2627
|
-
}
|
|
2628
|
-
load(data) {
|
|
2629
|
-
if (!data) {
|
|
2630
|
-
return;
|
|
2631
|
-
}
|
|
2632
|
-
if (data.count !== undefined) {
|
|
2633
|
-
this.count = setRangeValue(data.count);
|
|
2634
|
-
}
|
|
2635
|
-
if (data.enable !== undefined) {
|
|
2636
|
-
this.enable = data.enable;
|
|
2637
|
-
}
|
|
2638
|
-
if (data.speed !== undefined) {
|
|
2639
|
-
this.speed = setRangeValue(data.speed);
|
|
2640
|
-
}
|
|
2641
|
-
if (data.decay !== undefined) {
|
|
2642
|
-
this.decay = setRangeValue(data.decay);
|
|
2643
|
-
}
|
|
2644
|
-
if (data.delay !== undefined) {
|
|
2645
|
-
this.delay = setRangeValue(data.delay);
|
|
2646
|
-
}
|
|
2647
|
-
if (data.sync !== undefined) {
|
|
2648
|
-
this.sync = data.sync;
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
}
|
|
2652
|
-
class RangedAnimationOptions extends AnimationOptions {
|
|
2653
|
-
constructor() {
|
|
2654
|
-
super();
|
|
2655
|
-
this.mode = "auto";
|
|
2656
|
-
this.startValue = "random";
|
|
2657
|
-
}
|
|
2658
|
-
load(data) {
|
|
2659
|
-
super.load(data);
|
|
2660
|
-
if (!data) {
|
|
2661
|
-
return;
|
|
2662
|
-
}
|
|
2663
|
-
if (data.mode !== undefined) {
|
|
2664
|
-
this.mode = data.mode;
|
|
2665
|
-
}
|
|
2666
|
-
if (data.startValue !== undefined) {
|
|
2667
|
-
this.startValue = data.startValue;
|
|
2668
|
-
}
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Random.js
|
|
2672
|
-
class Random {
|
|
2673
|
-
constructor() {
|
|
2674
|
-
this.enable = false;
|
|
2675
|
-
this.minimumValue = 0;
|
|
2676
|
-
}
|
|
2677
|
-
load(data) {
|
|
2678
|
-
if (!data) {
|
|
2679
|
-
return;
|
|
2680
|
-
}
|
|
2681
|
-
if (data.enable !== undefined) {
|
|
2682
|
-
this.enable = data.enable;
|
|
2683
|
-
}
|
|
2684
|
-
if (data.minimumValue !== undefined) {
|
|
2685
|
-
this.minimumValue = data.minimumValue;
|
|
2686
|
-
}
|
|
2687
|
-
}
|
|
2688
|
-
}
|
|
2689
2706
|
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/ValueWithRandom.js
|
|
2690
2707
|
|
|
2691
2708
|
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
2709
|
class ValueWithRandom {
|
|
2695
2710
|
constructor() {
|
|
2696
|
-
this.random = new Random();
|
|
2697
2711
|
this.value = 0;
|
|
2698
2712
|
}
|
|
2699
2713
|
load(data) {
|
|
2700
2714
|
if (!data) {
|
|
2701
2715
|
return;
|
|
2702
2716
|
}
|
|
2703
|
-
if (isBoolean(data.random)) {
|
|
2704
|
-
this.random.enable = data.random;
|
|
2705
|
-
} else {
|
|
2706
|
-
this.random.load(data.random);
|
|
2707
|
-
}
|
|
2708
2717
|
if (data.value !== undefined) {
|
|
2709
|
-
this.value = setRangeValue(data.value
|
|
2718
|
+
this.value = setRangeValue(data.value);
|
|
2710
2719
|
}
|
|
2711
2720
|
}
|
|
2712
2721
|
}
|
|
@@ -2740,7 +2749,6 @@ class RangedAnimationValueWithRandom extends AnimationValueWithRandom {
|
|
|
2740
2749
|
class ParticlesBounceFactor extends ValueWithRandom {
|
|
2741
2750
|
constructor() {
|
|
2742
2751
|
super();
|
|
2743
|
-
this.random.minimumValue = 0.1;
|
|
2744
2752
|
this.value = 1;
|
|
2745
2753
|
}
|
|
2746
2754
|
}
|
|
@@ -2791,6 +2799,39 @@ class Collisions {
|
|
|
2791
2799
|
this.overlap.load(data.overlap);
|
|
2792
2800
|
}
|
|
2793
2801
|
}
|
|
2802
|
+
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Particles/Effect/Effect.js
|
|
2803
|
+
|
|
2804
|
+
class Effect {
|
|
2805
|
+
constructor() {
|
|
2806
|
+
this.close = true;
|
|
2807
|
+
this.fill = true;
|
|
2808
|
+
this.options = {};
|
|
2809
|
+
this.type = [];
|
|
2810
|
+
}
|
|
2811
|
+
load(data) {
|
|
2812
|
+
if (!data) {
|
|
2813
|
+
return;
|
|
2814
|
+
}
|
|
2815
|
+
const options = data.options;
|
|
2816
|
+
if (options !== undefined) {
|
|
2817
|
+
for (const effect in options) {
|
|
2818
|
+
const item = options[effect];
|
|
2819
|
+
if (item) {
|
|
2820
|
+
this.options[effect] = deepExtend(this.options[effect] ?? {}, item);
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
if (data.close !== undefined) {
|
|
2825
|
+
this.close = data.close;
|
|
2826
|
+
}
|
|
2827
|
+
if (data.fill !== undefined) {
|
|
2828
|
+
this.fill = data.fill;
|
|
2829
|
+
}
|
|
2830
|
+
if (data.type !== undefined) {
|
|
2831
|
+
this.type = data.type;
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2794
2835
|
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Particles/Move/MoveAngle.js
|
|
2795
2836
|
|
|
2796
2837
|
class MoveAngle {
|
|
@@ -3119,11 +3160,10 @@ class OpacityAnimation extends RangedAnimationOptions {
|
|
|
3119
3160
|
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Particles/Opacity/Opacity.js
|
|
3120
3161
|
|
|
3121
3162
|
|
|
3122
|
-
class Opacity extends
|
|
3163
|
+
class Opacity extends RangedAnimationValueWithRandom {
|
|
3123
3164
|
constructor() {
|
|
3124
3165
|
super();
|
|
3125
3166
|
this.animation = new OpacityAnimation();
|
|
3126
|
-
this.random.minimumValue = 0.1;
|
|
3127
3167
|
this.value = 1;
|
|
3128
3168
|
}
|
|
3129
3169
|
load(data) {
|
|
@@ -3161,12 +3201,31 @@ class ParticlesDensity {
|
|
|
3161
3201
|
}
|
|
3162
3202
|
}
|
|
3163
3203
|
}
|
|
3204
|
+
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js
|
|
3205
|
+
class ParticlesNumberLimit {
|
|
3206
|
+
constructor() {
|
|
3207
|
+
this.mode = "delete";
|
|
3208
|
+
this.value = 0;
|
|
3209
|
+
}
|
|
3210
|
+
load(data) {
|
|
3211
|
+
if (!data) {
|
|
3212
|
+
return;
|
|
3213
|
+
}
|
|
3214
|
+
if (data.mode !== undefined) {
|
|
3215
|
+
this.mode = data.mode;
|
|
3216
|
+
}
|
|
3217
|
+
if (data.value !== undefined) {
|
|
3218
|
+
this.value = data.value;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3164
3222
|
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Particles/Number/ParticlesNumber.js
|
|
3165
3223
|
|
|
3224
|
+
|
|
3166
3225
|
class ParticlesNumber {
|
|
3167
3226
|
constructor() {
|
|
3168
3227
|
this.density = new ParticlesDensity();
|
|
3169
|
-
this.limit =
|
|
3228
|
+
this.limit = new ParticlesNumberLimit();
|
|
3170
3229
|
this.value = 0;
|
|
3171
3230
|
}
|
|
3172
3231
|
load(data) {
|
|
@@ -3174,10 +3233,7 @@ class ParticlesNumber {
|
|
|
3174
3233
|
return;
|
|
3175
3234
|
}
|
|
3176
3235
|
this.density.load(data.density);
|
|
3177
|
-
|
|
3178
|
-
if (limit !== undefined) {
|
|
3179
|
-
this.limit = limit;
|
|
3180
|
-
}
|
|
3236
|
+
this.limit.load(data.limit);
|
|
3181
3237
|
if (data.value !== undefined) {
|
|
3182
3238
|
this.value = data.value;
|
|
3183
3239
|
}
|
|
@@ -3272,11 +3328,10 @@ class SizeAnimation extends RangedAnimationOptions {
|
|
|
3272
3328
|
;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Particles/Size/Size.js
|
|
3273
3329
|
|
|
3274
3330
|
|
|
3275
|
-
class Size extends
|
|
3331
|
+
class Size extends RangedAnimationValueWithRandom {
|
|
3276
3332
|
constructor() {
|
|
3277
3333
|
super();
|
|
3278
3334
|
this.animation = new SizeAnimation();
|
|
3279
|
-
this.random.minimumValue = 1;
|
|
3280
3335
|
this.value = 3;
|
|
3281
3336
|
}
|
|
3282
3337
|
load(data) {
|
|
@@ -3350,6 +3405,7 @@ class ZIndex extends ValueWithRandom {
|
|
|
3350
3405
|
|
|
3351
3406
|
|
|
3352
3407
|
|
|
3408
|
+
|
|
3353
3409
|
class ParticlesOptions {
|
|
3354
3410
|
constructor(engine, container) {
|
|
3355
3411
|
this._engine = engine;
|
|
@@ -3358,6 +3414,7 @@ class ParticlesOptions {
|
|
|
3358
3414
|
this.collisions = new Collisions();
|
|
3359
3415
|
this.color = new AnimatableColor();
|
|
3360
3416
|
this.color.value = "#fff";
|
|
3417
|
+
this.effect = new Effect();
|
|
3361
3418
|
this.groups = {};
|
|
3362
3419
|
this.move = new Move();
|
|
3363
3420
|
this.number = new ParticlesNumber();
|
|
@@ -3375,6 +3432,7 @@ class ParticlesOptions {
|
|
|
3375
3432
|
}
|
|
3376
3433
|
this.bounce.load(data.bounce);
|
|
3377
3434
|
this.color.load(AnimatableColor.create(this.color, data.color));
|
|
3435
|
+
this.effect.load(data.effect);
|
|
3378
3436
|
if (data.groups !== undefined) {
|
|
3379
3437
|
for (const group in data.groups) {
|
|
3380
3438
|
const item = data.groups[group];
|
|
@@ -3647,7 +3705,27 @@ class InteractionManager {
|
|
|
3647
3705
|
|
|
3648
3706
|
|
|
3649
3707
|
|
|
3650
|
-
|
|
3708
|
+
function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
|
|
3709
|
+
const effectData = effectOptions.options[effect];
|
|
3710
|
+
if (!effectData) {
|
|
3711
|
+
return;
|
|
3712
|
+
}
|
|
3713
|
+
return deepExtend({
|
|
3714
|
+
close: effectOptions.close,
|
|
3715
|
+
fill: effectOptions.fill
|
|
3716
|
+
}, itemFromSingleOrMultiple(effectData, id, reduceDuplicates));
|
|
3717
|
+
}
|
|
3718
|
+
function loadShapeData(shape, shapeOptions, id, reduceDuplicates) {
|
|
3719
|
+
const shapeData = shapeOptions.options[shape];
|
|
3720
|
+
if (!shapeData) {
|
|
3721
|
+
return;
|
|
3722
|
+
}
|
|
3723
|
+
return deepExtend({
|
|
3724
|
+
close: shapeOptions.close,
|
|
3725
|
+
fill: shapeOptions.fill
|
|
3726
|
+
}, itemFromSingleOrMultiple(shapeData, id, reduceDuplicates));
|
|
3727
|
+
}
|
|
3728
|
+
function fixOutMode(data) {
|
|
3651
3729
|
if (!isInArray(data.outMode, data.checkModes)) {
|
|
3652
3730
|
return;
|
|
3653
3731
|
}
|
|
@@ -3657,7 +3735,7 @@ const fixOutMode = data => {
|
|
|
3657
3735
|
} else if (data.coord < diameter) {
|
|
3658
3736
|
data.setCb(data.radius);
|
|
3659
3737
|
}
|
|
3660
|
-
}
|
|
3738
|
+
}
|
|
3661
3739
|
class Particle {
|
|
3662
3740
|
constructor(engine, id, container, position, overrideOptions, group) {
|
|
3663
3741
|
this.container = container;
|
|
@@ -3715,8 +3793,8 @@ class Particle {
|
|
|
3715
3793
|
const rad = Math.PI / 180 * getRangeValue(moveOptions.angle.value),
|
|
3716
3794
|
radOffset = Math.PI / 180 * getRangeValue(moveOptions.angle.offset),
|
|
3717
3795
|
range = {
|
|
3718
|
-
left: radOffset - rad
|
|
3719
|
-
right: radOffset + rad
|
|
3796
|
+
left: radOffset - rad * 0.5,
|
|
3797
|
+
right: radOffset + rad * 0.5
|
|
3720
3798
|
};
|
|
3721
3799
|
if (!moveOptions.straight) {
|
|
3722
3800
|
res.angle += randomInRange(setRangeValue(range.left, range.right));
|
|
@@ -3747,7 +3825,7 @@ class Particle {
|
|
|
3747
3825
|
return color;
|
|
3748
3826
|
}
|
|
3749
3827
|
const backFactor = this.roll.horizontal && this.roll.vertical ? 2 : 1,
|
|
3750
|
-
backSum = this.roll.horizontal ? Math.PI
|
|
3828
|
+
backSum = this.roll.horizontal ? Math.PI * 0.5 : 0,
|
|
3751
3829
|
rolled = Math.floor(((this.roll.angle ?? 0) + backSum) / (Math.PI / backFactor)) % 2;
|
|
3752
3830
|
if (!rolled) {
|
|
3753
3831
|
return color;
|
|
@@ -3782,16 +3860,6 @@ class Particle {
|
|
|
3782
3860
|
}
|
|
3783
3861
|
this.offset = Vector.origin;
|
|
3784
3862
|
};
|
|
3785
|
-
this._loadShapeData = (shapeOptions, reduceDuplicates) => {
|
|
3786
|
-
const shapeData = shapeOptions.options[this.shape];
|
|
3787
|
-
if (!shapeData) {
|
|
3788
|
-
return;
|
|
3789
|
-
}
|
|
3790
|
-
return deepExtend({
|
|
3791
|
-
close: shapeOptions.close,
|
|
3792
|
-
fill: shapeOptions.fill
|
|
3793
|
-
}, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
|
|
3794
|
-
};
|
|
3795
3863
|
this._engine = engine;
|
|
3796
3864
|
this.init(id, position, overrideOptions, group);
|
|
3797
3865
|
}
|
|
@@ -3805,18 +3873,12 @@ class Particle {
|
|
|
3805
3873
|
const container = this.container,
|
|
3806
3874
|
pathGenerator = this.pathGenerator;
|
|
3807
3875
|
for (const [, plugin] of container.plugins) {
|
|
3808
|
-
|
|
3809
|
-
plugin.particleDestroyed(this, override);
|
|
3810
|
-
}
|
|
3876
|
+
plugin.particleDestroyed && plugin.particleDestroyed(this, override);
|
|
3811
3877
|
}
|
|
3812
3878
|
for (const updater of container.particles.updaters) {
|
|
3813
|
-
|
|
3814
|
-
updater.particleDestroyed(this, override);
|
|
3815
|
-
}
|
|
3816
|
-
}
|
|
3817
|
-
if (pathGenerator) {
|
|
3818
|
-
pathGenerator.reset(this);
|
|
3879
|
+
updater.particleDestroyed && updater.particleDestroyed(this, override);
|
|
3819
3880
|
}
|
|
3881
|
+
pathGenerator && pathGenerator.reset(this);
|
|
3820
3882
|
}
|
|
3821
3883
|
draw(delta) {
|
|
3822
3884
|
const container = this.container,
|
|
@@ -3830,7 +3892,7 @@ class Particle {
|
|
|
3830
3892
|
return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.color));
|
|
3831
3893
|
}
|
|
3832
3894
|
getMass() {
|
|
3833
|
-
return this.getRadius() ** 2 * Math.PI
|
|
3895
|
+
return this.getRadius() ** 2 * Math.PI * 0.5;
|
|
3834
3896
|
}
|
|
3835
3897
|
getPosition() {
|
|
3836
3898
|
return {
|
|
@@ -3850,9 +3912,11 @@ class Particle {
|
|
|
3850
3912
|
engine = this._engine;
|
|
3851
3913
|
this.id = id;
|
|
3852
3914
|
this.group = group;
|
|
3853
|
-
this.
|
|
3915
|
+
this.effectClose = true;
|
|
3916
|
+
this.effectFill = true;
|
|
3917
|
+
this.shapeClose = true;
|
|
3918
|
+
this.shapeFill = true;
|
|
3854
3919
|
this.pathRotation = false;
|
|
3855
|
-
this.close = true;
|
|
3856
3920
|
this.lastPathTime = 0;
|
|
3857
3921
|
this.destroyed = false;
|
|
3858
3922
|
this.unbreakable = false;
|
|
@@ -3866,22 +3930,40 @@ class Particle {
|
|
|
3866
3930
|
const pxRatio = container.retina.pixelRatio,
|
|
3867
3931
|
mainOptions = container.actualOptions,
|
|
3868
3932
|
particlesOptions = loadParticlesOptions(this._engine, container, mainOptions.particles),
|
|
3933
|
+
effectType = particlesOptions.effect.type,
|
|
3869
3934
|
shapeType = particlesOptions.shape.type,
|
|
3870
3935
|
{
|
|
3871
3936
|
reduceDuplicates
|
|
3872
3937
|
} = particlesOptions;
|
|
3938
|
+
this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
|
|
3873
3939
|
this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
|
|
3874
|
-
const
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3940
|
+
const effectOptions = particlesOptions.effect,
|
|
3941
|
+
shapeOptions = particlesOptions.shape;
|
|
3942
|
+
if (overrideOptions) {
|
|
3943
|
+
if (overrideOptions.effect && overrideOptions.effect.type) {
|
|
3944
|
+
const overrideEffectType = overrideOptions.effect.type,
|
|
3945
|
+
effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
|
|
3946
|
+
if (effect) {
|
|
3947
|
+
this.effect = effect;
|
|
3948
|
+
effectOptions.load(overrideOptions.effect);
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
if (overrideOptions.shape && overrideOptions.shape.type) {
|
|
3952
|
+
const overrideShapeType = overrideOptions.shape.type,
|
|
3953
|
+
shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
|
|
3954
|
+
if (shape) {
|
|
3955
|
+
this.shape = shape;
|
|
3956
|
+
shapeOptions.load(overrideOptions.shape);
|
|
3957
|
+
}
|
|
3881
3958
|
}
|
|
3882
3959
|
}
|
|
3883
|
-
this.
|
|
3960
|
+
this.effectData = loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates);
|
|
3961
|
+
this.shapeData = loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates);
|
|
3884
3962
|
particlesOptions.load(overrideOptions);
|
|
3963
|
+
const effectData = this.effectData;
|
|
3964
|
+
if (effectData) {
|
|
3965
|
+
particlesOptions.load(effectData.particles);
|
|
3966
|
+
}
|
|
3885
3967
|
const shapeData = this.shapeData;
|
|
3886
3968
|
if (shapeData) {
|
|
3887
3969
|
particlesOptions.load(shapeData.particles);
|
|
@@ -3890,11 +3972,13 @@ class Particle {
|
|
|
3890
3972
|
interactivity.load(container.actualOptions.interactivity);
|
|
3891
3973
|
interactivity.load(particlesOptions.interactivity);
|
|
3892
3974
|
this.interactivity = interactivity;
|
|
3893
|
-
this.
|
|
3894
|
-
this.
|
|
3975
|
+
this.effectFill = effectData?.fill ?? particlesOptions.effect.fill;
|
|
3976
|
+
this.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
3977
|
+
this.shapeFill = shapeData?.fill ?? particlesOptions.shape.fill;
|
|
3978
|
+
this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
3895
3979
|
this.options = particlesOptions;
|
|
3896
3980
|
const pathOptions = this.options.move.path;
|
|
3897
|
-
this.pathDelay =
|
|
3981
|
+
this.pathDelay = getRangeValue(pathOptions.delay.value) * 1000;
|
|
3898
3982
|
if (pathOptions.generator) {
|
|
3899
3983
|
this.pathGenerator = this._engine.getPathGenerator(pathOptions.generator);
|
|
3900
3984
|
if (this.pathGenerator && container.addPath(pathOptions.generator, this.pathGenerator)) {
|
|
@@ -3915,34 +3999,46 @@ class Particle {
|
|
|
3915
3999
|
this.velocity = this.initialVelocity.copy();
|
|
3916
4000
|
this.moveDecay = 1 - getRangeValue(this.options.move.decay);
|
|
3917
4001
|
const particles = container.particles;
|
|
3918
|
-
particles.
|
|
3919
|
-
particles.lastZIndex = this.position.z;
|
|
4002
|
+
particles.setLastZIndex(this.position.z);
|
|
3920
4003
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
3921
4004
|
this.sides = 24;
|
|
3922
|
-
let
|
|
3923
|
-
if (!
|
|
3924
|
-
|
|
3925
|
-
if (
|
|
3926
|
-
container.
|
|
4005
|
+
let effectDrawer = container.effectDrawers.get(this.effect);
|
|
4006
|
+
if (!effectDrawer) {
|
|
4007
|
+
effectDrawer = this._engine.getEffectDrawer(this.effect);
|
|
4008
|
+
if (effectDrawer) {
|
|
4009
|
+
container.effectDrawers.set(this.effect, effectDrawer);
|
|
3927
4010
|
}
|
|
3928
4011
|
}
|
|
3929
|
-
if (
|
|
3930
|
-
|
|
4012
|
+
if (effectDrawer && effectDrawer.loadEffect) {
|
|
4013
|
+
effectDrawer.loadEffect(this);
|
|
3931
4014
|
}
|
|
3932
|
-
|
|
4015
|
+
let shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
4016
|
+
if (!shapeDrawer) {
|
|
4017
|
+
shapeDrawer = this._engine.getShapeDrawer(this.shape);
|
|
4018
|
+
if (shapeDrawer) {
|
|
4019
|
+
container.shapeDrawers.set(this.shape, shapeDrawer);
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
if (shapeDrawer && shapeDrawer.loadShape) {
|
|
4023
|
+
shapeDrawer.loadShape(this);
|
|
4024
|
+
}
|
|
4025
|
+
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
3933
4026
|
if (sideCountFunc) {
|
|
3934
4027
|
this.sides = sideCountFunc(this);
|
|
3935
4028
|
}
|
|
3936
4029
|
this.spawning = false;
|
|
3937
4030
|
this.shadowColor = rangeColorToRgb(this.options.shadow.color);
|
|
3938
|
-
for (const updater of
|
|
4031
|
+
for (const updater of particles.updaters) {
|
|
3939
4032
|
updater.init(this);
|
|
3940
4033
|
}
|
|
3941
|
-
for (const mover of
|
|
4034
|
+
for (const mover of particles.movers) {
|
|
3942
4035
|
mover.init && mover.init(this);
|
|
3943
4036
|
}
|
|
3944
|
-
if (
|
|
3945
|
-
|
|
4037
|
+
if (effectDrawer && effectDrawer.particleInit) {
|
|
4038
|
+
effectDrawer.particleInit(container, this);
|
|
4039
|
+
}
|
|
4040
|
+
if (shapeDrawer && shapeDrawer.particleInit) {
|
|
4041
|
+
shapeDrawer.particleInit(container, this);
|
|
3946
4042
|
}
|
|
3947
4043
|
for (const [, plugin] of container.plugins) {
|
|
3948
4044
|
plugin.particleCreated && plugin.particleCreated(this);
|
|
@@ -4069,7 +4165,7 @@ class QuadTree {
|
|
|
4069
4165
|
capacity
|
|
4070
4166
|
} = this;
|
|
4071
4167
|
for (let i = 0; i < 4; i++) {
|
|
4072
|
-
this._subs.push(new QuadTree(new Rectangle(x + width
|
|
4168
|
+
this._subs.push(new QuadTree(new Rectangle(x + width * 0.5 * (i % 2), y + height * 0.5 * (Math.round(i * 0.5) - i % 2), width * 0.5, height * 0.5), capacity));
|
|
4073
4169
|
}
|
|
4074
4170
|
this._divided = true;
|
|
4075
4171
|
};
|
|
@@ -4125,21 +4221,36 @@ class QuadTree {
|
|
|
4125
4221
|
|
|
4126
4222
|
const qTreeCapacity = 4;
|
|
4127
4223
|
const qTreeRectangle = canvasSize => {
|
|
4128
|
-
|
|
4224
|
+
const {
|
|
4225
|
+
height,
|
|
4226
|
+
width
|
|
4227
|
+
} = canvasSize,
|
|
4228
|
+
posOffset = -0.25,
|
|
4229
|
+
sizeFactor = 1.5;
|
|
4230
|
+
return new Rectangle(posOffset * width, posOffset * height, sizeFactor * width, sizeFactor * height);
|
|
4129
4231
|
};
|
|
4130
4232
|
class Particles {
|
|
4131
4233
|
constructor(engine, container) {
|
|
4132
4234
|
this._applyDensity = (options, manualCount, group) => {
|
|
4235
|
+
const numberOptions = options.number;
|
|
4133
4236
|
if (!options.number.density?.enable) {
|
|
4237
|
+
if (group === undefined) {
|
|
4238
|
+
this._limit = numberOptions.limit.value;
|
|
4239
|
+
} else {
|
|
4240
|
+
this._groupLimits.set(group, numberOptions.limit.value);
|
|
4241
|
+
}
|
|
4134
4242
|
return;
|
|
4135
4243
|
}
|
|
4136
|
-
const
|
|
4137
|
-
densityFactor = this._initDensityFactor(numberOptions.density),
|
|
4244
|
+
const densityFactor = this._initDensityFactor(numberOptions.density),
|
|
4138
4245
|
optParticlesNumber = numberOptions.value,
|
|
4139
|
-
optParticlesLimit = numberOptions.limit > 0 ? numberOptions.limit : optParticlesNumber,
|
|
4246
|
+
optParticlesLimit = numberOptions.limit.value > 0 ? numberOptions.limit.value : optParticlesNumber,
|
|
4140
4247
|
particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + manualCount,
|
|
4141
4248
|
particlesCount = Math.min(this.count, this.filter(t => t.group === group).length);
|
|
4142
|
-
|
|
4249
|
+
if (group === undefined) {
|
|
4250
|
+
this._limit = numberOptions.limit.value * densityFactor;
|
|
4251
|
+
} else {
|
|
4252
|
+
this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
|
|
4253
|
+
}
|
|
4143
4254
|
if (particlesCount < particlesNumber) {
|
|
4144
4255
|
this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
|
|
4145
4256
|
} else if (particlesCount > particlesNumber) {
|
|
@@ -4157,7 +4268,7 @@ class Particles {
|
|
|
4157
4268
|
};
|
|
4158
4269
|
this._pushParticle = (position, overrideOptions, group, initializer) => {
|
|
4159
4270
|
try {
|
|
4160
|
-
let particle = this.
|
|
4271
|
+
let particle = this._pool.pop();
|
|
4161
4272
|
if (particle) {
|
|
4162
4273
|
particle.init(this._nextId, position, overrideOptions, group);
|
|
4163
4274
|
} else {
|
|
@@ -4194,7 +4305,7 @@ class Particles {
|
|
|
4194
4305
|
const zIdx = this._zArray.indexOf(particle);
|
|
4195
4306
|
this._array.splice(index, 1);
|
|
4196
4307
|
this._zArray.splice(zIdx, 1);
|
|
4197
|
-
this.
|
|
4308
|
+
this._pool.push(particle);
|
|
4198
4309
|
this._engine.dispatchEvent("particleRemoved", {
|
|
4199
4310
|
container: this._container,
|
|
4200
4311
|
data: {
|
|
@@ -4208,10 +4319,11 @@ class Particles {
|
|
|
4208
4319
|
this._nextId = 0;
|
|
4209
4320
|
this._array = [];
|
|
4210
4321
|
this._zArray = [];
|
|
4211
|
-
this.
|
|
4212
|
-
this.
|
|
4213
|
-
this.
|
|
4214
|
-
this.
|
|
4322
|
+
this._pool = [];
|
|
4323
|
+
this._limit = 0;
|
|
4324
|
+
this._groupLimits = new Map();
|
|
4325
|
+
this._needsSort = false;
|
|
4326
|
+
this._lastZIndex = 0;
|
|
4215
4327
|
this._interactionManager = new InteractionManager(engine, container);
|
|
4216
4328
|
const canvasSize = container.canvas.size;
|
|
4217
4329
|
this.quadTree = new QuadTree(qTreeRectangle(canvasSize), qTreeCapacity);
|
|
@@ -4229,19 +4341,22 @@ class Particles {
|
|
|
4229
4341
|
}
|
|
4230
4342
|
}
|
|
4231
4343
|
addParticle(position, overrideOptions, group, initializer) {
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
limit = options.particles.number.limit;
|
|
4344
|
+
const limitOptions = this._container.actualOptions.particles.number.limit,
|
|
4345
|
+
limit = group === undefined ? this._limit : this._groupLimits.get(group) ?? this._limit,
|
|
4346
|
+
currentCount = this.count;
|
|
4236
4347
|
if (limit > 0) {
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4348
|
+
if (limitOptions.mode === "delete") {
|
|
4349
|
+
const countToRemove = currentCount + 1 - limit;
|
|
4350
|
+
if (countToRemove > 0) {
|
|
4351
|
+
this.removeQuantity(countToRemove);
|
|
4352
|
+
}
|
|
4353
|
+
} else if (limitOptions.mode === "wait") {
|
|
4354
|
+
if (currentCount >= limit) {
|
|
4355
|
+
return;
|
|
4356
|
+
}
|
|
4240
4357
|
}
|
|
4241
4358
|
}
|
|
4242
|
-
|
|
4243
|
-
this.pushing = false;
|
|
4244
|
-
return res;
|
|
4359
|
+
return this._pushParticle(position, overrideOptions, group, initializer);
|
|
4245
4360
|
}
|
|
4246
4361
|
clear() {
|
|
4247
4362
|
this._array = [];
|
|
@@ -4280,8 +4395,8 @@ class Particles {
|
|
|
4280
4395
|
init() {
|
|
4281
4396
|
const container = this._container,
|
|
4282
4397
|
options = container.actualOptions;
|
|
4283
|
-
this.
|
|
4284
|
-
this.
|
|
4398
|
+
this._lastZIndex = 0;
|
|
4399
|
+
this._needsSort = false;
|
|
4285
4400
|
let handled = false;
|
|
4286
4401
|
this.updaters = this._engine.getUpdaters(container, true);
|
|
4287
4402
|
this._interactionManager.init();
|
|
@@ -4348,6 +4463,13 @@ class Particles {
|
|
|
4348
4463
|
}
|
|
4349
4464
|
this._applyDensity(options.particles, options.manualParticles.length);
|
|
4350
4465
|
}
|
|
4466
|
+
setLastZIndex(zIndex) {
|
|
4467
|
+
this._lastZIndex = zIndex;
|
|
4468
|
+
this._needsSort = this._needsSort || this._lastZIndex < zIndex;
|
|
4469
|
+
}
|
|
4470
|
+
setResizeFactor(factor) {
|
|
4471
|
+
this._resizeFactor = factor;
|
|
4472
|
+
}
|
|
4351
4473
|
async update(delta) {
|
|
4352
4474
|
const container = this._container,
|
|
4353
4475
|
particlesToDelete = new Set();
|
|
@@ -4356,10 +4478,10 @@ class Particles {
|
|
|
4356
4478
|
pathGenerator.update();
|
|
4357
4479
|
}
|
|
4358
4480
|
for (const [, plugin] of container.plugins) {
|
|
4359
|
-
plugin.update && plugin.update(delta);
|
|
4481
|
+
plugin.update && (await plugin.update(delta));
|
|
4360
4482
|
}
|
|
4483
|
+
const resizeFactor = this._resizeFactor;
|
|
4361
4484
|
for (const particle of this._array) {
|
|
4362
|
-
const resizeFactor = container.canvas.resizeFactor;
|
|
4363
4485
|
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
4364
4486
|
particle.position.x *= resizeFactor.width;
|
|
4365
4487
|
particle.position.y *= resizeFactor.height;
|
|
@@ -4387,7 +4509,7 @@ class Particles {
|
|
|
4387
4509
|
const checkDelete = p => !particlesToDelete.has(p);
|
|
4388
4510
|
this._array = this.filter(checkDelete);
|
|
4389
4511
|
this._zArray = this._zArray.filter(checkDelete);
|
|
4390
|
-
this.
|
|
4512
|
+
this._pool.push(...particlesToDelete);
|
|
4391
4513
|
}
|
|
4392
4514
|
await this._interactionManager.externalInteract(delta);
|
|
4393
4515
|
for (const particle of this._array) {
|
|
@@ -4398,12 +4520,12 @@ class Particles {
|
|
|
4398
4520
|
await this._interactionManager.particlesInteract(particle, delta);
|
|
4399
4521
|
}
|
|
4400
4522
|
}
|
|
4401
|
-
delete
|
|
4402
|
-
if (this.
|
|
4523
|
+
delete this._resizeFactor;
|
|
4524
|
+
if (this._needsSort) {
|
|
4403
4525
|
const zArray = this._zArray;
|
|
4404
4526
|
zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
4405
|
-
this.
|
|
4406
|
-
this.
|
|
4527
|
+
this._lastZIndex = zArray[zArray.length - 1].position.z;
|
|
4528
|
+
this._needsSort = false;
|
|
4407
4529
|
}
|
|
4408
4530
|
}
|
|
4409
4531
|
}
|
|
@@ -4430,7 +4552,6 @@ class Retina {
|
|
|
4430
4552
|
}
|
|
4431
4553
|
const particles = options.particles,
|
|
4432
4554
|
moveOptions = particles.move;
|
|
4433
|
-
this.attractDistance = getRangeValue(moveOptions.attract.distance) * ratio;
|
|
4434
4555
|
this.maxSpeed = getRangeValue(moveOptions.gravity.maxSpeed) * ratio;
|
|
4435
4556
|
this.sizeAnimationSpeed = getRangeValue(particles.size.animation.speed) * ratio;
|
|
4436
4557
|
}
|
|
@@ -4440,7 +4561,6 @@ class Retina {
|
|
|
4440
4561
|
moveOptions = options.move,
|
|
4441
4562
|
moveDistance = moveOptions.distance,
|
|
4442
4563
|
props = particle.retina;
|
|
4443
|
-
props.attractDistance = getRangeValue(moveOptions.attract.distance) * ratio;
|
|
4444
4564
|
props.moveDrift = getRangeValue(moveOptions.drift) * ratio;
|
|
4445
4565
|
props.moveSpeed = getRangeValue(moveOptions.speed) * ratio;
|
|
4446
4566
|
props.sizeAnimationSpeed = getRangeValue(options.size.animation.speed) * ratio;
|
|
@@ -4476,7 +4596,6 @@ function loadContainerOptions(engine, container, ...sourceOptionsArr) {
|
|
|
4476
4596
|
}
|
|
4477
4597
|
class Container {
|
|
4478
4598
|
constructor(engine, id, sourceOptions) {
|
|
4479
|
-
this.id = id;
|
|
4480
4599
|
this._intersectionManager = entries => {
|
|
4481
4600
|
if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
|
|
4482
4601
|
return;
|
|
@@ -4490,14 +4609,14 @@ class Container {
|
|
|
4490
4609
|
};
|
|
4491
4610
|
this._nextFrame = async timestamp => {
|
|
4492
4611
|
try {
|
|
4493
|
-
if (!this.
|
|
4612
|
+
if (!this._smooth && this._lastFrameTime !== undefined && timestamp < this._lastFrameTime + 1000 / this.fpsLimit) {
|
|
4494
4613
|
this.draw(false);
|
|
4495
4614
|
return;
|
|
4496
4615
|
}
|
|
4497
|
-
this.
|
|
4498
|
-
const delta = initDelta(timestamp - this.
|
|
4616
|
+
this._lastFrameTime ??= timestamp;
|
|
4617
|
+
const delta = initDelta(timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
|
|
4499
4618
|
this.addLifeTime(delta.value);
|
|
4500
|
-
this.
|
|
4619
|
+
this._lastFrameTime = timestamp;
|
|
4501
4620
|
if (delta.value > 1000) {
|
|
4502
4621
|
this.draw(false);
|
|
4503
4622
|
return;
|
|
@@ -4515,8 +4634,9 @@ class Container {
|
|
|
4515
4634
|
}
|
|
4516
4635
|
};
|
|
4517
4636
|
this._engine = engine;
|
|
4637
|
+
this.id = Symbol(id);
|
|
4518
4638
|
this.fpsLimit = 120;
|
|
4519
|
-
this.
|
|
4639
|
+
this._smooth = false;
|
|
4520
4640
|
this._delay = 0;
|
|
4521
4641
|
this._duration = 0;
|
|
4522
4642
|
this._lifeTime = 0;
|
|
@@ -4524,7 +4644,7 @@ class Container {
|
|
|
4524
4644
|
this.started = false;
|
|
4525
4645
|
this.destroyed = false;
|
|
4526
4646
|
this._paused = true;
|
|
4527
|
-
this.
|
|
4647
|
+
this._lastFrameTime = 0;
|
|
4528
4648
|
this.zLayers = 100;
|
|
4529
4649
|
this.pageHidden = false;
|
|
4530
4650
|
this._sourceOptions = sourceOptions;
|
|
@@ -4540,13 +4660,12 @@ class Container {
|
|
|
4540
4660
|
}
|
|
4541
4661
|
};
|
|
4542
4662
|
this.plugins = new Map();
|
|
4543
|
-
this.
|
|
4663
|
+
this.effectDrawers = new Map();
|
|
4664
|
+
this.shapeDrawers = new Map();
|
|
4544
4665
|
this._options = loadContainerOptions(this._engine, this);
|
|
4545
4666
|
this.actualOptions = loadContainerOptions(this._engine, this);
|
|
4546
4667
|
this._eventListeners = new EventListeners(this);
|
|
4547
|
-
|
|
4548
|
-
this._intersectionObserver = new IntersectionObserver(entries => this._intersectionManager(entries));
|
|
4549
|
-
}
|
|
4668
|
+
this._intersectionObserver = safeIntersectionObserver(entries => this._intersectionManager(entries));
|
|
4550
4669
|
this._engine.dispatchEvent("containerBuilt", {
|
|
4551
4670
|
container: this
|
|
4552
4671
|
});
|
|
@@ -4660,11 +4779,17 @@ class Container {
|
|
|
4660
4779
|
this.stop();
|
|
4661
4780
|
this.particles.destroy();
|
|
4662
4781
|
this.canvas.destroy();
|
|
4663
|
-
for (const [,
|
|
4664
|
-
|
|
4782
|
+
for (const [, effectDrawer] of this.effectDrawers) {
|
|
4783
|
+
effectDrawer.destroy && effectDrawer.destroy(this);
|
|
4784
|
+
}
|
|
4785
|
+
for (const [, shapeDrawer] of this.shapeDrawers) {
|
|
4786
|
+
shapeDrawer.destroy && shapeDrawer.destroy(this);
|
|
4665
4787
|
}
|
|
4666
|
-
for (const key of this.
|
|
4667
|
-
this.
|
|
4788
|
+
for (const key of this.effectDrawers.keys()) {
|
|
4789
|
+
this.effectDrawers.delete(key);
|
|
4790
|
+
}
|
|
4791
|
+
for (const key of this.shapeDrawers.keys()) {
|
|
4792
|
+
this.shapeDrawers.delete(key);
|
|
4668
4793
|
}
|
|
4669
4794
|
this._engine.clearPlugins(this);
|
|
4670
4795
|
this.destroyed = true;
|
|
@@ -4684,7 +4809,7 @@ class Container {
|
|
|
4684
4809
|
let refreshTime = force;
|
|
4685
4810
|
this._drawAnimationFrame = requestAnimationFrame(async timestamp => {
|
|
4686
4811
|
if (refreshTime) {
|
|
4687
|
-
this.
|
|
4812
|
+
this._lastFrameTime = undefined;
|
|
4688
4813
|
refreshTime = false;
|
|
4689
4814
|
}
|
|
4690
4815
|
await this._nextFrame(timestamp);
|
|
@@ -4719,11 +4844,18 @@ class Container {
|
|
|
4719
4844
|
if (!guardCheck(this)) {
|
|
4720
4845
|
return;
|
|
4721
4846
|
}
|
|
4847
|
+
const effects = this._engine.getSupportedEffects();
|
|
4848
|
+
for (const type of effects) {
|
|
4849
|
+
const drawer = this._engine.getEffectDrawer(type);
|
|
4850
|
+
if (drawer) {
|
|
4851
|
+
this.effectDrawers.set(type, drawer);
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4722
4854
|
const shapes = this._engine.getSupportedShapes();
|
|
4723
4855
|
for (const type of shapes) {
|
|
4724
4856
|
const drawer = this._engine.getShapeDrawer(type);
|
|
4725
4857
|
if (drawer) {
|
|
4726
|
-
this.
|
|
4858
|
+
this.shapeDrawers.set(type, drawer);
|
|
4727
4859
|
}
|
|
4728
4860
|
}
|
|
4729
4861
|
this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
|
|
@@ -4742,8 +4874,11 @@ class Container {
|
|
|
4742
4874
|
this._delay = getRangeValue(this.actualOptions.delay) * 1000;
|
|
4743
4875
|
this._lifeTime = 0;
|
|
4744
4876
|
this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
|
|
4745
|
-
this.
|
|
4746
|
-
for (const [, drawer] of this.
|
|
4877
|
+
this._smooth = this.actualOptions.smooth;
|
|
4878
|
+
for (const [, drawer] of this.effectDrawers) {
|
|
4879
|
+
drawer.init && (await drawer.init(this));
|
|
4880
|
+
}
|
|
4881
|
+
for (const [, drawer] of this.shapeDrawers) {
|
|
4747
4882
|
drawer.init && (await drawer.init(this));
|
|
4748
4883
|
}
|
|
4749
4884
|
for (const [, plugin] of this.plugins) {
|
|
@@ -4884,10 +5019,10 @@ class Container {
|
|
|
4884
5019
|
this.actualOptions.responsive = [];
|
|
4885
5020
|
const newMaxWidth = this.actualOptions.setResponsive(this.canvas.size.width, this.retina.pixelRatio, this._options);
|
|
4886
5021
|
this.actualOptions.setTheme(this._currentTheme);
|
|
4887
|
-
if (this.
|
|
5022
|
+
if (this._responsiveMaxWidth === newMaxWidth) {
|
|
4888
5023
|
return false;
|
|
4889
5024
|
}
|
|
4890
|
-
this.
|
|
5025
|
+
this._responsiveMaxWidth = newMaxWidth;
|
|
4891
5026
|
return true;
|
|
4892
5027
|
}
|
|
4893
5028
|
}
|
|
@@ -4978,7 +5113,8 @@ class Engine {
|
|
|
4978
5113
|
this.movers = new Map();
|
|
4979
5114
|
this.updaters = new Map();
|
|
4980
5115
|
this.presets = new Map();
|
|
4981
|
-
this.
|
|
5116
|
+
this.effectDrawers = new Map();
|
|
5117
|
+
this.shapeDrawers = new Map();
|
|
4982
5118
|
this.pathGenerators = new Map();
|
|
4983
5119
|
}
|
|
4984
5120
|
get configs() {
|
|
@@ -4989,17 +5125,23 @@ class Engine {
|
|
|
4989
5125
|
return res;
|
|
4990
5126
|
}
|
|
4991
5127
|
get version() {
|
|
4992
|
-
return "3.0.0-beta.
|
|
5128
|
+
return "3.0.0-beta.4";
|
|
4993
5129
|
}
|
|
4994
|
-
addConfig(
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
5130
|
+
addConfig(config) {
|
|
5131
|
+
const name = config.name ?? "default";
|
|
5132
|
+
this._configs.set(name, config);
|
|
5133
|
+
this._eventDispatcher.dispatchEvent("configAdded", {
|
|
5134
|
+
data: {
|
|
5135
|
+
name,
|
|
5136
|
+
config
|
|
4999
5137
|
}
|
|
5000
|
-
}
|
|
5001
|
-
|
|
5002
|
-
|
|
5138
|
+
});
|
|
5139
|
+
}
|
|
5140
|
+
async addEffect(effect, drawer, refresh = true) {
|
|
5141
|
+
executeOnSingleOrMultiple(effect, type => {
|
|
5142
|
+
!this.getEffectDrawer(type) && this.effectDrawers.set(type, drawer);
|
|
5143
|
+
});
|
|
5144
|
+
await this.refresh(refresh);
|
|
5003
5145
|
}
|
|
5004
5146
|
addEventListener(type, listener) {
|
|
5005
5147
|
this._eventDispatcher.addEventListener(type, listener);
|
|
@@ -5028,44 +5170,11 @@ class Engine {
|
|
|
5028
5170
|
(override || !this.getPreset(preset)) && this.presets.set(preset, options);
|
|
5029
5171
|
await this.refresh(refresh);
|
|
5030
5172
|
}
|
|
5031
|
-
async addShape(shape, drawer,
|
|
5032
|
-
let customDrawer;
|
|
5033
|
-
let realRefresh = refresh,
|
|
5034
|
-
realInit,
|
|
5035
|
-
realAfterEffect,
|
|
5036
|
-
realDestroy;
|
|
5037
|
-
if (isBoolean(initOrRefresh)) {
|
|
5038
|
-
realRefresh = initOrRefresh;
|
|
5039
|
-
realInit = undefined;
|
|
5040
|
-
} else {
|
|
5041
|
-
realInit = initOrRefresh;
|
|
5042
|
-
}
|
|
5043
|
-
if (isBoolean(afterEffectOrRefresh)) {
|
|
5044
|
-
realRefresh = afterEffectOrRefresh;
|
|
5045
|
-
realAfterEffect = undefined;
|
|
5046
|
-
} else {
|
|
5047
|
-
realAfterEffect = afterEffectOrRefresh;
|
|
5048
|
-
}
|
|
5049
|
-
if (isBoolean(destroyOrRefresh)) {
|
|
5050
|
-
realRefresh = destroyOrRefresh;
|
|
5051
|
-
realDestroy = undefined;
|
|
5052
|
-
} else {
|
|
5053
|
-
realDestroy = destroyOrRefresh;
|
|
5054
|
-
}
|
|
5055
|
-
if (isFunction(drawer)) {
|
|
5056
|
-
customDrawer = {
|
|
5057
|
-
afterEffect: realAfterEffect,
|
|
5058
|
-
destroy: realDestroy,
|
|
5059
|
-
draw: drawer,
|
|
5060
|
-
init: realInit
|
|
5061
|
-
};
|
|
5062
|
-
} else {
|
|
5063
|
-
customDrawer = drawer;
|
|
5064
|
-
}
|
|
5173
|
+
async addShape(shape, drawer, refresh = true) {
|
|
5065
5174
|
executeOnSingleOrMultiple(shape, type => {
|
|
5066
|
-
!this.getShapeDrawer(type) && this.
|
|
5175
|
+
!this.getShapeDrawer(type) && this.shapeDrawers.set(type, drawer);
|
|
5067
5176
|
});
|
|
5068
|
-
await this.refresh(
|
|
5177
|
+
await this.refresh(refresh);
|
|
5069
5178
|
}
|
|
5070
5179
|
clearPlugins(container) {
|
|
5071
5180
|
this.updaters.delete(container);
|
|
@@ -5094,6 +5203,9 @@ class Engine {
|
|
|
5094
5203
|
}
|
|
5095
5204
|
return res;
|
|
5096
5205
|
}
|
|
5206
|
+
getEffectDrawer(type) {
|
|
5207
|
+
return this.effectDrawers.get(type);
|
|
5208
|
+
}
|
|
5097
5209
|
getInteractors(container, force = false) {
|
|
5098
5210
|
return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);
|
|
5099
5211
|
}
|
|
@@ -5110,10 +5222,13 @@ class Engine {
|
|
|
5110
5222
|
return this.presets.get(preset);
|
|
5111
5223
|
}
|
|
5112
5224
|
getShapeDrawer(type) {
|
|
5113
|
-
return this.
|
|
5225
|
+
return this.shapeDrawers.get(type);
|
|
5226
|
+
}
|
|
5227
|
+
getSupportedEffects() {
|
|
5228
|
+
return this.effectDrawers.keys();
|
|
5114
5229
|
}
|
|
5115
5230
|
getSupportedShapes() {
|
|
5116
|
-
return this.
|
|
5231
|
+
return this.shapeDrawers.keys();
|
|
5117
5232
|
}
|
|
5118
5233
|
getUpdaters(container, force = false) {
|
|
5119
5234
|
return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
|
|
@@ -5143,7 +5258,7 @@ class Engine {
|
|
|
5143
5258
|
}
|
|
5144
5259
|
const currentOptions = itemFromSingleOrMultiple(options, index),
|
|
5145
5260
|
dom = this.dom(),
|
|
5146
|
-
oldIndex = dom.findIndex(v => v.id === id);
|
|
5261
|
+
oldIndex = dom.findIndex(v => v.id.description === id);
|
|
5147
5262
|
if (oldIndex >= 0) {
|
|
5148
5263
|
const old = this.domItem(oldIndex);
|
|
5149
5264
|
if (old && !old.destroyed) {
|
|
@@ -5409,7 +5524,6 @@ class ParticlesInteractorBase {
|
|
|
5409
5524
|
|
|
5410
5525
|
|
|
5411
5526
|
|
|
5412
|
-
|
|
5413
5527
|
|
|
5414
5528
|
|
|
5415
5529
|
;// CONCATENATED MODULE: ../../engine/dist/browser/index.js
|
|
@@ -5577,10 +5691,10 @@ function applyDistance(particle) {
|
|
|
5577
5691
|
if ((hDistance && dxFixed >= hDistance || vDistance && dyFixed >= vDistance) && !particle.misplaced) {
|
|
5578
5692
|
particle.misplaced = !!hDistance && dxFixed > hDistance || !!vDistance && dyFixed > vDistance;
|
|
5579
5693
|
if (hDistance) {
|
|
5580
|
-
particle.velocity.x = particle.velocity.y
|
|
5694
|
+
particle.velocity.x = particle.velocity.y * 0.5 - particle.velocity.x;
|
|
5581
5695
|
}
|
|
5582
5696
|
if (vDistance) {
|
|
5583
|
-
particle.velocity.y = particle.velocity.x
|
|
5697
|
+
particle.velocity.y = particle.velocity.x * 0.5 - particle.velocity.y;
|
|
5584
5698
|
}
|
|
5585
5699
|
} else if ((!hDistance || dxFixed < hDistance) && (!vDistance || dyFixed < vDistance) && particle.misplaced) {
|
|
5586
5700
|
particle.misplaced = false;
|
|
@@ -5638,15 +5752,16 @@ function spin(particle, moveSpeed) {
|
|
|
5638
5752
|
particle.position.x = particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle);
|
|
5639
5753
|
particle.position.y = particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle);
|
|
5640
5754
|
particle.spin.radius += particle.spin.acceleration;
|
|
5641
|
-
const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height)
|
|
5642
|
-
|
|
5643
|
-
|
|
5755
|
+
const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height),
|
|
5756
|
+
halfMaxSize = maxCanvasSize * 0.5;
|
|
5757
|
+
if (particle.spin.radius > halfMaxSize) {
|
|
5758
|
+
particle.spin.radius = halfMaxSize;
|
|
5644
5759
|
particle.spin.acceleration *= -1;
|
|
5645
5760
|
} else if (particle.spin.radius < 0) {
|
|
5646
5761
|
particle.spin.radius = 0;
|
|
5647
5762
|
particle.spin.acceleration *= -1;
|
|
5648
5763
|
}
|
|
5649
|
-
particle.spin.angle += moveSpeed
|
|
5764
|
+
particle.spin.angle += moveSpeed * 0.01 * (1 - particle.spin.radius / maxCanvasSize);
|
|
5650
5765
|
}
|
|
5651
5766
|
function applyPath(particle, delta) {
|
|
5652
5767
|
const particlesOptions = particle.options,
|
|
@@ -5690,8 +5805,8 @@ class BaseMover {
|
|
|
5690
5805
|
y: 50
|
|
5691
5806
|
},
|
|
5692
5807
|
spinCenter = {
|
|
5693
|
-
x: spinPos.x
|
|
5694
|
-
y: spinPos.y
|
|
5808
|
+
x: spinPos.x * 0.01 * container.canvas.size.width,
|
|
5809
|
+
y: spinPos.y * 0.01 * container.canvas.size.height
|
|
5695
5810
|
},
|
|
5696
5811
|
pos = particle.getPosition(),
|
|
5697
5812
|
distance = getDistance(pos, spinCenter),
|
|
@@ -5750,7 +5865,12 @@ async function loadBaseMover(engine, refresh = true) {
|
|
|
5750
5865
|
;// CONCATENATED MODULE: ../../shapes/circle/dist/browser/CircleDrawer.js
|
|
5751
5866
|
|
|
5752
5867
|
class CircleDrawer {
|
|
5753
|
-
draw(
|
|
5868
|
+
draw(data) {
|
|
5869
|
+
const {
|
|
5870
|
+
context,
|
|
5871
|
+
particle,
|
|
5872
|
+
radius
|
|
5873
|
+
} = data;
|
|
5754
5874
|
if (!particle.circleRange) {
|
|
5755
5875
|
particle.circleRange = {
|
|
5756
5876
|
min: 0,
|
|
@@ -6009,7 +6129,7 @@ function bounceHorizontal(data) {
|
|
|
6009
6129
|
const velocity = data.particle.velocity.x;
|
|
6010
6130
|
let bounced = false;
|
|
6011
6131
|
if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0 || data.direction === "left" && data.bounds.left <= 0 && velocity < 0) {
|
|
6012
|
-
const newVelocity =
|
|
6132
|
+
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
|
|
6013
6133
|
data.particle.velocity.x *= -newVelocity;
|
|
6014
6134
|
bounced = true;
|
|
6015
6135
|
}
|
|
@@ -6038,7 +6158,7 @@ function bounceVertical(data) {
|
|
|
6038
6158
|
const velocity = data.particle.velocity.y;
|
|
6039
6159
|
let bounced = false;
|
|
6040
6160
|
if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0 || data.direction === "top" && data.bounds.top <= 0 && velocity < 0) {
|
|
6041
|
-
const newVelocity =
|
|
6161
|
+
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
|
|
6042
6162
|
data.particle.velocity.y *= -newVelocity;
|
|
6043
6163
|
bounced = true;
|
|
6044
6164
|
}
|
|
@@ -6488,6 +6608,7 @@ class Attract {
|
|
|
6488
6608
|
;// CONCATENATED MODULE: ../../interactions/external/attract/dist/browser/Attractor.js
|
|
6489
6609
|
|
|
6490
6610
|
|
|
6611
|
+
const attractMode = "attract";
|
|
6491
6612
|
class Attractor extends ExternalInteractorBase {
|
|
6492
6613
|
constructor(engine, container) {
|
|
6493
6614
|
super(container);
|
|
@@ -6559,7 +6680,7 @@ class Attractor extends ExternalInteractorBase {
|
|
|
6559
6680
|
this.handleClickMode = mode => {
|
|
6560
6681
|
const options = this.container.actualOptions,
|
|
6561
6682
|
attract = options.interactivity.modes.attract;
|
|
6562
|
-
if (!attract || mode !==
|
|
6683
|
+
if (!attract || mode !== attractMode) {
|
|
6563
6684
|
return;
|
|
6564
6685
|
}
|
|
6565
6686
|
if (!container.attract) {
|
|
@@ -6608,9 +6729,9 @@ class Attractor extends ExternalInteractorBase {
|
|
|
6608
6729
|
hoverMode = events.onHover.mode,
|
|
6609
6730
|
clickEnabled = events.onClick.enable,
|
|
6610
6731
|
clickMode = events.onClick.mode;
|
|
6611
|
-
if (mouseMoveStatus && hoverEnabled && isInArray(
|
|
6732
|
+
if (mouseMoveStatus && hoverEnabled && isInArray(attractMode, hoverMode)) {
|
|
6612
6733
|
this._hoverAttract();
|
|
6613
|
-
} else if (clickEnabled && isInArray(
|
|
6734
|
+
} else if (clickEnabled && isInArray(attractMode, clickMode)) {
|
|
6614
6735
|
this._clickAttract();
|
|
6615
6736
|
}
|
|
6616
6737
|
}
|
|
@@ -6624,7 +6745,7 @@ class Attractor extends ExternalInteractorBase {
|
|
|
6624
6745
|
}
|
|
6625
6746
|
const hoverMode = events.onHover.mode,
|
|
6626
6747
|
clickMode = events.onClick.mode;
|
|
6627
|
-
return isInArray(
|
|
6748
|
+
return isInArray(attractMode, hoverMode) || isInArray(attractMode, clickMode);
|
|
6628
6749
|
}
|
|
6629
6750
|
loadModeOptions(options, ...sources) {
|
|
6630
6751
|
if (!options.attract) {
|
|
@@ -6660,6 +6781,7 @@ class Bounce {
|
|
|
6660
6781
|
;// CONCATENATED MODULE: ../../interactions/external/bounce/dist/browser/Bouncer.js
|
|
6661
6782
|
|
|
6662
6783
|
|
|
6784
|
+
const bounceMode = "bounce";
|
|
6663
6785
|
class Bouncer extends ExternalInteractorBase {
|
|
6664
6786
|
constructor(container) {
|
|
6665
6787
|
super(container);
|
|
@@ -6727,10 +6849,10 @@ class Bouncer extends ExternalInteractorBase {
|
|
|
6727
6849
|
hoverEnabled = events.onHover.enable,
|
|
6728
6850
|
hoverMode = events.onHover.mode,
|
|
6729
6851
|
divs = events.onDiv;
|
|
6730
|
-
if (mouseMoveStatus && hoverEnabled && isInArray(
|
|
6852
|
+
if (mouseMoveStatus && hoverEnabled && isInArray(bounceMode, hoverMode)) {
|
|
6731
6853
|
this._processMouseBounce();
|
|
6732
6854
|
} else {
|
|
6733
|
-
divModeExecute(
|
|
6855
|
+
divModeExecute(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div));
|
|
6734
6856
|
}
|
|
6735
6857
|
}
|
|
6736
6858
|
isEnabled(particle) {
|
|
@@ -6739,7 +6861,7 @@ class Bouncer extends ExternalInteractorBase {
|
|
|
6739
6861
|
mouse = container.interactivity.mouse,
|
|
6740
6862
|
events = (particle?.interactivity ?? options.interactivity).events,
|
|
6741
6863
|
divs = events.onDiv;
|
|
6742
|
-
return mouse.position && events.onHover.enable && isInArray(
|
|
6864
|
+
return mouse.position && events.onHover.enable && isInArray(bounceMode, events.onHover.mode) || isDivModeEnabled(bounceMode, divs);
|
|
6743
6865
|
}
|
|
6744
6866
|
loadModeOptions(options, ...sources) {
|
|
6745
6867
|
if (!options.bounce) {
|
|
@@ -6842,6 +6964,7 @@ function calculateBubbleValue(particleValue, modeValue, optionsValue, ratio) {
|
|
|
6842
6964
|
|
|
6843
6965
|
|
|
6844
6966
|
|
|
6967
|
+
const bubbleMode = "bubble";
|
|
6845
6968
|
class Bubbler extends ExternalInteractorBase {
|
|
6846
6969
|
constructor(container) {
|
|
6847
6970
|
super(container);
|
|
@@ -7078,7 +7201,7 @@ class Bubbler extends ExternalInteractorBase {
|
|
|
7078
7201
|
container.bubble = {};
|
|
7079
7202
|
}
|
|
7080
7203
|
this.handleClickMode = mode => {
|
|
7081
|
-
if (mode !==
|
|
7204
|
+
if (mode !== bubbleMode) {
|
|
7082
7205
|
return;
|
|
7083
7206
|
}
|
|
7084
7207
|
if (!container.bubble) {
|
|
@@ -7117,12 +7240,12 @@ class Bubbler extends ExternalInteractorBase {
|
|
|
7117
7240
|
clickEnabled = onClick.enable,
|
|
7118
7241
|
clickMode = onClick.mode,
|
|
7119
7242
|
divs = events.onDiv;
|
|
7120
|
-
if (hoverEnabled && isInArray(
|
|
7243
|
+
if (hoverEnabled && isInArray(bubbleMode, hoverMode)) {
|
|
7121
7244
|
this._hoverBubble();
|
|
7122
|
-
} else if (clickEnabled && isInArray(
|
|
7245
|
+
} else if (clickEnabled && isInArray(bubbleMode, clickMode)) {
|
|
7123
7246
|
this._clickBubble();
|
|
7124
7247
|
} else {
|
|
7125
|
-
divModeExecute(
|
|
7248
|
+
divModeExecute(bubbleMode, divs, (selector, div) => this._singleSelectorHover(delta, selector, div));
|
|
7126
7249
|
}
|
|
7127
7250
|
}
|
|
7128
7251
|
isEnabled(particle) {
|
|
@@ -7135,11 +7258,11 @@ class Bubbler extends ExternalInteractorBase {
|
|
|
7135
7258
|
onDiv,
|
|
7136
7259
|
onHover
|
|
7137
7260
|
} = events,
|
|
7138
|
-
divBubble = isDivModeEnabled(
|
|
7261
|
+
divBubble = isDivModeEnabled(bubbleMode, onDiv);
|
|
7139
7262
|
if (!(divBubble || onHover.enable && mouse.position || onClick.enable && mouse.clickPosition)) {
|
|
7140
7263
|
return false;
|
|
7141
7264
|
}
|
|
7142
|
-
return isInArray(
|
|
7265
|
+
return isInArray(bubbleMode, onHover.mode) || isInArray(bubbleMode, onClick.mode) || divBubble;
|
|
7143
7266
|
}
|
|
7144
7267
|
loadModeOptions(options, ...sources) {
|
|
7145
7268
|
if (!options.bubble) {
|
|
@@ -7246,6 +7369,7 @@ function drawConnection(container, p1, p2) {
|
|
|
7246
7369
|
|
|
7247
7370
|
|
|
7248
7371
|
|
|
7372
|
+
const connectMode = "connect";
|
|
7249
7373
|
class Connector extends ExternalInteractorBase {
|
|
7250
7374
|
constructor(container) {
|
|
7251
7375
|
super(container);
|
|
@@ -7293,7 +7417,7 @@ class Connector extends ExternalInteractorBase {
|
|
|
7293
7417
|
if (!(events.onHover.enable && mouse.position)) {
|
|
7294
7418
|
return false;
|
|
7295
7419
|
}
|
|
7296
|
-
return isInArray(
|
|
7420
|
+
return isInArray(connectMode, events.onHover.mode);
|
|
7297
7421
|
}
|
|
7298
7422
|
loadModeOptions(options, ...sources) {
|
|
7299
7423
|
if (!options.connect) {
|
|
@@ -7387,6 +7511,7 @@ function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
|
7387
7511
|
|
|
7388
7512
|
|
|
7389
7513
|
|
|
7514
|
+
const grabMode = "grab";
|
|
7390
7515
|
class Grabber extends ExternalInteractorBase {
|
|
7391
7516
|
constructor(container) {
|
|
7392
7517
|
super(container);
|
|
@@ -7444,7 +7569,7 @@ class Grabber extends ExternalInteractorBase {
|
|
|
7444
7569
|
const container = this.container,
|
|
7445
7570
|
mouse = container.interactivity.mouse,
|
|
7446
7571
|
events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
7447
|
-
return events.onHover.enable && !!mouse.position && isInArray(
|
|
7572
|
+
return events.onHover.enable && !!mouse.position && isInArray(grabMode, events.onHover.mode);
|
|
7448
7573
|
}
|
|
7449
7574
|
loadModeOptions(options, ...sources) {
|
|
7450
7575
|
if (!options.grab) {
|
|
@@ -7467,11 +7592,12 @@ async function loadExternalGrabInteraction(engine, refresh = true) {
|
|
|
7467
7592
|
|
|
7468
7593
|
;// CONCATENATED MODULE: ../../interactions/external/pause/dist/browser/Pauser.js
|
|
7469
7594
|
|
|
7595
|
+
const pauseMode = "pause";
|
|
7470
7596
|
class Pauser extends ExternalInteractorBase {
|
|
7471
7597
|
constructor(container) {
|
|
7472
7598
|
super(container);
|
|
7473
7599
|
this.handleClickMode = mode => {
|
|
7474
|
-
if (mode !==
|
|
7600
|
+
if (mode !== pauseMode) {
|
|
7475
7601
|
return;
|
|
7476
7602
|
}
|
|
7477
7603
|
const container = this.container;
|
|
@@ -7531,11 +7657,12 @@ class Push {
|
|
|
7531
7657
|
;// CONCATENATED MODULE: ../../interactions/external/push/dist/browser/Pusher.js
|
|
7532
7658
|
|
|
7533
7659
|
|
|
7660
|
+
const pushMode = "push";
|
|
7534
7661
|
class Pusher extends ExternalInteractorBase {
|
|
7535
7662
|
constructor(container) {
|
|
7536
7663
|
super(container);
|
|
7537
7664
|
this.handleClickMode = mode => {
|
|
7538
|
-
if (mode !==
|
|
7665
|
+
if (mode !== pushMode) {
|
|
7539
7666
|
return;
|
|
7540
7667
|
}
|
|
7541
7668
|
const container = this.container,
|
|
@@ -7601,13 +7728,14 @@ class Remove {
|
|
|
7601
7728
|
;// CONCATENATED MODULE: ../../interactions/external/remove/dist/browser/Remover.js
|
|
7602
7729
|
|
|
7603
7730
|
|
|
7731
|
+
const removeMode = "remove";
|
|
7604
7732
|
class Remover extends ExternalInteractorBase {
|
|
7605
7733
|
constructor(container) {
|
|
7606
7734
|
super(container);
|
|
7607
7735
|
this.handleClickMode = mode => {
|
|
7608
7736
|
const container = this.container,
|
|
7609
7737
|
options = container.actualOptions;
|
|
7610
|
-
if (!options.interactivity.modes.remove || mode !==
|
|
7738
|
+
if (!options.interactivity.modes.remove || mode !== removeMode) {
|
|
7611
7739
|
return;
|
|
7612
7740
|
}
|
|
7613
7741
|
const removeNb = getRangeValue(options.interactivity.modes.remove.quantity);
|
|
@@ -7708,6 +7836,7 @@ class Repulse extends RepulseBase {
|
|
|
7708
7836
|
;// CONCATENATED MODULE: ../../interactions/external/repulse/dist/browser/Repulser.js
|
|
7709
7837
|
|
|
7710
7838
|
|
|
7839
|
+
const repulseMode = "repulse";
|
|
7711
7840
|
class Repulser extends ExternalInteractorBase {
|
|
7712
7841
|
constructor(engine, container) {
|
|
7713
7842
|
super(container);
|
|
@@ -7780,14 +7909,21 @@ class Repulser extends ExternalInteractorBase {
|
|
|
7780
7909
|
if (!repulseOptions) {
|
|
7781
7910
|
return;
|
|
7782
7911
|
}
|
|
7912
|
+
const {
|
|
7913
|
+
easing,
|
|
7914
|
+
speed,
|
|
7915
|
+
factor,
|
|
7916
|
+
maxSpeed
|
|
7917
|
+
} = repulseOptions,
|
|
7918
|
+
easingFunc = getEasing(easing),
|
|
7919
|
+
velocity = (divRepulse?.speed ?? speed) * factor;
|
|
7783
7920
|
for (const particle of query) {
|
|
7784
7921
|
const {
|
|
7785
7922
|
dx,
|
|
7786
7923
|
dy,
|
|
7787
7924
|
distance
|
|
7788
7925
|
} = getDistances(particle.position, position),
|
|
7789
|
-
|
|
7790
|
-
repulseFactor = clamp(getEasing(repulseOptions.easing)(1 - distance / repulseRadius) * velocity, 0, repulseOptions.maxSpeed),
|
|
7926
|
+
repulseFactor = clamp(easingFunc(1 - distance / repulseRadius) * velocity, 0, maxSpeed),
|
|
7791
7927
|
normVec = Vector.create(distance === 0 ? velocity : dx / distance * repulseFactor, distance === 0 ? velocity : dy / distance * repulseFactor);
|
|
7792
7928
|
particle.position.addTo(normVec);
|
|
7793
7929
|
}
|
|
@@ -7825,7 +7961,7 @@ class Repulser extends ExternalInteractorBase {
|
|
|
7825
7961
|
this.handleClickMode = mode => {
|
|
7826
7962
|
const options = this.container.actualOptions,
|
|
7827
7963
|
repulseOpts = options.interactivity.modes.repulse;
|
|
7828
|
-
if (!repulseOpts || mode !==
|
|
7964
|
+
if (!repulseOpts || mode !== repulseMode) {
|
|
7829
7965
|
return;
|
|
7830
7966
|
}
|
|
7831
7967
|
if (!container.repulse) {
|
|
@@ -7873,12 +8009,12 @@ class Repulser extends ExternalInteractorBase {
|
|
|
7873
8009
|
clickEnabled = click.enable,
|
|
7874
8010
|
clickMode = click.mode,
|
|
7875
8011
|
divs = events.onDiv;
|
|
7876
|
-
if (mouseMoveStatus && hoverEnabled && isInArray(
|
|
8012
|
+
if (mouseMoveStatus && hoverEnabled && isInArray(repulseMode, hoverMode)) {
|
|
7877
8013
|
this._hoverRepulse();
|
|
7878
|
-
} else if (clickEnabled && isInArray(
|
|
8014
|
+
} else if (clickEnabled && isInArray(repulseMode, clickMode)) {
|
|
7879
8015
|
this._clickRepulse();
|
|
7880
8016
|
} else {
|
|
7881
|
-
divModeExecute(
|
|
8017
|
+
divModeExecute(repulseMode, divs, (selector, div) => this._singleSelectorRepulse(selector, div));
|
|
7882
8018
|
}
|
|
7883
8019
|
}
|
|
7884
8020
|
isEnabled(particle) {
|
|
@@ -7889,13 +8025,13 @@ class Repulser extends ExternalInteractorBase {
|
|
|
7889
8025
|
divs = events.onDiv,
|
|
7890
8026
|
hover = events.onHover,
|
|
7891
8027
|
click = events.onClick,
|
|
7892
|
-
divRepulse = isDivModeEnabled(
|
|
8028
|
+
divRepulse = isDivModeEnabled(repulseMode, divs);
|
|
7893
8029
|
if (!(divRepulse || hover.enable && mouse.position || click.enable && mouse.clickPosition)) {
|
|
7894
8030
|
return false;
|
|
7895
8031
|
}
|
|
7896
8032
|
const hoverMode = hover.mode,
|
|
7897
8033
|
clickMode = click.mode;
|
|
7898
|
-
return isInArray(
|
|
8034
|
+
return isInArray(repulseMode, hoverMode) || isInArray(repulseMode, clickMode) || divRepulse;
|
|
7899
8035
|
}
|
|
7900
8036
|
loadModeOptions(options, ...sources) {
|
|
7901
8037
|
if (!options.repulse) {
|
|
@@ -7939,6 +8075,7 @@ class Slow {
|
|
|
7939
8075
|
;// CONCATENATED MODULE: ../../interactions/external/slow/dist/browser/Slower.js
|
|
7940
8076
|
|
|
7941
8077
|
|
|
8078
|
+
const slowMode = "slow";
|
|
7942
8079
|
class Slower extends ExternalInteractorBase {
|
|
7943
8080
|
constructor(container) {
|
|
7944
8081
|
super(container);
|
|
@@ -7962,7 +8099,7 @@ class Slower extends ExternalInteractorBase {
|
|
|
7962
8099
|
const container = this.container,
|
|
7963
8100
|
mouse = container.interactivity.mouse,
|
|
7964
8101
|
events = (particle?.interactivity ?? container.actualOptions.interactivity).events;
|
|
7965
|
-
return events.onHover.enable && !!mouse.position && isInArray(
|
|
8102
|
+
return events.onHover.enable && !!mouse.position && isInArray(slowMode, events.onHover.mode);
|
|
7966
8103
|
}
|
|
7967
8104
|
loadModeOptions(options, ...sources) {
|
|
7968
8105
|
if (!options.slow) {
|
|
@@ -8554,8 +8691,15 @@ class ImageDrawer {
|
|
|
8554
8691
|
}
|
|
8555
8692
|
this._engine.images.push(image);
|
|
8556
8693
|
}
|
|
8557
|
-
draw(
|
|
8558
|
-
const
|
|
8694
|
+
draw(data) {
|
|
8695
|
+
const {
|
|
8696
|
+
context,
|
|
8697
|
+
radius,
|
|
8698
|
+
particle,
|
|
8699
|
+
opacity,
|
|
8700
|
+
delta
|
|
8701
|
+
} = data,
|
|
8702
|
+
image = particle.image,
|
|
8559
8703
|
element = image?.element;
|
|
8560
8704
|
if (!image) {
|
|
8561
8705
|
return;
|
|
@@ -8662,8 +8806,11 @@ class ImageDrawer {
|
|
|
8662
8806
|
if (!this._engine.images) {
|
|
8663
8807
|
this._engine.images = [];
|
|
8664
8808
|
}
|
|
8665
|
-
const imageData = particle.shapeData
|
|
8666
|
-
|
|
8809
|
+
const imageData = particle.shapeData;
|
|
8810
|
+
if (!imageData) {
|
|
8811
|
+
return;
|
|
8812
|
+
}
|
|
8813
|
+
const image = this._engine.images.find(t => t.name === imageData.name || t.source === imageData.src);
|
|
8667
8814
|
if (!image) {
|
|
8668
8815
|
this.loadImageShape(imageData).then(() => {
|
|
8669
8816
|
this.loadShape(particle);
|
|
@@ -8678,8 +8825,11 @@ class ImageDrawer {
|
|
|
8678
8825
|
this._engine.images = [];
|
|
8679
8826
|
}
|
|
8680
8827
|
const images = this._engine.images,
|
|
8681
|
-
imageData = particle.shapeData
|
|
8682
|
-
|
|
8828
|
+
imageData = particle.shapeData;
|
|
8829
|
+
if (!imageData) {
|
|
8830
|
+
return;
|
|
8831
|
+
}
|
|
8832
|
+
const color = particle.getFillColor(),
|
|
8683
8833
|
image = images.find(t => t.name === imageData.name || t.source === imageData.src);
|
|
8684
8834
|
if (!image) {
|
|
8685
8835
|
return;
|
|
@@ -8712,16 +8862,16 @@ class ImageDrawer {
|
|
|
8712
8862
|
if (!imageRes.ratio) {
|
|
8713
8863
|
imageRes.ratio = 1;
|
|
8714
8864
|
}
|
|
8715
|
-
const fill = imageData.fill ?? particle.
|
|
8716
|
-
close = imageData.close ?? particle.
|
|
8865
|
+
const fill = imageData.fill ?? particle.shapeFill,
|
|
8866
|
+
close = imageData.close ?? particle.shapeClose,
|
|
8717
8867
|
imageShape = {
|
|
8718
8868
|
image: imageRes,
|
|
8719
8869
|
fill,
|
|
8720
8870
|
close
|
|
8721
8871
|
};
|
|
8722
8872
|
particle.image = imageShape.image;
|
|
8723
|
-
particle.
|
|
8724
|
-
particle.
|
|
8873
|
+
particle.shapeFill = imageShape.fill;
|
|
8874
|
+
particle.shapeClose = imageShape.close;
|
|
8725
8875
|
})();
|
|
8726
8876
|
}
|
|
8727
8877
|
}
|
|
@@ -8854,7 +9004,6 @@ class LifeDelay extends ValueWithRandom {
|
|
|
8854
9004
|
class LifeDuration extends ValueWithRandom {
|
|
8855
9005
|
constructor() {
|
|
8856
9006
|
super();
|
|
8857
|
-
this.random.minimumValue = 0.0001;
|
|
8858
9007
|
this.sync = false;
|
|
8859
9008
|
}
|
|
8860
9009
|
load(data) {
|
|
@@ -8991,8 +9140,13 @@ async function loadLifeUpdater(engine, refresh = true) {
|
|
|
8991
9140
|
}
|
|
8992
9141
|
;// CONCATENATED MODULE: ../../shapes/line/dist/browser/LineDrawer.js
|
|
8993
9142
|
class LineDrawer {
|
|
8994
|
-
draw(
|
|
8995
|
-
const
|
|
9143
|
+
draw(data) {
|
|
9144
|
+
const {
|
|
9145
|
+
context,
|
|
9146
|
+
particle,
|
|
9147
|
+
radius
|
|
9148
|
+
} = data,
|
|
9149
|
+
shapeData = particle.shapeData;
|
|
8996
9150
|
context.moveTo(-radius / 2, 0);
|
|
8997
9151
|
context.lineTo(radius / 2, 0);
|
|
8998
9152
|
context.lineCap = shapeData?.cap ?? "butt";
|
|
@@ -9027,8 +9181,8 @@ class ParallaxMover {
|
|
|
9027
9181
|
}
|
|
9028
9182
|
const canvasSize = container.canvas.size,
|
|
9029
9183
|
canvasCenter = {
|
|
9030
|
-
x: canvasSize.width
|
|
9031
|
-
y: canvasSize.height
|
|
9184
|
+
x: canvasSize.width * 0.5,
|
|
9185
|
+
y: canvasSize.height * 0.5
|
|
9032
9186
|
},
|
|
9033
9187
|
parallaxSmooth = parallaxOptions.smooth,
|
|
9034
9188
|
factor = particle.getRadius() / parallaxForce,
|
|
@@ -9057,8 +9211,11 @@ class Attractor_Attractor extends ParticlesInteractorBase {
|
|
|
9057
9211
|
clear() {}
|
|
9058
9212
|
init() {}
|
|
9059
9213
|
async interact(p1) {
|
|
9060
|
-
const container = this.container
|
|
9061
|
-
|
|
9214
|
+
const container = this.container;
|
|
9215
|
+
if (p1.attractDistance === undefined) {
|
|
9216
|
+
p1.attractDistance = getRangeValue(p1.options.move.attract.distance) * container.retina.pixelRatio;
|
|
9217
|
+
}
|
|
9218
|
+
const distance = p1.attractDistance,
|
|
9062
9219
|
pos1 = p1.getPosition(),
|
|
9063
9220
|
query = container.particles.quadTree.queryCircle(pos1, distance);
|
|
9064
9221
|
for (const p2 of query) {
|
|
@@ -9475,6 +9632,13 @@ async function loadLinksInteraction(engine, refresh = true) {
|
|
|
9475
9632
|
}
|
|
9476
9633
|
;// CONCATENATED MODULE: ../../interactions/particles/links/dist/browser/Utils.js
|
|
9477
9634
|
|
|
9635
|
+
function drawTriangle(context, p1, p2, p3) {
|
|
9636
|
+
context.beginPath();
|
|
9637
|
+
context.moveTo(p1.x, p1.y);
|
|
9638
|
+
context.lineTo(p2.x, p2.y);
|
|
9639
|
+
context.lineTo(p3.x, p3.y);
|
|
9640
|
+
context.closePath();
|
|
9641
|
+
}
|
|
9478
9642
|
function drawLinkLine(params) {
|
|
9479
9643
|
let drawn = false;
|
|
9480
9644
|
const {
|
|
@@ -9808,8 +9972,13 @@ async function loadParticlesLinksInteraction(engine, refresh = true) {
|
|
|
9808
9972
|
;// CONCATENATED MODULE: ../../shapes/polygon/dist/browser/PolygonDrawerBase.js
|
|
9809
9973
|
|
|
9810
9974
|
class PolygonDrawerBase {
|
|
9811
|
-
draw(
|
|
9812
|
-
const
|
|
9975
|
+
draw(data) {
|
|
9976
|
+
const {
|
|
9977
|
+
context,
|
|
9978
|
+
particle,
|
|
9979
|
+
radius
|
|
9980
|
+
} = data,
|
|
9981
|
+
start = this.getCenter(particle, radius),
|
|
9813
9982
|
side = this.getSidesData(particle, radius),
|
|
9814
9983
|
sideCount = side.count.numerator * side.count.denominator,
|
|
9815
9984
|
decimalSides = side.count.numerator / side.count.denominator,
|
|
@@ -10043,8 +10212,12 @@ async function loadRotateUpdater(engine, refresh = true) {
|
|
|
10043
10212
|
;// CONCATENATED MODULE: ../../shapes/square/dist/browser/SquareDrawer.js
|
|
10044
10213
|
const fixFactor = Math.sqrt(2);
|
|
10045
10214
|
class SquareDrawer {
|
|
10046
|
-
draw(
|
|
10047
|
-
const
|
|
10215
|
+
draw(data) {
|
|
10216
|
+
const {
|
|
10217
|
+
context,
|
|
10218
|
+
radius
|
|
10219
|
+
} = data,
|
|
10220
|
+
fixedRadius = radius / fixFactor,
|
|
10048
10221
|
fixedDiameter = fixedRadius * 2;
|
|
10049
10222
|
context.rect(-fixedRadius, -fixedRadius, fixedDiameter, fixedDiameter);
|
|
10050
10223
|
}
|
|
@@ -10060,8 +10233,13 @@ async function loadSquareShape(engine, refresh = true) {
|
|
|
10060
10233
|
;// CONCATENATED MODULE: ../../shapes/star/dist/browser/StarDrawer.js
|
|
10061
10234
|
|
|
10062
10235
|
class StarDrawer {
|
|
10063
|
-
draw(
|
|
10064
|
-
const
|
|
10236
|
+
draw(data) {
|
|
10237
|
+
const {
|
|
10238
|
+
context,
|
|
10239
|
+
particle,
|
|
10240
|
+
radius
|
|
10241
|
+
} = data,
|
|
10242
|
+
sides = particle.sides,
|
|
10065
10243
|
inset = particle.starInset ?? 2;
|
|
10066
10244
|
context.moveTo(0, 0 - radius);
|
|
10067
10245
|
for (let i = 0; i < sides; i++) {
|
|
@@ -10197,11 +10375,31 @@ async function loadStrokeColorUpdater(engine, refresh = true) {
|
|
|
10197
10375
|
}
|
|
10198
10376
|
;// CONCATENATED MODULE: ../../shapes/text/dist/browser/TextDrawer.js
|
|
10199
10377
|
|
|
10200
|
-
const validTypes = ["text", "character", "char"];
|
|
10378
|
+
const validTypes = ["text", "character", "char", "multiline-text"];
|
|
10201
10379
|
class TextDrawer {
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10380
|
+
constructor() {
|
|
10381
|
+
this._drawLine = (context, line, radius, opacity, index, fill) => {
|
|
10382
|
+
const offsetX = line.length * radius / 2,
|
|
10383
|
+
pos = {
|
|
10384
|
+
x: -offsetX,
|
|
10385
|
+
y: radius / 2
|
|
10386
|
+
};
|
|
10387
|
+
if (fill) {
|
|
10388
|
+
context.fillText(line, pos.x, pos.y + radius * 2 * index);
|
|
10389
|
+
} else {
|
|
10390
|
+
context.strokeText(line, pos.x, pos.y + radius * 2 * index);
|
|
10391
|
+
}
|
|
10392
|
+
};
|
|
10393
|
+
}
|
|
10394
|
+
draw(data) {
|
|
10395
|
+
const {
|
|
10396
|
+
context,
|
|
10397
|
+
particle,
|
|
10398
|
+
radius,
|
|
10399
|
+
opacity
|
|
10400
|
+
} = data,
|
|
10401
|
+
character = particle.shapeData;
|
|
10402
|
+
if (!character) {
|
|
10205
10403
|
return;
|
|
10206
10404
|
}
|
|
10207
10405
|
const textData = character.value;
|
|
@@ -10216,24 +10414,18 @@ class TextDrawer {
|
|
|
10216
10414
|
weight = character.weight ?? "400",
|
|
10217
10415
|
size = Math.round(radius) * 2,
|
|
10218
10416
|
font = character.font ?? "Verdana",
|
|
10219
|
-
fill = particle.
|
|
10220
|
-
|
|
10417
|
+
fill = particle.shapeFill;
|
|
10418
|
+
const lines = text?.split("\n");
|
|
10419
|
+
if (!lines) {
|
|
10420
|
+
return;
|
|
10421
|
+
}
|
|
10221
10422
|
context.font = `${style} ${weight} ${size}px "${font}"`;
|
|
10222
|
-
const pos = {
|
|
10223
|
-
x: -offsetX,
|
|
10224
|
-
y: radius / 2
|
|
10225
|
-
};
|
|
10226
10423
|
context.globalAlpha = opacity;
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
} else {
|
|
10230
|
-
context.strokeText(text, pos.x, pos.y);
|
|
10424
|
+
for (let i = 0; i < lines.length; i++) {
|
|
10425
|
+
this._drawLine(context, lines[i], radius, opacity, i, fill);
|
|
10231
10426
|
}
|
|
10232
10427
|
context.globalAlpha = 1;
|
|
10233
10428
|
}
|
|
10234
|
-
getSidesCount() {
|
|
10235
|
-
return 12;
|
|
10236
|
-
}
|
|
10237
10429
|
async init(container) {
|
|
10238
10430
|
const options = container.actualOptions;
|
|
10239
10431
|
if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
|