{"ScriptPreparationCode":"function addAlpha(color, opacity) {\r\n // coerce values so ti is between 0 and 1.\r\n const _opacity = Math.round(Math.min(Math.max(opacity || 1, 0), 1) * 255);\r\n return color \u002B _opacity.toString(16).toUpperCase();\r\n}\r\n\r\nfunction hex2rgba(hex, alpha = 1) {\r\n const [r, g, b] = hex.match(/\\w\\w/g).map(x =\u003E parseInt(x, 16));\r\n return \u0060rgba(${r},${g},${b},${alpha})\u0060;\r\n}\r\n\r\nfunction adjustHexOpacity(color, opacity) {\r\n const r = parseInt(color.slice(1, 3), 16);\r\n const g = parseInt(color.slice(3, 5), 16);\r\n const b = parseInt(color.slice(5, 7), 16);\r\n\r\n return \u0027rgba(\u0027 \u002B r \u002B \u0027, \u0027 \u002B g \u002B \u0027, \u0027 \u002B b \u002B \u0027, \u0027 \u002B opacity \u002B \u0027)\u0027;\r\n}\r\n\r\nfunction setOpacity(hex, alpha) {\r\n return \u0060${hex}${Math.floor(alpha * 255).toString(16).padStart(2, 0)}\u0060;\r\n}\r\n","TestCases":[{"Name":"addAlpha","Code":"addAlpha(\u0027FF0000\u0027, 0.5); ","IsDeferred":false},{"Name":"hex2rgba","Code":"hex2rgba(\u0027FF0000\u0027, 0.5); ","IsDeferred":false},{"Name":"adjustHexOpacity","Code":"adjustHexOpacity(\u0027FF0000\u0027, 0.5);","IsDeferred":false},{"Name":"setOpacity","Code":"setOpacity(\u0027FF0000\u0027, 0.5);","IsDeferred":false}]}