Skip to content

a13xe/ColorizeTextHpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

🎨 Text Colorizer for C++

👁️ Overview

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.

🔰 Getting Started

  • 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

BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE BRIGHT_BLACK BRIGHT_RED BRIGHT_GREEN BRIGHT_YELLOW BRIGHT_BLUE BRIGHT_MAGENTA BRIGHT_CYAN BRIGHT_WHITE

🕹️ Example

#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;
}

📷 Screenshots