This tiny C++ library provides simple tools for colorizing your console output. With it you can set the text color, background color, and the boldness of a text.
- Include the ColorizeText.hpp file into your project.
- In the Windows operating system, you should also clear the console screen to ensure that the colors are displayed correctly:
system("cls");
- Print things using the following syntax:
colorized_print("Your message", text_color, background_color, boldness);
// choose one of the colors below for both text_color and background_color
// boldness can be either 0 or 1
#include "ColorizeText.hpp"
int main()
{
// system("cls"); // on Windows
colorized_print("white text on black bg\n", WHITE, BLACK, 0);
colorized_print("bold white text on black bg\n", WHITE, BLACK, 1);
colorized_print("black text on white bg\n", BLACK, WHITE, 0);
colorized_print("bold black text on white bg\n", BLACK, WHITE, 1);
colorized_print("red text on cyan bg\n", RED, CYAN, 0);
colorized_print("bold red text on cyan bg\n", RED, CYAN, 1);
colorized_print("blue text on green bg\n", BLUE, GREEN, 0);
colorized_print("bold blue text on green bg\n", BLUE, GREEN, 1);
colorized_print("magenta text on yellow bg\n", MAGENTA, YELLOW, 0);
colorized_print("bold magenta text on yellow bg\n", MAGENTA, YELLOW, 1);
system("pause");
return 0;
}