色值转RGBA
colorToRGBA(color, opacity) {
let _color
if (color.substr(0, 1) == "#")
_color = color.substring(1);
if (_color.length == 3)
_color = _color.split('').map(e => '' + e + e).join('')
if (_color.length != 6)
return '';
_color = _color.toLowerCase()
var rgb = new Array();
for (var x = 0; x < 3; x++) {
rgb[0] = _color.substr(x * 2, 2)
rgb[3] = "0123456789abcdef";
rgb[1] = rgb[0].substr(0, 1)
rgb[2] = rgb[0].substr(1, 1)
rgb[20 + x] = rgb[3].indexOf(rgb[1]) * 16 + rgb[3].indexOf(rgb[2])
}
return 'rgba(' + rgb[20] + ',' + rgb[21] + ',' + rgb[22] + ',' + opacity + ')';
}