@tsparticles/pjs 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 +4 -4
- package/report.html +1 -1
- package/tsparticles.pjs.bundle.js +328 -120
- 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) :
|
|
@@ -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 {
|
|
@@ -2800,7 +2930,7 @@
|
|
|
2800
2930
|
}
|
|
2801
2931
|
|
|
2802
2932
|
async function loadInteractivityPlugin(engine) {
|
|
2803
|
-
engine.checkVersion("4.
|
|
2933
|
+
engine.checkVersion("4.4.0");
|
|
2804
2934
|
await engine.pluginManager.register(e => {
|
|
2805
2935
|
const interactivityEngine = e, interactivityPluginManager = interactivityEngine.pluginManager;
|
|
2806
2936
|
interactivityPluginManager.addPlugin(new InteractivityPlugin(interactivityPluginManager));
|
|
@@ -3040,7 +3170,7 @@
|
|
|
3040
3170
|
}
|
|
3041
3171
|
|
|
3042
3172
|
async function loadAbsorbersInteraction(engine) {
|
|
3043
|
-
engine.checkVersion("4.
|
|
3173
|
+
engine.checkVersion("4.4.0");
|
|
3044
3174
|
await engine.pluginManager.register(async (e) => {
|
|
3045
3175
|
const pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);
|
|
3046
3176
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -3088,7 +3218,7 @@
|
|
|
3088
3218
|
}
|
|
3089
3219
|
|
|
3090
3220
|
async function loadAbsorbersPluginSimple(engine) {
|
|
3091
|
-
engine.checkVersion("4.
|
|
3221
|
+
engine.checkVersion("4.4.0");
|
|
3092
3222
|
await engine.pluginManager.register(async (e) => {
|
|
3093
3223
|
const pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);
|
|
3094
3224
|
pluginManager.addPlugin(new AbsorbersPlugin(instancesManager));
|
|
@@ -3414,7 +3544,7 @@
|
|
|
3414
3544
|
}
|
|
3415
3545
|
|
|
3416
3546
|
async function loadDestroyUpdater(engine) {
|
|
3417
|
-
engine.checkVersion("4.
|
|
3547
|
+
engine.checkVersion("4.4.0");
|
|
3418
3548
|
await engine.pluginManager.register(e => {
|
|
3419
3549
|
e.pluginManager.addParticleUpdater("destroy", container => {
|
|
3420
3550
|
return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
|
|
@@ -3732,7 +3862,7 @@
|
|
|
3732
3862
|
})(EmitterClickMode || (EmitterClickMode = {}));
|
|
3733
3863
|
|
|
3734
3864
|
async function loadEmittersInteraction(engine) {
|
|
3735
|
-
engine.checkVersion("4.
|
|
3865
|
+
engine.checkVersion("4.4.0");
|
|
3736
3866
|
await engine.pluginManager.register(async (e) => {
|
|
3737
3867
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
3738
3868
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -3775,7 +3905,7 @@
|
|
|
3775
3905
|
}
|
|
3776
3906
|
|
|
3777
3907
|
async function loadEmittersPluginSimple(engine) {
|
|
3778
|
-
engine.checkVersion("4.
|
|
3908
|
+
engine.checkVersion("4.4.0");
|
|
3779
3909
|
await engine.pluginManager.register(async (e) => {
|
|
3780
3910
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
3781
3911
|
await addEmittersShapesManager(e);
|
|
@@ -3832,7 +3962,7 @@
|
|
|
3832
3962
|
}
|
|
3833
3963
|
|
|
3834
3964
|
async function loadEmittersShapeCircle(engine) {
|
|
3835
|
-
engine.checkVersion("4.
|
|
3965
|
+
engine.checkVersion("4.4.0");
|
|
3836
3966
|
await engine.pluginManager.register((e) => {
|
|
3837
3967
|
ensureEmittersPluginLoaded(e);
|
|
3838
3968
|
e.pluginManager.addEmitterShapeGenerator?.("circle", new EmittersCircleShapeGenerator());
|
|
@@ -3913,7 +4043,7 @@
|
|
|
3913
4043
|
}
|
|
3914
4044
|
|
|
3915
4045
|
async function loadEmittersShapeSquare(engine) {
|
|
3916
|
-
engine.checkVersion("4.
|
|
4046
|
+
engine.checkVersion("4.4.0");
|
|
3917
4047
|
await engine.pluginManager.register((e) => {
|
|
3918
4048
|
ensureEmittersPluginLoaded(e);
|
|
3919
4049
|
e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
|
|
@@ -4095,7 +4225,7 @@
|
|
|
4095
4225
|
}
|
|
4096
4226
|
|
|
4097
4227
|
async function loadExternalDragInteraction(engine) {
|
|
4098
|
-
engine.checkVersion("4.
|
|
4228
|
+
engine.checkVersion("4.4.0");
|
|
4099
4229
|
await engine.pluginManager.register((e) => {
|
|
4100
4230
|
ensureInteractivityPluginLoaded(e);
|
|
4101
4231
|
e.pluginManager.addInteractor?.("externalDrag", container => {
|
|
@@ -4268,7 +4398,7 @@
|
|
|
4268
4398
|
}
|
|
4269
4399
|
|
|
4270
4400
|
async function loadExternalTrailInteraction(engine) {
|
|
4271
|
-
engine.checkVersion("4.
|
|
4401
|
+
engine.checkVersion("4.4.0");
|
|
4272
4402
|
await engine.pluginManager.register((e) => {
|
|
4273
4403
|
ensureInteractivityPluginLoaded(e);
|
|
4274
4404
|
e.pluginManager.addInteractor?.("externalTrail", container => {
|
|
@@ -4404,7 +4534,7 @@
|
|
|
4404
4534
|
}
|
|
4405
4535
|
|
|
4406
4536
|
async function loadRollUpdater(engine) {
|
|
4407
|
-
engine.checkVersion("4.
|
|
4537
|
+
engine.checkVersion("4.4.0");
|
|
4408
4538
|
await engine.pluginManager.register(e => {
|
|
4409
4539
|
e.pluginManager.addParticleUpdater("roll", () => {
|
|
4410
4540
|
return Promise.resolve(new RollUpdater(e.pluginManager));
|
|
@@ -4450,7 +4580,7 @@
|
|
|
4450
4580
|
}
|
|
4451
4581
|
|
|
4452
4582
|
async function loadBlendPlugin(engine) {
|
|
4453
|
-
engine.checkVersion("4.
|
|
4583
|
+
engine.checkVersion("4.4.0");
|
|
4454
4584
|
await engine.pluginManager.register(e => {
|
|
4455
4585
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
4456
4586
|
});
|
|
@@ -4487,7 +4617,7 @@
|
|
|
4487
4617
|
}
|
|
4488
4618
|
|
|
4489
4619
|
async function loadCircleShape(engine) {
|
|
4490
|
-
engine.checkVersion("4.
|
|
4620
|
+
engine.checkVersion("4.4.0");
|
|
4491
4621
|
await engine.pluginManager.register(e => {
|
|
4492
4622
|
e.pluginManager.addShape(["circle"], () => {
|
|
4493
4623
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -4535,7 +4665,7 @@
|
|
|
4535
4665
|
}
|
|
4536
4666
|
|
|
4537
4667
|
async function loadHexColorPlugin(engine) {
|
|
4538
|
-
engine.checkVersion("4.
|
|
4668
|
+
engine.checkVersion("4.4.0");
|
|
4539
4669
|
await engine.pluginManager.register(e => {
|
|
4540
4670
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
4541
4671
|
});
|
|
@@ -4588,7 +4718,7 @@
|
|
|
4588
4718
|
}
|
|
4589
4719
|
|
|
4590
4720
|
async function loadHslColorPlugin(engine) {
|
|
4591
|
-
engine.checkVersion("4.
|
|
4721
|
+
engine.checkVersion("4.4.0");
|
|
4592
4722
|
await engine.pluginManager.register(e => {
|
|
4593
4723
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
4594
4724
|
});
|
|
@@ -4612,7 +4742,7 @@
|
|
|
4612
4742
|
}
|
|
4613
4743
|
|
|
4614
4744
|
async function loadMovePlugin(engine) {
|
|
4615
|
-
engine.checkVersion("4.
|
|
4745
|
+
engine.checkVersion("4.4.0");
|
|
4616
4746
|
await engine.pluginManager.register(e => {
|
|
4617
4747
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
4618
4748
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -4828,7 +4958,7 @@
|
|
|
4828
4958
|
}
|
|
4829
4959
|
|
|
4830
4960
|
async function loadOpacityUpdater(engine) {
|
|
4831
|
-
engine.checkVersion("4.
|
|
4961
|
+
engine.checkVersion("4.4.0");
|
|
4832
4962
|
await engine.pluginManager.register(e => {
|
|
4833
4963
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
4834
4964
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -5173,7 +5303,7 @@
|
|
|
5173
5303
|
}
|
|
5174
5304
|
|
|
5175
5305
|
async function loadOutModesUpdater(engine) {
|
|
5176
|
-
engine.checkVersion("4.
|
|
5306
|
+
engine.checkVersion("4.4.0");
|
|
5177
5307
|
await engine.pluginManager.register(e => {
|
|
5178
5308
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
5179
5309
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -5244,7 +5374,7 @@
|
|
|
5244
5374
|
}
|
|
5245
5375
|
|
|
5246
5376
|
async function loadPaintUpdater(engine) {
|
|
5247
|
-
engine.checkVersion("4.
|
|
5377
|
+
engine.checkVersion("4.4.0");
|
|
5248
5378
|
await engine.pluginManager.register(e => {
|
|
5249
5379
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
5250
5380
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -5299,7 +5429,7 @@
|
|
|
5299
5429
|
}
|
|
5300
5430
|
|
|
5301
5431
|
async function loadRgbColorPlugin(engine) {
|
|
5302
|
-
engine.checkVersion("4.
|
|
5432
|
+
engine.checkVersion("4.4.0");
|
|
5303
5433
|
await engine.pluginManager.register(e => {
|
|
5304
5434
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
5305
5435
|
});
|
|
@@ -5384,7 +5514,7 @@
|
|
|
5384
5514
|
}
|
|
5385
5515
|
|
|
5386
5516
|
async function loadSizeUpdater(engine) {
|
|
5387
|
-
engine.checkVersion("4.
|
|
5517
|
+
engine.checkVersion("4.4.0");
|
|
5388
5518
|
await engine.pluginManager.register(e => {
|
|
5389
5519
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
5390
5520
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -5393,7 +5523,7 @@
|
|
|
5393
5523
|
}
|
|
5394
5524
|
|
|
5395
5525
|
async function loadBasic(engine) {
|
|
5396
|
-
engine.checkVersion("4.
|
|
5526
|
+
engine.checkVersion("4.4.0");
|
|
5397
5527
|
await engine.pluginManager.register(async (e) => {
|
|
5398
5528
|
await Promise.all([
|
|
5399
5529
|
loadBlendPlugin(e),
|
|
@@ -5416,7 +5546,7 @@
|
|
|
5416
5546
|
easingsFunctions.set("ease-in-out-quad", value => (value < 0.5 ? 2 * value ** 2 : 1 - (-2 * value + 2) ** 2 / 2));
|
|
5417
5547
|
|
|
5418
5548
|
async function loadEasingQuadPlugin(engine) {
|
|
5419
|
-
engine.checkVersion("4.
|
|
5549
|
+
engine.checkVersion("4.4.0");
|
|
5420
5550
|
await engine.pluginManager.register(e => {
|
|
5421
5551
|
for (const [easing, easingFn] of easingsFunctions) {
|
|
5422
5552
|
e.pluginManager.addEasing(easing, easingFn);
|
|
@@ -5524,7 +5654,7 @@
|
|
|
5524
5654
|
}
|
|
5525
5655
|
|
|
5526
5656
|
async function loadEmojiShape(engine) {
|
|
5527
|
-
engine.checkVersion("4.
|
|
5657
|
+
engine.checkVersion("4.4.0");
|
|
5528
5658
|
await engine.pluginManager.register(e => {
|
|
5529
5659
|
e.pluginManager.addShape(validTypes$1, () => Promise.resolve(new EmojiDrawer()));
|
|
5530
5660
|
});
|
|
@@ -5757,7 +5887,7 @@
|
|
|
5757
5887
|
};
|
|
5758
5888
|
|
|
5759
5889
|
async function loadExternalAttractInteraction(engine) {
|
|
5760
|
-
engine.checkVersion("4.
|
|
5890
|
+
engine.checkVersion("4.4.0");
|
|
5761
5891
|
await engine.pluginManager.register((e) => {
|
|
5762
5892
|
ensureInteractivityPluginLoaded(e);
|
|
5763
5893
|
e.pluginManager.addInteractor?.("externalAttract", container => {
|
|
@@ -5946,7 +6076,7 @@
|
|
|
5946
6076
|
}
|
|
5947
6077
|
|
|
5948
6078
|
async function loadExternalBounceInteraction(engine) {
|
|
5949
|
-
engine.checkVersion("4.
|
|
6079
|
+
engine.checkVersion("4.4.0");
|
|
5950
6080
|
await engine.pluginManager.register((e) => {
|
|
5951
6081
|
ensureInteractivityPluginLoaded(e);
|
|
5952
6082
|
e.pluginManager.addInteractor?.("externalBounce", container => {
|
|
@@ -6233,7 +6363,7 @@
|
|
|
6233
6363
|
mod.strokeColor = undefined;
|
|
6234
6364
|
const pColor = particle.getFillColor();
|
|
6235
6365
|
if (pColor) {
|
|
6236
|
-
const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio));
|
|
6366
|
+
const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio, this.container.hdr));
|
|
6237
6367
|
mod.fillColor = mixedColor;
|
|
6238
6368
|
mod.strokeColor = mixedColor;
|
|
6239
6369
|
}
|
|
@@ -6346,7 +6476,7 @@
|
|
|
6346
6476
|
}
|
|
6347
6477
|
|
|
6348
6478
|
async function loadExternalBubbleInteraction(engine) {
|
|
6349
|
-
engine.checkVersion("4.
|
|
6479
|
+
engine.checkVersion("4.4.0");
|
|
6350
6480
|
await engine.pluginManager.register((e) => {
|
|
6351
6481
|
ensureInteractivityPluginLoaded(e);
|
|
6352
6482
|
e.pluginManager.addInteractor?.("externalBubble", container => {
|
|
@@ -6385,10 +6515,10 @@
|
|
|
6385
6515
|
if (!color1 || !color2) {
|
|
6386
6516
|
return;
|
|
6387
6517
|
}
|
|
6388
|
-
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);
|
|
6389
|
-
grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity));
|
|
6390
|
-
grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity));
|
|
6391
|
-
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));
|
|
6392
6522
|
return grad;
|
|
6393
6523
|
}
|
|
6394
6524
|
function drawConnectLine(context, width, lineStyle, begin, end) {
|
|
@@ -6474,7 +6604,7 @@
|
|
|
6474
6604
|
}
|
|
6475
6605
|
|
|
6476
6606
|
async function loadExternalConnectInteraction(engine) {
|
|
6477
|
-
engine.checkVersion("4.
|
|
6607
|
+
engine.checkVersion("4.4.0");
|
|
6478
6608
|
await engine.pluginManager.register((e) => {
|
|
6479
6609
|
ensureInteractivityPluginLoaded(e);
|
|
6480
6610
|
e.pluginManager.addInteractor?.("externalConnect", container => {
|
|
@@ -6578,7 +6708,7 @@
|
|
|
6578
6708
|
}
|
|
6579
6709
|
|
|
6580
6710
|
async function loadExternalDestroyInteraction(engine) {
|
|
6581
|
-
engine.checkVersion("4.
|
|
6711
|
+
engine.checkVersion("4.4.0");
|
|
6582
6712
|
await engine.pluginManager.register((e) => {
|
|
6583
6713
|
ensureInteractivityPluginLoaded(e);
|
|
6584
6714
|
e.pluginManager.addInteractor?.("externalDestroy", async (container) => {
|
|
@@ -6618,16 +6748,16 @@
|
|
|
6618
6748
|
}
|
|
6619
6749
|
|
|
6620
6750
|
const defaultWidth = 0;
|
|
6621
|
-
function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {
|
|
6751
|
+
function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false, peakNits, mode) {
|
|
6622
6752
|
drawLine$1(context, begin, end);
|
|
6623
|
-
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
|
|
6753
|
+
context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity, peakNits, mode);
|
|
6624
6754
|
context.lineWidth = width;
|
|
6625
6755
|
context.stroke();
|
|
6626
6756
|
}
|
|
6627
6757
|
function drawGrab(container, particle, lineColor, opacity, mousePos) {
|
|
6628
6758
|
container.canvas.render.draw(ctx => {
|
|
6629
6759
|
const beginPos = particle.getPosition();
|
|
6630
|
-
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);
|
|
6631
6761
|
});
|
|
6632
6762
|
}
|
|
6633
6763
|
|
|
@@ -6683,7 +6813,7 @@
|
|
|
6683
6813
|
const linksOptions = interactivity.modes.grab.links;
|
|
6684
6814
|
container.particles.grabLineColor = getLinkRandomColor(this.#pluginManager, optColor, linksOptions.blink, linksOptions.consent);
|
|
6685
6815
|
}
|
|
6686
|
-
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor);
|
|
6816
|
+
const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor, container.hdr);
|
|
6687
6817
|
if (!colorLine) {
|
|
6688
6818
|
continue;
|
|
6689
6819
|
}
|
|
@@ -6702,7 +6832,7 @@
|
|
|
6702
6832
|
}
|
|
6703
6833
|
|
|
6704
6834
|
async function loadExternalGrabInteraction(engine) {
|
|
6705
|
-
engine.checkVersion("4.
|
|
6835
|
+
engine.checkVersion("4.4.0");
|
|
6706
6836
|
await engine.pluginManager.register((e) => {
|
|
6707
6837
|
ensureInteractivityPluginLoaded(e);
|
|
6708
6838
|
e.pluginManager.addInteractor?.("externalGrab", container => {
|
|
@@ -6772,7 +6902,7 @@
|
|
|
6772
6902
|
}
|
|
6773
6903
|
|
|
6774
6904
|
async function loadExternalParallaxInteraction(engine) {
|
|
6775
|
-
engine.checkVersion("4.
|
|
6905
|
+
engine.checkVersion("4.4.0");
|
|
6776
6906
|
await engine.pluginManager.register((e) => {
|
|
6777
6907
|
ensureInteractivityPluginLoaded(e);
|
|
6778
6908
|
e.pluginManager.addInteractor?.("externalParallax", container => {
|
|
@@ -6815,7 +6945,7 @@
|
|
|
6815
6945
|
}
|
|
6816
6946
|
|
|
6817
6947
|
async function loadExternalPauseInteraction(engine) {
|
|
6818
|
-
engine.checkVersion("4.
|
|
6948
|
+
engine.checkVersion("4.4.0");
|
|
6819
6949
|
await engine.pluginManager.register((e) => {
|
|
6820
6950
|
ensureInteractivityPluginLoaded(e);
|
|
6821
6951
|
e.pluginManager.addInteractor?.("externalPause", container => {
|
|
@@ -6887,7 +7017,7 @@
|
|
|
6887
7017
|
}
|
|
6888
7018
|
|
|
6889
7019
|
async function loadExternalPushInteraction(engine) {
|
|
6890
|
-
engine.checkVersion("4.
|
|
7020
|
+
engine.checkVersion("4.4.0");
|
|
6891
7021
|
await engine.pluginManager.register((e) => {
|
|
6892
7022
|
ensureInteractivityPluginLoaded(e);
|
|
6893
7023
|
e.pluginManager.addInteractor?.("externalPush", container => {
|
|
@@ -6941,7 +7071,7 @@
|
|
|
6941
7071
|
}
|
|
6942
7072
|
|
|
6943
7073
|
async function loadExternalRemoveInteraction(engine) {
|
|
6944
|
-
engine.checkVersion("4.
|
|
7074
|
+
engine.checkVersion("4.4.0");
|
|
6945
7075
|
await engine.pluginManager.register((e) => {
|
|
6946
7076
|
ensureInteractivityPluginLoaded(e);
|
|
6947
7077
|
e.pluginManager.addInteractor?.("externalRemove", container => {
|
|
@@ -7247,7 +7377,7 @@
|
|
|
7247
7377
|
}
|
|
7248
7378
|
|
|
7249
7379
|
async function loadExternalRepulseInteraction(engine) {
|
|
7250
|
-
engine.checkVersion("4.
|
|
7380
|
+
engine.checkVersion("4.4.0");
|
|
7251
7381
|
await engine.pluginManager.register((e) => {
|
|
7252
7382
|
ensureInteractivityPluginLoaded(e);
|
|
7253
7383
|
const pluginManager = e.pluginManager;
|
|
@@ -7341,7 +7471,7 @@
|
|
|
7341
7471
|
}
|
|
7342
7472
|
|
|
7343
7473
|
async function loadExternalSlowInteraction(engine) {
|
|
7344
|
-
engine.checkVersion("4.
|
|
7474
|
+
engine.checkVersion("4.4.0");
|
|
7345
7475
|
await engine.pluginManager.register((e) => {
|
|
7346
7476
|
ensureInteractivityPluginLoaded(e);
|
|
7347
7477
|
e.pluginManager.addInteractor?.("externalSlow", container => {
|
|
@@ -7353,12 +7483,12 @@
|
|
|
7353
7483
|
const shapeTypes = ["image", "images"];
|
|
7354
7484
|
const stringStart = 0, defaultOpacity = 1;
|
|
7355
7485
|
const currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;
|
|
7356
|
-
function replaceColorSvg(imageShape, color, opacity, hdr = false) {
|
|
7486
|
+
function replaceColorSvg(imageShape, color, opacity, hdr = false, peakNits, mode) {
|
|
7357
7487
|
const { svgData } = imageShape;
|
|
7358
7488
|
if (!svgData) {
|
|
7359
7489
|
return "";
|
|
7360
7490
|
}
|
|
7361
|
-
const colorStyle = getStyleFromHsl(color, hdr, opacity);
|
|
7491
|
+
const colorStyle = getStyleFromHsl(color, hdr, opacity, peakNits, mode);
|
|
7362
7492
|
if (svgData.includes("fill")) {
|
|
7363
7493
|
return svgData.replaceAll(currentColorRegex, () => colorStyle);
|
|
7364
7494
|
}
|
|
@@ -7400,8 +7530,8 @@
|
|
|
7400
7530
|
}
|
|
7401
7531
|
image.loading = false;
|
|
7402
7532
|
}
|
|
7403
|
-
function replaceImageColor(image, imageData, color, particle, hdr = false) {
|
|
7404
|
-
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 = {
|
|
7405
7535
|
color,
|
|
7406
7536
|
data: {
|
|
7407
7537
|
...image,
|
|
@@ -7513,7 +7643,7 @@
|
|
|
7513
7643
|
void (async () => {
|
|
7514
7644
|
let imageRes;
|
|
7515
7645
|
if (image.svgData && color) {
|
|
7516
|
-
imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr);
|
|
7646
|
+
imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr, container.peakNits, container.hdrMode);
|
|
7517
7647
|
}
|
|
7518
7648
|
else {
|
|
7519
7649
|
imageRes = {
|
|
@@ -7650,7 +7780,7 @@
|
|
|
7650
7780
|
};
|
|
7651
7781
|
}
|
|
7652
7782
|
async function loadImageShape(engine) {
|
|
7653
|
-
engine.checkVersion("4.
|
|
7783
|
+
engine.checkVersion("4.4.0");
|
|
7654
7784
|
await engine.pluginManager.register(e => {
|
|
7655
7785
|
addLoadImageToEngine(e);
|
|
7656
7786
|
e.pluginManager.addPlugin(new ImagePreloaderPlugin(e));
|
|
@@ -7795,7 +7925,7 @@
|
|
|
7795
7925
|
}
|
|
7796
7926
|
|
|
7797
7927
|
async function loadLifeUpdater(engine) {
|
|
7798
|
-
engine.checkVersion("4.
|
|
7928
|
+
engine.checkVersion("4.4.0");
|
|
7799
7929
|
await engine.pluginManager.register(e => {
|
|
7800
7930
|
e.pluginManager.addParticleUpdater("life", container => {
|
|
7801
7931
|
return Promise.resolve(new LifeUpdater(container));
|
|
@@ -7821,7 +7951,7 @@
|
|
|
7821
7951
|
}
|
|
7822
7952
|
|
|
7823
7953
|
async function loadLineShape(engine) {
|
|
7824
|
-
engine.checkVersion("4.
|
|
7954
|
+
engine.checkVersion("4.4.0");
|
|
7825
7955
|
await engine.pluginManager.register(e => {
|
|
7826
7956
|
e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
|
|
7827
7957
|
});
|
|
@@ -7905,7 +8035,7 @@
|
|
|
7905
8035
|
}
|
|
7906
8036
|
|
|
7907
8037
|
async function loadParticlesAttractInteraction(engine) {
|
|
7908
|
-
engine.checkVersion("4.
|
|
8038
|
+
engine.checkVersion("4.4.0");
|
|
7909
8039
|
await engine.pluginManager.register((e) => {
|
|
7910
8040
|
ensureInteractivityPluginLoaded(e);
|
|
7911
8041
|
e.pluginManager.addInteractor?.("particlesAttract", container => {
|
|
@@ -8115,7 +8245,7 @@
|
|
|
8115
8245
|
}
|
|
8116
8246
|
|
|
8117
8247
|
async function loadParticlesCollisionsInteraction(engine) {
|
|
8118
|
-
engine.checkVersion("4.
|
|
8248
|
+
engine.checkVersion("4.4.0");
|
|
8119
8249
|
await engine.pluginManager.register((e) => {
|
|
8120
8250
|
ensureInteractivityPluginLoaded(e);
|
|
8121
8251
|
e.pluginManager.addPlugin(new OverlapPlugin());
|
|
@@ -8328,7 +8458,7 @@
|
|
|
8328
8458
|
const linkColor = linksOptions.id !== undefined
|
|
8329
8459
|
? container.particles.linksColors.get(linksOptions.id)
|
|
8330
8460
|
: container.particles.linksColor;
|
|
8331
|
-
return getLinkColor(p1, p2, linkColor);
|
|
8461
|
+
return getLinkColor(p1, p2, linkColor, container.hdr);
|
|
8332
8462
|
}
|
|
8333
8463
|
#setColor(p1) {
|
|
8334
8464
|
if (!p1.options.links) {
|
|
@@ -8369,7 +8499,7 @@
|
|
|
8369
8499
|
}
|
|
8370
8500
|
|
|
8371
8501
|
async function loadParticlesLinksInteraction(engine) {
|
|
8372
|
-
engine.checkVersion("4.
|
|
8502
|
+
engine.checkVersion("4.4.0");
|
|
8373
8503
|
await engine.pluginManager.register((e) => {
|
|
8374
8504
|
const pluginManager = e.pluginManager;
|
|
8375
8505
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -8459,19 +8589,19 @@
|
|
|
8459
8589
|
}
|
|
8460
8590
|
|
|
8461
8591
|
async function loadGenericPolygonShape(engine) {
|
|
8462
|
-
engine.checkVersion("4.
|
|
8592
|
+
engine.checkVersion("4.4.0");
|
|
8463
8593
|
await engine.pluginManager.register(e => {
|
|
8464
8594
|
e.pluginManager.addShape(["polygon"], () => Promise.resolve(new PolygonDrawer()));
|
|
8465
8595
|
});
|
|
8466
8596
|
}
|
|
8467
8597
|
async function loadTriangleShape(engine) {
|
|
8468
|
-
engine.checkVersion("4.
|
|
8598
|
+
engine.checkVersion("4.4.0");
|
|
8469
8599
|
await engine.pluginManager.register(e => {
|
|
8470
8600
|
e.pluginManager.addShape(["triangle"], () => Promise.resolve(new TriangleDrawer()));
|
|
8471
8601
|
});
|
|
8472
8602
|
}
|
|
8473
8603
|
async function loadPolygonShape(engine) {
|
|
8474
|
-
engine.checkVersion("4.
|
|
8604
|
+
engine.checkVersion("4.4.0");
|
|
8475
8605
|
await Promise.all([
|
|
8476
8606
|
loadGenericPolygonShape(engine),
|
|
8477
8607
|
loadTriangleShape(engine),
|
|
@@ -8576,7 +8706,7 @@
|
|
|
8576
8706
|
}
|
|
8577
8707
|
|
|
8578
8708
|
async function loadRotateUpdater(engine) {
|
|
8579
|
-
engine.checkVersion("4.
|
|
8709
|
+
engine.checkVersion("4.4.0");
|
|
8580
8710
|
await engine.pluginManager.register(e => {
|
|
8581
8711
|
e.pluginManager.addParticleUpdater("rotate", container => {
|
|
8582
8712
|
return Promise.resolve(new RotateUpdater(container));
|
|
@@ -8600,7 +8730,7 @@
|
|
|
8600
8730
|
}
|
|
8601
8731
|
|
|
8602
8732
|
async function loadSquareShape(engine) {
|
|
8603
|
-
engine.checkVersion("4.
|
|
8733
|
+
engine.checkVersion("4.4.0");
|
|
8604
8734
|
await engine.pluginManager.register(e => {
|
|
8605
8735
|
e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
|
|
8606
8736
|
});
|
|
@@ -8634,14 +8764,14 @@
|
|
|
8634
8764
|
}
|
|
8635
8765
|
|
|
8636
8766
|
async function loadStarShape(engine) {
|
|
8637
|
-
engine.checkVersion("4.
|
|
8767
|
+
engine.checkVersion("4.4.0");
|
|
8638
8768
|
await engine.pluginManager.register(e => {
|
|
8639
8769
|
e.pluginManager.addShape(["star"], () => Promise.resolve(new StarDrawer()));
|
|
8640
8770
|
});
|
|
8641
8771
|
}
|
|
8642
8772
|
|
|
8643
8773
|
async function loadSlim(engine) {
|
|
8644
|
-
engine.checkVersion("4.
|
|
8774
|
+
engine.checkVersion("4.4.0");
|
|
8645
8775
|
await engine.pluginManager.register(async (e) => {
|
|
8646
8776
|
const loadInteractivityForSlim = async (e) => {
|
|
8647
8777
|
await loadInteractivityPlugin(e);
|
|
@@ -8758,7 +8888,7 @@
|
|
|
8758
8888
|
}
|
|
8759
8889
|
|
|
8760
8890
|
async function loadTextShape(engine) {
|
|
8761
|
-
engine.checkVersion("4.
|
|
8891
|
+
engine.checkVersion("4.4.0");
|
|
8762
8892
|
await engine.pluginManager.register(e => {
|
|
8763
8893
|
e.pluginManager.addShape(validTypes, () => Promise.resolve(new TextDrawer()));
|
|
8764
8894
|
});
|
|
@@ -8867,7 +8997,7 @@
|
|
|
8867
8997
|
}
|
|
8868
8998
|
|
|
8869
8999
|
async function loadTiltUpdater(engine) {
|
|
8870
|
-
engine.checkVersion("4.
|
|
9000
|
+
engine.checkVersion("4.4.0");
|
|
8871
9001
|
await engine.pluginManager.register(e => {
|
|
8872
9002
|
e.pluginManager.addParticleUpdater("tilt", container => {
|
|
8873
9003
|
return Promise.resolve(new TiltUpdater(container));
|
|
@@ -8943,12 +9073,12 @@
|
|
|
8943
9073
|
if (!twinkleFillRgb) {
|
|
8944
9074
|
return undefined;
|
|
8945
9075
|
}
|
|
8946
|
-
return getStyleFromHsl(twinkleFillRgb, container.hdr, twinklingOpacity);
|
|
9076
|
+
return getStyleFromHsl(twinkleFillRgb, container.hdr, twinklingOpacity, container.peakNits, container.hdrMode);
|
|
8947
9077
|
}, getTwinkleStrokeStyle = () => {
|
|
8948
9078
|
if (!twinkleStrokeRgb) {
|
|
8949
9079
|
return undefined;
|
|
8950
9080
|
}
|
|
8951
|
-
return getStyleFromHsl(twinkleStrokeRgb, container.hdr, twinklingOpacity);
|
|
9081
|
+
return getStyleFromHsl(twinkleStrokeRgb, container.hdr, twinklingOpacity, container.peakNits, container.hdrMode);
|
|
8952
9082
|
}, twinkleFillStyle = getTwinkleFillStyle(), twinkleStrokeStyle = getTwinkleStrokeStyle(), res = {}, needsTwinkle = twinkling && (!!twinkleFillStyle || !!twinkleStrokeStyle);
|
|
8953
9083
|
res.fill = needsTwinkle ? twinkleFillStyle : undefined;
|
|
8954
9084
|
res.stroke = needsTwinkle ? twinkleStrokeStyle : undefined;
|
|
@@ -8971,7 +9101,7 @@
|
|
|
8971
9101
|
}
|
|
8972
9102
|
|
|
8973
9103
|
async function loadTwinkleUpdater(engine) {
|
|
8974
|
-
engine.checkVersion("4.
|
|
9104
|
+
engine.checkVersion("4.4.0");
|
|
8975
9105
|
await engine.pluginManager.register(e => {
|
|
8976
9106
|
e.pluginManager.addParticleUpdater("twinkle", container => {
|
|
8977
9107
|
return Promise.resolve(new TwinkleUpdater(e.pluginManager, container));
|
|
@@ -9073,7 +9203,7 @@
|
|
|
9073
9203
|
}
|
|
9074
9204
|
|
|
9075
9205
|
async function loadWobbleUpdater(engine) {
|
|
9076
|
-
engine.checkVersion("4.
|
|
9206
|
+
engine.checkVersion("4.4.0");
|
|
9077
9207
|
await engine.pluginManager.register(e => {
|
|
9078
9208
|
e.pluginManager.addParticleUpdater("wobble", container => {
|
|
9079
9209
|
return Promise.resolve(new WobbleUpdater(container));
|
|
@@ -9082,7 +9212,7 @@
|
|
|
9082
9212
|
}
|
|
9083
9213
|
|
|
9084
9214
|
async function loadFull(engine) {
|
|
9085
|
-
engine.checkVersion("4.
|
|
9215
|
+
engine.checkVersion("4.4.0");
|
|
9086
9216
|
await engine.pluginManager.register(async (e) => {
|
|
9087
9217
|
const loadEmittersPluginBundle = async (e) => {
|
|
9088
9218
|
await loadEmittersPlugin(e);
|
|
@@ -9182,14 +9312,14 @@
|
|
|
9182
9312
|
}
|
|
9183
9313
|
|
|
9184
9314
|
async function loadResponsivePlugin(engine) {
|
|
9185
|
-
engine.checkVersion("4.
|
|
9315
|
+
engine.checkVersion("4.4.0");
|
|
9186
9316
|
await engine.pluginManager.register(e => {
|
|
9187
9317
|
e.pluginManager.addPlugin(new ResponsivePlugin());
|
|
9188
9318
|
});
|
|
9189
9319
|
}
|
|
9190
9320
|
|
|
9191
9321
|
const initPjs = async (engine) => {
|
|
9192
|
-
engine.checkVersion("4.
|
|
9322
|
+
engine.checkVersion("4.4.0");
|
|
9193
9323
|
await engine.pluginManager.register(async (e) => {
|
|
9194
9324
|
await Promise.all([loadFull(e), loadResponsivePlugin(e)]);
|
|
9195
9325
|
});
|
|
@@ -9321,7 +9451,11 @@
|
|
|
9321
9451
|
if (!fColor && !sColor) {
|
|
9322
9452
|
return;
|
|
9323
9453
|
}
|
|
9324
|
-
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;
|
|
9325
9459
|
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
9326
9460
|
colorStyles.fill = fill;
|
|
9327
9461
|
colorStyles.stroke = stroke;
|
|
@@ -9655,7 +9789,9 @@
|
|
|
9655
9789
|
if (typeof background.element === "string") {
|
|
9656
9790
|
if (typeof document !== "undefined") {
|
|
9657
9791
|
const node = document.querySelector(background.element);
|
|
9658
|
-
if (
|
|
9792
|
+
if ((typeof HTMLCanvasElement !== "undefined" && node instanceof HTMLCanvasElement) ||
|
|
9793
|
+
(typeof HTMLVideoElement !== "undefined" && node instanceof HTMLVideoElement) ||
|
|
9794
|
+
(typeof HTMLImageElement !== "undefined" && node instanceof HTMLImageElement)) {
|
|
9659
9795
|
this.#backgroundElement = node;
|
|
9660
9796
|
}
|
|
9661
9797
|
else if (node) {
|
|
@@ -9666,10 +9802,10 @@
|
|
|
9666
9802
|
}
|
|
9667
9803
|
}
|
|
9668
9804
|
}
|
|
9669
|
-
else if (background.element instanceof HTMLCanvasElement ||
|
|
9670
|
-
background.element instanceof OffscreenCanvas ||
|
|
9671
|
-
background.element instanceof HTMLVideoElement ||
|
|
9672
|
-
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)) {
|
|
9673
9809
|
this.#backgroundElement = background.element;
|
|
9674
9810
|
}
|
|
9675
9811
|
}
|
|
@@ -9737,6 +9873,7 @@
|
|
|
9737
9873
|
zoom = defaultZoom;
|
|
9738
9874
|
#container;
|
|
9739
9875
|
#generated;
|
|
9876
|
+
#hdrMediaListeners;
|
|
9740
9877
|
#mutationObserver;
|
|
9741
9878
|
#originalStyle;
|
|
9742
9879
|
#pluginManager;
|
|
@@ -9801,7 +9938,6 @@
|
|
|
9801
9938
|
});
|
|
9802
9939
|
this.resize();
|
|
9803
9940
|
this.#initStyle();
|
|
9804
|
-
this.initBackground();
|
|
9805
9941
|
this.#safeMutationObserver(obs => {
|
|
9806
9942
|
const element = this.domElement;
|
|
9807
9943
|
if (!element || !(element instanceof Node)) {
|
|
@@ -9811,6 +9947,8 @@
|
|
|
9811
9947
|
});
|
|
9812
9948
|
this.initPlugins();
|
|
9813
9949
|
this.#initContext();
|
|
9950
|
+
this.initBackground();
|
|
9951
|
+
this.#initHdrListeners();
|
|
9814
9952
|
this.render.init();
|
|
9815
9953
|
}
|
|
9816
9954
|
initBackground() {
|
|
@@ -9820,7 +9958,8 @@
|
|
|
9820
9958
|
}
|
|
9821
9959
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
9822
9960
|
if (color) {
|
|
9823
|
-
|
|
9961
|
+
const hdrOptions = container.actualOptions.hdr;
|
|
9962
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity, hdrOptions.peakNits, hdrOptions.mode);
|
|
9824
9963
|
}
|
|
9825
9964
|
else {
|
|
9826
9965
|
elementStyle.backgroundColor = "";
|
|
@@ -9917,6 +10056,7 @@
|
|
|
9917
10056
|
obs.disconnect();
|
|
9918
10057
|
});
|
|
9919
10058
|
this.#mutationObserver = undefined;
|
|
10059
|
+
this.#removeHdrListeners();
|
|
9920
10060
|
this.render.stop();
|
|
9921
10061
|
}
|
|
9922
10062
|
async windowResize() {
|
|
@@ -9936,9 +10076,16 @@
|
|
|
9936
10076
|
}
|
|
9937
10077
|
}
|
|
9938
10078
|
#initContext() {
|
|
9939
|
-
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
10079
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr.enable &&
|
|
9940
10080
|
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
9941
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
|
+
}
|
|
9942
10089
|
this.render.setContextSettings({
|
|
9943
10090
|
alpha: true,
|
|
9944
10091
|
desynchronized: true,
|
|
@@ -9947,11 +10094,47 @@
|
|
|
9947
10094
|
? { colorSpace: "display-p3", colorType: "float16" }
|
|
9948
10095
|
: { colorSpace: "srgb" }),
|
|
9949
10096
|
});
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
10097
|
+
let context;
|
|
10098
|
+
try {
|
|
10099
|
+
context = renderCanvas.getContext("2d", this.render.settings);
|
|
9953
10100
|
}
|
|
9954
|
-
|
|
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
|
+
}
|
|
10119
|
+
}
|
|
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;
|
|
9955
10138
|
}
|
|
9956
10139
|
#initStyle() {
|
|
9957
10140
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
@@ -9975,6 +10158,25 @@
|
|
|
9975
10158
|
element.style.setProperty(key, value, "important");
|
|
9976
10159
|
}
|
|
9977
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
|
+
}
|
|
9978
10180
|
#repairStyle() {
|
|
9979
10181
|
const element = this.domElement;
|
|
9980
10182
|
if (!element) {
|
|
@@ -10359,9 +10561,9 @@
|
|
|
10359
10561
|
}
|
|
10360
10562
|
getOpacity() {
|
|
10361
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;
|
|
10362
|
-
this.#cachedOpacityData.fillOpacity =
|
|
10564
|
+
this.#cachedOpacityData.fillOpacity = fillOpacity;
|
|
10363
10565
|
this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
10364
|
-
this.#cachedOpacityData.strokeOpacity =
|
|
10566
|
+
this.#cachedOpacityData.strokeOpacity = strokeOpacity;
|
|
10365
10567
|
return this.#cachedOpacityData;
|
|
10366
10568
|
}
|
|
10367
10569
|
getPosition() {
|
|
@@ -11216,6 +11418,7 @@
|
|
|
11216
11418
|
effectDrawers;
|
|
11217
11419
|
fpsLimit;
|
|
11218
11420
|
hdr;
|
|
11421
|
+
hdrMode;
|
|
11219
11422
|
id;
|
|
11220
11423
|
pageHidden;
|
|
11221
11424
|
particleCreatedPlugins;
|
|
@@ -11223,6 +11426,7 @@
|
|
|
11223
11426
|
particlePositionPlugins;
|
|
11224
11427
|
particleUpdaters;
|
|
11225
11428
|
particles;
|
|
11429
|
+
peakNits;
|
|
11226
11430
|
plugins;
|
|
11227
11431
|
retina;
|
|
11228
11432
|
shapeDrawers;
|
|
@@ -11253,6 +11457,8 @@
|
|
|
11253
11457
|
this.id = Symbol(id);
|
|
11254
11458
|
this.fpsLimit = 120;
|
|
11255
11459
|
this.hdr = false;
|
|
11460
|
+
this.hdrMode = exports.HdrMode.standard;
|
|
11461
|
+
this.peakNits = 400;
|
|
11256
11462
|
this.#smooth = false;
|
|
11257
11463
|
this.#delay = 0;
|
|
11258
11464
|
this.#duration = 0;
|
|
@@ -11392,8 +11598,9 @@
|
|
|
11392
11598
|
this.updateActualOptions();
|
|
11393
11599
|
this.canvas.initBackground();
|
|
11394
11600
|
this.canvas.resize();
|
|
11395
|
-
const { delay, duration, fpsLimit,
|
|
11396
|
-
this.
|
|
11601
|
+
const { delay, duration, fpsLimit, smooth, zLayers } = this.actualOptions, hdrOptions = this.actualOptions.hdr;
|
|
11602
|
+
this.hdrMode = hdrOptions.mode;
|
|
11603
|
+
this.peakNits = hdrOptions.peakNits;
|
|
11397
11604
|
this.zLayers = zLayers;
|
|
11398
11605
|
this.#duration = getRangeValue(duration) * millisecondsToSeconds;
|
|
11399
11606
|
this.#delay = getRangeValue(delay) * millisecondsToSeconds;
|
|
@@ -12812,10 +13019,10 @@
|
|
|
12812
13019
|
}
|
|
12813
13020
|
}
|
|
12814
13021
|
#getCachedStyle(rgb) {
|
|
12815
|
-
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}`;
|
|
12816
13023
|
let style = this.#colorCache.get(key);
|
|
12817
13024
|
if (!style) {
|
|
12818
|
-
style = getStyleFromRgb(rgb, this.#container.hdr);
|
|
13025
|
+
style = getStyleFromRgb(rgb, this.#container.hdr, undefined, this.#container.peakNits, this.#container.hdrMode);
|
|
12819
13026
|
this.#colorCache.set(key, style);
|
|
12820
13027
|
}
|
|
12821
13028
|
return style;
|
|
@@ -12948,7 +13155,7 @@
|
|
|
12948
13155
|
context.beginPath();
|
|
12949
13156
|
context.arc(originPoint.x, originPoint.y, this.size, minAngle, maxAngle, false);
|
|
12950
13157
|
context.closePath();
|
|
12951
|
-
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);
|
|
12952
13159
|
context.fill();
|
|
12953
13160
|
}
|
|
12954
13161
|
resize() {
|
|
@@ -13428,6 +13635,7 @@
|
|
|
13428
13635
|
exports.ColorAnimation = ColorAnimation;
|
|
13429
13636
|
exports.Fill = Fill;
|
|
13430
13637
|
exports.FullScreen = FullScreen;
|
|
13638
|
+
exports.HDROptions = HDROptions;
|
|
13431
13639
|
exports.HslAnimation = HslAnimation;
|
|
13432
13640
|
exports.Move = Move;
|
|
13433
13641
|
exports.MoveAngle = MoveAngle;
|