Integers to Colors
function toHexString(col) {
return '#' + ('000000' + col.toString(16)).substr(-6);
}
document.body.style.background = toHexString(0x275ba1);
console.log("#275ba1 as an integer:", 0x275ba1);
console.log("#ff0000 as an integer:", 0xff0000);
Convert an integer in hex (like 0xff0000
) to a usable hex string "#ff0000"
.