HLJ 发布于
2019-04-22 16:23:30

js如何将原始十进制数转换为rgba值?

JavaScript代码将十进制数转换成rgba值的方法

function ARGBtoRGBA(num) {
    num >>>= 0;
    let b = num & 0xFF,
        g = (num & 0xFF00) >>> 8,
        r = (num & 0xFF0000) >>> 16,
        a = ( (num & 0xFF000000) >>> 24 ) / 255 ;
    return "rgba(" + [r, g, b, a].join(",") + ")";
}
let x = ARGBtoRGBA(4280362283);
console.log(x);
// 输出结果:rgba(33,37,43,1)
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2019-04-22/401.html
最后生成于 2024-05-31 12:57:51
此内容有帮助 ?
0