How Hex Color Codes Work


Most Internet graphics software program applications convert RGB to Hex with no blink. And for many tasks, you will definitely wish to use a instrument for making these sorts of calculations. Nonetheless, if you would like to know what’s taking place behind the scenes, and perhaps do your personal math to create hex coloration codes, here is the way it works.

When you’re conversant in RGB, you realize {that a} particular color hex map is represented by a set of three completely different numbers: one for crimson (R), one for inexperienced (G), and one for blue (B). For instance, the RGB values for a darkish, grassy inexperienced could be:

R=77

B=131

G=50

With hex codes, a particular coloration is represented by a single code, which incorporates a mixture of six letters and numbers. To vary the three RGB values above right into a single hex code, we’ll have to make just a few conversions. First take your first RGB quantity and divide that by 16. You may drop the rest for now and simply write down the entire quantity. This would be the first character in your hex code.

R – 77 / 16 = 4.812 = 4 (first character in code)

Subsequent take the rest and multiply that by 16. Be sure you spherical up the ultimate quantity. This would be the second character in your hex code.

.812 x 16 = 12.99 = 13 (second character in code)

However wait…13 cannot be a single character in a hex coloration code. So we have to use a letter code as an alternative. Numbers between 10 and 15 must be changed with the letters A by way of F (A=10, B=11, C=12, and so forth). In my instance, meaning the second character I got here up with (13) will now be the letter “D.” That makes the primary character in my hex code seem like this: 4D. That is higher. Repeat the entire course of above for every RGB quantity, and presto, you’ve got transformed RGB to Hex!


Leave a Reply

Your email address will not be published. Required fields are marked *