function colorRGB2Hex(color) { const rgb = color.split(','); const r = parseInt(rgb[0].split('(')[1]); const g = parseInt(rgb[1]); const b = parseInt(rgb[2].split(')')[0]); return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); } function hex2Rgba(hex, opacity) { const RGBA = "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + "," + opacity + ")"; return { red: parseInt("0x" + hex.slice(1, 3)), green: parseInt("0x" + hex.slice(3, 5)), blue: parseInt("0x" + hex.slice(5, 7)), rgba: RGBA } }