import transparency from './transparency'
//rgba转成16进制
export function hexify(color: string) {
  if (color) {
      let opacity = '',
          rgb = color.split(','),
          r = parseInt(rgb[0].split('(')[1]),
          g = parseInt(rgb[1]),
          b = parseInt(rgb[2].split(')')[0]),
          a = Number(rgb[3].split(')')[0] || 1) * 100

      transparency.forEach((i, index) => {
          if (index == a) {
              opacity = i
          }
      })

      var hex = '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1) + opacity
      
      return hex
  } else {
      return
  }
}