GithubHelp home page GithubHelp logo

a13xe / colorizetexthpp Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 24 KB

C++ Header File For Colorizing Console Text Output

Home Page: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

C++ 100.00%
colored-output colored-text header header-only text-color text-coloring linux macos windows hpp-library

colorizetexthpp's Introduction

๐ŸŽจ 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

colorizetexthpp's People

Contributors

a13xe avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.