How to convert a hexadecimal color code to RGB color
Hex to RGB conversion
- Get the 2 left digits of the hex color code and convert to decimal value to get the red color level.
- Get the 2 middle digits of the hex color code and convert to decimal value to get the green color level.
- Get the 2 right digits of the hex color code and convert to decimal value to get the blue color level.
Example #1: Convert red hex color code FF0000 to RGB color
- Hex = FF0000
- So the RGB colors are:
- R = FF16 = 25510
- G = 0016 = 010
- B = 0016 = 010
- RGB = (255, 0, 0)
Example #2: Convert red hex color code D4AF37 to RGB color
- Hex = D4AF37
- So the RGB colors are:
- R = D416 = 21210
- G = AF16 = 17510
- B = 3716 = 5510
- RGB = (212, 175, 55)