@tsparticles/slim 4.3.2 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.js +1 -1
- package/browser/index.lazy.js +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.lazy.js +1 -1
- package/esm/index.js +1 -1
- package/esm/index.lazy.js +1 -1
- package/package.json +29 -29
- package/report.html +1 -1
- package/tsparticles.slim.bundle.js +297 -97
- package/tsparticles.slim.bundle.min.js +1 -1
- package/tsparticles.slim.js +2 -2
- package/tsparticles.slim.min.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* tsParticles v4.
|
|
2
|
+
/* tsParticles v4.4.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -880,7 +880,7 @@
|
|
|
880
880
|
return this.#domArray;
|
|
881
881
|
}
|
|
882
882
|
get version() {
|
|
883
|
-
return "4.
|
|
883
|
+
return "4.4.0";
|
|
884
884
|
}
|
|
885
885
|
addEventListener(type, listener) {
|
|
886
886
|
this.#eventDispatcher.addEventListener(type, listener);
|
|
@@ -961,6 +961,10 @@
|
|
|
961
961
|
}
|
|
962
962
|
|
|
963
963
|
function initEngine() {
|
|
964
|
+
const existing = globalThis.tsParticles;
|
|
965
|
+
if (existing?.pluginManager) {
|
|
966
|
+
return existing;
|
|
967
|
+
}
|
|
964
968
|
return new Engine();
|
|
965
969
|
}
|
|
966
970
|
|
|
@@ -1058,6 +1062,15 @@
|
|
|
1058
1062
|
AnimationMode["random"] = "random";
|
|
1059
1063
|
})(exports.AnimationMode || (exports.AnimationMode = {}));
|
|
1060
1064
|
|
|
1065
|
+
exports.HdrMode = void 0;
|
|
1066
|
+
(function (HdrMode) {
|
|
1067
|
+
HdrMode["standard"] = "standard";
|
|
1068
|
+
HdrMode["natural"] = "natural";
|
|
1069
|
+
HdrMode["vivid"] = "vivid";
|
|
1070
|
+
HdrMode["cinematic"] = "cinematic";
|
|
1071
|
+
HdrMode["dynamic"] = "dynamic";
|
|
1072
|
+
})(exports.HdrMode || (exports.HdrMode = {}));
|
|
1073
|
+
|
|
1061
1074
|
exports.LimitMode = void 0;
|
|
1062
1075
|
(function (LimitMode) {
|
|
1063
1076
|
LimitMode["delete"] = "delete";
|
|
@@ -1323,6 +1336,29 @@
|
|
|
1323
1336
|
}
|
|
1324
1337
|
}
|
|
1325
1338
|
|
|
1339
|
+
const defaultPeakNits = 400, minPeakNits = 0, toStringValue = (value) => String(value);
|
|
1340
|
+
class HDROptions extends OptionLoader {
|
|
1341
|
+
enable = true;
|
|
1342
|
+
mode = exports.HdrMode.standard;
|
|
1343
|
+
peakNits = defaultPeakNits;
|
|
1344
|
+
doLoad(data) {
|
|
1345
|
+
if (data.enable !== undefined && !isBoolean(data.enable)) {
|
|
1346
|
+
throw new Error(`Invalid HDR "enable" value: expected a boolean, got "${String(data.enable)}"`);
|
|
1347
|
+
}
|
|
1348
|
+
if (data.mode !== undefined &&
|
|
1349
|
+
(typeof data.mode !== "string" || !Object.values(exports.HdrMode).includes(data.mode))) {
|
|
1350
|
+
throw new Error(`Invalid HDR "mode" value: expected one of ${Object.values(exports.HdrMode).join(", ")}, got "${toStringValue(data.mode)}"`);
|
|
1351
|
+
}
|
|
1352
|
+
if (data.peakNits !== undefined &&
|
|
1353
|
+
(!isNumber(data.peakNits) || !Number.isFinite(data.peakNits) || data.peakNits <= minPeakNits)) {
|
|
1354
|
+
throw new Error(`Invalid HDR "peakNits" value: expected a positive number, got "${String(data.peakNits)}"`);
|
|
1355
|
+
}
|
|
1356
|
+
loadProperty(this, "enable", data.enable);
|
|
1357
|
+
loadProperty(this, "mode", data.mode);
|
|
1358
|
+
loadProperty(this, "peakNits", data.peakNits);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1326
1362
|
class ResizeEvent extends OptionLoader {
|
|
1327
1363
|
delay = 0.5;
|
|
1328
1364
|
enable = true;
|
|
@@ -1766,7 +1802,7 @@
|
|
|
1766
1802
|
duration = 0;
|
|
1767
1803
|
fpsLimit = 120;
|
|
1768
1804
|
fullScreen;
|
|
1769
|
-
hdr
|
|
1805
|
+
hdr;
|
|
1770
1806
|
key;
|
|
1771
1807
|
name;
|
|
1772
1808
|
palette;
|
|
@@ -1786,6 +1822,7 @@
|
|
|
1786
1822
|
this.#container = container;
|
|
1787
1823
|
this.background = new Background();
|
|
1788
1824
|
this.fullScreen = new FullScreen();
|
|
1825
|
+
this.hdr = new HDROptions();
|
|
1789
1826
|
this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
|
|
1790
1827
|
this.resize = new ResizeEvent();
|
|
1791
1828
|
}
|
|
@@ -1808,7 +1845,15 @@
|
|
|
1808
1845
|
loadProperty(this, "detectRetina", data.detectRetina);
|
|
1809
1846
|
loadRangeProperty(this, "duration", data.duration);
|
|
1810
1847
|
loadProperty(this, "fpsLimit", data.fpsLimit);
|
|
1811
|
-
|
|
1848
|
+
const hdrData = data.hdr;
|
|
1849
|
+
if (isBoolean(hdrData)) {
|
|
1850
|
+
this.hdr.enable = hdrData;
|
|
1851
|
+
this.hdr.mode = exports.HdrMode.standard;
|
|
1852
|
+
this.hdr.peakNits = 400;
|
|
1853
|
+
}
|
|
1854
|
+
else {
|
|
1855
|
+
this.hdr.load(hdrData);
|
|
1856
|
+
}
|
|
1812
1857
|
loadProperty(this, "pauseOnBlur", data.pauseOnBlur);
|
|
1813
1858
|
loadProperty(this, "pauseOnOutsideViewport", data.pauseOnOutsideViewport);
|
|
1814
1859
|
loadProperty(this, "zLayers", data.zLayers);
|
|
@@ -1851,7 +1896,7 @@
|
|
|
1851
1896
|
}
|
|
1852
1897
|
}
|
|
1853
1898
|
|
|
1854
|
-
const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, hdrRgbFixedPrecision = 4, hdrHslFixedPrecision = 4, sdrReferenceWhiteNits = 203,
|
|
1899
|
+
const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, hdrRgbFixedPrecision = 4, hdrHslFixedPrecision = 4, sdrReferenceWhiteNits = 203, acesA = 2.51, acesB = 0.03, acesC = 2.43, acesD = 0.59, acesE = 0.14, saturationBoost = 1.15, lightnessBoost = 1.05, temperatureR = 1.05, temperatureB = 0.95, contrastFactor = 1.1, luminanceR = 0.2126, luminanceG = 0.7152, luminanceB = 0.0722, dynamicLuminanceFactor = 2, channelCount = 3, srgbThreshold = 0.04045, srgbDivisor = 12.92, srgbOffset = 0.055, srgbScale = 1.055, srgbExponent = 2.4, linearThreshold = 0.0031308, linearScale = 12.92;
|
|
1855
1900
|
function getCachedStyle(key, generator) {
|
|
1856
1901
|
let cached = styleCache.get(key);
|
|
1857
1902
|
if (!cached) {
|
|
@@ -1863,6 +1908,48 @@
|
|
|
1863
1908
|
}
|
|
1864
1909
|
return cached;
|
|
1865
1910
|
}
|
|
1911
|
+
function acesFilmic(x) {
|
|
1912
|
+
return clamp((x * (acesA * x + acesB)) / (x * (acesC * x + acesD) + acesE), none, one);
|
|
1913
|
+
}
|
|
1914
|
+
function srgbToLinear(c) {
|
|
1915
|
+
return c <= srgbThreshold ? c / srgbDivisor : Math.pow((c + srgbOffset) / srgbScale, srgbExponent);
|
|
1916
|
+
}
|
|
1917
|
+
function linearToSrgb(c) {
|
|
1918
|
+
return c <= linearThreshold ? c * linearScale : srgbScale * Math.pow(c, one / srgbExponent) - srgbOffset;
|
|
1919
|
+
}
|
|
1920
|
+
function applyHdrModeAdjustments(r, g, b, mode, maxChannel) {
|
|
1921
|
+
switch (mode) {
|
|
1922
|
+
case exports.HdrMode.vivid: {
|
|
1923
|
+
const avg = (r + g + b) / channelCount;
|
|
1924
|
+
return {
|
|
1925
|
+
b: clamp(clamp(avg + (b - avg) * saturationBoost, none, maxChannel) * lightnessBoost, none, maxChannel),
|
|
1926
|
+
g: clamp(clamp(avg + (g - avg) * saturationBoost, none, maxChannel) * lightnessBoost, none, maxChannel),
|
|
1927
|
+
r: clamp(clamp(avg + (r - avg) * saturationBoost, none, maxChannel) * lightnessBoost, none, maxChannel),
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
case exports.HdrMode.cinematic: {
|
|
1931
|
+
const tempR = r * temperatureR, tempB = b * temperatureB, avg = (tempR + g + tempB) / channelCount;
|
|
1932
|
+
return {
|
|
1933
|
+
b: clamp(avg + (tempB - avg) * contrastFactor, none, maxChannel),
|
|
1934
|
+
g: clamp(avg + (g - avg) * contrastFactor, none, maxChannel),
|
|
1935
|
+
r: clamp(avg + (tempR - avg) * contrastFactor, none, maxChannel),
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
case exports.HdrMode.dynamic: {
|
|
1939
|
+
const luminance = luminanceR * r + luminanceG * g + luminanceB * b, vividWeight = Math.min(one, luminance * dynamicLuminanceFactor), naturalWeight = one - vividWeight, avg = (r + g + b) / channelCount, vividR = clamp(avg + (r - avg) * saturationBoost, none, maxChannel) * lightnessBoost, vividG = clamp(avg + (g - avg) * saturationBoost, none, maxChannel) * lightnessBoost, vividB = clamp(avg + (b - avg) * saturationBoost, none, maxChannel) * lightnessBoost;
|
|
1940
|
+
return {
|
|
1941
|
+
b: clamp(b * naturalWeight + vividB * vividWeight, none, maxChannel),
|
|
1942
|
+
g: clamp(g * naturalWeight + vividG * vividWeight, none, maxChannel),
|
|
1943
|
+
r: clamp(r * naturalWeight + vividR * vividWeight, none, maxChannel),
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
case exports.HdrMode.standard:
|
|
1947
|
+
return { b, g, r };
|
|
1948
|
+
case exports.HdrMode.natural:
|
|
1949
|
+
default:
|
|
1950
|
+
return { b, g, r };
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1866
1953
|
function stringToRgba(pluginManager, input) {
|
|
1867
1954
|
if (!input) {
|
|
1868
1955
|
return;
|
|
@@ -2030,30 +2117,65 @@
|
|
|
2030
2117
|
r: getRgbInRangeValue(),
|
|
2031
2118
|
};
|
|
2032
2119
|
}
|
|
2033
|
-
function getStyleFromRgb(color, hdr, opacity) {
|
|
2034
|
-
const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? defaultOpacity$3, key =
|
|
2035
|
-
|
|
2120
|
+
function getStyleFromRgb(color, hdr, opacity, peakNits, mode) {
|
|
2121
|
+
const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? defaultOpacity$3, key = hdr
|
|
2122
|
+
? `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-hdr-${op.toString()}-${(peakNits ?? maxNits).toString()}-${mode ?? exports.HdrMode.standard}`
|
|
2123
|
+
: `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-sdr-${op.toString()}`;
|
|
2124
|
+
return getCachedStyle(key, () => hdr ? getHdrStyleFromRgb(color, opacity, peakNits, mode) : getSdrStyleFromRgb(color, opacity));
|
|
2125
|
+
}
|
|
2126
|
+
function getHdrStyleFromRgb(color, opacity, peakNits = maxNits, mode = exports.HdrMode.standard) {
|
|
2127
|
+
const headroom = peakNits / sdrReferenceWhiteNits, middleGray = 0.18, mapped = hdrToneMapColor(color, headroom, middleGray, mode);
|
|
2128
|
+
return `color(display-p3 ${mapped.r.toString()} ${mapped.g.toString()} ${mapped.b.toString()} / ${(opacity ?? defaultOpacity$3).toString()})`;
|
|
2129
|
+
}
|
|
2130
|
+
function hdrToneMapColor(color, headroom, middleGray, mode) {
|
|
2131
|
+
const rNorm = color.r / rgbMax, gNorm = color.g / rgbMax, bNorm = color.b / rgbMax;
|
|
2132
|
+
if (mode !== exports.HdrMode.natural && mode !== exports.HdrMode.vivid && mode !== exports.HdrMode.cinematic && mode !== exports.HdrMode.dynamic) {
|
|
2133
|
+
return { b: bNorm, g: gNorm, r: rNorm };
|
|
2134
|
+
}
|
|
2135
|
+
const maxChannel = Math.max(one, headroom), luminance = luminanceR * rNorm + luminanceG * gNorm + luminanceB * bNorm, mappedLuminance = hdrToneMap(luminance, headroom, middleGray), scale = luminance > none ? mappedLuminance / luminance : one;
|
|
2136
|
+
return applyHdrModeAdjustments(clamp(rNorm * scale, none, maxChannel), clamp(gNorm * scale, none, maxChannel), clamp(bNorm * scale, none, maxChannel), mode, maxChannel);
|
|
2036
2137
|
}
|
|
2037
|
-
function
|
|
2038
|
-
|
|
2039
|
-
|
|
2138
|
+
function hdrToneMap(normalized, headroom, middleGray) {
|
|
2139
|
+
if (normalized <= middleGray) {
|
|
2140
|
+
return acesFilmic(normalized);
|
|
2141
|
+
}
|
|
2142
|
+
const expanded = normalized + (normalized - middleGray) * (headroom - one);
|
|
2143
|
+
return acesFilmic(expanded);
|
|
2040
2144
|
}
|
|
2041
2145
|
function getSdrStyleFromRgb(color, opacity) {
|
|
2042
2146
|
return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$3).toString()})`;
|
|
2043
2147
|
}
|
|
2044
|
-
function getStyleFromHsl(color, hdr, opacity) {
|
|
2045
|
-
const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? defaultOpacity$3, key =
|
|
2148
|
+
function getStyleFromHsl(color, hdr, opacity, peakNits, mode) {
|
|
2149
|
+
const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? defaultOpacity$3, key = hdr
|
|
2150
|
+
? `hsl-${color.h.toFixed(hslPrecision)}-${color.s.toFixed(hslPrecision)}-${color.l.toFixed(hslPrecision)}-hdr-${op.toString()}-${(peakNits ?? maxNits).toString()}-${mode ?? exports.HdrMode.standard}`
|
|
2151
|
+
: `hsl-${color.h.toFixed(hslPrecision)}-${color.s.toFixed(hslPrecision)}-${color.l.toFixed(hslPrecision)}-sdr-${op.toString()}`;
|
|
2046
2152
|
return getCachedStyle(key, () => hdr
|
|
2047
|
-
? getStyleFromRgb(hslToRgbFloat(color), true, opacity)
|
|
2153
|
+
? getStyleFromRgb(hslToRgbFloat(color), true, opacity, peakNits, mode)
|
|
2048
2154
|
: `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
|
|
2049
2155
|
}
|
|
2050
|
-
function colorMix(color1, color2, size1, size2) {
|
|
2156
|
+
function colorMix(color1, color2, size1, size2, hdr) {
|
|
2051
2157
|
let rgb1 = color1, rgb2 = color2;
|
|
2052
2158
|
if (!("r" in rgb1)) {
|
|
2053
|
-
rgb1 = hslToRgb(color1);
|
|
2159
|
+
rgb1 = hdr ? hslToRgbFloat(color1) : hslToRgb(color1);
|
|
2054
2160
|
}
|
|
2055
2161
|
if (!("r" in rgb2)) {
|
|
2056
|
-
rgb2 = hslToRgb(color2);
|
|
2162
|
+
rgb2 = hdr ? hslToRgbFloat(color2) : hslToRgb(color2);
|
|
2163
|
+
}
|
|
2164
|
+
if (hdr) {
|
|
2165
|
+
const lin1 = {
|
|
2166
|
+
b: srgbToLinear(rgb1.b / rgbMax),
|
|
2167
|
+
g: srgbToLinear(rgb1.g / rgbMax),
|
|
2168
|
+
r: srgbToLinear(rgb1.r / rgbMax),
|
|
2169
|
+
}, lin2 = {
|
|
2170
|
+
b: srgbToLinear(rgb2.b / rgbMax),
|
|
2171
|
+
g: srgbToLinear(rgb2.g / rgbMax),
|
|
2172
|
+
r: srgbToLinear(rgb2.r / rgbMax),
|
|
2173
|
+
}, totalWeight = size1 + size2;
|
|
2174
|
+
return {
|
|
2175
|
+
b: linearToSrgb((lin1.b * size1 + lin2.b * size2) / totalWeight) * rgbMax,
|
|
2176
|
+
g: linearToSrgb((lin1.g * size1 + lin2.g * size2) / totalWeight) * rgbMax,
|
|
2177
|
+
r: linearToSrgb((lin1.r * size1 + lin2.r * size2) / totalWeight) * rgbMax,
|
|
2178
|
+
};
|
|
2057
2179
|
}
|
|
2058
2180
|
return {
|
|
2059
2181
|
b: mix(rgb1.b, rgb2.b, size1, size2),
|
|
@@ -2061,14 +2183,14 @@
|
|
|
2061
2183
|
r: mix(rgb1.r, rgb2.r, size1, size2),
|
|
2062
2184
|
};
|
|
2063
2185
|
}
|
|
2064
|
-
function getLinkColor(p1, p2, linkColor) {
|
|
2186
|
+
function getLinkColor(p1, p2, linkColor, hdr) {
|
|
2065
2187
|
if (linkColor === randomColorValue) {
|
|
2066
2188
|
return getRandomRgbColor();
|
|
2067
2189
|
}
|
|
2068
2190
|
else if (linkColor === midColorValue) {
|
|
2069
2191
|
const sourceColor = p1.getFillColor() ?? p1.getStrokeColor(), destColor = p2?.getFillColor() ?? p2?.getStrokeColor();
|
|
2070
2192
|
if (sourceColor && destColor && p2) {
|
|
2071
|
-
return colorMix(sourceColor, destColor, p1.getRadius(), p2.getRadius());
|
|
2193
|
+
return colorMix(sourceColor, destColor, p1.getRadius(), p2.getRadius(), hdr);
|
|
2072
2194
|
}
|
|
2073
2195
|
else {
|
|
2074
2196
|
const hslColor = sourceColor ?? destColor;
|
|
@@ -2164,7 +2286,7 @@
|
|
|
2164
2286
|
colorValue.velocity = defaultVelocity;
|
|
2165
2287
|
}
|
|
2166
2288
|
}
|
|
2167
|
-
function updateColorValue(data, decrease, delta,
|
|
2289
|
+
function updateColorValue(data, decrease, delta, _hdr) {
|
|
2168
2290
|
const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minOffset = 0, velocityFactor = 3.6;
|
|
2169
2291
|
if (!data.enable ||
|
|
2170
2292
|
((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
|
|
@@ -2177,7 +2299,7 @@
|
|
|
2177
2299
|
if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
|
|
2178
2300
|
return;
|
|
2179
2301
|
}
|
|
2180
|
-
const offset = data.offset ? randomInRangeValue(data.offset) : minOffset, velocity = (
|
|
2302
|
+
const offset = data.offset ? randomInRangeValue(data.offset) : minOffset, velocity = (data.velocity ?? minVelocity) * delta.factor + offset * velocityFactor, decay = data.decay ?? identity, max = data.max, min = data.min;
|
|
2181
2303
|
if (!decrease || data.status === exports.AnimationStatus.increasing) {
|
|
2182
2304
|
data.value += velocity;
|
|
2183
2305
|
if (data.value > max) {
|
|
@@ -2209,9 +2331,9 @@
|
|
|
2209
2331
|
return;
|
|
2210
2332
|
}
|
|
2211
2333
|
const { h, s, l } = color;
|
|
2212
|
-
updateColorValue(h, false, delta
|
|
2213
|
-
updateColorValue(s, true, delta
|
|
2214
|
-
updateColorValue(l, true, delta
|
|
2334
|
+
updateColorValue(h, false, delta);
|
|
2335
|
+
updateColorValue(s, true, delta);
|
|
2336
|
+
updateColorValue(l, true, delta);
|
|
2215
2337
|
}
|
|
2216
2338
|
function alterHsl(color, type, value) {
|
|
2217
2339
|
return {
|
|
@@ -2261,7 +2383,7 @@
|
|
|
2261
2383
|
}
|
|
2262
2384
|
|
|
2263
2385
|
async function loadBlendPlugin(engine) {
|
|
2264
|
-
engine.checkVersion("4.
|
|
2386
|
+
engine.checkVersion("4.4.0");
|
|
2265
2387
|
await engine.pluginManager.register(e => {
|
|
2266
2388
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
2267
2389
|
});
|
|
@@ -2298,7 +2420,7 @@
|
|
|
2298
2420
|
}
|
|
2299
2421
|
|
|
2300
2422
|
async function loadCircleShape(engine) {
|
|
2301
|
-
engine.checkVersion("4.
|
|
2423
|
+
engine.checkVersion("4.4.0");
|
|
2302
2424
|
await engine.pluginManager.register(e => {
|
|
2303
2425
|
e.pluginManager.addShape(["circle"], () => {
|
|
2304
2426
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -2346,7 +2468,7 @@
|
|
|
2346
2468
|
}
|
|
2347
2469
|
|
|
2348
2470
|
async function loadHexColorPlugin(engine) {
|
|
2349
|
-
engine.checkVersion("4.
|
|
2471
|
+
engine.checkVersion("4.4.0");
|
|
2350
2472
|
await engine.pluginManager.register(e => {
|
|
2351
2473
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
2352
2474
|
});
|
|
@@ -2399,7 +2521,7 @@
|
|
|
2399
2521
|
}
|
|
2400
2522
|
|
|
2401
2523
|
async function loadHslColorPlugin(engine) {
|
|
2402
|
-
engine.checkVersion("4.
|
|
2524
|
+
engine.checkVersion("4.4.0");
|
|
2403
2525
|
await engine.pluginManager.register(e => {
|
|
2404
2526
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
2405
2527
|
});
|
|
@@ -2423,7 +2545,7 @@
|
|
|
2423
2545
|
}
|
|
2424
2546
|
|
|
2425
2547
|
async function loadMovePlugin(engine) {
|
|
2426
|
-
engine.checkVersion("4.
|
|
2548
|
+
engine.checkVersion("4.4.0");
|
|
2427
2549
|
await engine.pluginManager.register(e => {
|
|
2428
2550
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
2429
2551
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -2639,7 +2761,7 @@
|
|
|
2639
2761
|
}
|
|
2640
2762
|
|
|
2641
2763
|
async function loadOpacityUpdater(engine) {
|
|
2642
|
-
engine.checkVersion("4.
|
|
2764
|
+
engine.checkVersion("4.4.0");
|
|
2643
2765
|
await engine.pluginManager.register(e => {
|
|
2644
2766
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
2645
2767
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -2984,7 +3106,7 @@
|
|
|
2984
3106
|
}
|
|
2985
3107
|
|
|
2986
3108
|
async function loadOutModesUpdater(engine) {
|
|
2987
|
-
engine.checkVersion("4.
|
|
3109
|
+
engine.checkVersion("4.4.0");
|
|
2988
3110
|
await engine.pluginManager.register(e => {
|
|
2989
3111
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
2990
3112
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3055,7 +3177,7 @@
|
|
|
3055
3177
|
}
|
|
3056
3178
|
|
|
3057
3179
|
async function loadPaintUpdater(engine) {
|
|
3058
|
-
engine.checkVersion("4.
|
|
3180
|
+
engine.checkVersion("4.4.0");
|
|
3059
3181
|
await engine.pluginManager.register(e => {
|
|
3060
3182
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3061
3183
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3110,7 +3232,7 @@
|
|
|
3110
3232
|
}
|
|
3111
3233
|
|
|
3112
3234
|
async function loadRgbColorPlugin(engine) {
|
|
3113
|
-
engine.checkVersion("4.
|
|
3235
|
+
engine.checkVersion("4.4.0");
|
|
3114
3236
|
await engine.pluginManager.register(e => {
|
|
3115
3237
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3116
3238
|
});
|
|
@@ -3195,7 +3317,7 @@
|
|
|
3195
3317
|
}
|
|
3196
3318
|
|
|
3197
3319
|
async function loadSizeUpdater(engine) {
|
|
3198
|
-
engine.checkVersion("4.
|
|
3320
|
+
engine.checkVersion("4.4.0");
|
|
3199
3321
|
await engine.pluginManager.register(e => {
|
|
3200
3322
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3201
3323
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3204,7 +3326,7 @@
|
|
|
3204
3326
|
}
|
|
3205
3327
|
|
|
3206
3328
|
async function loadBasic(engine) {
|
|
3207
|
-
engine.checkVersion("4.
|
|
3329
|
+
engine.checkVersion("4.4.0");
|
|
3208
3330
|
await engine.pluginManager.register(async (e) => {
|
|
3209
3331
|
await Promise.all([
|
|
3210
3332
|
loadBlendPlugin(e),
|
|
@@ -3227,7 +3349,7 @@
|
|
|
3227
3349
|
easingsFunctions.set("ease-in-out-quad", value => (value < 0.5 ? 2 * value ** 2 : 1 - (-2 * value + 2) ** 2 / 2));
|
|
3228
3350
|
|
|
3229
3351
|
async function loadEasingQuadPlugin(engine) {
|
|
3230
|
-
engine.checkVersion("4.
|
|
3352
|
+
engine.checkVersion("4.4.0");
|
|
3231
3353
|
await engine.pluginManager.register(e => {
|
|
3232
3354
|
for (const [easing, easingFn] of easingsFunctions) {
|
|
3233
3355
|
e.pluginManager.addEasing(easing, easingFn);
|
|
@@ -3335,7 +3457,7 @@
|
|
|
3335
3457
|
}
|
|
3336
3458
|
|
|
3337
3459
|
async function loadEmojiShape(engine) {
|
|
3338
|
-
engine.checkVersion("4.
|
|
3460
|
+
engine.checkVersion("4.4.0");
|
|
3339
3461
|
await engine.pluginManager.register(e => {
|
|
3340
3462
|
e.pluginManager.addShape(validTypes, () => Promise.resolve(new EmojiDrawer()));
|
|
3341
3463
|
});
|
|
@@ -3572,7 +3694,7 @@
|
|
|
3572
3694
|
}
|
|
3573
3695
|
|
|
3574
3696
|
async function loadInteractivityPlugin(engine) {
|
|
3575
|
-
engine.checkVersion("4.
|
|
3697
|
+
engine.checkVersion("4.4.0");
|
|
3576
3698
|
await engine.pluginManager.register(e => {
|
|
3577
3699
|
const interactivityEngine = e, interactivityPluginManager = interactivityEngine.pluginManager;
|
|
3578
3700
|
interactivityPluginManager.addPlugin(new InteractivityPlugin(interactivityPluginManager));
|
|
@@ -3832,7 +3954,7 @@
|
|
|
3832
3954
|
};
|
|
3833
3955
|
|
|
3834
3956
|
async function loadExternalAttractInteraction(engine) {
|
|
3835
|
-
engine.checkVersion("4.
|
|
3957
|
+
engine.checkVersion("4.4.0");
|
|
3836
3958
|
await engine.pluginManager.register((e) => {
|
|
3837
3959
|
ensureInteractivityPluginLoaded(e);
|
|
3838
3960
|
e.pluginManager.addInteractor?.("externalAttract", container => {
|
|
@@ -4021,7 +4143,7 @@
|
|
|
4021
4143
|
}
|
|
4022
4144
|
|
|
4023
4145
|
async function loadExternalBounceInteraction(engine) {
|
|
4024
|
-
engine.checkVersion("4.
|
|
4146
|
+
engine.checkVersion("4.4.0");
|
|
4025
4147
|
await engine.pluginManager.register((e) => {
|
|
4026
4148
|
ensureInteractivityPluginLoaded(e);
|
|
4027
4149
|
e.pluginManager.addInteractor?.("externalBounce", container => {
|
|
@@ -4308,7 +4430,7 @@
|
|
|
4308
4430
|
mod.strokeColor = undefined;
|
|
4309
4431
|
const pColor = particle.getFillColor();
|
|
4310
4432
|
if (pColor) {
|
|
4311
|
-
const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio));
|
|
4433
|
+
const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio, this.container.hdr));
|
|
4312
4434
|
mod.fillColor = mixedColor;
|
|
4313
4435
|
mod.strokeColor = mixedColor;
|
|
4314
4436
|
}
|
|
@@ -4421,7 +4543,7 @@
|
|
|
4421
4543
|
}
|
|
4422
4544
|
|
|
4423
4545
|
async function loadExternalBubbleInteraction(engine) {
|
|
4424
|
-
engine.checkVersion("4.
|
|
4546
|
+
engine.checkVersion("4.4.0");
|
|
4425
4547
|
await engine.pluginManager.register((e) => {
|
|
4426
4548
|
ensureInteractivityPluginLoaded(e);
|
|
4427
4549
|
e.pluginManager.addInteractor?.("externalBubble", container => {
|
|
@@ -4460,10 +4582,10 @@
|
|
|
4460
4582
|
if (!color1 || !color2) {
|
|
4461
4583
|
return;
|
|
4462
4584
|
}
|
|
4463
|
-
const sourcePos = p1.getPosition(), destPos = p2.getPosition(), midRgb = colorMix(color1, color2, p1.getRadius(), p2.getRadius()), grad = context.createLinearGradient(sourcePos.x, sourcePos.y, destPos.x, destPos.y);
|
|
4464
|
-
grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity));
|
|
4465
|
-
grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity));
|
|
4466
|
-
grad.addColorStop(gradientMax, getStyleFromHsl(color2, container.hdr, opacity));
|
|
4585
|
+
const sourcePos = p1.getPosition(), destPos = p2.getPosition(), midRgb = colorMix(color1, color2, p1.getRadius(), p2.getRadius(), container.hdr), grad = context.createLinearGradient(sourcePos.x, sourcePos.y, destPos.x, destPos.y);
|
|
4586
|
+
grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
4587
|
+
grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
4588
|
+
grad.addColorStop(gradientMax, getStyleFromHsl(color2, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
4467
4589
|
return grad;
|
|
4468
4590
|
}
|
|
4469
4591
|
function drawConnectLine(context, width, lineStyle, begin, end) {
|
|
@@ -4549,7 +4671,7 @@
|
|
|
4549
4671
|
}
|
|
4550
4672
|
|
|
4551
4673
|
async function loadExternalConnectInteraction(engine) {
|
|
4552
|
-
engine.checkVersion("4.
|
|
4674
|
+
engine.checkVersion("4.4.0");
|
|
4553
4675
|
await engine.pluginManager.register((e) => {
|
|
4554
4676
|
ensureInteractivityPluginLoaded(e);
|
|
4555
4677
|
e.pluginManager.addInteractor?.("externalConnect", container => {
|
|
@@ -4653,7 +4775,7 @@
|
|
|
4653
4775
|
}
|
|
4654
4776
|
|
|
4655
4777
|
async function loadExternalDestroyInteraction(engine) {
|
|
4656
|
-
engine.checkVersion("4.
|
|
4778
|
+
engine.checkVersion("4.4.0");
|
|
4657
4779
|
await engine.pluginManager.register((e) => {
|
|
4658
4780
|
ensureInteractivityPluginLoaded(e);
|
|
4659
4781
|
e.pluginManager.addInteractor?.("externalDestroy", async (container) => {
|
|
@@ -4693,16 +4815,16 @@
|
|
|
4693
4815
|
}
|
|
4694
4816
|
|
|
4695
4817
|
const defaultWidth = 0;
|
|
4696
|
-
function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {
|
|
4818
|
+
function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false, peakNits, mode) {
|
|
4697
4819
|
drawLine$1(context, begin, end);
|
|
4698
|
-
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
4820
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity, peakNits, mode);
|
|
4699
4821
|
context.lineWidth = width;
|
|
4700
4822
|
context.stroke();
|
|
4701
4823
|
}
|
|
4702
4824
|
function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
4703
4825
|
container.canvas.render.draw(ctx => {
|
|
4704
4826
|
const beginPos = particle.getPosition();
|
|
4705
|
-
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr);
|
|
4827
|
+
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr, container.peakNits, container.hdrMode);
|
|
4706
4828
|
});
|
|
4707
4829
|
}
|
|
4708
4830
|
|
|
@@ -4758,7 +4880,7 @@
|
|
|
4758
4880
|
const linksOptions = interactivity.modes.grab.links;
|
|
4759
4881
|
container.particles.grabLineColor = getLinkRandomColor(this.#pluginManager, optColor, linksOptions.blink, linksOptions.consent);
|
|
4760
4882
|
}
|
|
4761
|
-
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor);
|
|
4883
|
+
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor, container.hdr);
|
|
4762
4884
|
if (!colorLine) {
|
|
4763
4885
|
continue;
|
|
4764
4886
|
}
|
|
@@ -4777,7 +4899,7 @@
|
|
|
4777
4899
|
}
|
|
4778
4900
|
|
|
4779
4901
|
async function loadExternalGrabInteraction(engine) {
|
|
4780
|
-
engine.checkVersion("4.
|
|
4902
|
+
engine.checkVersion("4.4.0");
|
|
4781
4903
|
await engine.pluginManager.register((e) => {
|
|
4782
4904
|
ensureInteractivityPluginLoaded(e);
|
|
4783
4905
|
e.pluginManager.addInteractor?.("externalGrab", container => {
|
|
@@ -4847,7 +4969,7 @@
|
|
|
4847
4969
|
}
|
|
4848
4970
|
|
|
4849
4971
|
async function loadExternalParallaxInteraction(engine) {
|
|
4850
|
-
engine.checkVersion("4.
|
|
4972
|
+
engine.checkVersion("4.4.0");
|
|
4851
4973
|
await engine.pluginManager.register((e) => {
|
|
4852
4974
|
ensureInteractivityPluginLoaded(e);
|
|
4853
4975
|
e.pluginManager.addInteractor?.("externalParallax", container => {
|
|
@@ -4890,7 +5012,7 @@
|
|
|
4890
5012
|
}
|
|
4891
5013
|
|
|
4892
5014
|
async function loadExternalPauseInteraction(engine) {
|
|
4893
|
-
engine.checkVersion("4.
|
|
5015
|
+
engine.checkVersion("4.4.0");
|
|
4894
5016
|
await engine.pluginManager.register((e) => {
|
|
4895
5017
|
ensureInteractivityPluginLoaded(e);
|
|
4896
5018
|
e.pluginManager.addInteractor?.("externalPause", container => {
|
|
@@ -4962,7 +5084,7 @@
|
|
|
4962
5084
|
}
|
|
4963
5085
|
|
|
4964
5086
|
async function loadExternalPushInteraction(engine) {
|
|
4965
|
-
engine.checkVersion("4.
|
|
5087
|
+
engine.checkVersion("4.4.0");
|
|
4966
5088
|
await engine.pluginManager.register((e) => {
|
|
4967
5089
|
ensureInteractivityPluginLoaded(e);
|
|
4968
5090
|
e.pluginManager.addInteractor?.("externalPush", container => {
|
|
@@ -5016,7 +5138,7 @@
|
|
|
5016
5138
|
}
|
|
5017
5139
|
|
|
5018
5140
|
async function loadExternalRemoveInteraction(engine) {
|
|
5019
|
-
engine.checkVersion("4.
|
|
5141
|
+
engine.checkVersion("4.4.0");
|
|
5020
5142
|
await engine.pluginManager.register((e) => {
|
|
5021
5143
|
ensureInteractivityPluginLoaded(e);
|
|
5022
5144
|
e.pluginManager.addInteractor?.("externalRemove", container => {
|
|
@@ -5322,7 +5444,7 @@
|
|
|
5322
5444
|
}
|
|
5323
5445
|
|
|
5324
5446
|
async function loadExternalRepulseInteraction(engine) {
|
|
5325
|
-
engine.checkVersion("4.
|
|
5447
|
+
engine.checkVersion("4.4.0");
|
|
5326
5448
|
await engine.pluginManager.register((e) => {
|
|
5327
5449
|
ensureInteractivityPluginLoaded(e);
|
|
5328
5450
|
const pluginManager = e.pluginManager;
|
|
@@ -5416,7 +5538,7 @@
|
|
|
5416
5538
|
}
|
|
5417
5539
|
|
|
5418
5540
|
async function loadExternalSlowInteraction(engine) {
|
|
5419
|
-
engine.checkVersion("4.
|
|
5541
|
+
engine.checkVersion("4.4.0");
|
|
5420
5542
|
await engine.pluginManager.register((e) => {
|
|
5421
5543
|
ensureInteractivityPluginLoaded(e);
|
|
5422
5544
|
e.pluginManager.addInteractor?.("externalSlow", container => {
|
|
@@ -5428,12 +5550,12 @@
|
|
|
5428
5550
|
const shapeTypes = ["image", "images"];
|
|
5429
5551
|
const stringStart = 0, defaultOpacity = 1;
|
|
5430
5552
|
const currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;
|
|
5431
|
-
function replaceColorSvg(imageShape, color, opacity, hdr = false) {
|
|
5553
|
+
function replaceColorSvg(imageShape, color, opacity, hdr = false, peakNits, mode) {
|
|
5432
5554
|
const { svgData } = imageShape;
|
|
5433
5555
|
if (!svgData) {
|
|
5434
5556
|
return "";
|
|
5435
5557
|
}
|
|
5436
|
-
const colorStyle = getStyleFromHsl(color, hdr, opacity);
|
|
5558
|
+
const colorStyle = getStyleFromHsl(color, hdr, opacity, peakNits, mode);
|
|
5437
5559
|
if (svgData.includes("fill")) {
|
|
5438
5560
|
return svgData.replaceAll(currentColorRegex, () => colorStyle);
|
|
5439
5561
|
}
|
|
@@ -5475,8 +5597,8 @@
|
|
|
5475
5597
|
}
|
|
5476
5598
|
image.loading = false;
|
|
5477
5599
|
}
|
|
5478
|
-
function replaceImageColor(image, imageData, color, particle, hdr = false) {
|
|
5479
|
-
const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity, hdr), imageRes = {
|
|
5600
|
+
function replaceImageColor(image, imageData, color, particle, hdr = false, peakNits, mode) {
|
|
5601
|
+
const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity, hdr, peakNits, mode), imageRes = {
|
|
5480
5602
|
color,
|
|
5481
5603
|
data: {
|
|
5482
5604
|
...image,
|
|
@@ -5588,7 +5710,7 @@
|
|
|
5588
5710
|
void (async () => {
|
|
5589
5711
|
let imageRes;
|
|
5590
5712
|
if (image.svgData && color) {
|
|
5591
|
-
imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr);
|
|
5713
|
+
imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr, container.peakNits, container.hdrMode);
|
|
5592
5714
|
}
|
|
5593
5715
|
else {
|
|
5594
5716
|
imageRes = {
|
|
@@ -5725,7 +5847,7 @@
|
|
|
5725
5847
|
};
|
|
5726
5848
|
}
|
|
5727
5849
|
async function loadImageShape(engine) {
|
|
5728
|
-
engine.checkVersion("4.
|
|
5850
|
+
engine.checkVersion("4.4.0");
|
|
5729
5851
|
await engine.pluginManager.register(e => {
|
|
5730
5852
|
addLoadImageToEngine(e);
|
|
5731
5853
|
e.pluginManager.addPlugin(new ImagePreloaderPlugin(e));
|
|
@@ -5870,7 +5992,7 @@
|
|
|
5870
5992
|
}
|
|
5871
5993
|
|
|
5872
5994
|
async function loadLifeUpdater(engine) {
|
|
5873
|
-
engine.checkVersion("4.
|
|
5995
|
+
engine.checkVersion("4.4.0");
|
|
5874
5996
|
await engine.pluginManager.register(e => {
|
|
5875
5997
|
e.pluginManager.addParticleUpdater("life", container => {
|
|
5876
5998
|
return Promise.resolve(new LifeUpdater(container));
|
|
@@ -5896,7 +6018,7 @@
|
|
|
5896
6018
|
}
|
|
5897
6019
|
|
|
5898
6020
|
async function loadLineShape(engine) {
|
|
5899
|
-
engine.checkVersion("4.
|
|
6021
|
+
engine.checkVersion("4.4.0");
|
|
5900
6022
|
await engine.pluginManager.register(e => {
|
|
5901
6023
|
e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
|
|
5902
6024
|
});
|
|
@@ -5980,7 +6102,7 @@
|
|
|
5980
6102
|
}
|
|
5981
6103
|
|
|
5982
6104
|
async function loadParticlesAttractInteraction(engine) {
|
|
5983
|
-
engine.checkVersion("4.
|
|
6105
|
+
engine.checkVersion("4.4.0");
|
|
5984
6106
|
await engine.pluginManager.register((e) => {
|
|
5985
6107
|
ensureInteractivityPluginLoaded(e);
|
|
5986
6108
|
e.pluginManager.addInteractor?.("particlesAttract", container => {
|
|
@@ -6190,7 +6312,7 @@
|
|
|
6190
6312
|
}
|
|
6191
6313
|
|
|
6192
6314
|
async function loadParticlesCollisionsInteraction(engine) {
|
|
6193
|
-
engine.checkVersion("4.
|
|
6315
|
+
engine.checkVersion("4.4.0");
|
|
6194
6316
|
await engine.pluginManager.register((e) => {
|
|
6195
6317
|
ensureInteractivityPluginLoaded(e);
|
|
6196
6318
|
e.pluginManager.addPlugin(new OverlapPlugin());
|
|
@@ -6403,7 +6525,7 @@
|
|
|
6403
6525
|
const linkColor = linksOptions.id !== undefined
|
|
6404
6526
|
? container.particles.linksColors.get(linksOptions.id)
|
|
6405
6527
|
: container.particles.linksColor;
|
|
6406
|
-
return getLinkColor(p1, p2, linkColor);
|
|
6528
|
+
return getLinkColor(p1, p2, linkColor, container.hdr);
|
|
6407
6529
|
}
|
|
6408
6530
|
#setColor(p1) {
|
|
6409
6531
|
if (!p1.options.links) {
|
|
@@ -6444,7 +6566,7 @@
|
|
|
6444
6566
|
}
|
|
6445
6567
|
|
|
6446
6568
|
async function loadParticlesLinksInteraction(engine) {
|
|
6447
|
-
engine.checkVersion("4.
|
|
6569
|
+
engine.checkVersion("4.4.0");
|
|
6448
6570
|
await engine.pluginManager.register((e) => {
|
|
6449
6571
|
const pluginManager = e.pluginManager;
|
|
6450
6572
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -6534,19 +6656,19 @@
|
|
|
6534
6656
|
}
|
|
6535
6657
|
|
|
6536
6658
|
async function loadGenericPolygonShape(engine) {
|
|
6537
|
-
engine.checkVersion("4.
|
|
6659
|
+
engine.checkVersion("4.4.0");
|
|
6538
6660
|
await engine.pluginManager.register(e => {
|
|
6539
6661
|
e.pluginManager.addShape(["polygon"], () => Promise.resolve(new PolygonDrawer()));
|
|
6540
6662
|
});
|
|
6541
6663
|
}
|
|
6542
6664
|
async function loadTriangleShape(engine) {
|
|
6543
|
-
engine.checkVersion("4.
|
|
6665
|
+
engine.checkVersion("4.4.0");
|
|
6544
6666
|
await engine.pluginManager.register(e => {
|
|
6545
6667
|
e.pluginManager.addShape(["triangle"], () => Promise.resolve(new TriangleDrawer()));
|
|
6546
6668
|
});
|
|
6547
6669
|
}
|
|
6548
6670
|
async function loadPolygonShape(engine) {
|
|
6549
|
-
engine.checkVersion("4.
|
|
6671
|
+
engine.checkVersion("4.4.0");
|
|
6550
6672
|
await Promise.all([
|
|
6551
6673
|
loadGenericPolygonShape(engine),
|
|
6552
6674
|
loadTriangleShape(engine),
|
|
@@ -6651,7 +6773,7 @@
|
|
|
6651
6773
|
}
|
|
6652
6774
|
|
|
6653
6775
|
async function loadRotateUpdater(engine) {
|
|
6654
|
-
engine.checkVersion("4.
|
|
6776
|
+
engine.checkVersion("4.4.0");
|
|
6655
6777
|
await engine.pluginManager.register(e => {
|
|
6656
6778
|
e.pluginManager.addParticleUpdater("rotate", container => {
|
|
6657
6779
|
return Promise.resolve(new RotateUpdater(container));
|
|
@@ -6675,7 +6797,7 @@
|
|
|
6675
6797
|
}
|
|
6676
6798
|
|
|
6677
6799
|
async function loadSquareShape(engine) {
|
|
6678
|
-
engine.checkVersion("4.
|
|
6800
|
+
engine.checkVersion("4.4.0");
|
|
6679
6801
|
await engine.pluginManager.register(e => {
|
|
6680
6802
|
e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
|
|
6681
6803
|
});
|
|
@@ -6709,14 +6831,14 @@
|
|
|
6709
6831
|
}
|
|
6710
6832
|
|
|
6711
6833
|
async function loadStarShape(engine) {
|
|
6712
|
-
engine.checkVersion("4.
|
|
6834
|
+
engine.checkVersion("4.4.0");
|
|
6713
6835
|
await engine.pluginManager.register(e => {
|
|
6714
6836
|
e.pluginManager.addShape(["star"], () => Promise.resolve(new StarDrawer()));
|
|
6715
6837
|
});
|
|
6716
6838
|
}
|
|
6717
6839
|
|
|
6718
6840
|
async function loadSlim(engine) {
|
|
6719
|
-
engine.checkVersion("4.
|
|
6841
|
+
engine.checkVersion("4.4.0");
|
|
6720
6842
|
await engine.pluginManager.register(async (e) => {
|
|
6721
6843
|
const loadInteractivityForSlim = async (e) => {
|
|
6722
6844
|
await loadInteractivityPlugin(e);
|
|
@@ -6877,7 +6999,11 @@
|
|
|
6877
6999
|
if (!fColor && !sColor) {
|
|
6878
7000
|
return;
|
|
6879
7001
|
}
|
|
6880
|
-
const container = this.#container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this.#reusableTransform, colorStyles = this.#reusableColorStyles, fill = fColor
|
|
7002
|
+
const container = this.#container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this.#reusableTransform, colorStyles = this.#reusableColorStyles, fill = fColor
|
|
7003
|
+
? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity, container.peakNits, container.hdrMode)
|
|
7004
|
+
: undefined, stroke = sColor
|
|
7005
|
+
? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity, container.peakNits, container.hdrMode)
|
|
7006
|
+
: fill;
|
|
6881
7007
|
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
6882
7008
|
colorStyles.fill = fill;
|
|
6883
7009
|
colorStyles.stroke = stroke;
|
|
@@ -7211,7 +7337,9 @@
|
|
|
7211
7337
|
if (typeof background.element === "string") {
|
|
7212
7338
|
if (typeof document !== "undefined") {
|
|
7213
7339
|
const node = document.querySelector(background.element);
|
|
7214
|
-
if (
|
|
7340
|
+
if ((typeof HTMLCanvasElement !== "undefined" && node instanceof HTMLCanvasElement) ||
|
|
7341
|
+
(typeof HTMLVideoElement !== "undefined" && node instanceof HTMLVideoElement) ||
|
|
7342
|
+
(typeof HTMLImageElement !== "undefined" && node instanceof HTMLImageElement)) {
|
|
7215
7343
|
this.#backgroundElement = node;
|
|
7216
7344
|
}
|
|
7217
7345
|
else if (node) {
|
|
@@ -7222,10 +7350,10 @@
|
|
|
7222
7350
|
}
|
|
7223
7351
|
}
|
|
7224
7352
|
}
|
|
7225
|
-
else if (background.element instanceof HTMLCanvasElement ||
|
|
7226
|
-
background.element instanceof OffscreenCanvas ||
|
|
7227
|
-
background.element instanceof HTMLVideoElement ||
|
|
7228
|
-
background.element instanceof HTMLImageElement) {
|
|
7353
|
+
else if ((typeof HTMLCanvasElement !== "undefined" && background.element instanceof HTMLCanvasElement) ||
|
|
7354
|
+
(typeof OffscreenCanvas !== "undefined" && background.element instanceof OffscreenCanvas) ||
|
|
7355
|
+
(typeof HTMLVideoElement !== "undefined" && background.element instanceof HTMLVideoElement) ||
|
|
7356
|
+
(typeof HTMLImageElement !== "undefined" && background.element instanceof HTMLImageElement)) {
|
|
7229
7357
|
this.#backgroundElement = background.element;
|
|
7230
7358
|
}
|
|
7231
7359
|
}
|
|
@@ -7293,6 +7421,7 @@
|
|
|
7293
7421
|
zoom = defaultZoom;
|
|
7294
7422
|
#container;
|
|
7295
7423
|
#generated;
|
|
7424
|
+
#hdrMediaListeners;
|
|
7296
7425
|
#mutationObserver;
|
|
7297
7426
|
#originalStyle;
|
|
7298
7427
|
#pluginManager;
|
|
@@ -7357,7 +7486,6 @@
|
|
|
7357
7486
|
});
|
|
7358
7487
|
this.resize();
|
|
7359
7488
|
this.#initStyle();
|
|
7360
|
-
this.initBackground();
|
|
7361
7489
|
this.#safeMutationObserver(obs => {
|
|
7362
7490
|
const element = this.domElement;
|
|
7363
7491
|
if (!element || !(element instanceof Node)) {
|
|
@@ -7367,6 +7495,8 @@
|
|
|
7367
7495
|
});
|
|
7368
7496
|
this.initPlugins();
|
|
7369
7497
|
this.#initContext();
|
|
7498
|
+
this.initBackground();
|
|
7499
|
+
this.#initHdrListeners();
|
|
7370
7500
|
this.render.init();
|
|
7371
7501
|
}
|
|
7372
7502
|
initBackground() {
|
|
@@ -7376,7 +7506,8 @@
|
|
|
7376
7506
|
}
|
|
7377
7507
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
7378
7508
|
if (color) {
|
|
7379
|
-
|
|
7509
|
+
const hdrOptions = container.actualOptions.hdr;
|
|
7510
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity, hdrOptions.peakNits, hdrOptions.mode);
|
|
7380
7511
|
}
|
|
7381
7512
|
else {
|
|
7382
7513
|
elementStyle.backgroundColor = "";
|
|
@@ -7473,6 +7604,7 @@
|
|
|
7473
7604
|
obs.disconnect();
|
|
7474
7605
|
});
|
|
7475
7606
|
this.#mutationObserver = undefined;
|
|
7607
|
+
this.#removeHdrListeners();
|
|
7476
7608
|
this.render.stop();
|
|
7477
7609
|
}
|
|
7478
7610
|
async windowResize() {
|
|
@@ -7492,9 +7624,16 @@
|
|
|
7492
7624
|
}
|
|
7493
7625
|
}
|
|
7494
7626
|
#initContext() {
|
|
7495
|
-
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
7627
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr.enable &&
|
|
7496
7628
|
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
7497
7629
|
safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
7630
|
+
container.hdr = canSupportHdr ?? false;
|
|
7631
|
+
container.hdrMode = container.actualOptions.hdr.mode;
|
|
7632
|
+
container.peakNits = container.actualOptions.hdr.peakNits;
|
|
7633
|
+
const renderCanvas = this.renderCanvas;
|
|
7634
|
+
if (!renderCanvas) {
|
|
7635
|
+
return;
|
|
7636
|
+
}
|
|
7498
7637
|
this.render.setContextSettings({
|
|
7499
7638
|
alpha: true,
|
|
7500
7639
|
desynchronized: true,
|
|
@@ -7503,11 +7642,47 @@
|
|
|
7503
7642
|
? { colorSpace: "display-p3", colorType: "float16" }
|
|
7504
7643
|
: { colorSpace: "srgb" }),
|
|
7505
7644
|
});
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7645
|
+
let context;
|
|
7646
|
+
try {
|
|
7647
|
+
context = renderCanvas.getContext("2d", this.render.settings);
|
|
7648
|
+
}
|
|
7649
|
+
catch {
|
|
7650
|
+
context = null;
|
|
7651
|
+
}
|
|
7652
|
+
if (canSupportHdr && !context) {
|
|
7653
|
+
container.hdr = false;
|
|
7654
|
+
const sdrSettings = {
|
|
7655
|
+
alpha: true,
|
|
7656
|
+
desynchronized: true,
|
|
7657
|
+
willReadFrequently: false,
|
|
7658
|
+
colorSpace: "srgb",
|
|
7659
|
+
};
|
|
7660
|
+
this.render.setContextSettings(sdrSettings);
|
|
7661
|
+
try {
|
|
7662
|
+
context = renderCanvas.getContext("2d", sdrSettings);
|
|
7663
|
+
}
|
|
7664
|
+
catch {
|
|
7665
|
+
context = null;
|
|
7666
|
+
}
|
|
7509
7667
|
}
|
|
7510
|
-
this.render.setContext(
|
|
7668
|
+
this.render.setContext(context);
|
|
7669
|
+
}
|
|
7670
|
+
#initHdrListeners() {
|
|
7671
|
+
this.#removeHdrListeners();
|
|
7672
|
+
const p3Query = safeMatchMedia("(color-gamut: p3)"), hdrQuery = safeMatchMedia("(dynamic-range: high)"), handleChange = () => {
|
|
7673
|
+
this.#recreateRenderCanvas();
|
|
7674
|
+
this.#initContext();
|
|
7675
|
+
this.initBackground();
|
|
7676
|
+
}, listeners = [];
|
|
7677
|
+
if (p3Query) {
|
|
7678
|
+
p3Query.addEventListener("change", handleChange);
|
|
7679
|
+
listeners.push({ handler: handleChange, mql: p3Query });
|
|
7680
|
+
}
|
|
7681
|
+
if (hdrQuery) {
|
|
7682
|
+
hdrQuery.addEventListener("change", handleChange);
|
|
7683
|
+
listeners.push({ handler: handleChange, mql: hdrQuery });
|
|
7684
|
+
}
|
|
7685
|
+
this.#hdrMediaListeners = listeners;
|
|
7511
7686
|
}
|
|
7512
7687
|
#initStyle() {
|
|
7513
7688
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
@@ -7531,6 +7706,25 @@
|
|
|
7531
7706
|
element.style.setProperty(key, value, "important");
|
|
7532
7707
|
}
|
|
7533
7708
|
}
|
|
7709
|
+
#recreateRenderCanvas() {
|
|
7710
|
+
const renderCanvas = this.renderCanvas;
|
|
7711
|
+
if (!renderCanvas) {
|
|
7712
|
+
return;
|
|
7713
|
+
}
|
|
7714
|
+
if (this.domElement) {
|
|
7715
|
+
return;
|
|
7716
|
+
}
|
|
7717
|
+
this.renderCanvas = new OffscreenCanvas(renderCanvas.width, renderCanvas.height);
|
|
7718
|
+
}
|
|
7719
|
+
#removeHdrListeners() {
|
|
7720
|
+
if (!this.#hdrMediaListeners) {
|
|
7721
|
+
return;
|
|
7722
|
+
}
|
|
7723
|
+
for (const { handler, mql } of this.#hdrMediaListeners) {
|
|
7724
|
+
mql.removeEventListener("change", handler);
|
|
7725
|
+
}
|
|
7726
|
+
this.#hdrMediaListeners = undefined;
|
|
7727
|
+
}
|
|
7534
7728
|
#repairStyle() {
|
|
7535
7729
|
const element = this.domElement;
|
|
7536
7730
|
if (!element) {
|
|
@@ -7915,9 +8109,9 @@
|
|
|
7915
8109
|
}
|
|
7916
8110
|
getOpacity() {
|
|
7917
8111
|
const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, baseOpacity = getRangeValue(this.opacity?.value ?? defaultOpacity$3), modifierOpacity = this.#applyModifiers(undefined, m => m.opacity), opacity = modifierOpacity ?? baseOpacity, fillOpacity = this.fillOpacity ?? defaultOpacity$3, strokeOpacity = this.strokeOpacity ?? defaultOpacity$3;
|
|
7918
|
-
this.#cachedOpacityData.fillOpacity =
|
|
8112
|
+
this.#cachedOpacityData.fillOpacity = fillOpacity;
|
|
7919
8113
|
this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
7920
|
-
this.#cachedOpacityData.strokeOpacity =
|
|
8114
|
+
this.#cachedOpacityData.strokeOpacity = strokeOpacity;
|
|
7921
8115
|
return this.#cachedOpacityData;
|
|
7922
8116
|
}
|
|
7923
8117
|
getPosition() {
|
|
@@ -8772,6 +8966,7 @@
|
|
|
8772
8966
|
effectDrawers;
|
|
8773
8967
|
fpsLimit;
|
|
8774
8968
|
hdr;
|
|
8969
|
+
hdrMode;
|
|
8775
8970
|
id;
|
|
8776
8971
|
pageHidden;
|
|
8777
8972
|
particleCreatedPlugins;
|
|
@@ -8779,6 +8974,7 @@
|
|
|
8779
8974
|
particlePositionPlugins;
|
|
8780
8975
|
particleUpdaters;
|
|
8781
8976
|
particles;
|
|
8977
|
+
peakNits;
|
|
8782
8978
|
plugins;
|
|
8783
8979
|
retina;
|
|
8784
8980
|
shapeDrawers;
|
|
@@ -8809,6 +9005,8 @@
|
|
|
8809
9005
|
this.id = Symbol(id);
|
|
8810
9006
|
this.fpsLimit = 120;
|
|
8811
9007
|
this.hdr = false;
|
|
9008
|
+
this.hdrMode = exports.HdrMode.standard;
|
|
9009
|
+
this.peakNits = 400;
|
|
8812
9010
|
this.#smooth = false;
|
|
8813
9011
|
this.#delay = 0;
|
|
8814
9012
|
this.#duration = 0;
|
|
@@ -8948,8 +9146,9 @@
|
|
|
8948
9146
|
this.updateActualOptions();
|
|
8949
9147
|
this.canvas.initBackground();
|
|
8950
9148
|
this.canvas.resize();
|
|
8951
|
-
const { delay, duration, fpsLimit,
|
|
8952
|
-
this.
|
|
9149
|
+
const { delay, duration, fpsLimit, smooth, zLayers } = this.actualOptions, hdrOptions = this.actualOptions.hdr;
|
|
9150
|
+
this.hdrMode = hdrOptions.mode;
|
|
9151
|
+
this.peakNits = hdrOptions.peakNits;
|
|
8953
9152
|
this.zLayers = zLayers;
|
|
8954
9153
|
this.#duration = getRangeValue(duration) * millisecondsToSeconds;
|
|
8955
9154
|
this.#delay = getRangeValue(delay) * millisecondsToSeconds;
|
|
@@ -10123,10 +10322,10 @@
|
|
|
10123
10322
|
}
|
|
10124
10323
|
}
|
|
10125
10324
|
#getCachedStyle(rgb) {
|
|
10126
|
-
const key = `${rgb.r},${rgb.g},${rgb.b}`;
|
|
10325
|
+
const key = `${rgb.r},${rgb.g},${rgb.b}-${this.#container.hdr}-${this.#container.peakNits}-${this.#container.hdrMode}`;
|
|
10127
10326
|
let style = this.#colorCache.get(key);
|
|
10128
10327
|
if (!style) {
|
|
10129
|
-
style = getStyleFromRgb(rgb, this.#container.hdr);
|
|
10328
|
+
style = getStyleFromRgb(rgb, this.#container.hdr, undefined, this.#container.peakNits, this.#container.hdrMode);
|
|
10130
10329
|
this.#colorCache.set(key, style);
|
|
10131
10330
|
}
|
|
10132
10331
|
return style;
|
|
@@ -10153,6 +10352,7 @@
|
|
|
10153
10352
|
exports.ColorAnimation = ColorAnimation;
|
|
10154
10353
|
exports.Fill = Fill;
|
|
10155
10354
|
exports.FullScreen = FullScreen;
|
|
10355
|
+
exports.HDROptions = HDROptions;
|
|
10156
10356
|
exports.HslAnimation = HslAnimation;
|
|
10157
10357
|
exports.Move = Move;
|
|
10158
10358
|
exports.MoveAngle = MoveAngle;
|