十进制、十六进制、RGBA颜色值之间的相互转换
10进制转rgba
// 10进制转rgba
function decToRgba(number) {
const blue = number & 0xff;
const green = number >> 8 & 0xff;
const red = number >> 16 & 0xff;
number = number >> 24 & 0xff;
const alpha = (number / 0xff).toFixed(2);
return `rgba(${
red}, ${
green}, ${
blue}, ${
alpha})`;
}
rgb转16进制
// rgb转16进制
function rgbToHex(rgb) {
const regexp = /[0-9]{0,3}/g;
const re = rgb.match(regexp).filter(f => f).map