How to add Transparency information to a HEX color code?

Posted by TK123 on Stack Overflow See other posts from Stack Overflow or by TK123
Published on 2013-11-05T21:52:26Z Indexed on 2013/11/05 21:53 UTC
Read the original article Hit count: 145

Filed under:
|
|

I have to modify some code and the previous developer left this comment:

color: color, // e.g. '#RRGGBBFF' - Last 2 digits are alpha information

On the page there is a color picker that let's the user change text color. It gives HEX values like so:

#RRGGBB

And there is a slider that allows the user to change a text's transparency. It runs from 0.1 to 1

Somehow I need to get a 2 digit letter from this transparency amount and append it to the HEX value for it to work.

Does anyone know how to append Alpga information to HEX color codes? What is the math formula for it?

I guess the question can also be answered if anyone knows how to concert RGBA color values with transparency into HEX:

rgba(255, 255, 255, 0.6)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about math