Most people know what RGB is, and maybe they know how #HEX colors are made up. By the way, for whom those have not payed attention yet, it would be interesting to know how #HEX colors are.
RGB is based on three decimal numbers between 0 and 255 for each color: Red, Green, Blue; and the #HEX color? Simply convert these decimal(base 10) RGB colors to hexadecimal(base 16) and put them in order #RGB.
Black? 0, 0, 0 and the #hex color: #000000
Green? 0, 255, 0 and the #hex color: #00FF00 (255d = FF hexadecimal)
Are You a Programmer?
function decimalToHex(theNumber) { var hex = theNumber.toString(16); return hex.length == 1 ? "0" + hex : hex; } function rgbToHex(r, g, b) { return "#" + decimalToHex(r) + decimalToHex(g) + decimalToHex(b); }