Turn red, green and blue numbers into the HEX code CSS and design tools expect. Handy when you have sampled a colour from an image, pulled values out of a canvas, or received brand colours specified in RGB and need them in a stylesheet.
Some graphics environments, including OpenGL and certain design tools, normalise channels to 0 through 1. Multiply each by 255 and round before entering them here.
They are clamped to the valid range, because 24-bit colour cannot represent anything beyond it.
Convert the three colour channels here, then append the alpha as a fourth hex pair. An alpha of 0.5 becomes roughly 80, giving an eight-digit code.
Colour management. The same RGB triplet can render differently across displays and colour profiles. The values are exact; the perceived appearance depends on the screen.