Skip to content

Instantly share code, notes, and snippets.

@v3c70r
Created November 11, 2014 01:46
Show Gist options
  • Save v3c70r/79821744bacdf5356cf1 to your computer and use it in GitHub Desktop.
Save v3c70r/79821744bacdf5356cf1 to your computer and use it in GitHub Desktop.
generate a colourful dragon in terminal
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
std::string RESET = "\033[0m" ;
std::string BLACK = "\033[30m"; /* Black */
std::string RED = "\033[31m"; /* Red */
std::string GREEN = "\033[32m"; /* Green */
std::string YELLOW = "\033[33m"; /* Yellow */
std::string BLUE = "\033[34m"; /* Blue */
std::string MAGENTA= "\033[35m"; /* Magenta */
std::string CYAN = "\033[36m"; /* Cyan */
std::string WHITE = "\033[37m"; /* White */
std::string BOLDBLACK = "\033[1m\033[30m"; /* Bold Black */
std::string BOLDRED = "\033[1m\033[31m"; /* Bold Red */
std::string BOLDGREEN = "\033[1m\033[32m"; /* Bold Green */
std::string BOLDYELLOW = "\033[1m\033[33m"; /* Bold Yellow */
std::string BOLDBLUE = "\033[1m\033[34m"; /* Bold Blue */
std::string BOLDMAGENTA= "\033[1m\033[35m"; /* Bold Magenta */
std::string BOLDCYAN = "\033[1m\033[36m"; /* Bold Cyan */
std::string BOLDWHITE = "\033[1m\033[37m"; /* Bold White */
std::vector<std::string> colors = { RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN };
std::string dragon =
R"(
___====-_ _-====___
_--~~~#####// ' ` \\#####~~~--_
-~##########// ( ) \\##########~-_
-############// |\^^/| \\############-
_~############// (O||O) \\############~_
~#############(( \\// ))#############~
-###############\\ (oo) //###############-
-#################\\ / `' \ //#################-
-###################\\/ () \//###################-
_#/|##########/\######( (()) )######/\##########|\#_
|/ |#/\#/\#/\/ \#/\##| \()/ |##/\#/ \/\#/\#/\#| \|
` |/ V V ` V )|| |()| ||( V ' V /\ \| '
` ` ` ` / | |()| | \ ' '<||> '
( | |()| | )\ /|/
__\ |__|()|__| /__\______/|/
(vvv(vvvv)(vvvv)vvv)______|/
_|_|_|_|_| _|_|_| _|_|_| _| _| _|_|_|
_| _| _| _|_| _| _|
_| _|_| _| _| _| _| _| _|_|
_| _| _| _| _|_| _| _|
_| _|_|_| _|_|_| _| _| _|_|_|
01010100 01010011 01001001 01001110 01000111
)";
int main()
{
std::stringstream sstream(dragon);
std::string line;
int colorIdx = 0;
while (std::getline(sstream, line)) {
std::cout << colors[colorIdx] <<line<<RESET << std::endl;
colorIdx = (colorIdx+1)%colors.size();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment