@tsparticles/slim 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.
@@ -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.3.1 */
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$3 = 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 === "__proto__" || key === "constructor" || key === "prototype") {
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 === "__proto__" || key === "constructor" || key === "prototype") {
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.3.1";
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
- obj[key] = deepExtend(obj[key] ?? {}, value);
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 = true;
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
- loadProperty(this, "hdr", data.hdr);
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, hdrAnimationScale = sdrReferenceWhiteNits / maxNits;
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 = `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
2027
- return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
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 ${((color.r / rgbMax) * headroom).toString()} ${((color.g / rgbMax) * headroom).toString()} ${((color.b / rgbMax) * headroom).toString()} / ${(opacity ?? defaultOpacity$3).toString()})`;
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 = `hsl-${color.h.toFixed(hslPrecision)}-${color.s.toFixed(hslPrecision)}-${color.l.toFixed(hslPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
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, hdr) {
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 = ((data.velocity ?? minVelocity) * delta.factor + offset * velocityFactor) * (hdr ? hdrAnimationScale : identity), decay = data.decay ?? identity, max = data.max, min = data.min;
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, hdr);
2205
- updateColorValue(s, true, delta, hdr);
2206
- updateColorValue(l, true, delta, hdr);
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.3.1");
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.3.1");
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.3.1");
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.3.1");
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.3.1");
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();
@@ -2631,7 +2761,7 @@
2631
2761
  }
2632
2762
 
2633
2763
  async function loadOpacityUpdater(engine) {
2634
- engine.checkVersion("4.3.1");
2764
+ engine.checkVersion("4.4.0");
2635
2765
  await engine.pluginManager.register(e => {
2636
2766
  e.pluginManager.addParticleUpdater("opacity", container => {
2637
2767
  return Promise.resolve(new OpacityUpdater(container));
@@ -2976,7 +3106,7 @@
2976
3106
  }
2977
3107
 
2978
3108
  async function loadOutModesUpdater(engine) {
2979
- engine.checkVersion("4.3.1");
3109
+ engine.checkVersion("4.4.0");
2980
3110
  await engine.pluginManager.register(e => {
2981
3111
  e.pluginManager.addParticleUpdater("outModes", container => {
2982
3112
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3047,7 +3177,7 @@
3047
3177
  }
3048
3178
 
3049
3179
  async function loadPaintUpdater(engine) {
3050
- engine.checkVersion("4.3.1");
3180
+ engine.checkVersion("4.4.0");
3051
3181
  await engine.pluginManager.register(e => {
3052
3182
  e.pluginManager.addParticleUpdater("paint", container => {
3053
3183
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3102,7 +3232,7 @@
3102
3232
  }
3103
3233
 
3104
3234
  async function loadRgbColorPlugin(engine) {
3105
- engine.checkVersion("4.3.1");
3235
+ engine.checkVersion("4.4.0");
3106
3236
  await engine.pluginManager.register(e => {
3107
3237
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3108
3238
  });
@@ -3187,7 +3317,7 @@
3187
3317
  }
3188
3318
 
3189
3319
  async function loadSizeUpdater(engine) {
3190
- engine.checkVersion("4.3.1");
3320
+ engine.checkVersion("4.4.0");
3191
3321
  await engine.pluginManager.register(e => {
3192
3322
  e.pluginManager.addParticleUpdater("size", container => {
3193
3323
  return Promise.resolve(new SizeUpdater(container));
@@ -3196,7 +3326,7 @@
3196
3326
  }
3197
3327
 
3198
3328
  async function loadBasic(engine) {
3199
- engine.checkVersion("4.3.1");
3329
+ engine.checkVersion("4.4.0");
3200
3330
  await engine.pluginManager.register(async (e) => {
3201
3331
  await Promise.all([
3202
3332
  loadBlendPlugin(e),
@@ -3219,7 +3349,7 @@
3219
3349
  easingsFunctions.set("ease-in-out-quad", value => (value < 0.5 ? 2 * value ** 2 : 1 - (-2 * value + 2) ** 2 / 2));
3220
3350
 
3221
3351
  async function loadEasingQuadPlugin(engine) {
3222
- engine.checkVersion("4.3.1");
3352
+ engine.checkVersion("4.4.0");
3223
3353
  await engine.pluginManager.register(e => {
3224
3354
  for (const [easing, easingFn] of easingsFunctions) {
3225
3355
  e.pluginManager.addEasing(easing, easingFn);
@@ -3327,7 +3457,7 @@
3327
3457
  }
3328
3458
 
3329
3459
  async function loadEmojiShape(engine) {
3330
- engine.checkVersion("4.3.1");
3460
+ engine.checkVersion("4.4.0");
3331
3461
  await engine.pluginManager.register(e => {
3332
3462
  e.pluginManager.addShape(validTypes, () => Promise.resolve(new EmojiDrawer()));
3333
3463
  });
@@ -3564,7 +3694,7 @@
3564
3694
  }
3565
3695
 
3566
3696
  async function loadInteractivityPlugin(engine) {
3567
- engine.checkVersion("4.3.1");
3697
+ engine.checkVersion("4.4.0");
3568
3698
  await engine.pluginManager.register(e => {
3569
3699
  const interactivityEngine = e, interactivityPluginManager = interactivityEngine.pluginManager;
3570
3700
  interactivityPluginManager.addPlugin(new InteractivityPlugin(interactivityPluginManager));
@@ -3824,7 +3954,7 @@
3824
3954
  };
3825
3955
 
3826
3956
  async function loadExternalAttractInteraction(engine) {
3827
- engine.checkVersion("4.3.1");
3957
+ engine.checkVersion("4.4.0");
3828
3958
  await engine.pluginManager.register((e) => {
3829
3959
  ensureInteractivityPluginLoaded(e);
3830
3960
  e.pluginManager.addInteractor?.("externalAttract", container => {
@@ -4013,7 +4143,7 @@
4013
4143
  }
4014
4144
 
4015
4145
  async function loadExternalBounceInteraction(engine) {
4016
- engine.checkVersion("4.3.1");
4146
+ engine.checkVersion("4.4.0");
4017
4147
  await engine.pluginManager.register((e) => {
4018
4148
  ensureInteractivityPluginLoaded(e);
4019
4149
  e.pluginManager.addInteractor?.("externalBounce", container => {
@@ -4300,7 +4430,7 @@
4300
4430
  mod.strokeColor = undefined;
4301
4431
  const pColor = particle.getFillColor();
4302
4432
  if (pColor) {
4303
- const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio));
4433
+ const mixedColor = rgbToHsl(colorMix(pColor, mod.finalColor, ratioOffset - ratio, ratio, this.container.hdr));
4304
4434
  mod.fillColor = mixedColor;
4305
4435
  mod.strokeColor = mixedColor;
4306
4436
  }
@@ -4413,7 +4543,7 @@
4413
4543
  }
4414
4544
 
4415
4545
  async function loadExternalBubbleInteraction(engine) {
4416
- engine.checkVersion("4.3.1");
4546
+ engine.checkVersion("4.4.0");
4417
4547
  await engine.pluginManager.register((e) => {
4418
4548
  ensureInteractivityPluginLoaded(e);
4419
4549
  e.pluginManager.addInteractor?.("externalBubble", container => {
@@ -4452,10 +4582,10 @@
4452
4582
  if (!color1 || !color2) {
4453
4583
  return;
4454
4584
  }
4455
- 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);
4456
- grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity));
4457
- grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity));
4458
- grad.addColorStop(gradientMax, getStyleFromHsl(color2, container.hdr, opacity));
4585
+ const sourcePos = p1.getPosition(), destPos = p2.getPosition(), midRgb = colorMix(color1, color2, p1.getRadius(), p2.getRadius(), container.hdr), grad = context.createLinearGradient(sourcePos.x, sourcePos.y, destPos.x, destPos.y);
4586
+ grad.addColorStop(gradientMin, getStyleFromHsl(color1, container.hdr, opacity, container.peakNits, container.hdrMode));
4587
+ grad.addColorStop(clamp(gradStop, gradientMin, gradientMax), getStyleFromRgb(midRgb, container.hdr, opacity, container.peakNits, container.hdrMode));
4588
+ grad.addColorStop(gradientMax, getStyleFromHsl(color2, container.hdr, opacity, container.peakNits, container.hdrMode));
4459
4589
  return grad;
4460
4590
  }
4461
4591
  function drawConnectLine(context, width, lineStyle, begin, end) {
@@ -4541,7 +4671,7 @@
4541
4671
  }
4542
4672
 
4543
4673
  async function loadExternalConnectInteraction(engine) {
4544
- engine.checkVersion("4.3.1");
4674
+ engine.checkVersion("4.4.0");
4545
4675
  await engine.pluginManager.register((e) => {
4546
4676
  ensureInteractivityPluginLoaded(e);
4547
4677
  e.pluginManager.addInteractor?.("externalConnect", container => {
@@ -4645,7 +4775,7 @@
4645
4775
  }
4646
4776
 
4647
4777
  async function loadExternalDestroyInteraction(engine) {
4648
- engine.checkVersion("4.3.1");
4778
+ engine.checkVersion("4.4.0");
4649
4779
  await engine.pluginManager.register((e) => {
4650
4780
  ensureInteractivityPluginLoaded(e);
4651
4781
  e.pluginManager.addInteractor?.("externalDestroy", async (container) => {
@@ -4685,16 +4815,16 @@
4685
4815
  }
4686
4816
 
4687
4817
  const defaultWidth = 0;
4688
- function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false) {
4818
+ function drawGrabLine(context, width, begin, end, colorLine, opacity, hdr = false, peakNits, mode) {
4689
4819
  drawLine$1(context, begin, end);
4690
- context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity);
4820
+ context.strokeStyle = getStyleFromRgb(colorLine, hdr, opacity, peakNits, mode);
4691
4821
  context.lineWidth = width;
4692
4822
  context.stroke();
4693
4823
  }
4694
4824
  function drawGrab(container, particle, lineColor, opacity, mousePos) {
4695
4825
  container.canvas.render.draw(ctx => {
4696
4826
  const beginPos = particle.getPosition();
4697
- drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr);
4827
+ drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity, container.hdr, container.peakNits, container.hdrMode);
4698
4828
  });
4699
4829
  }
4700
4830
 
@@ -4750,7 +4880,7 @@
4750
4880
  const linksOptions = interactivity.modes.grab.links;
4751
4881
  container.particles.grabLineColor = getLinkRandomColor(this.#pluginManager, optColor, linksOptions.blink, linksOptions.consent);
4752
4882
  }
4753
- const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor);
4883
+ const colorLine = getLinkColor(particle, undefined, container.particles.grabLineColor, container.hdr);
4754
4884
  if (!colorLine) {
4755
4885
  continue;
4756
4886
  }
@@ -4769,7 +4899,7 @@
4769
4899
  }
4770
4900
 
4771
4901
  async function loadExternalGrabInteraction(engine) {
4772
- engine.checkVersion("4.3.1");
4902
+ engine.checkVersion("4.4.0");
4773
4903
  await engine.pluginManager.register((e) => {
4774
4904
  ensureInteractivityPluginLoaded(e);
4775
4905
  e.pluginManager.addInteractor?.("externalGrab", container => {
@@ -4839,7 +4969,7 @@
4839
4969
  }
4840
4970
 
4841
4971
  async function loadExternalParallaxInteraction(engine) {
4842
- engine.checkVersion("4.3.1");
4972
+ engine.checkVersion("4.4.0");
4843
4973
  await engine.pluginManager.register((e) => {
4844
4974
  ensureInteractivityPluginLoaded(e);
4845
4975
  e.pluginManager.addInteractor?.("externalParallax", container => {
@@ -4882,7 +5012,7 @@
4882
5012
  }
4883
5013
 
4884
5014
  async function loadExternalPauseInteraction(engine) {
4885
- engine.checkVersion("4.3.1");
5015
+ engine.checkVersion("4.4.0");
4886
5016
  await engine.pluginManager.register((e) => {
4887
5017
  ensureInteractivityPluginLoaded(e);
4888
5018
  e.pluginManager.addInteractor?.("externalPause", container => {
@@ -4954,7 +5084,7 @@
4954
5084
  }
4955
5085
 
4956
5086
  async function loadExternalPushInteraction(engine) {
4957
- engine.checkVersion("4.3.1");
5087
+ engine.checkVersion("4.4.0");
4958
5088
  await engine.pluginManager.register((e) => {
4959
5089
  ensureInteractivityPluginLoaded(e);
4960
5090
  e.pluginManager.addInteractor?.("externalPush", container => {
@@ -5008,7 +5138,7 @@
5008
5138
  }
5009
5139
 
5010
5140
  async function loadExternalRemoveInteraction(engine) {
5011
- engine.checkVersion("4.3.1");
5141
+ engine.checkVersion("4.4.0");
5012
5142
  await engine.pluginManager.register((e) => {
5013
5143
  ensureInteractivityPluginLoaded(e);
5014
5144
  e.pluginManager.addInteractor?.("externalRemove", container => {
@@ -5314,7 +5444,7 @@
5314
5444
  }
5315
5445
 
5316
5446
  async function loadExternalRepulseInteraction(engine) {
5317
- engine.checkVersion("4.3.1");
5447
+ engine.checkVersion("4.4.0");
5318
5448
  await engine.pluginManager.register((e) => {
5319
5449
  ensureInteractivityPluginLoaded(e);
5320
5450
  const pluginManager = e.pluginManager;
@@ -5408,7 +5538,7 @@
5408
5538
  }
5409
5539
 
5410
5540
  async function loadExternalSlowInteraction(engine) {
5411
- engine.checkVersion("4.3.1");
5541
+ engine.checkVersion("4.4.0");
5412
5542
  await engine.pluginManager.register((e) => {
5413
5543
  ensureInteractivityPluginLoaded(e);
5414
5544
  e.pluginManager.addInteractor?.("externalSlow", container => {
@@ -5420,12 +5550,12 @@
5420
5550
  const shapeTypes = ["image", "images"];
5421
5551
  const stringStart = 0, defaultOpacity = 1;
5422
5552
  const currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;
5423
- function replaceColorSvg(imageShape, color, opacity, hdr = false) {
5553
+ function replaceColorSvg(imageShape, color, opacity, hdr = false, peakNits, mode) {
5424
5554
  const { svgData } = imageShape;
5425
5555
  if (!svgData) {
5426
5556
  return "";
5427
5557
  }
5428
- const colorStyle = getStyleFromHsl(color, hdr, opacity);
5558
+ const colorStyle = getStyleFromHsl(color, hdr, opacity, peakNits, mode);
5429
5559
  if (svgData.includes("fill")) {
5430
5560
  return svgData.replaceAll(currentColorRegex, () => colorStyle);
5431
5561
  }
@@ -5467,8 +5597,8 @@
5467
5597
  }
5468
5598
  image.loading = false;
5469
5599
  }
5470
- function replaceImageColor(image, imageData, color, particle, hdr = false) {
5471
- const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity, hdr), imageRes = {
5600
+ function replaceImageColor(image, imageData, color, particle, hdr = false, peakNits, mode) {
5601
+ const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity, hdr, peakNits, mode), imageRes = {
5472
5602
  color,
5473
5603
  data: {
5474
5604
  ...image,
@@ -5580,7 +5710,7 @@
5580
5710
  void (async () => {
5581
5711
  let imageRes;
5582
5712
  if (image.svgData && color) {
5583
- imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr);
5713
+ imageRes = await replaceImageColor(image, imageData, color, particle, container.hdr, container.peakNits, container.hdrMode);
5584
5714
  }
5585
5715
  else {
5586
5716
  imageRes = {
@@ -5717,7 +5847,7 @@
5717
5847
  };
5718
5848
  }
5719
5849
  async function loadImageShape(engine) {
5720
- engine.checkVersion("4.3.1");
5850
+ engine.checkVersion("4.4.0");
5721
5851
  await engine.pluginManager.register(e => {
5722
5852
  addLoadImageToEngine(e);
5723
5853
  e.pluginManager.addPlugin(new ImagePreloaderPlugin(e));
@@ -5862,7 +5992,7 @@
5862
5992
  }
5863
5993
 
5864
5994
  async function loadLifeUpdater(engine) {
5865
- engine.checkVersion("4.3.1");
5995
+ engine.checkVersion("4.4.0");
5866
5996
  await engine.pluginManager.register(e => {
5867
5997
  e.pluginManager.addParticleUpdater("life", container => {
5868
5998
  return Promise.resolve(new LifeUpdater(container));
@@ -5888,7 +6018,7 @@
5888
6018
  }
5889
6019
 
5890
6020
  async function loadLineShape(engine) {
5891
- engine.checkVersion("4.3.1");
6021
+ engine.checkVersion("4.4.0");
5892
6022
  await engine.pluginManager.register(e => {
5893
6023
  e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
5894
6024
  });
@@ -5972,7 +6102,7 @@
5972
6102
  }
5973
6103
 
5974
6104
  async function loadParticlesAttractInteraction(engine) {
5975
- engine.checkVersion("4.3.1");
6105
+ engine.checkVersion("4.4.0");
5976
6106
  await engine.pluginManager.register((e) => {
5977
6107
  ensureInteractivityPluginLoaded(e);
5978
6108
  e.pluginManager.addInteractor?.("particlesAttract", container => {
@@ -6182,7 +6312,7 @@
6182
6312
  }
6183
6313
 
6184
6314
  async function loadParticlesCollisionsInteraction(engine) {
6185
- engine.checkVersion("4.3.1");
6315
+ engine.checkVersion("4.4.0");
6186
6316
  await engine.pluginManager.register((e) => {
6187
6317
  ensureInteractivityPluginLoaded(e);
6188
6318
  e.pluginManager.addPlugin(new OverlapPlugin());
@@ -6395,7 +6525,7 @@
6395
6525
  const linkColor = linksOptions.id !== undefined
6396
6526
  ? container.particles.linksColors.get(linksOptions.id)
6397
6527
  : container.particles.linksColor;
6398
- return getLinkColor(p1, p2, linkColor);
6528
+ return getLinkColor(p1, p2, linkColor, container.hdr);
6399
6529
  }
6400
6530
  #setColor(p1) {
6401
6531
  if (!p1.options.links) {
@@ -6436,7 +6566,7 @@
6436
6566
  }
6437
6567
 
6438
6568
  async function loadParticlesLinksInteraction(engine) {
6439
- engine.checkVersion("4.3.1");
6569
+ engine.checkVersion("4.4.0");
6440
6570
  await engine.pluginManager.register((e) => {
6441
6571
  const pluginManager = e.pluginManager;
6442
6572
  ensureInteractivityPluginLoaded(e);
@@ -6526,19 +6656,19 @@
6526
6656
  }
6527
6657
 
6528
6658
  async function loadGenericPolygonShape(engine) {
6529
- engine.checkVersion("4.3.1");
6659
+ engine.checkVersion("4.4.0");
6530
6660
  await engine.pluginManager.register(e => {
6531
6661
  e.pluginManager.addShape(["polygon"], () => Promise.resolve(new PolygonDrawer()));
6532
6662
  });
6533
6663
  }
6534
6664
  async function loadTriangleShape(engine) {
6535
- engine.checkVersion("4.3.1");
6665
+ engine.checkVersion("4.4.0");
6536
6666
  await engine.pluginManager.register(e => {
6537
6667
  e.pluginManager.addShape(["triangle"], () => Promise.resolve(new TriangleDrawer()));
6538
6668
  });
6539
6669
  }
6540
6670
  async function loadPolygonShape(engine) {
6541
- engine.checkVersion("4.3.1");
6671
+ engine.checkVersion("4.4.0");
6542
6672
  await Promise.all([
6543
6673
  loadGenericPolygonShape(engine),
6544
6674
  loadTriangleShape(engine),
@@ -6643,7 +6773,7 @@
6643
6773
  }
6644
6774
 
6645
6775
  async function loadRotateUpdater(engine) {
6646
- engine.checkVersion("4.3.1");
6776
+ engine.checkVersion("4.4.0");
6647
6777
  await engine.pluginManager.register(e => {
6648
6778
  e.pluginManager.addParticleUpdater("rotate", container => {
6649
6779
  return Promise.resolve(new RotateUpdater(container));
@@ -6667,7 +6797,7 @@
6667
6797
  }
6668
6798
 
6669
6799
  async function loadSquareShape(engine) {
6670
- engine.checkVersion("4.3.1");
6800
+ engine.checkVersion("4.4.0");
6671
6801
  await engine.pluginManager.register(e => {
6672
6802
  e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
6673
6803
  });
@@ -6701,14 +6831,14 @@
6701
6831
  }
6702
6832
 
6703
6833
  async function loadStarShape(engine) {
6704
- engine.checkVersion("4.3.1");
6834
+ engine.checkVersion("4.4.0");
6705
6835
  await engine.pluginManager.register(e => {
6706
6836
  e.pluginManager.addShape(["star"], () => Promise.resolve(new StarDrawer()));
6707
6837
  });
6708
6838
  }
6709
6839
 
6710
6840
  async function loadSlim(engine) {
6711
- engine.checkVersion("4.3.1");
6841
+ engine.checkVersion("4.4.0");
6712
6842
  await engine.pluginManager.register(async (e) => {
6713
6843
  const loadInteractivityForSlim = async (e) => {
6714
6844
  await loadInteractivityPlugin(e);
@@ -6869,7 +6999,11 @@
6869
6999
  if (!fColor && !sColor) {
6870
7000
  return;
6871
7001
  }
6872
- 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 ? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity) : undefined, stroke = sColor ? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity) : fill;
7002
+ const container = this.#container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this.#reusableTransform, colorStyles = this.#reusableColorStyles, fill = fColor
7003
+ ? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity, container.peakNits, container.hdrMode)
7004
+ : undefined, stroke = sColor
7005
+ ? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity, container.peakNits, container.hdrMode)
7006
+ : fill;
6873
7007
  transform.a = transform.b = transform.c = transform.d = undefined;
6874
7008
  colorStyles.fill = fill;
6875
7009
  colorStyles.stroke = stroke;
@@ -7203,7 +7337,9 @@
7203
7337
  if (typeof background.element === "string") {
7204
7338
  if (typeof document !== "undefined") {
7205
7339
  const node = document.querySelector(background.element);
7206
- if (node instanceof HTMLCanvasElement || node instanceof HTMLVideoElement || node instanceof HTMLImageElement) {
7340
+ if ((typeof HTMLCanvasElement !== "undefined" && node instanceof HTMLCanvasElement) ||
7341
+ (typeof HTMLVideoElement !== "undefined" && node instanceof HTMLVideoElement) ||
7342
+ (typeof HTMLImageElement !== "undefined" && node instanceof HTMLImageElement)) {
7207
7343
  this.#backgroundElement = node;
7208
7344
  }
7209
7345
  else if (node) {
@@ -7214,10 +7350,10 @@
7214
7350
  }
7215
7351
  }
7216
7352
  }
7217
- else if (background.element instanceof HTMLCanvasElement ||
7218
- background.element instanceof OffscreenCanvas ||
7219
- background.element instanceof HTMLVideoElement ||
7220
- background.element instanceof HTMLImageElement) {
7353
+ else if ((typeof HTMLCanvasElement !== "undefined" && background.element instanceof HTMLCanvasElement) ||
7354
+ (typeof OffscreenCanvas !== "undefined" && background.element instanceof OffscreenCanvas) ||
7355
+ (typeof HTMLVideoElement !== "undefined" && background.element instanceof HTMLVideoElement) ||
7356
+ (typeof HTMLImageElement !== "undefined" && background.element instanceof HTMLImageElement)) {
7221
7357
  this.#backgroundElement = background.element;
7222
7358
  }
7223
7359
  }
@@ -7285,6 +7421,7 @@
7285
7421
  zoom = defaultZoom;
7286
7422
  #container;
7287
7423
  #generated;
7424
+ #hdrMediaListeners;
7288
7425
  #mutationObserver;
7289
7426
  #originalStyle;
7290
7427
  #pluginManager;
@@ -7349,7 +7486,6 @@
7349
7486
  });
7350
7487
  this.resize();
7351
7488
  this.#initStyle();
7352
- this.initBackground();
7353
7489
  this.#safeMutationObserver(obs => {
7354
7490
  const element = this.domElement;
7355
7491
  if (!element || !(element instanceof Node)) {
@@ -7359,6 +7495,8 @@
7359
7495
  });
7360
7496
  this.initPlugins();
7361
7497
  this.#initContext();
7498
+ this.initBackground();
7499
+ this.#initHdrListeners();
7362
7500
  this.render.init();
7363
7501
  }
7364
7502
  initBackground() {
@@ -7368,7 +7506,8 @@
7368
7506
  }
7369
7507
  const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
7370
7508
  if (color) {
7371
- elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
7509
+ const hdrOptions = container.actualOptions.hdr;
7510
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity, hdrOptions.peakNits, hdrOptions.mode);
7372
7511
  }
7373
7512
  else {
7374
7513
  elementStyle.backgroundColor = "";
@@ -7465,6 +7604,7 @@
7465
7604
  obs.disconnect();
7466
7605
  });
7467
7606
  this.#mutationObserver = undefined;
7607
+ this.#removeHdrListeners();
7468
7608
  this.render.stop();
7469
7609
  }
7470
7610
  async windowResize() {
@@ -7484,9 +7624,16 @@
7484
7624
  }
7485
7625
  }
7486
7626
  #initContext() {
7487
- const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
7627
+ const container = this.#container, canSupportHdr = container.actualOptions.hdr.enable &&
7488
7628
  safeMatchMedia("(color-gamut: p3)")?.matches &&
7489
7629
  safeMatchMedia("(dynamic-range: high)")?.matches;
7630
+ container.hdr = canSupportHdr ?? false;
7631
+ container.hdrMode = container.actualOptions.hdr.mode;
7632
+ container.peakNits = container.actualOptions.hdr.peakNits;
7633
+ const renderCanvas = this.renderCanvas;
7634
+ if (!renderCanvas) {
7635
+ return;
7636
+ }
7490
7637
  this.render.setContextSettings({
7491
7638
  alpha: true,
7492
7639
  desynchronized: true,
@@ -7495,11 +7642,47 @@
7495
7642
  ? { colorSpace: "display-p3", colorType: "float16" }
7496
7643
  : { colorSpace: "srgb" }),
7497
7644
  });
7498
- const renderCanvas = this.renderCanvas;
7499
- if (!renderCanvas) {
7500
- return;
7645
+ let context;
7646
+ try {
7647
+ context = renderCanvas.getContext("2d", this.render.settings);
7501
7648
  }
7502
- this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
7649
+ catch {
7650
+ context = null;
7651
+ }
7652
+ if (canSupportHdr && !context) {
7653
+ container.hdr = false;
7654
+ const sdrSettings = {
7655
+ alpha: true,
7656
+ desynchronized: true,
7657
+ willReadFrequently: false,
7658
+ colorSpace: "srgb",
7659
+ };
7660
+ this.render.setContextSettings(sdrSettings);
7661
+ try {
7662
+ context = renderCanvas.getContext("2d", sdrSettings);
7663
+ }
7664
+ catch {
7665
+ context = null;
7666
+ }
7667
+ }
7668
+ this.render.setContext(context);
7669
+ }
7670
+ #initHdrListeners() {
7671
+ this.#removeHdrListeners();
7672
+ const p3Query = safeMatchMedia("(color-gamut: p3)"), hdrQuery = safeMatchMedia("(dynamic-range: high)"), handleChange = () => {
7673
+ this.#recreateRenderCanvas();
7674
+ this.#initContext();
7675
+ this.initBackground();
7676
+ }, listeners = [];
7677
+ if (p3Query) {
7678
+ p3Query.addEventListener("change", handleChange);
7679
+ listeners.push({ handler: handleChange, mql: p3Query });
7680
+ }
7681
+ if (hdrQuery) {
7682
+ hdrQuery.addEventListener("change", handleChange);
7683
+ listeners.push({ handler: handleChange, mql: hdrQuery });
7684
+ }
7685
+ this.#hdrMediaListeners = listeners;
7503
7686
  }
7504
7687
  #initStyle() {
7505
7688
  const element = this.domElement, options = this.#container.actualOptions;
@@ -7523,6 +7706,25 @@
7523
7706
  element.style.setProperty(key, value, "important");
7524
7707
  }
7525
7708
  }
7709
+ #recreateRenderCanvas() {
7710
+ const renderCanvas = this.renderCanvas;
7711
+ if (!renderCanvas) {
7712
+ return;
7713
+ }
7714
+ if (this.domElement) {
7715
+ return;
7716
+ }
7717
+ this.renderCanvas = new OffscreenCanvas(renderCanvas.width, renderCanvas.height);
7718
+ }
7719
+ #removeHdrListeners() {
7720
+ if (!this.#hdrMediaListeners) {
7721
+ return;
7722
+ }
7723
+ for (const { handler, mql } of this.#hdrMediaListeners) {
7724
+ mql.removeEventListener("change", handler);
7725
+ }
7726
+ this.#hdrMediaListeners = undefined;
7727
+ }
7526
7728
  #repairStyle() {
7527
7729
  const element = this.domElement;
7528
7730
  if (!element) {
@@ -7907,9 +8109,9 @@
7907
8109
  }
7908
8110
  getOpacity() {
7909
8111
  const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, baseOpacity = getRangeValue(this.opacity?.value ?? defaultOpacity$3), modifierOpacity = this.#applyModifiers(undefined, m => m.opacity), opacity = modifierOpacity ?? baseOpacity, fillOpacity = this.fillOpacity ?? defaultOpacity$3, strokeOpacity = this.strokeOpacity ?? defaultOpacity$3;
7910
- this.#cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
8112
+ this.#cachedOpacityData.fillOpacity = fillOpacity;
7911
8113
  this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
7912
- this.#cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
8114
+ this.#cachedOpacityData.strokeOpacity = strokeOpacity;
7913
8115
  return this.#cachedOpacityData;
7914
8116
  }
7915
8117
  getPosition() {
@@ -8764,6 +8966,7 @@
8764
8966
  effectDrawers;
8765
8967
  fpsLimit;
8766
8968
  hdr;
8969
+ hdrMode;
8767
8970
  id;
8768
8971
  pageHidden;
8769
8972
  particleCreatedPlugins;
@@ -8771,6 +8974,7 @@
8771
8974
  particlePositionPlugins;
8772
8975
  particleUpdaters;
8773
8976
  particles;
8977
+ peakNits;
8774
8978
  plugins;
8775
8979
  retina;
8776
8980
  shapeDrawers;
@@ -8801,6 +9005,8 @@
8801
9005
  this.id = Symbol(id);
8802
9006
  this.fpsLimit = 120;
8803
9007
  this.hdr = false;
9008
+ this.hdrMode = exports.HdrMode.standard;
9009
+ this.peakNits = 400;
8804
9010
  this.#smooth = false;
8805
9011
  this.#delay = 0;
8806
9012
  this.#duration = 0;
@@ -8940,8 +9146,9 @@
8940
9146
  this.updateActualOptions();
8941
9147
  this.canvas.initBackground();
8942
9148
  this.canvas.resize();
8943
- const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
8944
- this.hdr = hdr;
9149
+ const { delay, duration, fpsLimit, smooth, zLayers } = this.actualOptions, hdrOptions = this.actualOptions.hdr;
9150
+ this.hdrMode = hdrOptions.mode;
9151
+ this.peakNits = hdrOptions.peakNits;
8945
9152
  this.zLayers = zLayers;
8946
9153
  this.#duration = getRangeValue(duration) * millisecondsToSeconds;
8947
9154
  this.#delay = getRangeValue(delay) * millisecondsToSeconds;
@@ -10115,10 +10322,10 @@
10115
10322
  }
10116
10323
  }
10117
10324
  #getCachedStyle(rgb) {
10118
- const key = `${rgb.r},${rgb.g},${rgb.b}`;
10325
+ const key = `${rgb.r},${rgb.g},${rgb.b}-${this.#container.hdr}-${this.#container.peakNits}-${this.#container.hdrMode}`;
10119
10326
  let style = this.#colorCache.get(key);
10120
10327
  if (!style) {
10121
- style = getStyleFromRgb(rgb, this.#container.hdr);
10328
+ style = getStyleFromRgb(rgb, this.#container.hdr, undefined, this.#container.peakNits, this.#container.hdrMode);
10122
10329
  this.#colorCache.set(key, style);
10123
10330
  }
10124
10331
  return style;
@@ -10145,6 +10352,7 @@
10145
10352
  exports.ColorAnimation = ColorAnimation;
10146
10353
  exports.Fill = Fill;
10147
10354
  exports.FullScreen = FullScreen;
10355
+ exports.HDROptions = HDROptions;
10148
10356
  exports.HslAnimation = HslAnimation;
10149
10357
  exports.Move = Move;
10150
10358
  exports.MoveAngle = MoveAngle;