function hexToRGBA(hex, opacity) {
  const rgb = hexToRGBArray(hex);
  let a = 0.3;

  if (typeof Number.parseInt(opacity) === "number") {
    a = opacity;
  }

  return `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${a})`;
}
Convert HEX to RGBA
@param {string} hex 3 digits + # or 6 digits + #
@param {number?} opacity From 0 to 1