I have task to work with colors. From API i got color Argb value (as i understood it's an 32 bit integer value), for example -65536, which i convert to hex using next function:
argbToHex: function(color) {
return '#'+ ('000000' + (color & 0xFFFFFF).toString(16)).slice(-6);
}
as resalt i'm getting hex color number:
#ff0000
but i need to do reverse operation, convert this hex back to Argb format with result:
-65536
i tried do something like that:
function (hex){
let parsedHex = hex.replace('#', '0x');
return parseInt(hex, 32);
}
and lot's of other variants, but nothing gave me expected result.
Any ideas?
Thanks!