Convert 8-bit integer to Hex color value in JavaScript
Posted: 02 Dec 2020, 05:57
I'm trying to convert 8-bit integer to Hex color value. (e.g. FFFFFF)
The 8-bit color integer is generated with the following formula:
In C, it is done by:
How can I convert this 8-bit integer value to Hex color value in Javascript?
The 8-bit color integer is generated with the following formula:
Code: Select all
color = ( [red] * 65536) + ( [green] * 256) + ( [blue] * 1)
Code: Select all
sprintf(colorbuf, "#%6.6x", color);