# Pipette ## TColor

The format TColor, used in the Lazarus or Delphi programming, is also based on the RGB color model. It translates the three RGB values into a single value, which accepts the range from 0 to 16777215. This distinguishes TColor from all other presented color models, which otherwise all express the colors with a combination of several numbers (even if these numbers are pulled together in the case of the hexadecimal writing of the RGB notation in the form #RRGGBB).

## Conversion from or to the RGB Color Model

The RGB values are in the following relation to the TColor value:

TColor = R or (G shl 8) or (B shl 16)

The following relationship applies when converting the TColor value in the components R, G and B:

R = TColor and \$FF
G = (TColor shr 8) and \$FF
B = (TColor shr 16) and \$FF

The operators "shl" (shift left), "shr" (right shift), "and" and "or" are bitwise operators. This means that they work at the binary level (for example, 1101010 or 1001) rather than the numerical level (for example 2, 17 or 345). A left-shift (SHL) implies a shift of the ones and the zeros to the left by the value behind, a right-shift (shr) a shift of the ones and the zeros to the right by the value behind.

The bitwise "or" is used for two sequences of the same lenght and links couples of the same position with a logical "or" (for example: 1010 or 1100 = 1110). The bitwise "and" is used for two sequences of the same lenght and links couples of the same position with a logical "and". Here the result is 1 if both bits are 1, otherwise 0 (for example: 1010 and 1100 = 1000).

## Number of representable Colors

A maximum of 16777216 different colors can be displayed with a TColor value. This corresponds to 8 bits per red, green and blue channel (0 to 255 each). The maximum number of possible colors is therefore the same as in the hexadecimal notation #RRGGBB, in which also one byte is used for each of the three color channels.

In the program pipette, the TColor value is displayed in the line "TColor".