- Ascii-art-color is a program written in Go that takes a string as input and outputs a graphic representation of the string using ASCII characters in different colors.
- The output should manipulate colors using the flag "--color=thecolor", "substring" and "string to be colored", in which --color is the flag and "thecolor" is the color desired by the user and "substring" is the substring that you can choose to be colored from the string.
- Colors can be achieved using different notations (color code systems, like RGB, hsl, ANSI...), it is up to you to choose which one you want to use.
- In the project below we implemented the RGB notation which also uses RGB hexadecimal color codes.
- Colors can be achieved using different notions i.e RGB, hsl, ANSI...
- The substring to be coloured can be a single letter or more.
- If the substring is not specified the whole string should be colored.
- The flag must have exactly the same format as mentioned above, any other formats must return the following usage message:
Usage: go run . [OPTION] [STRING]
EX: go run . --color=<color> <substring to be colored> "something"
or
go run . --color=<color> "something"
- Additionally, the program must still be able to run with a single [STRING] argument. EX: go run . [STRING]
To clone this repository, copy the command below on your terminal:
git clone https://learn.zone01kisumu.ke/git/weakinyi/ascii-art-color.git
Go to the project directory
cd ascii-art-color
- To run the program, use the command below;
go run . [OPTION] [STRING]
EX: go run . --color= "something"
- Theprogram can also run in this instances below;
go run . [OPTION] [SUBSTRING] [STRING] [BANNER]
go run . [OPTION] [SUBSTRING] [STRING]
- The program also runs with a different flag notation by using a hexadecimal representation of a color in the RGB and the hexadecimal must be seven characters i.e. for example the color code below represents red.The RGB colors should be written in lowercase letters only whereas the RGB hex color codes can use either capital or small letters.
go run . --color=yellow world
or
go run . --color=#FF0000 hello
or
go run . --color=#ff0000 hello
red, green, blue, black, white, yellow, cyan, magenta, gray, maroon, olive, purple, teal, navy, silver, lime, orange, brown, darkgreen and gold.
For the RGB hex color codes you can get them here: RGBhexcolorcodes
- Each character in the ASCII representation has a height of 8 lines.
- Characters are separated by a newline character \n.
- Incase of an empty string such as "\n" it takes a height of 1 line.
The program uses four banner files i.e. standard.txt, shadow.txt, lean.txt and thinkertoy.txt formats for graphical representation using ASCII characters:
The program automatically takes the banner format of
standard
as the default banner if no banner is specified.
To run unit tests, navigate to the project directory and run the following command:
go test -v
To format the program, navigate to the project directory and run the following command:
gofmt -w -s .