src/mode/shared/bar.js
function getRgbAColor(color, opacity) {
  const id = color + '&' + opacity;
  if (colorCache[id]) {
    return colorCache[id];
  }

  const div = document.createElement('div');
  div.style.background = color;
  document.body.appendChild(div);
  const computedColor = window.getComputedStyle(div).backgroundColor;
  document.body.removeChild(div);

  /* istanbul ignore if */
  if (!rgbReg.test(computedColor)) {
    return color;
  }

  return (colorCache[id] = `rgba(${
    extractRgbColor.exec(computedColor)[1]
  }, ${opacity})`);
}
function getRgbAColor(color, opacity) {
  const id = color + '&' + opacity;
  if (colorCache[id]) {
    return colorCache[id];
  }

  const div = document.createElement('div');
  div.style.background = color;
  document.body.appendChild(div);
  const computedColor = window.getComputedStyle(div).backgroundColor;
  document.body.removeChild(div);

  /* istanbul ignore if */
  if (!rgbReg.test(computedColor)) {
    return color;
  }

  return (colorCache[id] = `rgba(${
    extractRgbColor.exec(computedColor)[1]
  }, ${opacity})`);
}
function getRgbAColor ( color , opacity ) { const id = color + '&' + opacity ; if ( colorCache [ id ] ) { return colorCache [ id ] ; } const div = document . createElement ( 'div' ) ; div . style . background = color ; document . body . appendChild ( div ) ; const computedColor = window . getComputedStyle ( div ) . backgroundColor ; document . body . removeChild ( div ) ; /* istanbul ignore if */ if ( ! rgbReg . test ( computedColor ) ) { return color ; } return ( colorCache [ id ] = ` ${ extractRgbColor . exec ( computedColor ) [ 1 ] } ${ opacity } ` ) ; }
Transform a common color int oa `rgbA` color
Transform a common color int oa rgbA color