Hex Colors#
What are Hex Colors?#
The 24-bit Hex color model covers over 16 million colors, and each color can be defined with a code in hexadecimal, for instance #00aaff
or sometimes shortened to #0af
, that can be broken down into a RGB value:
Hex Code | 00 | aa | ff |
---|---|---|---|
RGB value | 0 | 170 | 255 |
Channel | Red | Green | Blue |
Disclaimer
Not all terminals support 24-bit colors in RGB, HSL, or Hex. If your terminal does support such advanced colors, read on.
Full Line Text Functions#
Try the hex()
and bg_hex()
methods for a full line of colored text. Allowed Hex values are, for instance, #00aaff
or #0af
, alternatively without the hash sign as 00aaff
or 0af
.
Example:
Python | |
---|---|
How it appears in the terminal:
% I want this text in coral Hex colors
% I want this background in coral Hex colors
Custom String Styling#
Or customize the styling of text and background with the ColorHex()
and BgColorHex()
classes:
Python | |
---|---|
How it appears in the terminal:
% I want to use WATERMELON RED...
% ... and MINT GREEN colors