From a7e80ab4ba0fc61af7164951b06b91ab2764196e Mon Sep 17 00:00:00 2001 From: Lucie Bader <167515375+Lucie-Bdr@users.noreply.github.com> Date: Mon, 24 Feb 2025 13:45:05 +0100 Subject: [PATCH] Correction bug surlignage --- src/assets/lexicon_icon.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/assets/lexicon_icon.js b/src/assets/lexicon_icon.js index d3bec91..fa5852f 100644 --- a/src/assets/lexicon_icon.js +++ b/src/assets/lexicon_icon.js @@ -110,6 +110,20 @@ async function getColorForLexicon(lexiconId) { return (lexiconColors && lexiconColors[String(lexiconId)]) || "#cccccc"; } +/** + * Convertit une couleur hexadécimale en une couleur RGBA. + * @param {string} hex - La couleur en hexadécimal. + * @param {number} opacity - La transparence (0-1). + * @returns {string} La couleur RGBA. + */ +function hexToRgba(hex, opacity) { + const bigint = parseInt(hex.replace('#', ''), 16); + const r = (bigint >> 16) & 255; + const g = (bigint >> 8) & 255; + const b = bigint & 255; + return `rgba(${r}, ${g}, ${b}, ${opacity})`; +} + // Expose les fonctions globalement window.updateLexiconColors = updateLexiconColors; window.getColorForLexicon = getColorForLexicon; @@ -117,3 +131,4 @@ window.convertColor = convertColor; window.getOrCreateLexiconColor = getOrCreateLexiconColor; window.createColorCircle = createColorCircle; window.getLexiconsColors = getLexiconsColors; +window.hexToRgba = hexToRgba; -- GitLab