复制代码//十六进制颜色码转换成RGB颜色值
function transformationRGB(hex = '7F7A09') {
let regSplit = /([0-9a-fA-F]{2})/,
rgb = hex.split(regSplit);
rgb = rgb.filter(item => item != "");
rgb = rgb.map(item => parseInt('0x' + item));
return rgb;
}
console.log(transformationRGB('396B5A')); //(3) [57, 107, 90]
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
上面是“十六进制颜色码转换成RGB颜色值”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4069.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!