@tsparticles/stencil 4.2.1 → 4.3.1
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/dist/cjs/{Container-BIhHE6mu.js → Container-DwRv_rua.js} +162 -74
- package/dist/cjs/{index-BIoj1BEO.js → index-BEJx8swj.js} +21 -11
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/stencil-particles.cjs.entry.js +1 -1
- package/dist/esm/{Container-DZZsfp6i.js → Container-COqetWkt.js} +162 -74
- package/dist/esm/{index-BH3sNkGS.js → index-uBrXcY8m.js} +22 -12
- package/dist/esm/index.js +1 -1
- package/dist/esm/stencil-particles.entry.js +1 -1
- package/dist/tsparticlesstencil/index.esm.js +1 -1
- package/dist/tsparticlesstencil/{p-bd76f15b.entry.js → p-0204e6c5.entry.js} +1 -1
- package/dist/tsparticlesstencil/p-BMflXhxM.js +1 -0
- package/dist/tsparticlesstencil/p-Buaac_o7.js +1 -0
- package/dist/tsparticlesstencil/tsparticlesstencil.esm.js +1 -1
- package/package.json +3 -3
- package/dist/tsparticlesstencil/p-CIUgBOXY.js +0 -1
- package/dist/tsparticlesstencil/p-QSzGOBhI.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RangeType, c as checkDistance, s as squareExp, a as isNull, b as setRangeValue, h as hMin, d as hMax, l as lMin, e as lMax, f as sMin, g as sMax, j as isString, k as isArray, m as deepExtend, P as PixelMode, O as OutMode, M as MoveDirection, n as isNumber, o as isObject, L as LimitMode, p as executeOnSingleOrMultiple, q as isBoolean, r as itemFromArray, u as defaultOpacity, v as randomColorValue, A as AlterType, w as lFactor, x as half, y as double, z as hPhase, B as rgbMax, C as getRandomInRange, D as identity, E as defaultRgbMin, F as maxNits, G as sextuple, H as triple, I as phaseNumerator, J as sNormalizedOffset, K as originPoint, N as
|
|
1
|
+
import { R as RangeType, c as checkDistance, s as squareExp, a as isNull, b as setRangeValue, h as hMin, d as hMax, l as lMin, e as lMax, f as sMin, g as sMax, j as isString, k as isArray, m as deepExtend, P as PixelMode, O as OutMode, M as MoveDirection, n as isNumber, o as isObject, L as LimitMode, p as executeOnSingleOrMultiple, q as isBoolean, r as itemFromArray, u as defaultOpacity, v as randomColorValue, A as AlterType, w as lFactor, x as half, y as double, z as hPhase, B as rgbMax, C as getRandomInRange, D as identity, E as defaultRgbMin, F as maxNits, G as sextuple, H as triple, I as phaseNumerator, J as sNormalizedOffset, K as originPoint, N as DrawLayer, Q as minimumSize, S as defaultCompositeValue, T as minStrokeWidth, U as defaultZoom, V as getLogger, W as zIndexFactorOffset, X as defaultTransformValue, Y as safeMutationObserver, Z as generatedAttribute, _ as cloneStyle, $ as safeMatchMedia, a0 as getFullScreenStyle, a1 as safeDocument, a2 as millisecondsToSeconds, a3 as manageListener, a4 as visibilityChangeEvent, a5 as resizeEvent, a6 as Vector3d, a7 as EventType, a8 as defaultAngle, a9 as defaultTransform, aa as defaultRetryCount, ab as tryCountIncrement, ac as getParticleBaseVelocity, ad as randomInRangeValue, ae as getRandom, af as OutModeDirection, ag as clamp, ah as minZ, ai as getPosition, aj as getParticleDirectionAngle, ak as ParticleOutType, al as Vector, am as calcExactPositionOrRandomFromSize, an as getRangeValue, ao as itemFromSingleOrMultiple, ap as isInArray, aq as doublePI, ar as degToRad, as as spatialHashGridCellSize, at as minLimit, au as minCount, av as minIndex, aw as defaultRemoveQuantity, ax as defaultDensityFactor, ay as deleteCount, az as countOffset, aA as one, aB as defaultRatio, aC as defaultReduceFactor, aD as animate, aE as defaultFpsLimit, aF as minFpsLimit, aG as cancelAnimation, aH as defaultFps } from './index-uBrXcY8m.js';
|
|
2
2
|
|
|
3
3
|
class BaseRange {
|
|
4
4
|
position;
|
|
@@ -204,6 +204,8 @@ class AnimatableColor extends OptionsColor {
|
|
|
204
204
|
|
|
205
205
|
class Background extends OptionLoader {
|
|
206
206
|
color;
|
|
207
|
+
draw;
|
|
208
|
+
element;
|
|
207
209
|
image = "";
|
|
208
210
|
opacity = 1;
|
|
209
211
|
position = "";
|
|
@@ -218,6 +220,8 @@ class Background extends OptionLoader {
|
|
|
218
220
|
if (data.color !== undefined) {
|
|
219
221
|
this.color = OptionsColor.create(this.color, data.color);
|
|
220
222
|
}
|
|
223
|
+
loadProperty(this, "element", data.element);
|
|
224
|
+
loadProperty(this, "draw", data.draw);
|
|
221
225
|
loadProperty(this, "image", data.image);
|
|
222
226
|
loadProperty(this, "position", data.position);
|
|
223
227
|
loadProperty(this, "repeat", data.repeat);
|
|
@@ -753,7 +757,7 @@ class Options extends OptionLoader {
|
|
|
753
757
|
}
|
|
754
758
|
}
|
|
755
759
|
|
|
756
|
-
const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, sdrReferenceWhiteNits = 203;
|
|
760
|
+
const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, hdrRgbFixedPrecision = 4, hdrHslFixedPrecision = 4, sdrReferenceWhiteNits = 203;
|
|
757
761
|
function getCachedStyle(key, generator) {
|
|
758
762
|
let cached = styleCache.get(key);
|
|
759
763
|
if (!cached) {
|
|
@@ -882,19 +886,20 @@ function hslChannel(temp1, temp2, temp3) {
|
|
|
882
886
|
}
|
|
883
887
|
return temp1;
|
|
884
888
|
}
|
|
885
|
-
function
|
|
889
|
+
function hslToRgbFloat(hsl) {
|
|
886
890
|
const h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax;
|
|
887
891
|
if (s === sMin) {
|
|
888
|
-
const grayscaleValue =
|
|
892
|
+
const grayscaleValue = lNormalized * rgbMax;
|
|
889
893
|
return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
|
|
890
894
|
}
|
|
891
895
|
const temp1 = lNormalized < half
|
|
892
896
|
? lNormalized * (sNormalizedOffset + sNormalized)
|
|
893
897
|
: lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseThird = phaseNumerator / triple, red = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized + phaseThird)), green = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized)), blue = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized - phaseThird));
|
|
894
|
-
return { r:
|
|
898
|
+
return { r: red, g: green, b: blue };
|
|
895
899
|
}
|
|
896
|
-
function getRandomRgbColor(min) {
|
|
897
|
-
const fixedMin = defaultRgbMin
|
|
900
|
+
function getRandomRgbColor(min, hdr) {
|
|
901
|
+
const fixedMin = defaultRgbMin;
|
|
902
|
+
const fixedMax = rgbMax + identity, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
|
|
898
903
|
return {
|
|
899
904
|
b: getRgbInRangeValue(),
|
|
900
905
|
g: getRgbInRangeValue(),
|
|
@@ -902,7 +907,7 @@ function getRandomRgbColor(min) {
|
|
|
902
907
|
};
|
|
903
908
|
}
|
|
904
909
|
function getStyleFromRgb(color, hdr, opacity) {
|
|
905
|
-
const op = opacity ?? defaultOpacity, key = `rgb-${color.r.toFixed(
|
|
910
|
+
const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? defaultOpacity, key = `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
|
|
906
911
|
return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
|
|
907
912
|
}
|
|
908
913
|
function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
|
|
@@ -913,9 +918,9 @@ function getSdrStyleFromRgb(color, opacity) {
|
|
|
913
918
|
return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity).toString()})`;
|
|
914
919
|
}
|
|
915
920
|
function getStyleFromHsl(color, hdr, opacity) {
|
|
916
|
-
const op = opacity ?? defaultOpacity, key = `hsl-${color.h.toFixed(
|
|
921
|
+
const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? defaultOpacity, key = `hsl-${color.h.toFixed(hslPrecision)}-${color.s.toFixed(hslPrecision)}-${color.l.toFixed(hslPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
|
|
917
922
|
return getCachedStyle(key, () => hdr
|
|
918
|
-
? getStyleFromRgb(
|
|
923
|
+
? getStyleFromRgb(hslToRgbFloat(color), true, opacity)
|
|
919
924
|
: `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
|
|
920
925
|
}
|
|
921
926
|
function getHslFromAnimation(animation) {
|
|
@@ -943,10 +948,10 @@ function setTransformValue(factor, newFactor, key) {
|
|
|
943
948
|
}
|
|
944
949
|
}
|
|
945
950
|
class RenderManager {
|
|
951
|
+
#backgroundElement;
|
|
952
|
+
#backgroundWarnings;
|
|
946
953
|
#canvasClearPlugins;
|
|
947
954
|
#canvasManager;
|
|
948
|
-
#canvasPaintPlugins;
|
|
949
|
-
#clearDrawPlugins;
|
|
950
955
|
#colorPlugins;
|
|
951
956
|
#container;
|
|
952
957
|
#context;
|
|
@@ -954,9 +959,7 @@ class RenderManager {
|
|
|
954
959
|
#drawParticlePlugins;
|
|
955
960
|
#drawParticlesCleanupPlugins;
|
|
956
961
|
#drawParticlesSetupPlugins;
|
|
957
|
-
#
|
|
958
|
-
#drawSettingsCleanupPlugins;
|
|
959
|
-
#drawSettingsSetupPlugins;
|
|
962
|
+
#layers;
|
|
960
963
|
#pluginManager;
|
|
961
964
|
#postDrawUpdaters;
|
|
962
965
|
#preDrawUpdaters;
|
|
@@ -968,18 +971,25 @@ class RenderManager {
|
|
|
968
971
|
this.#container = container;
|
|
969
972
|
this.#canvasManager = canvasManager;
|
|
970
973
|
this.#context = null;
|
|
974
|
+
this.#backgroundElement = null;
|
|
975
|
+
this.#backgroundWarnings = new Set();
|
|
971
976
|
this.#preDrawUpdaters = [];
|
|
972
977
|
this.#postDrawUpdaters = [];
|
|
973
|
-
this.#colorPlugins = [];
|
|
974
978
|
this.#canvasClearPlugins = [];
|
|
975
|
-
this.#
|
|
976
|
-
this.#clearDrawPlugins = [];
|
|
979
|
+
this.#colorPlugins = [];
|
|
977
980
|
this.#drawParticlePlugins = [];
|
|
978
981
|
this.#drawParticlesCleanupPlugins = [];
|
|
979
982
|
this.#drawParticlesSetupPlugins = [];
|
|
980
|
-
this.#
|
|
981
|
-
|
|
982
|
-
|
|
983
|
+
this.#layers = {
|
|
984
|
+
0: [],
|
|
985
|
+
1: [],
|
|
986
|
+
2: [],
|
|
987
|
+
3: [],
|
|
988
|
+
4: [],
|
|
989
|
+
5: [],
|
|
990
|
+
6: [],
|
|
991
|
+
7: [],
|
|
992
|
+
};
|
|
983
993
|
}
|
|
984
994
|
get settings() {
|
|
985
995
|
return this.#contextSettings;
|
|
@@ -993,32 +1003,38 @@ class RenderManager {
|
|
|
993
1003
|
});
|
|
994
1004
|
}
|
|
995
1005
|
clear() {
|
|
996
|
-
let pluginHandled = false;
|
|
997
1006
|
for (const plugin of this.#canvasClearPlugins) {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
break;
|
|
1007
|
+
if (plugin.canvasClear?.() ?? false) {
|
|
1008
|
+
return;
|
|
1001
1009
|
}
|
|
1002
1010
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1011
|
+
for (const layer of Object.values(DrawLayer)) {
|
|
1012
|
+
if (typeof layer === "number") {
|
|
1013
|
+
for (const plugin of this.#getLayerPlugins(layer)) {
|
|
1014
|
+
if (plugin.canvasClear?.() ?? false) {
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1005
1019
|
}
|
|
1006
1020
|
this.canvasClear();
|
|
1007
1021
|
}
|
|
1008
1022
|
destroy() {
|
|
1009
1023
|
this.stop();
|
|
1024
|
+
this.#backgroundElement = null;
|
|
1025
|
+
this.#backgroundWarnings.clear();
|
|
1010
1026
|
this.#preDrawUpdaters = [];
|
|
1011
1027
|
this.#postDrawUpdaters = [];
|
|
1012
|
-
this.#colorPlugins = [];
|
|
1013
1028
|
this.#canvasClearPlugins = [];
|
|
1014
|
-
this.#
|
|
1015
|
-
this.#clearDrawPlugins = [];
|
|
1029
|
+
this.#colorPlugins = [];
|
|
1016
1030
|
this.#drawParticlePlugins = [];
|
|
1017
1031
|
this.#drawParticlesCleanupPlugins = [];
|
|
1018
1032
|
this.#drawParticlesSetupPlugins = [];
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1033
|
+
for (const layer of Object.values(DrawLayer)) {
|
|
1034
|
+
if (typeof layer === "number") {
|
|
1035
|
+
this.#layers[layer] = [];
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1022
1038
|
}
|
|
1023
1039
|
draw(cb) {
|
|
1024
1040
|
const ctx = this.#context;
|
|
@@ -1075,21 +1091,40 @@ class RenderManager {
|
|
|
1075
1091
|
});
|
|
1076
1092
|
}
|
|
1077
1093
|
drawParticles(delta) {
|
|
1078
|
-
const { particles } = this.#container;
|
|
1094
|
+
const { particles, actualOptions } = this.#container;
|
|
1079
1095
|
this.clear();
|
|
1080
1096
|
particles.update(delta);
|
|
1081
1097
|
this.draw(ctx => {
|
|
1082
|
-
|
|
1098
|
+
const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
|
|
1099
|
+
if (this.#backgroundElement) {
|
|
1100
|
+
try {
|
|
1101
|
+
ctx.drawImage(this.#backgroundElement, originPoint.x, originPoint.y, width, height);
|
|
1102
|
+
}
|
|
1103
|
+
catch {
|
|
1104
|
+
this.#warnOnce("background-element-draw-error", "Error drawing background element onto canvas");
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
const background = actualOptions.background;
|
|
1108
|
+
if (background.draw) {
|
|
1109
|
+
try {
|
|
1110
|
+
background.draw(ctx, delta);
|
|
1111
|
+
}
|
|
1112
|
+
catch {
|
|
1113
|
+
this.#warnOnce("background-draw-error", "Error in background.draw callback");
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
|
|
1117
|
+
plugin.canvasPaint?.();
|
|
1118
|
+
}
|
|
1119
|
+
for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
|
|
1083
1120
|
plugin.drawSettingsSetup?.(ctx, delta);
|
|
1084
1121
|
}
|
|
1085
|
-
for (const plugin of this.#
|
|
1122
|
+
for (const plugin of this.#getLayerPlugins(DrawLayer.PluginContent)) {
|
|
1086
1123
|
plugin.draw?.(ctx, delta);
|
|
1087
1124
|
}
|
|
1088
1125
|
particles.drawParticles(delta);
|
|
1089
|
-
for (const plugin of this.#
|
|
1126
|
+
for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasCleanup)) {
|
|
1090
1127
|
plugin.clearDraw?.(ctx, delta);
|
|
1091
|
-
}
|
|
1092
|
-
for (const plugin of this.#drawSettingsCleanupPlugins) {
|
|
1093
1128
|
plugin.drawSettingsCleanup?.(ctx, delta);
|
|
1094
1129
|
}
|
|
1095
1130
|
});
|
|
@@ -1097,29 +1132,24 @@ class RenderManager {
|
|
|
1097
1132
|
init() {
|
|
1098
1133
|
this.initUpdaters();
|
|
1099
1134
|
this.initPlugins();
|
|
1135
|
+
this.#resolveBackgroundElement();
|
|
1100
1136
|
this.paint();
|
|
1101
1137
|
}
|
|
1102
1138
|
initPlugins() {
|
|
1103
|
-
this.#colorPlugins = [];
|
|
1104
1139
|
this.#canvasClearPlugins = [];
|
|
1105
|
-
this.#
|
|
1106
|
-
this.#clearDrawPlugins = [];
|
|
1140
|
+
this.#colorPlugins = [];
|
|
1107
1141
|
this.#drawParticlePlugins = [];
|
|
1108
1142
|
this.#drawParticlesSetupPlugins = [];
|
|
1109
1143
|
this.#drawParticlesCleanupPlugins = [];
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1144
|
+
for (const layer of Object.values(DrawLayer)) {
|
|
1145
|
+
if (typeof layer === "number") {
|
|
1146
|
+
this.#layers[layer] = [];
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1113
1149
|
for (const plugin of this.#container.plugins) {
|
|
1114
1150
|
if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
|
|
1115
1151
|
this.#colorPlugins.push(plugin);
|
|
1116
1152
|
}
|
|
1117
|
-
if (plugin.canvasClear) {
|
|
1118
|
-
this.#canvasClearPlugins.push(plugin);
|
|
1119
|
-
}
|
|
1120
|
-
if (plugin.canvasPaint) {
|
|
1121
|
-
this.#canvasPaintPlugins.push(plugin);
|
|
1122
|
-
}
|
|
1123
1153
|
if (plugin.drawParticle) {
|
|
1124
1154
|
this.#drawParticlePlugins.push(plugin);
|
|
1125
1155
|
}
|
|
@@ -1129,17 +1159,20 @@ class RenderManager {
|
|
|
1129
1159
|
if (plugin.drawParticleCleanup) {
|
|
1130
1160
|
this.#drawParticlesCleanupPlugins.push(plugin);
|
|
1131
1161
|
}
|
|
1132
|
-
if (plugin.
|
|
1133
|
-
this.#
|
|
1162
|
+
if (plugin.canvasClear) {
|
|
1163
|
+
this.#canvasClearPlugins.push(plugin);
|
|
1164
|
+
}
|
|
1165
|
+
if (plugin.canvasPaint) {
|
|
1166
|
+
this.#getLayerPlugins(DrawLayer.BackgroundMask).push(plugin);
|
|
1134
1167
|
}
|
|
1135
1168
|
if (plugin.drawSettingsSetup) {
|
|
1136
|
-
this.#
|
|
1169
|
+
this.#getLayerPlugins(DrawLayer.CanvasSetup).push(plugin);
|
|
1137
1170
|
}
|
|
1138
|
-
if (plugin.
|
|
1139
|
-
this.#
|
|
1171
|
+
if (plugin.draw) {
|
|
1172
|
+
this.#getLayerPlugins(DrawLayer.PluginContent).push(plugin);
|
|
1140
1173
|
}
|
|
1141
|
-
if (plugin.clearDraw) {
|
|
1142
|
-
this.#
|
|
1174
|
+
if (plugin.clearDraw ?? plugin.drawSettingsCleanup) {
|
|
1175
|
+
this.#getLayerPlugins(DrawLayer.CanvasCleanup).push(plugin);
|
|
1143
1176
|
}
|
|
1144
1177
|
}
|
|
1145
1178
|
}
|
|
@@ -1157,7 +1190,7 @@ class RenderManager {
|
|
|
1157
1190
|
}
|
|
1158
1191
|
paint() {
|
|
1159
1192
|
let handled = false;
|
|
1160
|
-
for (const plugin of this.#
|
|
1193
|
+
for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
|
|
1161
1194
|
handled = plugin.canvasPaint?.() ?? false;
|
|
1162
1195
|
if (handled) {
|
|
1163
1196
|
break;
|
|
@@ -1330,6 +1363,9 @@ class RenderManager {
|
|
|
1330
1363
|
}
|
|
1331
1364
|
drawer.beforeDraw(data);
|
|
1332
1365
|
}
|
|
1366
|
+
#getLayerPlugins(layer) {
|
|
1367
|
+
return this.#layers[layer];
|
|
1368
|
+
}
|
|
1333
1369
|
#getPluginParticleColors(particle) {
|
|
1334
1370
|
let fColor, sColor;
|
|
1335
1371
|
for (const plugin of this.#colorPlugins) {
|
|
@@ -1347,6 +1383,39 @@ class RenderManager {
|
|
|
1347
1383
|
this.#reusablePluginColors[sColorIndex] = sColor;
|
|
1348
1384
|
return this.#reusablePluginColors;
|
|
1349
1385
|
}
|
|
1386
|
+
#resolveBackgroundElement() {
|
|
1387
|
+
const background = this.#container.actualOptions.background;
|
|
1388
|
+
this.#backgroundElement = null;
|
|
1389
|
+
if (!background.element) {
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
if (typeof background.element === "string") {
|
|
1393
|
+
if (typeof document !== "undefined") {
|
|
1394
|
+
const node = document.querySelector(background.element);
|
|
1395
|
+
if (node instanceof HTMLCanvasElement || node instanceof HTMLVideoElement || node instanceof HTMLImageElement) {
|
|
1396
|
+
this.#backgroundElement = node;
|
|
1397
|
+
}
|
|
1398
|
+
else if (node) {
|
|
1399
|
+
this.#warnOnce("background-element-not-supported", `Background element "${background.element}" is not a supported drawable element (canvas, video, or img)`);
|
|
1400
|
+
}
|
|
1401
|
+
else {
|
|
1402
|
+
this.#warnOnce("background-element-not-found", `Background element selector "${background.element}" not found`);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
else if (background.element instanceof HTMLCanvasElement ||
|
|
1407
|
+
background.element instanceof OffscreenCanvas ||
|
|
1408
|
+
background.element instanceof HTMLVideoElement ||
|
|
1409
|
+
background.element instanceof HTMLImageElement) {
|
|
1410
|
+
this.#backgroundElement = background.element;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
#warnOnce(key, message) {
|
|
1414
|
+
if (!this.#backgroundWarnings.has(key)) {
|
|
1415
|
+
this.#backgroundWarnings.add(key);
|
|
1416
|
+
getLogger().warning(message);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1350
1419
|
}
|
|
1351
1420
|
|
|
1352
1421
|
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
@@ -1923,7 +1992,6 @@ function runParticleCreatedPlugins(container, particle) {
|
|
|
1923
1992
|
}
|
|
1924
1993
|
class Particle {
|
|
1925
1994
|
backColor;
|
|
1926
|
-
bubble;
|
|
1927
1995
|
destroyed;
|
|
1928
1996
|
direction;
|
|
1929
1997
|
effect;
|
|
@@ -1957,7 +2025,6 @@ class Particle {
|
|
|
1957
2025
|
shapeData;
|
|
1958
2026
|
sides;
|
|
1959
2027
|
size;
|
|
1960
|
-
slow;
|
|
1961
2028
|
spawning;
|
|
1962
2029
|
strokeColor;
|
|
1963
2030
|
strokeOpacity;
|
|
@@ -1979,18 +2046,25 @@ class Particle {
|
|
|
1979
2046
|
d: 1,
|
|
1980
2047
|
};
|
|
1981
2048
|
#container;
|
|
2049
|
+
#modifiers = [];
|
|
1982
2050
|
#pluginManager;
|
|
1983
2051
|
constructor(pluginManager, container) {
|
|
1984
2052
|
this.#pluginManager = pluginManager;
|
|
1985
2053
|
this.#container = container;
|
|
1986
2054
|
}
|
|
2055
|
+
addModifier(modifier) {
|
|
2056
|
+
this.#modifiers.push(modifier);
|
|
2057
|
+
this.#modifiers.sort((a, b) => a.priority - b.priority);
|
|
2058
|
+
}
|
|
2059
|
+
clearModifiers() {
|
|
2060
|
+
this.#modifiers.length = 0;
|
|
2061
|
+
}
|
|
1987
2062
|
destroy(override) {
|
|
1988
2063
|
if (this.unbreakable || this.destroyed) {
|
|
1989
2064
|
return;
|
|
1990
2065
|
}
|
|
1991
2066
|
this.destroyed = true;
|
|
1992
|
-
this.
|
|
1993
|
-
this.slow.inRange = false;
|
|
2067
|
+
this.clearModifiers();
|
|
1994
2068
|
const container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
|
|
1995
2069
|
shapeDrawer?.particleDestroy?.(this);
|
|
1996
2070
|
for (const plugin of container.particleDestroyedPlugins) {
|
|
@@ -2012,13 +2086,16 @@ class Particle {
|
|
|
2012
2086
|
return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
|
|
2013
2087
|
}
|
|
2014
2088
|
getFillColor() {
|
|
2015
|
-
return this.#getRollColor(this
|
|
2089
|
+
return this.#getRollColor(this.#applyModifiers(getHslFromAnimation(this.fillColor), m => m.fillColor));
|
|
2016
2090
|
}
|
|
2017
2091
|
getMass() {
|
|
2018
2092
|
return this.getRadius() ** squareExp * Math.PI * half;
|
|
2019
2093
|
}
|
|
2094
|
+
getModifier(id) {
|
|
2095
|
+
return this.#modifiers.find(m => m.id === id);
|
|
2096
|
+
}
|
|
2020
2097
|
getOpacity() {
|
|
2021
|
-
const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate,
|
|
2098
|
+
const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, baseOpacity = getRangeValue(this.opacity?.value ?? defaultOpacity), modifierOpacity = this.#applyModifiers(undefined, m => m.opacity), opacity = modifierOpacity ?? baseOpacity, fillOpacity = this.fillOpacity ?? defaultOpacity, strokeOpacity = this.strokeOpacity ?? defaultOpacity;
|
|
2022
2099
|
this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
|
|
2023
2100
|
this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
2024
2101
|
this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
|
|
@@ -2031,7 +2108,7 @@ class Particle {
|
|
|
2031
2108
|
return this.#cachedPosition;
|
|
2032
2109
|
}
|
|
2033
2110
|
getRadius() {
|
|
2034
|
-
return this.
|
|
2111
|
+
return this.#applyModifiers(this.size.value, m => m.radius);
|
|
2035
2112
|
}
|
|
2036
2113
|
getRotateData() {
|
|
2037
2114
|
const angle = this.getAngle();
|
|
@@ -2040,7 +2117,7 @@ class Particle {
|
|
|
2040
2117
|
return this.#cachedRotateData;
|
|
2041
2118
|
}
|
|
2042
2119
|
getStrokeColor() {
|
|
2043
|
-
return this.#getRollColor(this
|
|
2120
|
+
return this.#getRollColor(this.#applyModifiers(getHslFromAnimation(this.strokeColor), m => m.strokeColor));
|
|
2044
2121
|
}
|
|
2045
2122
|
getTransformData(externalTransform) {
|
|
2046
2123
|
const rotateData = this.getRotateData(), rotating = this.isRotating;
|
|
@@ -2060,13 +2137,6 @@ class Particle {
|
|
|
2060
2137
|
this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
|
|
2061
2138
|
container.retina.initParticle(this);
|
|
2062
2139
|
runUpdaterPreInit(container.particleUpdaters, this);
|
|
2063
|
-
this.bubble = {
|
|
2064
|
-
inRange: false,
|
|
2065
|
-
};
|
|
2066
|
-
this.slow = {
|
|
2067
|
-
inRange: false,
|
|
2068
|
-
factor: 1,
|
|
2069
|
-
};
|
|
2070
2140
|
this.#initPosition(position);
|
|
2071
2141
|
this.initialVelocity = this.#calculateVelocity();
|
|
2072
2142
|
this.velocity = this.initialVelocity.copy();
|
|
@@ -2106,11 +2176,29 @@ class Particle {
|
|
|
2106
2176
|
isVisible() {
|
|
2107
2177
|
return !this.destroyed && !this.spawning && this.isInsideCanvas();
|
|
2108
2178
|
}
|
|
2179
|
+
removeModifier(id) {
|
|
2180
|
+
const idx = this.#modifiers.findIndex(m => m.id === id);
|
|
2181
|
+
if (idx >= defaultAngle) {
|
|
2182
|
+
this.#modifiers.splice(idx, identity);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2109
2185
|
reset() {
|
|
2110
2186
|
for (const updater of this.#container.particleUpdaters) {
|
|
2111
2187
|
updater.reset?.(this);
|
|
2112
2188
|
}
|
|
2113
2189
|
}
|
|
2190
|
+
#applyModifiers(base, getter) {
|
|
2191
|
+
let value = base;
|
|
2192
|
+
for (const mod of this.#modifiers) {
|
|
2193
|
+
if (mod.enabled) {
|
|
2194
|
+
const override = getter(mod);
|
|
2195
|
+
if (override !== undefined) {
|
|
2196
|
+
value = override;
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
return value;
|
|
2201
|
+
}
|
|
2114
2202
|
#calcPosition(position, zIndex) {
|
|
2115
2203
|
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
2116
2204
|
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
|
|
@@ -308,29 +308,27 @@ function deepExtend(destination, ...sources) {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
else if (!isObject(destination) || Array.isArray(destination)) {
|
|
311
|
-
destination =
|
|
311
|
+
destination = Object.create(null);
|
|
312
312
|
}
|
|
313
|
-
const sourceKeys = Object.keys(source),
|
|
313
|
+
const sourceKeys = Object.keys(source), hasNested = sourceKeys.some(k => {
|
|
314
314
|
const v = source[k];
|
|
315
315
|
return isObject(v) || Array.isArray(v);
|
|
316
316
|
});
|
|
317
317
|
if (!hasNested) {
|
|
318
318
|
const sourceDict = source, destDict = destination;
|
|
319
319
|
for (const key of sourceKeys) {
|
|
320
|
-
if (
|
|
320
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
321
321
|
continue;
|
|
322
322
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
destDict[key] = v;
|
|
327
|
-
}
|
|
323
|
+
const v = sourceDict[key];
|
|
324
|
+
if (v !== undefined) {
|
|
325
|
+
destDict[key] = v;
|
|
328
326
|
}
|
|
329
327
|
}
|
|
330
328
|
continue;
|
|
331
329
|
}
|
|
332
330
|
for (const key of sourceKeys) {
|
|
333
|
-
if (
|
|
331
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
334
332
|
continue;
|
|
335
333
|
}
|
|
336
334
|
const sourceDict = source, destDict = destination, value = sourceDict[key];
|
|
@@ -746,7 +744,7 @@ class Engine {
|
|
|
746
744
|
return this.#domArray;
|
|
747
745
|
}
|
|
748
746
|
get version() {
|
|
749
|
-
return "4.
|
|
747
|
+
return "4.3.1";
|
|
750
748
|
}
|
|
751
749
|
addEventListener(type, listener) {
|
|
752
750
|
this.#eventDispatcher.addEventListener(type, listener);
|
|
@@ -781,7 +779,7 @@ class Engine {
|
|
|
781
779
|
if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
|
|
782
780
|
domSourceElement = params.element;
|
|
783
781
|
}
|
|
784
|
-
const { Container } = await import('./Container-
|
|
782
|
+
const { Container } = await import('./Container-COqetWkt.js'), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
|
|
785
783
|
dispatchCallback: (eventType, args) => {
|
|
786
784
|
this.dispatchEvent(eventType, args);
|
|
787
785
|
},
|
|
@@ -906,6 +904,18 @@ var AnimationStatus;
|
|
|
906
904
|
AnimationStatus["decreasing"] = "decreasing";
|
|
907
905
|
})(AnimationStatus || (AnimationStatus = {}));
|
|
908
906
|
|
|
907
|
+
var DrawLayer;
|
|
908
|
+
(function (DrawLayer) {
|
|
909
|
+
DrawLayer[DrawLayer["BackgroundElement"] = 0] = "BackgroundElement";
|
|
910
|
+
DrawLayer[DrawLayer["BackgroundDraw"] = 1] = "BackgroundDraw";
|
|
911
|
+
DrawLayer[DrawLayer["BackgroundMask"] = 2] = "BackgroundMask";
|
|
912
|
+
DrawLayer[DrawLayer["CanvasSetup"] = 3] = "CanvasSetup";
|
|
913
|
+
DrawLayer[DrawLayer["PluginContent"] = 4] = "PluginContent";
|
|
914
|
+
DrawLayer[DrawLayer["Particles"] = 5] = "Particles";
|
|
915
|
+
DrawLayer[DrawLayer["CanvasCleanup"] = 6] = "CanvasCleanup";
|
|
916
|
+
DrawLayer[DrawLayer["Foreground"] = 7] = "Foreground";
|
|
917
|
+
})(DrawLayer || (DrawLayer = {}));
|
|
918
|
+
|
|
909
919
|
const tsParticles = initEngine();
|
|
910
920
|
|
|
911
921
|
let initialized = false;
|
|
@@ -946,4 +956,4 @@ async function waitForParticlesEngineInitialization() {
|
|
|
946
956
|
await (initPromise !== null && initPromise !== void 0 ? initPromise : Promise.resolve());
|
|
947
957
|
}
|
|
948
958
|
|
|
949
|
-
export {
|
|
959
|
+
export { safeMatchMedia as $, AlterType as A, rgbMax as B, getRandomInRange as C, identity as D, defaultRgbMin as E, maxNits as F, sextuple as G, triple as H, phaseNumerator as I, sNormalizedOffset as J, originPoint as K, LimitMode as L, MoveDirection as M, DrawLayer as N, OutMode as O, PixelMode as P, minimumSize as Q, RangeType as R, defaultCompositeValue as S, minStrokeWidth as T, defaultZoom as U, getLogger as V, zIndexFactorOffset as W, defaultTransformValue as X, safeMutationObserver as Y, generatedAttribute as Z, cloneStyle as _, isNull as a, getFullScreenStyle as a0, safeDocument as a1, millisecondsToSeconds as a2, manageListener as a3, visibilityChangeEvent as a4, resizeEvent as a5, Vector3d as a6, EventType as a7, defaultAngle as a8, defaultTransform as a9, one as aA, defaultRatio as aB, defaultReduceFactor as aC, animate as aD, defaultFpsLimit as aE, minFpsLimit as aF, cancelAnimation as aG, defaultFps as aH, isParticlesEngineInitialized as aI, waitForParticlesEngineInitialization as aJ, defaultRetryCount as aa, tryCountIncrement as ab, getParticleBaseVelocity as ac, randomInRangeValue as ad, getRandom as ae, OutModeDirection as af, clamp as ag, minZ as ah, getPosition as ai, getParticleDirectionAngle as aj, ParticleOutType as ak, Vector as al, calcExactPositionOrRandomFromSize as am, getRangeValue as an, itemFromSingleOrMultiple as ao, isInArray as ap, doublePI as aq, degToRad as ar, spatialHashGridCellSize as as, minLimit as at, minCount as au, minIndex as av, defaultRemoveQuantity as aw, defaultDensityFactor as ax, deleteCount as ay, countOffset as az, setRangeValue as b, checkDistance as c, hMax as d, lMax as e, sMin as f, sMax as g, hMin as h, initParticlesEngine as i, isString as j, isArray as k, lMin as l, deepExtend as m, isNumber as n, isObject as o, executeOnSingleOrMultiple as p, isBoolean as q, itemFromArray as r, squareExp as s, tsParticles as t, defaultOpacity as u, randomColorValue as v, lFactor as w, half as x, double as y, hPhase as z };
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { i as initParticlesEngine,
|
|
1
|
+
export { i as initParticlesEngine, aI as isParticlesEngineInitialized, aJ as waitForParticlesEngineInitialization } from './index-uBrXcY8m.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h } from './index-PhwiK2_P.js';
|
|
2
|
-
import { i as initParticlesEngine, t as tsParticles } from './index-
|
|
2
|
+
import { i as initParticlesEngine, t as tsParticles } from './index-uBrXcY8m.js';
|
|
3
3
|
|
|
4
4
|
const StencilParticles = class {
|
|
5
5
|
constructor(hostRef) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{i as initParticlesEngine,
|
|
1
|
+
export{i as initParticlesEngine,aI as isParticlesEngineInitialized,aJ as waitForParticlesEngineInitialization}from"./p-Buaac_o7.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as s}from"./p-PhwiK2_P.js";import{i as e,t as
|
|
1
|
+
import{r as t,c as i,h as s}from"./p-PhwiK2_P.js";import{i as e,t as a}from"./p-Buaac_o7.js";const n=class{constructor(s){t(this,s),this.particlesLoaded=i(this,"particlesLoaded"),this.renderId=0}async componentDidLoad(){await this.loadParticles(++this.renderId)}disconnectedCallback(){var t;this.renderId++,null===(t=this.container)||void 0===t||t.destroy(),this.container=void 0}async onPropsChange(){await this.loadParticles(++this.renderId)}async onThemeChange(){var t,i;this.container&&(null===(i=(t=this.container).loadTheme)||void 0===i||i.call(t,this.theme))}async loadParticles(t){var i,s,n;if(null===(i=this.container)||void 0===i||i.destroy(),!this.containerElement)return void console.warn("[stencil-particles] container element not available yet");let o;try{if(this.init&&await e(this.init),!this.options&&!this.url)return void console.warn("[stencil-particles] neither options nor url provided");const t=Object.assign(Object.assign({element:this.containerElement},this.containerId?{id:this.containerId}:{}),this.options?{options:this.options}:{url:this.url});o=await a.load(t)}catch(t){return void console.error("[stencil-particles] load failed",t)}t===this.renderId?(this.container=o,this.particlesLoaded.emit(o),o&&this.theme&&(null===(n=(s=o).loadTheme)||void 0===n||n.call(s,this.theme))):null==o||o.destroy()}render(){return s("div",{key:"f5fe33d147a1a606a75fe0d1ee385bacaf0e0b7d",id:this.containerId,ref:t=>{this.containerElement=t},style:{width:"100%",height:"100%"}})}static get watchers(){return{options:[{onPropsChange:0}],url:[{onPropsChange:0}],init:[{onPropsChange:0}],containerId:[{onPropsChange:0}],theme:[{onThemeChange:0}]}}};export{n as stencil_particles}
|