# What is RGB and Hex?

## What's RGB?

RGB is one of the color space models described by the RGB coordinates. Its name is derived from the first letters of the color names: R - red, G - green, and B - blue, of which this model is composed. It is a model resulting from the perception properties of the human eye, in which the impression of seeing any color can be evoked by mixing in fixed proportions three beams of light of red, green, and blue.

The RGB model is widely used in image analysis devices (e.g. digital cameras, scanners) and image display devices (e.g. TV sets, computer monitors).

From a combination of RGB colors in any quantitative combination, a wide range of derivative colors can be obtained, e.g. a combination of green and red produces yellow. For the RGB space an additive synthesis is applied, where the lowest values mean black and the highest values mean white. However, the RGB model is theoretical, and its representation depends on the device, which means that in each device each of the RGB components may have slightly different spectral characteristics, and thus, each of the devices may have its range of colors possible to obtain.

Colour recording as RGB is often used in computer science (e.g. color palettes in graphic files, in Html files). The most commonly used is 24-bit color writing (8 bits for each of the component colors), in which each of the colors is written using the components that take a value from the range 0-255. In the RGB model, the value 0 of all the components gives a black color, while 255 - white color.

The RGB colour can be calculated from the formula: `colour number = R ⋅ 65536 + G ⋅ 256 + B` where R, G, and B take a value between 0 and 255.

## What is the Hex triplet

A hexadecimal record consists of six hexadecimal digits (three bytes). According to the RGB (red, green, blue) model, the bytes are red, green, and blue. Each byte can take a value from 00 (0) to FF (255), which means the lowest and highest intensity of a given color respectively.

Even if the intensity of a color is less than 16 (which gives one digit in hexadecimal notation), the notation has 6 digits. For example, one of the dark blue hues, where the intensity of red is A, green 2, and blue 66, is 0A0266. The recording can only be shortened if each byte consists of two identical digits, e.g. the example AABBCC can be written as ABC.

In this system you can write `256 × 256 × 256 = 16777216` different colors.

The hexadecimal record is used in HTML and CSS, SVG vector graphics format, and other applications. Converting hexadecimal to RGB is about saving the decimal values of consecutive pairs of hexadecimal digits, e.g. 0FAB40 = RGB(15, 171, 64).