This answer解释像4280362283这样的数字是原始十进制颜色代码。我正在使用的库通过这些。转换它们的算法是什么?我已经在墙上抛出了一些这样的尝试但到目前为止没有任何问题:
console.log("Dec:", arr1[0])
let num1 = parseInt(arr1[0], 16);
console.log("Hex:", num1);
let r = parseInt(num1.toString().slice(0, 3), 16);
let g = parseInt(num1.toString().slice(3, 6), 16);
let b = parseInt(num1.toString().slice(6, 9), 16);
console.log("r, g, b:", r, g, b);
4280362283看起来像ARGB颜色可能来自Android(见下面的Kaiido评论)。以下函数来自此post
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);