@tsparticles/pjs 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 +4 -4
- package/report.html +1 -1
- package/tsparticles.pjs.bundle.js +317 -117
- package/tsparticles.pjs.bundle.min.js +1 -1
- package/tsparticles.pjs.js +2 -2
- package/tsparticles.pjs.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 {
|
|
@@ -2808,7 +2930,7 @@
|
|
|
2808
2930
|
}
|
|
2809
2931
|
|
|
2810
2932
|
async function loadInteractivityPlugin(engine) {
|
|
2811
|
-
engine.checkVersion("4.
|
|
2933
|
+
engine.checkVersion("4.4.0");
|
|
2812
2934
|
await engine.pluginManager.register(e => {
|
|
2813
2935
|
const interactivityEngine = e, interactivityPluginManager = interactivityEngine.pluginManager;
|
|
2814
2936
|
interactivityPluginManager.addPlugin(new InteractivityPlugin(interactivityPluginManager));
|
|
@@ -3048,7 +3170,7 @@
|
|
|
3048
3170
|
}
|
|
3049
3171
|
|
|
3050
3172
|
async function loadAbsorbersInteraction(engine) {
|
|
3051
|
-
engine.checkVersion("4.
|
|
3173
|
+
engine.checkVersion("4.4.0");
|
|
3052
3174
|
await engine.pluginManager.register(async (e) => {
|
|
3053
3175
|
const pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);
|
|
3054
3176
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -3096,7 +3218,7 @@
|
|
|
3096
3218
|
}
|
|
3097
3219
|
|
|
3098
3220
|
async function loadAbsorbersPluginSimple(engine) {
|
|
3099
|
-
engine.checkVersion("4.
|
|
3221
|
+
engine.checkVersion("4.4.0");
|
|
3100
3222
|
await engine.pluginManager.register(async (e) => {
|
|
3101
3223
|
const pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);
|
|
3102
3224
|
pluginManager.addPlugin(new AbsorbersPlugin(instancesManager));
|
|
@@ -3422,7 +3544,7 @@
|
|
|
3422
3544
|
}
|
|
3423
3545
|
|
|
3424
3546
|
async function loadDestroyUpdater(engine) {
|
|
3425
|
-
engine.checkVersion("4.
|
|
3547
|
+
engine.checkVersion("4.4.0");
|
|
3426
3548
|
await engine.pluginManager.register(e => {
|
|
3427
3549
|
e.pluginManager.addParticleUpdater("destroy", container => {
|
|
3428
3550
|
return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
|
|
@@ -3740,7 +3862,7 @@
|
|
|
3740
3862
|
})(EmitterClickMode || (EmitterClickMode = {}));
|
|
3741
3863
|
|
|
3742
3864
|
async function loadEmittersInteraction(engine) {
|
|
3743
|
-
engine.checkVersion("4.
|
|
3865
|
+
engine.checkVersion("4.4.0");
|
|
3744
3866
|
await engine.pluginManager.register(async (e) => {
|
|
3745
3867
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
3746
3868
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -3783,7 +3905,7 @@
|
|
|
3783
3905
|
}
|
|
3784
3906
|
|
|
3785
3907
|
async function loadEmittersPluginSimple(engine) {
|
|
3786
|
-
engine.checkVersion("4.
|
|
3908
|
+
engine.checkVersion("4.4.0");
|
|
3787
3909
|
await engine.pluginManager.register(async (e) => {
|
|
3788
3910
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
3789
3911
|
await addEmittersShapesManager(e);
|
|
@@ -3840,7 +3962,7 @@
|
|
|
3840
3962
|
}
|
|
3841
3963
|
|
|
3842
3964
|
async function loadEmittersShapeCircle(engine) {
|
|
3843
|
-
engine.checkVersion("4.
|
|
3965
|
+
engine.checkVersion("4.4.0");
|
|
3844
3966
|
await engine.pluginManager.register((e) => {
|
|
3845
3967
|
ensureEmittersPluginLoaded(e);
|
|
3846
3968
|
e.pluginManager.addEmitterShapeGenerator?.("circle", new EmittersCircleShapeGenerator());
|
|
@@ -3921,7 +4043,7 @@
|
|
|
3921
4043
|
}
|
|
3922
4044
|
|
|
3923
4045
|
async function loadEmittersShapeSquare(engine) {
|
|
3924
|
-
engine.checkVersion("4.
|
|
4046
|
+
engine.checkVersion("4.4.0");
|
|
3925
4047
|
await engine.pluginManager.register((e) => {
|
|
3926
4048
|
ensureEmittersPluginLoaded(e);
|
|
3927
4049
|
e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
|
|
@@ -4103,7 +4225,7 @@
|
|
|
4103
4225
|
}
|
|
4104
4226
|
|
|
4105
4227
|
async function loadExternalDragInteraction(engine) {
|
|
4106
|
-
engine.checkVersion("4.
|
|
4228
|
+
engine.checkVersion("4.4.0");
|
|
4107
4229
|
await engine.pluginManager.register((e) => {
|
|
4108
4230
|
ensureInteractivityPluginLoaded(e);
|
|
4109
4231
|
e.pluginManager.addInteractor?.("externalDrag", container => {
|
|
@@ -4276,7 +4398,7 @@
|
|
|
4276
4398
|
}
|
|
4277
4399
|
|
|
4278
4400
|
async function loadExternalTrailInteraction(engine) {
|
|
4279
|
-
engine.checkVersion("4.
|
|
4401
|
+
engine.checkVersion("4.4.0");
|
|
4280
4402
|
await engine.pluginManager.register((e) => {
|
|
4281
4403
|
ensureInteractivityPluginLoaded(e);
|
|
4282
4404
|
e.pluginManager.addInteractor?.("externalTrail", container => {
|
|
@@ -4412,7 +4534,7 @@
|
|
|
4412
4534
|
}
|
|
4413
4535
|
|
|
4414
4536
|
async function loadRollUpdater(engine) {
|
|
4415
|
-
engine.checkVersion("4.
|
|
4537
|
+
engine.checkVersion("4.4.0");
|
|
4416
4538
|
await engine.pluginManager.register(e => {
|
|
4417
4539
|
e.pluginManager.addParticleUpdater("roll", () => {
|
|
4418
4540
|
return Promise.resolve(new RollUpdater(e.pluginManager));
|
|
@@ -4458,7 +4580,7 @@
|
|
|
4458
4580
|
}
|
|
4459
4581
|
|
|
4460
4582
|
async function loadBlendPlugin(engine) {
|
|
4461
|
-
engine.checkVersion("4.
|
|
4583
|
+
engine.checkVersion("4.4.0");
|
|
4462
4584
|
await engine.pluginManager.register(e => {
|
|
4463
4585
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
4464
4586
|
});
|
|
@@ -4495,7 +4617,7 @@
|
|
|
4495
4617
|
}
|
|
4496
4618
|
|
|
4497
4619
|
async function loadCircleShape(engine) {
|
|
4498
|
-
engine.checkVersion("4.
|
|
4620
|
+
engine.checkVersion("4.4.0");
|
|
4499
4621
|
await engine.pluginManager.register(e => {
|
|
4500
4622
|
e.pluginManager.addShape(["circle"], () => {
|
|
4501
4623
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -4543,7 +4665,7 @@
|
|
|
4543
4665
|
}
|
|
4544
4666
|
|
|
4545
4667
|
async function loadHexColorPlugin(engine) {
|
|
4546
|
-
engine.checkVersion("4.
|
|
4668
|
+
engine.checkVersion("4.4.0");
|
|
4547
4669
|
await engine.pluginManager.register(e => {
|
|
4548
4670
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
4549
4671
|
});
|
|
@@ -4596,7 +4718,7 @@
|
|
|
4596
4718
|
}
|
|
4597
4719
|
|
|
4598
4720
|
async function loadHslColorPlugin(engine) {
|
|
4599
|
-
engine.checkVersion("4.
|
|
4721
|
+
engine.checkVersion("4.4.0");
|
|
4600
4722
|
await engine.pluginManager.register(e => {
|
|
4601
4723
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
4602
4724
|
});
|
|
@@ -4620,7 +4742,7 @@
|
|
|
4620
4742
|
}
|
|
4621
4743
|
|
|
4622
4744
|
async function loadMovePlugin(engine) {
|
|
4623
|
-
engine.checkVersion("4.
|
|
4745
|
+
engine.checkVersion("4.4.0");
|
|
4624
4746
|
await engine.pluginManager.register(e => {
|
|
4625
4747
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
4626
4748
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -4836,7 +4958,7 @@
|
|
|
4836
4958
|
}
|
|
4837
4959
|
|
|
4838
4960
|
async function loadOpacityUpdater(engine) {
|
|
4839
|
-
engine.checkVersion("4.
|
|
4961
|
+
engine.checkVersion("4.4.0");
|
|
4840
4962
|
await engine.pluginManager.register(e => {
|
|
4841
4963
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
4842
4964
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -5181,7 +5303,7 @@
|
|
|
5181
5303
|
}
|
|
5182
5304
|
|
|
5183
5305
|
async function loadOutModesUpdater(engine) {
|
|
5184
|
-
engine.checkVersion("4.
|
|
5306
|
+
engine.checkVersion("4.4.0");
|
|
5185
5307
|
await engine.pluginManager.register(e => {
|
|
5186
5308
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
5187
5309
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -5252,7 +5374,7 @@
|
|
|
5252
5374
|
}
|
|
5253
5375
|
|
|
5254
5376
|
async function loadPaintUpdater(engine) {
|
|
5255
|
-
engine.checkVersion("4.
|
|
5377
|
+
engine.checkVersion("4.4.0");
|
|
5256
5378
|
await engine.pluginManager.register(e => {
|
|
5257
5379
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
5258
5380
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -5307,7 +5429,7 @@
|
|
|
5307
5429
|
}
|
|
5308
5430
|
|
|
5309
5431
|
async function loadRgbColorPlugin(engine) {
|
|
5310
|
-
engine.checkVersion("4.
|
|
5432
|
+
engine.checkVersion("4.4.0");
|
|
5311
5433
|
await engine.pluginManager.register(e => {
|
|
5312
5434
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
5313
5435
|
});
|
|
@@ -5392,7 +5514,7 @@
|
|
|
5392
5514
|
}
|
|
5393
5515
|
|
|
5394
5516
|
async function loadSizeUpdater(engine) {
|
|
5395
|
-
engine.checkVersion("4.
|
|
5517
|
+
engine.checkVersion("4.4.0");
|
|
5396
5518
|
await engine.pluginManager.register(e => {
|
|
5397
5519
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
5398
5520
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -5401,7 +5523,7 @@
|
|
|
5401
5523
|
}
|
|
5402
5524
|
|
|
5403
5525
|
async function loadBasic(engine) {
|
|
5404
|
-
engine.checkVersion("4.
|
|
5526
|
+
engine.checkVersion("4.4.0");
|
|
5405
5527
|
await engine.pluginManager.register(async (e) => {
|
|
5406
5528
|
await Promise.all([
|
|
5407
5529
|
loadBlendPlugin(e),
|
|
@@ -5424,7 +5546,7 @@
|
|
|
5424
5546
|
easingsFunctions.set("ease-in-out-quad", value => (value < 0.5 ? 2 * value ** 2 : 1 - (-2 * value + 2) ** 2 / 2));
|
|
5425
5547
|
|
|
5426
5548
|
async function loadEasingQuadPlugin(engine) {
|
|
5427
|
-
engine.checkVersion("4.
|
|
5549
|
+
engine.checkVersion("4.4.0");
|
|
5428
5550
|
await engine.pluginManager.register(e => {
|
|
5429
5551
|
for (const [easing, easingFn] of easingsFunctions) {
|
|
5430
5552
|
e.pluginManager.addEasing(easing, easingFn);
|
|
@@ -5532,7 +5654,7 @@
|
|
|
5532
5654
|
}
|
|
5533
5655
|
|
|
5534
5656
|
async function loadEmojiShape(engine) {
|
|
5535
|
-
engine.checkVersion("4.
|
|
5657
|
+
engine.checkVersion("4.4.0");
|
|
5536
5658
|
await engine.pluginManager.register(e => {
|
|
5537
5659
|
e.pluginManager.addShape(validTypes$1, () => Promise.resolve(new EmojiDrawer()));
|
|
5538
5660
|
});
|
|
@@ -5765,7 +5887,7 @@
|
|
|
5765
5887
|
};
|
|
5766
5888
|
|
|
5767
5889
|
async function loadExternalAttractInteraction(engine) {
|
|
5768
|
-
engine.checkVersion("4.
|
|
5890
|
+
engine.checkVersion("4.4.0");
|
|
5769
5891
|
await engine.pluginManager.register((e) => {
|
|
5770
5892
|
ensureInteractivityPluginLoaded(e);
|
|
5771
5893
|
e.pluginManager.addInteractor?.("externalAttract", container => {
|
|
@@ -5954,7 +6076,7 @@
|
|
|
5954
6076
|
}
|
|
5955
6077
|
|
|
5956
6078
|
async function loadExternalBounceInteraction(engine) {
|
|
5957
|
-
engine.checkVersion("4.
|
|
6079
|
+
engine.checkVersion("4.4.0");
|
|
5958
6080
|
await engine.pluginManager.register((e) => {
|
|
5959
6081
|
ensureInteractivityPluginLoaded(e);
|
|
5960
6082
|
e.pluginManager.addInteractor?.("externalBounce", container => {
|
|
@@ -6241,7 +6363,7 @@
|
|
|
6241
6363
|
mod.strokeColor = undefined;
|
|
6242
6364
|
const pColor = particle.getFillColor();
|
|
6243
6365
|
if (pColor) {
|
|
6244
|
-
const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio));
|
|
6366
|
+
const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio, this.container.hdr));
|
|
6245
6367
|
mod.fillColor = mixedColor;
|
|
6246
6368
|
mod.strokeColor = mixedColor;
|
|
6247
6369
|
}
|
|
@@ -6354,7 +6476,7 @@
|
|
|
6354
6476
|
}
|
|
6355
6477
|
|
|
6356
6478
|
async function loadExternalBubbleInteraction(engine) {
|
|
6357
|
-
engine.checkVersion("4.
|
|
6479
|
+
engine.checkVersion("4.4.0");
|
|
6358
6480
|
await engine.pluginManager.register((e) => {
|
|
6359
6481
|
ensureInteractivityPluginLoaded(e);
|
|
6360
6482
|
e.pluginManager.addInteractor?.("externalBubble", container => {
|
|
@@ -6393,10 +6515,10 @@
|
|
|
6393
6515
|
if (!color1 || !color2) {
|
|
6394
6516
|
return;
|
|
6395
6517
|
}
|
|
6396
|
-
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);
|
|
6397
|
-
grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity));
|
|
6398
|
-
grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity));
|
|
6399
|
-
grad.addColorStop(gradientMax, getStyleFromHsl(color2, container.hdr, opacity));
|
|
6518
|
+
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);
|
|
6519
|
+
grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
6520
|
+
grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
6521
|
+
grad.addColorStop(gradientMax, getStyleFromHsl(color2, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
6400
6522
|
return grad;
|
|
6401
6523
|
}
|
|
6402
6524
|
function drawConnectLine(context, width, lineStyle, begin, end) {
|
|
@@ -6482,7 +6604,7 @@
|
|
|
6482
6604
|
}
|
|
6483
6605
|
|
|
6484
6606
|
async function loadExternalConnectInteraction(engine) {
|
|
6485
|
-
engine.checkVersion("4.
|
|
6607
|
+
engine.checkVersion("4.4.0");
|
|
6486
6608
|
await engine.pluginManager.register((e) => {
|
|
6487
6609
|
ensureInteractivityPluginLoaded(e);
|
|
6488
6610
|
e.pluginManager.addInteractor?.("externalConnect", container => {
|
|
@@ -6586,7 +6708,7 @@
|
|
|
6586
6708
|
}
|
|
6587
6709
|
|
|
6588
6710
|
async function loadExternalDestroyInteraction(engine) {
|
|
6589
|
-
engine.checkVersion("4.
|
|
6711
|
+
engine.checkVersion("4.4.0");
|
|
6590
6712
|
await engine.pluginManager.register((e) => {
|
|
6591
6713
|
ensureInteractivityPluginLoaded(e);
|
|
6592
6714
|
e.pluginManager.addInteractor?.("externalDestroy", async (container) => {
|
|
@@ -6626,16 +6748,16 @@
|
|
|
6626
6748
|
}
|
|
6627
6749
|
|
|
6628
6750
|
const defaultWidth = 0;
|
|
6629
|
-
function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {
|
|
6751
|
+
function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false, peakNits, mode) {
|
|
6630
6752
|
drawLine$1(context, begin, end);
|
|
6631
|
-
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
6753
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity, peakNits, mode);
|
|
6632
6754
|
context.lineWidth = width;
|
|
6633
6755
|
context.stroke();
|
|
6634
6756
|
}
|
|
6635
6757
|
function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
6636
6758
|
container.canvas.render.draw(ctx => {
|
|
6637
6759
|
const beginPos = particle.getPosition();
|
|
6638
|
-
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr);
|
|
6760
|
+
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr, container.peakNits, container.hdrMode);
|
|
6639
6761
|
});
|
|
6640
6762
|
}
|
|
6641
6763
|
|
|
@@ -6691,7 +6813,7 @@
|
|
|
6691
6813
|
const linksOptions = interactivity.modes.grab.links;
|
|
6692
6814
|
container.particles.grabLineColor = getLinkRandomColor(this.#pluginManager, optColor, linksOptions.blink, linksOptions.consent);
|
|
6693
6815
|
}
|
|
6694
|
-
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor);
|
|
6816
|
+
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor, container.hdr);
|
|
6695
6817
|
if (!colorLine) {
|
|
6696
6818
|
continue;
|
|
6697
6819
|
}
|
|
@@ -6710,7 +6832,7 @@
|
|
|
6710
6832
|
}
|
|
6711
6833
|
|
|
6712
6834
|
async function loadExternalGrabInteraction(engine) {
|
|
6713
|
-
engine.checkVersion("4.
|
|
6835
|
+
engine.checkVersion("4.4.0");
|
|
6714
6836
|
await engine.pluginManager.register((e) => {
|
|
6715
6837
|
ensureInteractivityPluginLoaded(e);
|
|
6716
6838
|
e.pluginManager.addInteractor?.("externalGrab", container => {
|
|
@@ -6780,7 +6902,7 @@
|
|
|
6780
6902
|
}
|
|
6781
6903
|
|
|
6782
6904
|
async function loadExternalParallaxInteraction(engine) {
|
|
6783
|
-
engine.checkVersion("4.
|
|
6905
|
+
engine.checkVersion("4.4.0");
|
|
6784
6906
|
await engine.pluginManager.register((e) => {
|
|
6785
6907
|
ensureInteractivityPluginLoaded(e);
|
|
6786
6908
|
e.pluginManager.addInteractor?.("externalParallax", container => {
|
|
@@ -6823,7 +6945,7 @@
|
|
|
6823
6945
|
}
|
|
6824
6946
|
|
|
6825
6947
|
async function loadExternalPauseInteraction(engine) {
|
|
6826
|
-
engine.checkVersion("4.
|
|
6948
|
+
engine.checkVersion("4.4.0");
|
|
6827
6949
|
await engine.pluginManager.register((e) => {
|
|
6828
6950
|
ensureInteractivityPluginLoaded(e);
|
|
6829
6951
|
e.pluginManager.addInteractor?.("externalPause", container => {
|
|
@@ -6895,7 +7017,7 @@
|
|
|
6895
7017
|
}
|
|
6896
7018
|
|
|
6897
7019
|
async function loadExternalPushInteraction(engine) {
|
|
6898
|
-
engine.checkVersion("4.
|
|
7020
|
+
engine.checkVersion("4.4.0");
|
|
6899
7021
|
await engine.pluginManager.register((e) => {
|
|
6900
7022
|
ensureInteractivityPluginLoaded(e);
|
|
6901
7023
|
e.pluginManager.addInteractor?.("externalPush", container => {
|
|
@@ -6949,7 +7071,7 @@
|
|
|
6949
7071
|
}
|
|
6950
7072
|
|
|
6951
7073
|
async function loadExternalRemoveInteraction(engine) {
|
|
6952
|
-
engine.checkVersion("4.
|
|
7074
|
+
engine.checkVersion("4.4.0");
|
|
6953
7075
|
await engine.pluginManager.register((e) => {
|
|
6954
7076
|
ensureInteractivityPluginLoaded(e);
|
|
6955
7077
|
e.pluginManager.addInteractor?.("externalRemove", container => {
|
|
@@ -7255,7 +7377,7 @@
|
|
|
7255
7377
|
}
|
|
7256
7378
|
|
|
7257
7379
|
async function loadExternalRepulseInteraction(engine) {
|
|
7258
|
-
engine.checkVersion("4.
|
|
7380
|
+
engine.checkVersion("4.4.0");
|
|
7259
7381
|
await engine.pluginManager.register((e) => {
|
|
7260
7382
|
ensureInteractivityPluginLoaded(e);
|
|
7261
7383
|
const pluginManager = e.pluginManager;
|
|
@@ -7349,7 +7471,7 @@
|
|
|
7349
7471
|
}
|
|
7350
7472
|
|
|
7351
7473
|
async function loadExternalSlowInteraction(engine) {
|
|
7352
|
-
engine.checkVersion("4.
|
|
7474
|
+
engine.checkVersion("4.4.0");
|
|
7353
7475
|
await engine.pluginManager.register((e) => {
|
|
7354
7476
|
ensureInteractivityPluginLoaded(e);
|
|
7355
7477
|
e.pluginManager.addInteractor?.("externalSlow", container => {
|
|
@@ -7361,12 +7483,12 @@
|
|
|
7361
7483
|
const shapeTypes = ["image", "images"];
|
|
7362
7484
|
const stringStart = 0, defaultOpacity = 1;
|
|
7363
7485
|
const currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;
|
|
7364
|
-
function replaceColorSvg(imageShape, color, opacity, hdr = false) {
|
|
7486
|
+
function replaceColorSvg(imageShape, color, opacity, hdr = false, peakNits, mode) {
|
|
7365
7487
|
const { svgData } = imageShape;
|
|
7366
7488
|
if (!svgData) {
|
|
7367
7489
|
return "";
|
|
7368
7490
|
}
|
|
7369
|
-
const colorStyle = getStyleFromHsl(color, hdr, opacity);
|
|
7491
|
+
const colorStyle = getStyleFromHsl(color, hdr, opacity, peakNits, mode);
|
|
7370
7492
|
if (svgData.includes("fill")) {
|
|
7371
7493
|
return svgData.replaceAll(currentColorRegex, () => colorStyle);
|
|
7372
7494
|
}
|
|
@@ -7408,8 +7530,8 @@
|
|
|
7408
7530
|
}
|
|
7409
7531
|
image.loading = false;
|
|
7410
7532
|
}
|
|
7411
|
-
function replaceImageColor(image, imageData, color, particle, hdr = false) {
|
|
7412
|
-
const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity, hdr), imageRes = {
|
|
7533
|
+
function replaceImageColor(image, imageData, color, particle, hdr = false, peakNits, mode) {
|
|
7534
|
+
const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity, hdr, peakNits, mode), imageRes = {
|
|
7413
7535
|
color,
|
|
7414
7536
|
data: {
|
|
7415
7537
|
...image,
|
|
@@ -7521,7 +7643,7 @@
|
|
|
7521
7643
|
void (async () => {
|
|
7522
7644
|
let imageRes;
|
|
7523
7645
|
if (image.svgData && color) {
|
|
7524
|
-
imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr);
|
|
7646
|
+
imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr, container.peakNits, container.hdrMode);
|
|
7525
7647
|
}
|
|
7526
7648
|
else {
|
|
7527
7649
|
imageRes = {
|
|
@@ -7658,7 +7780,7 @@
|
|
|
7658
7780
|
};
|
|
7659
7781
|
}
|
|
7660
7782
|
async function loadImageShape(engine) {
|
|
7661
|
-
engine.checkVersion("4.
|
|
7783
|
+
engine.checkVersion("4.4.0");
|
|
7662
7784
|
await engine.pluginManager.register(e => {
|
|
7663
7785
|
addLoadImageToEngine(e);
|
|
7664
7786
|
e.pluginManager.addPlugin(new ImagePreloaderPlugin(e));
|
|
@@ -7803,7 +7925,7 @@
|
|
|
7803
7925
|
}
|
|
7804
7926
|
|
|
7805
7927
|
async function loadLifeUpdater(engine) {
|
|
7806
|
-
engine.checkVersion("4.
|
|
7928
|
+
engine.checkVersion("4.4.0");
|
|
7807
7929
|
await engine.pluginManager.register(e => {
|
|
7808
7930
|
e.pluginManager.addParticleUpdater("life", container => {
|
|
7809
7931
|
return Promise.resolve(new LifeUpdater(container));
|
|
@@ -7829,7 +7951,7 @@
|
|
|
7829
7951
|
}
|
|
7830
7952
|
|
|
7831
7953
|
async function loadLineShape(engine) {
|
|
7832
|
-
engine.checkVersion("4.
|
|
7954
|
+
engine.checkVersion("4.4.0");
|
|
7833
7955
|
await engine.pluginManager.register(e => {
|
|
7834
7956
|
e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
|
|
7835
7957
|
});
|
|
@@ -7913,7 +8035,7 @@
|
|
|
7913
8035
|
}
|
|
7914
8036
|
|
|
7915
8037
|
async function loadParticlesAttractInteraction(engine) {
|
|
7916
|
-
engine.checkVersion("4.
|
|
8038
|
+
engine.checkVersion("4.4.0");
|
|
7917
8039
|
await engine.pluginManager.register((e) => {
|
|
7918
8040
|
ensureInteractivityPluginLoaded(e);
|
|
7919
8041
|
e.pluginManager.addInteractor?.("particlesAttract", container => {
|
|
@@ -8123,7 +8245,7 @@
|
|
|
8123
8245
|
}
|
|
8124
8246
|
|
|
8125
8247
|
async function loadParticlesCollisionsInteraction(engine) {
|
|
8126
|
-
engine.checkVersion("4.
|
|
8248
|
+
engine.checkVersion("4.4.0");
|
|
8127
8249
|
await engine.pluginManager.register((e) => {
|
|
8128
8250
|
ensureInteractivityPluginLoaded(e);
|
|
8129
8251
|
e.pluginManager.addPlugin(new OverlapPlugin());
|
|
@@ -8336,7 +8458,7 @@
|
|
|
8336
8458
|
const linkColor = linksOptions.id !== undefined
|
|
8337
8459
|
? container.particles.linksColors.get(linksOptions.id)
|
|
8338
8460
|
: container.particles.linksColor;
|
|
8339
|
-
return getLinkColor(p1, p2, linkColor);
|
|
8461
|
+
return getLinkColor(p1, p2, linkColor, container.hdr);
|
|
8340
8462
|
}
|
|
8341
8463
|
#setColor(p1) {
|
|
8342
8464
|
if (!p1.options.links) {
|
|
@@ -8377,7 +8499,7 @@
|
|
|
8377
8499
|
}
|
|
8378
8500
|
|
|
8379
8501
|
async function loadParticlesLinksInteraction(engine) {
|
|
8380
|
-
engine.checkVersion("4.
|
|
8502
|
+
engine.checkVersion("4.4.0");
|
|
8381
8503
|
await engine.pluginManager.register((e) => {
|
|
8382
8504
|
const pluginManager = e.pluginManager;
|
|
8383
8505
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -8467,19 +8589,19 @@
|
|
|
8467
8589
|
}
|
|
8468
8590
|
|
|
8469
8591
|
async function loadGenericPolygonShape(engine) {
|
|
8470
|
-
engine.checkVersion("4.
|
|
8592
|
+
engine.checkVersion("4.4.0");
|
|
8471
8593
|
await engine.pluginManager.register(e => {
|
|
8472
8594
|
e.pluginManager.addShape(["polygon"], () => Promise.resolve(new PolygonDrawer()));
|
|
8473
8595
|
});
|
|
8474
8596
|
}
|
|
8475
8597
|
async function loadTriangleShape(engine) {
|
|
8476
|
-
engine.checkVersion("4.
|
|
8598
|
+
engine.checkVersion("4.4.0");
|
|
8477
8599
|
await engine.pluginManager.register(e => {
|
|
8478
8600
|
e.pluginManager.addShape(["triangle"], () => Promise.resolve(new TriangleDrawer()));
|
|
8479
8601
|
});
|
|
8480
8602
|
}
|
|
8481
8603
|
async function loadPolygonShape(engine) {
|
|
8482
|
-
engine.checkVersion("4.
|
|
8604
|
+
engine.checkVersion("4.4.0");
|
|
8483
8605
|
await Promise.all([
|
|
8484
8606
|
loadGenericPolygonShape(engine),
|
|
8485
8607
|
loadTriangleShape(engine),
|
|
@@ -8584,7 +8706,7 @@
|
|
|
8584
8706
|
}
|
|
8585
8707
|
|
|
8586
8708
|
async function loadRotateUpdater(engine) {
|
|
8587
|
-
engine.checkVersion("4.
|
|
8709
|
+
engine.checkVersion("4.4.0");
|
|
8588
8710
|
await engine.pluginManager.register(e => {
|
|
8589
8711
|
e.pluginManager.addParticleUpdater("rotate", container => {
|
|
8590
8712
|
return Promise.resolve(new RotateUpdater(container));
|
|
@@ -8608,7 +8730,7 @@
|
|
|
8608
8730
|
}
|
|
8609
8731
|
|
|
8610
8732
|
async function loadSquareShape(engine) {
|
|
8611
|
-
engine.checkVersion("4.
|
|
8733
|
+
engine.checkVersion("4.4.0");
|
|
8612
8734
|
await engine.pluginManager.register(e => {
|
|
8613
8735
|
e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
|
|
8614
8736
|
});
|
|
@@ -8642,14 +8764,14 @@
|
|
|
8642
8764
|
}
|
|
8643
8765
|
|
|
8644
8766
|
async function loadStarShape(engine) {
|
|
8645
|
-
engine.checkVersion("4.
|
|
8767
|
+
engine.checkVersion("4.4.0");
|
|
8646
8768
|
await engine.pluginManager.register(e => {
|
|
8647
8769
|
e.pluginManager.addShape(["star"], () => Promise.resolve(new StarDrawer()));
|
|
8648
8770
|
});
|
|
8649
8771
|
}
|
|
8650
8772
|
|
|
8651
8773
|
async function loadSlim(engine) {
|
|
8652
|
-
engine.checkVersion("4.
|
|
8774
|
+
engine.checkVersion("4.4.0");
|
|
8653
8775
|
await engine.pluginManager.register(async (e) => {
|
|
8654
8776
|
const loadInteractivityForSlim = async (e) => {
|
|
8655
8777
|
await loadInteractivityPlugin(e);
|
|
@@ -8766,7 +8888,7 @@
|
|
|
8766
8888
|
}
|
|
8767
8889
|
|
|
8768
8890
|
async function loadTextShape(engine) {
|
|
8769
|
-
engine.checkVersion("4.
|
|
8891
|
+
engine.checkVersion("4.4.0");
|
|
8770
8892
|
await engine.pluginManager.register(e => {
|
|
8771
8893
|
e.pluginManager.addShape(validTypes, () => Promise.resolve(new TextDrawer()));
|
|
8772
8894
|
});
|
|
@@ -8875,7 +8997,7 @@
|
|
|
8875
8997
|
}
|
|
8876
8998
|
|
|
8877
8999
|
async function loadTiltUpdater(engine) {
|
|
8878
|
-
engine.checkVersion("4.
|
|
9000
|
+
engine.checkVersion("4.4.0");
|
|
8879
9001
|
await engine.pluginManager.register(e => {
|
|
8880
9002
|
e.pluginManager.addParticleUpdater("tilt", container => {
|
|
8881
9003
|
return Promise.resolve(new TiltUpdater(container));
|
|
@@ -8951,12 +9073,12 @@
|
|
|
8951
9073
|
if (!twinkleFillRgb) {
|
|
8952
9074
|
return undefined;
|
|
8953
9075
|
}
|
|
8954
|
-
return getStyleFromHsl(twinkleFillRgb, container.hdr, twinklingOpacity);
|
|
9076
|
+
return getStyleFromHsl(twinkleFillRgb, container.hdr, twinklingOpacity, container.peakNits, container.hdrMode);
|
|
8955
9077
|
}, getTwinkleStrokeStyle = () => {
|
|
8956
9078
|
if (!twinkleStrokeRgb) {
|
|
8957
9079
|
return undefined;
|
|
8958
9080
|
}
|
|
8959
|
-
return getStyleFromHsl(twinkleStrokeRgb, container.hdr, twinklingOpacity);
|
|
9081
|
+
return getStyleFromHsl(twinkleStrokeRgb, container.hdr, twinklingOpacity, container.peakNits, container.hdrMode);
|
|
8960
9082
|
}, twinkleFillStyle = getTwinkleFillStyle(), twinkleStrokeStyle = getTwinkleStrokeStyle(), res = {}, needsTwinkle = twinkling && (!!twinkleFillStyle || !!twinkleStrokeStyle);
|
|
8961
9083
|
res.fill = needsTwinkle ? twinkleFillStyle : undefined;
|
|
8962
9084
|
res.stroke = needsTwinkle ? twinkleStrokeStyle : undefined;
|
|
@@ -8979,7 +9101,7 @@
|
|
|
8979
9101
|
}
|
|
8980
9102
|
|
|
8981
9103
|
async function loadTwinkleUpdater(engine) {
|
|
8982
|
-
engine.checkVersion("4.
|
|
9104
|
+
engine.checkVersion("4.4.0");
|
|
8983
9105
|
await engine.pluginManager.register(e => {
|
|
8984
9106
|
e.pluginManager.addParticleUpdater("twinkle", container => {
|
|
8985
9107
|
return Promise.resolve(new TwinkleUpdater(e.pluginManager, container));
|
|
@@ -9081,7 +9203,7 @@
|
|
|
9081
9203
|
}
|
|
9082
9204
|
|
|
9083
9205
|
async function loadWobbleUpdater(engine) {
|
|
9084
|
-
engine.checkVersion("4.
|
|
9206
|
+
engine.checkVersion("4.4.0");
|
|
9085
9207
|
await engine.pluginManager.register(e => {
|
|
9086
9208
|
e.pluginManager.addParticleUpdater("wobble", container => {
|
|
9087
9209
|
return Promise.resolve(new WobbleUpdater(container));
|
|
@@ -9090,7 +9212,7 @@
|
|
|
9090
9212
|
}
|
|
9091
9213
|
|
|
9092
9214
|
async function loadFull(engine) {
|
|
9093
|
-
engine.checkVersion("4.
|
|
9215
|
+
engine.checkVersion("4.4.0");
|
|
9094
9216
|
await engine.pluginManager.register(async (e) => {
|
|
9095
9217
|
const loadEmittersPluginBundle = async (e) => {
|
|
9096
9218
|
await loadEmittersPlugin(e);
|
|
@@ -9190,14 +9312,14 @@
|
|
|
9190
9312
|
}
|
|
9191
9313
|
|
|
9192
9314
|
async function loadResponsivePlugin(engine) {
|
|
9193
|
-
engine.checkVersion("4.
|
|
9315
|
+
engine.checkVersion("4.4.0");
|
|
9194
9316
|
await engine.pluginManager.register(e => {
|
|
9195
9317
|
e.pluginManager.addPlugin(new ResponsivePlugin());
|
|
9196
9318
|
});
|
|
9197
9319
|
}
|
|
9198
9320
|
|
|
9199
9321
|
const initPjs = async (engine) => {
|
|
9200
|
-
engine.checkVersion("4.
|
|
9322
|
+
engine.checkVersion("4.4.0");
|
|
9201
9323
|
await engine.pluginManager.register(async (e) => {
|
|
9202
9324
|
await Promise.all([loadFull(e), loadResponsivePlugin(e)]);
|
|
9203
9325
|
});
|
|
@@ -9329,7 +9451,11 @@
|
|
|
9329
9451
|
if (!fColor && !sColor) {
|
|
9330
9452
|
return;
|
|
9331
9453
|
}
|
|
9332
|
-
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
|
|
9454
|
+
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
|
|
9455
|
+
? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity, container.peakNits, container.hdrMode)
|
|
9456
|
+
: undefined, stroke = sColor
|
|
9457
|
+
? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity, container.peakNits, container.hdrMode)
|
|
9458
|
+
: fill;
|
|
9333
9459
|
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
9334
9460
|
colorStyles.fill = fill;
|
|
9335
9461
|
colorStyles.stroke = stroke;
|
|
@@ -9663,7 +9789,9 @@
|
|
|
9663
9789
|
if (typeof background.element === "string") {
|
|
9664
9790
|
if (typeof document !== "undefined") {
|
|
9665
9791
|
const node = document.querySelector(background.element);
|
|
9666
|
-
if (
|
|
9792
|
+
if ((typeof HTMLCanvasElement !== "undefined" && node instanceof HTMLCanvasElement) ||
|
|
9793
|
+
(typeof HTMLVideoElement !== "undefined" && node instanceof HTMLVideoElement) ||
|
|
9794
|
+
(typeof HTMLImageElement !== "undefined" && node instanceof HTMLImageElement)) {
|
|
9667
9795
|
this.#backgroundElement = node;
|
|
9668
9796
|
}
|
|
9669
9797
|
else if (node) {
|
|
@@ -9674,10 +9802,10 @@
|
|
|
9674
9802
|
}
|
|
9675
9803
|
}
|
|
9676
9804
|
}
|
|
9677
|
-
else if (background.element instanceof HTMLCanvasElement ||
|
|
9678
|
-
background.element instanceof OffscreenCanvas ||
|
|
9679
|
-
background.element instanceof HTMLVideoElement ||
|
|
9680
|
-
background.element instanceof HTMLImageElement) {
|
|
9805
|
+
else if ((typeof HTMLCanvasElement !== "undefined" && background.element instanceof HTMLCanvasElement) ||
|
|
9806
|
+
(typeof OffscreenCanvas !== "undefined" && background.element instanceof OffscreenCanvas) ||
|
|
9807
|
+
(typeof HTMLVideoElement !== "undefined" && background.element instanceof HTMLVideoElement) ||
|
|
9808
|
+
(typeof HTMLImageElement !== "undefined" && background.element instanceof HTMLImageElement)) {
|
|
9681
9809
|
this.#backgroundElement = background.element;
|
|
9682
9810
|
}
|
|
9683
9811
|
}
|
|
@@ -9745,6 +9873,7 @@
|
|
|
9745
9873
|
zoom = defaultZoom;
|
|
9746
9874
|
#container;
|
|
9747
9875
|
#generated;
|
|
9876
|
+
#hdrMediaListeners;
|
|
9748
9877
|
#mutationObserver;
|
|
9749
9878
|
#originalStyle;
|
|
9750
9879
|
#pluginManager;
|
|
@@ -9809,7 +9938,6 @@
|
|
|
9809
9938
|
});
|
|
9810
9939
|
this.resize();
|
|
9811
9940
|
this.#initStyle();
|
|
9812
|
-
this.initBackground();
|
|
9813
9941
|
this.#safeMutationObserver(obs => {
|
|
9814
9942
|
const element = this.domElement;
|
|
9815
9943
|
if (!element || !(element instanceof Node)) {
|
|
@@ -9819,6 +9947,8 @@
|
|
|
9819
9947
|
});
|
|
9820
9948
|
this.initPlugins();
|
|
9821
9949
|
this.#initContext();
|
|
9950
|
+
this.initBackground();
|
|
9951
|
+
this.#initHdrListeners();
|
|
9822
9952
|
this.render.init();
|
|
9823
9953
|
}
|
|
9824
9954
|
initBackground() {
|
|
@@ -9828,7 +9958,8 @@
|
|
|
9828
9958
|
}
|
|
9829
9959
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
9830
9960
|
if (color) {
|
|
9831
|
-
|
|
9961
|
+
const hdrOptions = container.actualOptions.hdr;
|
|
9962
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity, hdrOptions.peakNits, hdrOptions.mode);
|
|
9832
9963
|
}
|
|
9833
9964
|
else {
|
|
9834
9965
|
elementStyle.backgroundColor = "";
|
|
@@ -9925,6 +10056,7 @@
|
|
|
9925
10056
|
obs.disconnect();
|
|
9926
10057
|
});
|
|
9927
10058
|
this.#mutationObserver = undefined;
|
|
10059
|
+
this.#removeHdrListeners();
|
|
9928
10060
|
this.render.stop();
|
|
9929
10061
|
}
|
|
9930
10062
|
async windowResize() {
|
|
@@ -9944,9 +10076,16 @@
|
|
|
9944
10076
|
}
|
|
9945
10077
|
}
|
|
9946
10078
|
#initContext() {
|
|
9947
|
-
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
10079
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr.enable &&
|
|
9948
10080
|
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
9949
10081
|
safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
10082
|
+
container.hdr = canSupportHdr ?? false;
|
|
10083
|
+
container.hdrMode = container.actualOptions.hdr.mode;
|
|
10084
|
+
container.peakNits = container.actualOptions.hdr.peakNits;
|
|
10085
|
+
const renderCanvas = this.renderCanvas;
|
|
10086
|
+
if (!renderCanvas) {
|
|
10087
|
+
return;
|
|
10088
|
+
}
|
|
9950
10089
|
this.render.setContextSettings({
|
|
9951
10090
|
alpha: true,
|
|
9952
10091
|
desynchronized: true,
|
|
@@ -9955,11 +10094,47 @@
|
|
|
9955
10094
|
? { colorSpace: "display-p3", colorType: "float16" }
|
|
9956
10095
|
: { colorSpace: "srgb" }),
|
|
9957
10096
|
});
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
10097
|
+
let context;
|
|
10098
|
+
try {
|
|
10099
|
+
context = renderCanvas.getContext("2d", this.render.settings);
|
|
10100
|
+
}
|
|
10101
|
+
catch {
|
|
10102
|
+
context = null;
|
|
10103
|
+
}
|
|
10104
|
+
if (canSupportHdr && !context) {
|
|
10105
|
+
container.hdr = false;
|
|
10106
|
+
const sdrSettings = {
|
|
10107
|
+
alpha: true,
|
|
10108
|
+
desynchronized: true,
|
|
10109
|
+
willReadFrequently: false,
|
|
10110
|
+
colorSpace: "srgb",
|
|
10111
|
+
};
|
|
10112
|
+
this.render.setContextSettings(sdrSettings);
|
|
10113
|
+
try {
|
|
10114
|
+
context = renderCanvas.getContext("2d", sdrSettings);
|
|
10115
|
+
}
|
|
10116
|
+
catch {
|
|
10117
|
+
context = null;
|
|
10118
|
+
}
|
|
9961
10119
|
}
|
|
9962
|
-
this.render.setContext(
|
|
10120
|
+
this.render.setContext(context);
|
|
10121
|
+
}
|
|
10122
|
+
#initHdrListeners() {
|
|
10123
|
+
this.#removeHdrListeners();
|
|
10124
|
+
const p3Query = safeMatchMedia("(color-gamut: p3)"), hdrQuery = safeMatchMedia("(dynamic-range: high)"), handleChange = () => {
|
|
10125
|
+
this.#recreateRenderCanvas();
|
|
10126
|
+
this.#initContext();
|
|
10127
|
+
this.initBackground();
|
|
10128
|
+
}, listeners = [];
|
|
10129
|
+
if (p3Query) {
|
|
10130
|
+
p3Query.addEventListener("change", handleChange);
|
|
10131
|
+
listeners.push({ handler: handleChange, mql: p3Query });
|
|
10132
|
+
}
|
|
10133
|
+
if (hdrQuery) {
|
|
10134
|
+
hdrQuery.addEventListener("change", handleChange);
|
|
10135
|
+
listeners.push({ handler: handleChange, mql: hdrQuery });
|
|
10136
|
+
}
|
|
10137
|
+
this.#hdrMediaListeners = listeners;
|
|
9963
10138
|
}
|
|
9964
10139
|
#initStyle() {
|
|
9965
10140
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
@@ -9983,6 +10158,25 @@
|
|
|
9983
10158
|
element.style.setProperty(key, value, "important");
|
|
9984
10159
|
}
|
|
9985
10160
|
}
|
|
10161
|
+
#recreateRenderCanvas() {
|
|
10162
|
+
const renderCanvas = this.renderCanvas;
|
|
10163
|
+
if (!renderCanvas) {
|
|
10164
|
+
return;
|
|
10165
|
+
}
|
|
10166
|
+
if (this.domElement) {
|
|
10167
|
+
return;
|
|
10168
|
+
}
|
|
10169
|
+
this.renderCanvas = new OffscreenCanvas(renderCanvas.width, renderCanvas.height);
|
|
10170
|
+
}
|
|
10171
|
+
#removeHdrListeners() {
|
|
10172
|
+
if (!this.#hdrMediaListeners) {
|
|
10173
|
+
return;
|
|
10174
|
+
}
|
|
10175
|
+
for (const { handler, mql } of this.#hdrMediaListeners) {
|
|
10176
|
+
mql.removeEventListener("change", handler);
|
|
10177
|
+
}
|
|
10178
|
+
this.#hdrMediaListeners = undefined;
|
|
10179
|
+
}
|
|
9986
10180
|
#repairStyle() {
|
|
9987
10181
|
const element = this.domElement;
|
|
9988
10182
|
if (!element) {
|
|
@@ -10367,9 +10561,9 @@
|
|
|
10367
10561
|
}
|
|
10368
10562
|
getOpacity() {
|
|
10369
10563
|
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;
|
|
10370
|
-
this.#cachedOpacityData.fillOpacity =
|
|
10564
|
+
this.#cachedOpacityData.fillOpacity = fillOpacity;
|
|
10371
10565
|
this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
10372
|
-
this.#cachedOpacityData.strokeOpacity =
|
|
10566
|
+
this.#cachedOpacityData.strokeOpacity = strokeOpacity;
|
|
10373
10567
|
return this.#cachedOpacityData;
|
|
10374
10568
|
}
|
|
10375
10569
|
getPosition() {
|
|
@@ -11224,6 +11418,7 @@
|
|
|
11224
11418
|
effectDrawers;
|
|
11225
11419
|
fpsLimit;
|
|
11226
11420
|
hdr;
|
|
11421
|
+
hdrMode;
|
|
11227
11422
|
id;
|
|
11228
11423
|
pageHidden;
|
|
11229
11424
|
particleCreatedPlugins;
|
|
@@ -11231,6 +11426,7 @@
|
|
|
11231
11426
|
particlePositionPlugins;
|
|
11232
11427
|
particleUpdaters;
|
|
11233
11428
|
particles;
|
|
11429
|
+
peakNits;
|
|
11234
11430
|
plugins;
|
|
11235
11431
|
retina;
|
|
11236
11432
|
shapeDrawers;
|
|
@@ -11261,6 +11457,8 @@
|
|
|
11261
11457
|
this.id = Symbol(id);
|
|
11262
11458
|
this.fpsLimit = 120;
|
|
11263
11459
|
this.hdr = false;
|
|
11460
|
+
this.hdrMode = exports.HdrMode.standard;
|
|
11461
|
+
this.peakNits = 400;
|
|
11264
11462
|
this.#smooth = false;
|
|
11265
11463
|
this.#delay = 0;
|
|
11266
11464
|
this.#duration = 0;
|
|
@@ -11400,8 +11598,9 @@
|
|
|
11400
11598
|
this.updateActualOptions();
|
|
11401
11599
|
this.canvas.initBackground();
|
|
11402
11600
|
this.canvas.resize();
|
|
11403
|
-
const { delay, duration, fpsLimit,
|
|
11404
|
-
this.
|
|
11601
|
+
const { delay, duration, fpsLimit, smooth, zLayers } = this.actualOptions, hdrOptions = this.actualOptions.hdr;
|
|
11602
|
+
this.hdrMode = hdrOptions.mode;
|
|
11603
|
+
this.peakNits = hdrOptions.peakNits;
|
|
11405
11604
|
this.zLayers = zLayers;
|
|
11406
11605
|
this.#duration = getRangeValue(duration) * millisecondsToSeconds;
|
|
11407
11606
|
this.#delay = getRangeValue(delay) * millisecondsToSeconds;
|
|
@@ -12820,10 +13019,10 @@
|
|
|
12820
13019
|
}
|
|
12821
13020
|
}
|
|
12822
13021
|
#getCachedStyle(rgb) {
|
|
12823
|
-
const key = `${rgb.r},${rgb.g},${rgb.b}`;
|
|
13022
|
+
const key = `${rgb.r},${rgb.g},${rgb.b}-${this.#container.hdr}-${this.#container.peakNits}-${this.#container.hdrMode}`;
|
|
12824
13023
|
let style = this.#colorCache.get(key);
|
|
12825
13024
|
if (!style) {
|
|
12826
|
-
style = getStyleFromRgb(rgb, this.#container.hdr);
|
|
13025
|
+
style = getStyleFromRgb(rgb, this.#container.hdr, undefined, this.#container.peakNits, this.#container.hdrMode);
|
|
12827
13026
|
this.#colorCache.set(key, style);
|
|
12828
13027
|
}
|
|
12829
13028
|
return style;
|
|
@@ -12956,7 +13155,7 @@
|
|
|
12956
13155
|
context.beginPath();
|
|
12957
13156
|
context.arc(originPoint.x, originPoint.y, this.size, minAngle, maxAngle, false);
|
|
12958
13157
|
context.closePath();
|
|
12959
|
-
context.fillStyle = getStyleFromRgb(this.color, this.#container.hdr, this.opacity);
|
|
13158
|
+
context.fillStyle = getStyleFromRgb(this.color, this.#container.hdr, this.opacity, this.#container.peakNits, this.#container.hdrMode);
|
|
12960
13159
|
context.fill();
|
|
12961
13160
|
}
|
|
12962
13161
|
resize() {
|
|
@@ -13436,6 +13635,7 @@
|
|
|
13436
13635
|
exports.ColorAnimation = ColorAnimation;
|
|
13437
13636
|
exports.Fill = Fill;
|
|
13438
13637
|
exports.FullScreen = FullScreen;
|
|
13638
|
+
exports.HDROptions = HDROptions;
|
|
13439
13639
|
exports.HslAnimation = HslAnimation;
|
|
13440
13640
|
exports.Move = Move;
|
|
13441
13641
|
exports.MoveAngle = MoveAngle;
|