tsparticles 4.3.1 → 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 +15 -15
- package/report.html +1 -1
- package/tsparticles.bundle.js +326 -118
- package/tsparticles.bundle.min.js +1 -1
- package/tsparticles.js +2 -2
- package/tsparticles.min.js +1 -1
package/tsparticles.bundle.js
CHANGED
|
@@ -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) :
|
|
@@ -332,6 +332,9 @@
|
|
|
332
332
|
})(exports.PixelMode || (exports.PixelMode = {}));
|
|
333
333
|
|
|
334
334
|
const minRadius$4 = 0;
|
|
335
|
+
function isForbiddenKey(key) {
|
|
336
|
+
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
337
|
+
}
|
|
335
338
|
function hasMatchMedia() {
|
|
336
339
|
return typeof matchMedia !== "undefined";
|
|
337
340
|
}
|
|
@@ -407,7 +410,7 @@
|
|
|
407
410
|
if (!hasNested) {
|
|
408
411
|
const sourceDict = source, destDict = destination;
|
|
409
412
|
for (const key of sourceKeys) {
|
|
410
|
-
if (key
|
|
413
|
+
if (isForbiddenKey(key)) {
|
|
411
414
|
continue;
|
|
412
415
|
}
|
|
413
416
|
const v = sourceDict[key];
|
|
@@ -418,7 +421,7 @@
|
|
|
418
421
|
continue;
|
|
419
422
|
}
|
|
420
423
|
for (const key of sourceKeys) {
|
|
421
|
-
if (key
|
|
424
|
+
if (isForbiddenKey(key)) {
|
|
422
425
|
continue;
|
|
423
426
|
}
|
|
424
427
|
const sourceDict = source, destDict = destination, value = sourceDict[key];
|
|
@@ -877,7 +880,7 @@
|
|
|
877
880
|
return this.#domArray;
|
|
878
881
|
}
|
|
879
882
|
get version() {
|
|
880
|
-
return "4.
|
|
883
|
+
return "4.4.0";
|
|
881
884
|
}
|
|
882
885
|
addEventListener(type, listener) {
|
|
883
886
|
this.#eventDispatcher.addEventListener(type, listener);
|
|
@@ -958,6 +961,10 @@
|
|
|
958
961
|
}
|
|
959
962
|
|
|
960
963
|
function initEngine() {
|
|
964
|
+
const existing = globalThis.tsParticles;
|
|
965
|
+
if (existing?.pluginManager) {
|
|
966
|
+
return existing;
|
|
967
|
+
}
|
|
961
968
|
return new Engine();
|
|
962
969
|
}
|
|
963
970
|
|
|
@@ -1055,6 +1062,15 @@
|
|
|
1055
1062
|
AnimationMode["random"] = "random";
|
|
1056
1063
|
})(exports.AnimationMode || (exports.AnimationMode = {}));
|
|
1057
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
|
+
|
|
1058
1074
|
exports.LimitMode = void 0;
|
|
1059
1075
|
(function (LimitMode) {
|
|
1060
1076
|
LimitMode["delete"] = "delete";
|
|
@@ -1160,7 +1176,12 @@
|
|
|
1160
1176
|
}
|
|
1161
1177
|
function loadExtendProperty(obj, key, value) {
|
|
1162
1178
|
if (value !== undefined) {
|
|
1163
|
-
|
|
1179
|
+
const keyStr = key;
|
|
1180
|
+
if (keyStr === "__proto__" || keyStr === "constructor" || keyStr === "prototype") {
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
const objRecord = obj, currentValue = Object.prototype.hasOwnProperty.call(objRecord, keyStr) ? objRecord[keyStr] : {};
|
|
1184
|
+
objRecord[keyStr] = deepExtend(currentValue, value);
|
|
1164
1185
|
}
|
|
1165
1186
|
}
|
|
1166
1187
|
function loadOptionProperty(obj, key, optionClass, ...sources) {
|
|
@@ -1315,6 +1336,29 @@
|
|
|
1315
1336
|
}
|
|
1316
1337
|
}
|
|
1317
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
|
+
|
|
1318
1362
|
class ResizeEvent extends OptionLoader {
|
|
1319
1363
|
delay = 0.5;
|
|
1320
1364
|
enable = true;
|
|
@@ -1758,7 +1802,7 @@
|
|
|
1758
1802
|
duration = 0;
|
|
1759
1803
|
fpsLimit = 120;
|
|
1760
1804
|
fullScreen;
|
|
1761
|
-
hdr
|
|
1805
|
+
hdr;
|
|
1762
1806
|
key;
|
|
1763
1807
|
name;
|
|
1764
1808
|
palette;
|
|
@@ -1778,6 +1822,7 @@
|
|
|
1778
1822
|
this.#container = container;
|
|
1779
1823
|
this.background = new Background();
|
|
1780
1824
|
this.fullScreen = new FullScreen();
|
|
1825
|
+
this.hdr = new HDROptions();
|
|
1781
1826
|
this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
|
|
1782
1827
|
this.resize = new ResizeEvent();
|
|
1783
1828
|
}
|
|
@@ -1800,7 +1845,15 @@
|
|
|
1800
1845
|
loadProperty(this, "detectRetina", data.detectRetina);
|
|
1801
1846
|
loadRangeProperty(this, "duration", data.duration);
|
|
1802
1847
|
loadProperty(this, "fpsLimit", data.fpsLimit);
|
|
1803
|
-
|
|
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
|
+
}
|
|
1804
1857
|
loadProperty(this, "pauseOnBlur", data.pauseOnBlur);
|
|
1805
1858
|
loadProperty(this, "pauseOnOutsideViewport", data.pauseOnOutsideViewport);
|
|
1806
1859
|
loadProperty(this, "zLayers", data.zLayers);
|
|
@@ -1843,7 +1896,7 @@
|
|
|
1843
1896
|
}
|
|
1844
1897
|
}
|
|
1845
1898
|
|
|
1846
|
-
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;
|
|
1847
1900
|
function getCachedStyle(key, generator) {
|
|
1848
1901
|
let cached = styleCache.get(key);
|
|
1849
1902
|
if (!cached) {
|
|
@@ -1855,6 +1908,48 @@
|
|
|
1855
1908
|
}
|
|
1856
1909
|
return cached;
|
|
1857
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
|
+
}
|
|
1858
1953
|
function stringToRgba(pluginManager, input) {
|
|
1859
1954
|
if (!input) {
|
|
1860
1955
|
return;
|
|
@@ -2022,30 +2117,65 @@
|
|
|
2022
2117
|
r: getRgbInRangeValue(),
|
|
2023
2118
|
};
|
|
2024
2119
|
}
|
|
2025
|
-
function getStyleFromRgb(color, hdr, opacity) {
|
|
2026
|
-
const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? defaultOpacity$3, key =
|
|
2027
|
-
|
|
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));
|
|
2028
2125
|
}
|
|
2029
|
-
function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
|
|
2030
|
-
const headroom = peakNits / sdrReferenceWhiteNits;
|
|
2031
|
-
return `color(display-p3 ${
|
|
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);
|
|
2137
|
+
}
|
|
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);
|
|
2032
2144
|
}
|
|
2033
2145
|
function getSdrStyleFromRgb(color, opacity) {
|
|
2034
2146
|
return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$3).toString()})`;
|
|
2035
2147
|
}
|
|
2036
|
-
function getStyleFromHsl(color, hdr, opacity) {
|
|
2037
|
-
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()}`;
|
|
2038
2152
|
return getCachedStyle(key, () => hdr
|
|
2039
|
-
? getStyleFromRgb(hslToRgbFloat(color), true, opacity)
|
|
2153
|
+
? getStyleFromRgb(hslToRgbFloat(color), true, opacity, peakNits, mode)
|
|
2040
2154
|
: `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
|
|
2041
2155
|
}
|
|
2042
|
-
function colorMix(color1, color2, size1, size2) {
|
|
2156
|
+
function colorMix(color1, color2, size1, size2, hdr) {
|
|
2043
2157
|
let rgb1 = color1, rgb2 = color2;
|
|
2044
2158
|
if (!("r" in rgb1)) {
|
|
2045
|
-
rgb1 = hslToRgb(color1);
|
|
2159
|
+
rgb1 = hdr ? hslToRgbFloat(color1) : hslToRgb(color1);
|
|
2046
2160
|
}
|
|
2047
2161
|
if (!("r" in rgb2)) {
|
|
2048
|
-
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
|
+
};
|
|
2049
2179
|
}
|
|
2050
2180
|
return {
|
|
2051
2181
|
b: mix(rgb1.b, rgb2.b, size1, size2),
|
|
@@ -2053,14 +2183,14 @@
|
|
|
2053
2183
|
r: mix(rgb1.r, rgb2.r, size1, size2),
|
|
2054
2184
|
};
|
|
2055
2185
|
}
|
|
2056
|
-
function getLinkColor(p1, p2, linkColor) {
|
|
2186
|
+
function getLinkColor(p1, p2, linkColor, hdr) {
|
|
2057
2187
|
if (linkColor === randomColorValue) {
|
|
2058
2188
|
return getRandomRgbColor();
|
|
2059
2189
|
}
|
|
2060
2190
|
else if (linkColor === midColorValue) {
|
|
2061
2191
|
const sourceColor = p1.getFillColor() ?? p1.getStrokeColor(), destColor = p2?.getFillColor() ?? p2?.getStrokeColor();
|
|
2062
2192
|
if (sourceColor && destColor && p2) {
|
|
2063
|
-
return colorMix(sourceColor, destColor, p1.getRadius(), p2.getRadius());
|
|
2193
|
+
return colorMix(sourceColor, destColor, p1.getRadius(), p2.getRadius(), hdr);
|
|
2064
2194
|
}
|
|
2065
2195
|
else {
|
|
2066
2196
|
const hslColor = sourceColor ?? destColor;
|
|
@@ -2156,7 +2286,7 @@
|
|
|
2156
2286
|
colorValue.velocity = defaultVelocity;
|
|
2157
2287
|
}
|
|
2158
2288
|
}
|
|
2159
|
-
function updateColorValue(data, decrease, delta,
|
|
2289
|
+
function updateColorValue(data, decrease, delta, _hdr) {
|
|
2160
2290
|
const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minOffset = 0, velocityFactor = 3.6;
|
|
2161
2291
|
if (!data.enable ||
|
|
2162
2292
|
((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
|
|
@@ -2169,7 +2299,7 @@
|
|
|
2169
2299
|
if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
|
|
2170
2300
|
return;
|
|
2171
2301
|
}
|
|
2172
|
-
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;
|
|
2173
2303
|
if (!decrease || data.status === exports.AnimationStatus.increasing) {
|
|
2174
2304
|
data.value += velocity;
|
|
2175
2305
|
if (data.value > max) {
|
|
@@ -2201,9 +2331,9 @@
|
|
|
2201
2331
|
return;
|
|
2202
2332
|
}
|
|
2203
2333
|
const { h, s, l } = color;
|
|
2204
|
-
updateColorValue(h, false, delta
|
|
2205
|
-
updateColorValue(s, true, delta
|
|
2206
|
-
updateColorValue(l, true, delta
|
|
2334
|
+
updateColorValue(h, false, delta);
|
|
2335
|
+
updateColorValue(s, true, delta);
|
|
2336
|
+
updateColorValue(l, true, delta);
|
|
2207
2337
|
}
|
|
2208
2338
|
function alterHsl(color, type, value) {
|
|
2209
2339
|
return {
|
|
@@ -2446,7 +2576,7 @@
|
|
|
2446
2576
|
}
|
|
2447
2577
|
|
|
2448
2578
|
async function loadInteractivityPlugin(engine) {
|
|
2449
|
-
engine.checkVersion("4.
|
|
2579
|
+
engine.checkVersion("4.4.0");
|
|
2450
2580
|
await engine.pluginManager.register(e => {
|
|
2451
2581
|
const interactivityEngine = e, interactivityPluginManager = interactivityEngine.pluginManager;
|
|
2452
2582
|
interactivityPluginManager.addPlugin(new InteractivityPlugin(interactivityPluginManager));
|
|
@@ -2686,7 +2816,7 @@
|
|
|
2686
2816
|
}
|
|
2687
2817
|
|
|
2688
2818
|
async function loadAbsorbersInteraction(engine) {
|
|
2689
|
-
engine.checkVersion("4.
|
|
2819
|
+
engine.checkVersion("4.4.0");
|
|
2690
2820
|
await engine.pluginManager.register(async (e) => {
|
|
2691
2821
|
const pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);
|
|
2692
2822
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -2734,7 +2864,7 @@
|
|
|
2734
2864
|
}
|
|
2735
2865
|
|
|
2736
2866
|
async function loadAbsorbersPluginSimple(engine) {
|
|
2737
|
-
engine.checkVersion("4.
|
|
2867
|
+
engine.checkVersion("4.4.0");
|
|
2738
2868
|
await engine.pluginManager.register(async (e) => {
|
|
2739
2869
|
const pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);
|
|
2740
2870
|
pluginManager.addPlugin(new AbsorbersPlugin(instancesManager));
|
|
@@ -3060,7 +3190,7 @@
|
|
|
3060
3190
|
}
|
|
3061
3191
|
|
|
3062
3192
|
async function loadDestroyUpdater(engine) {
|
|
3063
|
-
engine.checkVersion("4.
|
|
3193
|
+
engine.checkVersion("4.4.0");
|
|
3064
3194
|
await engine.pluginManager.register(e => {
|
|
3065
3195
|
e.pluginManager.addParticleUpdater("destroy", container => {
|
|
3066
3196
|
return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
|
|
@@ -3378,7 +3508,7 @@
|
|
|
3378
3508
|
})(EmitterClickMode || (EmitterClickMode = {}));
|
|
3379
3509
|
|
|
3380
3510
|
async function loadEmittersInteraction(engine) {
|
|
3381
|
-
engine.checkVersion("4.
|
|
3511
|
+
engine.checkVersion("4.4.0");
|
|
3382
3512
|
await engine.pluginManager.register(async (e) => {
|
|
3383
3513
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
3384
3514
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -3421,7 +3551,7 @@
|
|
|
3421
3551
|
}
|
|
3422
3552
|
|
|
3423
3553
|
async function loadEmittersPluginSimple(engine) {
|
|
3424
|
-
engine.checkVersion("4.
|
|
3554
|
+
engine.checkVersion("4.4.0");
|
|
3425
3555
|
await engine.pluginManager.register(async (e) => {
|
|
3426
3556
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
3427
3557
|
await addEmittersShapesManager(e);
|
|
@@ -3478,7 +3608,7 @@
|
|
|
3478
3608
|
}
|
|
3479
3609
|
|
|
3480
3610
|
async function loadEmittersShapeCircle(engine) {
|
|
3481
|
-
engine.checkVersion("4.
|
|
3611
|
+
engine.checkVersion("4.4.0");
|
|
3482
3612
|
await engine.pluginManager.register((e) => {
|
|
3483
3613
|
ensureEmittersPluginLoaded(e);
|
|
3484
3614
|
e.pluginManager.addEmitterShapeGenerator?.("circle", new EmittersCircleShapeGenerator());
|
|
@@ -3559,7 +3689,7 @@
|
|
|
3559
3689
|
}
|
|
3560
3690
|
|
|
3561
3691
|
async function loadEmittersShapeSquare(engine) {
|
|
3562
|
-
engine.checkVersion("4.
|
|
3692
|
+
engine.checkVersion("4.4.0");
|
|
3563
3693
|
await engine.pluginManager.register((e) => {
|
|
3564
3694
|
ensureEmittersPluginLoaded(e);
|
|
3565
3695
|
e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
|
|
@@ -3741,7 +3871,7 @@
|
|
|
3741
3871
|
}
|
|
3742
3872
|
|
|
3743
3873
|
async function loadExternalDragInteraction(engine) {
|
|
3744
|
-
engine.checkVersion("4.
|
|
3874
|
+
engine.checkVersion("4.4.0");
|
|
3745
3875
|
await engine.pluginManager.register((e) => {
|
|
3746
3876
|
ensureInteractivityPluginLoaded(e);
|
|
3747
3877
|
e.pluginManager.addInteractor?.("externalDrag", container => {
|
|
@@ -3914,7 +4044,7 @@
|
|
|
3914
4044
|
}
|
|
3915
4045
|
|
|
3916
4046
|
async function loadExternalTrailInteraction(engine) {
|
|
3917
|
-
engine.checkVersion("4.
|
|
4047
|
+
engine.checkVersion("4.4.0");
|
|
3918
4048
|
await engine.pluginManager.register((e) => {
|
|
3919
4049
|
ensureInteractivityPluginLoaded(e);
|
|
3920
4050
|
e.pluginManager.addInteractor?.("externalTrail", container => {
|
|
@@ -4050,7 +4180,7 @@
|
|
|
4050
4180
|
}
|
|
4051
4181
|
|
|
4052
4182
|
async function loadRollUpdater(engine) {
|
|
4053
|
-
engine.checkVersion("4.
|
|
4183
|
+
engine.checkVersion("4.4.0");
|
|
4054
4184
|
await engine.pluginManager.register(e => {
|
|
4055
4185
|
e.pluginManager.addParticleUpdater("roll", () => {
|
|
4056
4186
|
return Promise.resolve(new RollUpdater(e.pluginManager));
|
|
@@ -4096,7 +4226,7 @@
|
|
|
4096
4226
|
}
|
|
4097
4227
|
|
|
4098
4228
|
async function loadBlendPlugin(engine) {
|
|
4099
|
-
engine.checkVersion("4.
|
|
4229
|
+
engine.checkVersion("4.4.0");
|
|
4100
4230
|
await engine.pluginManager.register(e => {
|
|
4101
4231
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
4102
4232
|
});
|
|
@@ -4133,7 +4263,7 @@
|
|
|
4133
4263
|
}
|
|
4134
4264
|
|
|
4135
4265
|
async function loadCircleShape(engine) {
|
|
4136
|
-
engine.checkVersion("4.
|
|
4266
|
+
engine.checkVersion("4.4.0");
|
|
4137
4267
|
await engine.pluginManager.register(e => {
|
|
4138
4268
|
e.pluginManager.addShape(["circle"], () => {
|
|
4139
4269
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -4181,7 +4311,7 @@
|
|
|
4181
4311
|
}
|
|
4182
4312
|
|
|
4183
4313
|
async function loadHexColorPlugin(engine) {
|
|
4184
|
-
engine.checkVersion("4.
|
|
4314
|
+
engine.checkVersion("4.4.0");
|
|
4185
4315
|
await engine.pluginManager.register(e => {
|
|
4186
4316
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
4187
4317
|
});
|
|
@@ -4234,7 +4364,7 @@
|
|
|
4234
4364
|
}
|
|
4235
4365
|
|
|
4236
4366
|
async function loadHslColorPlugin(engine) {
|
|
4237
|
-
engine.checkVersion("4.
|
|
4367
|
+
engine.checkVersion("4.4.0");
|
|
4238
4368
|
await engine.pluginManager.register(e => {
|
|
4239
4369
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
4240
4370
|
});
|
|
@@ -4258,7 +4388,7 @@
|
|
|
4258
4388
|
}
|
|
4259
4389
|
|
|
4260
4390
|
async function loadMovePlugin(engine) {
|
|
4261
|
-
engine.checkVersion("4.
|
|
4391
|
+
engine.checkVersion("4.4.0");
|
|
4262
4392
|
await engine.pluginManager.register(e => {
|
|
4263
4393
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
4264
4394
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -4474,7 +4604,7 @@
|
|
|
4474
4604
|
}
|
|
4475
4605
|
|
|
4476
4606
|
async function loadOpacityUpdater(engine) {
|
|
4477
|
-
engine.checkVersion("4.
|
|
4607
|
+
engine.checkVersion("4.4.0");
|
|
4478
4608
|
await engine.pluginManager.register(e => {
|
|
4479
4609
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
4480
4610
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -4819,7 +4949,7 @@
|
|
|
4819
4949
|
}
|
|
4820
4950
|
|
|
4821
4951
|
async function loadOutModesUpdater(engine) {
|
|
4822
|
-
engine.checkVersion("4.
|
|
4952
|
+
engine.checkVersion("4.4.0");
|
|
4823
4953
|
await engine.pluginManager.register(e => {
|
|
4824
4954
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
4825
4955
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -4890,7 +5020,7 @@
|
|
|
4890
5020
|
}
|
|
4891
5021
|
|
|
4892
5022
|
async function loadPaintUpdater(engine) {
|
|
4893
|
-
engine.checkVersion("4.
|
|
5023
|
+
engine.checkVersion("4.4.0");
|
|
4894
5024
|
await engine.pluginManager.register(e => {
|
|
4895
5025
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
4896
5026
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -4945,7 +5075,7 @@
|
|
|
4945
5075
|
}
|
|
4946
5076
|
|
|
4947
5077
|
async function loadRgbColorPlugin(engine) {
|
|
4948
|
-
engine.checkVersion("4.
|
|
5078
|
+
engine.checkVersion("4.4.0");
|
|
4949
5079
|
await engine.pluginManager.register(e => {
|
|
4950
5080
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
4951
5081
|
});
|
|
@@ -5030,7 +5160,7 @@
|
|
|
5030
5160
|
}
|
|
5031
5161
|
|
|
5032
5162
|
async function loadSizeUpdater(engine) {
|
|
5033
|
-
engine.checkVersion("4.
|
|
5163
|
+
engine.checkVersion("4.4.0");
|
|
5034
5164
|
await engine.pluginManager.register(e => {
|
|
5035
5165
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
5036
5166
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -5039,7 +5169,7 @@
|
|
|
5039
5169
|
}
|
|
5040
5170
|
|
|
5041
5171
|
async function loadBasic(engine) {
|
|
5042
|
-
engine.checkVersion("4.
|
|
5172
|
+
engine.checkVersion("4.4.0");
|
|
5043
5173
|
await engine.pluginManager.register(async (e) => {
|
|
5044
5174
|
await Promise.all([
|
|
5045
5175
|
loadBlendPlugin(e),
|
|
@@ -5062,7 +5192,7 @@
|
|
|
5062
5192
|
easingsFunctions.set("ease-in-out-quad", value => (value < 0.5 ? 2 * value ** 2 : 1 - (-2 * value + 2) ** 2 / 2));
|
|
5063
5193
|
|
|
5064
5194
|
async function loadEasingQuadPlugin(engine) {
|
|
5065
|
-
engine.checkVersion("4.
|
|
5195
|
+
engine.checkVersion("4.4.0");
|
|
5066
5196
|
await engine.pluginManager.register(e => {
|
|
5067
5197
|
for (const [easing, easingFn] of easingsFunctions) {
|
|
5068
5198
|
e.pluginManager.addEasing(easing, easingFn);
|
|
@@ -5170,7 +5300,7 @@
|
|
|
5170
5300
|
}
|
|
5171
5301
|
|
|
5172
5302
|
async function loadEmojiShape(engine) {
|
|
5173
|
-
engine.checkVersion("4.
|
|
5303
|
+
engine.checkVersion("4.4.0");
|
|
5174
5304
|
await engine.pluginManager.register(e => {
|
|
5175
5305
|
e.pluginManager.addShape(validTypes$1, () => Promise.resolve(new EmojiDrawer()));
|
|
5176
5306
|
});
|
|
@@ -5403,7 +5533,7 @@
|
|
|
5403
5533
|
};
|
|
5404
5534
|
|
|
5405
5535
|
async function loadExternalAttractInteraction(engine) {
|
|
5406
|
-
engine.checkVersion("4.
|
|
5536
|
+
engine.checkVersion("4.4.0");
|
|
5407
5537
|
await engine.pluginManager.register((e) => {
|
|
5408
5538
|
ensureInteractivityPluginLoaded(e);
|
|
5409
5539
|
e.pluginManager.addInteractor?.("externalAttract", container => {
|
|
@@ -5592,7 +5722,7 @@
|
|
|
5592
5722
|
}
|
|
5593
5723
|
|
|
5594
5724
|
async function loadExternalBounceInteraction(engine) {
|
|
5595
|
-
engine.checkVersion("4.
|
|
5725
|
+
engine.checkVersion("4.4.0");
|
|
5596
5726
|
await engine.pluginManager.register((e) => {
|
|
5597
5727
|
ensureInteractivityPluginLoaded(e);
|
|
5598
5728
|
e.pluginManager.addInteractor?.("externalBounce", container => {
|
|
@@ -5879,7 +6009,7 @@
|
|
|
5879
6009
|
mod.strokeColor = undefined;
|
|
5880
6010
|
const pColor = particle.getFillColor();
|
|
5881
6011
|
if (pColor) {
|
|
5882
|
-
const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio));
|
|
6012
|
+
const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio, this.container.hdr));
|
|
5883
6013
|
mod.fillColor = mixedColor;
|
|
5884
6014
|
mod.strokeColor = mixedColor;
|
|
5885
6015
|
}
|
|
@@ -5992,7 +6122,7 @@
|
|
|
5992
6122
|
}
|
|
5993
6123
|
|
|
5994
6124
|
async function loadExternalBubbleInteraction(engine) {
|
|
5995
|
-
engine.checkVersion("4.
|
|
6125
|
+
engine.checkVersion("4.4.0");
|
|
5996
6126
|
await engine.pluginManager.register((e) => {
|
|
5997
6127
|
ensureInteractivityPluginLoaded(e);
|
|
5998
6128
|
e.pluginManager.addInteractor?.("externalBubble", container => {
|
|
@@ -6031,10 +6161,10 @@
|
|
|
6031
6161
|
if (!color1 || !color2) {
|
|
6032
6162
|
return;
|
|
6033
6163
|
}
|
|
6034
|
-
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);
|
|
6035
|
-
grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity));
|
|
6036
|
-
grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity));
|
|
6037
|
-
grad.addColorStop(gradientMax, getStyleFromHsl(color2, container.hdr, opacity));
|
|
6164
|
+
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);
|
|
6165
|
+
grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
6166
|
+
grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
6167
|
+
grad.addColorStop(gradientMax, getStyleFromHsl(color2, container.hdr, opacity, container.peakNits, container.hdrMode));
|
|
6038
6168
|
return grad;
|
|
6039
6169
|
}
|
|
6040
6170
|
function drawConnectLine(context, width, lineStyle, begin, end) {
|
|
@@ -6120,7 +6250,7 @@
|
|
|
6120
6250
|
}
|
|
6121
6251
|
|
|
6122
6252
|
async function loadExternalConnectInteraction(engine) {
|
|
6123
|
-
engine.checkVersion("4.
|
|
6253
|
+
engine.checkVersion("4.4.0");
|
|
6124
6254
|
await engine.pluginManager.register((e) => {
|
|
6125
6255
|
ensureInteractivityPluginLoaded(e);
|
|
6126
6256
|
e.pluginManager.addInteractor?.("externalConnect", container => {
|
|
@@ -6224,7 +6354,7 @@
|
|
|
6224
6354
|
}
|
|
6225
6355
|
|
|
6226
6356
|
async function loadExternalDestroyInteraction(engine) {
|
|
6227
|
-
engine.checkVersion("4.
|
|
6357
|
+
engine.checkVersion("4.4.0");
|
|
6228
6358
|
await engine.pluginManager.register((e) => {
|
|
6229
6359
|
ensureInteractivityPluginLoaded(e);
|
|
6230
6360
|
e.pluginManager.addInteractor?.("externalDestroy", async (container) => {
|
|
@@ -6264,16 +6394,16 @@
|
|
|
6264
6394
|
}
|
|
6265
6395
|
|
|
6266
6396
|
const defaultWidth = 0;
|
|
6267
|
-
function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {
|
|
6397
|
+
function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false, peakNits, mode) {
|
|
6268
6398
|
drawLine$1(context, begin, end);
|
|
6269
|
-
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
6399
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity, peakNits, mode);
|
|
6270
6400
|
context.lineWidth = width;
|
|
6271
6401
|
context.stroke();
|
|
6272
6402
|
}
|
|
6273
6403
|
function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
6274
6404
|
container.canvas.render.draw(ctx => {
|
|
6275
6405
|
const beginPos = particle.getPosition();
|
|
6276
|
-
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr);
|
|
6406
|
+
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr, container.peakNits, container.hdrMode);
|
|
6277
6407
|
});
|
|
6278
6408
|
}
|
|
6279
6409
|
|
|
@@ -6329,7 +6459,7 @@
|
|
|
6329
6459
|
const linksOptions = interactivity.modes.grab.links;
|
|
6330
6460
|
container.particles.grabLineColor = getLinkRandomColor(this.#pluginManager, optColor, linksOptions.blink, linksOptions.consent);
|
|
6331
6461
|
}
|
|
6332
|
-
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor);
|
|
6462
|
+
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor, container.hdr);
|
|
6333
6463
|
if (!colorLine) {
|
|
6334
6464
|
continue;
|
|
6335
6465
|
}
|
|
@@ -6348,7 +6478,7 @@
|
|
|
6348
6478
|
}
|
|
6349
6479
|
|
|
6350
6480
|
async function loadExternalGrabInteraction(engine) {
|
|
6351
|
-
engine.checkVersion("4.
|
|
6481
|
+
engine.checkVersion("4.4.0");
|
|
6352
6482
|
await engine.pluginManager.register((e) => {
|
|
6353
6483
|
ensureInteractivityPluginLoaded(e);
|
|
6354
6484
|
e.pluginManager.addInteractor?.("externalGrab", container => {
|
|
@@ -6418,7 +6548,7 @@
|
|
|
6418
6548
|
}
|
|
6419
6549
|
|
|
6420
6550
|
async function loadExternalParallaxInteraction(engine) {
|
|
6421
|
-
engine.checkVersion("4.
|
|
6551
|
+
engine.checkVersion("4.4.0");
|
|
6422
6552
|
await engine.pluginManager.register((e) => {
|
|
6423
6553
|
ensureInteractivityPluginLoaded(e);
|
|
6424
6554
|
e.pluginManager.addInteractor?.("externalParallax", container => {
|
|
@@ -6461,7 +6591,7 @@
|
|
|
6461
6591
|
}
|
|
6462
6592
|
|
|
6463
6593
|
async function loadExternalPauseInteraction(engine) {
|
|
6464
|
-
engine.checkVersion("4.
|
|
6594
|
+
engine.checkVersion("4.4.0");
|
|
6465
6595
|
await engine.pluginManager.register((e) => {
|
|
6466
6596
|
ensureInteractivityPluginLoaded(e);
|
|
6467
6597
|
e.pluginManager.addInteractor?.("externalPause", container => {
|
|
@@ -6533,7 +6663,7 @@
|
|
|
6533
6663
|
}
|
|
6534
6664
|
|
|
6535
6665
|
async function loadExternalPushInteraction(engine) {
|
|
6536
|
-
engine.checkVersion("4.
|
|
6666
|
+
engine.checkVersion("4.4.0");
|
|
6537
6667
|
await engine.pluginManager.register((e) => {
|
|
6538
6668
|
ensureInteractivityPluginLoaded(e);
|
|
6539
6669
|
e.pluginManager.addInteractor?.("externalPush", container => {
|
|
@@ -6587,7 +6717,7 @@
|
|
|
6587
6717
|
}
|
|
6588
6718
|
|
|
6589
6719
|
async function loadExternalRemoveInteraction(engine) {
|
|
6590
|
-
engine.checkVersion("4.
|
|
6720
|
+
engine.checkVersion("4.4.0");
|
|
6591
6721
|
await engine.pluginManager.register((e) => {
|
|
6592
6722
|
ensureInteractivityPluginLoaded(e);
|
|
6593
6723
|
e.pluginManager.addInteractor?.("externalRemove", container => {
|
|
@@ -6893,7 +7023,7 @@
|
|
|
6893
7023
|
}
|
|
6894
7024
|
|
|
6895
7025
|
async function loadExternalRepulseInteraction(engine) {
|
|
6896
|
-
engine.checkVersion("4.
|
|
7026
|
+
engine.checkVersion("4.4.0");
|
|
6897
7027
|
await engine.pluginManager.register((e) => {
|
|
6898
7028
|
ensureInteractivityPluginLoaded(e);
|
|
6899
7029
|
const pluginManager = e.pluginManager;
|
|
@@ -6987,7 +7117,7 @@
|
|
|
6987
7117
|
}
|
|
6988
7118
|
|
|
6989
7119
|
async function loadExternalSlowInteraction(engine) {
|
|
6990
|
-
engine.checkVersion("4.
|
|
7120
|
+
engine.checkVersion("4.4.0");
|
|
6991
7121
|
await engine.pluginManager.register((e) => {
|
|
6992
7122
|
ensureInteractivityPluginLoaded(e);
|
|
6993
7123
|
e.pluginManager.addInteractor?.("externalSlow", container => {
|
|
@@ -6999,12 +7129,12 @@
|
|
|
6999
7129
|
const shapeTypes = ["image", "images"];
|
|
7000
7130
|
const stringStart = 0, defaultOpacity = 1;
|
|
7001
7131
|
const currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;
|
|
7002
|
-
function replaceColorSvg(imageShape, color, opacity, hdr = false) {
|
|
7132
|
+
function replaceColorSvg(imageShape, color, opacity, hdr = false, peakNits, mode) {
|
|
7003
7133
|
const { svgData } = imageShape;
|
|
7004
7134
|
if (!svgData) {
|
|
7005
7135
|
return "";
|
|
7006
7136
|
}
|
|
7007
|
-
const colorStyle = getStyleFromHsl(color, hdr, opacity);
|
|
7137
|
+
const colorStyle = getStyleFromHsl(color, hdr, opacity, peakNits, mode);
|
|
7008
7138
|
if (svgData.includes("fill")) {
|
|
7009
7139
|
return svgData.replaceAll(currentColorRegex, () => colorStyle);
|
|
7010
7140
|
}
|
|
@@ -7046,8 +7176,8 @@
|
|
|
7046
7176
|
}
|
|
7047
7177
|
image.loading = false;
|
|
7048
7178
|
}
|
|
7049
|
-
function replaceImageColor(image, imageData, color, particle, hdr = false) {
|
|
7050
|
-
const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity, hdr), imageRes = {
|
|
7179
|
+
function replaceImageColor(image, imageData, color, particle, hdr = false, peakNits, mode) {
|
|
7180
|
+
const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity, hdr, peakNits, mode), imageRes = {
|
|
7051
7181
|
color,
|
|
7052
7182
|
data: {
|
|
7053
7183
|
...image,
|
|
@@ -7159,7 +7289,7 @@
|
|
|
7159
7289
|
void (async () => {
|
|
7160
7290
|
let imageRes;
|
|
7161
7291
|
if (image.svgData && color) {
|
|
7162
|
-
imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr);
|
|
7292
|
+
imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr, container.peakNits, container.hdrMode);
|
|
7163
7293
|
}
|
|
7164
7294
|
else {
|
|
7165
7295
|
imageRes = {
|
|
@@ -7296,7 +7426,7 @@
|
|
|
7296
7426
|
};
|
|
7297
7427
|
}
|
|
7298
7428
|
async function loadImageShape(engine) {
|
|
7299
|
-
engine.checkVersion("4.
|
|
7429
|
+
engine.checkVersion("4.4.0");
|
|
7300
7430
|
await engine.pluginManager.register(e => {
|
|
7301
7431
|
addLoadImageToEngine(e);
|
|
7302
7432
|
e.pluginManager.addPlugin(new ImagePreloaderPlugin(e));
|
|
@@ -7441,7 +7571,7 @@
|
|
|
7441
7571
|
}
|
|
7442
7572
|
|
|
7443
7573
|
async function loadLifeUpdater(engine) {
|
|
7444
|
-
engine.checkVersion("4.
|
|
7574
|
+
engine.checkVersion("4.4.0");
|
|
7445
7575
|
await engine.pluginManager.register(e => {
|
|
7446
7576
|
e.pluginManager.addParticleUpdater("life", container => {
|
|
7447
7577
|
return Promise.resolve(new LifeUpdater(container));
|
|
@@ -7467,7 +7597,7 @@
|
|
|
7467
7597
|
}
|
|
7468
7598
|
|
|
7469
7599
|
async function loadLineShape(engine) {
|
|
7470
|
-
engine.checkVersion("4.
|
|
7600
|
+
engine.checkVersion("4.4.0");
|
|
7471
7601
|
await engine.pluginManager.register(e => {
|
|
7472
7602
|
e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
|
|
7473
7603
|
});
|
|
@@ -7551,7 +7681,7 @@
|
|
|
7551
7681
|
}
|
|
7552
7682
|
|
|
7553
7683
|
async function loadParticlesAttractInteraction(engine) {
|
|
7554
|
-
engine.checkVersion("4.
|
|
7684
|
+
engine.checkVersion("4.4.0");
|
|
7555
7685
|
await engine.pluginManager.register((e) => {
|
|
7556
7686
|
ensureInteractivityPluginLoaded(e);
|
|
7557
7687
|
e.pluginManager.addInteractor?.("particlesAttract", container => {
|
|
@@ -7761,7 +7891,7 @@
|
|
|
7761
7891
|
}
|
|
7762
7892
|
|
|
7763
7893
|
async function loadParticlesCollisionsInteraction(engine) {
|
|
7764
|
-
engine.checkVersion("4.
|
|
7894
|
+
engine.checkVersion("4.4.0");
|
|
7765
7895
|
await engine.pluginManager.register((e) => {
|
|
7766
7896
|
ensureInteractivityPluginLoaded(e);
|
|
7767
7897
|
e.pluginManager.addPlugin(new OverlapPlugin());
|
|
@@ -7974,7 +8104,7 @@
|
|
|
7974
8104
|
const linkColor = linksOptions.id !== undefined
|
|
7975
8105
|
? container.particles.linksColors.get(linksOptions.id)
|
|
7976
8106
|
: container.particles.linksColor;
|
|
7977
|
-
return getLinkColor(p1, p2, linkColor);
|
|
8107
|
+
return getLinkColor(p1, p2, linkColor, container.hdr);
|
|
7978
8108
|
}
|
|
7979
8109
|
#setColor(p1) {
|
|
7980
8110
|
if (!p1.options.links) {
|
|
@@ -8015,7 +8145,7 @@
|
|
|
8015
8145
|
}
|
|
8016
8146
|
|
|
8017
8147
|
async function loadParticlesLinksInteraction(engine) {
|
|
8018
|
-
engine.checkVersion("4.
|
|
8148
|
+
engine.checkVersion("4.4.0");
|
|
8019
8149
|
await engine.pluginManager.register((e) => {
|
|
8020
8150
|
const pluginManager = e.pluginManager;
|
|
8021
8151
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -8105,19 +8235,19 @@
|
|
|
8105
8235
|
}
|
|
8106
8236
|
|
|
8107
8237
|
async function loadGenericPolygonShape(engine) {
|
|
8108
|
-
engine.checkVersion("4.
|
|
8238
|
+
engine.checkVersion("4.4.0");
|
|
8109
8239
|
await engine.pluginManager.register(e => {
|
|
8110
8240
|
e.pluginManager.addShape(["polygon"], () => Promise.resolve(new PolygonDrawer()));
|
|
8111
8241
|
});
|
|
8112
8242
|
}
|
|
8113
8243
|
async function loadTriangleShape(engine) {
|
|
8114
|
-
engine.checkVersion("4.
|
|
8244
|
+
engine.checkVersion("4.4.0");
|
|
8115
8245
|
await engine.pluginManager.register(e => {
|
|
8116
8246
|
e.pluginManager.addShape(["triangle"], () => Promise.resolve(new TriangleDrawer()));
|
|
8117
8247
|
});
|
|
8118
8248
|
}
|
|
8119
8249
|
async function loadPolygonShape(engine) {
|
|
8120
|
-
engine.checkVersion("4.
|
|
8250
|
+
engine.checkVersion("4.4.0");
|
|
8121
8251
|
await Promise.all([
|
|
8122
8252
|
loadGenericPolygonShape(engine),
|
|
8123
8253
|
loadTriangleShape(engine),
|
|
@@ -8222,7 +8352,7 @@
|
|
|
8222
8352
|
}
|
|
8223
8353
|
|
|
8224
8354
|
async function loadRotateUpdater(engine) {
|
|
8225
|
-
engine.checkVersion("4.
|
|
8355
|
+
engine.checkVersion("4.4.0");
|
|
8226
8356
|
await engine.pluginManager.register(e => {
|
|
8227
8357
|
e.pluginManager.addParticleUpdater("rotate", container => {
|
|
8228
8358
|
return Promise.resolve(new RotateUpdater(container));
|
|
@@ -8246,7 +8376,7 @@
|
|
|
8246
8376
|
}
|
|
8247
8377
|
|
|
8248
8378
|
async function loadSquareShape(engine) {
|
|
8249
|
-
engine.checkVersion("4.
|
|
8379
|
+
engine.checkVersion("4.4.0");
|
|
8250
8380
|
await engine.pluginManager.register(e => {
|
|
8251
8381
|
e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
|
|
8252
8382
|
});
|
|
@@ -8280,14 +8410,14 @@
|
|
|
8280
8410
|
}
|
|
8281
8411
|
|
|
8282
8412
|
async function loadStarShape(engine) {
|
|
8283
|
-
engine.checkVersion("4.
|
|
8413
|
+
engine.checkVersion("4.4.0");
|
|
8284
8414
|
await engine.pluginManager.register(e => {
|
|
8285
8415
|
e.pluginManager.addShape(["star"], () => Promise.resolve(new StarDrawer()));
|
|
8286
8416
|
});
|
|
8287
8417
|
}
|
|
8288
8418
|
|
|
8289
8419
|
async function loadSlim(engine) {
|
|
8290
|
-
engine.checkVersion("4.
|
|
8420
|
+
engine.checkVersion("4.4.0");
|
|
8291
8421
|
await engine.pluginManager.register(async (e) => {
|
|
8292
8422
|
const loadInteractivityForSlim = async (e) => {
|
|
8293
8423
|
await loadInteractivityPlugin(e);
|
|
@@ -8404,7 +8534,7 @@
|
|
|
8404
8534
|
}
|
|
8405
8535
|
|
|
8406
8536
|
async function loadTextShape(engine) {
|
|
8407
|
-
engine.checkVersion("4.
|
|
8537
|
+
engine.checkVersion("4.4.0");
|
|
8408
8538
|
await engine.pluginManager.register(e => {
|
|
8409
8539
|
e.pluginManager.addShape(validTypes, () => Promise.resolve(new TextDrawer()));
|
|
8410
8540
|
});
|
|
@@ -8513,7 +8643,7 @@
|
|
|
8513
8643
|
}
|
|
8514
8644
|
|
|
8515
8645
|
async function loadTiltUpdater(engine) {
|
|
8516
|
-
engine.checkVersion("4.
|
|
8646
|
+
engine.checkVersion("4.4.0");
|
|
8517
8647
|
await engine.pluginManager.register(e => {
|
|
8518
8648
|
e.pluginManager.addParticleUpdater("tilt", container => {
|
|
8519
8649
|
return Promise.resolve(new TiltUpdater(container));
|
|
@@ -8589,12 +8719,12 @@
|
|
|
8589
8719
|
if (!twinkleFillRgb) {
|
|
8590
8720
|
return undefined;
|
|
8591
8721
|
}
|
|
8592
|
-
return getStyleFromHsl(twinkleFillRgb, container.hdr, twinklingOpacity);
|
|
8722
|
+
return getStyleFromHsl(twinkleFillRgb, container.hdr, twinklingOpacity, container.peakNits, container.hdrMode);
|
|
8593
8723
|
}, getTwinkleStrokeStyle = () => {
|
|
8594
8724
|
if (!twinkleStrokeRgb) {
|
|
8595
8725
|
return undefined;
|
|
8596
8726
|
}
|
|
8597
|
-
return getStyleFromHsl(twinkleStrokeRgb, container.hdr, twinklingOpacity);
|
|
8727
|
+
return getStyleFromHsl(twinkleStrokeRgb, container.hdr, twinklingOpacity, container.peakNits, container.hdrMode);
|
|
8598
8728
|
}, twinkleFillStyle = getTwinkleFillStyle(), twinkleStrokeStyle = getTwinkleStrokeStyle(), res = {}, needsTwinkle = twinkling && (!!twinkleFillStyle || !!twinkleStrokeStyle);
|
|
8599
8729
|
res.fill = needsTwinkle ? twinkleFillStyle : undefined;
|
|
8600
8730
|
res.stroke = needsTwinkle ? twinkleStrokeStyle : undefined;
|
|
@@ -8617,7 +8747,7 @@
|
|
|
8617
8747
|
}
|
|
8618
8748
|
|
|
8619
8749
|
async function loadTwinkleUpdater(engine) {
|
|
8620
|
-
engine.checkVersion("4.
|
|
8750
|
+
engine.checkVersion("4.4.0");
|
|
8621
8751
|
await engine.pluginManager.register(e => {
|
|
8622
8752
|
e.pluginManager.addParticleUpdater("twinkle", container => {
|
|
8623
8753
|
return Promise.resolve(new TwinkleUpdater(e.pluginManager, container));
|
|
@@ -8719,7 +8849,7 @@
|
|
|
8719
8849
|
}
|
|
8720
8850
|
|
|
8721
8851
|
async function loadWobbleUpdater(engine) {
|
|
8722
|
-
engine.checkVersion("4.
|
|
8852
|
+
engine.checkVersion("4.4.0");
|
|
8723
8853
|
await engine.pluginManager.register(e => {
|
|
8724
8854
|
e.pluginManager.addParticleUpdater("wobble", container => {
|
|
8725
8855
|
return Promise.resolve(new WobbleUpdater(container));
|
|
@@ -8728,7 +8858,7 @@
|
|
|
8728
8858
|
}
|
|
8729
8859
|
|
|
8730
8860
|
async function loadFull(engine) {
|
|
8731
|
-
engine.checkVersion("4.
|
|
8861
|
+
engine.checkVersion("4.4.0");
|
|
8732
8862
|
await engine.pluginManager.register(async (e) => {
|
|
8733
8863
|
const loadEmittersPluginBundle = async (e) => {
|
|
8734
8864
|
await loadEmittersPlugin(e);
|
|
@@ -8879,7 +9009,11 @@
|
|
|
8879
9009
|
if (!fColor && !sColor) {
|
|
8880
9010
|
return;
|
|
8881
9011
|
}
|
|
8882
|
-
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
|
|
9012
|
+
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
|
|
9013
|
+
? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity, container.peakNits, container.hdrMode)
|
|
9014
|
+
: undefined, stroke = sColor
|
|
9015
|
+
? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity, container.peakNits, container.hdrMode)
|
|
9016
|
+
: fill;
|
|
8883
9017
|
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
8884
9018
|
colorStyles.fill = fill;
|
|
8885
9019
|
colorStyles.stroke = stroke;
|
|
@@ -9213,7 +9347,9 @@
|
|
|
9213
9347
|
if (typeof background.element === "string") {
|
|
9214
9348
|
if (typeof document !== "undefined") {
|
|
9215
9349
|
const node = document.querySelector(background.element);
|
|
9216
|
-
if (
|
|
9350
|
+
if ((typeof HTMLCanvasElement !== "undefined" && node instanceof HTMLCanvasElement) ||
|
|
9351
|
+
(typeof HTMLVideoElement !== "undefined" && node instanceof HTMLVideoElement) ||
|
|
9352
|
+
(typeof HTMLImageElement !== "undefined" && node instanceof HTMLImageElement)) {
|
|
9217
9353
|
this.#backgroundElement = node;
|
|
9218
9354
|
}
|
|
9219
9355
|
else if (node) {
|
|
@@ -9224,10 +9360,10 @@
|
|
|
9224
9360
|
}
|
|
9225
9361
|
}
|
|
9226
9362
|
}
|
|
9227
|
-
else if (background.element instanceof HTMLCanvasElement ||
|
|
9228
|
-
background.element instanceof OffscreenCanvas ||
|
|
9229
|
-
background.element instanceof HTMLVideoElement ||
|
|
9230
|
-
background.element instanceof HTMLImageElement) {
|
|
9363
|
+
else if ((typeof HTMLCanvasElement !== "undefined" && background.element instanceof HTMLCanvasElement) ||
|
|
9364
|
+
(typeof OffscreenCanvas !== "undefined" && background.element instanceof OffscreenCanvas) ||
|
|
9365
|
+
(typeof HTMLVideoElement !== "undefined" && background.element instanceof HTMLVideoElement) ||
|
|
9366
|
+
(typeof HTMLImageElement !== "undefined" && background.element instanceof HTMLImageElement)) {
|
|
9231
9367
|
this.#backgroundElement = background.element;
|
|
9232
9368
|
}
|
|
9233
9369
|
}
|
|
@@ -9295,6 +9431,7 @@
|
|
|
9295
9431
|
zoom = defaultZoom;
|
|
9296
9432
|
#container;
|
|
9297
9433
|
#generated;
|
|
9434
|
+
#hdrMediaListeners;
|
|
9298
9435
|
#mutationObserver;
|
|
9299
9436
|
#originalStyle;
|
|
9300
9437
|
#pluginManager;
|
|
@@ -9359,7 +9496,6 @@
|
|
|
9359
9496
|
});
|
|
9360
9497
|
this.resize();
|
|
9361
9498
|
this.#initStyle();
|
|
9362
|
-
this.initBackground();
|
|
9363
9499
|
this.#safeMutationObserver(obs => {
|
|
9364
9500
|
const element = this.domElement;
|
|
9365
9501
|
if (!element || !(element instanceof Node)) {
|
|
@@ -9369,6 +9505,8 @@
|
|
|
9369
9505
|
});
|
|
9370
9506
|
this.initPlugins();
|
|
9371
9507
|
this.#initContext();
|
|
9508
|
+
this.initBackground();
|
|
9509
|
+
this.#initHdrListeners();
|
|
9372
9510
|
this.render.init();
|
|
9373
9511
|
}
|
|
9374
9512
|
initBackground() {
|
|
@@ -9378,7 +9516,8 @@
|
|
|
9378
9516
|
}
|
|
9379
9517
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
9380
9518
|
if (color) {
|
|
9381
|
-
|
|
9519
|
+
const hdrOptions = container.actualOptions.hdr;
|
|
9520
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity, hdrOptions.peakNits, hdrOptions.mode);
|
|
9382
9521
|
}
|
|
9383
9522
|
else {
|
|
9384
9523
|
elementStyle.backgroundColor = "";
|
|
@@ -9475,6 +9614,7 @@
|
|
|
9475
9614
|
obs.disconnect();
|
|
9476
9615
|
});
|
|
9477
9616
|
this.#mutationObserver = undefined;
|
|
9617
|
+
this.#removeHdrListeners();
|
|
9478
9618
|
this.render.stop();
|
|
9479
9619
|
}
|
|
9480
9620
|
async windowResize() {
|
|
@@ -9494,9 +9634,16 @@
|
|
|
9494
9634
|
}
|
|
9495
9635
|
}
|
|
9496
9636
|
#initContext() {
|
|
9497
|
-
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
9637
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr.enable &&
|
|
9498
9638
|
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
9499
9639
|
safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
9640
|
+
container.hdr = canSupportHdr ?? false;
|
|
9641
|
+
container.hdrMode = container.actualOptions.hdr.mode;
|
|
9642
|
+
container.peakNits = container.actualOptions.hdr.peakNits;
|
|
9643
|
+
const renderCanvas = this.renderCanvas;
|
|
9644
|
+
if (!renderCanvas) {
|
|
9645
|
+
return;
|
|
9646
|
+
}
|
|
9500
9647
|
this.render.setContextSettings({
|
|
9501
9648
|
alpha: true,
|
|
9502
9649
|
desynchronized: true,
|
|
@@ -9505,11 +9652,47 @@
|
|
|
9505
9652
|
? { colorSpace: "display-p3", colorType: "float16" }
|
|
9506
9653
|
: { colorSpace: "srgb" }),
|
|
9507
9654
|
});
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9655
|
+
let context;
|
|
9656
|
+
try {
|
|
9657
|
+
context = renderCanvas.getContext("2d", this.render.settings);
|
|
9511
9658
|
}
|
|
9512
|
-
|
|
9659
|
+
catch {
|
|
9660
|
+
context = null;
|
|
9661
|
+
}
|
|
9662
|
+
if (canSupportHdr && !context) {
|
|
9663
|
+
container.hdr = false;
|
|
9664
|
+
const sdrSettings = {
|
|
9665
|
+
alpha: true,
|
|
9666
|
+
desynchronized: true,
|
|
9667
|
+
willReadFrequently: false,
|
|
9668
|
+
colorSpace: "srgb",
|
|
9669
|
+
};
|
|
9670
|
+
this.render.setContextSettings(sdrSettings);
|
|
9671
|
+
try {
|
|
9672
|
+
context = renderCanvas.getContext("2d", sdrSettings);
|
|
9673
|
+
}
|
|
9674
|
+
catch {
|
|
9675
|
+
context = null;
|
|
9676
|
+
}
|
|
9677
|
+
}
|
|
9678
|
+
this.render.setContext(context);
|
|
9679
|
+
}
|
|
9680
|
+
#initHdrListeners() {
|
|
9681
|
+
this.#removeHdrListeners();
|
|
9682
|
+
const p3Query = safeMatchMedia("(color-gamut: p3)"), hdrQuery = safeMatchMedia("(dynamic-range: high)"), handleChange = () => {
|
|
9683
|
+
this.#recreateRenderCanvas();
|
|
9684
|
+
this.#initContext();
|
|
9685
|
+
this.initBackground();
|
|
9686
|
+
}, listeners = [];
|
|
9687
|
+
if (p3Query) {
|
|
9688
|
+
p3Query.addEventListener("change", handleChange);
|
|
9689
|
+
listeners.push({ handler: handleChange, mql: p3Query });
|
|
9690
|
+
}
|
|
9691
|
+
if (hdrQuery) {
|
|
9692
|
+
hdrQuery.addEventListener("change", handleChange);
|
|
9693
|
+
listeners.push({ handler: handleChange, mql: hdrQuery });
|
|
9694
|
+
}
|
|
9695
|
+
this.#hdrMediaListeners = listeners;
|
|
9513
9696
|
}
|
|
9514
9697
|
#initStyle() {
|
|
9515
9698
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
@@ -9533,6 +9716,25 @@
|
|
|
9533
9716
|
element.style.setProperty(key, value, "important");
|
|
9534
9717
|
}
|
|
9535
9718
|
}
|
|
9719
|
+
#recreateRenderCanvas() {
|
|
9720
|
+
const renderCanvas = this.renderCanvas;
|
|
9721
|
+
if (!renderCanvas) {
|
|
9722
|
+
return;
|
|
9723
|
+
}
|
|
9724
|
+
if (this.domElement) {
|
|
9725
|
+
return;
|
|
9726
|
+
}
|
|
9727
|
+
this.renderCanvas = new OffscreenCanvas(renderCanvas.width, renderCanvas.height);
|
|
9728
|
+
}
|
|
9729
|
+
#removeHdrListeners() {
|
|
9730
|
+
if (!this.#hdrMediaListeners) {
|
|
9731
|
+
return;
|
|
9732
|
+
}
|
|
9733
|
+
for (const { handler, mql } of this.#hdrMediaListeners) {
|
|
9734
|
+
mql.removeEventListener("change", handler);
|
|
9735
|
+
}
|
|
9736
|
+
this.#hdrMediaListeners = undefined;
|
|
9737
|
+
}
|
|
9536
9738
|
#repairStyle() {
|
|
9537
9739
|
const element = this.domElement;
|
|
9538
9740
|
if (!element) {
|
|
@@ -9917,9 +10119,9 @@
|
|
|
9917
10119
|
}
|
|
9918
10120
|
getOpacity() {
|
|
9919
10121
|
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;
|
|
9920
|
-
this.#cachedOpacityData.fillOpacity =
|
|
10122
|
+
this.#cachedOpacityData.fillOpacity = fillOpacity;
|
|
9921
10123
|
this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
9922
|
-
this.#cachedOpacityData.strokeOpacity =
|
|
10124
|
+
this.#cachedOpacityData.strokeOpacity = strokeOpacity;
|
|
9923
10125
|
return this.#cachedOpacityData;
|
|
9924
10126
|
}
|
|
9925
10127
|
getPosition() {
|
|
@@ -10774,6 +10976,7 @@
|
|
|
10774
10976
|
effectDrawers;
|
|
10775
10977
|
fpsLimit;
|
|
10776
10978
|
hdr;
|
|
10979
|
+
hdrMode;
|
|
10777
10980
|
id;
|
|
10778
10981
|
pageHidden;
|
|
10779
10982
|
particleCreatedPlugins;
|
|
@@ -10781,6 +10984,7 @@
|
|
|
10781
10984
|
particlePositionPlugins;
|
|
10782
10985
|
particleUpdaters;
|
|
10783
10986
|
particles;
|
|
10987
|
+
peakNits;
|
|
10784
10988
|
plugins;
|
|
10785
10989
|
retina;
|
|
10786
10990
|
shapeDrawers;
|
|
@@ -10811,6 +11015,8 @@
|
|
|
10811
11015
|
this.id = Symbol(id);
|
|
10812
11016
|
this.fpsLimit = 120;
|
|
10813
11017
|
this.hdr = false;
|
|
11018
|
+
this.hdrMode = exports.HdrMode.standard;
|
|
11019
|
+
this.peakNits = 400;
|
|
10814
11020
|
this.#smooth = false;
|
|
10815
11021
|
this.#delay = 0;
|
|
10816
11022
|
this.#duration = 0;
|
|
@@ -10950,8 +11156,9 @@
|
|
|
10950
11156
|
this.updateActualOptions();
|
|
10951
11157
|
this.canvas.initBackground();
|
|
10952
11158
|
this.canvas.resize();
|
|
10953
|
-
const { delay, duration, fpsLimit,
|
|
10954
|
-
this.
|
|
11159
|
+
const { delay, duration, fpsLimit, smooth, zLayers } = this.actualOptions, hdrOptions = this.actualOptions.hdr;
|
|
11160
|
+
this.hdrMode = hdrOptions.mode;
|
|
11161
|
+
this.peakNits = hdrOptions.peakNits;
|
|
10955
11162
|
this.zLayers = zLayers;
|
|
10956
11163
|
this.#duration = getRangeValue(duration) * millisecondsToSeconds;
|
|
10957
11164
|
this.#delay = getRangeValue(delay) * millisecondsToSeconds;
|
|
@@ -12370,10 +12577,10 @@
|
|
|
12370
12577
|
}
|
|
12371
12578
|
}
|
|
12372
12579
|
#getCachedStyle(rgb) {
|
|
12373
|
-
const key = `${rgb.r},${rgb.g},${rgb.b}`;
|
|
12580
|
+
const key = `${rgb.r},${rgb.g},${rgb.b}-${this.#container.hdr}-${this.#container.peakNits}-${this.#container.hdrMode}`;
|
|
12374
12581
|
let style = this.#colorCache.get(key);
|
|
12375
12582
|
if (!style) {
|
|
12376
|
-
style = getStyleFromRgb(rgb, this.#container.hdr);
|
|
12583
|
+
style = getStyleFromRgb(rgb, this.#container.hdr, undefined, this.#container.peakNits, this.#container.hdrMode);
|
|
12377
12584
|
this.#colorCache.set(key, style);
|
|
12378
12585
|
}
|
|
12379
12586
|
return style;
|
|
@@ -12484,7 +12691,7 @@
|
|
|
12484
12691
|
context.beginPath();
|
|
12485
12692
|
context.arc(originPoint.x, originPoint.y, this.size, minAngle, maxAngle, false);
|
|
12486
12693
|
context.closePath();
|
|
12487
|
-
context.fillStyle = getStyleFromRgb(this.color, this.#container.hdr, this.opacity);
|
|
12694
|
+
context.fillStyle = getStyleFromRgb(this.color, this.#container.hdr, this.opacity, this.#container.peakNits, this.#container.hdrMode);
|
|
12488
12695
|
context.fill();
|
|
12489
12696
|
}
|
|
12490
12697
|
resize() {
|
|
@@ -12964,6 +13171,7 @@
|
|
|
12964
13171
|
exports.ColorAnimation = ColorAnimation;
|
|
12965
13172
|
exports.Fill = Fill;
|
|
12966
13173
|
exports.FullScreen = FullScreen;
|
|
13174
|
+
exports.HDROptions = HDROptions;
|
|
12967
13175
|
exports.HslAnimation = HslAnimation;
|
|
12968
13176
|
exports.Move = Move;
|
|
12969
13177
|
exports.MoveAngle = MoveAngle;
|