@tsparticles/ribbons 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/ribbons.js +3 -3
- package/browser/ribbons.lazy.js +3 -3
- package/cjs/ribbons.js +3 -3
- package/cjs/ribbons.lazy.js +3 -3
- package/esm/ribbons.js +3 -3
- package/esm/ribbons.lazy.js +3 -3
- package/package.json +8 -8
- package/report.html +1 -1
- package/tsparticles.ribbons.bundle.js +330 -108
- package/tsparticles.ribbons.bundle.min.js +1 -1
- package/tsparticles.ribbons.js +4 -4
- package/tsparticles.ribbons.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$1 = 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$1, key =
|
|
2027
|
-
|
|
2120
|
+
function getStyleFromRgb(color, hdr, opacity, peakNits, mode) {
|
|
2121
|
+
const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? defaultOpacity$1, key = hdr
|
|
2122
|
+
? `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-hdr-${op.toString()}-${(peakNits ?? maxNits).toString()}-${mode ?? exports.HdrMode.standard}`
|
|
2123
|
+
: `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-sdr-${op.toString()}`;
|
|
2124
|
+
return getCachedStyle(key, () => hdr ? getHdrStyleFromRgb(color, opacity, peakNits, mode) : getSdrStyleFromRgb(color, opacity));
|
|
2125
|
+
}
|
|
2126
|
+
function getHdrStyleFromRgb(color, opacity, peakNits = maxNits, mode = exports.HdrMode.standard) {
|
|
2127
|
+
const headroom = peakNits / sdrReferenceWhiteNits, middleGray = 0.18, mapped = hdrToneMapColor(color, headroom, middleGray, mode);
|
|
2128
|
+
return `color(display-p3 ${mapped.r.toString()} ${mapped.g.toString()} ${mapped.b.toString()} / ${(opacity ?? defaultOpacity$1).toString()})`;
|
|
2028
2129
|
}
|
|
2029
|
-
function
|
|
2030
|
-
const
|
|
2031
|
-
|
|
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$1).toString()})`;
|
|
2035
2147
|
}
|
|
2036
|
-
function getStyleFromHsl(color, hdr, opacity) {
|
|
2037
|
-
const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? defaultOpacity$1, key =
|
|
2148
|
+
function getStyleFromHsl(color, hdr, opacity, peakNits, mode) {
|
|
2149
|
+
const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? defaultOpacity$1, 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 {
|
|
@@ -2253,7 +2383,7 @@
|
|
|
2253
2383
|
}
|
|
2254
2384
|
|
|
2255
2385
|
async function loadBlendPlugin(engine) {
|
|
2256
|
-
engine.checkVersion("4.
|
|
2386
|
+
engine.checkVersion("4.4.0");
|
|
2257
2387
|
await engine.pluginManager.register(e => {
|
|
2258
2388
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
2259
2389
|
});
|
|
@@ -2290,7 +2420,7 @@
|
|
|
2290
2420
|
}
|
|
2291
2421
|
|
|
2292
2422
|
async function loadCircleShape(engine) {
|
|
2293
|
-
engine.checkVersion("4.
|
|
2423
|
+
engine.checkVersion("4.4.0");
|
|
2294
2424
|
await engine.pluginManager.register(e => {
|
|
2295
2425
|
e.pluginManager.addShape(["circle"], () => {
|
|
2296
2426
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -2338,7 +2468,7 @@
|
|
|
2338
2468
|
}
|
|
2339
2469
|
|
|
2340
2470
|
async function loadHexColorPlugin(engine) {
|
|
2341
|
-
engine.checkVersion("4.
|
|
2471
|
+
engine.checkVersion("4.4.0");
|
|
2342
2472
|
await engine.pluginManager.register(e => {
|
|
2343
2473
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
2344
2474
|
});
|
|
@@ -2391,7 +2521,7 @@
|
|
|
2391
2521
|
}
|
|
2392
2522
|
|
|
2393
2523
|
async function loadHslColorPlugin(engine) {
|
|
2394
|
-
engine.checkVersion("4.
|
|
2524
|
+
engine.checkVersion("4.4.0");
|
|
2395
2525
|
await engine.pluginManager.register(e => {
|
|
2396
2526
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
2397
2527
|
});
|
|
@@ -2415,7 +2545,7 @@
|
|
|
2415
2545
|
}
|
|
2416
2546
|
|
|
2417
2547
|
async function loadMovePlugin(engine) {
|
|
2418
|
-
engine.checkVersion("4.
|
|
2548
|
+
engine.checkVersion("4.4.0");
|
|
2419
2549
|
await engine.pluginManager.register(e => {
|
|
2420
2550
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
2421
2551
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -2625,7 +2755,7 @@
|
|
|
2625
2755
|
}
|
|
2626
2756
|
|
|
2627
2757
|
async function loadOpacityUpdater(engine) {
|
|
2628
|
-
engine.checkVersion("4.
|
|
2758
|
+
engine.checkVersion("4.4.0");
|
|
2629
2759
|
await engine.pluginManager.register(e => {
|
|
2630
2760
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
2631
2761
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -2970,7 +3100,7 @@
|
|
|
2970
3100
|
}
|
|
2971
3101
|
|
|
2972
3102
|
async function loadOutModesUpdater(engine) {
|
|
2973
|
-
engine.checkVersion("4.
|
|
3103
|
+
engine.checkVersion("4.4.0");
|
|
2974
3104
|
await engine.pluginManager.register(e => {
|
|
2975
3105
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
2976
3106
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3041,7 +3171,7 @@
|
|
|
3041
3171
|
}
|
|
3042
3172
|
|
|
3043
3173
|
async function loadPaintUpdater(engine) {
|
|
3044
|
-
engine.checkVersion("4.
|
|
3174
|
+
engine.checkVersion("4.4.0");
|
|
3045
3175
|
await engine.pluginManager.register(e => {
|
|
3046
3176
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3047
3177
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3096,7 +3226,7 @@
|
|
|
3096
3226
|
}
|
|
3097
3227
|
|
|
3098
3228
|
async function loadRgbColorPlugin(engine) {
|
|
3099
|
-
engine.checkVersion("4.
|
|
3229
|
+
engine.checkVersion("4.4.0");
|
|
3100
3230
|
await engine.pluginManager.register(e => {
|
|
3101
3231
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3102
3232
|
});
|
|
@@ -3181,7 +3311,7 @@
|
|
|
3181
3311
|
}
|
|
3182
3312
|
|
|
3183
3313
|
async function loadSizeUpdater(engine) {
|
|
3184
|
-
engine.checkVersion("4.
|
|
3314
|
+
engine.checkVersion("4.4.0");
|
|
3185
3315
|
await engine.pluginManager.register(e => {
|
|
3186
3316
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3187
3317
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3190,7 +3320,7 @@
|
|
|
3190
3320
|
}
|
|
3191
3321
|
|
|
3192
3322
|
async function loadBasic(engine) {
|
|
3193
|
-
engine.checkVersion("4.
|
|
3323
|
+
engine.checkVersion("4.4.0");
|
|
3194
3324
|
await engine.pluginManager.register(async (e) => {
|
|
3195
3325
|
await Promise.all([
|
|
3196
3326
|
loadBlendPlugin(e),
|
|
@@ -3430,7 +3560,7 @@
|
|
|
3430
3560
|
})(EmitterClickMode || (EmitterClickMode = {}));
|
|
3431
3561
|
|
|
3432
3562
|
async function loadEmittersPluginSimple(engine) {
|
|
3433
|
-
engine.checkVersion("4.
|
|
3563
|
+
engine.checkVersion("4.4.0");
|
|
3434
3564
|
await engine.pluginManager.register(async (e) => {
|
|
3435
3565
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
3436
3566
|
await addEmittersShapesManager(e);
|
|
@@ -3518,7 +3648,7 @@
|
|
|
3518
3648
|
}
|
|
3519
3649
|
|
|
3520
3650
|
async function loadEmittersShapeSquare(engine) {
|
|
3521
|
-
engine.checkVersion("4.
|
|
3651
|
+
engine.checkVersion("4.4.0");
|
|
3522
3652
|
await engine.pluginManager.register((e) => {
|
|
3523
3653
|
ensureEmittersPluginLoaded(e);
|
|
3524
3654
|
e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
|
|
@@ -3662,7 +3792,7 @@
|
|
|
3662
3792
|
}
|
|
3663
3793
|
|
|
3664
3794
|
async function loadLifeUpdater(engine) {
|
|
3665
|
-
engine.checkVersion("4.
|
|
3795
|
+
engine.checkVersion("4.4.0");
|
|
3666
3796
|
await engine.pluginManager.register(e => {
|
|
3667
3797
|
e.pluginManager.addParticleUpdater("life", container => {
|
|
3668
3798
|
return Promise.resolve(new LifeUpdater(container));
|
|
@@ -3716,7 +3846,7 @@
|
|
|
3716
3846
|
}
|
|
3717
3847
|
|
|
3718
3848
|
async function loadMotionPlugin(engine) {
|
|
3719
|
-
engine.checkVersion("4.
|
|
3849
|
+
engine.checkVersion("4.4.0");
|
|
3720
3850
|
await engine.pluginManager.register(e => {
|
|
3721
3851
|
e.pluginManager.addPlugin(new MotionPlugin());
|
|
3722
3852
|
});
|
|
@@ -3924,12 +4054,7 @@
|
|
|
3924
4054
|
context.fill();
|
|
3925
4055
|
}
|
|
3926
4056
|
}
|
|
3927
|
-
function
|
|
3928
|
-
const { context, particle, radius } = data, points = particle.ribbonPoints, offsets = particle.ribbonOffsets, bounds = particle.ribbonBounds, hasFill = data.fill, hasStroke = data.stroke;
|
|
3929
|
-
if (!points || !offsets || !bounds || points.length < minPointCount || (!hasFill && !hasStroke)) {
|
|
3930
|
-
return;
|
|
3931
|
-
}
|
|
3932
|
-
const drawOffsets = offsets.mult(radius), center = particle.position, frontFill = typeof context.fillStyle === "string" ? context.fillStyle : "", frontStroke = typeof context.strokeStyle === "string" ? context.strokeStyle : "", shapeData = particle.shapeData;
|
|
4057
|
+
function resolveBackFill(hasStroke, frontFill, frontStroke, shapeData, particle, hdr, peakNits, mode) {
|
|
3933
4058
|
let backFill = hasStroke ? frontStroke : frontFill;
|
|
3934
4059
|
if (shapeData?.backColor) {
|
|
3935
4060
|
backFill = shapeData.backColor;
|
|
@@ -3938,16 +4063,68 @@
|
|
|
3938
4063
|
const frontHsl = getHslFromAnimation(particle.fillColor);
|
|
3939
4064
|
if (frontHsl) {
|
|
3940
4065
|
const altered = alterHsl(frontHsl, exports.AlterType.darken, getRangeValue(shapeData.darken.value));
|
|
3941
|
-
backFill = getStyleFromHsl(altered, hdr);
|
|
4066
|
+
backFill = getStyleFromHsl(altered, hdr, undefined, peakNits, mode);
|
|
3942
4067
|
}
|
|
3943
4068
|
}
|
|
3944
4069
|
else if (shapeData?.enlighten?.enable) {
|
|
3945
4070
|
const frontHsl = getHslFromAnimation(particle.fillColor);
|
|
3946
4071
|
if (frontHsl) {
|
|
3947
4072
|
const altered = alterHsl(frontHsl, exports.AlterType.enlighten, getRangeValue(shapeData.enlighten.value));
|
|
3948
|
-
backFill = getStyleFromHsl(altered, hdr);
|
|
4073
|
+
backFill = getStyleFromHsl(altered, hdr, undefined, peakNits, mode);
|
|
3949
4074
|
}
|
|
3950
4075
|
}
|
|
4076
|
+
return backFill;
|
|
4077
|
+
}
|
|
4078
|
+
function drawEdgeSegments(context, currentBase, nextBase, currentSide, nextSide, isFirst, isLast, hasFill, hasStroke) {
|
|
4079
|
+
if (isFirst) {
|
|
4080
|
+
drawPolygonSegment(context, {
|
|
4081
|
+
a: currentBase,
|
|
4082
|
+
b: nextBase,
|
|
4083
|
+
c: getMidpoint(nextBase, nextSide),
|
|
4084
|
+
fill: hasFill,
|
|
4085
|
+
stroke: hasStroke,
|
|
4086
|
+
});
|
|
4087
|
+
drawPolygonSegment(context, {
|
|
4088
|
+
a: nextSide,
|
|
4089
|
+
b: currentSide,
|
|
4090
|
+
c: getMidpoint(nextBase, nextSide),
|
|
4091
|
+
fill: hasFill,
|
|
4092
|
+
stroke: hasStroke,
|
|
4093
|
+
});
|
|
4094
|
+
}
|
|
4095
|
+
else if (isLast) {
|
|
4096
|
+
drawPolygonSegment(context, {
|
|
4097
|
+
a: currentBase,
|
|
4098
|
+
b: nextBase,
|
|
4099
|
+
c: getMidpoint(currentBase, currentSide),
|
|
4100
|
+
fill: hasFill,
|
|
4101
|
+
stroke: hasStroke,
|
|
4102
|
+
});
|
|
4103
|
+
drawPolygonSegment(context, {
|
|
4104
|
+
a: nextSide,
|
|
4105
|
+
b: currentSide,
|
|
4106
|
+
c: getMidpoint(currentBase, currentSide),
|
|
4107
|
+
fill: hasFill,
|
|
4108
|
+
stroke: hasStroke,
|
|
4109
|
+
});
|
|
4110
|
+
}
|
|
4111
|
+
else {
|
|
4112
|
+
drawPolygonSegment(context, {
|
|
4113
|
+
a: currentBase,
|
|
4114
|
+
b: nextBase,
|
|
4115
|
+
c: nextSide,
|
|
4116
|
+
d: currentSide,
|
|
4117
|
+
fill: hasFill,
|
|
4118
|
+
stroke: hasStroke,
|
|
4119
|
+
});
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
function drawRibbon(data, hdr, peakNits, mode) {
|
|
4123
|
+
const { context, particle, radius } = data, points = particle.ribbonPoints, offsets = particle.ribbonOffsets, bounds = particle.ribbonBounds, hasFill = data.fill, hasStroke = data.stroke;
|
|
4124
|
+
if (!points || !offsets || !bounds || points.length < minPointCount || (!hasFill && !hasStroke)) {
|
|
4125
|
+
return;
|
|
4126
|
+
}
|
|
4127
|
+
const drawOffsets = offsets.mult(radius), center = particle.position, frontFill = typeof context.fillStyle === "string" ? context.fillStyle : "", frontStroke = typeof context.strokeStyle === "string" ? context.strokeStyle : "", shapeData = particle.shapeData, backFill = resolveBackFill(hasStroke, frontFill, frontStroke, shapeData, particle, hdr, peakNits, mode);
|
|
3951
4128
|
context.lineWidth = lineWidth;
|
|
3952
4129
|
context.lineJoin = "round";
|
|
3953
4130
|
context.lineCap = "round";
|
|
@@ -3965,46 +4142,13 @@
|
|
|
3965
4142
|
context.strokeStyle = segmentStyle;
|
|
3966
4143
|
}
|
|
3967
4144
|
if (i === noPoint) {
|
|
3968
|
-
|
|
3969
|
-
a: currentBase,
|
|
3970
|
-
b: nextBase,
|
|
3971
|
-
c: getMidpoint(nextBase, nextSide),
|
|
3972
|
-
fill: hasFill,
|
|
3973
|
-
stroke: hasStroke,
|
|
3974
|
-
});
|
|
3975
|
-
drawPolygonSegment(context, {
|
|
3976
|
-
a: nextSide,
|
|
3977
|
-
b: currentSide,
|
|
3978
|
-
c: getMidpoint(nextBase, nextSide),
|
|
3979
|
-
fill: hasFill,
|
|
3980
|
-
stroke: hasStroke,
|
|
3981
|
-
});
|
|
4145
|
+
drawEdgeSegments(context, currentBase, nextBase, currentSide, nextSide, true, false, hasFill, hasStroke);
|
|
3982
4146
|
}
|
|
3983
4147
|
else if (i === points.length - secondPoint) {
|
|
3984
|
-
|
|
3985
|
-
a: currentBase,
|
|
3986
|
-
b: nextBase,
|
|
3987
|
-
c: getMidpoint(currentBase, currentSide),
|
|
3988
|
-
fill: hasFill,
|
|
3989
|
-
stroke: hasStroke,
|
|
3990
|
-
});
|
|
3991
|
-
drawPolygonSegment(context, {
|
|
3992
|
-
a: nextSide,
|
|
3993
|
-
b: currentSide,
|
|
3994
|
-
c: getMidpoint(currentBase, currentSide),
|
|
3995
|
-
fill: hasFill,
|
|
3996
|
-
stroke: hasStroke,
|
|
3997
|
-
});
|
|
4148
|
+
drawEdgeSegments(context, currentBase, nextBase, currentSide, nextSide, false, true, hasFill, hasStroke);
|
|
3998
4149
|
}
|
|
3999
4150
|
else {
|
|
4000
|
-
|
|
4001
|
-
a: currentBase,
|
|
4002
|
-
b: nextBase,
|
|
4003
|
-
c: nextSide,
|
|
4004
|
-
d: currentSide,
|
|
4005
|
-
fill: hasFill,
|
|
4006
|
-
stroke: hasStroke,
|
|
4007
|
-
});
|
|
4151
|
+
drawEdgeSegments(context, currentBase, nextBase, currentSide, nextSide, false, false, hasFill, hasStroke);
|
|
4008
4152
|
}
|
|
4009
4153
|
}
|
|
4010
4154
|
context.fillStyle = frontFill;
|
|
@@ -4052,7 +4196,7 @@
|
|
|
4052
4196
|
createRibbonState(data.particle);
|
|
4053
4197
|
}
|
|
4054
4198
|
updateRibbon(data);
|
|
4055
|
-
drawRibbon(data, this.#container.hdr);
|
|
4199
|
+
drawRibbon(data, this.#container.hdr, this.#container.peakNits, this.#container.hdrMode);
|
|
4056
4200
|
}
|
|
4057
4201
|
getSidesCount(particle) {
|
|
4058
4202
|
const pointsLen = particle.ribbonPoints?.length;
|
|
@@ -4114,7 +4258,7 @@
|
|
|
4114
4258
|
}
|
|
4115
4259
|
|
|
4116
4260
|
async function loadRibbonShape(engine) {
|
|
4117
|
-
engine.checkVersion("4.
|
|
4261
|
+
engine.checkVersion("4.4.0");
|
|
4118
4262
|
await engine.pluginManager.register(e => {
|
|
4119
4263
|
e.pluginManager.addShape(["ribbon"], (container) => Promise.resolve(new RibbonDrawer(container)));
|
|
4120
4264
|
});
|
|
@@ -4434,7 +4578,7 @@
|
|
|
4434
4578
|
|
|
4435
4579
|
let initPromise = null;
|
|
4436
4580
|
async function doInitPlugins(engine) {
|
|
4437
|
-
engine.checkVersion("4.
|
|
4581
|
+
engine.checkVersion("4.4.0");
|
|
4438
4582
|
await engine.pluginManager.register(async (e) => {
|
|
4439
4583
|
const emittersRegister = async (engine) => {
|
|
4440
4584
|
await loadEmittersPluginSimple(engine);
|
|
@@ -4489,7 +4633,7 @@
|
|
|
4489
4633
|
}
|
|
4490
4634
|
else {
|
|
4491
4635
|
subId = id;
|
|
4492
|
-
subOptions = idOrOptions ??
|
|
4636
|
+
subOptions = idOrOptions ?? options;
|
|
4493
4637
|
}
|
|
4494
4638
|
return setRibbons(tsParticles, {
|
|
4495
4639
|
id: subId,
|
|
@@ -4501,7 +4645,7 @@
|
|
|
4501
4645
|
ribbons.init = async () => {
|
|
4502
4646
|
await initPlugins(tsParticles);
|
|
4503
4647
|
};
|
|
4504
|
-
ribbons.version = "4.
|
|
4648
|
+
ribbons.version = "4.4.0";
|
|
4505
4649
|
globalThis.ribbons = ribbons;
|
|
4506
4650
|
|
|
4507
4651
|
const globalObject = globalThis;
|
|
@@ -4626,7 +4770,11 @@
|
|
|
4626
4770
|
if (!fColor && !sColor) {
|
|
4627
4771
|
return;
|
|
4628
4772
|
}
|
|
4629
|
-
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
|
|
4773
|
+
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
|
|
4774
|
+
? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity, container.peakNits, container.hdrMode)
|
|
4775
|
+
: undefined, stroke = sColor
|
|
4776
|
+
? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity, container.peakNits, container.hdrMode)
|
|
4777
|
+
: fill;
|
|
4630
4778
|
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
4631
4779
|
colorStyles.fill = fill;
|
|
4632
4780
|
colorStyles.stroke = stroke;
|
|
@@ -4960,7 +5108,9 @@
|
|
|
4960
5108
|
if (typeof background.element === "string") {
|
|
4961
5109
|
if (typeof document !== "undefined") {
|
|
4962
5110
|
const node = document.querySelector(background.element);
|
|
4963
|
-
if (
|
|
5111
|
+
if ((typeof HTMLCanvasElement !== "undefined" && node instanceof HTMLCanvasElement) ||
|
|
5112
|
+
(typeof HTMLVideoElement !== "undefined" && node instanceof HTMLVideoElement) ||
|
|
5113
|
+
(typeof HTMLImageElement !== "undefined" && node instanceof HTMLImageElement)) {
|
|
4964
5114
|
this.#backgroundElement = node;
|
|
4965
5115
|
}
|
|
4966
5116
|
else if (node) {
|
|
@@ -4971,10 +5121,10 @@
|
|
|
4971
5121
|
}
|
|
4972
5122
|
}
|
|
4973
5123
|
}
|
|
4974
|
-
else if (background.element instanceof HTMLCanvasElement ||
|
|
4975
|
-
background.element instanceof OffscreenCanvas ||
|
|
4976
|
-
background.element instanceof HTMLVideoElement ||
|
|
4977
|
-
background.element instanceof HTMLImageElement) {
|
|
5124
|
+
else if ((typeof HTMLCanvasElement !== "undefined" && background.element instanceof HTMLCanvasElement) ||
|
|
5125
|
+
(typeof OffscreenCanvas !== "undefined" && background.element instanceof OffscreenCanvas) ||
|
|
5126
|
+
(typeof HTMLVideoElement !== "undefined" && background.element instanceof HTMLVideoElement) ||
|
|
5127
|
+
(typeof HTMLImageElement !== "undefined" && background.element instanceof HTMLImageElement)) {
|
|
4978
5128
|
this.#backgroundElement = background.element;
|
|
4979
5129
|
}
|
|
4980
5130
|
}
|
|
@@ -5042,6 +5192,7 @@
|
|
|
5042
5192
|
zoom = defaultZoom;
|
|
5043
5193
|
#container;
|
|
5044
5194
|
#generated;
|
|
5195
|
+
#hdrMediaListeners;
|
|
5045
5196
|
#mutationObserver;
|
|
5046
5197
|
#originalStyle;
|
|
5047
5198
|
#pluginManager;
|
|
@@ -5106,7 +5257,6 @@
|
|
|
5106
5257
|
});
|
|
5107
5258
|
this.resize();
|
|
5108
5259
|
this.#initStyle();
|
|
5109
|
-
this.initBackground();
|
|
5110
5260
|
this.#safeMutationObserver(obs => {
|
|
5111
5261
|
const element = this.domElement;
|
|
5112
5262
|
if (!element || !(element instanceof Node)) {
|
|
@@ -5116,6 +5266,8 @@
|
|
|
5116
5266
|
});
|
|
5117
5267
|
this.initPlugins();
|
|
5118
5268
|
this.#initContext();
|
|
5269
|
+
this.initBackground();
|
|
5270
|
+
this.#initHdrListeners();
|
|
5119
5271
|
this.render.init();
|
|
5120
5272
|
}
|
|
5121
5273
|
initBackground() {
|
|
@@ -5125,7 +5277,8 @@
|
|
|
5125
5277
|
}
|
|
5126
5278
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
5127
5279
|
if (color) {
|
|
5128
|
-
|
|
5280
|
+
const hdrOptions = container.actualOptions.hdr;
|
|
5281
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity, hdrOptions.peakNits, hdrOptions.mode);
|
|
5129
5282
|
}
|
|
5130
5283
|
else {
|
|
5131
5284
|
elementStyle.backgroundColor = "";
|
|
@@ -5222,6 +5375,7 @@
|
|
|
5222
5375
|
obs.disconnect();
|
|
5223
5376
|
});
|
|
5224
5377
|
this.#mutationObserver = undefined;
|
|
5378
|
+
this.#removeHdrListeners();
|
|
5225
5379
|
this.render.stop();
|
|
5226
5380
|
}
|
|
5227
5381
|
async windowResize() {
|
|
@@ -5241,9 +5395,16 @@
|
|
|
5241
5395
|
}
|
|
5242
5396
|
}
|
|
5243
5397
|
#initContext() {
|
|
5244
|
-
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
5398
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr.enable &&
|
|
5245
5399
|
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
5246
5400
|
safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
5401
|
+
container.hdr = canSupportHdr ?? false;
|
|
5402
|
+
container.hdrMode = container.actualOptions.hdr.mode;
|
|
5403
|
+
container.peakNits = container.actualOptions.hdr.peakNits;
|
|
5404
|
+
const renderCanvas = this.renderCanvas;
|
|
5405
|
+
if (!renderCanvas) {
|
|
5406
|
+
return;
|
|
5407
|
+
}
|
|
5247
5408
|
this.render.setContextSettings({
|
|
5248
5409
|
alpha: true,
|
|
5249
5410
|
desynchronized: true,
|
|
@@ -5252,11 +5413,47 @@
|
|
|
5252
5413
|
? { colorSpace: "display-p3", colorType: "float16" }
|
|
5253
5414
|
: { colorSpace: "srgb" }),
|
|
5254
5415
|
});
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5416
|
+
let context;
|
|
5417
|
+
try {
|
|
5418
|
+
context = renderCanvas.getContext("2d", this.render.settings);
|
|
5419
|
+
}
|
|
5420
|
+
catch {
|
|
5421
|
+
context = null;
|
|
5422
|
+
}
|
|
5423
|
+
if (canSupportHdr && !context) {
|
|
5424
|
+
container.hdr = false;
|
|
5425
|
+
const sdrSettings = {
|
|
5426
|
+
alpha: true,
|
|
5427
|
+
desynchronized: true,
|
|
5428
|
+
willReadFrequently: false,
|
|
5429
|
+
colorSpace: "srgb",
|
|
5430
|
+
};
|
|
5431
|
+
this.render.setContextSettings(sdrSettings);
|
|
5432
|
+
try {
|
|
5433
|
+
context = renderCanvas.getContext("2d", sdrSettings);
|
|
5434
|
+
}
|
|
5435
|
+
catch {
|
|
5436
|
+
context = null;
|
|
5437
|
+
}
|
|
5438
|
+
}
|
|
5439
|
+
this.render.setContext(context);
|
|
5440
|
+
}
|
|
5441
|
+
#initHdrListeners() {
|
|
5442
|
+
this.#removeHdrListeners();
|
|
5443
|
+
const p3Query = safeMatchMedia("(color-gamut: p3)"), hdrQuery = safeMatchMedia("(dynamic-range: high)"), handleChange = () => {
|
|
5444
|
+
this.#recreateRenderCanvas();
|
|
5445
|
+
this.#initContext();
|
|
5446
|
+
this.initBackground();
|
|
5447
|
+
}, listeners = [];
|
|
5448
|
+
if (p3Query) {
|
|
5449
|
+
p3Query.addEventListener("change", handleChange);
|
|
5450
|
+
listeners.push({ handler: handleChange, mql: p3Query });
|
|
5451
|
+
}
|
|
5452
|
+
if (hdrQuery) {
|
|
5453
|
+
hdrQuery.addEventListener("change", handleChange);
|
|
5454
|
+
listeners.push({ handler: handleChange, mql: hdrQuery });
|
|
5258
5455
|
}
|
|
5259
|
-
this
|
|
5456
|
+
this.#hdrMediaListeners = listeners;
|
|
5260
5457
|
}
|
|
5261
5458
|
#initStyle() {
|
|
5262
5459
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
@@ -5280,6 +5477,25 @@
|
|
|
5280
5477
|
element.style.setProperty(key, value, "important");
|
|
5281
5478
|
}
|
|
5282
5479
|
}
|
|
5480
|
+
#recreateRenderCanvas() {
|
|
5481
|
+
const renderCanvas = this.renderCanvas;
|
|
5482
|
+
if (!renderCanvas) {
|
|
5483
|
+
return;
|
|
5484
|
+
}
|
|
5485
|
+
if (this.domElement) {
|
|
5486
|
+
return;
|
|
5487
|
+
}
|
|
5488
|
+
this.renderCanvas = new OffscreenCanvas(renderCanvas.width, renderCanvas.height);
|
|
5489
|
+
}
|
|
5490
|
+
#removeHdrListeners() {
|
|
5491
|
+
if (!this.#hdrMediaListeners) {
|
|
5492
|
+
return;
|
|
5493
|
+
}
|
|
5494
|
+
for (const { handler, mql } of this.#hdrMediaListeners) {
|
|
5495
|
+
mql.removeEventListener("change", handler);
|
|
5496
|
+
}
|
|
5497
|
+
this.#hdrMediaListeners = undefined;
|
|
5498
|
+
}
|
|
5283
5499
|
#repairStyle() {
|
|
5284
5500
|
const element = this.domElement;
|
|
5285
5501
|
if (!element) {
|
|
@@ -5664,9 +5880,9 @@
|
|
|
5664
5880
|
}
|
|
5665
5881
|
getOpacity() {
|
|
5666
5882
|
const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, baseOpacity = getRangeValue(this.opacity?.value ?? defaultOpacity$1), modifierOpacity = this.#applyModifiers(undefined, m => m.opacity), opacity = modifierOpacity ?? baseOpacity, fillOpacity = this.fillOpacity ?? defaultOpacity$1, strokeOpacity = this.strokeOpacity ?? defaultOpacity$1;
|
|
5667
|
-
this.#cachedOpacityData.fillOpacity =
|
|
5883
|
+
this.#cachedOpacityData.fillOpacity = fillOpacity;
|
|
5668
5884
|
this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
5669
|
-
this.#cachedOpacityData.strokeOpacity =
|
|
5885
|
+
this.#cachedOpacityData.strokeOpacity = strokeOpacity;
|
|
5670
5886
|
return this.#cachedOpacityData;
|
|
5671
5887
|
}
|
|
5672
5888
|
getPosition() {
|
|
@@ -6521,6 +6737,7 @@
|
|
|
6521
6737
|
effectDrawers;
|
|
6522
6738
|
fpsLimit;
|
|
6523
6739
|
hdr;
|
|
6740
|
+
hdrMode;
|
|
6524
6741
|
id;
|
|
6525
6742
|
pageHidden;
|
|
6526
6743
|
particleCreatedPlugins;
|
|
@@ -6528,6 +6745,7 @@
|
|
|
6528
6745
|
particlePositionPlugins;
|
|
6529
6746
|
particleUpdaters;
|
|
6530
6747
|
particles;
|
|
6748
|
+
peakNits;
|
|
6531
6749
|
plugins;
|
|
6532
6750
|
retina;
|
|
6533
6751
|
shapeDrawers;
|
|
@@ -6558,6 +6776,8 @@
|
|
|
6558
6776
|
this.id = Symbol(id);
|
|
6559
6777
|
this.fpsLimit = 120;
|
|
6560
6778
|
this.hdr = false;
|
|
6779
|
+
this.hdrMode = exports.HdrMode.standard;
|
|
6780
|
+
this.peakNits = 400;
|
|
6561
6781
|
this.#smooth = false;
|
|
6562
6782
|
this.#delay = 0;
|
|
6563
6783
|
this.#duration = 0;
|
|
@@ -6697,8 +6917,9 @@
|
|
|
6697
6917
|
this.updateActualOptions();
|
|
6698
6918
|
this.canvas.initBackground();
|
|
6699
6919
|
this.canvas.resize();
|
|
6700
|
-
const { delay, duration, fpsLimit,
|
|
6701
|
-
this.
|
|
6920
|
+
const { delay, duration, fpsLimit, smooth, zLayers } = this.actualOptions, hdrOptions = this.actualOptions.hdr;
|
|
6921
|
+
this.hdrMode = hdrOptions.mode;
|
|
6922
|
+
this.peakNits = hdrOptions.peakNits;
|
|
6702
6923
|
this.zLayers = zLayers;
|
|
6703
6924
|
this.#duration = getRangeValue(duration) * millisecondsToSeconds$1;
|
|
6704
6925
|
this.#delay = getRangeValue(delay) * millisecondsToSeconds$1;
|
|
@@ -7695,6 +7916,7 @@
|
|
|
7695
7916
|
exports.ColorAnimation = ColorAnimation;
|
|
7696
7917
|
exports.Fill = Fill;
|
|
7697
7918
|
exports.FullScreen = FullScreen;
|
|
7919
|
+
exports.HDROptions = HDROptions;
|
|
7698
7920
|
exports.HslAnimation = HslAnimation;
|
|
7699
7921
|
exports.Move = Move;
|
|
7700
7922
|
exports.MoveAngle = MoveAngle;
|